示例#1
0
 public new bool Update()
 {
     bool ret = true;
     try
     {
         base.Update();
         List<Pin> pins = Pin.LoadAllForSet(this);
         for(int x=0;x<pins.Count;x++)
         {
             Pin p = pins[x];
             bool found = false;
             for(int y=0;y<_pins.Count;y++)
             {
                 NameValuePair nvp = _pins[y];
                 if (Advanced && p.Extension!=null)
                 {
                     if (nvp.Name == p.Extension.id)
                     {
                         found = true;
                         p.PinNumber = nvp.Value.ToString();
                         p.Update();
                         _pins.RemoveAt(y);
                         break;
                     }
                 }
                 else if (!Advanced)
                 {
                     if (p.ID.ToString() == nvp.Name)
                     {
                         found = true;
                         p.PinNumber = nvp.Value.ToString();
                         p.Extension = null;
                         p.Update();
                         _pins.RemoveAt(y);
                     }
                 }
             }
             if (found)
             {
                 pins.RemoveAt(x);
                 x--;
             }
             else
                 p.Delete();
         }
         foreach (NameValuePair nvp in _pins)
         {
             Pin p = new Pin();
             if (Advanced)
                 p.Extension = Extension.Load(nvp.Name);
             p.PinNumber = nvp.Value.ToString();
             p.OwningSet = this;
             p.Save();
         }
         ConfigurationController.RegisterChangeCall(
                     typeof(PinnedRoutePlan),
                     new ADialPlan.sUpdateConfigurationsCall(
                         (Advanced ? "UpdateAdvancedPinset" : "UpdateBasicPinset"),
                     new NameValuePair[]{
                         new NameValuePair("context",Context.Name),
                         new NameValuePair("name",_orignalName),
                         new NameValuePair("newName",Name),
                         new NameValuePair("pins",_PinData)
                     }),
                     new IEvent[]{
                         new GenericEvent("PinSetUpdated",
                             new NameValuePair[]{
                                 new NameValuePair("Name",Name),
                                 new NameValuePair("Context",Context.Name),
                                 new NameValuePair("IsAdvanced",Advanced)
                         })
                     });
     }
     catch (Exception e)
     {
         Log.Error(e);
         EventController.TriggerEvent(new ErrorOccuredEvent(e));
         ret = false;
     }
     return ret;
 }
示例#2
0
 public new bool Save()
 {
     bool ret = true;
     try
     {
         base.Save();
         foreach (NameValuePair nvp in _pins)
         {
             Pin p = new Pin();
             if (Advanced)
                 p.Extension = Extension.Load(nvp.Name);
             p.PinNumber = nvp.Value.ToString();
             p.OwningSet = this;
             p.Save();
         }
         ConfigurationController.RegisterChangeCall(
                     typeof(PinnedRoutePlan),
                     new ADialPlan.sUpdateConfigurationsCall(
                         (Advanced ? "AddAdvancedPinset" : "AddBasicPinset"),
                     new NameValuePair[]{
                         new NameValuePair("context",Context.Name),
                         new NameValuePair("name",_orignalName),
                         new NameValuePair("pins",_PinData)
                     }),
                     new IEvent[]{
                         new GenericEvent("PinSetCreated",
                             new NameValuePair[]{
                                 new NameValuePair("Name",Name),
                                 new NameValuePair("Context",Context.Name),
                                 new NameValuePair("IsAdvanced",Advanced)
                         })
                     });
     }
     catch (Exception e)
     {
         Log.Error(e);
         EventController.TriggerEvent(new ErrorOccuredEvent(e));
         ret = false;
     }
     return ret;
 }
示例#3
0
 public bool Save()
 {
     bool ret = true;
     try
     {
         Pin pn = new Pin();
         pn.PinNumber = PinNumber;
         if (ExtensionNumber != null)
             pn.Extension = Extension.Load(ExtensionNumber + "@" + ExtensionDomain);
         pn.OwningSet = PinSet.Load(SetName+"@"+Context);
         pn.Save();
         ID = pn.ID;
         ConfigurationController.RegisterChangeCall(
             typeof(PinnedRoutePlan),
             new ADialPlan.sUpdateConfigurationsCall(
                     (ExtensionNumber != null ? "AddAdvancedPin" : "AddBasicPin"),
                     new NameValuePair[]{
                         new NameValuePair("context",Context),
                         new NameValuePair("name",SetName),
                         new NameValuePair("pin",(ExtensionNumber!=null ? (object)new PinnedRoutePlan.sAdvancedPin(ExtensionNumber,ExtensionDomain,PinNumber) : (object)PinNumber))
                     }
                 ),
                     new IEvent[]{
                         new GenericEvent("PinSetUpdated",
                             new NameValuePair[]{
                                 new NameValuePair("Name",SetName),
                                 new NameValuePair("Context",Context),
                                 new NameValuePair("IsAdvanced",(ExtensionNumber!=null))
                         })
                     }
             );
     }
     catch (Exception e)
     {
         Log.Error(e);
         EventController.TriggerEvent(new ErrorOccuredEvent(e));
         ret = false;
     }
     return ret;
 }