Kaynağa Gözat

清除多余的代码文件

linhong 3 yıl önce
ebeveyn
işleme
4b81a53c24

+ 18 - 18
Controllers/TestController.cs

@@ -1,4 +1,5 @@
-using Microsoft.AspNetCore.Http.Extensions;
+using LJLib.Client;
+using Microsoft.AspNetCore.Http.Extensions;
 using Microsoft.AspNetCore.Mvc;
 using System;
 using System.Collections.Generic;
@@ -19,23 +20,22 @@ namespace LJProxy.Controllers
             _clientFactory = clientFactory;
         }
 
-        [Route("postapi/{apiName}")]
-        [HttpPost]
-        public async Task<IActionResult> PostApi(string apiName)
-        {
-            string requestBody;
-            using (StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8))
-            {
-                requestBody = await reader.ReadToEndAsync();
-            }
-            string url = $"http://127.0.0.1:58966/api/l1svr/svr/{apiName}";
-            var content = new StringContent(requestBody, Encoding.UTF8,"application/json");
-            var client = _clientFactory.CreateClient();
-            var response = await client.PostAsync(url, content);
-            string result = await response.Content.ReadAsStringAsync();
-            return Content(result, "application/json");
-
-        }
+        //[HttpGet]
+        //[Route("test")]
+        //public string test()
+        //{
+        //    var creator = new DirectP1ClientCreator("192.168.0.92", Convert.ToInt32("7940"));
+        //    var pool = new LJClientPool(creator, 20);
+        //    var loginObj = new
+        //    {
+        //        accountname = "CRP1",
+        //        userid = "admin",
+        //        psw = "longjoe",
+        //        clientType = 10
+        //    };
+        //    var result=pool.DoExcute("ClientLogin", Newtonsoft.Json.JsonConvert.SerializeObject(loginObj));
+        //    return result;
+        //}
 
     }
 }

+ 0 - 66
Excutor/CheckUpdateExcutor.cs

@@ -1,66 +0,0 @@
-using LJProxy.LJLib.Net.SPI.Server;
-using LJProxy.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.IO;
-using LJLib;
-using Microsoft.AspNetCore.Mvc;
-
-namespace LJProxy.Excutor
-{
-    public class CheckUpdateExcutor : ExcutorBase<CheckUpdateRequest>
-    {
-        private static object _syncRoot = new object();
-        protected override IActionResult ExcuteInternal(CheckUpdateRequest request, object state)
-        {
-            CheckUpdateResponse rslt = new CheckUpdateResponse();
-            rslt.ErrCode = "0";
-            if (string.IsNullOrEmpty(request.CurrentVersion))
-            {
-                rslt.ErrMsg = "CurrentVersion can not be empty";
-                return new JsonResult(rslt);
-            }
-
-            var apkDirs =@$"{AppDomain.CurrentDomain.BaseDirectory}apk\";
-            if (!Directory.Exists(apkDirs))
-            {
-                rslt.ErrMsg = "apk file folder not exists";
-                return new JsonResult(rslt);
-            }
-
-            //cache file version
-            string newVersion = string.Empty;
-            string cacheKey = "NewestApkVersion";
-            lock (_syncRoot)
-            {
-                newVersion = Cache.DefaultCache.Get(cacheKey) as string;
-                if (string.IsNullOrEmpty(newVersion))
-                {
-                    var dirinfo = new DirectoryInfo(apkDirs);
-                    var file = dirinfo.GetFiles()
-                        .Where(x => x.Name.EndsWith(".apk", StringComparison.CurrentCultureIgnoreCase))
-                        .OrderByDescending(x => x.LastWriteTime).FirstOrDefault();
-                    if (file == null)
-                    {
-                        rslt.ErrMsg = "can not found apk";
-                        return new JsonResult(rslt);
-                    }
-
-                    APKHelper apkHelper = new APKHelper();
-                    newVersion = apkHelper.GetVersionName(file.FullName);
-                    //TODO:文件夹缓存依赖不生效,待扩展
-                    Cache.DefaultCache.Add(cacheKey, newVersion, Cache.CreateCacheItemPolicy(null, DateTime.Now.AddMinutes(30), new List<string>() { file.FullName }));
-                }
-            }
-
-            if (string.Compare(newVersion, request.CurrentVersion) > 0)
-            {
-                rslt.ErrCode = "1";
-                rslt.NewVersion = newVersion;
-            }
-            return new JsonResult(rslt);
-        }
-
-    }
-}

+ 0 - 41
Excutor/GetAppUpdateExcutor.cs

@@ -1,41 +0,0 @@
-using LJProxy.LJLib.Net.SPI.Server;
-using LJProxy.Models;
-using LJProxy.Services;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text.RegularExpressions;
-using System.Threading.Tasks;
-
-namespace LJProxy.Excutor
-{
-    public class GetAppUpdateExcutor : ExcutorBase<GetAppUpdateRequest>
-    {
-        VersionService _service = new VersionService();
-        protected override IActionResult ExcuteInternal(GetAppUpdateRequest request, object state)
-        {
-            HttpRequest httpRequest = state as HttpRequest;
-            Regex regx = new Regex(@"GetAppUpdate/(?<apkName>.*?\.apk)", RegexOptions.IgnoreCase);
-            var matchResult=regx.Match(httpRequest.Path.ToString());
-            if (matchResult.Success)
-            {
-                var apkName = matchResult.Groups["apkName"]?.Value;
-                var fs = _service.GetAPK(apkName);
-                if (fs==null)
-                {
-                    return new NotFoundResult();
-                }
-                else
-                {
-                    return new FileContentResult(fs, "application/vnd.android.package-archive");
-                }
-            }
-            else
-            {
-                return new NotFoundResult();
-            }
-        }
-    }
-}

+ 0 - 22
Excutor/GetProxyDomainListExcutor.cs

@@ -1,22 +0,0 @@
-using LJProxy.LJLib.Net.SPI.Server;
-using LJProxy.Models;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Excutor
-{
-    public class GetProxyDomainListExcutor : ExcutorBase<GetProxyDomainListRequest>
-    {
-        protected override IActionResult ExcuteInternal(GetProxyDomainListRequest request, object state)
-        {
-            GetProxyDomainListResponse rslt = new GetProxyDomainListResponse();
-            rslt.ErrMsg = "";
-            rslt.DomainList = GlobalVar.Setting.ProxyDomainList;
-            return new JsonResult(rslt);
-        }
-        
-    }
-}

+ 0 - 25
Excutor/GetUpdateJsonExcutor.cs

@@ -1,25 +0,0 @@
-using LJProxy.LJLib.Net.SPI.Server;
-using LJProxy.Models;
-using LJProxy.Services;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace LJProxy.Excutor
-{
-    public class GetUpdateJsonExcutor : ExcutorBase<GetUpdateJsonRequest>
-    {
-        VersionService _service = new VersionService();
-        protected override IActionResult ExcuteInternal(GetUpdateJsonRequest request, object state)
-        {
-            string updateJson = _service.GetUpdateJson();
-            var result = new ContentResult();
-            result.Content = updateJson;
-            result.ContentType = "application/json";
-            return result;
-        }
-    }
-}

+ 0 - 85
Excutor/GetUpdatePkgExcutor.cs

@@ -1,85 +0,0 @@
-using LJLib;
-using LJLib.Net.SPI.Com;
-using LJLib.Tools.Encry;
-using LJProxy.LJLib.Net.SPI.Server;
-using LJProxy.Models;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Excutor
-{
-    public class GetUpdatePkgExcutor : ExcutorBase<GetUpdatePkgRequest>
-    {
-        private static object _syncRoot = new object();
-
-
-        protected override IActionResult ExcuteInternal(GetUpdatePkgRequest request, object state)
-        {
-            GetUpdatePkgResponse rslt = new GetUpdatePkgResponse();
-            rslt.ErrCode = "0";
-
-            var apkDirs = @$"{AppDomain.CurrentDomain.BaseDirectory}apk\";
-            if (!Directory.Exists(apkDirs))
-            {
-                rslt.ErrMsg = "apk file folder not exists";
-                return new JsonResult(rslt);
-            }
-
-            //cache file version
-            GetUpdatePkgResponse apkInfo = null;
-            string cacheKey = "NewestApkData";
-            lock (_syncRoot)
-            {
-                apkInfo = Cache.DefaultCache.Get(cacheKey) as GetUpdatePkgResponse;
-                if (apkInfo == null)
-                {
-                    var dirinfo = new DirectoryInfo(apkDirs);
-                    var file = dirinfo.GetFiles()
-                        .Where(x => x.Name.EndsWith(".apk", StringComparison.CurrentCultureIgnoreCase))
-                        .OrderByDescending(x => x.LastWriteTime).FirstOrDefault();
-                    if (file == null)
-                    {
-                        rslt.ErrMsg = "can not found apk";
-                        return new JsonResult(rslt);
-                    }
-
-                    byte[] apkData = null;
-                    using (var fs = file.OpenRead())
-                    using (var ms = new MemoryStream())
-                    {
-                        byte[] buff = new byte[10240];
-                        int read = 0;
-                        int total = 0;
-                        while ((read = fs.Read(buff, 0, buff.Length)) > 0)
-                        {
-                            ms.Write(buff, 0, read);
-                            ms.Flush();
-                            total += read;
-                        }
-                        apkData = ms.ToArray();
-                    }
-
-                    APKHelper apkHelper = new APKHelper();
-                    var md5Helper = new MD5();
-                    var clientVer = apkHelper.GetVersionName(apkData);
-                    apkInfo = new GetUpdatePkgResponse();
-                    apkInfo.Version = clientVer;
-                    apkInfo.ApkData = apkData;
-                    apkInfo.Checksum = md5Helper.GetMD5(apkData);
-                    //TODO:文件夹缓存依赖不生效,待扩展
-                    Cache.DefaultCache.Add(cacheKey, apkInfo, Cache.CreateCacheItemPolicy(null, DateTime.Now.AddMinutes(30), new List<string>() { file.FullName }));
-                }
-            }
-
-            rslt.Version = apkInfo.Version;
-            rslt.ApkData = apkInfo.ApkData;
-            rslt.Checksum = apkInfo.Checksum;
-            return new JsonResult(rslt);
-        }
-
-    }
-}

+ 0 - 30
GlobalVar/GlobalVar.cs

@@ -1,6 +1,4 @@
 using LJLib.Net.SPI.Com;
-using LJProxy.Excutor;
-using LJProxy.LJLib.Net.SPI.Server;
 using LJProxy.Models;
 using System;
 using System.Collections.Generic;
@@ -15,34 +13,6 @@ namespace LJProxy
 {
     public static class GlobalVar
     {
-        private static ExcutorManager excutorManager = null;
-        static GlobalVar()
-        {
-            InitExcutorMap();
-        }
-
-        private static void InitExcutorMap()
-        {
-            excutorManager = new ExcutorManager();
-
-            excutorManager.AddMap(new CheckUpdateRequest().GetApiName(), typeof(CheckUpdateRequest), new CheckUpdateExcutor());
-            excutorManager.AddMap(new GetUpdatePkgRequest().GetApiName(), typeof(GetUpdatePkgRequest), new GetUpdatePkgExcutor());
-            excutorManager.AddMap(new GetProxyDomainListRequest().GetApiName(), typeof(GetProxyDomainListRequest), new GetProxyDomainListExcutor());
-            excutorManager.AddMap(new GetUpdateJsonRequest().GetApiName(), typeof(GetUpdateJsonRequest), new GetUpdateJsonExcutor());
-            excutorManager.AddMap(new GetAppUpdateRequest().GetApiName(), typeof(GetAppUpdateRequest), new GetAppUpdateExcutor());
-        }
-
-        public static Tuple<bool,IActionResult> Excute(string apiName,string requestBody,object requestState)
-        {
-            var requestType = excutorManager.GetRequestType(apiName);
-            if (requestType == null) return new Tuple<bool, IActionResult>(false, null);
-            ILJRequest request = null;
-            if(!string.IsNullOrEmpty(requestBody)) request = JObject.Parse(requestBody).ToObject(requestType) as ILJRequest;
-            else request = new JObject().ToObject(requestType) as ILJRequest;
-            var result = excutorManager.DoExcute( request, requestState);
-            return new Tuple<bool, IActionResult>(true, result);
-        }
-
         public static AppSettings Setting { get; private set; }
 
         public static void InitSetting(IConfiguration configuration)

+ 0 - 30
LJLib.Net.SPI.Server/ExcutorBase.cs

@@ -1,30 +0,0 @@
-using LJLib.Net.SPI.Com;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.LJLib.Net.SPI.Server
-{
-    public abstract class ExcutorBase
-    {
-        public abstract IActionResult Excute(ILJRequest request,object state);
-    }
-
-    public abstract class ExcutorBase<T1>:ExcutorBase where T1: class,ILJRequest
-    {
-        protected abstract IActionResult ExcuteInternal(T1 request, object state);
-        public override IActionResult Excute(ILJRequest request, object state)
-        {
-            T1 req = request as T1;
-            if (req == null)
-            {
-                ErrResponse err = new ErrResponse(string.Format("request 不能转换成类型[{0}]", typeof(T1).Name));
-                return new JsonResult(err);
-            }
-            var rslt = ExcuteInternal(req, state);
-            return rslt;
-        }
-    }
-}

+ 0 - 32
LJLib.Net.SPI.Server/ExcutorManager.cs

@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.LJLib.Net.SPI.Server
-{
-    public sealed class ExcutorManager:LJServerBase
-    {
-        private Dictionary<string, ExcutorBase> excutors = new Dictionary<string, ExcutorBase>();
-        private Dictionary<string, string> dynamicHtmlDic = new Dictionary<string, string>();
-
-        public void AddMap(string apiName, Type requestType, ExcutorBase excutor, string dynamicHtml = null)
-        {
-            excutors[apiName] = excutor;
-            this.AddMap(apiName, requestType, excutor.Excute);
-            if (!string.IsNullOrEmpty(dynamicHtml))
-            {
-                dynamicHtmlDic[dynamicHtml] = apiName;
-            }
-        }
-
-        public string getDynamicHtmlApi(string url)
-        {
-            if (dynamicHtmlDic.ContainsKey(url))
-            {
-                return dynamicHtmlDic[url];
-            }
-            return null;
-        }
-    }
-}

+ 0 - 48
LJLib.Net.SPI.Server/LJServerBase.cs

@@ -1,48 +0,0 @@
-using LJLib.Net.SPI.Com;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.LJLib.Net.SPI.Server
-{
-    public abstract class LJServerBase
-    {
-        public delegate IActionResult DHandle(ILJRequest request, object state);
-        protected Dictionary<string, DHandle> handlers = new Dictionary<string, DHandle>(StringComparer.OrdinalIgnoreCase);
-        protected Dictionary<string, Type> requestTypes = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
-
-        public IActionResult DoExcute(ILJRequest request, object state)
-        {
-            if (!handlers.ContainsKey(request.GetApiName()))
-            {
-                throw new Exception("接口未定义:" + request.GetApiName().ToString());
-            }
-            var handler = handlers[request.GetApiName()];
-            if (handler == null)
-            {
-                throw new Exception("接口未定义:" + request.GetApiName().ToString());
-            }
-            return handler(request, state);
-        }
-
-        public Type GetRequestType(string apiName)
-        {
-            if (requestTypes.ContainsKey(apiName))
-            {
-                return requestTypes[apiName];
-            }
-            else
-            {
-                return null;
-            }
-        }
-
-        public void AddMap(string apiName,Type requestType,DHandle handler)
-        {
-            requestTypes[apiName] = requestType;
-            handlers[apiName] = handler;
-        }
-    }
-}

+ 0 - 18
Models/CheckUpdate.cs

@@ -1,18 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class CheckUpdateRequest : LJRequest
-    {
-        public string CurrentVersion { get; set; }
-    }
-
-    public class CheckUpdateResponse:LJResponse
-    {
-        public string NewVersion { get; set; }
-    }
-}

+ 0 - 12
Models/GetAppUpdate.cs

@@ -1,12 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class GetAppUpdateRequest: LJRequest
-    {
-    }
-}

+ 0 - 13
Models/GetUpdateJson.cs

@@ -1,13 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class GetUpdateJsonRequest: LJRequest
-    {
-    }
-
-}

+ 0 - 20
Models/GetUpdatePkg.cs

@@ -1,20 +0,0 @@
-using LJLib.Net.SPI.Com;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace LJProxy.Models
-{
-    public class GetUpdatePkgRequest : LJRequest
-    {
-        
-    }
-
-    public class GetUpdatePkgResponse : LJResponse
-    {
-        public string Version { get; set; }
-        public byte[] ApkData { get; set; }
-        public string Checksum { get; set; }
-    }
-}

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1 - 1
Properties/PublishProfiles/FolderProfile.pubxml.user