Beispiel #1
0
        //private Dictionary<string, List<RmdsFid>> mapList = new Dictionary<string, List<RmdsFid>>();


        public JobStatus Run(StringBuilder log)
        {
            // ==========================================================================
            _fids = DataTableSerializer.ToList <RmdsFid>(OracleHelper.Query("SELECT  RICTYPE, FIDNAME,  TABNAME,  COLNAME,COLTYPE FROM FIDLIST").Tables[0]);
            _rics = new List <RmdsRic>();
            NewListBond.GetNewBondRics(_rics);
            CtrlBreakHandler.Init();
            _queueMessageFromRfas = new List <QueueMessageFromRFA>();
            // Initialize Context, Config, and Dictionary
            Context.Initialize();
            _configDb    = ConfigDatabase.Acquire(new RFA_String("RFA"));
            _stgConfigDb = StagingConfigDatabase.Create();
            string rootPath       = AppDomain.CurrentDomain.BaseDirectory;
            string configFilePath = "ExampleRFA.cfg";

            configFilePath = rootPath + configFilePath;
            _stgConfigDb.Load(ConfigRepositoryTypeEnum.flatFile, new RFA_String(configFilePath));
            _configDb.Merge(_stgConfigDb);
            _rdmFieldDictionary = RDMFieldDictionary.Create();

            string fieldDictPath = "RDMFieldDictionary";

            fieldDictPath = Path.Combine(rootPath, fieldDictPath);
            string enumTypeDefPath = "enumtype.def";

            enumTypeDefPath = Path.Combine(rootPath, enumTypeDefPath);

            _rdmFieldDictionary.ReadRDMFieldDictionary(new RFA_String(fieldDictPath));
            _rdmFieldDictionary.ReadRDMEnumTypeDef(new RFA_String(enumTypeDefPath));
            _rdmFieldDictionary.Version = new RFA_String("1.1");
            _rdmFieldDictionary.DictId  = 1;

            // ==========================================================================
            // Initialize EventQueue, Session, and OMMConsumer
            _eventQueue  = EventQueue.Create(new RFA_String("NewListBondEventQueue"));
            _session     = Session.Acquire(new RFA_String("Session1"));
            _ommConsumer = _session.CreateOMMConsumer(new RFA_String("NewListBond"));

            // ==========================================================================
            // Send Login request
            ReqMsg reqMsg = new ReqMsg
            {
                MsgModelType    = RDM.MESSAGE_MODEL_TYPES.MMT_LOGIN,
                InteractionType =
                    ReqMsg.InteractionTypeFlag.InitialImage | ReqMsg.InteractionTypeFlag.InterestAfterRefresh
            };
            AttribInfo attribInfo = new AttribInfo
            {
                NameType = Login.USER_ID_TYPES.USER_NAME,
                Name     = new RFA_String("trep")
            };

            reqMsg.AttribInfo = attribInfo;
            OMMItemIntSpec ommItemIntSpec = new OMMItemIntSpec {
                Msg = reqMsg
            };

            if (_ommConsumer != null)
            {
                _ommConsumer.RegisterClient(_eventQueue, ommItemIntSpec, this);
                //string[] ricTypes = { "CFXS/NEWISSUE", "CNREPO/PBOC", "SLO/PBOC", "SLF/PBOC", "MLF/PBOC" };

                // ==========================================================================
                // Send Market Price item request
                _rfaLog.Append("<ol>");
                foreach (var ric in _rics)
                {
                    _requestRic  = ric.Ric;
                    _responseRic = null;
                    _currentFids =
                        _fids.Where(re => re.Rictype == ric.Rictype && re.FidName != null)
                        .Select(re => re.FidName)
                        .ToList();

                    reqMsg.Clear();
                    attribInfo.Clear();
                    _eventQueue            = EventQueue.Create(new RFA_String("StartConsumerEventQueue"));
                    reqMsg.MsgModelType    = RDM.MESSAGE_MODEL_TYPES.MMT_MARKET_PRICE;
                    reqMsg.InteractionType = ReqMsg.InteractionTypeFlag.InitialImage | ReqMsg.InteractionTypeFlag.InterestAfterRefresh;
                    attribInfo.NameType    = RDM.INSTRUMENT_NAME_TYPES.INSTRUMENT_NAME_RIC;
                    attribInfo.Name        = new RFA_String(ric.Ric);
                    attribInfo.ServiceName = new RFA_String("ELEKTRON_DD");
                    reqMsg.AttribInfo      = attribInfo;
                    ommItemIntSpec.Msg     = reqMsg;
                    _ommConsumer.RegisterClient(_eventQueue, ommItemIntSpec, this);
                    _rfaLog.Append("<li>Request Ric <b>" + _requestRic + "</b>");
                    Console.WriteLine("Dispatching events for 60 seconds.");
                    System.DateTime currentTime = System.DateTime.Now;
                    System.DateTime startTime   = currentTime;
                    System.DateTime endTime     = currentTime.AddSeconds(60);
                    while ((!CtrlBreakHandler.IsTerminated()) && (currentTime < endTime || endTime == startTime))
                    {
                        if (_eventQueue != null)
                        {
                            int dispatchReturn = _eventQueue.Dispatch(10);
                            if ((dispatchReturn == Dispatchable.DispatchReturnEnum.NothingDispatchedInActive) ||
                                (dispatchReturn == Dispatchable.DispatchReturnEnum.NothingDispatchedNoActiveEventStreams))
                            {
                                break;
                            }
                        }
                        currentTime = System.DateTime.Now;
                    }
                    CtrlBreakHandler.SetTerminated(false);
                    if (_responseRic == null)
                    {
                        _rfaLog.Append(" ,<span style=\"color:red;\">No response data</span>");
                    }
                    _rfaLog.Append("</li>");
                }
            }
            log.Append(_rfaLog + "</ol>");

            foreach (var ricType in _queueMessageFromRfas.Select(re => re.RicType).Distinct())
            {
                log.Append("Table:<b>" + _fids.Where(re => re.Rictype == ricType).Select(re => re.TabName).First() + "</b> RicType:<b>" + ricType + "</b> update:" + _queueMessageFromRfas.Count(re => re.RicType == ricType && re.OperationType == "Update") + " insert:" + _queueMessageFromRfas.Count(re => re.RicType == ricType && re.OperationType == "Insert") + " ignore:" + _queueMessageFromRfas.Count(re => re.RicType == ricType && re.OperationType == "Ignore") + "\n");
            }
            if (_queueMessageFromRfas.Count == _rics.Count)
            {
                return(JobStatus.Success);
            }
            log.Append("<b><span style=\"color:red;\">Some rics no response data!</span></b>");
            return(JobStatus.Fail);
        }