internal void Update(Manager.Common.MetadataUpdateMessage message)
 {
     switch (message.MetadataType)
     {
         case MetadataType.QuotationSource:
             if (message.UpdateAction == UpdateAction.Modify)
             {
                 QuotationSource source = this._QuotationSources.SingleOrDefault(s => s.Id == message.ObjectId);
                 if (source != null)
                 {
                     foreach (string key in message.Fields.Keys)
                     {
                         if (key == FieldSR.Name)
                         {
                             source.Name = message.Fields[key];
                         }
                         else if (key == FieldSR.AuthName)
                         {
                             source.AuthName = message.Fields[key];
                         }
                         else if (key == FieldSR.Password)
                         {
                             source.Password = message.Fields[key];
                         }
                     }
                 }
             }
             else if (message.UpdateAction == UpdateAction.Add)
             {
                 QuotationSource source = new QuotationSource();
                 source.Id = message.ObjectId;
                 source.Name = message.Fields[FieldSR.Name];
                 source.AuthName = message.Fields[FieldSR.AuthName];
                 source.Password = message.Fields[FieldSR.Password];
                 this._QuotationSources.Add(source);
             }
             else if (message.UpdateAction == UpdateAction.Delete)
             {
                 QuotationSource source = this._QuotationSources.SingleOrDefault(s => s.Id == message.ObjectId);
                 if (source != null)
                 {
                     this._QuotationSources.Remove(source);
                 }
             }
             break;
         case MetadataType.Instrument:
             break;
         case MetadataType.InstrumentSourceRelation:
             break;
         case MetadataType.DerivativeRelation:
             break;
         case MetadataType.PriceRangeCheckRule:
             break;
         case MetadataType.WeightedPriceRule:
             break;
         default:
             break;
     }
 }
 public void Add(QuotationSource source)
 {
     this._QuotationSources.Add(new VmQuotationSource(source));
 }
 public VmQuotationSource Clone()
 {
     QuotationSource source = new QuotationSource() { Id = this._QuotationSource.Id, Name = this._QuotationSource.Name, AuthName = this._QuotationSource.AuthName, Password = this._QuotationSource.Password };
     return new VmQuotationSource(source);
 }
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if (this._EditingSource == null)
            {
                QuotationSource source = new QuotationSource();
                source.Name = this.NameTextBox.Text;
                source.AuthName = this.AuthNameTextBox.Text;
                source.Password = this.PasswordTextBox.Text;

                ConsoleClient.Instance.AddMetadataObject(source, delegate(int objectId)
                {
                    this.Dispatcher.BeginInvoke((Action)delegate()
                    {
                        if (objectId > 0)
                        {
                            source.Id = objectId;
                            this._QuotationConfigData.Add(source);
                            this.HintTextBlock.Foreground = Brushes.Green;
                            this.HintTextBlock.Text = "Add success.";
                            this.NameTextBox.Text = string.Empty;
                            this.AuthNameTextBox.Text = string.Empty;
                            this.PasswordTextBox.Text = string.Empty;
                        }
                        else
                        {
                            this.HintTextBlock.Foreground = Brushes.Red;
                            this.HintTextBlock.Text = "Add failed.";
                        }
                    });
                });
            }
            else
            {
                Dictionary<string, object> fieldAndValues = new Dictionary<string, object>();
                if (this._EditingOrigin.Name != this._EditingSource.Name)
                {
                    fieldAndValues.Add(FieldSR.Name, this._EditingSource.Name);
                }
                if (this._EditingOrigin.AuthName != this._EditingSource.AuthName)
                {
                    fieldAndValues.Add(FieldSR.AuthName, this._EditingSource.AuthName);
                }
                if (this._EditingOrigin.Password != this._EditingSource.Password)
                {
                    fieldAndValues.Add(FieldSR.Password, this._EditingSource.Password);
                }
                if (fieldAndValues.Count > 0)
                {
                    ConsoleClient.Instance.UpdateMetadataObject(MetadataType.QuotationSource, this._EditingSource.Id, fieldAndValues, delegate(bool success)
                    {
                        if (success)
                        {
                            this._EditingOrigin.ApplyChangeToUI(fieldAndValues);
                            this.ShowSuccessHint("Update Successful.");
                        }
                        else
                        {
                            this.ShowSuccessHint("Update failed.");
                        }
                    });
                }
            }
        }
 public VmQuotationSource(QuotationSource quotationSource)
     : base(quotationSource)
 {
     this._QuotationSource = quotationSource;
 }