Beispiel #1
0
        public void IncrementalAppend()
        {
            IDataFile file = Transaction.GetFile(new Key(0, 0, 1), FileAccess.ReadWrite);
            Assert.IsNotNull(file);

            StringData data = new StringData(file);

            for (int i = 0; i < 500; i++) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < i; j++) {
                    sb.Append(" ");
                }

                data.Append(sb.ToString());
            }

            file.Position = 0;

            int offset = 0;
            for (int i = 0; i < 500; i++) {
                StringBuilder sb = new StringBuilder();
                for (int j = 0; j < i; j++) {
                    sb.Append(" ");
                }

                string s = data.Substring(offset, i);
                Assert.AreEqual(sb.ToString(), s);

                offset += i;
            }
        }
        internal void End(int count, WebSocketMessageType messageType)
        {
            _bs.AddRange(ReceiveData.Take(count));
            ByteData   = _bs.ToArray();
            StringData = Encoding.UTF8.GetString(ByteData);
            var index = StringData.IndexOf(",");

            if (index >= 0 && index < StringData.Length)
            {
                Tag  = StringData.Substring(0, index);
                Body = StringData.Substring(index + 1);
            }
            MessageType = messageType;
        }
Beispiel #3
0
        public void SimpleAppend()
        {
            IDataFile file = Transaction.GetFile(new Key(0, 0, 1), FileAccess.ReadWrite);
            Assert.IsNotNull(file);

            StringData data = new StringData(file);
            data.Append("test");
            Assert.AreNotEqual(0, file.Position);

            file.Position = 0;
            string s = data.Substring(0, 4);
            Assert.AreEqual("test", s);

            Commit();
        }
Beispiel #4
0
        public override void ProcessRawData()
        {
            try
            {
                var myArr = new ArrayList
                {
                    "WBC",
                    "RBC",
                    "HGB",
                    "HCT",
                    "MCV",
                    "MCH",
                    "MCHC",
                    "PLT",
                    "LYM%",
                    "MXD%",
                    "NEUT%",
                    "LYM#",
                    "MXD#",
                    "NEUT#",
                    "RDW",
                    "UNUSE",
                    "PDW",
                    "MPV",
                    "P-LCR"
                };

                Log.Trace("Begin Process Data");
                //Lưu lại Data
                Log.Trace(StringData);
                int idStx = StringData.IndexOf(DeviceHelper.STX);

                if ((StringData.Length < 457) || (idStx < 0))
                {
                    return;
                }

                string[] allPatients = SeparatorData(StringData.Substring(idStx));
                Log.Debug("Result has {0} patient(s)", allPatients.Length);

                foreach (string patient in allPatients)
                {
                    string[] tempdate = patient.Substring(1, 8).Split('/');
                    TestResult.TestDate = string.Format("{0}/{1}/{2}{3}", tempdate[2].Trim().PadLeft(2, '0'),
                                                        tempdate[1].Trim().PadLeft(2, '0'),
                                                        DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2),
                                                        tempdate[0].Trim().PadLeft(2, '0'));
                    TestResult.Barcode = patient.Substring(14, 13).Trim();

                    string tempResult = patient.Substring(82, 120);
                    foreach (string testName in myArr)
                    {
                        string testValue = tempResult.Substring(0, 5);
                        tempResult = tempResult.Substring(5);
                        if (testName != "UNUSE")
                        {
                            AddResult(new ResultItem(testName, testValue));
                        }
                    }

                    Log.Debug("Begin Import Result");
                    ImportResults();
                    Log.Debug("Import Result Success");
                }
                Log.Trace("Finish Process Data");
                ClearData();
            }
            catch (Exception ex)
            {
                Log.Error("Error while process data Error:" + ex);
            }
            finally
            {
                //ClearData();
            }
        }
Beispiel #5
0
        public override void ProcessRawData()
        {
            try
            {
                Log.Trace(DeviceHelper.CRLF + StringData);
                string rawResult = StringData.Substring(StringData.IndexOf("SAMPLE RESULTS", StringComparison.Ordinal));
                if ((rawResult.IndexOf("Na") < 0) || (rawResult.IndexOf("K") < 0) || (rawResult.IndexOf("Cl") < 0))
                {
                    Log.Trace("Data is not valided");
                    return;
                }
                string[] strResutl = DeviceHelper.DeleteAllBlankLine(rawResult, DeviceHelper.CRLF.ToCharArray());
                Log.Trace("Begin Process Data");
                //Lưu lại Data
                //Lưu lại Data

                TestResult.TestDate = strResutl[strResutl.Length - 1].Substring(0, 9).Trim();
                string pTestDate = strResutl[strResutl.Length - 1].Substring(0, 3);
                pTestDate           = DeviceHelper.GetMonth(pTestDate);
                TestResult.TestDate = string.Format("{0}/{1}/{3}{2}", TestResult.TestDate.Substring(4, 2), pTestDate,
                                                    TestResult.TestDate.Substring(7, 2),
                                                    DateTime.Now.Year.ToString(CultureInfo.InvariantCulture).Substring(0, 2));

                //Lấy về dòng chứa ID
                int tempRowIndex = GetRowIndex(strResutl, "ID");
                if (tempRowIndex == -1)
                {
                    TestResult.Barcode = "0000";
                }
                else
                {
                    string[] tempId = strResutl[tempRowIndex].Split();
                    TestResult.Barcode = tempId.Length >= 2 ? Convert.ToInt32(tempId[1]).ToString() : "0000";
                }
                //Tìm đến phần tử đầu tien chứa kết quả.
                tempRowIndex = GetRowIndex(strResutl, "Na");
                if (tempRowIndex != -1)
                {
                    string[] tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 1].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                    tempResult = DeviceHelper.DeleteAllBlankLine(strResutl[tempRowIndex + 2].Split());
                    AddResult(new ResultItem(tempResult[0].Replace("\"", "").Replace("^", "").Trim(),
                                             tempResult[1].Trim(), tempResult[2].Trim()));
                }

                Log.Debug("Begin Importdata");
                Log.Debug(ImportResults() ? "Finish Imported result" : "Error While Import Result to DB");
                ClearData();

                //  }
            }
            catch (Exception ex)
            {
                //throw ex;
                Log.Error("Error while processing data Error: {0}", ex);
                ClearData();
            }
        }