Exemple #1
0
        public void TestTestResult()
        {
            TestResult x = new TestResult();

            Assert.Equal(0, x.NumberOfPassedAsserts);
            Assert.Equal(0, x.NumberOfFailedAsserts);

            x.Add(true, "Something went right");
            Assert.Equal(1, x.NumberOfPassedAsserts);
            Assert.Equal(0, x.NumberOfFailedAsserts);
            Assert.True(x.AllTestsSucceeded);

            x.IsTrue("Something else went right");
            Assert.Equal(2, x.NumberOfPassedAsserts);
            Assert.Equal(0, x.NumberOfFailedAsserts);
            Assert.True(x.AllTestsSucceeded);

            x.Add(false, "Something went wrong");
            Assert.Equal(2, x.NumberOfPassedAsserts);
            Assert.Equal(1, x.NumberOfFailedAsserts);
            Assert.False(x.AllTestsSucceeded);

            x.IsFalse("Something else went wrong");
            Assert.Equal(2, x.NumberOfPassedAsserts);
            Assert.Equal(2, x.NumberOfFailedAsserts);
            Assert.False(x.AllTestsSucceeded);
        }
Exemple #2
0
        public void TestTestResultSerialization()
        {
            TestResult before = new TestResult();

            before.Add(true, "Something went right");
            before.Add(true, "Something else went right");
            before.Add(false, "Something went wrong");

            TestResult after = TestResult.FromJson(before.ToJson());

            Assert.NotNull(after);
            Assert.Equal(1, after.NumberOfFailedAsserts);
            Assert.Equal(2, after.NumberOfPassedAsserts);

            Assert.Equal(before.ToJson(), after.ToJson());
        }
Exemple #3
0
        public override void ProcessRawData()
        {
            try
            {
                _timer.Elapsed -= TimerOnElapsed;
            }
            catch (Exception)
            {
            }
            finally
            {
                _timer.Elapsed += TimerOnElapsed;
            }
            try
            {
                //Kiểm tra nếu chưa kết thúc nhận dữ liệu
                if (!StringData.Contains(DeviceHelper.EOT.ToString(CultureInfo.InvariantCulture)))
                {
                    _timer.Enabled = true;
                    _timer.Start();
                    return;
                }
                _timer.Stop();
                string[] allResult = StringData.Split(DeviceHelper.CR);

                foreach (string record in allResult)
                {
                    TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                    bool startsWithD   = record.StartsWith(string.Format("{0}D", DeviceHelper.STX));
                    bool startsWithRcs = record.StartsWith(string.Format("{0}RCS", DeviceHelper.STX));
                    if (startsWithD || startsWithRcs)
                    {
                        string[] strResult = DeviceHelper.DeleteAllBlankLine(record, " ");
                        try
                        {
                            TestResult.Barcode = strResult[0].Substring(startsWithD ? 2 : 7);
                        }
                        catch (Exception)
                        {
                            TestResult.Barcode = "";
                        }
                        try
                        {
                            TestResult.Add(new ResultItem(strResult[1], strResult[2], strResult[3]));
                        }
                        catch (Exception)
                        {
                        }
                        ImportResults();
                    }
                }
                ClearData();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public TestResult Predict(DetectedPoints pts)
        {
            TestResult result = new TestResult();
            Dictionary <Label, double> results = new Dictionary <Label, double>();

            foreach (var a in library)
            {
                double comparison = a.Value.Compare(pts);
                results[a.Key] = comparison;
            }
            result.Add(results);
            return(result);
        }
Exemple #5
0
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessRawData()
        {
            try
            {
                // Kiểm tra dữ liệu xem có đủ không ?
                if (!StringData.EndsWith(DeviceHelper.ETX.ToString()))
                {
                    return;
                }


                Log.Trace("Begin Process Data");
                Log.Trace(DeviceHelper.CRLF + StringData);

                //Lấy về dữ liệu của các bệnh nhân
                string[] arrPatients = DeviceHelper.SeperatorRawData(StringData, DeviceHelper.STX, DeviceHelper.ETX);

                Log.Trace("Result has {0} Patients", arrPatients.Length);
                //Duyệt qua mảng xử lý dữ liệu của từng bệnh nhân
                foreach (string patient in arrPatients)
                {
                    var rawdata  = patient.Split(',');
                    var tempDate = rawdata[4].Substring(1).Split('-');
                    TestResult.TestDate = string.Format("{0}/{1}/{2}", tempDate[2], tempDate[1], tempDate[0]);
                    string barcode = rawdata[10].Substring(1).Trim();
                    TestResult.Barcode = barcode;
                    string testValue = rawdata[11].Trim();
                    try
                    {
                        testValue = Convert.ToDouble(testValue).ToString();
                    }
                    catch (Exception)
                    {
                    }

                    TestResult.Add(new ResultItem("HbA1C", testValue));
                    Log.Debug(string.Format("Import Result For barocde:{0}", barcode));
                    Log.Debug(ImportResults()
                        ? string.Format("Import Result Success")
                        : string.Format("Error while import result"));
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error while processing data {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
            }
            finally
            {
                ClearData();
            }
        }
Exemple #6
0
        public virtual void Test()
        {
            TestResult.Clear();
            TestExpected.Clear();

            int testlength = _TestInput.Length;

            for (int i = 0; i < testlength; i += 10)
            {
                TestResult.Add(Compute(_TestInput[i]));
                TestExpected.Add(_TestOutput[i]);
            }

            CalculateMSE();
        }
Exemple #7
0
        public override void Test()
        {
            TestResult.Clear();
            TestExpected.Clear();

            int testlength = _TestInput.Length;

            for (int i = 0; i < testlength; i++)
            {
                double[] computed = Compute(_TestInput[i]);
                //double[] result = new double[] { computed[0], computed[1], _TestInput[i][4] };
                double[] result = new double[] { computed[0], _TestInput[i][1] };
                TestResult.Add(result);
                TestExpected.Add(_TestOutput[i]);
            }
        }
Exemple #8
0
        internal bool OneTest(string nameTest, TestRequestDataDrv request, TestResult res, Func <MsgTest> func, bool error = false)
        {
            bool            result          = true;
            TestDriverError testDriverError = null;
            MsgTest         readResult      = null;

            try
            {
                readResult = func();
                if ((!readResult.OperationResult.IsGood) && (!error))
                {
                    testDriverError = new TestDriverError(false, "{0}, {1}", nameTest, readResult.OperationResult.ErrorMsg);
                    result          = false;
                }
            }
            catch (Exception e)
            {
                testDriverError = new TestDriverError(false, "{0}, {1}", nameTest, e.GetFullMessageDisplay());
                result          = false;
            }
            if (testDriverError != null)
            {
                res.Add(testDriverError);
            }

            if (Log.Trace.IsOn(1))
            {
                var mgg = String.Format("{0}: {1}", nameTest, (result) ? readResult.Message : testDriverError.Message);
                if ((readResult.OperationResult.IsGood) || (error))
                {
                    Log.Trace.Info(1, mgg);
                }
                else
                {
                    Log.Trace.Error(1, mgg);
                }
            }
            return(result);
        }
        public override void ProcessRawData()
        {
            try
            {
                //Nếu ký tự kết thúc khác EOT thi gửi ACK để confirm dữ liệu đã được nhận
                if (
                    !(StringData.EndsWith(DeviceHelper.ETX.ToString(CultureInfo.InvariantCulture)) ||
                      StringData.EndsWith(DeviceHelper.EOT.ToString(CultureInfo.InvariantCulture))))
                {
                    return;
                }

                Log.Trace("Begin Process Data");

                //Lưu lại Data
                Log.Trace(DeviceHelper.CRLF + StringData);

                //Kết thúc khi nhận được EOT và tiến hành xử lý DL
                SendStringData(DeviceHelper.ACK.ToString(CultureInfo.InvariantCulture));
                string[] allPatients = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.STX);
                Log.Trace("Result has {0} Patients", allPatients.Length);
                //Duyệt theo từng dòng
                foreach (string patient in allPatients)
                {
                    string tempPatient = patient;
                    //Nếu đúng với các ký tự bắt đầu thì xử lý:
                    if (Validdata(patient))
                    {
                        TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                        TestResult.Barcode  = tempPatient.Substring(12, 11).Trim();
                        tempPatient         = tempPatient.Substring(24);
                        while (tempPatient.Length > 9)
                        {
                            string result    = tempPatient.Substring(0, 9);
                            string testName  = result.Substring(0, 2).Trim();
                            string testValue = result.Substring(2, 7).Trim();

                            //Xử lý các ký tự thừa trong kết quả

                            //Loại bỏ dấu "$"
                            testValue = testValue.Replace("$", "");

                            //Loại bỏ các chữ cái in hoa và in thường trong chuỗi kết quả
                            for (byte i = 65; i <= 90; i++)
                            {
                                testValue = testValue.Replace(Convert.ToChar(i).ToString(CultureInfo.InvariantCulture),
                                                              "")
                                            .Replace(Convert.ToChar(i + 32).ToString(CultureInfo.InvariantCulture), "");
                            }

                            //Thêm kết quả mới
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add new Result: TestName = {0}, TestValue = {1}", testName, testValue);

                            //Cắt bỏ các dữ liệu vừa được xử lý
                            tempPatient = tempPatient.Substring(9);

                            //Xử lý các thông số tính toán
                            double iHdlc = -1,
                                   iTrig = -1,
                                   iChol = -1,
                                   iAlb  = -1,
                                   iProT = -1,
                                   iBilt = -1,
                                   iBild = -1,
                                   iCa   = -1;

                            foreach (ResultItem item in TestResult.Items)
                            {
                                //BIL-Toàn phần
                                if (item.TestName.Equals("10"))
                                {
                                    iBilt = TryToConvertToDouble(item.TestValue);
                                    if (iBilt > 50)
                                    {
                                        iBilt          = Math.Round(iBilt, 0);
                                        item.TestValue = iBilt.ToString(CultureInfo.InvariantCulture);
                                    }
                                }

                                //BIL-Trực tiếp
                                if (item.TestName.Equals("11"))
                                {
                                    iBild = TryToConvertToDouble(item.TestValue);
                                    if (iBild > 50)
                                    {
                                        iBild          = Math.Round(iBild, 0);
                                        item.TestValue = iBild.ToString(CultureInfo.InvariantCulture);
                                    }
                                }

                                //Protein-T
                                if (item.TestName.Equals("4"))
                                {
                                    iProT = TryToConvertToDouble(item.TestValue);
                                }

                                //ALB
                                if (item.TestName.Equals("5"))
                                {
                                    iAlb = TryToConvertToDouble(item.TestValue);
                                }

                                //CHOL
                                if (item.TestName.Equals("2"))
                                {
                                    iChol = TryToConvertToDouble(item.TestValue);
                                }

                                //Trig
                                if (item.TestName.Equals("3"))
                                {
                                    iTrig = TryToConvertToDouble(item.TestValue);
                                }

                                //HDLC
                                if (item.TestName.Equals("16"))
                                {
                                    iHdlc = TryToConvertToDouble(item.TestValue);
                                }

                                //Ca
                                if (item.TestName.Equals("15"))
                                {
                                    iCa = TryToConvertToDouble(item.TestValue);
                                }
                            }

                            //Tính toán

                            //Bil-Gián tiếp:
                            if ((iBild > 0) && (iBilt > 0))
                            {
                                testName  = "47";
                                testValue = (iBilt - iBild).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add new Calculated Result: TestName = {0}, TestValue = {1}", testName,
                                          testValue);
                            }

                            //Globumin,Tỷ số A/G
                            if ((iProT > 0) && (iAlb > 0))
                            {
                                //Globumin
                                testName  = "51";
                                testValue = (iProT - iAlb).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add new Calculated Result: TestName = {0}, TestValue = {1}", testName,
                                          testValue);

                                //Tỷ số A/G
                                testName  = "49";
                                testValue = (iAlb / (iProT - iAlb)).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add new Calculated Result: TestName = {0}, TestValue = {1}", testName,
                                          testValue);
                            }

                            //LDLC:
                            if ((iChol > 0) && (iHdlc > 0) && (iTrig > 0))
                            {
                                testName  = "50";
                                testValue = iTrig <= 4.5
                                    ? (iChol - (iTrig / 2.2 + iHdlc)).ToString(CultureInfo.InvariantCulture)
                                    : "HTĐ";
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add new Calculated Result: TestName = {0}, TestValue = {1}", testName,
                                          testValue);
                            }

                            //CA-Ion
                            if (iCa > 0)
                            {
                                testName  = "caion";
                                testValue = (iCa * 0.53).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add new Calculated Result: TestName = {0}, TestValue = {1}", testName,
                                          testValue);
                            }
                        }
                    }
                    Log.Debug("Begin Importdata");
                    ImportResults();
                    Log.Debug("Finish Imported result");
                    ClearData();
                }

                //System.IO.File.WriteAllText(@"C:\Hitachi717_Input.txt",StringData);
            }
            catch (Exception ex)
            {
                ClearData();
                throw ex;
            }
        }
Exemple #10
0
        public override void ProcessRawData()
        {
            try
            {
                //Kiểm tra dữ liệu
                if (!ValidData())
                {
                    return;
                }
                Log.Debug("Begin Process Data");
                Log.Debug("Raw Data \n: {0}", StringData);
                IEnumerable <string> arrPatients = SeparatorData(StringData);
                foreach (string patient in arrPatients)
                {
                    if (!patient.StartsWith("D "))
                    {
                        continue;
                    }
                    if (patient.Length < 44)
                    {
                        continue;
                    }
                    // Lấy ngày tháng năm hiện tại
                    TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                    string barcode = patient.Substring(15, 22).Trim();

                    //lấy barcode bệnh nhân
                    TestResult.Barcode = barcode.Length < 1 ? "0" : barcode;

                    string tempPatient = patient;

                    string temp = tempPatient.Substring(44);
                    while (temp.Length >= 9)
                    {
                        //lấy tên loại XN
                        string testName = temp.Substring(0, 2).Trim();
                        //Lấy kq
                        string testValue = temp.Substring(2, 8).Trim();

                        //Xử lý các ký tự thừa trong kết quả

                        //Loại bỏ dấu "$,"r"
                        testValue = testValue.Replace("r", "").Replace("$", "");

                        //Loại bỏ các chữ cái in hoa và in thường trong chuỗi kết quả
                        for (byte i = 65; i <= 90; i++)
                        {
                            testValue =
                                testValue.Replace(Convert.ToChar(i).ToString(CultureInfo.InvariantCulture), "").Replace(
                                    Convert.ToChar(i + 32).ToString(CultureInfo.InvariantCulture), "");
                        }
                        //add kết quả
                        TestResult.Add(new ResultItem(testName, testValue));
                        temp = temp.Substring(10);
                    }
                    //Lưu vào db
                    Log.Debug("Begin Import Result");
                    Log.Debug(ImportResults() ? "Import Success" : "Import false");
                }
                ClearData();
            }
            catch (Exception ex)
            {
                ClearData();
                Log.Error("Error while process Data - Error:{0}", ex.ToString());
            }
        }
Exemple #11
0
        public override void ProcessRawData()
        {
            try
            {
                string mystringData = StringData.Trim();
                if (!mystringData.EndsWith("-->"))
                {
                    return;
                }

                mystringData = string.Format(@"<VBIT>{0}</VBIT>", mystringData);

                XElement xElement = XElement.Parse(mystringData);

                // Get Id List
                List <string> barcodeList = (from p in xElement.Descendants("p")
                                             let element = p.Element("n")
                                                           where element != null && element.Value.Equals("ID")
                                                           let element1 = p.Element("v")
                                                                          select element1 != null ? element1.Value :"").ToList();

                List <string> testDateList = (from p in xElement.Descendants("p")
                                              let element = p.Element("n")
                                                            where element != null && element.Value.Equals("DATE")
                                                            let element1 = p.Element("v")
                                                                           where element1 != null
                                                                           select element1.Value.Substring(0, 10)).ToList();

                var allResult = xElement.Descendants("smpresults");

                // Duyệt từng bệnh nhân để import dữ liệu
                var xElements = allResult as IList <XElement> ?? allResult.ToList();
                for (int i = 0; i < xElements.Count(); i++)
                {
                    TestResult.Barcode = barcodeList[i];
                    var tempTestDate = testDateList[i].Split('-');
                    TestResult.TestDate = string.Format("{0}/{1}/{2}", tempTestDate[2],
                                                        tempTestDate[1], tempTestDate[0]);
                    foreach (XElement element in xElements[i].Descendants("p"))
                    {
                        string testName = "";
                        try
                        {
                            testName = element.Element("n").Value;
                        }
                        catch (Exception)
                        {
                        }
                        string testValue = "";
                        try
                        {
                            testValue = element.Element("v").Value;
                        }
                        catch (Exception)
                        {
                        }
                        TestResult.Add(new ResultItem(testName, testValue));
                    }
                    Log.Debug("Begin import result: Barrcode {0}", TestResult.Barcode);
                    Log.Debug(ImportResults()?"Import Result success":"Error while import result");
                }
                ClearData();
            }
            catch (Exception ex)
            {
                Log.Debug("Error while process data:\r\n{0}", ex);
                ClearData();
            }
        }
Exemple #12
0
        public override void ProcessRawData()
        {
            try
            {
                //Nếu ký tự kết thúc bằng CR thì tiến hành xử lý
                if (!StringData.EndsWith(DeviceHelper.ETX.ToString(CultureInfo.InvariantCulture)))
                {
                    return;
                }

                Log.Trace("Begin Process Data");

                Log.Trace(DeviceHelper.CRLF + StringData);
                SendStringData(DeviceHelper.ACK.ToString(CultureInfo.InvariantCulture));
                //string[] allPatients = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CRLF);
                string[] allPatients = DeviceHelper.SeperatorRawData(StringData, DeviceHelper.STX, DeviceHelper.ETX);

                Log.Trace("Result has {0} Patients", allPatients.Length);

                //Duyệt theo từng dòng
                foreach (string patient in allPatients)
                {
                    string tempPatient = patient;
                    //Nếu đúng với các ký tự bắt đầu thì xử lý:
                    if (!Validdata(patient))
                    {
                        continue;
                    }

                    TestResult.Barcode  = patient.Substring(13, 15).Trim();
                    TestResult.TestDate = patient.Substring(31, 6).Trim();
                    TestResult.TestDate = string.Format("{0}/{1}/{2}{3}", TestResult.TestDate.Substring(2, 2),
                                                        TestResult.TestDate.Substring(0, 2),
                                                        DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2),
                                                        TestResult.TestDate.Substring(4, 2));
                    //Nếu số lượng kết quả =0 chuyển xử lý kết quả sau
                    int totalTest = Convert.ToInt32(tempPatient.Substring(42, 2).Trim());
                    if (totalTest == 0)
                    {
                        continue;
                    }
                    tempPatient = tempPatient.Substring(44);
                    int testCount = 1;
                    while ((tempPatient.Length > 9) && (testCount <= totalTest))
                    {
                        testCount++;
                        string result    = tempPatient.Substring(0, 10);
                        string testName  = result.Substring(0, 3).Trim();
                        string testValue = result.Substring(3, 7).Trim();

                        //Xử lý các ký tự thừa trong kết quả

                        //Loại bỏ dấu "$"
                        testValue = testValue.Replace("$", "");
                        testValue = testValue.Replace("!", "");
                        testValue = testValue.Replace("%", "");

                        //Loại bỏ các chữ cái in hoa và in thường trong chuỗi kết quả
                        for (byte i = 65; i <= 90; i++)
                        {
                            testValue =
                                testValue.Replace(Convert.ToChar(i).ToString(CultureInfo.InvariantCulture), "")
                                .Replace(Convert.ToChar(i + 32).ToString(CultureInfo.InvariantCulture), "");
                        }

                        //Thêm kết quả mới
                        //Nếu tên xét nghiệm khác rỗng thì insert

                        if (!string.IsNullOrEmpty(testName.Trim()))
                        {
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add new Result: TestName = {0}, TestValue = {1}", testName, testValue);
                        }

                        //Cắt bỏ các dữ liệu vừa được xử lý
                        tempPatient = tempPatient.Substring(10);
                    }

                    Log.Debug("Begin Import Result For barocde:{0}", TestResult.Barcode);
                    ImportResults();
                    Log.Debug("Import Result Success");
                }
                ClearData();
            }
            catch (Exception ex)
            {
                ClearData();
                Log.Error("Error while processing data, Error:{0}", ex.ToString());
            }
        }
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                Log.Trace(DeviceHelper.CRLF + StringData);
                string[] allPatients = SeparatorData(StringData);

                foreach (string patient in allPatients)
                {
                    try
                    {
                        string[] tempResult = patient.Split(DeviceHelper.CR);
                        string[] tempDate = tempResult[1].Split()[0].Split('/');
                        TestResult.TestDate = string.Format("{0}/{1}/{2}", tempDate[2], tempDate[1], tempDate[0]);

                        try
                        {
                            //string tempbarcode = tempResult[3].Split(':')[1].Trim();
                            string tempbarcode = tempResult[3].Split(':')[1].Trim().Replace(".", "");
                            TestResult.Barcode = tempbarcode == "" ? "0000" : tempbarcode;
                        }
                        catch (Exception)
                        {
                            TestResult.Barcode = "0000";
                        }
                        Log.Debug(string.Format("Testdate:{0}, Barcode:{1}", TestResult.TestDate, TestResult.Barcode));

                        for (int i = 4; i < 15; i++)
                        {
                            try
                            {
                                string[] tempresultarr = DeviceHelper.DeleteAllBlankLine(tempResult[i], "");
                                if (tempresultarr.Length > 1)
                                {
                                    string testName = tempresultarr[0];
                                    string testValue = tempresultarr[1];
                                    TestResult.Add(new ResultItem(testName, testValue));
                                    Log.Debug("Add new Result: TestName = {0}, TestValue = {1}", testName, testValue);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }


                        Log.Debug("Begin Import Result");
                        ImportResults();
                        Log.Debug("Import Result Success");
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
                ClearData();
                throw;
            }
            finally
            {
                ClearData();
            }
        }
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                Log.Trace(DeviceHelper.CRLF + StringData);

                //Lấy về dữ liệu của các bệnh nhân
                string[] arrPatients = SeparatorData(StringData);

                Log.Trace("Result has {0} Patients", arrPatients.Length);
                //Duyệt qua mảng xử lý dữ liệu của từng bệnh nhân
                foreach (string patient in arrPatients)
                {
                    foreach (string record in patient.Split(DeviceHelper.CR))
                    {
                        string[] temp;
                        if (record.StartsWith("O"))
                        {
                            try
                            {
                                temp = record.Split('|');
                                TestResult.Barcode  = temp[2].Split('^')[0].Trim();
                                TestResult.TestDate = string.Format("{0}/{1}/{2}", temp[6].Substring(6, 2),
                                                                    temp[6].Substring(4, 2),
                                                                    temp[6].Substring(0, 4));
                                Log.Debug("Barcode:{0}, TestDate:{1}", TestResult.Barcode, TestResult.TestDate);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while parse data: {0}{1}Eror String:{2}", record, DeviceHelper.CRLF,
                                          ex.ToString());
                            }
                        }
                        else if (record.StartsWith("R"))
                        {
                            try
                            {
                                temp = record.Split('|');
                                string testName  = temp[2].Replace("^", "").Trim();
                                string testValue = temp[3].Trim();
                                string testUnit  = temp[4].Trim();
                                AddResult(new ResultItem(testName, testValue, testUnit));
                                Log.Debug("Add Result Item success: TestName={0}, TestValue={1}, TestUnit={2}", testName,
                                          testValue, testUnit);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while parse data: {0}{1}Eror String:{2}", record, DeviceHelper.CRLF,
                                          ex.ToString());
                            }
                        }
                    }

                    //Xử lý các thông số tính toán
                    double iHdlc = -1, iTrig = -1, iChol = -1, iAlb = -1, iProT = -1, iBilt = -1, iBild = -1, iCa = -1;
                    foreach (ResultItem item in TestResult.Items)
                    {
                        //BIL-Toàn phần
                        if (item.TestName.ToUpper().Equals("BIL-T"))
                        {
                            iBilt = TryToConvertToDouble(item.TestValue);
                        }

                        //BIL-Trực tiếp
                        if (item.TestName.ToUpper().Equals("BIL-D"))
                        {
                            iBild = TryToConvertToDouble(item.TestValue);
                        }

                        //Protein-T
                        if (item.TestName.ToUpper().Equals("PROTEIN T.P"))
                        {
                            iProT = TryToConvertToDouble(item.TestValue);
                        }

                        //ALB
                        if (item.TestName.ToUpper().Equals("ALB"))
                        {
                            iAlb = TryToConvertToDouble(item.TestValue);
                        }

                        //CHOL
                        if (item.TestName.ToUpper().Equals("CHOLESTEROL"))
                        {
                            iChol = TryToConvertToDouble(item.TestValue);
                        }

                        //Trig
                        if (item.TestName.ToUpper().Equals("TRIGLYCERID"))
                        {
                            iTrig = TryToConvertToDouble(item.TestValue);
                        }

                        //HDLC
                        if (item.TestName.ToUpper().Equals("HDL-C"))
                        {
                            iHdlc = TryToConvertToDouble(item.TestValue);
                        }

                        //Ca
                        if (item.TestName.ToUpper().Equals("CA"))
                        {
                            iCa = TryToConvertToDouble(item.TestValue);
                        }
                    }

                    //Tính toán

                    //Bil-Gián tiếp:
                    if ((iBild > 0) && (iBilt > 0))
                    {
                        try
                        {
                            string testName  = "BIL-GT";
                            string testValue = Math.Round((iBilt - iBild), 2).ToString(CultureInfo.InvariantCulture);
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                      testValue);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error while calculate BIL - GT {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                        }
                    }

                    //Globumin,Tỷ số A/G
                    if ((iProT > 0) && (iAlb > 0))
                    {
                        //Globumin
                        try
                        {
                            string testName  = "GLOB";
                            string testValue = Math.Round((iProT - iAlb), 2).ToString(CultureInfo.InvariantCulture);
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                      testValue);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error while calculate GLOB {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                        }

                        //Tỷ số A/G
                        try
                        {
                            string testName  = "A/G";
                            string testValue =
                                Math.Round((iAlb / (iProT - iAlb)), 2).ToString(CultureInfo.InvariantCulture);
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                      testValue);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error while calculate A/G {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                        }
                    }

                    //LDLC:
                    if ((iChol > 0) && (iHdlc > 0) && (iTrig > 0))
                    {
                        try
                        {
                            string testName  = "LDL-CHOL";
                            string testValue =
                                Math.Round((iChol - (iTrig / 2.2 + iHdlc)), 2).ToString(CultureInfo.InvariantCulture);
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName, testValue);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error while calculate LDL_C {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                        }
                    }

                    //Ca-ion:
                    if ((iCa > 0) && (iProT > 0))
                    {
                        try
                        {
                            string testName  = "Ca-ion";
                            string testValue =
                                Math.Round((((65 * iCa + 11.4) / (iProT + 66)) - 0.16), 2)
                                .ToString(CultureInfo.InvariantCulture);
                            TestResult.Add(new ResultItem(testName, testValue));
                            Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                      testValue);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error while calculate Ca-ion {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                        }
                    }

                    Log.Debug(string.Format("Import Result For barocde:{0}", TestResult.Barcode));
                    ImportResults();
                    Log.Debug(string.Format("Import Result Success"));
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error while processing data {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                throw;
            }
            finally
            {
                ClearData();
            }
        }
Exemple #15
0
        public override void ProcessRawData()
        {
            try
            {
                //Nếu ký tự kết thúc bằng CR thì tiến hành xử lý
                if ((StringData.EndsWith(DeviceHelper.CR.ToString(CultureInfo.InvariantCulture))) ||
                    (StringData.EndsWith(DeviceHelper.CRLF)))
                {
                    Log.Trace("Begin Process Data");
                    Log.Trace(DeviceHelper.CRLF + StringData);
                    SendStringData(DeviceHelper.ACK.ToString(CultureInfo.InvariantCulture));
                    string[] allPatients = DeviceHelper.DeleteAllBlankLine(StringData, DeviceHelper.CR);
                    Log.Trace("Result has {0} Patients", allPatients.Length);

                    //Duyệt theo từng dòng
                    foreach (string patient in allPatients)
                    {
                        string tempPatient = patient;
                        //Nếu đúng với các ký tự bắt đầu thì xử lý:
                        if (Validdata(patient))
                        {
                            TestResult.TestDate = DateTime.Now.ToString("dd/MM/yyyy");
                            TestResult.Barcode  = tempPatient.Substring(10, 16).Trim();
                            tempPatient         = tempPatient.Substring(40);
                            while (tempPatient.Length > 9)
                            {
                                string result    = tempPatient.Substring(0, 9);
                                string testName  = result.Substring(0, 2).Trim();
                                string testValue = result.Substring(2, 7).Trim();

                                //Xử lý các ký tự thừa trong kết quả

                                //Loại bỏ dấu "$"
                                testValue = testValue.Replace("$", "").Replace("!", "");

                                //Loại bỏ các chữ cái in hoa và in thường trong chuỗi kết quả
                                for (byte i = 65; i <= 90; i++)
                                {
                                    testValue =
                                        testValue.Replace(Convert.ToChar(i).ToString(CultureInfo.InvariantCulture), "").
                                        Replace(Convert.ToChar(i + 32).ToString(CultureInfo.InvariantCulture), "");
                                }

                                //Thêm kết quả mới
                                TestResult.Add(new ResultItem(testName, testValue));

                                //Cắt bỏ các dữ liệu vừa được xử lý
                                tempPatient = tempPatient.Substring(9);

                                //////////////Xử lý các thông số tính toán
                                ////////////double iHdlc = -1, iTrig = -1, iChol = -1, iAlb = -1, iProT = -1, iBilt = -1, iBild = -1;

                                ////////////foreach (ResultItem item in TestResult.Items)
                                ////////////{
                                ////////////    //BIL-Toàn phần
                                ////////////    if (item.TestName.Equals("10")) iBilt = TryToConvertToDouble(item.TestValue);

                                ////////////    //BIL-Trực tiếp
                                ////////////    if (item.TestName.Equals("11")) iBild = TryToConvertToDouble(item.TestValue);

                                ////////////    //Protein-T
                                ////////////    if (item.TestName.Equals("12")) iProT = TryToConvertToDouble(item.TestValue);

                                ////////////    //ALB
                                ////////////    if (item.TestName.Equals("15")) iAlb = TryToConvertToDouble(item.TestValue);

                                ////////////    //CHOL
                                ////////////    if (item.TestName.Equals("17")) iChol = TryToConvertToDouble(item.TestValue);

                                ////////////    //Trig
                                ////////////    if (item.TestName.Equals("16")) iTrig = TryToConvertToDouble(item.TestValue);

                                ////////////    //HDLC
                                ////////////    if (item.TestName.Equals("18")) iHdlc = TryToConvertToDouble(item.TestValue);
                                ////////////}

                                //////////////Tính toán

                                //////////////Bil-Gián tiếp:
                                ////////////if ((iBild > 0) && (iBilt > 0))
                                ////////////{
                                ////////////    testName = "47";
                                ////////////    testValue = (iBilt - iBild).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}

                                //////////////Globumin,Tỷ số A/G
                                ////////////if ((iProT > 0) && (iAlb > 0))
                                ////////////{
                                ////////////    //Globumin
                                ////////////    testName = "51";
                                ////////////    testValue = (iProT - iAlb).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));

                                ////////////    //Tỷ số A/G
                                ////////////    testName = "49";
                                ////////////    testValue = (iAlb/(iProT - iAlb)).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}

                                //////////////LDLC:
                                ////////////if ((iChol > 0) && (iHdlc > 0) && (iTrig > 0))
                                ////////////{
                                ////////////    testName = "50";
                                ////////////    testValue = (iChol - (iTrig/2.2 + iHdlc)).ToString();
                                ////////////    TestResult.Add(new ResultItem(testName, testValue));
                                ////////////}
                            }
                            ImportResults();
                            Log.Debug("Import Result Success For barocde:{0}", TestResult.Barcode);
                        }
                    }
                    ClearData();
                }
            }
            catch (Exception ex)
            {
                ClearData();
                throw ex;
            }
        }
Exemple #16
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace("Begin Process Data");
                Log.Trace(DeviceHelper.CRLF + StringData);
                string[] allPatients = DeviceHelper.SeperatorRawData(StringData, DeviceHelper.STX, DeviceHelper.ETX);

                foreach (string patient in allPatients)
                {
                    try
                    {
                        string[] tempResult   = DeviceHelper.DeleteAllBlankLine(patient, DeviceHelper.CRLF, false);
                        string[] tempTestDate = tempResult[4].Split()[0].Split('.');
                        TestResult.TestDate = string.Format("{0}/{1}/{2}", tempTestDate[2], tempTestDate[1],
                                                            tempTestDate[0]);
                        try
                        {
                            string tempbarcode = tempResult[3].Split(':')[1].Trim();
                            //if(string.IsNullOrEmpty(tempbarcode))
                            //    tempbarcode = tempResult[2].Split(':')[1].Trim().Replace(".","");
                            TestResult.Barcode = tempbarcode == "" ? "0000" : tempbarcode;
                        }
                        catch (Exception)
                        {
                            TestResult.Barcode = "0000";
                        }

                        for (int i = 6; i < 16; i++)
                        {
                            try
                            {
                                string[] tempresultarr = DeviceHelper.DeleteAllBlankLine(tempResult[i].Substring(2), "");
                                if (tempresultarr.Length > 1)
                                {
                                    string testName  = tempresultarr[0].Replace("*", "");
                                    string testValue = tempresultarr[1];
                                    TestResult.Add(new ResultItem(testName, testValue));
                                    Log.Debug("Add new Result: TestName = {0}, TestValue = {1}", testName, testValue);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }
                        Log.Debug("Begin Import Result");
                        Log.Debug(ImportResults() ? "Import Result Success" : "Error while import result");
                    }
                    catch (Exception)
                    {
                    }
                }
            }
            catch (Exception)
            {
                ClearData();
                throw;
            }
            finally
            {
                ClearData();
            }
        }
Exemple #17
0
        public override TestResult Test(TestRequestDataDrv request)
        {
            TestResult result = new TestResult();

            var          drvSetting = request.GetDriverSetting(() => new DriverSetting());
            var          cs         = request.GetContentSetting <EmeraContentSetting>(() => new EmeraContentSetting());
            EmeraRequest emera      = new EmeraRequest(this, drvSetting, ReadTimeOutRequestMSec());

            //var sr = new Def.ShortRequest(cs.Address);

            if ((request.TestLevel == TestLevel.Ping) || (request.TestLevel == TestLevel.Search))
            {
                DateTimeUtc dateTimeUtc;
                int         timeTwoSidePathMsec;
                if (!DataBusSetting.StubData)
                {
                    var readRes = emera.TryReadDateTime(this.Channel, cs.Address, cs.Psw, TimeZoneMap.Local, out dateTimeUtc, out timeTwoSidePathMsec);
                    if (!readRes.IsGood)
                    {
                        result.Add(new TestDriverError(false, "Error Connect. {0}", readRes.ErrorMsg));
                    }
                }
            }
            else if (request.TestLevel == TestLevel.Full)
            {
                DateTimeUtc dateTimeUtcPrb = DateTimeUtc.MinValue;
                int         timeTwoSidePathMsec;
                if (!OneTest(SR.Test_DT, request, result, () =>
                {
                    var res = emera.TryReadDateTime(this.Channel, cs.Address, cs.Psw, TimeZoneMap.Local, out dateTimeUtcPrb, out timeTwoSidePathMsec);
                    return(new MsgTest(res, res.IsGood ? dateTimeUtcPrb.ToLocal().ToString() : string.Empty));
                }))
                {
                    return(result);
                }
                TimeSpan diffTime = DateTimeUtc.Now - dateTimeUtcPrb;

                string sn = string.Empty;
                if (!OneTest(SR.Test_SN, request, result, () =>
                {
                    var res = emera.TryReadSerialNumber(this.Channel, cs.Address, cs.Psw, out sn);
                    return(new MsgTest(res, res.IsGood ? sn : string.Empty));
                }))
                {
                    return(result);
                }

                string deviceConfiguration = string.Empty;
                if (!OneTest(SR.Test_SV, request, result, () =>
                {
                    var res = emera.TryReadDeviceConfiguration(this.Channel, cs.Address, cs.Psw, out deviceConfiguration, true);
                    return(new MsgTest(res, res.IsGood ? deviceConfiguration.ToString() : string.Empty));
                }))
                {
                    return(result);
                }

                /*if (!OneTest(SR.Test_Error_Req, request, result, () =>
                 * {
                 * Energy eRead;
                 * var res = emera.TryReadSlicesEnergy(this.Channel, DeviceCompOn.Default, SlicesQuery.GetEmulError(sr.Address), TypeInfo.Imp, out eRead);
                 * return new MsgTest(res, res.IsGood ? "" : "Ok");
                 * }, true)) return result;*/

                result.Message = String.Format("Сер.Номер: {0}, Временной разрыв: {1} sec, Конфигурация: {2}", sn, (int)diffTime.TotalSeconds, deviceConfiguration);
            }
            return(result);
        }
Exemple #18
0
        /// <summary>
        /// Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessData()
        {
            try
            {
                DateTime Statdate = DateTime.Now;
                DateTime Enddate  = new DateTime(2016, 01, 20);
                if (Statdate >= Enddate)
                {
                    Log.Trace("XXXX - Contact technical Support");
                    return;
                }

                Log.Trace("Begin Process Data");
                //Lưu lại Data
                Log.Trace(StringData);

                //Lấy về dữ liệu của các bệnh nhân
                IEnumerable <string> arrPatients = SeparatorData(StringData);

                //Duyệt qua mảng xử lý dữ liệu của từng bệnh nhân
                foreach (string patient in arrPatients)
                {
                    foreach (string record in patient.Split(DeviceHelper.CR))
                    {
                        string[] temp;
                        if (record.StartsWith("O"))
                        {
                            temp = record.Split('|');
                            //Lấy barcode xét nghiệm
                            try
                            {
                                string strTempbarcode = temp[2].Split('^')[0].Trim();
                                TestResult.Barcode = strTempbarcode == "" ? "0000" : strTempbarcode;
                            }
                            catch (Exception)
                            {
                                TestResult.Barcode = "0000";
                            }
                        }
                        else if (record.StartsWith("R"))
                        {
                            try
                            {
                                temp = record.Split('|');
                                //Lấy về ngày tháng làm xét nghiệm
                                if (string.IsNullOrEmpty(TestResult.TestDate))
                                {
                                    string datetime = record.Split('|')[12];
                                    TestResult.TestDate = string.Format("{0}/{1}/{2}", datetime.Substring(6, 2),
                                                                        datetime.Substring(4, 2),
                                                                        datetime.Substring(0, 4));
                                }

                                string strTestName  = temp[2].Split('^')[3].Trim();
                                string strTestValue = temp[3].Trim().Replace(',', '.');
                                string strTestUnit  = temp[4].Trim();
                                AddResult(new ResultItem(strTestName, strTestValue, strTestUnit));
                                Log.Debug("Add Result Item success: TestName={0}, TestValue={1}, TestUnit={2}", strTestName,
                                          strTestValue, strTestUnit);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while processing data Error: {0}", ex);
                                continue;
                            }
                        }

                        //Xử lý các thông số tính toán
                        double iHdlc = -1, iTrig = -1, iChol = -1, iAlb = -1, iProT = -1, iBilt = -1, iBild = -1, iCa = -1;
                        foreach (ResultItem item in TestResult.Items)
                        {
                            //BIL-Toàn phần
                            if (item.TestName.ToUpper().Equals("12"))
                            {
                                iBilt = TryToConvertToDouble(item.TestValue);
                            }

                            //BIL-Trực tiếp
                            if (item.TestName.ToUpper().Equals("11"))
                            {
                                iBild = TryToConvertToDouble(item.TestValue);
                            }

                            //Protein-T
                            if (item.TestName.ToUpper().Equals("09"))
                            {
                                iProT = TryToConvertToDouble(item.TestValue);
                            }

                            //ALB
                            if (item.TestName.ToUpper().Equals("10"))
                            {
                                iAlb = TryToConvertToDouble(item.TestValue);
                            }

                            //CHOL
                            if (item.TestName.ToUpper().Equals("05"))
                            {
                                iChol = TryToConvertToDouble(item.TestValue);
                            }

                            //Trig
                            if (item.TestName.ToUpper().Equals("04"))
                            {
                                iTrig = TryToConvertToDouble(item.TestValue);
                            }

                            //HDLC
                            if (item.TestName.ToUpper().Equals("17"))
                            {
                                iHdlc = TryToConvertToDouble(item.TestValue);
                            }

                            //Ca
                            if (item.TestName.ToUpper().Equals("13"))
                            {
                                iCa = TryToConvertToDouble(item.TestValue);
                            }
                        }

                        //Tính toán

                        //Bil-Gián tiếp:
                        if ((iBild > 0) && (iBilt > 0))
                        {
                            try
                            {
                                string testName  = "BIL-GT";
                                string testValue = Math.Round((iBilt - iBild), 2).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                          testValue);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while calculate BIL - GT {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                            }
                        }

                        //Globumin,Tỷ số A/G
                        if ((iProT > 0) && (iAlb > 0))
                        {
                            //Globumin
                            try
                            {
                                string testName  = "GLOB";
                                string testValue = Math.Round((iProT - iAlb), 2).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                          testValue);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while calculate GLOB {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                            }

                            //Tỷ số A/G
                            try
                            {
                                string testName  = "A/G";
                                string testValue =
                                    Math.Round((iAlb / (iProT - iAlb)), 2).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                          testValue);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while calculate A/G {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                            }
                        }

                        //LDLC:
                        if ((iChol > 0) && (iHdlc > 0) && (iTrig > 0))
                        {
                            try
                            {
                                string testName  = "LDL-CHOL";
                                string testValue =
                                    Math.Round((iChol - (iTrig / 2.2 + iHdlc)), 2).ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName, testValue);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while calculate LDL_C {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                            }
                        }

                        //Ca-ion:
                        if ((iCa > 0) && (iProT > 0))
                        {
                            try
                            {
                                string testName  = "Ca-ion";
                                string testValue =
                                    Math.Round((((65 * iCa + 11.4) / (iProT + 66)) - 0.16), 2)
                                    .ToString(CultureInfo.InvariantCulture);
                                TestResult.Add(new ResultItem(testName, testValue));
                                Log.Debug("Add Calculated Result Item success: TestName={0}, TestValue={1}", testName,
                                          testValue);
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while calculate Ca-ion {0}Error:{1}", DeviceHelper.CRLF, ex.ToString());
                            }
                        }
                    }
                    Log.Trace("Begin Import Result");
                    Log.Trace(ImportResults() ? "Import Result Success" : "Error While Import result");
                }
            }
            catch (Exception ex)
            {
                Log.Error("Error while processing data Error: {0}", ex);
            }
            finally
            {
                ClearData();
            }
        }
Exemple #19
0
        public override void ProcessRawData()
        {
            try
            {
                if (!StringData.Contains("URINALYSIS"))
                {
                    return;
                }
                Log.Trace("Begin Process Data");
                Log.Trace(DeviceHelper.CRLF + StringData);
                string[] allPatients = SeparatorData(StringData);

                foreach (string patient in allPatients)
                {
                    try
                    {
                        string[] tempResult = patient.Split(DeviceHelper.CR);
                        TestResult.TestDate = tempResult[1].Split()[0];
                        try
                        {
                            string tempbarcode = tempResult[3].Split(':')[1].Trim();
                            //if(string.IsNullOrEmpty(tempbarcode))
                            //    tempbarcode = tempResult[2].Split(':')[1].Trim().Replace(".","");
                            TestResult.Barcode = tempbarcode == "" ? "0000" : tempbarcode;
                        }
                        catch (Exception)
                        {
                            TestResult.Barcode = "0000";
                        }

                        for (int i = 4; i < 15; i++)
                        {
                            try
                            {
                                string[] tempresultarr = DeviceHelper.DeleteAllBlankLine(tempResult[i], "");
                                if (tempresultarr.Length > 1)
                                {
                                    string testName  = tempresultarr[0];
                                    string testValue = tempresultarr[1];
                                    TestResult.Add(new ResultItem(testName, testValue));
                                    Log.Debug("Add new Result: TestName = {0}, TestValue = {1}", testName, testValue);
                                }
                            }
                            catch (Exception)
                            {
                            }
                        }


                        Log.Debug("Begin Import Result");
                        ImportResults();
                        Log.Debug("Import Result Success");
                    }
                    catch (Exception)
                    {
                    }
                }
                ClearData();
            }
            catch (Exception)
            {
                ClearData();
            }
        }