예제 #1
0
 private void wbWorkArea_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     wbWorkArea.Document.InvokeScript("setExecModeForPam");
     wbWorkArea.Document.InvokeScript("setClientSize", new object[] { wbWorkArea.Width.ToString(), wbWorkArea.Height.ToString() });
     if (e.Url.ToString() == PensionAgencyVar.AccessPoint + _AutoLoginUrl)
     {
         autoLoginThread = ThreadAdapter.WhileCircleTask(
             () =>
         {
             if (!isAutoLogined && flash4ajaxReady)
             {
                 this.Invoke(new Action(() =>
                 {
                     Common.DebugLog("----------------------------begin setAutoLogin-------------------");
                     string jsonStr = JsonConvert.SerializeObject(new { Code = PensionAgencyVar.UserCode, Password = PensionAgencyVar.Password });
                     wbWorkArea.Document.InvokeScript("setAutoLogin", new object[] { jsonStr });
                 }));
                 isAutoLogined = true;
             }
         },
             100,
             () =>
         {
             return(isAutoLogined);
         }//flash准备好了则停止
             );
     }
     else if (e.Url.ToString() == PensionAgencyVar.AccessPoint + "/index.htm")
     {
         wbWorkArea.Document.InvokeScript("loadPage", new object[] { "welcome.htm" });
     }
 }
예제 #2
0
 private void wbProvinceSum_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 {
     wbProvinceSum.Document.InvokeScript("setExecModeForGov");
     wbProvinceSum.Document.InvokeScript("setClientSize", new object[] { wbProvinceSum.Width.ToString(), wbProvinceSum.Height.ToString() });
     if (e.Url.ToString() == GovVar.AccessOfProvice + _AutoLoginUrl)
     {
         autoLoginForProvinceThread = ThreadAdapter.WhileCircleTask(
             () =>
         {
             if (!isAutoLoginedForProvince && flash4ajaxReadyForProvince)
             {
                 this.Invoke(new Action(() =>
                 {
                     Common.DebugLog("----------------------------begin setAutoLogin for Province-------------------");
                     string jsonStr = JsonConvert.SerializeObject(new { Code = "demo", Password = "******" });
                     wbProvinceSum.Document.InvokeScript("setAutoLogin", new object[] { jsonStr });
                 }));
                 isAutoLoginedForProvince = true;
             }
         },
             100,
             () =>
         {
             return(isAutoLoginedForProvince);
         }//flash准备好了则停止
             );
     }
     else if (e.Url.ToString() == GovVar.AccessOfProvice + "/index.htm")
     {
         wbProvinceSum.Document.InvokeScript("loadPage", new object[] { "welcome.htm" });
     }
 }
예제 #3
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时关闭
         );
 }
예제 #4
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  不执行确认接口
            });
        }
예제 #5
0
        private void frmLogin_Load(object sender, EventArgs e)
        {
            lblProductName.Text           = Properties.Settings.Default.ProductName;
            lblProductVersionComment.Text = Properties.Settings.Default.ProductVersionComment;

            authEndPoint           = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH);
            authDataPoint          = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_DATA_POINT, Common.CFG_FILE_PATH);
            strUserNameSinceLast   = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, Common.INI_FILE_PATH);
            strObjectIdSinceLast   = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_ID_SINCE_LAST, Common.INI_FILE_PATH);
            strObjectNameSinceLast = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_NAME_SINCE_LAST, Common.INI_FILE_PATH);
            strRunMode             = INIAdapter.ReadValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_RUN_MODE, Common.INI_FILE_PATH);
            string strDeployNodeObjects = INIAdapter.ReadValue(Common.INI_SECTION_DATA, Common.INI_KEY_DEPLOY_NODE_OBJECTS, Common.INI_FILE_PATH);

            if (strDeployNodeObjects == "")
            {
                btnOk.Enabled = false;

                //远程获取deployNodeObjects
                ThreadAdapter.DoOnceTask(() =>
                {
                    HttpAdapter.getSyncTo(authDataPoint + "/GetDeployNodeObjects", (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            strDeployNodeObjects = JsonConvert.SerializeObject(ret.rows);
                            INIAdapter.WriteValue(Common.INI_SECTION_DATA, Common.INI_KEY_DEPLOY_NODE_OBJECTS, strDeployNodeObjects, Common.INI_FILE_PATH);
                            this.UIInvoke(() =>
                            {
                                btnOk.Enabled = true;
                            });
                            BindDeployNodeObjects(strDeployNodeObjects);
                        }
                        else
                        {
                            this.UIInvoke(() =>
                            {
                                btnOk.Enabled = true;
                            });
                        }
                    });
                });
            }
            else
            {
                BindDeployNodeObjects(strDeployNodeObjects);
            }

            if (strRunMode == "")
            {
                strRunMode = "0";
            }
            if (!string.IsNullOrEmpty(strUserNameSinceLast))
            {
                txtUserName.Text = strUserNameSinceLast;
            }
        }
예제 #6
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;
            }
        }
    //---------------------------------------------------------------------------------------
    // Code from: http://blog.yamanyar.com/2015/05/unity-creating-c-thread-with-callback.html
    //---------------------------------------------------------------------------------------

    public void CalcCorrectionThread(object state)
    {
        object[]         array    = state as object[];
        ThreadAdapter    adapter  = array[1] as ThreadAdapter;
        JobResultHandler callback = array[2] as JobResultHandler;

        CorrectionData calcData = array[0] as CorrectionData;
        double         distance = ClosestApproach(calcData);

        //if adapter is not null; callback is also not null.
        if (adapter != null)
        {
            adapter.ExecuteOnUi(delegate {
                callback(distance, calcData);
            });
        }
    }
예제 #8
0
 //ui清理
 private void _LoopForUiSendSms()
 {
     UiSendSms_CircleThread = ThreadAdapter.UIDoCircleTask(lb_Send, () =>
     {
         if (lb_Send.Items.Count > 1000)
         {
             lb_Send.Items.Clear();
         }
     },
                                                           180000,
                                                           () => {
         return(false);   //暂时不停止
     },
                                                           () => {
         return(!bPassValidated);    //验证通过不跳过
     });
 }
예제 #9
0
        //验证
        private void _LoopForAuth()
        {
            Auth_CircleThread = ThreadAdapter.UIDoCircleTask(lblMsg, () =>
            {
                if (lblMsg.Text.IndexOf(".") == -1)
                {
                    lblMsg.Text += ".";
                }
                else if (lblMsg.Text.IndexOf(".") + 5 == lblMsg.Text.Length)
                {
                    lblMsg.Text = lblMsg.Text.Substring(0, lblMsg.Text.Length - 5);
                }
                else
                {
                    lblMsg.Text += ".";
                }
            },
                                                             200,
                                                             () =>
            {
                return(bStopAuthThread);
            },//验证未通过永远不停止
                                                             () =>
            {
                return(false);
            }//暂时永远不跳过
                                                             );

            //验证请求
            HttpAdapter.optionsAsyncTo(authEndPoint + "/", new { ApplicationId = "CS001" }.ToStringObjectDictionary(), (ret, res) =>
            {
                this.Invoke(new Action(() => {
                    lblMsg.Hide();      //
                }));
                bStopAuthThread = true; //停止验证
                if (ret != "ok")
                {
                    MessageBoxAdapter.ShowError("无效的认证节点");
                }
                else
                {
                    bPassValidated = true;
                }
            });
        }
예제 #10
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);
     }//验证通过开始执行
                                                           );
 }
예제 #11
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);
            }    //当数据队列不为空则跳过
                );
        }
예제 #12
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;
            }
        }
예제 #13
0
        private void btnAreaSync_Click(object sender, EventArgs e)
        {
            //远程获取deployNodeObjects
            string authDataPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_DATA_POINT, Common.CFG_FILE_PATH);

            ThreadAdapter.DoOnceTask(() =>
            {
                HttpAdapter.getSyncTo(authDataPoint + "/GetDeployNodeObjects", (ret, res) =>
                {
                    if ((bool)ret.Success)
                    {
                        string strDeployNodeObjects = JsonConvert.SerializeObject(ret.rows);
                        INIAdapter.WriteValue(Common.INI_SECTION_DATA, Common.INI_KEY_DEPLOY_NODE_OBJECTS, strDeployNodeObjects, Common.INI_FILE_PATH);
                        MessageBoxAdapter.ShowInfo("区域同步成功");
                    }
                    else
                    {
                        MessageBoxAdapter.ShowError(ret.ErrorMessage.ToString());
                    }
                });
            });
        }
예제 #14
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 跳过,否则执行
            }));
        }
예제 #15
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);
            }    //当数据队列为空时跳过
                );
        }
예제 #16
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);  //验证通过开始执行
            });
        }
예제 #17
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));  //未找到节点 跳过
            });
        }
예제 #18
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));
            }//未获取到节点时跳过
                                                              );
        }
예제 #19
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);
                }//暂时永远不跳过
                                              ));
            }
        }
예제 #20
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;
                }));
            });
        }
        private async Task DeployCloudServiceAsync(
            ComputeManagementClient computeClient,
            CloudBlobContainer container,
            string serviceName,
            string packagePath,
            string configurationPath,
            string diagnosticsConfigurationPath,
            DeploymentSlot targetSlot)
        {
            ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                     $"[{serviceName}] Checking the existence of an existing deployment"));

            var deployment = await computeClient.GetAzureDeyploymentAsync(serviceName, targetSlot);

            if (ForceDelete && deployment != null)
            {
                ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                         $"[{serviceName}] ForceDelete is true and found an existing deployment: Deleting it."));

                await computeClient.Deployments.DeleteBySlotAsync(serviceName, targetSlot);

                deployment = null;
            }

            var blob = container.GetBlockBlobReference(DateTime.Now.ToString("yyyyMMdd_HHmmss_") + Path.GetFileName(packagePath));

            ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                     $"[{serviceName}] Uploading the cloud service package to storage account {StorageAccountName} in the {StorageContainer} container."));

            await blob.UploadFromFileAsync(packagePath, FileMode.Open);

            if (diagnosticsConfigurationPath != null)
            {
                ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                         $"[{serviceName}] Checking the Cloud Service for the PaaS Diagnostics extension -> Creating it if it doesn't exist."));

                var diagnosticsConfiguration = File.ReadAllText(diagnosticsConfigurationPath);
                var diagnosticsCreated       = await computeClient.AddDiagnosticsExtensionIfNotExistsAsync(serviceName, diagnosticsConfiguration);

                if (!diagnosticsCreated)
                {
                    diagnosticsConfigurationPath = null;
                }
            }

            if (deployment == null)
            {
                ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                         $"[{serviceName}] Found no previous deployments -> Creating a new deployment into {targetSlot.GetEnumDescription()}."));

                var createParams = new DeploymentCreateParameters
                {
                    Label           = serviceName,
                    Name            = $"{serviceName}{targetSlot.GetEnumDescription()}",
                    PackageUri      = blob.Uri,
                    Configuration   = File.ReadAllText(configurationPath),
                    StartDeployment = true
                };

                if (diagnosticsConfigurationPath != null)
                {
                    createParams.ExtensionConfiguration = new ExtensionConfiguration {
                        AllRoles = new[] { new ExtensionConfiguration.Extension {
                                               Id = FlexConfiguration.FlexDiagnosticsExtensionId
                                           } }
                    };
                }

                await computeClient.Deployments.CreateAsync(serviceName, targetSlot, createParams);
            }
            else
            {
                ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                         $"[{serviceName}] Found a previous deployment -> Updating the current deployment in {targetSlot.GetEnumDescription()}."));

                await computeClient.Deployments.UpgradeBySlotAsync(
                    serviceName,
                    targetSlot,
                    new DeploymentUpgradeParameters
                {
                    Label         = serviceName,
                    PackageUri    = blob.Uri,
                    Configuration = File.ReadAllText(configurationPath)
                });
            }

            if (VipSwap)
            {
                ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                         $"[{serviceName}] Swapping the deployments."));

                await computeClient.Deployments.SwapAsync(
                    serviceName,
                    new DeploymentSwapParameters
                {
                    SourceDeployment = $"{serviceName}{targetSlot.GetEnumDescription()}"
                });

                if (DeleteStaging)
                {
                    ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                             $"[{serviceName}] Deleting the staging deployment after the swap."));

                    await computeClient.Deployments.DeleteBySlotAsync(serviceName, DeploymentSlot.Staging);
                }
            }

            ThreadAdapter.QueueObject(new BuildEvent(BuildEventType.Information, BuildEventImportance.Medium,
                                                     $"[{serviceName}] Deployment complete."));
        }
예제 #22
0
        private void BuildControls()
        {
            this.UIDoStepTasks(new List <Func <bool> >()
            {
                () => {
                    xTab.TabPages.Clear();
                    return(true);
                },
                () => {
                    #region 数据源
                    dataSource.Clear();
                    dataSource.AddRange(Data.OldMans);
                    return(true);

                    #endregion
                },
                () => {
                    #region 构建UI
                    //计算页数
                    int needCreateTabPageCount = 1 + dataSource.Count / 20;
                    int padding   = 15;
                    int indexPage = 0;

                    int indexOfOldMan = 0;
                    int x, y          = 0;
                    do
                    {
                        int currentPageSize = pageSize;
                        xTab.TabPages.Add(indexPage.ToString());
                        needCreateTabPageCount--;
                        if (needCreateTabPageCount == 0)
                        {
                            currentPageSize = dataSource.Count % pageSize;
                        }

                        TabPage tb   = xTab.TabPages[indexPage];
                        tb.BackColor = Color.FromArgb(129, 61, 222);
                        int i        = 0;
                        for (indexOfOldMan = indexPage * pageSize + i; i < currentPageSize; i++)
                        {
                            OldManInfo oldman = dataSource[indexOfOldMan];


                            x = i % 4;
                            y = i / 4;

                            ucOldManCard card = new ucOldManCard();

                            card.BackColor = string.IsNullOrEmpty(oldman.ICNo) ? Color.Silver : Color.FromArgb(255, 192, 192);
                            card.Location  = new Point(padding * (x + 1) + x * card.Size.Width, padding * (y + 1) + y * card.Size.Height);

                            card.ClickLabel.Text = oldman.OldManName;
                            card.ClickLabel.Tag  = oldman.OldManId;

                            tb.Controls.Add(card);


                            indexOfOldMan++;
                        }

                        indexPage++;
                    } while (needCreateTabPageCount > 0);
                    #endregion
                    return(true);
                },
                () => {
                    lblPageNo.Text             = "1";
                    lblPageAll.Text            = "/ " + (dataSource.Count / pageSize + 1).ToString();
                    xSlideTab                  = new SlideableTabControl(xTab);
                    xSlideTab.SlidePageEamless = true;

                    return(true);
                },
                () => {
                    #region 绑定卡片点击事件
                    ThreadAdapter.DoOnceTask(() =>
                    {
                        foreach (TabPage page in xTab.TabPages)
                        {
                            Common.DebugLog(page.Text + ":" + page.Controls.Count);
                            foreach (ucOldManCard card in page.Controls)
                            {
                                card.ClickLabel.Click += new EventHandler((o, de) =>
                                {
                                    API icAPI = new API();
                                    icAPI.InitIC();
                                    if (icAPI.IcDev < 0)
                                    {
                                        MessageBoxAdapter.ShowError("初始化IC读卡设备失败,请确认是否已连接IC读卡设备");
                                        return;
                                    }
                                    frmCardView frm = new frmCardView();
                                    frm.LoadInfo(icAPI, (string)(o as Control).Tag);
                                    DialogResult result = frm.ShowDialog();
                                    if (result == System.Windows.Forms.DialogResult.OK)
                                    {
                                        (o as Control).Parent.BackColor = Color.FromArgb(255, 192, 192);
                                    }
                                    icAPI.ExitIC();
                                });
                            }
                        }
                    });
                    return(true);

                    #endregion
                }
            }, 0);
        }