示例#1
0
 /// <summary>
 /// Establece el error especificado en el objeto de respuesta de una petición
 /// </summary>
 /// <param name="response">Objeto de respuesta de la petición</param>
 /// <param name="code">Error a esteblecer</param>
 private void SetResponseErrorCode(AGenericApiResponse response, ErrorMessagesMnemonics code)
 {
     if (response != null)
     {
         response.ResponseCode    = (int)code;
         response.ResponseMessage = code.ToDescription();
     }
 }
示例#2
0
        /// <summary>
        /// Realiza la autenticacion en la plataforma y retorna el SessionId
        /// </summary>
        /// <param name="request">Objeto que contiene las credenciales del usuario</param>
        /// <param name="response">Objeto base de respuesta</param>
        /// <param name="returnCode">Codigo de error en caso de que algo falle (-1 = OK, >-1 = Error)</param>
        /// <returns>Un <c>String</c> que contiene el <c>SessionId</c> del usuario autenticado</returns>
        protected string GetSessionId(ASecuredApiRequest request, AGenericApiResponse response, out ErrorMessagesMnemonics returnCode)
        {
            returnCode = ErrorMessagesMnemonics.None;

            string sessionId = this.GetSessionId(request, out returnCode);

            if (returnCode != ErrorMessagesMnemonics.None)
            {
                response.ResponseCode    = (int)returnCode;
                response.ResponseMessage = returnCode.ToDescription();
            }

            return(sessionId);
        }
示例#3
0
        public DataContract.Macro.GetMacroProductListByCategoryResponse GetMacroProductsByCategory(DataContract.Macro.GetMacroProductListRequest request)
        {
            LogRequest(request);

            var response  = new DataContract.Macro.GetMacroProductListByCategoryResponse();
            var sessionId = GetSessionId(request, out errorMessage);

            logger.InfoLow("[API] [" + sessionId + "] [MacroProductProvider] [SEND-DATA] GetMacroProductsByCategory {sessionId = " + sessionId + ", UserId=" + request.Agent + ", DeviceType=" + request.DeviceType + "}");

            if (errorMessage != ErrorMessagesMnemonics.None)
            {
                response.ResponseCode    = (int)errorMessage;
                response.ResponseMessage = errorMessage.ToDescription();
                logger.InfoLow("[API Binwus] [" + sessionId + "] [MacroProductProvider] [SEND-DATA] GetMacroProductsByCategory Error: " + errorMessage.ToDescription());

                return(response);
            }

            try
            {
                var platformId = Convert.ToInt32(request.Platform);                              //1
                var countryId  = Convert.ToInt32(ConfigurationManager.AppSettings["CountryId"]); //10
                logger.InfoLow("[API BinwusA] [MacroProductProvider]");

                //Platform products.
                var productList = new ServiceExecutionDelegator <GetProductListResponseBody, GetProductListRequestBody>().
                                  ResolveRequest(new GetProductListRequestBody()
                {
                    AuthenticationData = new AuthenticationData()
                    {
                        Username  = request.AuthenticationData.Username,
                        Password  = request.AuthenticationData.Password,
                        SessionID = sessionId
                    },
                    Agent      = request.Agent,
                    DeviceType = request.DeviceType
                }, request.Platform, ApiServiceName.GetProductList);
                logger.InfoLow("[API BinwusB] [MacroProductProvider]");
                if (productList.ProductList == null)
                {
                    response = new GetMacroProductListByCategoryResponse
                    {
                        ResponseCode    = 99,
                        ResponseMessage = "Error: El usuario no tiene productos asignados en la plataforma.",
                        TransactionID   = 0
                    };
                    logger.InfoLow("[API Binwus1] [" + sessionId + "] [MacroProductProvider] [SEND-DATA] GetMacroProductsByCategory Error: El usuario no tiene productos asignados en la plataforma.");
                }
                else
                {
                    logger.InfoLow("[API BinwusC.] [MacroProductProvider]");
                    var dm = new Movilway.API.Data.MacroProduct.MacroProductDataManager();
                    logger.InfoLow("[API BinwusD.] [MacroProductProvider]");
                    response = dm.GetMacroProductsByCategory(platformId, countryId, productList.ProductList, request.DeviceType);
                    logger.InfoLow("[API BinwusE.] [MacroProductProvider]");

                    logger.InfoLow("[API Binwus2] [" + sessionId + "] [MacroProductProvider] [RECV-DATA] GetMacroProductsByCategory {response={" + productList.ProductList.ToString() + "}}");

                    response.ResponseCode    = 0;
                    response.ResponseMessage = "Exito.";
                    response.TransactionID   = 0;
                }
            }
            catch (Exception e)
            {
                logger.InfoLow("[API Binwus3] [" + sessionId + "] [MacroProductProvider] [RECV-DATA] GetMacroProductsByCategory Error: " + e.Message);

                ProviderLogger.ExceptionLow(() => TagValue.New().Message("Exception trying to serve KINACU Operation").Exception(e));
            }

            LogResponse(response);

            return(response);
        }