public List<CMSResearch> GetWeeklyInsightsDocuments(UserSettings userSettings)
        {
            var cacheKey = string.Format("WeeklyInsights-{0}-{1}", _token, userSettings.Language);

            var weeklyInsightsDocuments = TryGetDocumentsFromCache(cacheKey,
                                                                   _configurationService.GetGeneralSettings().ResearchReportsStillFreshInterval);
            if (weeklyInsightsDocuments == null)
            {
                var weeklyInsightsOffset = _configurationService.GetSetting(3, "WeeklyInsightsDateOffset", "Dictionaries", "AppSettings", "General", "ResearchReports");
                var latestResearchModel = new LatestResearchModel
                {
                    Count = int.MaxValue,
                    StartDate = DateTime.Now.AddMonths(-weeklyInsightsOffset).ToString("d", new CultureInfo("en-US")),
                    EndDate = DateTime.Now.ToString("d", new CultureInfo("en-US")),
                    Category = ResearchCategory.TheWeekAhead,
                };

                weeklyInsightsDocuments = GetCMSResearchDocuments(latestResearchModel, userSettings, ResearchType.WEEK_AHEAD).OrderByDescending(e => e.LastUpdatedDate).ToList();

                PutDocumentsInCache(cacheKey,
                    _configurationService.GetGeneralSettings().ResearchReportsSlidingExpiration,
                    weeklyInsightsDocuments);
            }


            return weeklyInsightsDocuments;
        }
        private List<CMSResearch> GetCMSResearchDocuments(LatestResearchModel latestResearchModel, UserSettings userSettings, ResearchType researchType = ResearchType.MARKET_UPDATE)
        {
            var researchLookup = new ResearchLookup();
            researchLookup.ReserchType = researchType;
            researchLookup.Category = latestResearchModel.Category;

            if (!string.IsNullOrEmpty(latestResearchModel.Tags))
            {
                var tags = latestResearchModel.Tags.Split(',');
                researchLookup.Tags = tags.Length > 0 ? tags : new[] { latestResearchModel.Tags };
            }

            researchLookup.RecordCount = latestResearchModel.Count.HasValue ? latestResearchModel.Count.Value : 20;
            researchLookup.Language = GetLanguage(userSettings.Language);

            researchLookup.StartDate = latestResearchModel.StartDate;
            researchLookup.EndDate = latestResearchModel.EndDate;

            var researchServiceAddress = WebservicesConfig.Webservices["Research"].Settings["URL"].Value;

            var researchServiceSoapClient = researchServiceAddress.Contains("https://")
                                                ? new ResearchServiceSoapClient("ResearchServiceSoapHttps", researchServiceAddress)
                                                : new ResearchServiceSoapClient("ResearchServiceSoap", researchServiceAddress);

            var latestResearchBlotter = researchServiceSoapClient.GetLatestResearch(null, _token, researchLookup);

            if (latestResearchBlotter != null)
            {
                return latestResearchBlotter.Output.OrderByDescending(e => e.LastUpdatedDate).ToList();
            }
            return new List<CMSResearch>();
        }
        public List<CMSResearch> GetTechnicalUpdateDocuments(UserSettings userSettings)
        {
            var cacheKey = string.Format("TechnicalUpdate-{0}-{1}", _token, userSettings.Language);

            var technicalUpdateDocuments = TryGetDocumentsFromCache(cacheKey,
                                                                    _configurationService.GetGeneralSettings().ResearchReportsStillFreshInterval);

            if (technicalUpdateDocuments == null)
            {
                var technicalUpdateDateOffset = _configurationService.GetSetting(2,
                                                "TechnicalUpdateDateOffset",
                                                "Dictionaries",
                                                "AppSettings",
                                                "General",
                                                "ResearchReports");
                var latestResearchModel = new LatestResearchModel
                {
                    Category = ResearchCategory.TechnicalUpdate,
                    Count = int.MaxValue,
                    StartDate = DateTime.Now.AddMonths(-technicalUpdateDateOffset).ToString("d", new CultureInfo("en-US")),
                    EndDate = DateTime.Now.ToString("d", new CultureInfo("en-US"))
                };

                technicalUpdateDocuments = GetCMSResearchDocuments(latestResearchModel, userSettings);
                latestResearchModel.Category = ResearchCategory.FXTechLab;
                var fxTechLabDocuments = GetCMSResearchDocuments(latestResearchModel, userSettings);
                technicalUpdateDocuments.AddRange(fxTechLabDocuments);
                technicalUpdateDocuments = technicalUpdateDocuments.OrderByDescending(e => e.LastUpdatedDate).ToList();

                PutDocumentsInCache(cacheKey,
                                    _configurationService.GetGeneralSettings().ResearchReportsSlidingExpiration,
                                    technicalUpdateDocuments);
            }
            return technicalUpdateDocuments;
        }
        public List<CMSResearch> GetForexInsiderDocuments(UserSettings userSettings)
        {
            var cacheKey = string.Format("ForexInsider-{0}-{1}", _token, userSettings.Language);

            var forexInsiderDocuments = TryGetDocumentsFromCache(cacheKey,
                                                                 _configurationService.GetGeneralSettings().ResearchReportsStillFreshInterval);
            if (forexInsiderDocuments == null)
            {
                forexInsiderDocuments = new List<CMSResearch>();

                var forexInsiderDateOffset = _configurationService.GetSetting(2,
                                "ForexInsiderDateOffset",
                                "Dictionaries",
                                "AppSettings",
                                "General",
                                "ResearchReports");
                var latestResearchModel = new LatestResearchModel
                {
                    Count = int.MaxValue,
                    StartDate = DateTime.Now.AddMonths(-forexInsiderDateOffset).ToString("d", new CultureInfo("en-US")),
                    EndDate = DateTime.Now.ToString("d", new CultureInfo("en-US"))
                };

                var categories = new[]
				{
                    ResearchCategory.AnalystPick, ResearchCategory.CorrelationCorner, ResearchCategory.FundamentalUpdate, ResearchCategory.IndicesInsider,
                    ResearchCategory.MarketUpdate, ResearchCategory.MorningUpdate, ResearchCategory.OilUpdate, ResearchCategory.WeeklyStrategy, 
                    ResearchCategory.FXTechLab, ResearchCategory.TechnicalUpdate
				};

                foreach (var category in categories)
                {
                    latestResearchModel.Category = category;
                    forexInsiderDocuments.AddRange(GetCMSResearchDocuments(latestResearchModel, userSettings));
                }

                forexInsiderDocuments = forexInsiderDocuments.OrderByDescending(e => e.LastUpdatedDate).ToList();

                PutDocumentsInCache(cacheKey,
                                    _configurationService.GetGeneralSettings().ResearchReportsSlidingExpiration,
                                    forexInsiderDocuments);
            }
            return forexInsiderDocuments;
        }
        public List<CMSResearch> GetResearchReportsDocuments(UserSettings userSettings)
        {
            var cacheKey = string.Format("ResearchReports-{0}-{1}", _token, userSettings.Language);

            var researchReportsDocuments = TryGetDocumentsFromCache(cacheKey,
                                                                    _configurationService.GetGeneralSettings().ResearchReportsStillFreshInterval);
            if (researchReportsDocuments == null)
            {
                var researchReportshDateOffset = _configurationService.GetSetting(18,
                                                                "ResearchReportshDateOffset",
                                                                "Dictionaries",
                                                                "AppSettings",
                                                                "General",
                                                                "ResearchReports");
                var latestResearchModel = new LatestResearchModel
                {
                    Category = ResearchCategory.ResearchNote,
                    Count = int.MaxValue,
                    StartDate = DateTime.Now.AddMonths(-researchReportshDateOffset).ToString("d", new CultureInfo("en-US")), // -1.5 year
                    EndDate = DateTime.Now.ToString("d", new CultureInfo("en-US"))
                };
                researchReportsDocuments = GetCMSResearchDocuments(latestResearchModel, userSettings);
                PutDocumentsInCache(cacheKey,
                                    _configurationService.GetGeneralSettings().ResearchReportsSlidingExpiration,
                                    researchReportsDocuments);
            }
            return researchReportsDocuments;
        }