using BaiDuSdk; using CommonUtil; using CommonUtil.RabbitMQ; using Newtonsoft.Json.Linq; using Operater.DAL; using Operater.DTO.System; using Operater.Service.System; using ProductDistribution.Handle; using System; using static CommonUtil.RabbitMQ.MQClientFullChannel; namespace ProductDistribution { class Program { /// /// 店铺铺货 /// /// static void Main(string[] args) { if (false) { ProductDistributionMq mq = new ProductDistributionMq() { TaskId="1000" }; ProductCheckHandle.MainMethod(mq); Console.WriteLine("执行完成"); Console.ReadLine(); } Console.Title = "铺货处理"; //string str = "{\"TaskId\":\"111\"}"; //HandleExecute(str); MainMethod(); } public static void HandleExecute(string message) { Console.WriteLine(message); ProductDistributionMq msg = JSONUtil.JsonToObject(message); switch (msg.TaskType) { case 1://代发商品铺货单获取 Console.WriteLine("代发商品铺货单获取任务"); DistributebillGetHandle.MainMethod(msg); break; case 2://批量修改 Console.WriteLine("批量修改任务"); BatchUpdatePriceHandle.MainMethod(msg); break; default://铺货 Console.WriteLine("铺货任务"); ProductDistribute.MainMethod(message); break; } Console.WriteLine("任务执行完成!"); } #region 主方法 private static void MainMethod() { try { MQClientFullChannel mQClientFullChannel = new MQClientFullChannel("product_distribution"); mQClientFullChannel.reConnectTime = 8000; mQClientFullChannel.OnMessage += OnMessage; mQClientFullChannel.OnConnected += OnConnected; mQClientFullChannel.OnDisConnected += OnDisConnected; mQClientFullChannel.Connect(0); Console.WriteLine("工具已正常开启--"); Console.ReadLine(); } catch { } } public static void OnMessage(EventMessageResultCluster result) { HandleExecute(result.Content); } public static void OnConnected(MQClientParam param) { // Console.WriteLine(JSONUtil.ObjectToJson(param) + " --> 链接成功"); } public static void OnDisConnected(MQClientParam param) { // Console.WriteLine(JSONUtil.ObjectToJson(param) + " --> 链接关闭"); } #endregion } }