コード例 #1
0
        public JsonNetResult GetBalanceTransactionsForSource(string sourceId)
        {
            #region Get data from WCF

            var platformBillingServiceClient = new PlatformBillingService.PlatformBillingServiceClient();
            var sourceBalanceTransactions    = new SourceBalanceTransactions();

            try
            {
                platformBillingServiceClient.Open();
                sourceBalanceTransactions = platformBillingServiceClient.GetBalanceTransactionsForSource(sourceId, Common.SharedClientKey);

                //Close the connection
                WCFManager.CloseConnection(platformBillingServiceClient);
            }
            catch (Exception e)
            {
                #region Manage Exception

                string exceptionMessage = e.Message.ToString();

                var    currentMethod       = System.Reflection.MethodBase.GetCurrentMethod();
                string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;

                // Abort the connection & manage the exception
                WCFManager.CloseConnection(platformBillingServiceClient, exceptionMessage, currentMethodString);

                #endregion
            }

            #endregion

            JsonNetResult jsonNetResult = new JsonNetResult();
            jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = sourceBalanceTransactions;

            return(jsonNetResult);
        }
コード例 #2
0
        public JsonNetResult GetTransferHistory(int itemLimit)
        {
            var             user      = AuthenticationCookieManager.GetAuthenticationCookie();
            List <Transfer> transfers = null;

            #region (Plan A) Get data from Redis Cache

            /*
             * try
             * {
             *  IDatabase cache = CoreServiceSettings.RedisConnectionMultiplexers.AccountManager_Multiplexer.GetDatabase();
             *
             *  string hashKey = "accountbyid:" + accountId.ToString().Replace("-", "");
             *  string hashField = "creditcard";
             *
             *  var redisValue = cache.HashGet(hashKey, hashField);
             *
             *  if (redisValue.HasValue)
             *  {
             *      accountCreditCardInfo = JsonConvert.DeserializeObject<AccountCreditCardInfo>(redisValue);
             *  }
             * }
             * catch (Exception e)
             * {
             *  var error = e.Message;
             *  //TODO: Log: error message for Redis call
             * }*/

            #endregion

            if (transfers == null)
            {
                #region (Plan B) Get data from WCF

                var platformBillingServiceClient = new PlatformBillingService.PlatformBillingServiceClient();

                try
                {
                    platformBillingServiceClient.Open();
                    transfers = platformBillingServiceClient.GetTransferHistory(
                        itemLimit, Common.SharedClientKey
                        ).ToList();//,
                    //user.Id,
                    //PlatformAdminSite.AccountManagementService.RequesterType.PlatformUser).ToList();

                    //Close the connection
                    WCFManager.CloseConnection(platformBillingServiceClient);
                }
                catch (Exception e)
                {
                    #region Manage Exception

                    string exceptionMessage = e.Message.ToString();

                    var    currentMethod       = System.Reflection.MethodBase.GetCurrentMethod();
                    string currentMethodString = currentMethod.DeclaringType.FullName + "." + currentMethod.Name;

                    // Abort the connection & manage the exception
                    WCFManager.CloseConnection(platformBillingServiceClient, exceptionMessage, currentMethodString);

                    #endregion
                }



                #endregion
            }

            JsonNetResult jsonNetResult = new JsonNetResult();
            jsonNetResult.Formatting = Newtonsoft.Json.Formatting.Indented;
            jsonNetResult.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local; //<-- Convert UTC times to LocalTime
            jsonNetResult.Data = transfers;

            return(jsonNetResult);
        }