public InvokeResult IpccRECManage(RECData recdata)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            if (!string.IsNullOrEmpty(recdata.RemoteUrl))
            {
                try
                {
                    HttpAdapter.postSyncAsJSON(recdata.RemoteUrl, recdata.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if (!string.IsNullOrEmpty((string)ret))
                        {
                            result.Success      = false;
                            result.ErrorMessage = (string)ret;
                        }
                    });
                }
                catch (Exception ex)
                {
                    result.Success      = false;
                    result.ErrorMessage = ex.ToString();
                }
            }

            return(result);
        }
        public InvokeResult PushJuDouMsg(JudouDevice judouDevice)
        {
            InvokeResult result = new InvokeResult {
                Success = true
            };

            if (!string.IsNullOrEmpty(judouDevice.RemoteUrl))
            {
                try
                {
                    HttpAdapter.postSyncAsJSON(judouDevice.RemoteUrl, judouDevice.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if (string.IsNullOrEmpty((string)ret))
                        {
                            result.Success      = false;
                            result.ErrorMessage = (string)ret;
                        }
                    });
                }
                catch (Exception ex)
                {
                    result.Success      = false;
                    result.ErrorMessage = ex.ToString();
                }
            }

            return(result);
        }
Esempio n. 3
0
        private void getData()
        {
            if (residentBaseInfos == null)
            {
                residentBaseInfos = new List <ResidentBaseInfo>();
            }
            else
            {
                residentBaseInfos.Clear();
            }
            StringObjectDictionary param = new { OrderByClause = " OperatedOn desc ", AreaIdSub = "", KeyWord = "", PageNo = 1, PageSize = 30 }.ToStringObjectDictionary();

            HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/GetResidentBaseInfo", param,
                                       (ret, res) =>
            {
                if ((bool)ret.Success)
                {
                    foreach (var row in ret.rows)
                    {
                        dynamic item = new ExpandoObject();
                        DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                        ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>();
                        residentBaseInfos.Add(dtItem);
                    }
                }
            });
        }
        public Stream IpccSpeechTemplateList(SpeechTemplate speechtemplate)
        {
            InvokeResult <string> result = new InvokeResult <string> {
                Success = true
            };

            if (!string.IsNullOrEmpty(speechtemplate.RemoteUrl))
            {
                try {
                    HttpAdapter.postSyncAsJSON(speechtemplate.RemoteUrl, new { orgNo = speechtemplate.OrgCode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if (speechtemplate.RetType == "json")
                        {
                            result.ret = JsonConvert.DeserializeObject(ret).ToString();
                        }
                        else
                        {
                            result.ret = ret.ToString();
                        }
                    });
                }
                catch (Exception ex) {
                    result.Success      = false;
                    result.ErrorMessage = ex.ToString();
                }
            }

            byte[] resultBytes = Encoding.UTF8.GetBytes(result.ToJson());
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json; charset=utf-8";
            return(new MemoryStream(resultBytes));
        }
Esempio n. 5
0
        private void FetchBookMeal(Button btn)
        {
            string mealType  = btn.Name.Substring(btn.Name.Length - 5);
            string setMealId = btn.Tag as string;

            HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PAFetchBookMeal", new { OldManId = _OldManId.ToGuid(), MealType = mealType, SetMealId = setMealId, OperatedBy = Data.UserId }.ToStringObjectDictionary(), new { PACode = SettingsVar.BindingPACode, ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
            {
                if ((bool)ret.Success)
                {
                    MessageBoxAdapter.ShowInfo("领取配餐成功");
                    BookMealInfo bookMealInfo = Data.BookMeals.Single(item => item.OldManId == _OldManId && item.MealType == mealType && item.SetMealId == setMealId);
                    bookMealInfo.FetchFlag    = "1";

                    if (Common.isInExhibition)
                    {
                        btn.ForeColor = SystemColors.ControlText;
                        btn.Enabled   = true;
                        btn.Text      = "循环使用";
                    }
                    else
                    {
                        btn.ForeColor = SystemColors.ControlLight;
                        btn.Enabled   = false;
                        btn.Text      = "确认领餐";
                    }
                }
                else
                {
                    MessageBoxAdapter.ShowError((string)ret.ErrorMessage);
                }
            });
        }
Esempio n. 6
0
        private void SubmitData()
        {
            if (item != null)
            {
                new Action(() =>
                {
                    int doStatus = int.Parse(item.StringObjectDictionary.DoStatus);

                    if (doStatus == 0)
                    {
                        //响应工单
                        if (MessageBoxAdapter.ShowConfirm("您确定要响应工单吗") == System.Windows.Forms.DialogResult.OK)
                        {
                            //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/ResponseWorkOrder";
                            string url = AccessPoint + "/Oca/WorkOrderService/ResponseWorkOrder";
                            HttpAdapter.postSyncAsJSON(url, new { WorkOrderId = Guid.Parse(WorkOrderId) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) =>
                            {
                                if ((bool)ret.Success)
                                {
                                    LastError = null;
                                }
                                else
                                {
                                    LastError = ret.ErrorMessage;
                                }
                            });
                        }
                        else
                        {
                            LastError = Common.ERROR_USER_CANCEL;
                        }
                    }
                }).BeginInvoke(new AsyncCallback((ar) =>
                {
                    //AsyncResult result = (AsyncResult)ar;
                    this.UIInvoke(() =>
                    {
                        xLoadingPanel.Stop();

                        if (!string.IsNullOrEmpty(LastError))
                        {
                            if (LastError != Common.ERROR_USER_CANCEL)
                            {
                                MessageBoxAdapter.ShowError(LastError);
                            }
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    });
                }), null);

                xLoadingPanel.Start();
            }
        }
Esempio n. 7
0
 //更新短信状体
 private void UpdateSmsSendStatus(StringObjectDictionary sod, string url, string token, string nodeId, int itype)
 {
     HttpAdapter.postSyncAsJSON(url + "/Pub/SmsSendService/Update2", sod, new { ApplicationId = "CS001", Token = token, NodeId = nodeId }.ToStringObjectDictionary(), (ret, res) =>
     {
         this.Invoke(new Action <int, string, bool>((p1, p2, p3) =>
         {
             lb_Send.Items.Add((itype == 1 ? "[回执]" : "") + (string.IsNullOrEmpty(p2) ? "" : "[" + p2 + "] ") + "更新数据库短信状态:" + (p3 == true ? "成功" : "失败"));
         }), new object[] { itype, (string)sod["Mobiles"], (bool)ret.Success });
     });
 }
        private void creatTreeData()
        {
            String url = GovVar.DataPointOfManage + "/Share/TreeDataService/fetchTreeData";
            StringObjectDictionary _treeParam = new { TreeCode = "01$01$02", OrderByClause = "OrderNo asc", TreeParams = "{\"DictionaryId\":\"00005\" , \"ItemId\":\"" + GovVar.Area1 + "\"}" }.ToStringObjectDictionary();

            HttpAdapter.postSyncAsJSON(url, _treeParam, (ret, res) =>
            {
                TreeNode treeNode = new TreeNode();
                foreach (var row in ret)
                {
                    if (row.pId.Value == "_")
                    {
                        string areaId = row.id.Value.ToString();
                        //辖区绑定,作为一级层次
                        treeNode.Text = row.name.Value.ToString();
                        treeNode.Name = areaId;

                        //街道绑定 ,作为二级层次
                        foreach (var row_s in ret)
                        {
                            if (row_s.pId.Value.ToString() == areaId)
                            {
                                string streetId = row_s.id.Value.ToString();
                                TreeNode tn_s   = new TreeNode();
                                tn_s.Text       = row_s.name.Value.ToString();
                                tn_s.Name       = streetId;
                                treeNode.Nodes.Add(tn_s);

                                //社区绑定 ,作为三级层次
                                foreach (var row_c in ret)
                                {
                                    if (row_c.pId.Value.ToString() == streetId)
                                    {
                                        TreeNode tn_c = new TreeNode();
                                        tn_c.Text     = row_c.name.Value.ToString();
                                        tn_c.Name     = row_c.id.Value.ToString();
                                        tn_s.Nodes.Add(tn_c);
                                    }
                                }
                            }
                        }
                        break;
                    }
                }
                this.tvAreaInfo.Nodes.Add(treeNode);
                if (tvAreaInfo.Nodes.Count > 0)
                {
                    tvAreaInfo.Nodes[0].Expand();
                }
            });
        }
        private void getData(string areaIdSub)
        {
            if (residentBaseInfos == null)
            {
                residentBaseInfos = new List <ResidentBaseInfo>();
            }
            else
            {
                residentBaseInfos.Clear();
            }

            StringObjectDictionary param = new { Order = " desc ", Sort = " OperatedOn ", AreaId = areaIdSub, KeyWord = txbKeyWord.Text.Trim(), PageNo = _pageCurrent, PageSize = _pageSize }.ToStringObjectDictionary();

            HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/GetResidentBaseInfo", param, new { ConnectId = GovVar.ConnectId }.ToStringObjectDictionary(),
                                       (ret, res) =>
            {
                if ((bool)ret.Success)
                {
                    foreach (var row in ret.rows)
                    {
                        dynamic item = new ExpandoObject();
                        DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                        ResidentBaseInfo dtItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <ResidentBaseInfo>();
                        residentBaseInfos.Add(dtItem);
                    }
                    var total  = ret.total.Value;
                    _nMax      = (int)total;
                    _pageCount = _nMax / _pageSize;
                    _pageCount = (_nMax % _pageSize) == 0 ? _pageCount : _pageCount + 1;
                }
                else
                {
                    _nMax      = 0;
                    _pageCount = 0;
                }
            });


            dgvResidentBaseInfo.DataSource = null;
            dgvResidentBaseInfo.DataSource = residentBaseInfos;
            dgvResidentBaseInfo.ScrollBars = ScrollBars.Both;

            txbPageTo.Text      = _pageCurrent.ToString();
            lblPageCount.Text   = "共 " + _pageCount.ToString() + " 页";
            lblRecordCount.Text = "总共 " + _nMax + " 条;当前第 " + _pageCurrent + " 页;共 " + _pageCount + " 页,每页 " + _pageSize + " 条";
            //bdngBaseInfo.BindingSource = null;
            //bdngBaseInfo.BindingSource = residentBaseInfos;
        }
Esempio n. 10
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;
            }
        }
Esempio n. 11
0
        private void btnMakeCard_Click(object sender, EventArgs e)
        {
            _icAPI.Beep();
            int sector = 0;

            if (_icAPI.AuthenticationKey(sector))
            {
                int address = 1;

                string read1 = _icAPI.ReadIC16Byte(address);
                string read2 = _icAPI.ReadIC16Byte(address + 1);
                string raw   = read1 + read2;
                int    ret0  = _icAPI.WriteIC(address, _IDNo);
                if (ret0 == 0)
                {
                    HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PAMakeCard", new { OldManId = _OldManId.ToGuid(), OperatedBy = Data.UserId, ICNo = _CurrentICNo }.ToStringObjectDictionary(), new { PACode = SettingsVar.BindingPACode, ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            MessageBoxAdapter.ShowInfo("制卡成功");
                            lblTip.Text           = "制卡成功";
                            OldManInfo oldmanInfo = Data.OldMans.SingleOrDefault(item => item.OldManId == _OldManId);
                            if (oldmanInfo != null)
                            {
                                oldmanInfo.ICNo = _CurrentICNo;
                                lblICNo.Text    = _CurrentICNo;
                            }
                            isStop            = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.OK;
                        }
                        else
                        {
                            ret0 = _icAPI.WriteIC(address, raw);
                            MessageBoxAdapter.ShowError((string)ret.ErrorMessage);
                        }
                    });
                }
                else
                {
                    MessageBoxAdapter.ShowError("写入卡失败" + ret0.ToString());
                }
            }
            else
            {
                MessageBoxAdapter.ShowError("验证密码失败");
            }
        }
Esempio n. 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;
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (checkFormData())
     {
         HttpAdapter.postSyncAsJSON(GovVar.DataPointOfManage + "/Bas/ResidentBaseInfoService/CreateInfo", getFormData(), new { ConnectId = GovVar.ConnectId }.ToStringObjectDictionary(),
                                    (ret, res) =>
         {
             if ((bool)ret.Success.Value)
             {
                 if (MessageBox.Show("新增成功,是否继续新增?", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
                 {
                     ///
                 }
                 else
                 {
                     this.Close();
                 }
             }
         });
     }
 }
Esempio n. 14
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);  //验证通过开始执行
            });
        }
Esempio n. 15
0
        private void frmSplash_Load(object sender, EventArgs e)
        {
            InitForm();

            this.UIDoStepTasks(new List <Func <bool> >()
            {
                () => {
                    #region 检查硬件环境
                    lblLoadItems.Text = _LoadItem = "检查硬件环境";
                    Application.DoEvents();
                    API icAPI = new API();
                    icAPI.InitIC();
                    if (icAPI.IcDev < 0)
                    {
                        if (MessageBoxAdapter.ShowConfirm("初始化IC读卡设备失败,请确认是否已连接IC读卡设备!是否要跳过该步骤?") == System.Windows.Forms.DialogResult.OK)
                        {
                            isBreak = false;
                        }
                        else
                        {
                            isBreak           = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                            return(false);
                        }
                    }
                    else
                    {
                        icAPI.ExitIC();
                    }
                    isBreak = false;
                    return(true);

                    #endregion
                },
                () => {
                    #region 获取业务服务器地址
                    lblLoadItems.Text = _LoadItem = "获取业务服务器地址";
                    isBreak           = false;
                    Application.DoEvents();
                    if (string.IsNullOrEmpty(SettingsVar.DataExchangePoint))
                    {
                        frmBindingPA frm = new frmBindingPA();
                        frm.ShowDialog();
                        if (frm.DialogResult != System.Windows.Forms.DialogResult.OK)
                        {
                            isBreak           = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                            return(false);
                        }
                        else
                        {
                            this.Activate();
                        }
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 连接到业务服务器
                    lblLoadItems.Text = _LoadItem = "连接到业务服务器";
                    isBreak           = false;
                    Application.DoEvents();
                    int errorCode = 0;
                    HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PADeviceBindingForSelfServiceTerminal", new { PACode = SettingsVar.BindingPACode, MachineKey = Common.MachineKey, Action = "check" }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if (!(bool)ret.Success)
                        {
                            errorCode     = (int)ret.ErrorCode;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (errorCode == 53010 || errorCode == 53011)
                    {
                        //设备未绑定或已解绑
                        frmBindingPA frm = new frmBindingPA();
                        frm.ShowDialog();
                        if (frm.DialogResult != System.Windows.Forms.DialogResult.OK)
                        {
                            isBreak           = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                            return(false);
                        }
                    }
                    else if (errorCode == 53012)
                    {
                        //失效
                        MessageBoxAdapter.ShowError("您的设备使用期已到,请联系管理员!");
                        isBreak           = true;
                        this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新机构信息
                    lblLoadItems.Text = _LoadItem = "更新机构信息";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetPAStationInfo", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            dynamic item = new ExpandoObject();
                            DynamicAdapter.Parse(item, XElement.Parse(ret.ret.ToString()));
                            PAStationInfo stationInfo = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <PAStationInfo>();
                            SettingsVar.BindingPAName = stationInfo.StationName;
                            INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_BINDING_PA_NAME, SettingsVar.BindingPAName, Common.INI_FILE_PATH);
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新老人数据
                    lblLoadItems.Text = _LoadItem = "更新老人数据";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManInfoForSelfServiceMachine", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.OldMans = new List <OldManInfo>();
                            foreach (var row in ret.rows)
                            {
                                dynamic item = new ExpandoObject();
                                DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                Data.OldMans.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <OldManInfo>());
                            }
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新配餐数据
                    lblLoadItems.Text = _LoadItem = "更新配餐数据";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManBookMealForToday", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.BookMeals = new List <BookMealInfo>();
                            foreach (var row in ret.rows)
                            {
                                dynamic item = new ExpandoObject();
                                DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                Data.BookMeals.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <BookMealInfo>());
                            }

                            //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString());
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新课程数据
                    lblLoadItems.Text = _LoadItem = "更新课程数据";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/LoadStationCourseList", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.Courses = new List <CourseInfo>();
                            foreach (var row in ret.rows)
                            {
                                dynamic item = new ExpandoObject();
                                DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                Data.Courses.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <CourseInfo>());
                            }

                            //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString());
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    allLoaded         = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    return(true);
                }
            }, Common.msDelay);

            lblLoadItems.UIDoCircleTask(() =>
            {
                if (dotNum == 3)
                {
                    lblLoadItems.Text = _LoadItem;
                    dotNum            = 0;
                }
                else
                {
                    lblLoadItems.Text += ".";
                    dotNum++;
                }
            }, Common.msDot, () =>
            {
                return(allLoaded || isBreak);
            });
        }
Esempio n. 16
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 跳过,否则执行
            }));
        }
        private void SubmitDataOfMerchant()
        {
            //if (item != null)
            //{
            new Action(() =>
            {
                if (MessageBoxAdapter.ShowConfirm("您确定要提交修改吗") == System.Windows.Forms.DialogResult.OK)
                {
                    if (!string.IsNullOrEmpty(stationId))
                    {
                        string url = MerchantVar.CurrentMerchant.AuthNodeInfos.FirstOrDefault(s => s.StationId.ToString() == stationId).AccessPoint;

                        if (!string.IsNullOrEmpty(url))
                        {
                            StringObjectDictionary postParam = new
                            {
                                StationId = Guid.Parse(stationId)
                            }.ToStringObjectDictionary();

                            //接单方式
                            var cbxAcceptTypeList = pnlAcceptType.Controls.OfType <CheckBox>().Where(c => c.Checked);
                            if (cbxAcceptTypeList != null)
                            {
                                foreach (var row in cbxAcceptTypeList)
                                {
                                    postParam["AcceptType"] = row.Name.Substring(3, 5) + ",";
                                }
                            }
                            //结算周期
                            RadioButton rbOfSettlementPeriod = pnlSettlementPeriod.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                            if (rbOfSettlementPeriod != null)
                            {
                                postParam["SettlementPeriod"] = rbOfSettlementPeriod.Name.Substring(2, 5);
                            }
                            //结算方式
                            RadioButton rbOfSettlementMode = pnlSettlementMode.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                            if (rbOfSettlementPeriod != null)
                            {
                                postParam["SettlementMode"] = rbOfSettlementPeriod.Name.Substring(2, 5);
                            }

                            //接单方式
                            var cbxWorkDayList = pnlWorkDay.Controls.OfType <CheckBox>().Where(c => c.Checked);
                            if (cbxWorkDayList != null)
                            {
                                string strday = "";
                                foreach (var row in cbxWorkDayList)
                                {
                                    strday += row.Name.Substring(row.Name.Length - 1, 1) + ",";
                                }
                                postParam["WorkDay"] = strday;
                            }
                            //
                            DateTime serveBeginTime, serveEndTime;
                            if (DateTime.TryParse(dtpServeTimeBeginOfDay.Text, out serveBeginTime))
                            {
                                postParam["ServeTimeBeginOfDay"] = serveBeginTime.ToString("HH:mm");
                            }
                            if (DateTime.TryParse(dtpServeTimeEndOfDay.Text, out serveEndTime))
                            {
                                postParam["ServeTimeEndOfDay"] = serveEndTime.ToString("HH:mm");
                            }

                            postParam["ServeTimeOfDayDescription"] = txtServeTimeOfDayDescription.Text.Trim();
                            postParam["ServeExtraComment"]         = txtServeExtraComment.Text.Trim();

                            //url = url.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") ;
                            HttpAdapter.postSyncAsJSON(url + "/Oca/MerchantService", postParam, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode }.ToStringObjectDictionary(), (ret, res) =>
                            {
                                if ((bool)ret.Success)
                                {
                                    LastError = null;
                                }
                                else
                                {
                                    LastError = ret.ErrorMessage;
                                }
                            });
                        }
                    }
                }
                else
                {
                    LastError = Common.ERROR_USER_CANCEL;
                }
            }).BeginInvoke(new AsyncCallback((ar) =>
            {
                this.UIInvoke(() =>
                {
                    xLoadingPanel.Stop();
                    if (!string.IsNullOrEmpty(LastError))
                    {
                        if (LastError != Common.ERROR_USER_CANCEL)
                        {
                            MessageBoxAdapter.ShowError(LastError);
                        }
                    }
                    else
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                });
            }), null);

            xLoadingPanel.Start();
            //}
        }
        private void SubmitDataOfMerchantServeItem()
        {
            //if (item != null)
            //{
            new Action(() =>
            {
                if (MessageBoxAdapter.ShowConfirm("您确定要提交修改吗") == System.Windows.Forms.DialogResult.OK)
                {
                    if (!string.IsNullOrEmpty(stationId))
                    {
                        string url = MerchantVar.CurrentMerchant.AuthNodeInfos.FirstOrDefault(s => s.StationId.ToString() == stationId).AccessPoint;

                        if (!string.IsNullOrEmpty(url))
                        {
                            StringObjectDictionary postParam = new { Status = 1 }.ToStringObjectDictionary();
                            IList <string> ServeItemBList    = new List <string>();
                            IList <string> ServeFeeList      = new List <string>();
                            IList <string> ServeModeList     = new List <string>();

                            serveControlList.Clear();
                            dymicFindControl(tlpServerItem);
                            IEnumerable <object> checkedList = serveControlList.Where(s => (s is CheckBox) && ((CheckBox)s).Checked == true);
                            UnderlineTextBox obj_Txt;
                            CheckBox obj_Cbx;
                            foreach (var c in checkedList)
                            {
                                obj_Cbx       = (CheckBox)c;
                                string txtKey = obj_Cbx.Name.Replace("cbx", "txt");
                                obj_Txt       = (UnderlineTextBox)serveControlList.FirstOrDefault(s => (s is UnderlineTextBox) && ((UnderlineTextBox)s).Name == txtKey);
                                if (obj_Txt != null && !string.IsNullOrEmpty(obj_Txt.Text))
                                {
                                    ServeItemBList.Add(txtKey.Substring(3, 5));
                                    ServeFeeList.Add(obj_Txt.Text);
                                    postParam["Status"] = 1;
                                }
                                else
                                {
                                    postParam["Status"] = 0;
                                    LastError           = "必须填写【" + obj_Cbx.Text + "】每小时的服务费用";
                                    obj_Cbx.Focus();
                                    break;
                                }
                            }

                            if ((int)postParam["Status"] > 0)
                            {
                                IEnumerable <CheckBox> cbxModeTypes = tabPage2.Controls.OfType <CheckBox>();
                                foreach (var c in cbxModeTypes)
                                {
                                    if (c.Checked)
                                    {
                                        ServeModeList.Add(c.Name.Substring(3, 5));
                                    }
                                }
                                postParam["ServeItemB"] = ServeItemBList;
                                postParam["ServeFee"]   = ServeFeeList;
                                postParam["ServeMode"]  = ServeModeList;

                                //url = url.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/MerchantService/SetServeItemsAndServeModes/" + stationId;
                                url = url + "/Oca/MerchantService/SetServeItemsAndServeModes/" + stationId;
                                HttpAdapter.postSyncAsJSON(url, postParam, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode }.ToStringObjectDictionary(), (ret, res) =>
                                {
                                    if ((bool)ret.Success)
                                    {
                                        LastError = null;
                                    }
                                    else
                                    {
                                        LastError = ret.ErrorMessage;
                                    }
                                });
                            }
                        }
                    }
                }
                else
                {
                    LastError = Common.ERROR_USER_CANCEL;
                }
            }).BeginInvoke(new AsyncCallback((ar) =>
            {
                this.UIInvoke(() =>
                {
                    xLoadingPanel.Stop();
                    if (!string.IsNullOrEmpty(LastError))
                    {
                        if (LastError != Common.ERROR_USER_CANCEL)
                        {
                            MessageBoxAdapter.ShowError(LastError);
                        }
                    }
                    else
                    {
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                });
            }), null);
            xLoadingPanel.Start();
            //}
        }
Esempio n. 19
0
        private void FetchData()
        {
            if (!isFetchingData)
            {
                if (datas == null)
                {
                    datas = new List <WorkOrderInfo>();
                }
                else
                {
                    datas.Clear();
                }

                new Action(() =>
                {
                    isFetchingData = true;
                    if (MerchantVar.CurrentMerchant.AuthNodeInfos.Count > 0)
                    {
                        foreach (var nodeInfo in MerchantVar.CurrentMerchant.AuthNodeInfos)
                        {
                            //string url = nodeInfo.AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/GetWorkOrderFinished";
                            //string url = nodeInfo.AccessPoint + "/Oca/WorkOrderService/GetWorkOrderFinished";
                            string url = "http://localhost/SmartLife.CertManage.MerchantServices/Oca/WorkOrderService/GetWorkOrderFinished";
                            //string OldManName = txbOldManName.Text.Trim();
                            //string ServeManArriveTime = dateTimePickerArrivalTime.Text;
                            //string ServeManLeaveTime = dateTimePickerLeaveTime.Text;

                            //设置传递的参数
                            StringObjectDictionary postPram = new StringObjectDictionary();
                            if (txbOldManName.Text.Trim() != "")
                            {
                                postPram["OldManName"] = txbOldManName.Text.Trim();
                            }
                            else
                            {
                                postPram["OldManName"] = null;
                            }
                            //满意度
                            IEnumerable <RadioButton> rbsOfReturnVisit = pnlFeedbackToOldManName.Controls.OfType <RadioButton>().Where(x => x.Checked == true);
                            if (rbsOfReturnVisit != null)
                            {
                                foreach (var rb in rbsOfReturnVisit)
                                {
                                    if (rb.Name.Remove(0, 2).Remove(5) != "00000")
                                    {
                                        postPram["FeedbackToServiceStation"] = rb.Name.Remove(0, 2).Remove(5);
                                    }
                                    else
                                    {
                                        postPram["FeedbackToServiceStation"] = null;
                                    }
                                }
                            }
                            else
                            {
                                postPram["FeedbackToServiceStation"] = null;
                            }
                            //服务人员到达时间
                            postPram["ServeManArriveTime_Start"] = dateTimePickerArrivalTime.Text;

                            HttpAdapter.postSyncAsJSON(url, postPram, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = nodeInfo.StationId }.ToStringObjectDictionary(), (ret, res) =>
                            {
                                if ((bool)ret.Success)
                                {
                                    System.TimeSpan ts = new TimeSpan();
                                    foreach (var row in ret.rows)
                                    {
                                        dynamic item = new ExpandoObject();
                                        DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                        WorkOrderInfo dataItem = (item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <WorkOrderInfo>();
                                        dataItem.DoStatusName  = WorkOrderInfo.getDoStatusName(int.Parse(item.StringObjectDictionary.DoStatus));
                                        dataItem.AccessPoint   = nodeInfo.AccessPoint;
                                        dataItem.StationId     = nodeInfo.StationId;
                                        ts = DateTime.Parse(dataItem.ServeManLeaveTime).Subtract(DateTime.Parse(dataItem.ServeManArriveTime));
                                        dataItem.ServiceTime = ts.TotalHours.ToString("0.00") + "小时";
                                        if (numUDServiceTimeFrom.Text.Trim() != "" && numUDServiceTimeTo.Text.Trim() != "")
                                        {
                                            if (int.Parse(numUDServiceTimeFrom.Text.Trim()) <= float.Parse(ts.TotalHours.ToString("0.00")) && float.Parse(ts.TotalHours.ToString("0.00")) <= int.Parse(numUDServiceTimeTo.Text.Trim()))
                                            {
                                                datas.Add(dataItem);
                                            }
                                        }
                                        else if (numUDServiceTimeFrom.Text.Trim() == "" && numUDServiceTimeTo.Text.Trim() != "")
                                        {
                                            if (float.Parse(ts.TotalHours.ToString("0.00")) <= int.Parse(numUDServiceTimeTo.Text.Trim()))
                                            {
                                                datas.Add(dataItem);
                                            }
                                        }
                                        else if (numUDServiceTimeFrom.Text.Trim() != "" && numUDServiceTimeTo.Text.Trim() == "")
                                        {
                                            if (int.Parse(numUDServiceTimeFrom.Text.Trim()) <= float.Parse(ts.TotalHours.ToString("0.00")))
                                            {
                                                datas.Add(dataItem);
                                            }
                                        }
                                        else if (numUDServiceTimeFrom.Text.Trim() == "" && numUDServiceTimeTo.Text.Trim() == "")
                                        {
                                            datas.Add(dataItem);
                                        }
                                    }
                                }
                            });
                        }
                    }
                }).BeginInvoke(new AsyncCallback((ar) =>
                {
                    //AsyncResult result = (AsyncResult)ar;
                    this.UIInvoke(() =>
                    {
                        xLoadingPanel.Stop();
                        xSource.DataSource = datas;
                        xSource.ResetBindings(false);
                    });

                    isFetchingData = false;
                }), null);
                xLoadingPanel.Start();
            }
        }
Esempio n. 20
0
        private void DoLogin(string userCode, string password)
        {
            //
            btnOK.SafeButtonEnable(false);

            this.UIDoStepTasks(new List <Func <bool> >()
            {
                () => {
                    #region 检查硬件环境
                    lblLoadItems.Text = _LoadItem = "检查硬件环境";
                    Application.DoEvents();
                    API icAPI = new API();
                    icAPI.InitIC();
                    if (icAPI.IcDev < 0)
                    {
                        if (MessageBoxAdapter.ShowConfirm("初始化IC读卡设备失败,请确认是否已连接IC读卡设备!是否要跳过该步骤?") == System.Windows.Forms.DialogResult.OK)
                        {
                            btnOK.SafeButtonEnable(true);
                            isBreak = false;
                        }
                        else
                        {
                            isBreak = true;
                            return(false);
                        }
                    }
                    else
                    {
                        icAPI.ExitIC();
                    }
                    isBreak = false;
                    return(true);

                    #endregion
                },
                () => {
                    #region 读取服务机构编码
                    lblLoadItems.Text = _LoadItem = "读取服务机构编码";
                    isBreak           = false;
                    Application.DoEvents();
                    if (string.IsNullOrEmpty(SettingsVar.BindingPACode))
                    {
                        frmBindingPA frm = new frmBindingPA();
                        frm.ShowDialog();
                        if (frm.DialogResult != System.Windows.Forms.DialogResult.OK)
                        {
                            isBreak           = true;
                            this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                            btnOK.SafeButtonEnable(true);
                            return(false);
                        }
                        else
                        {
                            this.Activate();
                        }
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 用户认证
                    lblLoadItems.Text = _LoadItem = "用户认证";
                    isBreak           = false;
                    Application.DoEvents();
                    string authEndPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_END_POINT, Common.CFG_FILE_PATH);
                    string objectId     = SettingsVar.BindingPACode.Substring(2, 6);
                    HttpAdapter.postSyncAsJSON(authEndPoint, new { RunMode = SettingsVar.RunMode, ObjectId = objectId, UserCode = userCode, PasswordHash = MD5Provider.Generate(password) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.UserId = Guid.Parse((string)ret.ret.UserId);
                            SettingsVar.DataExchangePoint = (string)ret.ret.AccessPoint;
                            INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INI_KEY_USER_NAME_SINCE_LAST, userCode, Common.INI_FILE_PATH);
                        }
                        else
                        {
                            MessageBoxAdapter.ShowError((string)ret.ErrorMessage);
                            isBreak = true;
                            btnOK.SafeButtonEnable(true);
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新老人数据
                    lblLoadItems.Text = _LoadItem = "更新老人数据";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManInfoForSelfServiceMachine", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.OldMans = new List <OldManInfo>();
                            foreach (var row in ret.rows)
                            {
                                dynamic item = new ExpandoObject();
                                DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                Data.OldMans.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <OldManInfo>());
                            }

                            //MessageBoxAdapter.ShowInfo("老人:" + Data.OldMans.Count.ToString());
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    #region 更新配餐数据
                    lblLoadItems.Text = _LoadItem = "更新配餐数据";
                    isBreak           = false;
                    Application.DoEvents();
                    HttpAdapter.getSyncTo(SettingsVar.DataExchangePoint + "/Pam/PamService/GetOldManBookMealForToday", null, new { ApplicationId = Common.APPLICATION_ID, PACode = SettingsVar.BindingPACode }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            Data.BookMeals = new List <BookMealInfo>();
                            foreach (var row in ret.rows)
                            {
                                dynamic item = new ExpandoObject();
                                DynamicAdapter.Parse(item, XElement.Parse(row.ToString()));
                                Data.BookMeals.Add((item.StringObjectDictionary as IDictionary <string, object>).FromDynamic <BookMealInfo>());
                            }

                            //MessageBoxAdapter.ShowInfo("订餐:" + Data.BookMeals.Count.ToString());
                        }
                        else
                        {
                            isBreak       = true;
                            lblError.Text = ret.ErrorCode;
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);

                    #endregion
                },
                () => {
                    allLoaded         = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    return(true);
                }
            }, Common.msDelay);

            lblLoadItems.UIDoCircleTask(() =>
            {
                if (dotNum == 3)
                {
                    lblLoadItems.Text = _LoadItem;
                    dotNum            = 0;
                }
                else
                {
                    lblLoadItems.Text += ".";
                    dotNum++;
                }
            }, Common.msDot, () =>
            {
                return(allLoaded || isBreak);
            });
        }
Esempio n. 21
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);
            }    //当数据队列为空时跳过
                );
        }
Esempio n. 22
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);
                }//暂时永远不跳过
                                              ));
            }
        }
Esempio n. 23
0
        private void SubmitData()
        {
            if (item != null)
            {
                new Action(() =>
                {
                    int doStatus = int.Parse(item.StringObjectDictionary.DoStatus);

                    if (doStatus == 0)
                    {
                        //响应工单
                        if (MessageBoxAdapter.ShowConfirm("您确定要响应工单吗") == System.Windows.Forms.DialogResult.OK)
                        {
                            //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/ResponseWorkOrder";
                            string url = AccessPoint + "/Oca/WorkOrderService/ResponseWorkOrder";
                            HttpAdapter.postSyncAsJSON(url, new { WorkOrderId = Guid.Parse(WorkOrderId) }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) =>
                            {
                                if ((bool)ret.Success)
                                {
                                    LastError = null;
                                }
                                else
                                {
                                    LastError = ret.ErrorMessage;
                                }
                            });
                        }
                        else
                        {
                            LastError = Common.ERROR_USER_CANCEL;
                        }
                    }
                    else
                    {
                        //商家填写工单服务过程信息
                        if (MessageBoxAdapter.ShowConfirm("您确定要提交工单服务处理与反馈吗") == System.Windows.Forms.DialogResult.OK)
                        {
                            bool canSubmit = true;
                            StringObjectDictionary postParam = new { WorkOrderId = Guid.Parse(WorkOrderId), ServeResultRemark = txtServeResultRemark.Text.Trim(), FeedbackRemarkToOldMan = txtFeedbackRemarkToOldMan.Text.Trim() }.ToStringObjectDictionary();

                            if (txtServeManName.Text.Trim() != "")
                            {
                                postParam["ServeManName"] = txtServeManName.Text.Trim();
                            }
                            else
                            {
                                LastError = "必须填写服务人";
                                canSubmit = false;
                            }
                            DateTime serveBeginTime, serveEndTime;
                            if (canSubmit)
                            {
                                if (DateTime.TryParse(dtpServeBeginTime.Text, out serveBeginTime))
                                {
                                    postParam["ServeBeginTime"] = serveBeginTime;
                                }
                                else
                                {
                                    LastError = "必须填写服务开始时间";
                                    canSubmit = false;
                                }
                            }
                            if (canSubmit)
                            {
                                if (DateTime.TryParse(dtpServeEndTime.Text, out serveEndTime))
                                {
                                    postParam["ServeEndTime"] = serveEndTime;
                                }
                                else
                                {
                                    LastError = "必须填写服务结束时间";
                                    canSubmit = false;
                                }
                            }
                            if (canSubmit)
                            {
                                RadioButton rbOfServeResultName = pnlServeResultName.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                                if (rbOfServeResultName != null)
                                {
                                    string serveResult       = rbOfServeResultName.Name.Substring(2, 5);
                                    postParam["ServeResult"] = serveResult;
                                }
                                else
                                {
                                    LastError = "必须填写服务结果";
                                    canSubmit = false;
                                }
                            }

                            if (canSubmit)
                            {
                                RadioButton rbOfFeedbackToOldManName = pnlFeedbackToOldManName.Controls.OfType <RadioButton>().FirstOrDefault(r => r.Checked);
                                if (rbOfFeedbackToOldManName != null)
                                {
                                    string feedbackToOldMan       = rbOfFeedbackToOldManName.Name.Substring(2, 5);
                                    postParam["FeedbackToOldMan"] = feedbackToOldMan;
                                }
                                else
                                {
                                    LastError = "必须评价老人";
                                    canSubmit = false;
                                }
                            }


                            if (canSubmit)
                            {
                                //string url = AccessPoint.Replace("http://115.236.175.110:17000/merchantservices", "http://localhost/SmartLife.CertManage.MerchantServices") + "/Oca/WorkOrderService/InputWorkOrder";
                                string url = AccessPoint + "/Oca/WorkOrderService/InputWorkOrder";
                                HttpAdapter.postSyncAsJSON(url, postParam, new { ApplicationId = Common.APPLICATION_ID, Token = MerchantVar.CurrentMerchant.Token, StationCode = MerchantVar.StationCode, StationId = StationId }.ToStringObjectDictionary(), (ret, res) =>
                                {
                                    if ((bool)ret.Success)
                                    {
                                        LastError = null;
                                    }
                                    else
                                    {
                                        LastError = ret.ErrorMessage;
                                    }
                                });
                            }
                        }
                        else
                        {
                            LastError = Common.ERROR_USER_CANCEL;
                        }
                    }
                }).BeginInvoke(new AsyncCallback((ar) =>
                {
                    //AsyncResult result = (AsyncResult)ar;
                    this.UIInvoke(() =>
                    {
                        xLoadingPanel.Stop();

                        if (!string.IsNullOrEmpty(LastError))
                        {
                            if (LastError != Common.ERROR_USER_CANCEL)
                            {
                                MessageBoxAdapter.ShowError(LastError);
                            }
                        }
                        else
                        {
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    });
                }), null);

                xLoadingPanel.Start();
            }
        }
        private void BindingPA()
        {
            string bindingPACode = txtBindingCode.Text.Trim();

            ObjectId = bindingPACode.Substring(2, 6);
            if (ObjectId.Length < 6)
            {
                MessageBoxAdapter.ShowError("无效的PA码");
                return;
            }


            string authDataPoint = INIAdapter.ReadValue(Common.CFG_SECTION_WEB, Common.CFG_KEY_AUTH_DATA_POINT, Common.CFG_FILE_PATH);


            this.UIDoStepTasks(new List <Func <bool> >()
            {
                () => {
                    lblLoadItems.Text = _LoadItem = "获取业务服务器地址";
                    isBreak           = false;
                    HttpAdapter.getSyncTo(authDataPoint + string.Format("/GetDeployNode/{0},{1},IC001", ObjectId, SettingsVar.RunMode), null, new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            SettingsVar.DataExchangePoint = (string)ret.ret.AccessPoint;
                            INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_DATA_EXCHANGE_POINT, SettingsVar.DataExchangePoint, Common.INI_FILE_PATH);
                        }
                        else
                        {
                            isBreak = true;
                            MessageBoxAdapter.ShowError((string)ret.ErrorMessage);
                        }
                    });

                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);
                },
                () => {
                    lblLoadItems.Text = _LoadItem = "绑定设备";
                    isBreak           = false;
                    HttpAdapter.postSyncAsJSON(SettingsVar.DataExchangePoint + "/Pam/PamService/PADeviceBindingForSelfServiceTerminal", new { PACode = bindingPACode, MachineKey = Common.MachineKey, Action = "binding" }.ToStringObjectDictionary(), new { ApplicationId = Common.APPLICATION_ID }.ToStringObjectDictionary(), (ret, res) =>
                    {
                        if ((bool)ret.Success)
                        {
                            SettingsVar.BindingPACode = bindingPACode;
                            INIAdapter.WriteValue(Common.INI_SECTION_LOCAL, Common.INT_KEY_BINDING_PA_CODE, SettingsVar.BindingPACode, Common.INI_FILE_PATH);
                        }
                        else
                        {
                            MessageBoxAdapter.ShowError((string)ret.ErrorCode);
                        }
                    });
                    if (isBreak)
                    {
                        return(false);
                    }
                    return(true);
                },
                () => {
                    allLoaded         = true;
                    this.DialogResult = System.Windows.Forms.DialogResult.OK;
                    return(true);
                }
            }, Common.msDelay);

            lblLoadItems.UIDoCircleTask(() =>
            {
                if (dotNum == 3)
                {
                    lblLoadItems.Text = _LoadItem;
                    dotNum            = 0;
                }
                else
                {
                    lblLoadItems.Text += ".";
                    dotNum++;
                }
            }, Common.msDot, () =>
            {
                return(allLoaded || isBreak);
            });
        }