Пример #1
0
 public void OnCountdownForClosing()
 {
     pnlCountdown.Visible       = true;
     _countdownValue            = 9;
     CloseForCountdown          = true;
     CTI_Countdown_CircleThread = ThreadAdapter.DoCircleTask(
         () =>
     {
         this.Invoke(new Action(() =>
         {
             lblCountdown.Text = _countdownValue.ToString();
             _countdownValue--;
         }));
     },
         1000,
         () =>
     {
         if (_countdownValue < 0)
         {
             this.Invoke(new Action <bool>(CloseWin), new object[] { false });
             CloseForCountdown = false;
             return(true);
         }
         else
         {
             return(false);
         }
     }    //倒计时为0时关闭
         );
 }
Пример #2
0
        //上行回复确认
        private void _LoopForReplyConfirmSms()
        {
            ReplyConfirmSms_CircleThread = ThreadAdapter.DoCircleTask(() =>
            {
                lock (lockme)
                {
                    Common.postSyncAsForm(smsEndPoint + "/replyConfirm.do", new { SpCode = txtDictionary["SpCode"], LoginName = txtDictionary["LoginName"], Password = txtDictionary["Password"], id = lastReplayId }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        bool bstr = ((string)ret).Contains("result=0");
                        this.Invoke(new Action <bool>(p1 =>
                        {
                            lb_Get.Items.Add("上行回复内容确认" + (p1 == true ? "成功!" : "失败!"));
                        }), new object[] { bstr });
                    });

                    lastReplayId = "0";     //重新清0
                }
            },
                                                                      15000,
                                                                      () =>
            {
                return(false);   //永不停止
            },
                                                                      () =>
            {
                return(!(lastReplayId != "0"));  //未取到最后一个查询Id  不执行确认接口
            });
        }
Пример #3
0
        //创建短信处理机制
        private void _MessageLoopForSendSms_Call(dynamic rows)
        {
            sendSmsThreadDic = new Dictionary <string, Thread>();
            var body = new { Status = "0" }.ToStringObjectDictionary();
            var header = new { ApplicationId = "CS001", Token = "", NodeId = "" }.ToStringObjectDictionary();

            foreach (var item in rows)
            {
                header["Token"]  = item.Token;
                header["NodeId"] = item.NodeId;

                Thread thread = ThreadAdapter.DoCircleTask(
                    () =>
                {
                    #region 执行任务=》检测发送短信消息
                    //同步请求
                    string url = (string)item.AccessPoint + "/Pub/SmsSendService/QueuedSendSms";
                    HttpAdapter.postSyncAsJSON(url, body, header, (result, response) =>
                    {
                        if ((bool)result.Success)
                        {
                            if (result.ret != null)
                            {
                            }
                        }
                        else
                        {
                            Common.DebugLog(string.Format("---------------------ErrorMessage:{0} ", result.ErrorMessage));
                        }
                    });

                    #endregion
                },
                    1000,
                    () =>
                {
                    return(!isRunning);
                },//未取到数据
                    () =>
                {
                    return(false);
                }//暂时永远不跳过
                    );
                sendSmsThreadDic.Add((string)item.NodeId, thread);
                thread = null;
            }
        }
Пример #4
0
 //获取短信节点个数
 private void _LoopForGetSmsPoint()
 {
     GetSmsPoint_CircleThread = ThreadAdapter.DoCircleTask(() =>
     {
         //验证请求
         HttpAdapter.getAsyncTo(authSmsEndPoint + "/GetCityDeployNodes", null, new { ApplicationId = "CS001" }.ToStringObjectDictionary(), (ret, res) =>
         {
             if ((bool)ret.Success)
             {
                 SendSmsEndPoint sendSmsEndPoint;
                 foreach (var item in ret.rows)
                 {
                     sendSmsEndPoint = new SendSmsEndPoint()
                     {
                         ApplicationId = "CS001"
                     };
                     sendSmsEndPoint.Url    = (string)item.AccessPoint;//"http://localhost/SmartLife.CertManage.SmsServices";//
                     sendSmsEndPoint.NodeId = (string)item.NodeId;
                     sendSmsEndPoint.Token  = (string)item.Token;
                     if (smsPointDic.ContainsKey(sendSmsEndPoint.NodeId))
                     {
                         smsPointDic.TryUpdate(sendSmsEndPoint.NodeId, sendSmsEndPoint, smsPointDic[sendSmsEndPoint.NodeId]);
                     }
                     else
                     {
                         smsPointDic.TryAdd(sendSmsEndPoint.NodeId, sendSmsEndPoint);
                     }
                 }
             }
         });
     },
                                                           30000,
                                                           () =>
     {
         return(false);
     },//永远不停止
                                                           () =>
     {
         return(!bPassValidated);
     }//验证通过开始执行
                                                           );
 }
Пример #5
0
        private void _FetchServiceWorkOrderContinuously()
        {
            _FetchServiceWorkOrderThread = ThreadAdapter.DoCircleTask(
                () =>
            {
                #region 执行任务=》获取需要同步到其他系统的工单

                dOnAppendToOutput dc = new dOnAppendToOutput(_OnAppendToOutput);
                this.Invoke(dc, new object[] { "获取需要同步到其他系统的工单..." });

                //同步请求
                string url = _SourceAddress + "/p12/c07/A01/GetSyncOutWorkOrders";

                HttpAdapter.getSyncTo(url, (result, response) =>
                {
                    if ((bool)result.Success)
                    {
                        this.Invoke(dc, new object[] { string.Format("###获取工单成功:{0}条 ", result.rows.Count) });
                        foreach (var row in result.rows)
                        {
                            queues.Enqueue(row);
                        }
                    }
                    else
                    {
                        this.Invoke(dc, new object[] { string.Format("#####获取工单出错:{0} ", result.ErrorMessage) });
                    }
                });

                #endregion
            },
                1000,//1秒执行一次
                () =>
            {
                return(!isEnableFetchServiceWorkOrder);
            },    //没有允许取数据则停止
                () =>
            {
                return(queues.Count > 0 || isPauseFetchServiceWorkOrder);
            }    //当数据队列不为空则跳过
                );
        }
Пример #6
0
        private void _MessageLoopForGetSms_Call(dynamic rows)
        {
            getSmsThreadDic = new Dictionary <string, Thread>();
            foreach (var item in rows)
            {
                Thread thread = ThreadAdapter.DoCircleTask(
                    () =>
                {
                    #region 执行任务=》检测接收短信消息
                    //同步请求
                    string url = ismgEndPoint;
                    HttpAdapter.postSyncAsJSON(url, (result, response) =>
                    {
                        if ((bool)result.Success)
                        {
                            if (result.ret != null)
                            {
                            }
                        }
                        else
                        {
                            Common.DebugLog(string.Format("---------------------ErrorMessage:{0} ", result.ErrorMessage));
                        }
                    });

                    #endregion
                },
                    1000,
                    () =>
                {
                    return(!isRunning);
                },//座席没登录则停止
                    () =>
                {
                    return(false);
                }//暂时永远不跳过
                    );
                getSmsThreadDic.Add(item.NodeId, thread);
                thread = null;
            }
        }
Пример #7
0
        //上行回复
        private void _LoopForReplySms()
        {
            ReplySms_CircleThread = ThreadAdapter.DoCircleTask(() => {
                Common.postSyncAsForm(smsEndPoint + "/reply.do", txtDictionary, (ret, res) =>
                {
                    Dictionary <string, string> dic = Common.StrToDictionary(ret, '&');
                    if (dic.ContainsKey("replys"))
                    {
                        string itemNo;
                        string content;
                        string replays = (string)dic["replys"];
                        //锁定 lastReplayId 保持线程同步
                        //比较最后一个回复ID号,没有新内容不执行发送,否则截取要发送的内容进行发送
                        lock (lockme)
                        {
                            if (lastReplayId != ((string)dic["id"]))
                            {
                                lastReplayId = (string)dic["id"];//保存最后一个ID号

                                dynamic dynJson = Newtonsoft.Json.JsonConvert.DeserializeObject(replays);
                                foreach (var item in dynJson)
                                {
                                    itemNo  = Convert.ToString(item.mdn);
                                    content = HttpUtility.UrlDecode((string)item.content, Encoding.GetEncoding("GBK"));

                                    if (string.IsNullOrEmpty(content) || content.Split('/').Length < 1)
                                    {
                                        continue;
                                    }
                                    if (string.IsNullOrEmpty(itemNo))
                                    {
                                        continue;
                                    }


                                    HttpAdapter.postSyncAsJSON(authEndPoint + "/AuthenticateUnicomMobileNo", new { MobileNo = itemNo }.ToStringObjectDictionary(), new { ApplicationId = "CS001" }.ToStringObjectDictionary(), (httpret, httpres) =>
                                    {
                                        if ((bool)httpret.Success)
                                        {
                                            ArrayList arr  = Common.StrSplitToArray(content);
                                            string strflag = (string)arr[0];

                                            string url = httpret.ret.AccessPoint;//"http://localhost/SmartLife.CertManage.SmsServices";//
                                            if (strflag == "102" || strflag == "103" || strflag == "104")
                                            {
                                                HttpAdapter.postSyncAsJSON(url + "/Oca/OldManLocateInfoService/CreateLocateByCall", new { LocateTime = item.reply_time, LongitudeS = arr[2], LatitudeS = arr[3] }.ToStringObjectDictionary(), new { ApplicationId = "CS001", Token = httpret.ret.Token, MobileNo = itemNo }.ToStringObjectDictionary(), (locret, locres) =>
                                                {
                                                    this.Invoke(new Action <string, string, bool>((p1, p2, p3) =>
                                                    {
                                                        lb_Get.Items.Add(p1 + " 执行命令 [" + p2 + "] " + (p3 == true ? "成功" : "失败"));
                                                    }), new object[] { itemNo, strflag, (bool)locret.Success });
                                                });
                                            }
                                            if (strflag == "105" || strflag == "104")
                                            {
                                                string reminderContent = (strflag == "104" ? "超出警戒范围报警" : "电压低于20%报警");
                                                HttpAdapter.postSyncAsJSON(url + "/Pub/ReminderService/CreateReminderByCall", new { LastTime = item.reply_time, SourceType = strflag, RemindContent = reminderContent }.ToStringObjectDictionary(), new { ApplicationId = "CS001", Token = httpret.ret.Token, MobileNo = itemNo }.ToStringObjectDictionary(), (remret, remres) =>
                                                {
                                                    this.Invoke(new Action <string, string, bool>((p1, p2, p3) =>
                                                    {
                                                        lb_Get.Items.Add(p1 + " 执行命令 [" + p2 + "] " + (p3 == true ? "成功" : "失败"));
                                                    }), new object[] { itemNo, strflag, (bool)remret.Success });
                                                });
                                            }
                                        }
                                    });
                                }
                            }
                        }
                    }
                });
            },
                                                               5000,
                                                               () =>
            {
                return(false);   //永不停止
            },
                                                               () =>
            {
                return(!bPassValidated);  //验证通过开始执行
            });
        }
Пример #8
0
        //回执
        private void _LoopForReportSms()
        {
            ReportSms_CircleThread = ThreadAdapter.DoCircleTask(() => {
                Common.postSyncAsForm(smsEndPoint + "/report.do", txtDictionary, null, (rret, rres) =>
                {
                    Dictionary <string, string> dic = Common.StrToDictionary(rret, '&');
                    if (!string.IsNullOrEmpty(dic["out"]))
                    {
                        string[] strPArray = dic["out"].Split(';');
                        string[] strCArray;
                        Dictionary <string, string> reportSmsDic = new Dictionary <string, string>();
                        for (int i = 0; i < strPArray.Length; i++)
                        {
                            //sendresult 默认应该是短信接口发送成功,暂时只更新短信接口发送失败的数据
                            strCArray = strPArray[i].Split(',');
                            if (strCArray.Length < 2)
                            {
                                break;
                            }

                            if (reportSmsDic.ContainsKey(strCArray[0]))
                            {
                                if (strCArray[2] != "0")
                                {
                                    reportSmsDic[strCArray[0]] += "," + strCArray[1];
                                }
                            }
                            else
                            {
                                reportSmsDic.Add(strCArray[0], (strCArray[2] != "0" ? strCArray[1] : ""));
                            }
                        }
                        //循环更新
                        StringObjectDictionary sod;
                        string[] strErrorNum;
                        string strToken, strUrl, strNodeId, strMobiles;
                        foreach (var item in reportSmsDic)
                        {
                            if (sendSmsDic.TryRemove(item.Key, out sod))
                            {
                                strUrl    = (string)sod["SmsUrl"];
                                strToken  = (string)sod["SmsToken"];
                                strNodeId = (string)sod["SmsNodeId"];
                                //更新
                                UpdateSmsSendStatus(new { SendResult = 0, Mobiles = "", BatchNum = item.Key }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 1);

                                strErrorNum = item.Value.Split(',');
                                if (strErrorNum.Length > 1)
                                {
                                    strMobiles = "'" + string.Join("','", strErrorNum.Where(s => !string.IsNullOrEmpty(s))) + "'";
                                    UpdateSmsSendStatus(new { SendResult = 1, Mobiles = strMobiles, BatchNum = item.Key }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 1);
                                }
                            }
                        }
                    }
                });
            },
                                                                6000,
                                                                () => {
                return(false); //永不停止
            },
                                                                () => {
                return(!(smsPointDic.Count() > 0));  //未找到节点 跳过
            });
        }
Пример #9
0
        //发送短信
        private void _LoopForSendSms()
        {
            SendSms_CircleThread = ThreadAdapter.DoCircleTask(() => {
                string strUrl, strToken, strNodeId;
                foreach (var item in smsPointDic)
                {
                    strUrl    = item.Value.Url;
                    strToken  = item.Value.Token;
                    strNodeId = item.Value.NodeId;

                    HttpAdapter.getSyncTo(strUrl + "/Pub/SmsSendService/QueuedUnSendSms", null, new { ApplicationId = "CS001", Token = strToken, NodeId = strNodeId }.ToStringObjectDictionary(), (smsret, smsres) =>
                    {
                        if ((bool)smsret.Success)
                        {
                            StringObjectDictionary sod;
                            IDictionary <string, object> dic;
                            string strItem        = "";
                            DateTime scheduleTime = DateTime.Now;
                            foreach (var row in smsret.rows)
                            {
                                sod          = new StringObjectDictionary();
                                dynamic list = new ExpandoObject();
                                DynamicAdapter.Parse(list, System.Xml.Linq.XElement.Parse(row.ToString()));
                                dic = list.StringObjectDictionary;

                                strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["SendCatalog"]);
                                if (strItem == "0")
                                {
                                    sod = sod.Union2(txtDictionary.ToStringObjectDictionary());
                                }

                                strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["Mobiles"]);
                                if (string.IsNullOrEmpty(strItem))
                                {
                                    continue;
                                }                                                 //跳过
                                sod.Add("UserNumber", strItem);

                                //是否有预约时间   是-转化yyyyMMddHHmmss;否-空
                                strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["ScheduleTime"], "");
                                sod.Add("ScheduleTime", strItem);
                                if (!string.IsNullOrEmpty(strItem))
                                {
                                    if (DateTime.TryParse(strItem, out scheduleTime))
                                    {
                                        sod["ScheduleTime"] = scheduleTime.ToString("yyyyMMddHHmmss");
                                    }
                                }

                                strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["SendContent"]);
                                sod.Add("MessageContent", HttpUtility.UrlEncode(strItem, Encoding.GetEncoding("GBK")));
                                //批次号
                                strItem = e0571.web.core.Utils.TypeConverter.ChangeString(dic["BatchNum"]);
                                sod.Add("SerialNumber", strItem);

                                //发送HttpAdapter.postSyncAsForm
                                Common.postSyncAsForm(smsEndPoint + "/Send.do", sod, null, (ret, res) =>
                                {
                                    Dictionary <string, string> retdict = Common.StrToDictionary(ret, '&');
                                    if (retdict["result"] == "0")
                                    {
                                        this.Invoke(new Action <string, string>((p1, p2) =>
                                        {
                                            lb_Send.Items.Add("[" + p1 + "] 成功发送 [" + p2 + "]");
                                        }), new object[] { sod["UserNumber"], HttpUtility.UrlDecode((string)sod["MessageContent"], Encoding.GetEncoding("GBK")) });

                                        //需要回执的短信
                                        StringObjectDictionary sod2;
                                        if (!sendSmsDic.TryGetValue(strItem, out sod2))
                                        {
                                            sod2 = new { SmsNodeId = strNodeId, SmsToken = strToken, SmsUrl = strUrl }.ToStringObjectDictionary();
                                            sendSmsDic.TryAdd(strItem, sod2);
                                        }

                                        //更新成功发送数据
                                        UpdateSmsSendStatus(new { Status = 1, Mobiles = ((string)sod["UserNumber"]), BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0);
                                        //发送成功 检查是否有发送失败数据
                                        if (!string.IsNullOrEmpty(retdict["faillist"]))
                                        {
                                            string[] strMobiles = retdict["faillist"].Split(',');
                                            string mobiles      = "'" + string.Join("','", strMobiles.Where(s => !string.IsNullOrEmpty(s))) + "'";

                                            this.Invoke(new Action <string>(p1 =>
                                            {
                                                lb_Send.Items.Add("[" + p1 + "] 无效号码");
                                            }), new object[] { retdict["faillist"] });

                                            UpdateSmsSendStatus(new { Status = 2, Mobiles = mobiles, BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0);
                                        }
                                    }
                                    else
                                    {
                                        this.Invoke(new Action <string, string>((p1, p2) =>
                                        {
                                            lb_Send.Items.Add("[" + p1 + "] 发送失败[" + (smsRetCodeDic.ContainsKey(p2) ? smsRetCodeDic[p2] : "发送异常") + "]");
                                        }), new object[] { (string)sod["UserNumber"], retdict["result"] });

                                        //发送失败
                                        UpdateSmsSendStatus(new { Status = 2, Mobiles = ((string)sod["UserNumber"]), BatchNum = sod["SerialNumber"] }.ToStringObjectDictionary(), strUrl, strToken, strNodeId, 0);
                                    }
                                });

                                //回执
                            }
                        }
                    });
                }
            },
                                                              5000,
                                                              () =>
            {
                return(false);
            },//永远不停止
                                                              () =>
            {
                return(!(smsPointDic.Count > 0));
            }//未获取到节点时跳过
                                                              );
        }
Пример #10
0
        private Thread InitAccessPointThread(AccessPointPart app)
        {
            return(ThreadAdapter.DoCircleTask(
                       () =>
            {
                if (lbResponseLog.Items.Count > 1000)
                {
                    lbResponseLog.Items.Clear();
                }
                if (lbResponseLog.Items.Count > 1000)
                {
                    lbResponseLog.Items.Clear();
                }
                #region 执行任务=》请求objectId对应的AccessPoint

                string url = app.Url + "/Pam/PamService/LoadRemindersWorkExecute";
                this.UIInvoke(() =>
                {
                    lbRequestLog.Items.Add("[" + app.ObjectId + "] " + url + "     " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                });


                HttpAdapter.postSyncAsJSON(url, (result, response) =>
                {
                    if ((bool)result.Success)
                    {
                        dynamic item;
                        //执行发送信息
                        IList <YYReminder> yyReminders = new List <YYReminder>();
                        YYReminder yyReminder;
                        //更新信息
                        Dictionary <string, string> IdCallNoDic = new Dictionary <string, string>();
                        foreach (var row in result.rows)
                        {
                            item = new ExpandoObject();
                            DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));

                            yyReminder = new YYReminder();
                            yyReminder.dest = item.StringObjectDictionary.CallNo;
                            yyReminder.roomNum = item.StringObjectDictionary.RoomNo;
                            yyReminder.sickbedNum = string.IsNullOrEmpty(item.StringObjectDictionary.SickBedNo) ? "0" : item.StringObjectDictionary.SickBedNo;
                            yyReminder.repeatTimes = item.StringObjectDictionary.PlayRepeats;
                            yyReminder.warnType = "13001" + item.StringObjectDictionary.WorkItem;

                            IdCallNoDic.Add(item.StringObjectDictionary.Id, item.StringObjectDictionary.CallNo);
                            yyReminders.Add(yyReminder);
                        }

                        if (yyReminders.Count == 0)
                        {
                            return;
                        }

                        HttpAdapter.postAsyncAsJSON(sendReminderUrl, new { info = yyReminders }.ToStringObjectDictionary(), (ret, res) =>
                        {
                            if (ret != null)
                            {
                                //暂时不做处理 默认发送成功

                                /*item = Newtonsoft.Json.JsonConvert.DeserializeObject(ret);
                                 * Dictionary<string, string> successSendDic = new Dictionary<string, string>();
                                 * foreach (var key in item)
                                 * {
                                 *  if((string)key.result!="+OK")
                                 *  {
                                 *      successSendDic = IdCallNoDic.Where(s => s.Value == (string)key.dest) as Dictionary<string, string>;
                                 *  }
                                 * }
                                 */
                                if (IdCallNoDic.Count > 0)
                                {
                                    HttpAdapter.postAsyncAsJSON(app.Url + "/Pam/PamService/UpdateWorkExecute", new { Ids = IdCallNoDic.Keys.ToArray() }.ToStringObjectDictionary(), (ret1, res1) =>
                                    {
                                        this.UIInvoke(() =>
                                        {
                                            lbResponseLog.Items.Insert(0, "[" + app.ObjectId + "] :     " + app.Url + "/Pam/PamService/UpdateWorkExecute");
                                        });
                                    });
                                }
                            }
                        });
                    }
                    else
                    {
                        this.UIInvoke(() =>
                        {
                            lbResponseLog.Items.Insert(0, "[" + app.ObjectId + "] ErrorMessage:     " + result.ErrorMessage);
                        });
                    }
                });

                #endregion
            },
                       60000,
                       () =>
            {
                return false;//永远执行
            },
                       () =>
            {
                return string.IsNullOrEmpty(sendReminderUrl);//空URL 跳过,否则执行
            }));
        }
Пример #11
0
        private void btnTestSpeed_Click(object sender, EventArgs e)
        {
            string oldText = btnTestSpeed.Text;

            btnTestSpeed.Enabled   = false;
            testSpeedLoadingThread = ThreadAdapter.DoCircleTask(() =>
            {
                BeginInvoke(new Action(() =>
                {
                    if (btnTestSpeed.Text.IndexOf(".") == -1)
                    {
                        btnTestSpeed.Text += ".";
                    }
                    else if (btnTestSpeed.Text.IndexOf(".") + 3 == btnTestSpeed.Text.Length)
                    {
                        btnTestSpeed.Text = btnTestSpeed.Text.Substring(0, btnTestSpeed.Text.Length - 3);
                    }
                    else
                    {
                        btnTestSpeed.Text += ".";
                    }
                }));
            }, 700, () =>
            {
                return(btnTestSpeed.Enabled);
            });

            string commandStr = string.Format("iperf.exe -c {0} -p 12347 -t 10 -y C", callCenterIP);

            CommandLineAdapter.Execute(commandStr, (o, dre) =>
            {
                string output = dre.Data;
                if (!string.IsNullOrEmpty(output))
                {
                    if (output.Contains("fail") || output.Contains("timed out"))
                    {
                        MessageBoxAdapter.ShowError("无法连接到呼叫中心,请检查网络!");
                    }
                    else
                    {
                        string[] results = output.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        if (results.Length == 9)
                        {
                            long bps = long.Parse(results[8]) / 8 / 1024;
                            MessageBoxAdapter.ShowInfo("连接到呼叫中心的即时速度为【" + bps.ToString() + "k】!");
                        }
                    }
                }

                if (!String.IsNullOrEmpty(dre.Data))
                {
                    Console.WriteLine(dre.Data);
                }
            }, "./tools", (o, ee) =>
            {
                BeginInvoke(new Action(() =>
                {
                    btnTestSpeed.Enabled = true;
                    btnTestSpeed.Text    = oldText;
                }));
            });
        }
Пример #12
0
        private void _MessageLoopForAccessPoints()
        {
            //检测CTI_Call
            txtObjectId.Text = string.Join(",", accessPointParts.Select(item => item.ObjectId).ToArray());
            foreach (var part in accessPointParts)
            {
                if (threadsToAccessPoints.ContainsKey(part.ObjectId))
                {
                    Thread accessPointThead = threadsToAccessPoints[part.ObjectId] as Thread;
                    if (accessPointThead != null)
                    {
                        if (accessPointThead.IsAlive)
                        {
                            accessPointThead.Abort();
                            threadsToAccessPoints.Remove(part.ObjectId);
                        }
                    }
                }

                threadsToAccessPoints.Add(part.ObjectId, ThreadAdapter.DoCircleTask(
                                              () =>
                {
                    if (lbResponseLog.Items.Count > 1000)
                    {
                        lbResponseLog.Items.Clear();
                    }
                    if (lbResponseLog.Items.Count > 1000)
                    {
                        lbResponseLog.Items.Clear();
                    }
                    #region 执行任务=》请求objectId对应的AccessPoint

                    string url = part.Url + "/api/share/v1/SendWXMessageSchedule";
                    this.UIInvoke(() =>
                    {
                        lbRequestLog.Items.Add("[" + part.ObjectId + "] " + url + "     " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    });


                    HttpAdapter.postSyncAsJSON(url, (result, response) =>
                    {
                        if ((bool)result.Success)
                        {
                            lbResponseLog.Items.Insert(0, "[" + part.ObjectId + "] " + result.ret);
                        }
                        else
                        {
                            lbResponseLog.Items.Insert(0, "[" + part.ObjectId + "] ErrorMessage:     " + result.ErrorMessage);
                        }
                    });

                    #endregion
                },
                                              1000,
                                              () =>
                {
                    return(!isRunning);
                },//座席没登录则停止
                                              () =>
                {
                    return(false);
                }//暂时永远不跳过
                                              ));
            }
        }
Пример #13
0
        private void _SaveOrderToRemoteContinuously()
        {
            _SaveOrderToRemoteThread = ThreadAdapter.DoCircleTask(
                () =>
            {
                #region 执行任务=》将工单提交到远程服务器

                if (queues.Count == 0)
                {
                    return;
                }

                dOnAppendToOutput dc = new dOnAppendToOutput(_OnAppendToOutput);
                this.Invoke(dc, new object[] { "将工单提交到远程服务器..." });

                isSaving = true;
                var item = queues.Dequeue();
                try
                {
                    HttpAdapter.postSyncAsForm(_TargetAddressToSaveOrder, new
                    {
                        unique         = item.WorkOrderNo,
                        service        = item.Service,
                        linkman        = item.LinkMan,
                        linkphone      = (item.LinkPhone == "" ? "没有linkphone" : item.LinkPhone),
                        note           = item.Note,
                        accept_time    = item.AcceptTime,
                        pie_time       = item.PieTime,
                        finish_time    = item.FinishTime,
                        service_time   = item.ServieTime,
                        back_note      = item.BackNote,
                        status         = item.Status,
                        satisficing    = item.Satisficing,
                        old_man_unique = item.OldManUnique,
                        longitude      = item.LongitudeS,
                        latitude       = item.LatitudeS
                    }.ToStringObjectDictionary(), (result, response) =>
                    {
                        if ((bool)result.flag)
                        {
                            this.Invoke(dc, new object[] { string.Format("#####提交工单成功:<{0}> ", item.WorkOrderNo) });

                            string url = _SourceAddress + "/p12/c07/A01/MarkSyncOutWorkOrder";

                            HttpAdapter.postSyncAsJSON(url, new { Id = item.Id }.ToStringObjectDictionary(), (result1, response1) =>
                            {
                                if ((bool)result1.Success)
                                {
                                    //将提交成功的工单设置同步标识
                                    this.Invoke(dc, new object[] { string.Format("###设置工单同步标识成功:<{0}> ", item.WorkOrderNo) });
                                }
                                else
                                {
                                    this.Invoke(dc, new object[] { string.Format("#####设置工单同步标识出错:{0} ", result1.ErrorMessage) });
                                }
                            });
                        }
                        else
                        {
                            this.Invoke(dc, new object[] { string.Format("#####提交工单出错:{0} ", result.msg) });
                        }
                    });
                }
                catch (Exception ex) {
                    this.Invoke(dc, new object[] { ex.Message });
                }
                finally
                {
                    isSaving = false;
                }
                #endregion
            },
                5000,//5秒执行一次
                () =>
            {
                return(false);
            },    //一直运行
                () =>
            {
                return(queues.Count == 0 || isSaving);
            }    //当数据队列为空时跳过
                );
        }