Пример #1
0
        private decimal balance(string sessionid)
        {
            mobiEz.balanceRequestType balanceRequestTypeObj = new balanceRequestType();
            mobiEz.balanceResponse    balanceResponseObj    = new balanceResponse();
            mobiEz.balance            balanceObj            = new balance();

            balanceRequestTypeObj.sessionid = sessionid;
            balanceRequestTypeObj.type      = 1;

            balanceObj.balanceRequest = balanceRequestTypeObj;
            try
            {
                //invoke balance function
                balanceResponseObj = UMSObj.balance(balanceObj);

                if (balanceResponseObj.balanceReturn.result == 0)
                {
                    return(balanceResponseObj.balanceReturn.avail_1);
                }
                else
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Пример #2
0
        internal static BalanceResponseInternal BalanceInternal(BalanceRequestInternal balanceRequest)
        {
            UMarketSCClient         utibaClient   = new UMarketSCClient();
            BalanceResponseInternal balanceResult = null;

            try
            {
                utibaClient.InnerChannel.OperationTimeout = new TimeSpan(0, 0, _balanceTimeout);
                using (OperationContextScope scope = new OperationContextScope(utibaClient.InnerChannel))
                {
                    HttpRequestMessageProperty messageProperty = new HttpRequestMessageProperty();
                    messageProperty.Headers.Add(HttpRequestHeader.UserAgent, UserAgent);
                    OperationContext.Current.OutgoingMessageProperties.Add(HttpRequestMessageProperty.Name, messageProperty);

                    Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Parámetros Recibidos BalanceProvider.BalanceInternal: SessionID={0}, DeviceType={1}", balanceRequest.SessionID, balanceRequest.DeviceType), Logger.LoggingLevelType.Low);

                    balanceResponse utibaBalanceResponse = utibaClient.balance(new Utiba.balance()
                    {
                        balanceRequest = new Utiba.balanceRequestType()
                        {
                            sessionid   = balanceRequest.SessionID,
                            device_type = balanceRequest.DeviceType
                        }
                    });

                    balanceResult = new BalanceResponseInternal()
                    {
                        ResponseCode    = utibaBalanceResponse.balanceReturn.result,
                        ResponseMessage = utibaBalanceResponse.balanceReturn.result_message,
                        TransactionID   = utibaBalanceResponse.balanceReturn.transid,
                        WalletBalance   = utibaBalanceResponse.balanceReturn.avail_1,
                        StockBalance    = utibaBalanceResponse.balanceReturn.avail_2,
                        PointsBalance   = utibaBalanceResponse.balanceReturn.avail_3,
                        DebtBalance     = utibaBalanceResponse.balanceReturn.avail_5
                    };
                }
                if (balanceResult.ResponseCode != 0)
                {
                    balanceResult.SetResponseNamespace(ApiResponseInternal.ResponseNamespace.BAC);
                }
            }
            catch (Exception e)
            {
                if (balanceResult == null)
                {
                    balanceResult = new BalanceResponseInternal();
                }
                balanceResult.SetThrowedException(e);
            }
            Log(Logger.LogMessageType.Info, "->   -------------------- " + String.Format("Resultado Obtenido BalanceProvider.BalanceInternal: ResponseCode={0}, ResponseMessage={1}, TransactionID={2}, " +
                                                                                         "WalletBalance={3}, PointsBalance={4}, PointsBalance={5}, DebtBalance={6}", balanceResult.ResponseCode, balanceResult.ResponseMessage, balanceResult.TransactionID,
                                                                                         balanceResult.WalletBalance, balanceResult.StockBalance, balanceResult.PointsBalance, balanceResult.DebtBalance), Logger.LoggingLevelType.Low);
            return(balanceResult);
        }
Пример #3
0
        public override IMovilwayApiResponse PerformUtibaOperation(IMovilwayApiRequest requestObject, API.Utiba.UMarketSCClient utibaClientProxy, string sessionID)
        {
            GetBalanceRequestBody request = requestObject as GetBalanceRequestBody;

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetBalanceProvider] [SEND-DATA] balanceRequest {sessionid=" + sessionID + ",device_type=" + request.DeviceType + "}");

            balanceResponse utibaBalanceResponse = utibaClientProxy.balance(new balance()
            {
                balanceRequest = new balanceRequestType()
                {
                    sessionid   = sessionID,
                    device_type = request.DeviceType
                }
            });

            StringBuilder sb = new StringBuilder("balances={");

            foreach (var pair in utibaBalanceResponse.balanceReturn.balances)
            {
                sb.Append("keyValuePair={key=" + pair.key + ",value=" + pair.value + "},");
            }
            sb.Remove(sb.Length - 1, 1);
            sb.Append("}");

            logger.InfoLow("[UTI] " + base.LOG_PREFIX + "[GetBalanceProvider] [RECV-DATA] balanceResponse {transid=" + utibaBalanceResponse.balanceReturn.transid + ",result=" + utibaBalanceResponse.balanceReturn.result +
                           ",result_namespace=" + utibaBalanceResponse.balanceReturn.result_namespace + ",result_message=" + utibaBalanceResponse.balanceReturn.result_message +
                           ",avail_1=" + utibaBalanceResponse.balanceReturn.avail_1 + ",avail_2=" + utibaBalanceResponse.balanceReturn.avail_2 + ",avail_3=" + utibaBalanceResponse.balanceReturn.avail_3 +
                           ",avail_5=" + utibaBalanceResponse.balanceReturn.avail_5 + ",current_1=" + utibaBalanceResponse.balanceReturn.current_1 + ",current_2=" + utibaBalanceResponse.balanceReturn.current_2 +
                           ",current_3=" + utibaBalanceResponse.balanceReturn.current_3 + ",current_5=" + utibaBalanceResponse.balanceReturn.current_5 + ",pending_1=" + utibaBalanceResponse.balanceReturn.pending_1 +
                           ",pending_2=" + utibaBalanceResponse.balanceReturn.pending_2 + ",pending_3=" + utibaBalanceResponse.balanceReturn.pending_3 + ",pending_5=" + utibaBalanceResponse.balanceReturn.pending_5 +
                           "," + sb.ToString() + "}");


            GetBalanceResponseBody response = new GetBalanceResponseBody()
            {
                ResponseCode    = Utils.BuildResponseCode(utibaBalanceResponse.balanceReturn.result, utibaBalanceResponse.balanceReturn.result_namespace),
                ResponseMessage = utibaBalanceResponse.balanceReturn.result_message,
                TransactionID   = utibaBalanceResponse.balanceReturn.transid,
                WalletBalance   = utibaBalanceResponse.balanceReturn.avail_1,
                StockBalance    = utibaBalanceResponse.balanceReturn.avail_2,
                PointsBalance   = utibaBalanceResponse.balanceReturn.avail_3,
                DebtBalance     = utibaBalanceResponse.balanceReturn.avail_5
            };

            return(response);
        }