コード例 #1
0
        public VersaCell()
        {
            try
            {
                _clsHRecord     = new VersaCellHeaderRecord();
                _clsPRecord     = new VersaCellPatientRecord();
                _clsORecord     = new VersaCellOrderRecord();
                _clsQRecord     = new VersaCellQueryRecord();
                _clsRRecord     = new VersaCellResultRecord();
                _clsTRecord     = new VersaCellTerminationRecord();
                PrvRequestArray = new Queue <List <string> >();
                objService      = new ExternalDataExchangeService();

                InstanceId = Guid.NewGuid();
                objWorkFlowRuntime.AddService(objService);
                objASTM = new clsASTM();
                objService.AddService(objASTM);
                objASTM.SendACKEvent += objASTM_SendACKEvent;
                objASTM.SendNAKEvent += objASTM_SendNAKEvent;
                objASTM.SendENQEvent += objASTM_SendENQEvent;
                objASTM.SendEOTEvent += objASTM_SendEOTEvent;
                objWorkFlowInstance   = objWorkFlowRuntime.CreateWorkflow(typeof(ASTMWorkflow), null, InstanceId);
                objWorkFlowInstance.Start();
                Console.WriteLine(@"Work flow started");

                objDataEventArgs             = new ExternalDataEventArgs(InstanceId);
                objDataEventArgs.WaitForIdle = true;
                DumpStateMachine(objWorkFlowRuntime, InstanceId);
            }
            catch (Exception ex)
            {
                Log.FatalException("Fatal Error: ", ex);
            }
        }
コード例 #2
0
        private List <string> CreateOrderFrame(List <string> orderList)
        {
            var    retList  = new List <string>();
            string sTemp    = String.Concat(DeviceHelper.STX, "1", _clsHRecord.sHeaderRecord, DeviceHelper.ETX);
            string checksum = DeviceHelper.GetCheckSumValue(sTemp);

            retList.Add(String.Concat(sTemp, checksum, DeviceHelper.CRLF));

            if ((orderList != null) && (orderList.Count != 0))
            {
                _clsPRecord = new VersaCellPatientRecord();
                sTemp       = String.Concat(DeviceHelper.STX, "2", _clsPRecord.CreateData(), DeviceHelper.ETX);
                checksum    = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(String.Concat(sTemp, checksum, DeviceHelper.CRLF));

                _clsORecord = new VersaCellOrderRecord();
                sTemp       = String.Concat(DeviceHelper.STX, "3", _clsORecord.CreateData(_sQBarcode, orderList),
                                            DeviceHelper.ETX);
                checksum = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(String.Concat(sTemp, checksum, DeviceHelper.CRLF));

                _clsTRecord = new VersaCellTerminationRecord(1, @"F");
                sTemp       = String.Concat(DeviceHelper.STX, "4", _clsTRecord.TerminationRecord);
                checksum    = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(String.Concat(sTemp, checksum, DeviceHelper.CRLF));
            }
            else
            {
                _clsTRecord = new VersaCellTerminationRecord(1, @"I");
                sTemp       = String.Concat(DeviceHelper.STX, "2", _clsTRecord.TerminationRecord);
                checksum    = DeviceHelper.GetCheckSumValue(sTemp);
                retList.Add(String.Concat(sTemp, checksum, DeviceHelper.CRLF));
            }

            return(retList);
        }
コード例 #3
0
        /// <summary>
        /// Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        public override void ProcessRawData()
        {
            try
            {
                var arrRecords  = new string[] {};
                var listRecords = new ArrayList();
                var listFields  = new ArrayList();

                if (BufferData != string.Empty)
                {
                    arrRecords = BufferData.Split(new[] { _clsRRecord.RecordDelimiter },
                                                  StringSplitOptions.RemoveEmptyEntries);
                }

                int i = 0;
                while (i < arrRecords.Length)
                {
                    string[] arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);

                    if (arrFields[0].Equals(_clsPRecord.RecordType))
                    {
                        listFields.Clear();
                        listFields.Add(arrFields);
                        listRecords.Add(listFields);

                        do
                        {
                            if (++i > arrRecords.Length - 1)
                            {
                                break;
                            }
                            arrFields = arrRecords[i].Split(_clsPRecord.FieldDelimiter);
                            if (arrFields[0].Equals(_clsORecord.RecordType) ||
                                arrFields[0].Equals(_clsRRecord.RecordType))
                            {
                                listFields.Add(arrFields);
                            }
                        } while (!arrFields[0].Equals(_clsPRecord.RecordType));

                        foreach (ArrayList l in listRecords)
                        {
                            foreach (string[] fields in l)
                            {
                                if (fields[0].StartsWith(_clsPRecord.RecordType))
                                {
                                    _clsPRecord = new VersaCellPatientRecord(fields);
                                }
                                else if (fields[0].StartsWith(_clsORecord.RecordType))
                                {
                                    _clsORecord        = new VersaCellOrderRecord(fields);
                                    TestResult.Barcode = _clsORecord.Barcode;
                                }
                                else if (fields[0].StartsWith(_clsRRecord.RecordType))
                                {
                                    _clsRRecord = new VersaCellResultRecord(fields);

                                    AddResult(new ResultItem(_clsRRecord.TestId,
                                                             _clsRRecord.DataValue.PubFieldData));
                                    TestResult.TestDate = _clsRRecord.TestDate;
                                    _newResult          = true;
                                }
                            }
                        }
                        if (_newResult)
                        {
                            ImportResults();
                            _newResult = false;
                        }
                    }
                    else if (arrFields[0].Equals(_clsQRecord.RecordType))
                    {
                        _clsQRecord = new VersaCellQueryRecord(arrFields);
                        _sQBarcode  = _clsQRecord.QueryBarcode;
                        _newQuery   = true;
                        List <string> regList = GetRegList(_clsQRecord.QueryBarcode);
                        PrvRequestArray.Enqueue(CreateOrderFrame(regList));
                        ++i;
                    }
                    else
                    {
                        ++i;
                    }
                }

                if (_newQuery)
                {
                    //Send((int)EventID.OpenNewOutputSession, _sQBarcode);
                    objASTM.CallGetQuery(objDataEventArgs);
                    if ((PrvRequestArray != null) && (PrvRequestArray.Count != 0))
                    {
                        currentOrder.Clear();
                        currentOrder    = PrvRequestArray.Dequeue();
                        currentOrderIdx = 0;
                    }
                    //SendByte((byte)DeviceHelper.ENQ);
                    _newQuery = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error("Fatal Error:{0}", ex.ToString());
            }
        }