예제 #1
0
 /// <summary>
 /// This method takes the Subscriber account object "subscriber" and uses it to save a subscriber.
 /// It is split from the CreateSubscriber method so a user can make changes to the "subscriber" object 
 /// before saving it. It does NOT make another attempt if it fails
 /// Caller will be responsible for handling exceptions thrown
 /// </summary>
 /// <param name="subscriber">Holds the field information of the subscriber</param>
 /// <returns>A boolean that says whether the subscriber was successfully created</returns>
 public bool SaveSubscriberNoRetry(SubscriberDto subscriber)
 {
     bool result = false;
     using (var client = new RosettianClient())
     {
         //Save subscriber
         client.CreateSubscriber(subscriber, CurrentUser.AsUserDto());
         result = true;
     }
     return result;
 }
예제 #2
0
        /// <summary>
        /// This method takes the Subscriber account object "subscriber" and uses it to save a subscriber.
        /// It is split from the CreateSubscriber method so a user can make changes to the "subscriber" object 
        /// before saving it. It will make up to four attempts to succeed.
        /// Caller will be responsible for handling exceptions thrown
        /// </summary>
        /// <param name="subscriber">Holds the field information of the subscriber</param>
        /// <returns>A boolean that says whether the subscriber was successfully created</returns>
        public bool SaveSubscriber(SubscriberDto subscriber)
        {
            int iteration = 0; //Used to keep track of how many attempts were made
            bool result = false;

            do
            {
                iteration++;
                try
                {
                    using (var client = new RosettianClient())
                    {
                        //Save subscriber
                        client.CreateSubscriber(subscriber, CurrentUser.AsUserDto());
                        result = true;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    //Try four times before throwing an error
                    if (iteration == 4)
                    {
                        //throw;
                        string temp = ex.Message;
                    }

                    subscriber = CreateSubscriber();
                }
            } while (iteration != 4);

            return result;
        }
예제 #3
0
 /// <summary>
 /// RestoreSubscriber1 - calls either Rosettian CreateSubscriber or UpdateSubscriber
 /// </summary>
 /// <param name="sub"></param>
 /// <param name="requiresUpdates"></param>
 public static void RestoreSubscriber1(SubscriberDto sub, bool requiresUpdates)
 {
     using (var client = new RosettianClient())
     {
         if (!client.SubscriberExists(sub.ID, user))
         {
             client.CreateSubscriber(sub, user);
         }
         else if (requiresUpdates)
         {
             client.UpdateSubscriber(sub, true, user);
         }
     }
 }
예제 #4
0
        /// <summary>
        /// This method takes the Subscriber account object "subscriber" and uses it to save a subscriber.
        /// It is split from the CreateSubscriber method so a user can make changes to the "subscriber" object 
        /// before saving it.
        /// Caller will be responsible for handling exceptions thrown
        /// </summary>
        /// <param name="subscriber">Holds the field information of the subscriber</param>
        /// <returns>A boolean that says whether the subscriber was successfully created</returns>
        public bool SaveMinimalSubscriberWithLocation(SubscriberDto subscriber)
        {
            int iteration = 0;
            bool result = false;

            do
            {
                iteration++;
                try
                {
                    using (var client = new RosettianClient())
                    {
                        //Save subscriber
                        client.CreateSubscriber(subscriber, CurrentUser.AsUserDto());
                        result = true;
                        break;
                    }
                }
                catch (Exception ex)
                {
                    if (iteration == 4)
                    {
                        //throw;
                        string temp = ex.Message;
                    }

                    subscriber = CreateMinimalSubscriberWithLocation();
                }
            } while (iteration != 4);

            return result;
        }
예제 #5
0
        /// <summary>
        /// RestoreSubscriber - returns SubscriberDto - calls either Rosettian CreateSubscriber or UpdateSubscriber
        /// </summary>
        /// <param name="sub"></param>
        /// <returns></returns>
        protected static SubscriberDto RestoreSubscriber(SubscriberDto sub)
        {
            using (var client = new RosettianClient())
            {
                if (!client.SubscriberExists(sub.ID, user))
                {
                    if (sub.Accounts != null && sub.Accounts.Count > 1 && sub.Accounts[0].ServiceEnabled == true)
                    {
                        sub.Accounts[0].ServiceEnabled = false;
                    }
                    client.CreateSubscriber(sub, user);
                }
                else
                {
                    client.UpdateSubscriber(sub, true, user);
                }

                if (sub.Accounts != null && sub.Accounts.Count > 0)
                {
                    var serviceProfiles = sub.Accounts[0].ServiceProfiles;
                    if (serviceProfiles != null && serviceProfiles.Count > 0)
                    {
                        var expectedPhones = ((VoiceServiceProfileDto)serviceProfiles[0]).PhoneLines;
                        RestorePhone(sub.ID, expectedPhones);

                    }
                }
                return sub;
            }
        }