Exemplo n.º 1
0
        /// <summary>扫描业务主体
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            //设置timer不可用
            timer.Stop();
            try
            {
                Orderexception        exception = new Orderexception();
                OrderexceptionService service   = new OrderexceptionService();

                //调用登陆验证方法(string Login(UserName: string; Password: string; Operator: string))返回SID
                //UserName,Password来源配置文件,Operator为空
                string username = ConfigurationManager.AppSettings["UserName"];
                string password = ConfigurationManager.AppSettings["Password"];
                string Operator = ConfigurationManager.AppSettings["Operator"];
                SendOrdersToLis.CenterServiceSoapClient client = new SendOrdersToLis.CenterServiceSoapClient();

                //按分点查找
                List <Dictlab> labLst = labser.GetDictlabList().Where(c => c.IsActive == '1').ToList <Dictlab>();
                //最后一次更新时间

                foreach (Dictlab dictlab in labLst)
                {
                    string lastDate = service.SelectOrderExceptionLastDate(dictlab.Labcode);
                    if (lastDate == null)
                    {
                        lastDate = DateTime.Now.AddDays(-30).ToString();
                        //lastDate = "2012-12-01";
                    }
                    if (!ht.ContainsKey(dictlab.Labcode))
                    {
                        string strsid = client.Login(dictlab.Labcode, username, password, Operator);
                        if (strsid.Split('|')[0].ToString() == "1")
                        {
                            strsid = strsid.Split('|')[1].ToString();
                            ht.Add(dictlab.Labcode, strsid);
                        }
                        else
                        {
                            strMsg = string.Format(">>>{0}    {1}:登录失败!{2}", DateTime.Now, dictlab.Labname, strsid.Split('|')[1].ToString());

                            AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                            this.Invoke(addNode, strMsg);
                            continue;
                        }
                    }
                    // 获取LIS的取消审核与退单信息
                    string strmessage = client.SelectPesExceptionLst(ht[dictlab.Labcode].ToString(), dictlab.Labcode, lastDate);

                    if (strmessage.Contains("MSG0006")) //登陆超时
                    {
                        ht.Remove(dictlab.Labcode);
                        strMsg = string.Format(">>>{0}    {1}:登录超时", DateTime.Now, dictlab.Labname);
                        AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                        this.Invoke(addNode, strMsg);
                        continue;
                    }
                    else
                    {
                        string[] strcontent = strmessage.Split('|');
                        if (strcontent[0] == "0")
                        {
                            strMsg = string.Format(">>>{0}    {1}:未查询到数据", DateTime.Now, dictlab.Labname);
                            AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                            this.Invoke(addNode, strMsg);
                            continue;
                        }
                        else
                        {
                            DataSet ds = new CommonFuncLibService().CXmlToDataSet(strcontent[1]);
                            if (service.AddOrderExceptional(ds.Tables[0], dictlab.Labcode))
                            {
                                strMsg = string.Format("***{0}    {1}:异常信息获取成功", DateTime.Now, dictlab.Labname);
                                AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                                this.Invoke(addNode, strMsg);
                            }
                            else
                            {
                                strMsg = string.Format(">>>{0}    {1}:异常信息获取失败,方法名称:SelectPesExceptionLst", DateTime.Now, dictlab.Labname);
                                AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                                this.Invoke(addNode, strMsg);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                strMsg = string.Format(">>>{0}    {1}", DateTime.Now.ToString() + ":  " + ex.Message);
                AddNodeHandler addNode = new AddNodeHandler(this.TreeViewAdd);
                this.Invoke(addNode, strMsg);
            }
            finally
            {
                if (timer != null)
                {
                    timer.Start();
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 开始计时
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (b)
            {
                return;
            }
            //设置timer不可用
            timer.Stop();//
            //传输数据

            try
            {
                #region  输数据
                // LoginService loginservice = new LoginService();
                OrdersService       orderservice        = new OrdersService();
                OrderbarcodeService orderbarcodeservice = new OrderbarcodeService();
                Stopwatch           sw = new Stopwatch();

                //调用登陆验证方法(string Login(UserName: string; Password: string; Operator: string))返回SID
                //UserName,Password来源配置文件,Operator为空
                string username = ConfigurationManager.AppSettings["UserName"];
                string password = ConfigurationManager.AppSettings["Password"];
                string Operator = ConfigurationManager.AppSettings["Operator"];
                SendOrdersToLis.CenterServiceSoapClient client = new SendOrdersToLis.CenterServiceSoapClient();
                sw.Start();
                // int t = 0;
                string strM = "";
                //按分点查找
                List <Dictlab> labLst = labser.GetDictlabList().Where(c => c.IsActive == '1').ToList <Dictlab>();
                #region
                foreach (Dictlab dictlab in labLst)
                {
                    //查询分点下面有没有数据
                    DataTable dt = orderservice.GetOrderToLis(dictlab.Dictlabid);// orderservice.GetOrderToLis(dictlab.Dictlabid);
                    if (dt.Rows.Count > 0)
                    {
                        if (!ht.ContainsKey(dictlab.Labcode))
                        {
                            string strsid = client.Login(dictlab.Labcode, username, password, Operator);
                            if (strsid.Split('|')[0] == "1")
                            {
                                strsid = strsid.Split('|')[1];
                                ht.Add(dictlab.Labcode, strsid);
                            }
                            else
                            {
                                string strS01 = String.Format("{0}登录失败!\n{1}", dictlab.Labname, strsid.Split('|')[1]);
                                SetTB(strS01);
                                continue;
                                //return;
                            }
                        }
                        #region
                        dt.TableName = "data_row";
                        string strxml = DataToXml.CDataToXml(dt);//将订单信息转换成xml形式的字符串
                        //根据SID,分点,及分点下的订单信息(xml字符串形式)调用Webservice上传数据到Lis
                        string strmessage = client.SendRequestInfo(ht[dictlab.Labcode].ToString(), dictlab.Labcode, StringToXML(strxml));

                        if (strmessage.Contains("MSG0006")) //登陆超时
                        {
                            ht.Remove(dictlab.Labcode);
                            SetTB(dictlab.Labname + " 登录超时!");
                            continue;
                        }
                        else
                        {
                            string[] strsp = strmessage.Split(',');
                            #region for
                            for (int k = 0; k < strsp.Length - 1; k++)
                            {
                                string[] s = strsp[k].Split('|');
                                if (s[3] == "0")
                                {
                                    strM += String.Format("{0}  达安条码[{1}],上传成功!\n", dictlab.Labname, s[0]);
                                    //上传后 如果成功就跟新orderbarcode中transed=1并给出成功提示信息,如果失败则给出失败信息
                                    orderbarcodeservice.UpdateTransedToLis(s[0]);
                                }
                                else
                                {
                                    string[] g = s[3].Split('/');
                                    #region for
                                    for (int i = 0; i < g.Length - 1; i++)
                                    {
                                        if (g[i] == "MSG1001")
                                        {
                                            strM += "申请信息不全,达安条码、医院条码、标本唯一标识不能全为空;";
                                        }
                                        if (g[i] == "MSG1002")
                                        {
                                            strM += String.Format("达安条码[{0}],申请信息姓名、性别、年龄必填项,有空值;", s[0]);
                                        }
                                        if (g[i] == "MSG1003")
                                        {
                                            strM += String.Format("达安条码[{0}],有匹配不正确的达安项目代码;", s[0]);
                                        }
                                        if (g[i] == "MSG1004")
                                        {
                                            strM += String.Format("达安条码[{0}],年龄格式不正确;", s[0]);
                                        }
                                        if (g[i] == "MSG1005")
                                        {
                                            strM += String.Format("达安条码[{0}],采样时间不能转换成时间格式;", s[0]);
                                        }
                                        if (g[i] == "MSG1007")
                                        {
                                            strM += String.Format("达安条码[{0}],病人电话格式错误;", s[0]);
                                        }
                                        if (g[i] == "MSG1008")
                                        {
                                            strM += String.Format("达安条码[{0}],医生电话格式错误;", s[0]);
                                        }
                                        if (g[i] == "MSG1009")
                                        {
                                            strM += String.Format("达安条码[{0}],病理标本、细菌标本必须单独信息;", s[0]);
                                        }
                                        if (g[i] == "MSG1010")
                                        {
                                            strM += String.Format("达安条码[{0}],性别必须为M或者F或者U;", s[0]);
                                        }
                                    }
                                    #endregion
                                    //失败信息,更新orderbarcode中transed=2
                                    if (s[0] != null && s[0] != "")
                                    {
                                        orderbarcodeservice.UpdateTransedToLisFail(s[0]);
                                    }
                                }
                            }
                            #endregion
                            SetTB(strM);
                            strM = null;
                        }
                        #endregion
                    }
                    else
                    {
                        string str2 = dictlab.Labname + "没有传输的数据!\n";
                        SetTB(str2);
                    }

                    #endregion
                    sw.Stop();
                }
                #endregion
            }
            catch (Exception ex)
            {
                string exmessage = String.Format("{0}:  {1}", DateTime.Now, ex.Message);
                SetTB(exmessage);
                CreateErrorLog(exmessage);
            }
            finally
            {
                //设置timer可用
                timer.Start();
            }
        }