| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System.Collections;
- using System.Text.RegularExpressions;
- using System.Web;
- using Common;
- using Customer.Source;
- using Infrastructure;
- using LitJson;
- using Microsoft.CodeAnalysis.CSharp.Scripting;
- using Model;
- using Services;
- using Util;
- using Util.MakeApp;
- namespace Tasks
- {
- public class MakeAppHelper
- {
- public readonly static MakeAppHelper Instance = new MakeAppHelper();
- private MakeAppHelper()
- { }
- public void Start(string QueueName)
- {
- // RabbitMQClient.Instance.StartReceive(QueueName, content => DoWorks(content));
- Thread th = new Thread(poscheck);
- th.IsBackground = true;
- th.Start(QueueName);
- }
- public void poscheck(object QueueName)
- {
- while (true)
- {
- string content = RedisServer.Cache.RPop<string>(QueueName.ToString());
- if (!string.IsNullOrEmpty(content))
- {
- DoWorks(content);
- Thread.Sleep(1000);
- }
- else
- {
- Thread.Sleep(2000);
- }
- }
- }
- public void DoWorks(string content)
- {
- if (!string.IsNullOrEmpty(content))
- {
- DoQueue(content);
- }
- }
- public string DoQueue(string content, bool push = true)
- {
- try
- {
- JsonData jsonObj = JsonMapper.ToObject(content);
- //流水号
- string requestId = jsonObj["requestId"].ToString();
- //附加数据,原样返回
- JsonData attach = JsonMapper.ToObject(jsonObj["attach"].ToString());
- string appKind = attach["appKind"].ToString();
- if (appKind.EndsWith("project_sycn"))
- {
- string kind = appKind.Substring(0, appKind.IndexOf("_"));
- GitHelper git = new GitHelper("AppTemplate/" + kind);
- if (string.IsNullOrEmpty(Function.ReadInstance(kind + "_project_sycn.txt")))
- {
- git.Clone($"https://repos.kexiaoshuang.com/omega/omega-" + kind + "-framework.git", "lichunlei", "8604515", "master");
- Function.WritePage("/", kind + "_project_sycn.txt", "1");
- }
- else
- {
- git.PullCode("lichunlei", "8604515", "lichunlei", "35013854@qq.com");
- }
- return "ok";
- }
- string fileName = jsonObj["data"]["fileName"].ToString();
- AppProject project = Newtonsoft.Json.JsonConvert.DeserializeObject<AppProject>(jsonObj["data"]["appProject"].ToString()) ?? new AppProject();
- AppProjectVersion version = Newtonsoft.Json.JsonConvert.DeserializeObject<AppProjectVersion>(jsonObj["data"]["appProjectVersion"].ToString()) ?? new AppProjectVersion();
- List<AppModule> smodules = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppModule>>(jsonObj["data"]["appModules"].ToString()) ?? new List<AppModule>();
- List<AppProjectModule> modules = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppProjectModule>>(jsonObj["data"]["appProjectModules"].ToString()) ?? new List<AppProjectModule>();
- List<AppProjectParam> paramList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppProjectParam>>(jsonObj["data"]["appProjectParams"].ToString()) ?? new List<AppProjectParam>();
- List<AppModuleFile> fileList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppModuleFile>>(jsonObj["data"]["appModulesFiles"].ToString()) ?? new List<AppModuleFile>();
- List<AppProjectPage> pages = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppProjectPage>>(jsonObj["data"]["appProjectPages"].ToString()) ?? new List<AppProjectPage>();
- List<AppProjectBottom> bottoms = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppProjectBottom>>(jsonObj["data"]["appProjectBottoms"].ToString()) ?? new List<AppProjectBottom>();
- if (appKind == "Android")
- {
- List<AppModuleAndroidCode> codes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppModuleAndroidCode>>(jsonObj["data"]["appModulesAndroidCode"].ToString()) ?? new List<AppModuleAndroidCode>();
- MakeAndroidCode.MakerFile(fileName, project, version, smodules, codes, modules, paramList, fileList, pages, bottoms);
- }
- else if (appKind == "ios")
- {
- List<AppModuleIosCode> codes = Newtonsoft.Json.JsonConvert.DeserializeObject<List<AppModuleIosCode>>(jsonObj["data"]["appModulesIosCode"].ToString()) ?? new List<AppModuleIosCode>();
- MakeAppleCode.MakerFile(fileName, project, version, smodules, codes, modules, paramList, fileList, pages, bottoms);
- }
- return "ok";
- }
- catch (Exception ex)
- {
- Utils.WriteLog(DateTime.Now.ToString() + "--" + ex, "生成异常");
- return "";
- }
- }
- }
- }
|