예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="username"></param>
        /// <param name="pushEnabled"></param>
        public static void UpdateUserAccount(string username, string password, PushEnabled pushEnabled, UserStatus userStatus)
        {
            RequestMode requestMode = RequestMode.Set;

            if (_voipServerUrl == null)
            {
                _voipServerUrl = ConfigurationManager.AppSettings[NeeoConstants.VoipServerUrl];
            }

            RestRequest request = new RestRequest();

            request.AddQueryParameter("mode", requestMode.ToString("G").ToLower());
            request.AddQueryParameter("mob", username);

            if (password != null)
            {
                request.AddQueryParameter("pass", password);
            }

            if (pushEnabled != Voip.PushEnabled.NotSpecified)
            {
                request.AddQueryParameter("pushEnabled", pushEnabled.ToString("D"));
            }

            if (userStatus != Voip.UserStatus.NotSpecified)
            {
                request.AddQueryParameter("status", userStatus.ToString("D"));
            }

            try
            {
                ExecuteRequest(request, requestMode);
            }
            catch (ApplicationException firstAppException)
            {
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, firstAppException.Message);
                try
                {
                    if (!NeeoUtility.IsNullOrEmpty(password))
                    {
                        ExecuteBackupPolicy(firstAppException.Message, request, requestMode);
                    }
                    else
                    {
                        throw new ApplicationException(CustomHttpStatusCode.ServerInternalError.ToString("D"));
                    }
                }
                catch (ApplicationException secondAppException)
                {
                    throw new Exception(secondAppException.Message);
                }
            }
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        public static void RegisterUser(string username, string password, PushEnabled pushEnabled)
        {
            RequestMode requestMode = RequestMode.Add;

            if (_voipServerUrl == null)
            {
                _voipServerUrl = ConfigurationManager.AppSettings[NeeoConstants.VoipServerUrl];
            }

            RestRequest request = new RestRequest();

            request.AddQueryParameter("mode", requestMode.ToString("G").ToLower());
            request.AddQueryParameter("mob", username);
            request.AddQueryParameter("pass", password);

            if (pushEnabled != Voip.PushEnabled.NotSpecified)
            {
                request.AddQueryParameter("pushEnabled", pushEnabled.ToString("D"));
            }

            try
            {
                ExecuteRequest(request, requestMode);
            }
            catch (ApplicationException firstAppException)
            {
                LogManager.CurrentInstance.ErrorLogger.LogError(
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, firstAppException.Message);
                try
                {
                    ExecuteBackupPolicy(firstAppException.Message, request, requestMode);
                }
                catch (ApplicationException secondAppException)
                {
                    LogManager.CurrentInstance.ErrorLogger.LogError(
                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, secondAppException.Message);
                    try
                    {
                        ExecuteBackupPolicy(firstAppException.Message, request, requestMode);
                    }
                    catch (ApplicationException thirdAppException)
                    {
                        throw new Exception(thirdAppException.Message);
                    }
                }
            }
        }