예제 #1
0
        private void FetchAccessPoints(Action success)
        {
            sendReminderUrl = INIAdapter.ReadValue(Common.INI_SECTION_WEB, Common.INI_KEY_SEND_REMINDER_POINT, Common.INI_FILE_PATH);
            strRunMode      = INIAdapter.ReadValue(Common.INI_SECTION_SYSTEM, Common.INI_KEY_RUN_MODE, Common.INI_FILE_PATH);
            string authEndPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH);

            //异步认证
            byte runMode = byte.Parse(strRunMode);//测试1 正式0

            HttpAdapter.postAsyncAsJSON(authEndPoint, new { RunMode = runMode }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
            {
                if ((bool)ret.Success)
                {
                    foreach (var accessPoint in ret.ret.AccessPoints)
                    {
                        accessPointParts.Add(new AccessPointPart {
                            ObjectId = accessPoint.ObjectId.ToString(), Url = accessPoint.Url.ToString()
                        });
                    }

                    if (success != null)
                    {
                        success();
                    }
                }
                else
                {
                    MessageBoxAdapter.ShowError(ret.ErrorMessage);
                }
            });
        }
예제 #2
0
 private void OnIgnoreReminderInfo(WorkOrderReminderInfo item)
 {
     //string url = item.AccessPoint.Replace("http://115.236.175.110:17001/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Pub/ReminderService/IgnoreReminder";
     HttpAdapter.postAsyncAsJSON(item.AccessPoint + "/Pub/ReminderService/IgnoreReminder", new { ResponseAppType = "00001", ObjectType = "Merchant", ObjectKey = item.StationId, SourceTable = "Oca_ServiceWorkOrder", SourceColumn = "WorkOrderId", SourceType = item.SourceType, SourceKey = item.SourceKey }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = item.StationId }.ToStringObjectDictionary(), (ret, res) =>
     {
     });
 }
예제 #3
0
        private void DoLogin(string userName, string password)
        {
            //
            btnOk.Enabled = false;

            lblMsg.Text         = "登录中";
            _tickTimer          = new System.Timers.Timer(1 * 200);
            _tickTimer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object source, System.Timers.ElapsedEventArgs ee)
            {
                BeginInvoke(new Action(() =>
                {
                    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 += ".";
                    }
                }));
            });                          //到达时间的时候执行事件;
            _tickTimer.AutoReset = true; //设置是执行一次(false)还是一直执行(true);
            _tickTimer.Enabled   = true; //是否执行System.Timers.Timer.Elapsed事件;


            HttpAdapter.postAsyncAsJSON(authEndPoint + "/AuthenticateMerchant", new AuthMerchantParam {
                StationCode = userName, PasswordHash = MD5Provider.Generate(password)
            }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
            {
                //MessageBoxAdapter.ShowDebug(_MonitorId.ToString());
                //dynamic ret = new { Error = "", Success = false };
                //ret = JsonConvert.DeserializeObject(result);
                MerchantVar.Load(userName, ret.ret);

                if ((bool)ret.Success)
                {
                    INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, userName, Common.INI_FILE_PATH);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    lblMsg.Text = ret.ErrorMessage;

                    this.UIInvoke(() =>
                    {
                        btnOk.Enabled = true;
                    });
                }
                _tickTimer.Enabled = false;
                _tickTimer         = null;
            });
        }
예제 #4
0
        private void DoLogin(string userCode, string password)
        {
            //
            btnOk.Enabled = false;

            lblMsg.Text         = "登录中";
            _tickTimer          = new System.Timers.Timer(1 * 200);
            _tickTimer.Elapsed += new System.Timers.ElapsedEventHandler(delegate(object source, System.Timers.ElapsedEventArgs ee)
            {
                BeginInvoke(new Action(() =>
                {
                    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 += ".";
                    }
                }));
            });                                                //到达时间的时候执行事件;
            _tickTimer.AutoReset = true;                       //设置是执行一次(false)还是一直执行(true);
            _tickTimer.Enabled   = true;                       //是否执行System.Timers.Timer.Elapsed事件;

            byte     runMode         = byte.Parse(strRunMode); //测试1 正式0
            string   objectId        = null;
            string   objectName      = null;
            TreeNode theSelectedNode = ctvObjectNodes.TreeView.SelectedNode;

            if (theSelectedNode != null && theSelectedNode.Name != "default")
            {
                objectId   = theSelectedNode.Name;
                objectName = theSelectedNode.Text;
            }
            else
            {
                objectName = "自动";
            }



            HttpAdapter.postAsyncAsJSON(authEndPoint, new { RunMode = runMode, ObjectId = objectId, UserCode = userCode, PasswordHash = MD5Provider.Generate(password) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
            {
                if ((bool)ret.Success)
                {
                    PensionAgencyVar.UserCode = userCode;
                    PensionAgencyVar.Password = password;
                    PensionAgencyVar.Load(ret.ret);
                    INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, userCode, Common.INI_FILE_PATH);
                    INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_ID_SINCE_LAST, (objectId ?? "default"), Common.INI_FILE_PATH);
                    INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_OBJECT_NAME_SINCE_LAST, objectName, Common.INI_FILE_PATH);
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    lblMsg.Text = ret.ErrorMessage;

                    this.UIInvoke(() =>
                    {
                        btnOk.Enabled = true;
                    });
                }
                _tickTimer.Enabled = false;
                _tickTimer         = null;
            });
        }
예제 #5
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 跳过,否则执行
            }));
        }