Example #1
0
        public void ProcessEvent(Event evnt)
        {
            if (evnt.Type == SessionLayerEventTypeEnum.OMMItemEvent)
            {
                OMMItemEvent ommItemEvent = evnt as OMMItemEvent;
                if (ommItemEvent != null)
                {
                    Msg msg = ommItemEvent.Msg;
                    if (msg.MsgType == MsgTypeEnum.RespMsg)
                    {
                        RespMsg respMsg = msg as RespMsg;
                        if (respMsg != null)
                        {
                            switch (respMsg.MsgModelType)
                            {
                            case RDM.MESSAGE_MODEL_TYPES.MMT_LOGIN:
                                Console.WriteLine("<- Received Login Response");
                                break;

                            case RDM.MESSAGE_MODEL_TYPES.MMT_MARKET_PRICE:
                                ProcessMarketPrice(respMsg);
                                break;
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public IActionResult  Check([FromBody] CheckPalindromeRequest item)
        {
            _logger.LogDebug(1, "Check");
            if (item == null || String.IsNullOrEmpty(item.inputStr))
            {
                return(BadRequest());
            }

            RespMsg response = new RespMsg();

            bool isPalindrome = _service.CheckPalindrome(item.inputStr);

            if (isPalindrome)
            {
                if (item.insert)
                {
                    _service.AddToDb(item.inputStr);
                    response.status = true;
                    response.data   = _service.Get(item.inputStr);
                }
            }
            else
            {
                response.status = false;
                response.data   = "Not a Palindrome";
            }

            return(new OkObjectResult(response));
        }
Example #3
0
        public IActionResult GetAll()
        {
            _logger.LogDebug(1, "GetAll");
            RespMsg response = new RespMsg();

            response.status = true;
            response.data   = _service.GetAll();
            return(new OkObjectResult(response));
        }
Example #4
0
        /// <summary>
        /// 返回json
        /// </summary>
        /// <param name="status"></param>
        /// <param name="data"></param>
        /// <param name="pager">分页配置</param>
        /// <param name="isLog">是否写入日志</param>
        /// <returns></returns>
        protected static ActionResult ResponseAjax(RespMsg msg, bool isLog = false)
        {
            var content = JsonConvert.SerializeObject(msg.ToObject());

            return(new ContentResult()
            {
                Content = content,
            });
        }
Example #5
0
        private void ProcessMarketPrice(RespMsg respMsg)
        {
            Console.WriteLine("<- Received Market Price " + respMsg.RespType.ToString());

            // ==========================================================================
            // Display AttribInfo
            if ((respMsg.HintMask & RespMsg.HintMaskFlag.AttribInfo) != 0)
            {
                if ((respMsg.AttribInfo.HintMask & AttribInfo.HintMaskFlag.ServiceName) != 0)
                {
                    Console.WriteLine("Service name: " + respMsg.AttribInfo.ServiceName.ToString());
                }
                if ((respMsg.AttribInfo.HintMask & AttribInfo.HintMaskFlag.Name) != 0)
                {
                    Console.WriteLine("Symbol name: " + respMsg.AttribInfo.Name.ToString());
                }
            }

            // ==========================================================================
            // Decode Payload
            if ((respMsg.HintMask & RespMsg.HintMaskFlag.Payload) != 0)
            {
                _responseRic = respMsg.AttribInfo.Name.ToString();
                Data payload = respMsg.Payload;
                if (payload.DataType == DataEnum.FieldList)
                {
                    FieldList fieldList = payload as FieldList;
                    //Console.WriteLine("FieldList's entry count: " + fieldList.StandardDataCount);
                    var currentRicType =
                        _rics.Where(re => re.Ric == respMsg.AttribInfo.Name.ToString()).Select(re => re.Rictype).First();
                    OpenMarketOperation bs = new OpenMarketOperation(_fids.Where(re => re.Rictype == currentRicType).Select(re => re.TabName).First());
                    bs.setRic(respMsg.AttribInfo.Name.ToString());

                    if (fieldList != null)
                    {
                        foreach (FieldEntry fieldEntry in fieldList)
                        {
                            var fieldId = fieldEntry.FieldID;
                            try
                            {
                                RDMFidDef fidDef    = _rdmFieldDictionary.GetFidDef(fieldId);
                                Data      dataEntry = fieldEntry.GetData(fidDef.OMMType);
                                if (dataEntry.DataType == DataEnum.DataBuffer)
                                {
                                    if (!_currentFids.Contains(fidDef.Name.ToString()))
                                    {
                                        continue;
                                    }

                                    DataBuffer dataBuffer = dataEntry as DataBuffer;
                                    //Console.Write("\tFieldEntry: {0,-10} {1,-8}\t", fidDef.Name, "(" + fieldId + ")");
                                    if (dataBuffer != null)
                                    {
                                        string fidValue = dataBuffer.GetAsString().ToString();
                                        //Console.WriteLine(fidValue);

                                        var fid =
                                            _fids.First(re => re.Rictype == currentRicType && re.FidName == fidDef.Name);
                                        string colName = fid.ColName;
                                        if (fid.ColName.ToUpper() == "BONDLOCALNAME")
                                        {
                                            RMTESConverter conv = new RMTESConverter();
                                            conv.SetBuffer(dataBuffer.GetBuffer());
                                            // For refresh msg display
                                            fidValue = ToSimplifiedChinese(conv.ToString());
                                        }
                                        if (colName != null)
                                        {
                                            bs.getColIdx(colName);
                                        }
                                        bs.appendColNames(fid.ColName, fid.ColType);
                                        if (fid.ColType == "DATE")
                                        {
                                            fidValue = string.IsNullOrEmpty(fidValue) ? "null" : fidValue.Replace(' ', '-');
                                        }
                                        else if (fid.ColType == "FLOAT")
                                        {
                                            fidValue = string.IsNullOrEmpty(fidValue) ? "0" : float.Parse(fidValue).ToString(CultureInfo.InvariantCulture);
                                        }
                                        else if (fid.ColType == "INT")
                                        {
                                            fidValue = string.IsNullOrEmpty(fidValue) ? "0" : Convert.ToInt32(fidValue).ToString();
                                        }

                                        bs.appendValues(fidValue);
                                    }
                                }
                                if (_responseRic == _requestRic)
                                {
                                    CtrlBreakHandler.SetTerminated(true);
                                }
                            }
                            catch (InvalidUsageException)
                            {
                            }
                        }
                    }
                    ExecuteSqlByRicType(currentRicType, bs);
                }
            }
        }