예제 #1
0
        private void SetFieldData(DataItem data, Dictionary <string, DataItem> included)
        {
            if (data.Relationships == null || data.Relationships.FieldData == null)
            {
                return;
            }

            foreach (var relationship in data.Relationships.FieldData.Data)
            {
                var item = included.LocateItem(relationship);

                if (item == null)
                {
                    continue;
                }

                FieldData.Add(new FieldDataDTO(item));
            }
        }
예제 #2
0
 private void TBFieldData_TextChanged(object sender, EventArgs e)
 {
     FieldData.Clear();
     if (TBFieldData.Text == "")
     {
         LFieldWarning.Text = "";
     }
     else
     {
         try
         {
             var splittedDatas = TBFieldData.Text.Replace(" ", "").Split(',').ToList();
             foreach (var si in splittedDatas)
             {
                 FieldData.Add(Convert.ChangeType(si, FieldType.FieldType));
             }
             LFieldWarning.Text = "";
         }
         catch (Exception ex)
         {
             LFieldWarning.Text = ex.Message;
         }
     }
 }
        public override void ProcessResponse(Session session, Message message, bool isPartialResponse, Action <Session, Message, Exception> onFailure)
        {
            IObserver <ReferenceDataResponse> observer;

            if (!TryGet(message.CorrelationID, out observer))
            {
                onFailure(session, message, new Exception("Unable to find handler for correlation id: " + message.CorrelationID));
                return;
            }

            if (message.HasElement(ElementNames.ResponseError))
            {
                var responseErrorElement = message.GetElement(ElementNames.ResponseError);
                var responseError        = new ResponseError(
                    responseErrorElement.GetElementAsString(ElementNames.Source),
                    responseErrorElement.GetElementAsString(ElementNames.Category),
                    responseErrorElement.GetElementAsString(ElementNames.SubCategory),
                    responseErrorElement.GetElementAsInt32(ElementNames.Code),
                    responseErrorElement.GetElementAsString(ElementNames.Message));
                observer.OnError(new ContentException <ResponseError>(responseError));

                // We assume no more messages will be delivered for this correlation id.
                Remove(message.CorrelationID);

                return;
            }

            var referenceDataResponse = new ReferenceDataResponse();

            var securities = message.GetElement(ElementNames.SecurityData);

            for (var i = 0; i < securities.NumValues; ++i)
            {
                var security = securities.GetValueAsElement(i);
                var ticker   = security.GetElementAsString(ElementNames.Security);

                if (security.HasElement(ElementNames.SecurityError))
                {
                    var securityErrorElement = security.GetElement(ElementNames.SecurityError);
                    var responseError        = new ResponseError(
                        securityErrorElement.GetElementAsString(ElementNames.Source),
                        securityErrorElement.GetElementAsString(ElementNames.Category),
                        securityErrorElement.GetElementAsString(ElementNames.SubCategory),
                        securityErrorElement.GetElementAsInt32(ElementNames.Code),
                        securityErrorElement.GetElementAsString(ElementNames.Message));

                    referenceDataResponse.Add(ticker, Either.Left <ResponseError, FieldData>(responseError));
                    continue;
                }

                var fieldData = new FieldData();

                var fields = security.GetElement(ElementNames.FieldData);
                for (var j = 0; j < fields.NumElements; ++j)
                {
                    var field = fields.GetElement(j);
                    var name  = field.Name.ToString();
                    var value = field.GetFieldValue();
                    if (fieldData.ContainsKey(name))
                    {
                        fieldData[name] = value;
                    }
                    else
                    {
                        fieldData.Add(name, value);
                    }
                }

                referenceDataResponse.Add(ticker, Either.Right <ResponseError, FieldData>(fieldData));
            }

            observer.OnNext(referenceDataResponse);

            if (!isPartialResponse)
            {
                observer.OnCompleted();
                Remove(message.CorrelationID);
            }
        }