Example #1
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                = "HZK320P样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\HZK320P.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       password            = sr.ReadLine();
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                //拆分路径,寻找地址
                string configPathDateTime = DateTime.Now.ToString("yyyyMMdd");
                configPath = configPath + "yb" + configPathDateTime + ".mdb";

                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice,
                                   configPath + "没有找到,系统进入下一个循环周期", "log");
                    return;
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(ybno) as ItemNo  from  zzjgb ";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                strTestTime = dateTime;

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  *  from  zzjgb where    ybno=in_编号  ";
                        sqlSelect = sqlSelect.Replace("in_编号", strSampleNo);

                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                string itemName  = item2["ywjc"].ToString();
                                double itemValue = Convert.ToDouble(item2["zzjg"].ToString());
                                itemValue = Math.Round(itemValue, 2);
                                TestValues.Add(itemName + ":" + itemValue.ToString());
                                sBuilder.Append(itemName + ',' + itemValue + '|');
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }

            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Example #2
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            #region 设置为串口通讯的时候
            //char c03 = Convert.ToChar(0x03);
            //char c0f = Convert.ToChar(0x0F);
            //char c00 = Convert.ToChar(0x00);
            //#region
            ////存储每次接收后的10进制字符串
            //char[] chars = strSource.ToCharArray();
            //writelog.Write(strDevice, "接收数据开始:"+strSource, "log");
            //string output = "";
            //for (int i = 0; i < chars.Length; i++)
            //{
            //    output = output + Convert.ToInt32(chars[i]) + " ";
            //}
            //writelog.Write(strDevice, "10进制接收数据:"+output, "log");

            ////
            //#endregion

            ////去掉空
            //strSource = strSource.Replace(c00, ' ').Trim();
            //strResult += strSource;
            //if (strSource.EndsWith(c03+""))
            //{
            // try
            //    {
            //        bool isSampleBar = true;
            //        //将接收到的字符串写入到日志文件中
            //        writelog.Write(strDevice, "接收数据开始:\r\n " + strResult, "log");
            //        writelog.Write(strDevice, "接收数据完成 ", "log");
            //        StreamReader sr = new StreamReader(@".\MVIS2010.txt");
            //        string correspondence = sr.ReadLine();
            //        sr.Close();
            //        string[] correspondenceArray = correspondence.Split('|');
            //        StringBuilder sBuilder = new StringBuilder("");
            //        string[] ss = strResult.Split(new char[] { '\r','\n' }, StringSplitOptions.RemoveEmptyEntries);
            //        string ChannelCode = "";
            //        for (int i = 0; i < ss.Length; i++)
            //        {
            //            if (ss[i].Trim().ToUpper().StartsWith("SN"))
            //            {
            //                strSampleNo = ss[i].Split(':')[1].Trim();
            //            }
            //            if (ss[i].Trim().ToUpper().StartsWith("DATE"))
            //            {
            //                strTestTime = ss[i].Replace("Date:","").Trim();
            //            }
            //            for (int j = 0; j < correspondenceArray.Length; j++)
            //            {
            //                string sTemp = ss[i].Trim();
            //                string lis = correspondenceArray[j].Split(',')[0];
            //                string zlchs = correspondenceArray[j].Split(',')[1];
            //                if (ss[i].StartsWith(lis))
            //                {
            //                    string itemValue = ss[i].Split(':')[1].Trim();
            //                    if (itemValue.IndexOf(" ") > -1)
            //                        itemValue = itemValue.Split(' ')[0];
            //                    sBuilder.Append(zlchs + ',' + itemValue + '|');
            //                }
            //            }
            //        }

            //        string str = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);

            //        writelog.Write(strDevice, "数据处理结果:" + str, "log");

            //        string[] strs = str.Split('|');

            //        string ChannelType = "";     //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
            //        string testItemID = "";
            //        string TestResultValue = "";
            //        for (int i = 0; i < strs.Length; i++)
            //        {
            //            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
            //            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
            //            {
            //                ChannelType = null;
            //                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
            //            }
            //            else
            //            {
            //                testItemID = FindRow[0]["项目id"].ToString();
            //                ChannelType = "0"; //普通结果
            //                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
            //            }
            //        }
            //        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
            //        saveResult = new SaveResult();
            //        if (!string.IsNullOrEmpty(strSampleNo))
            //        {
            //          saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);       if (ImmediatelyUpdate)
            //            {
            //                saveResult.UpdateData();
            //            }
            //        }
            //        if (!ImmediatelyUpdate)
            //        {
            //            saveResult.UpdateData();
            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            //    }
            //    strResult = "";
            //}
            //strCmd = Convert.ToChar(0x06) + "";
            #endregion
            try
            {
                string       file                = "MVIS2010样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\MVIS2010.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       configPathSrc       = configPath;
                string       password            = sr.ReadLine();
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                //拆分路径,寻找地址
                string[] configPaths      = configPath.Split('_');
                string   configPathRoot   = configPaths[0] + '_' + configPaths[1] + '_';
                string   configPathEndStr = DateTime.Now.ToString("yyyy_MM");
                configPath = configPathRoot + configPathEndStr + ".mdb";
                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice,
                                   configPath + "没有找到本月源数据,尝试寻找上一月", "log");
                    string configPathLastMonth = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-01")).AddMonths(-1).ToString("yyyy_MM");
                    configPath = configPathRoot + configPathLastMonth + ".mdb";
                    if (!File.Exists(configPath))
                    {
                        writelog.Write(strDevice,
                                       configPath + "没有找到上月源数据,尝试寻找原始配置文件", "log");
                        configPath = configPathSrc;;
                        if (!File.Exists(configPath))
                        {
                            writelog.Write(strDevice,
                                           configPath + "没有找到,系统进入下一个循环周期", "log");
                            return;
                        }
                    }
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(SN) as ItemNo  from  Test where Format(todaydate, 'yyyy-mm-dd')='" + dateTime + "'";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                strTestTime = dateTime;

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  *  from  Test where    SN=in_编号 and  Format(todaydate, 'yyyy-mm-dd')=  'in_clrq' ";
                        sqlSelect = sqlSelect.Replace("in_编号", strSampleNo);
                        sqlSelect = sqlSelect.Replace("in_clrq", dateTime);
                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                foreach (var subItem in correspondenceArray)
                                {
                                    string lis   = subItem.Split(',')[0].Trim();
                                    string zlchs = subItem.Split(',')[1].Trim();

                                    string itemName  = zlchs;
                                    double itemValue = Convert.ToDouble(item2[lis].ToString());
                                    itemValue = Math.Round(itemValue, 2);
                                    TestValues.Add(itemName + ":" + itemValue.ToString());
                                    sBuilder.Append(itemName + ',' + itemValue + '|');
                                }
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = "";     //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0)     //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }

            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Example #3
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime   = ""; //检验时间
            string strSampleNo   = ""; //标本号
            string strBarCode    = ""; //条码
            string strOperator   = ""; //检验医师
            string strSampleType = ""; //检验类型
            string StrSpecimen   = ""; //标本类型


            //连接access数据库
            //配置文件中读取密码,查询语句
            //读取配置文件
            try
            {
                string       file                = "FC3样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\FC3.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       pwd                 = sr.ReadLine().Replace("pwd:", "");
                sr.Close();
                string    connStr  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"yyyy-MM-dd");
                string    sql      = "SELECT   distinct(testno) as testNo   from samples   where  Format(gatherdate, 'yyyy-mm-dd') ='" + dateTime + "'";
                DataTable dt       = OleDBHelper.GetOledbDataTable(sql, connStr);
                foreach (DataRow item in dt.Rows)
                {
                    string testNo = item["testNo"].ToString();
                    strSampleNo = testNo;
                    strTestTime = dateTime;
                    string sqlSelect = @"select *  from  samples  where  Format(gatherdate, 'yyyy-mm-dd') ='in_testTime' and  testno=in_testNo";
                    sqlSelect = sqlSelect.Replace("in_testTime", dateTime);
                    sqlSelect = sqlSelect.Replace("in_testNo", testNo);

                    DataTable     dt2        = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                    List <string> TestValues = new List <string>();

                    StringBuilder sBuilder = new StringBuilder();
                    foreach (DataRow subItem in dt2.Rows)
                    {
                        string lisTestName  = subItem["outname"].ToString();
                        string lisTestValue = subItem["result"].ToString();
                        sBuilder.Append(lisTestName + "," + lisTestValue + "|");
                        TestValues.Add(lisTestName + ":" + lisTestValue);
                    }
                    if (Helper.CompareSampleNoAndTime(file, testNo, strTestTime, TestValues))
                    {
                        continue;
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');
                    sBuilder = null;
                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);


                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, e.ToString(), "log");
            }
        }
Example #4
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                = "D280样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\D280.txt", Encoding.Default);
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();

                strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();
                if (!File.Exists(configPath))
                {
                    writelog.Write(strDevice, "找不到数据库文件: " + configPath, "log");
                    return;
                }
                string connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password=iamysh";
                string sql     = "select distinct(sample_id) as ItemNo  from  SAMPLE_ITEM_TEST_RESULT   where   format(time,'yyyy-MM-dd')='in_dateTimeName'";
                sql = sql.Replace("in_dateTimeName", strTestTime);
                DataTable dt = OleDBHelper.GetOledbDataTable(sql, connStr);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"  select *  from SAMPLE_ITEM_TEST_RESULT where sample_id='in_strSampleNo' and format(time,'yyyy-MM-dd')='in_dateTimeName' ";
                        sqlSelect = sqlSelect.Replace("in_dateTimeName", strTestTime);
                        sqlSelect = sqlSelect.Replace("in_strSampleNo", strSampleNo);
                        DataTable     dt2        = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                string itemName  = item2["item"].ToString().ToUpper();
                                string itemValue = item2["result"].ToString().ToUpper();
                                TestValues.Add(itemName + ":" + itemValue.ToString());
                                sBuilder.Append(itemName + ',' + itemValue + '|');
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(5000);
        }
Example #5
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            //连接access数据库
            //配置文件中读取密码,查询语句
            //读取配置文件
            try
            {
                init();
                string       file                = "SF8000样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\SF8000.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                sr.Close();
                string connStr  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"yyyy-MM-dd");
                strTestTime = dateTime;
                string    sql = "select distinct(标本号) as 标本号  from  TB_TEST_RESULT   where  Format(测试日期, 'yyyy-mm-dd')='" + dateTime + "'";
                DataTable dt  = OleDBHelper.GetOledbDataTable(sql, connStr);
                foreach (DataRow item in dt.Rows)
                {
                    string        time1      = "";
                    string        no1        = "";
                    StringBuilder sBuilder   = new StringBuilder();
                    string        bbh        = item["标本号"].ToString();
                    string        sqlSelect  = @"select id,标本号,标本孔位,项目编号,项目名称,测试通道,结果状态,单位,Format(测试日期,'yyyy-mm-dd') as 测试日期,format(测试时间,'Long Time') as 测试时间,测试次序,已删除 , 测试结果 FROM TB_TEST_RESULT A where Format(测试日期, 'yyyy-mm-dd')='" + dateTime + "' and  标本号 =" + bbh;
                    DataTable     dt2        = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                    List <string> TestValues = new List <string>();
                    foreach (DataRow item1 in dt2.Rows)
                    {
                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            string strTestTime_little = item1["测试时间"].ToString().Trim();
                            string strTestTime1       = item1["测试日期"].ToString().Trim();
                            strTestTime = strTestTime1 + " " + strTestTime_little;
                            strSampleNo = bbh;
                            no1         = bbh;
                            time1       = strTestTime;
                            string returns = Helper.SampleNoToSampleBar(bbh);
                            if (!string.IsNullOrEmpty(returns))
                            {
                                strTestTime = returns.Split('|')[0];
                                strSampleNo = returns.Split('|')[1];
                                strBarCode  = bbh;
                            }
                            string lis     = correspondenceArray[j].Split(',')[0].Trim();
                            string zlchs   = correspondenceArray[j].Split(',')[1];
                            string lisName = item1["项目名称"].ToString().Trim();
                            string lisUnit = lisName + item1["单位"].ToString().Trim();
                            TestValues.Add(lisName + ":" + item1["测试结果"].ToString());
                            if (lisUnit.Equals(lis))
                            {
                                sBuilder.Append(zlchs + ',' + item1["测试结果"].ToString().Trim() + '|');
                            }
                        }
                    }
                    if (Helper.CompareSampleNoAndTime(file, no1, strTestTime, TestValues))
                    {
                        continue;
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');
                    sBuilder = null;
                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }
                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
            }
            catch (Exception ex)
            {
                writelog.Write(strDevice, "处理失败: " + ex.ToString(), "log");
            }
            System.Threading.Thread.Sleep(10000);
        }
Example #6
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            //连接access数据库
            //配置文件中读取密码,查询语句
            //读取配置文件
            string file = "FC3样本号重复处理.txt";

            init();
            StreamReader sr             = new StreamReader(@".\FC3.txt", System.Text.Encoding.GetEncoding("GB2312"));
            string       correspondence = sr.ReadLine();

            string[] correspondenceArray = correspondence.Split('|');
            string   configPath          = sr.ReadLine();

            sr.Close();

            string connStr  = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"yyyy-MM-dd");


            strTestTime = dateTime;
            // dateTime = "2016-06-15";
            string sql = "select distinct(Swatch) as swatch  from  result   where    Format(CheckDate, 'yyyy-mm-dd')='" + dateTime + "'";

            DataTable dt = OleDBHelper.GetOledbDataTable(sql, connStr);

            // sqlMessage="select 标本号,测试日期,测试时间,项目名称,测试结果  FROM TB_TEST_RESULT A where 测试时间="


            foreach (DataRow item in dt.Rows)
            {
                string    time1     = "";
                string    no1       = "";
                string    bbh       = item["Swatch"].ToString();
                string    sqlSelect = @"SELECT Swatch,Result,ProName,DW_Unit,Format(CheckDate,'yyyy-mm-dd hh:nn:ss') as   CheckDate    FROM result   where Format(CheckDate, 'yyyy-mm-dd')='" + dateTime + "'       and  Swatch ='" + bbh + "'";
                DataTable dt2       = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);
                try
                {
                    StringBuilder sBuilder = new StringBuilder();
                    foreach (DataRow item1 in dt2.Rows)
                    {
                        for (int j = 0; j < correspondenceArray.Length; j++)
                        {
                            strTestTime = item1["CheckDate"].ToString().Trim();
                            strSampleNo = bbh;
                            time1       = strTestTime;
                            no1         = bbh;
                            string returns = Helper.SampleNoToSampleBar(bbh);
                            if (!string.IsNullOrEmpty(returns))
                            {
                                strTestTime = returns.Split('|')[0];
                                strSampleNo = returns.Split('|')[1];
                                strBarCode  = bbh;
                            }
                            string lis   = correspondenceArray[j].Split(',')[0].Trim().ToUpper();
                            string zlchs = correspondenceArray[j].Split(',')[1].Trim().ToUpper();

                            string lisUnit = item1["ProName"].ToString().Trim().ToUpper();
                            if (lisUnit.Equals(lis))
                            {
                                sBuilder.Append(zlchs.ToUpper() + ',' + item1["Result"].ToString().Trim() + '|');
                            }
                        }
                    }
                    if (Helper.CompareSampleNoAndTime(file, no1, time1))
                    {
                        continue;
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');
                    sBuilder = null;
                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                    {
                        //strInstrument_id 替换到目标设备
                        if (string.IsNullOrEmpty(strReserved))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        }
                        else
                        {
                            saveResult.SaveTextResult(strReserved, TestResultValue, TestGraph, DrSampleNoField);
                        }

                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }
                }
                catch (Exception e)
                {
                    writelog.Write(strDevice, e.ToString(), "log");

                    writelog.Write(strDevice, "===========================标本号存在异常=======================:" + bbh, "log");
                }
            }
            // System.Threading.Thread.Sleep(5000);
        }
Example #7
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            try
            {
                string       file                = "BIOBASE.BK400样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\BIOBASE.BK400.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       dateTimeName        = DateTime.Now.ToString("yyyyMMdd");
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                configPath = configPath + dateTimeName + ".mdb";
                sr.Close();
                if (!File.Exists(configPath))
                {
                    return;
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(sampleNo) as sampleNo  from  sampleInfo   where  Format(SampleTime, 'yyyy-mm-dd')='" + dateTime + "'";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        string        time1     = "";
                        string        no1       = "";
                        StringBuilder sBuilder  = new StringBuilder("");
                        string        s         = item["sampleNo"].ToString();
                        string        sqlSelect = @"  select ProName as ItemCode, resultValue as TestValue , Format(a.SampleTime, 'yyyy-mm-dd') as TestTime  from sampleinfo a,sampleprogram b where  a.sampleInfoID=b.sampleInfoID and a.sampleNo= in_sampleNo  and   Format(a.SampleTime, 'yyyy-mm-dd')='in_SampleTime'";
                        sqlSelect = sqlSelect.Replace("in_sampleNo", s);
                        sqlSelect = sqlSelect.Replace("in_SampleTime", dateTime);


                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item1 in dt2.Rows)
                            {
                                strTestTime = item1["TestTime"].ToString();
                                strSampleNo = s;
                                time1       = strTestTime;
                                no1         = strSampleNo;
                                TestValues.Add(item1["ItemCode"].ToString() + ":" + item1["TestValue"].ToString());
                                for (int j = 0; j < correspondenceArray.Length; j++)
                                {
                                    string lis       = correspondenceArray[j].Split(',')[0].ToUpper();
                                    string zlchs     = correspondenceArray[j].Split(',')[1].ToUpper();
                                    string itemName  = item1["ItemCode"].ToString().ToUpper();
                                    string itemValue = item1["TestValue"].ToString().ToUpper();
                                    try
                                    {
                                        itemValue = Math.Round(Convert.ToDouble(itemValue), 2).ToString();
                                    }
                                    catch
                                    {
                                    }
                                    if (lis.Equals(itemName))
                                    {
                                        sBuilder.Append(zlchs + ',' + itemValue + '|');
                                    }
                                }
                            }
                        }
                        /////
                        if (Helper.CompareSampleNoAndTime(file, no1, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Example #8
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strTestTime   = ""; //检验时间
            string strSampleNo   = ""; //标本号
            string strBarCode    = ""; //条码
            string strOperator   = ""; //检验医师
            string strSampleType = ""; //检验类型
            string StrSpecimen   = ""; //标本类型

            try
            {
                string       file                = "SH212C样本号重复处理.txt";
                StreamReader sr                  = new StreamReader(@".\SH212C.txt", System.Text.Encoding.GetEncoding("GB2312"));
                string       correspondence      = sr.ReadLine();
                string[]     correspondenceArray = correspondence.Split('|');
                string       configPath          = sr.ReadLine();
                string       password            = sr.ReadLine();
                string       dateTime            = DateTime.Now.ToString("yyyy-MM-dd");
                sr.Close();

                if (!File.Exists(configPath))
                {
                    return;
                }
                string    connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + configPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"select distinct(编号) as ItemNo  from  病人数据表 where Format(clrq, 'yyyy-mm-dd')='" + dateTime + "'";
                DataTable dt      = OleDBHelper.GetOledbDataTable(sql, connStr);
                strTestTime = dateTime;

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow item in dt.Rows)
                    {
                        StringBuilder sBuilder = new StringBuilder("");
                        strSampleNo = item["ItemNo"].ToString();
                        string sqlSelect = @"select  *  from 病人数据表   where  编号=in_编号 and  Format(clrq, 'yyyy-mm-dd')=  'in_clrq' ";
                        sqlSelect = sqlSelect.Replace("in_编号", strSampleNo);
                        sqlSelect = sqlSelect.Replace("in_clrq", dateTime);
                        DataTable dt2 = OleDBHelper.GetOledbDataTable(sqlSelect, connStr);

                        List <string> TestValues = new List <string>();
                        if (dt2.Rows.Count > 0)
                        {
                            foreach (DataRow item2 in dt2.Rows)
                            {
                                foreach (var subItem in correspondenceArray)
                                {
                                    string lis   = subItem.Split(',')[0].Trim();
                                    string zlchs = subItem.Split(',')[1].Trim();

                                    string itemName  = zlchs;
                                    string itemValue = item2[lis].ToString().ToUpper();
                                    TestValues.Add(itemName + ":" + itemValue.ToString());
                                    sBuilder.Append(itemName + ',' + itemValue + '|');
                                }
                            }
                        }

                        /////
                        if (Helper.CompareSampleNoAndTime(file, strSampleNo, strTestTime, TestValues))
                        {
                            continue;
                        }
                        string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                        string[] strs = str.Split('|');

                        string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                        string testItemID      = "";
                        string TestResultValue = "";
                        for (int i = 0; i < strs.Length; i++)
                        {
                            FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                            if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                            {
                                ChannelType = null;
                                writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                            }
                            else
                            {
                                testItemID      = FindRow[0]["项目id"].ToString();
                                ChannelType     = "0"; //普通结果
                                TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                            }
                        }

                        TestResultValue = strTestTime + "|" + strSampleNo + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                        saveResult      = new SaveResult();
                        if (!string.IsNullOrEmpty(strSampleNo) || !string.IsNullOrEmpty(strBarCode))
                        {
                            saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                            if (ImmediatelyUpdate)
                            {
                                saveResult.UpdateData();
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }

            System.Threading.Thread.Sleep(3000);
        }
Example #9
0
        public void ParseResult(string strSource, ref string strResult, ref string strReserved, ref string strCmd)
        {
            string strSampleNo_temp = "";
            string file             = "DIRUI.CST300样本号重复处理.txt";

            try
            {
                string       msg            = "";
                StreamReader sr             = new StreamReader(@".\DIRUI.CST300.txt", Encoding.Default);
                string       correspondence = sr.ReadLine();
                string       ipPath         = sr.ReadLine();
                sr.Close();
                sr.Dispose();
                string[] correspondenceArray = correspondence.Split('|');
                string   strConn             = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ipPath + ";Persist Security Info=False;Jet OLEDB:Database Password="******"yyyy-MM-dd");
                string sql      = @"select distinct(pat_testno) as itemNo from  dr_patient  where   format(pat_testing_date,'yyyy-MM-dd') ='in_pat_testing'";
                sql = sql.Replace("in_pat_testing", dateTime);

                DataTable dt = OleDBHelper.GetOledbDataTable(sql, strConn);

                foreach (DataRow item in dt.Rows)
                {
                    StringBuilder sBuilder = new StringBuilder("");
                    strSampleNo_temp = item["itemNo"].ToString();
                    sql = @"select  testname as itemName ,testresult as  itemvalue   from  dr_test_app  where  format(testdate,'yyyy-MM-dd')='in_testdate' and  testno=in_testno";
                    sql = sql.Replace("in_testdate", dateTime);
                    sql = sql.Replace("in_testno", strSampleNo_temp);
                    DataTable     dt2        = OleDBHelper.GetOledbDataTable(sql, strConn);
                    List <string> TestValues = new List <string>();
                    foreach (DataRow item1 in dt2.Rows)
                    {
                        strTestTime = DateTime.Now.ToString("yyyy-MM-dd");
                        string itemName = item1["itemName"].ToString();
                        string itemVaue = item1["itemValue"].ToString();
                        if (string.IsNullOrEmpty(itemVaue))
                        {
                            itemVaue = "*";
                        }

                        TestValues.Add(item1["itemName"].ToString() + ":" + itemVaue);
                        sBuilder.Append(itemName + ',' + itemVaue + '|');
                    }
                    /////
                    if (Helper.CompareSampleNoAndTime(file, strSampleNo_temp, strTestTime, TestValues))
                    {
                        continue;
                    }
                    string   str  = sBuilder.ToString().Remove(sBuilder.Length - 1, 1);
                    string[] strs = str.Split('|');

                    string ChannelType     = ""; //0-普通结果;1-直方图;2-散点图;3-直方图界标;4-散点图界标;5-BASE64
                    string testItemID      = "";
                    string TestResultValue = "";
                    for (int i = 0; i < strs.Length; i++)
                    {
                        FindRow = tItemChannel.Select("通道编码='" + strs[i].Split(',')[0] + "'");
                        if (FindRow.Length == 0) //无普通结果则查找图像能道,无图像通道则更新通道类型为空
                        {
                            ChannelType = null;
                            writelog.Write(strDevice, "未设置通道:" + strs[i].Split(',')[0], "log");
                        }
                        else
                        {
                            testItemID      = FindRow[0]["项目id"].ToString();
                            ChannelType     = "0"; //普通结果
                            TestResultValue = TestResultValue + testItemID + "^" + strs[i].Split(',')[1] + "|";
                        }
                    }

                    TestResultValue = strTestTime + "|" + strSampleNo_temp + "^" + strSampleType + "^" + strBarCode + "|" + strOperator + "|" + StrSpecimen + "|" + "|" + TestResultValue;
                    saveResult      = new SaveResult();
                    if (!string.IsNullOrEmpty(strSampleNo_temp) || !string.IsNullOrEmpty(strBarCode))
                    {
                        saveResult.SaveTextResult(strInstrument_id, TestResultValue, TestGraph, DrSampleNoField);
                        if (ImmediatelyUpdate)
                        {
                            saveResult.UpdateData();
                        }
                    }

                    if (!ImmediatelyUpdate)
                    {
                        saveResult.UpdateData();
                    }


                    /////
                }
                System.Threading.Thread.Sleep(10000);
            }
            catch (Exception e)
            {
                writelog.Write(strDevice, "处理失败: " + e.ToString(), "log");
            }
        }