| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- using System.Collections;
- using System.Text.RegularExpressions;
- using Common;
- using LitJson;
- using Microsoft.CodeAnalysis.CSharp.Scripting;
- namespace Task
- {
- public class MakeHelper
- {
- public readonly static MakeHelper Instance = new MakeHelper();
- private MakeHelper()
- { }
- public void Start(string QueueName)
- {
- RabbitMQClient.Instance.StartReceive(QueueName, content => DoWorks(content));
- }
- public void DoWorks(string content)
- {
- try
- {
- if (!string.IsNullOrEmpty(content))
- {
- DoQueue(content);
- }
- }
- catch (Exception ex)
- {
- Utils.WriteLog(DateTime.Now.ToString() + "\n" + ex, "生成异常");
- }
- }
- public void DoQueue(string content)
- {
- JsonData jsonObj = JsonMapper.ToObject(content);
- //流水号
- string requestId = jsonObj["requestId"].ToString();
- //模板文件路径
- string modePath = jsonObj["modePath"].ToString();
- //附加数据,原样返回
- string attach = jsonObj["attach"].ToString();
- //读取模板文件内容
- string templateString = Function.ReadInstance("Template/" + modePath);
- //解析模板内容
- string resultString = Util.Maker.StartMake(jsonObj["data"], templateString);
- //MQ回调解析的结果
- RabbitMQClient.Instance.Push("MakeSqlCallBackQueue", requestId + "#cut#" + attach + "#cut#" + resultString);
- }
- }
- }
|