示例#1
0
 public Task SellerSideWalletBal(string Token, string WalletName, string Data)
 {
     try
     {
         //_chatHubContext.Clients.Group("SellerSideWalletBal:" + Pair).SendAsync("RecieveSellerSideWalletBal", Data);
         //++++++++++++++++++++++//
         //var Redis = new RadisServices<ConnetedClientList>(this._fact);
         //ConnetedClientList User = new ConnetedClientList();
         //User = Redis.GetConnectionID(Token);
         //_chatHubContext.Clients.Client(User.ConnectionId).SendAsync("RecieveSellerSideWalletBal", Data);
         var Redis = new RadisServices <ConnetedClientToken>(this._fact);
         IEnumerable <string> ClientList = Redis.GetKey(Token);
         foreach (string s in ClientList.ToList())
         {
             var Key = s;
             Key = Key.Split(":")[1].ToString();
             string Pair = Redis.GetPairOrMarketData(Key, ":", "Pairs");
             if (Pair.Split("_")[0].ToString() == WalletName)
             {
                 _chatHubContext.Clients.Client(Key).SendAsync(Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveSellerSideWalletBal), Data);
                 HelperForLog.WriteLogIntoFile("SellerSideWalletBal", "SocketHub", " Send Data :" + Data);
             }
             else
             {
                 // ignore Data
             }
         }
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#2
0
 public override Task OnConnectedAsync()
 {
     try
     {
         string Pair         = "INR_BTC";
         string BaseCurrency = "BTC";
         var    Redis        = new RadisServices <ConnetedClientList>(this._fact);
         Redis.SaveTagsToSetMember("Pairs:" + Pair, Context.ConnectionId, Pair);
         Redis.SaveTagsToSetMember("Markets:" + BaseCurrency, Context.ConnectionId, BaseCurrency);
         Groups.AddToGroupAsync(Context.ConnectionId, "BroadCast").Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "GroupMessage").Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "BuyerBook:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "SellerBook:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "TradingHistory:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "MarketData:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "ChartData:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "Price:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "PairData:" + BaseCurrency).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "MarketTicker:" + BaseCurrency).Wait();
         return(base.OnConnectedAsync());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#3
0
 //open order
 public Task OpenOrder(string Token, string Order)
 {
     try
     {
         //var Redis = new RadisServices<ConnetedClientList>(this._fact);
         //ConnetedClientList User = new ConnetedClientList();
         //User = Redis.GetConnectionID(Token);
         //_chatHubContext.Clients.Client(User.ConnectionId).SendAsync("RecieveOpenOrder", Order);
         var Redis = new RadisServices <ConnetedClientToken>(this._fact);
         IEnumerable <string> str = Redis.GetKey(Token);
         foreach (string s in str.ToList())
         {
             var key = s;
             key = key.Split(":")[1].ToString();
             _chatHubContext.Clients.Client(key).SendAsync(Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveOpenOrder), Order);
         }
         // _chatHubContext.Clients.Client(str.ToList().AsReadOnly()).SendAsync("RecieveOpenOrder", Order);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#4
0
 public IReadOnlyList <string> GetConnectedClient(string Pair)
 {
     try
     {
         var Redis = new RadisServices <string>(this._fact);
         IReadOnlyList <string> ConnectedClient = Redis.GetSetList(Pair);
         return(ConnectedClient);
     }
     catch (Exception ex)
     {
         List <string> ConnectedClient = new List <string>();
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(ConnectedClient.AsReadOnly());
     }
 }
示例#5
0
 public Task GetChatHistory(string Name, string Message)
 {
     try
     {
         var    Redis = new RadisServices <ChatHistory>(this._fact);
         string Data  = Redis.GetSetData("GroupChatHistory");
         _chatHubContext.Clients.Client(Context.ConnectionId).SendAsync("RecieveChatHistory", Data);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#6
0
 public string GetTokenByUserID(string ID)
 {
     try
     {
         var    Redis       = new RadisServices <ConnetedClientToken>(this._fact);
         string AccessToken = Redis.GetHashData("Tokens:" + ID.ToString(), "Token");
         return(AccessToken);
     }
     catch (Exception ex)
     {
         HelperForLog.WriteErrorLog(System.Reflection.MethodBase.GetCurrentMethod().Name, this.GetType().Name, ex);
         //throw ex;
         return("");
     }
 }
示例#7
0
 // One to one Message Chat
 public Task SendChatMessage(string UserID, string Message)
 {
     try
     {
         var Redis = new RadisServices <ConnetedClientList>(this._fact);
         ConnetedClientList User = new ConnetedClientList();
         User = Redis.GetData(UserID + ":ConnectionDetail");
         _chatHubContext.Clients.Client(User.ConnectionId).SendAsync("RecieveMessage", User + ": " + Message);
         //_chatHubContext.Clients.Group("BroadCast").SendAsync("BroadcastMessage", User + ": " + message);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#8
0
 // Add to Subscription Channel
 public Task AddMarketSubscription(string BaseCurrency, string OldBaseCurrency)
 {
     try
     {
         var Redis = new RadisServices <ConnetedClientList>(this._fact);
         Redis.SaveTagsToSetMember("Markets:" + BaseCurrency, Context.ConnectionId, Context.ConnectionId);
         Groups.AddToGroupAsync(Context.ConnectionId, "PairData:" + BaseCurrency).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "MarketTicker:" + BaseCurrency).Wait();
         RemoveMarketSubscription(OldBaseCurrency);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#9
0
 public Task SendGroupMessage(string Name, string Message)
 {
     try
     {
         // Call the broadcastMessage method to update _chatHubContext.Clients.
         _chatHubContext.Clients.Group("GroupMessage").SendAsync("ReciveGroupMessage", Name, Message);
         var Redis = new RadisServices <ChatHistory>(this._fact);
         Redis.SaveToSet("GroupChatHistory", new ChatHistory {
             Name = Name, Message = Message, Id = Guid.NewGuid()
         }, Name);
         Redis.GetSetData("GroupChatHistory");
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#10
0
        //public Task WalletBalChange(string Token, string WalletName, string Data)
        //{
        //    try
        //    {
        //        var Redis = new RadisServices<ConnetedClientToken>(this._fact);
        //        IEnumerable<string> ClientList = Redis.GetKey(Token);
        //        foreach (string s in ClientList.ToList())
        //        {
        //            var Key = s;
        //            Key = Key.Split(":")[1].ToString();
        //            string Pair = Redis.GetPairOrMarketData(Key, ":", "Pairs");
        //            if (Pair.Split("_")[0].ToString() == WalletName)
        //            {
        //                SellerSideWalletBal(Token,WalletName,Data);
        //            }
        //            else if(Key.Split("_")[1].ToString() == WalletName)
        //            {
        //                BuyerSideWalletBal(Token, WalletName, Data);
        //            }


        //        }
        //        return Task.FromResult(0);
        //    }
        //    catch (Exception ex)
        //    {
        //        _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
        //        return Task.FromResult(0);
        //    }
        //}
        public Task ActivityNotification(string Token, string Message)
        {
            try
            {
                var Redis = new RadisServices <ConnetedClientToken>(this._fact);
                IEnumerable <string> str = Redis.GetKey(Token);
                foreach (string s in str.ToList())
                {
                    var key = s;
                    key = key.Split(":")[1].ToString();
                    _chatHubContext.Clients.Client(key).SendAsync(Enum.GetName(typeof(enReturnMethod), enReturnMethod.RecieveNotification), Message);
                }
                return(Task.FromResult(0));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
                return(Task.FromResult(0));
            }
        }
示例#11
0
 public Task OnTokenChange(string Token)
 {
     try
     {
         var    Redis       = new RadisServices <ConnetedClientToken>(this._fact);
         string AccessToken = Redis.GetHashData(Token, "accessToken");
         ConnetedClientToken ClientToken = new ConnetedClientToken();
         ClientToken = Redis.GetData("Users:" + Context.ConnectionId);
         Redis.DeleteTag("Users:" + Context.ConnectionId, ClientToken.Token);
         Redis.SaveToHash("Users:" + Context.ConnectionId, new ConnetedClientToken {
             Token = AccessToken
         }, AccessToken);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#12
0
 // Add to Subscription Channel
 public Task AddPairSubscription(string Pair, string OldPair)
 {
     try
     {
         var Redis = new RadisServices <ConnetedClientList>(this._fact);
         Redis.SaveTagsToSetMember("Pairs:" + Pair, Context.ConnectionId, Context.ConnectionId);
         Groups.AddToGroupAsync(Context.ConnectionId, "BuyerBook:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "SellerBook:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "TradingHistory:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "MarketData:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "ChartData:" + Pair).Wait();
         Groups.AddToGroupAsync(Context.ConnectionId, "Price:" + Pair).Wait();
         RemovePairSubscription(OldPair);
         return(Task.FromResult(0));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
         return(Task.FromResult(0));
     }
 }
示例#13
0
        public override Task OnDisconnectedAsync(System.Exception exception)
        {
            try
            {
                //var Redis = new RadisServices<ConnetedClientList>(this._fact);
                //Redis.Scan(Context.ConnectionId, ":ConnectionDetail");

                var    Redis        = new RadisServices <ConnetedClientToken>(this._fact);
                string Pair         = Redis.GetPairOrMarketData(Context.ConnectionId, ":", "Pairs");
                string BaseCurrency = Redis.GetPairOrMarketData(Context.ConnectionId, ":", "Markets");
                //GetConnectedClient(Pair);
                ConnetedClientToken Client = new ConnetedClientToken();
                Client = Redis.GetData("Users:" + Context.ConnectionId);
                if (Client != null)
                {
                    Redis.DeleteTag("Users:" + Context.ConnectionId, Client.Token);
                }
                Redis.DeleteTag("Pairs:" + Pair, Context.ConnectionId);
                Redis.DeleteTag("Markets:" + BaseCurrency, Context.ConnectionId);
                Redis.DeleteHash("Users:" + Context.ConnectionId);
                Redis.RemoveSetMember("Pairs:" + Pair, Context.ConnectionId);
                Redis.RemoveSetMember("Markets:" + BaseCurrency, Context.ConnectionId);
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "BuyerBook:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "SellerBook:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "TradingHistory:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "MarketData:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "ChartData:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "Price:" + Pair).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "BroadCast").Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "GroupMessage").Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "PairData:" + BaseCurrency).Wait();
                Groups.RemoveFromGroupAsync(Context.ConnectionId, "MarketTicker:" + BaseCurrency).Wait();
                return(base.OnDisconnectedAsync(exception));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "An unexpected exception occured,\nMethodName:" + System.Reflection.MethodBase.GetCurrentMethod().Name + "\nClassname=" + this.GetType().Name, LogLevel.Error);
                return(Task.FromResult(0));
            }
        }
示例#14
0
        public async Task <IActionResult> Exchange(OpenIdConnectRequest request, string appkey)
        {
            Debug.Assert(request.IsTokenRequest(),
                         "The OpenIddict binder for ASP.NET Core MVC is not registered. " +
                         "Make sure services.AddOpenIddict().AddMvcBinders() is correctly called.");

            ApplicationUser user;  /// Create Application user Instance For set the user using Redis session Or using Database
            string          RedisDBKey = string.Empty;

            if (!string.IsNullOrEmpty(appkey) && !string.IsNullOrEmpty(request.Password)) /// added by nirav savariya for login with email and mobile on 16-10-2018
            {
                // Get User Name on Mobile number or Email ID
                var GetuserName = await _userService.FindUserDataByUserNameEmailMobile(request.Username);

                if (GetuserName == null)
                {
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.TokenCreationUserDataNotAvailable, ErrorCode = enErrorCode.Status4103UserDataNotAvailable
                    }));
                }

                // User Data Get
                var userdata = await _userManager.FindByNameAsync(GetuserName.UserName);

                var model = await _customPassword.IsValidPassword(appkey, request.Password);

                if (model != null)
                {
                    try
                    {
                        request.Username = userdata.UserName;
                        request.Password = model.Password;
                        var newPassword = _userManager.PasswordHasher.HashPassword(userdata, model.Password);
                        userdata.PasswordHash = newPassword;
                        // Update New Key Password
                        var res = await _userManager.UpdateAsync(userdata);

                        // Update OTP Key Password
                        _customPassword.UpdateOtp(model.Id);
                    }
                    catch (Exception ex)
                    {
                        string exs = ex.ToString();
                    }
                }
                else
                {
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidAppkey, ErrorCode = enErrorCode.Status4048Invalidappkey
                    }));
                    //return BadRequest("Invalid appkey.");
                }
            }

            if (string.IsNullOrEmpty(appkey) && request.IsPasswordGrantType())
            {
                string numeric = string.Empty;
                foreach (char str in request.Password)
                {
                    if (char.IsDigit(str))
                    {
                        if (numeric.Length < 6)
                        {
                            numeric += str.ToString();
                        }
                    }
                }
                if (numeric.Length == 6)
                {
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.Appkey, ErrorCode = enErrorCode.Status4049appkey
                    }));
                }
            }

            if (request.IsPasswordGrantType())
            {
                var Userdata = new RedisUserdata(); ///  If not find the RadisDbKey then we Set key
                var redis    = new RadisServices <RedisUserdata>(this._fact);

                user = await _userManager.FindByNameAsync(request.Username);

                if (user == null)
                {
                    //return BadRequest("The username/password couple is invalid.");
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidUser, ErrorCode = enErrorCode.Status4050InvalidUser
                    }));
                }
                else
                {
                    Userdata.RedisDBKey      = Guid.NewGuid().ToString();
                    Userdata.RedisSessionKey = Guid.NewGuid().ToString();
                    RedisDBKey = Userdata.RedisDBKey;
                    redis.Save(Userdata.RedisDBKey, Userdata);
                    _redisSessionStora.SetObject(Userdata.RedisSessionKey, user, RedisDBKey);
                }

                // Validate the username/password parameters and ensure the account is not locked out.
                var result = await _signInManager.CheckPasswordSignInAsync(user, request.Password, lockoutOnFailure : true);

                if (result.Succeeded)
                {
                    // Create a new authentication ticket.
                    var ticket = await CreateTicketAsync(request, user, null, RedisDBKey);

                    if (!string.IsNullOrEmpty(appkey))
                    {
                        var setpwd = _userManager.PasswordHasher.HashPassword(user, DateTime.UtcNow.ToString());
                        user.PasswordHash = setpwd;
                        var res = await _userManager.UpdateAsync(user);
                    }
                    //return Ok(new Customtokenresponse { ReturnCode = enResponseCode.Success, ReturnMsg = "Success", SignIntoken = SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme)});

                    return(SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme));
                }
                else if (result.IsLockedOut)
                {
                    return(BadRequest(new StandardLoginResponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.StandardLoginLockOut, ErrorCode = enErrorCode.Status423Locked
                    }));
                }
                else
                {
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.InvalidUser, ErrorCode = enErrorCode.Status4050InvalidUser
                    }));
                    //return BadRequest("The username/password couple is invalid.");
                }
            }

            else if (request.IsRefreshTokenGrantType())
            {
                // Retrieve the claims principal stored in the refresh token.
                var info = await HttpContext.AuthenticateAsync(OpenIdConnectServerDefaults.AuthenticationScheme);

                // Retrieve the user profile corresponding to the refresh token.
                // Note: if you want to automatically invalidate the refresh token
                // when the user password/roles change, use the following line instead:
                // var user = _signInManager.ValidateSecurityStampAsync(info.Principal);
                user = await _userManager.GetUserAsync(info.Principal);

                if (user == null)
                {
                    //return BadRequest(new OpenIdConnectResponse
                    //{
                    //    Error = OpenIdConnectConstants.Errors.InvalidGrant,
                    //    ErrorDescription = "The refresh token is no longer valid."
                    //});
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.RefreshToken, ErrorCode = enErrorCode.Status4051RefreshToken
                    }));
                }

                // Ensure the user is still allowed to sign in.
                if (!await _signInManager.CanSignInAsync(user))
                {
                    //return BadRequest(new OpenIdConnectResponse
                    //{
                    //    Error = OpenIdConnectConstants.Errors.InvalidGrant,
                    //    ErrorDescription = "The user is no longer allowed to sign in."
                    //});
                    return(BadRequest(new Customtokenresponse {
                        ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.UserToken, ErrorCode = enErrorCode.Status4052UserToken
                    }));
                }

                // Create a new authentication ticket, but reuse the properties stored
                // in the refresh token, including the scopes originally granted.
                var ticket = await CreateTicketAsync(request, user, info.Properties);

                //return Ok(new Customtokenresponse { ReturnCode = enResponseCode.Success, ReturnMsg = EnResponseMessage.LoginUserEmailOTP, SignIntoken = SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme)});

                return(SignIn(ticket.Principal, ticket.Properties, ticket.AuthenticationScheme));
            }

            //return BadRequest(new OpenIdConnectResponse
            //{
            //    Error = OpenIdConnectConstants.Errors.UnsupportedGrantType,
            //    ErrorDescription = "The specified grant type is not supported."
            //});
            return(BadRequest(new Customtokenresponse {
                ReturnCode = enResponseCode.Fail, ReturnMsg = EnResponseMessage.Granttype, ErrorCode = enErrorCode.Status4053Granttype
            }));
        }
        public async Task Invoke(HttpContext context)
        {
            Stream originalBody           = context.Response.Body;
            SignalRUserConfiguration User = new SignalRUserConfiguration();

            try
            {
                using (var memStream = new MemoryStream())
                {
                    var newBody    = new MemoryStream();
                    var newContent = string.Empty;

                    context.Response.Body = memStream;

                    await next(context);

                    var responseLog = $"RESPONSE Host:{context.Request.Host}, HttpMethod: {context.Request.Method}, Path: {context.Request.Path}";

                    //string ResponsePath = context.Request.Path.ToString();
                    //string[] ResonseDetails = ResponsePath.Split("/");
                    if (context.Request.Path == "/connect/token")
                    {
                        memStream.Seek(0, SeekOrigin.Begin);
                        var content = new StreamReader(memStream).ReadToEnd();
                        memStream.Seek(0, SeekOrigin.Begin);
                        tokanreponsmodel TokenData = JsonConvert.DeserializeObject <tokanreponsmodel>(content);
                        if (TokenData != null && !string.IsNullOrEmpty(TokenData.access_token))
                        {
                            using (var bodyReader = new StreamReader(context.Request.Body))
                            {
                                var bodyAsText = bodyReader.ReadToEnd();
                                if (string.IsNullOrWhiteSpace(bodyAsText) == false)
                                {
                                    User = convertStirngToJson(HttpUtility.UrlDecode(bodyAsText));
                                    // User.username = "******";
                                }
                                if (User != null && !string.IsNullOrEmpty(User.username))
                                {
                                    var Redis    = new RadisServices <ConnetedClientToken>(this._fact);
                                    var Userdata = _userManager.FindByNameAsync(User.username).GetAwaiter().GetResult();
                                    if (Userdata != null && Userdata.Id != 0)
                                    {
                                        Redis.SaveWithOrigionalKey("Tokens:" + Userdata.Id, new ConnetedClientToken {
                                            Token = TokenData.access_token
                                        });
                                        //string AccessToken = Redis.GetHashData("Tokens:" + Userdata.Id, "Token");
                                    }
                                }
                            }
                        }
                    }

                    memStream.Position = 0;
                    string responseBody = new StreamReader(memStream).ReadToEnd();
                    var    erParams     = (dynamic)null;
                    if (responseBody.Contains("ReturnCode"))
                    {
                        erParams = JsonConvert.DeserializeObject <ErrorParams>(responseBody);
                    }

                    responseLog += $", Response : {responseBody}";
                    //if (ResponseDetails?[1] == "api")
                    //{
                    //Uday 05-11-2018 don't write log for graph method
                    if (context.Request.Path.Value.Split("/")[1] != "swagger" && !context.Request.Path.Value.Contains("GetGraphDetail"))
                    {
                        if (erParams?.ReturnCode != 9)
                        {
                            HelperForLog.WriteLogIntoFile(2, _basePage.UTC_To_IST(), context.Request.Path.ToString(), context.Request.Path.ToString(), responseLog);
                            //HelperForLog.WriteLogIntoFile(2, _basePage.UTC_To_IST(), context.Request.Path.ToString(), context.Request.Path.ToString(), responseLog);
                            //HelperForLog.WriteErrorLog(_basePage.UTC_To_IST(), context.Request.Path.ToString(), context.Request.Path.ToString(), erParams.ReturnMsg);
                        }
                    }
                    //else
                    //{
                    //    HelperForLog.WriteLogIntoFile(2, _basePage.UTC_To_IST(), context.Request.Path.ToString(), context.Request.Path.ToString(), responseLog);

                    //}

                    //}
                    //else if (ResponseDetails?[1] != "swagger")
                    //    HelperForLog.WriteLogIntoFile(2, _basePage.UTC_To_IST(), "", "", responseLog);
                    memStream.Position = 0;
                    await memStream.CopyToAsync(originalBody);
                }
            }
            catch (Exception ex)
            {
                HelperForLog.WriteErrorLog(_basePage.UTC_To_IST(), "", "", ex.ToString());
            }
            finally
            {
                context.Response.Body = originalBody;
            }
        }