Пример #1
0
 public static void SetErrorCodeIfNecessary(LocalizedException e, ErrorConstants error)
 {
     if (!(e is AvailabilityException) && !(e is AvailabilityInvalidParameterException))
     {
         e.ErrorCode = (int)error;
     }
 }
Пример #2
0
        public override String ToFormulaString()
        {
            StringBuilder sb = new StringBuilder();

            if (externalWorkbookNumber >= 0)
            {
                sb.Append('[');
                sb.Append(externalWorkbookNumber);
                sb.Append(']');
            }
            if (sheetName != null)
            {
                sb.Append(sheetName);
            }
            sb.Append('!');
            sb.Append(ErrorConstants.GetText(ErrorConstants.ERROR_REF));
            return(sb.ToString());
        }
Пример #3
0
        public async Task <IHttpActionResult> SignUp([FromBody] CreateUserRequest apiRequest)
        {
            try
            {
                if (apiRequest == null)
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Empty required fields", null)));
                }

                if (string.IsNullOrEmpty(apiRequest.Name))
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Name is required", null)));
                }

                if (string.IsNullOrEmpty(apiRequest.Email))
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Email is required", null)));
                }

                if (string.IsNullOrEmpty(apiRequest.Password))
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Password is required", null)));
                }

                if (apiRequest.RoleID == 0)
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "RoleId is required", null)));
                }


                var result = (await RespositoryService.UserService.CreateUser(apiRequest)).ResponseObject;
                if (result < 0)
                {
                    return(Ok(new ResultDetail(result, ErrorConstants.ErrorDescription(result), Version, result)));
                }

                var response = new ResultDetail(ErrorConstants.Success, "Success", Version, result);
                return(Ok(response));
            }catch (Exception ex)
            {
                throw new AppHttpException(HttpStatusCode.OK
                                           , new ResultDetail(ErrorConstants.Unknown, ex.Message, Version));
            }
        }
Пример #4
0
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(GetType().Name);
            sb.Append(" [");
            if (externalWorkbookNumber >= 0)
            {
                sb.Append(" [");
                sb.Append("workbook=").Append(ExternalWorkbookNumber);
                sb.Append("] ");
            }
            if (sheetName != null)
            {
                SheetNameFormatter.AppendFormat(sb, sheetName);
            }
            sb.Append(" ! ");
            sb.Append(ErrorConstants.GetText(ErrorConstants.ERROR_REF));
            sb.Append("]");
            return(sb.ToString());
        }
 public AvailabilityException(string serverName, ErrorConstants errorCode, LocalizedString localizedString) : base(localizedString)
 {
     base.ErrorCode          = (int)errorCode;
     this.ServerName         = serverName;
     this.LocationIdentifier = string.Empty;
 }
 public AvailabilityException(ErrorConstants errorCode, LocalizedString localizedString, Exception innerException, uint locationIdentifier) : base(localizedString, innerException)
 {
     base.ErrorCode          = (int)errorCode;
     this.ServerName         = ExceptionDefaults.DefaultMachineName;
     this.LocationIdentifier = locationIdentifier.ToString();
 }
 public AvailabilityException(ErrorConstants errorCode, LocalizedString localizedString) : base(localizedString)
 {
     base.ErrorCode          = (int)errorCode;
     this.ServerName         = ExceptionDefaults.DefaultMachineName;
     this.LocationIdentifier = string.Empty;
 }
Пример #8
0
        internal void UpdateClientReportedPerfCounters(string messageId, DateTime requestTime, int responseTime, int responseSize, int responseCode, int[] recipientErrorCodes)
        {
            TimeSpan t = DateTime.UtcNow.Subtract(requestTime);

            if (t.Ticks < 0L)
            {
                t = DateTime.UtcNow.AddHours(24.0).Subtract(requestTime);
                if (t.Ticks < 0L)
                {
                    return;
                }
            }
            if (t < TimeSpan.FromHours(24.0))
            {
                int num  = responseCode;
                int num2 = 200;
                if (num == num2 && recipientErrorCodes != null)
                {
                    for (int i = 0; i < recipientErrorCodes.Length; i++)
                    {
                        if (recipientErrorCodes[i] > 0 && AvailabilityQuery.IsServerError(recipientErrorCodes[i]))
                        {
                            num = recipientErrorCodes[i];
                            break;
                        }
                    }
                }
                if (num != num2)
                {
                    PerformanceCounters.FailedClientReportedRequestsTotal.Increment();
                    ErrorConstants errorConstants = (ErrorConstants)num;
                    if (errorConstants == ErrorConstants.ServiceDiscoveryFailed)
                    {
                        PerformanceCounters.FailedClientRequestsNoASUrl.Increment();
                        return;
                    }
                    if (errorConstants == ErrorConstants.TimeoutExpired)
                    {
                        PerformanceCounters.FailedClientRequestsTimeouts.Increment();
                        return;
                    }
                    PerformanceCounters.FailedClientRequestsPartialOrOther.Increment();
                    return;
                }
                else
                {
                    PerformanceCounters.PastTotalClientSuccessRequests.Increment();
                    int num3 = (int)Math.Round((double)(responseTime / 1000));
                    if (num3 <= 5)
                    {
                        PerformanceCounters.PastClientRequestsUnder5.Increment();
                    }
                    if (num3 <= 10)
                    {
                        PerformanceCounters.PastClientRequestsUnder10.Increment();
                    }
                    if (num3 <= 20)
                    {
                        PerformanceCounters.PastClientRequestsUnder20.Increment();
                    }
                    if (num3 > 20)
                    {
                        PerformanceCounters.PastClientRequestsOver20.Increment();
                    }
                }
            }
        }
Пример #9
0
 public AvailabilityInvalidParameterException(ErrorConstants errorCode, LocalizedString localizedString) : base(localizedString)
 {
     base.ErrorCode = (int)errorCode;
 }
Пример #10
0
        public async Task <IHttpActionResult> Login([FromBody] UserRequest apiRequest)
        {
            try
            {
                if (string.IsNullOrEmpty(apiRequest.Email))
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Email is required", null)));
                }

                if (string.IsNullOrEmpty(apiRequest.Password))
                {
                    return(Ok(new ResultDetail(ErrorConstants.InvalidPropertyValue, "Password is required", null)));
                }

                var result = (await RespositoryService.UserService.GetUser(apiRequest)).ResponseObject;

                if (result == null)
                {
                    return(Ok(new ResultDetail(ErrorConstants.Unknown, "User not found", Version, result)));
                }

                if (!result.Password.ToUpper().Equals(ConfigHelpers.EncryptStringMD5(apiRequest.Password).ToUpper()))
                {
                    return(Ok(new ResultDetail(ErrorConstants.WRONG_USER_AUTHENTICATION, ErrorConstants.ErrorDescription(ErrorConstants.WRONG_USER_AUTHENTICATION), Version, null)));
                }

                JwtManager   jwtManager   = new JwtManager();
                TokenRequest tokenRequest = new TokenRequest();
                tokenRequest.UserID = result.ID;
                tokenRequest.Name   = result.Name;
                tokenRequest.Email  = result.Email;
                tokenRequest.RoleID = result.RoleID;

                var token = jwtManager.GenerateSecurityToken(tokenRequest);
                token.UserDetail = result;

                var response = new ResultDetail(ErrorConstants.Success, "Success", Version, token);
                return(Ok(response));
            }catch (Exception ex)
            {
                throw new AppHttpException(HttpStatusCode.OK
                                           , new ResultDetail(ErrorConstants.Unknown, ex.Message, Version));
            }
        }
Пример #11
0
 public FailureResponse(string code) : base(ResponseConstants.FAILURE, code, ErrorConstants.GetErrorMessage(code))
 {
 }
 public ProxyQueryFailureException(string serverName, LocalizedString message, ErrorConstants errorCode, ResponseMessage responseMessage, string responseSource) : base(serverName, errorCode, message)
 {
     this.ResponseMessage = responseMessage;
     this.ResponseSource  = responseSource;
 }