Пример #1
0
        public void StartHanlerWork()
        {
            Config19e cf19e = new Config19e();

            if (config is Config19e)
            {
                cf19e = config as Config19e;
            }
            if (cf19e.IsCloseSync)//关闭同步,全取
            {
                this.Recp.ReceiveAllPolicy();
            }
            else//同步
            {
                //Task.Factory.StartNew(() =>
                //{
                //while (true)
                // {

                this.Recp.SyncPolicy();
                //if (importCts.Token.IsCancellationRequested)
                //{
                //    LogContext log = new LogContext();
                //    string logPath = System.IO.Directory.GetCurrentDirectory() + "\\LogContext\\19eFinished\\" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt";
                //    log.AddLogInfo(logPath, "线程终止!时间:" + DateTime.Now, false);
                //}
                // Thread.Sleep(Convert.ToInt32(timeSpan) * 1000);
                // }
                // }, importCts.Token);
            }
        }
Пример #2
0
        public override RunTaskResult RunTask()
        {
            RunTaskResult taskResult = new RunTaskResult()
            {
                Success = true, Result = "执行完毕"
            };

            try
            {
                AutoMapperConfiguration.Configure();
                Config19e config = new Config19e
                {
                    AppCode19e        = CustomConfig["appCode_19e"],
                    IsCloseSync       = Convert.ToBoolean(CustomConfig["IsCloseSync19e"]),
                    PerPageSize       = CustomConfig["PerPageSize19e"],
                    SafeCode19e       = CustomConfig["safeCode_19e"],
                    TimeSpan19e       = CustomConfig["timespan_19e"],
                    Username19e       = CustomConfig["username_19e"],
                    QueueHost         = CustomConfig["queueHost"],
                    QueueName         = CustomConfig["queueName"],
                    IsSendPolicyQueue = Boolean.Parse(CustomConfig["isSendPolicyQueue"])
                };
                IHandlerForPolicy handler = new HandlerFor19eFactory().Create(config);
                handler.onWorklingMsg += handler_onWorklingMsg;
                handler.StartHanlerWork();
            }
            catch (Exception ex)
            {
                ShowRunningLog("抛出异常:" + ex.Message.ToString());
                taskResult = new RunTaskResult {
                    Success = false, Result = ex.Message
                };
            }
            return(taskResult);
        }
Пример #3
0
        public HandlerFor19e(GlobalConfig cf)
        {
            config = cf;

            Config19e cf19e = new Config19e();

            if (cf is Config19e)
            {
                cf19e = cf as Config19e;
            }
            this.Recp = new RecPolicy19eFactory().Create(cf19e);
            this.Recp.onWorklingMsg += Recp_onWorklingMsg;
        }
Пример #4
0
 public abstract IRecPolicy Create(Config19e config);
 public RecPolicy19eHelper(Config19e cf19e)
 {
     Config = cf19e;
 }
Пример #6
0
        static void Main(string[] args)
        {
            //new ReceiveKGTask().RunTask();
            // new SyncPolicyTask().RunTask();

            #region 接收政策
            AutoMapperConfiguration.Configure();
            Config19e config = new Config19e
            {
                AppCode19e        = "19",
                IsCloseSync       = false,
                PerPageSize       = "300",
                SafeCode19e       = "[66USljYj[3S#lkk3T#930Yj#93*j93&",
                TimeSpan19e       = "2000",
                Username19e       = "18618001265",
                QueueHost         = "private$",
                QueueName         = "policyQueue",
                IsSendPolicyQueue = false
            };
            IHandlerForPolicy handler = new HandlerFor19eFactory().Create(config);
            // handler.onWorklingMsg += handler_onWorklingMsg;
            handler.StartHanlerWork();
            #endregion

            #region 监听队列
            //Console.WriteLine("队列监听中...");
            //MessageQueue x = new MessageQueue(".\\private$\\warningpolicyupdatequeue");
            //System.Messaging.Message myMessage = x.Receive(MessageQueueTransactionType.Single);
            //myMessage.Formatter = new BinaryMessageFormatter();
            //List<Policies> lstPolicies = myMessage.Body as List<Policies>;
            //try
            //{
            //    lstPolicies.ForEach(x1 =>
            //    {
            //        x1.Id = 0;
            //    });
            //    if (lstPolicies == null || lstPolicies.Count <= 0)
            //    {
            //        Console.WriteLine("未从队列中收到任何政策更新包!");
            //        return;
            //    }
            //    File.WriteAllText("d://1.txt", JsonConvert.SerializeObject(lstPolicies));
            //    new MessageQueueHelper().SendMsgToQueue("policyupdatequeue", lstPolicies, MessagePriority.Normal, "private$");
            //    UploadPolicy(lstPolicies, "policyupdatequeue", "private$");
            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine("监听队列异常:" + JsonConvert.SerializeObject(ex));
            //    new MessageQueueHelper().SendMsgToQueue("policyupdatequeue", lstPolicies, MessagePriority.Normal, "private$");
            //}
            #endregion


            #region
            //HttpClient client = new HttpClient();

            ////client.DefaultRequestHeaders.enctype

            //byte[] ct = File.ReadAllBytes("E://20160106044440.zip");////@"D:\ND.Application\File\Qunar\ZipFile\2015\12\2\15\20151202030916.zip"
            //HttpContent con = new ByteArrayContent(ct, 0, ct.Length);//, Encoding.UTF8, "multipart/form-data"
            //con.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("multipart/form-data");

            //var res = client.PostAsync(System.Configuration.ConfigurationManager.AppSettings["QunarUpLoadUrl"].ToString(), con).Result;
            //res.EnsureSuccessStatusCode();
            //string backContent = res.Content.ReadAsStringAsync().Result;

            #endregion

            Console.ReadKey();
        }
Пример #7
0
 public override IRecPolicy Create(Config19e config)
 {
     return(new RecPolicy19e(config));
 }
Пример #8
0
 public RecPolicy19e(Config19e cf)
 {
     recHelper = new RecPolicy19eHelper(cf);
     recHelper.onWorklingMsg += recHelper_onWorklingMsg;
 }