/// <summary> /// Add By Nishant Sheth /// #2496 : Set the cache of currency exchange rate for users's preferd currency /// </summary> /// <param name="clientId"></param> /// <param name="userId"></param> public void SetUserCurrencyCache(int clientId, int userId) { try { BDSService.BDSServiceClient objBDSServiceClient = new BDSService.BDSServiceClient(); BDSService.Currency objUserCurrency = new BDSService.Currency(); DateTime now = DateTime.Now; DateTime CurrentMonthStartDate = GetFirstDayOfMonth(now.Month, now.Year); DateTime CurrentMonthEndDate = GetLastDayOfMonth(now.Month, now.Year); objUserCurrency = objBDSServiceClient.GetCurrencyExchangeRateEx(clientId, userId); // Call the BDS Sevice for get exchange rate if (objUserCurrency.UserCurrency != null) { var Currency = objUserCurrency.UserCurrency; // Get Planning Exchange rate // With Current Start Date and end date RevenuePlanner.Models.CurrencyModel.PlanCurrency UserPlanCurrency = Currency.CurrencyExchangeRate .Where(curr => curr.CurrencyCode == Currency.UserPreferredCurrencyCode && curr.Component == Enums.CurrencyComponent.Plan.ToString().ToLower() && (curr.StartDate >= CurrentMonthStartDate && curr.EndDate <= CurrentMonthEndDate)) .Select(curr => new RevenuePlanner.Models.CurrencyModel.PlanCurrency { CurrencyCode = curr.CurrencyCode, CurrencySymbol = curr.CurrencySymbol, ExchangeRate = curr.ExchangeRate }).FirstOrDefault(); if (UserPlanCurrency != null) { objCache.AddCache(Convert.ToString(Enums.CacheObject.UserPlanCurrency), UserPlanCurrency); Sessions.PlanExchangeRate = UserPlanCurrency.ExchangeRate; } else { Sessions.PlanExchangeRate = 1; } // Get Reporting Exchange rate List <RevenuePlanner.Models.CurrencyModel.ClientCurrency> UserReportCurrency = Currency.CurrencyExchangeRate .Where(curr => curr.CurrencyCode == Currency.UserPreferredCurrencyCode && curr.Component == Enums.CurrencyComponent.Report.ToString().ToLower()) .Select(curr => new RevenuePlanner.Models.CurrencyModel.ClientCurrency { ClientId = curr.CID, Component = curr.Component, CurrencyCode = curr.CurrencyCode, CurrencySymbol = curr.CurrencySymbol, EndDate = curr.EndDate, ExchangeRate = curr.ExchangeRate, StartDate = curr.StartDate }).ToList(); if (UserReportCurrency != null) { objCache.AddCache(Enums.CacheObject.ListUserReportCurrency.ToString(), UserReportCurrency); } Sessions.PlanCurrencySymbol = Currency.UserPreferredCurrencySymbol; } else { Sessions.PlanExchangeRate = 1; Sessions.PlanCurrencySymbol = Convert.ToString(Enums.CurrencySymbolsValues[Enums.CurrencySymbols.USD.ToString()]); } } catch (Exception ex) { Elmah.ErrorSignal.FromCurrentContext().Raise(ex); } }