示例#1
0
        public ADVIA1650()
        {
            try
            {
                _clsORecord     = new ADVIA1650OrderRecord();
                _clsQRecord     = new ADVIA1650QueryRecord();
                _clsRRecord     = new ADVIA1650ResultRecord();
                PrvRequestArray = new List <string>();
                var 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)
            {
                throw ex;
            }
        }
示例#2
0
        /// <summary>
        ///     Xử lý sau kkhi nhận được dữ liệu
        /// </summary>
        private void ProcessData()
        {
            try
            {
                var arrRecords = new string[] {};

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

                int i = 0;
                while (i < arrRecords.Length)
                {
                    if (arrRecords[i].StartsWith("R"))
                    {
                        Log.Trace(arrRecords[i]);
                        _clsRRecord         = new ADVIA1650ResultRecord(arrRecords[i]);
                        TestResult.TestDate = string.Concat(_clsRRecord.DateTestCompleted.Substring(6, 2), "/",
                                                            _clsRRecord.DateTestCompleted.Substring(4, 2), "/",
                                                            _clsRRecord.DateTestCompleted.Substring(0, 4));
                        TestResult.Barcode = _clsRRecord.Barcode;
                        foreach (DictionaryEntry entry in _clsRRecord.htResult)
                        {
                            AddResult(new ResultItem(entry.Key.ToString(), entry.Value.ToString()));
                        }
                        Log.Debug(ImportResults() ? "Import Result Success" : "Import Result Error");
                    }
                    if (arrRecords[i].StartsWith("q") || arrRecords[i].StartsWith("Q"))
                    {
                        Log.Trace(arrRecords[i]);
                        _clsQRecord = new ADVIA1650QueryRecord(arrRecords[i]);
                        _clsORecord = new ADVIA1650OrderRecord();
                        Log.Debug("Request for barcode: {0}", _clsQRecord.QueryBarcode);

                        for (int index = 0; index < _clsQRecord.QueryBarcode.Count; index++)
                        {
                            string        barcode = _clsQRecord.QueryBarcode[index];
                            List <string> reglist = GetRegList(barcode);
                            Log.Debug("Reglist for barcode: {0}", string.Join(",", reglist.ToArray()));
                            _newQuery = true;
                            if ((reglist == null) || (reglist.Count == 0))
                            {
                                continue;
                            }
                            string data = _clsORecord.CreateData(index, barcode, reglist);
                            PrvRequestArray.Add(data);
                            Log.Trace(data);
                        }
                    }
                    ++i;
                }

                if (_newQuery)
                {
                    objASTM.CallGetQuery(objDataEventArgs);

                    _newQuery = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error While Process Data: {0}", ex));
            }
        }