/// <summary> /// Update a single field to all the subscribers /// </summary> /// <param name="myID"></param> /// <param name="myValue"></param> protected void DoUpdate(string myID, string myValue) { try { // if we have some observers if (m_Subscribers.Count > 0) { // create a list of changed fields with their current values System.Collections.Generic.List<KaiTrade.Interfaces.IField> myFieldList = new List<KaiTrade.Interfaces.IField>(); K2DataObjects.Field myField = new K2DataObjects.Field(myID, myValue); // add the current time as the update time to the list K2DataObjects.Field myUpdTimeField; myUpdTimeField = new K2DataObjects.Field("UPDTIME", System.Environment.TickCount.ToString()); myFieldList.Add(myUpdTimeField); myFieldList.Add(myField); // send the update to all our observers foreach (KaiTrade.Interfaces.ISubscriber mySubscriber in m_Subscribers) { try { mySubscriber.OnUpdate(this, myFieldList); } catch (Exception myE) { m_Log.Error("doUpdate - invoke", myE); } } } } catch (Exception myE) { m_Log.Error("doUpdate", myE); } }
/// <summary> /// Update a field, this adds/updates the feilds awaiting an update /// and updates the corresponding image field /// </summary> /// <param name="myID"></param> /// <param name="myValue"></param> protected virtual void updateField(string myID, string myValue) { try { // first set the field in the iamge setImageField(myID, myValue); // Now add/update the set of updated fields KaiTrade.Interfaces.IField myField; if (m_UpdateFields.ContainsKey(myID)) { myField = m_UpdateFields[myID]; myField.Value = myValue; } else { myField = new K2DataObjects.Field(myID, myValue); m_UpdateFields.Add(myID, myField); } } catch (Exception myE) { m_Log.Error("updateField", myE); } }
void KaiTrade.Interfaces.IPublisher.Subscribe(KaiTrade.Interfaces.ISubscriber mySubscriber) { try { m_Subscribers.Add(mySubscriber); //myObserver.OnStatusChange(m_StatusInfo); //PTR // send an initial image System.Collections.Generic.List<KaiTrade.Interfaces.IField> myFieldList = new List<KaiTrade.Interfaces.IField>(); K2DataObjects.Field myField = new K2DataObjects.Field("IMAGE", "IMAGE"); myFieldList.Add(myField); mySubscriber.OnImage(this, myFieldList); } catch (Exception myE) { m_Log.Error("Publisher.Subscribe", myE); } }
/// <summary> /// Add a field into the image /// </summary> /// <param name="myID"></param> /// <param name="myValue"></param> protected void setImageField(string myID, string myValue) { try { KaiTrade.Interfaces.IField myField; if (m_Fields.ContainsKey(myID)) { myField = m_Fields[myID]; myField.Value = myValue; } else { myField = new K2DataObjects.Field(myID, myValue); m_Fields.Add(myID, myField); } } catch (Exception myE) { m_Log.Error("setImageField", myE); } }