public HttpResponseMessage Edit(string id) { try { OpenContentSettings settings = ActiveModule.OpenContentSettings(); ModuleInfo module = ActiveModule; if (settings.ModuleId > 0) { ModuleController mc = new ModuleController(); module = mc.GetModule(settings.ModuleId, settings.TabId, false); } var manifest = settings.Manifest; TemplateManifest templateManifest = settings.Template; string editRole = manifest.GetEditRole(); bool listMode = templateManifest != null && templateManifest.IsListTemplate; var ds = DataSourceManager.GetDataSource(manifest.DataSource); var dsContext = new DataSourceContext() { ModuleId = module.ModuleID, ActiveModuleId = ActiveModule.ModuleID, TemplateFolder = settings.TemplateDir.FolderPath, Config = manifest.DataSourceConfig }; IDataItem dsItem = null; if (listMode) { if (!string.IsNullOrEmpty(id)) // not a new item { dsItem = ds.Get(dsContext, id); } } else { dsContext.Single = true; dsItem = ds.Get(dsContext, null); } int createdByUserid = -1; var json = ds.GetAlpaca(dsContext, true, true, true); //var content = GetContent(module.ModuleID, listMode, int.Parse(id)); //if (content != null) if (dsItem != null) { //json["data"] = content.Json.ToJObject("GetContent " + id); //json = dsItem.Data as JObject; json["data"] = dsItem.Data; if (json["schema"]["properties"]["ModuleTitle"] is JObject) { //json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle; if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.String) { json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle; } else if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.Object) { json["data"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] = ActiveModule.ModuleTitle; } } var versions = ds.GetVersions(dsContext, dsItem); if (versions != null) { json["versions"] = versions; } //AddVersions(json, content); //createdByUserid = content.CreatedByUserId; createdByUserid = dsItem.CreatedByUserId; } if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid)) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } return(Request.CreateResponse(HttpStatusCode.OK, json)); } catch (Exception exc) { Log.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
// for openform compatibility public static string GetCurrentCultureCode() { return(DnnLanguageUtils.GetCurrentCultureCode()); }
public HttpResponseMessage Update(JObject json) { try { bool index = false; OpenContentSettings settings = ActiveModule.OpenContentSettings(); ModuleInfo module = ActiveModule; if (settings.ModuleId > 0) { ModuleController mc = new ModuleController(); module = mc.GetModule(settings.ModuleId, settings.TabId, false); } var manifest = settings.Template.Manifest; TemplateManifest templateManifest = settings.Template; index = settings.Template.Manifest.Index; string editRole = manifest.GetEditRole(); bool listMode = templateManifest != null && templateManifest.IsListTemplate; int createdByUserid = -1; var ds = DataSourceManager.GetDataSource(manifest.DataSource); var dsContext = new DataSourceContext() { ModuleId = module.ModuleID, ActiveModuleId = ActiveModule.ModuleID, TemplateFolder = settings.TemplateDir.FolderPath, Index = index, UserId = UserInfo.UserID, PortalId = module.PortalID, Config = manifest.DataSourceConfig }; IDataItem dsItem = null; if (listMode) { if (json["id"] != null) { var itemId = json["id"].ToString(); dsItem = ds.Get(dsContext, itemId); //content = ctrl.GetContent(itemId); if (dsItem != null) { createdByUserid = dsItem.CreatedByUserId; } } } else { dsContext.Single = true; dsItem = ds.Get(dsContext, null); //dsItem = ctrl.GetFirstContent(module.ModuleID); if (dsItem != null) { createdByUserid = dsItem.CreatedByUserId; } } if (!OpenContentUtils.HasEditPermissions(PortalSettings, ActiveModule, editRole, createdByUserid)) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } //var indexConfig = OpenContentUtils.GetIndexConfig(settings.Template.Key.TemplateDir); if (dsItem == null) { ds.Add(dsContext, json["form"] as JObject); } else { ds.Update(dsContext, dsItem, json["form"] as JObject); } if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String) { string moduleTitle = json["form"]["ModuleTitle"].ToString(); OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle); } else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object) { if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null) { string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString(); OpenContentUtils.UpdateModuleTitle(ActiveModule, moduleTitle); } } return(Request.CreateResponse(HttpStatusCode.OK, "")); } catch (Exception exc) { Log.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage ReOrder(List <string> ids) { try { var module = OpenContentModuleConfig.Create(ActiveModule, PortalSettings); IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID); var alpaca = ds.GetAlpaca(dsContext, false, true, false); var opt = alpaca["options"]?["fields"]?["SortIndex"]?["type"]?.ToString(); var ml = opt == "mlnumber"; if (!module.IsListMode()) { return(Request.CreateResponse(HttpStatusCode.OK, new { isValid = true })); } if (ids == null) { return(Request.CreateResponse(HttpStatusCode.OK, new { isValid = true })); } int i = 1; string errorOccured = ""; foreach (var id in ids) { if (id == "-1") { continue; // ignore items explicitly marked with id -1; } var dsItem = ds.Get(dsContext, id); if (dsItem == null) { Utils.DebuggerBreak(); // item not found. investigate! errorOccured = $"Reorder failed. Unknown item {id}. Reindex module and try again."; App.Services.Logger.Error(errorOccured); continue; } var json = dsItem.Data; if (ml) // multi language { #region Normalize irregulatities with SortIndex field // if old data-format (single-language) detected. Migrate to ML version. if (json["SortIndex"] == null || json["SortIndex"].Type != JTokenType.Object) { json["SortIndex"] = new JObject(); } // if not all site languages initialized, then give them a default value. var langList = DnnLanguageUtils.GetPortalLocales(this.PortalSettings.PortalId); if (json["SortIndex"].Count() != langList.Count) { foreach (var locale in langList) { json["SortIndex"][locale.Key] = i; } } #endregion // Set the new SortIndex value for this item. json["SortIndex"][DnnLanguageUtils.GetCurrentCultureCode()] = i; } else { json["SortIndex"] = i; } ds.Update(dsContext, dsItem, json); i++; } return(Request.CreateResponse(HttpStatusCode.OK, new { isValid = string.IsNullOrEmpty(errorOccured), errorMsg = errorOccured })); } catch (Exception exc) { App.Services.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { Log.Logger.Trace($"Indexing content Module {modInfo.ModuleID} - Tab {modInfo.TabID} - Culture {modInfo.CultureCode}- indexing from {beginDateUtc}"); var searchDocuments = new List <SearchDocument>(); //If module is marked as "don't index" then return no results if (modInfo.ModuleSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - MODULE Indexing disabled"); return(searchDocuments); } //If tab of the module is marked as "don't index" then return no results if (modInfo.ParentTab.TabSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - TAB Indexing disabled"); return(searchDocuments); } //If tab is marked as "inactive" then return no results if (modInfo.ParentTab.DisableLink) { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - TAB is inactive"); return(searchDocuments); } var module = new OpenContentModuleInfo(modInfo); OpenContentSettings settings = modInfo.OpenContentSettings(); if (settings.Template?.Main == null || !settings.Template.Main.DnnSearch) { return(searchDocuments); } if (settings.IsOtherModule) { return(searchDocuments); } IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); IDataItems contentList = ds.GetAll(dsContext, null); if (!contentList.Items.Any()) { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - No content found"); } foreach (IDataItem content in contentList.Items) { if (content == null) { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - Content is Null"); } else if (content.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && content.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow) { SearchDocument searchDoc; if (DnnLanguageUtils.IsMultiLingualPortal(modInfo.PortalID)) { // first process the default language module var culture = modInfo.CultureCode; var localizedData = GetLocalizedContent(content.Data, culture); searchDoc = CreateSearchDocument(modInfo, settings, localizedData, content.Id, culture, content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{culture} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); // now do the same with any linked localized instances of this module if (modInfo.LocalizedModules != null) { foreach (var localizedModule in modInfo.LocalizedModules) { culture = localizedModule.Value.CultureCode; localizedData = GetLocalizedContent(content.Data, culture); searchDoc = CreateSearchDocument(modInfo, settings, localizedData, content.Id, culture, content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{culture} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); } } } else { searchDoc = CreateSearchDocument(modInfo, settings, content.Data, content.Id, "", content.Title, content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - OK! {searchDoc.Title} ({modInfo.TabID}) of {content.LastModifiedOnDate.ToUniversalTime()}"); } } else { Log.Logger.Trace($"Indexing content {modInfo.ModuleID}|{modInfo.CultureCode} - NOT - No need to index: lastmod {content.LastModifiedOnDate.ToUniversalTime()} "); } } return(searchDocuments); }
public HttpResponseMessage Update(JObject json) { try { var module = OpenContentModuleConfig.Create(ActiveModule, PortalSettings); string editRole = module.Settings.Template.Manifest.GetEditRole(); int createdByUserid = -1; IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID); IDataItem dsItem = null; if (module.IsListMode()) { if (json["id"] != null) { var itemId = json["id"].ToString(); dsItem = ds.Get(dsContext, itemId); if (dsItem != null) { createdByUserid = dsItem.CreatedByUserId; } } } else { dsContext.Single = true; dsItem = ds.Get(dsContext, null); if (dsItem != null) { createdByUserid = dsItem.CreatedByUserId; } } //todo: can't we do some of these checks at the beginning of this method to fail faster? if (!DnnPermissionsUtils.HasEditPermissions(module, editRole, createdByUserid)) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } AddNotifyInfo(dsContext); try { if (dsItem == null) { ds.Add(dsContext, json["form"] as JObject); } else { ds.Update(dsContext, dsItem, json["form"] as JObject); } App.Services.CacheAdapter.SyncronizeCache(module); } catch (DataNotValidException ex) { return(Request.CreateResponse(HttpStatusCode.OK, new { isValid = false, validMessage = ex.Message })); } if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.String) { string moduleTitle = json["form"]["ModuleTitle"].ToString(); ActiveModule.UpdateModuleTitle(moduleTitle); } else if (json["form"]["ModuleTitle"] != null && json["form"]["ModuleTitle"].Type == JTokenType.Object) { if (json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] != null) { string moduleTitle = json["form"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()].ToString(); ActiveModule.UpdateModuleTitle(moduleTitle); } } return(Request.CreateResponse(HttpStatusCode.OK, new { isValid = true })); } catch (Exception exc) { App.Services.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage Edit(string id) { try { var module = OpenContentModuleConfig.Create(ActiveModule, PortalSettings); IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); IDataItem dsItem = null; if (module.IsListMode()) { if (!string.IsNullOrEmpty(id)) // not a new item { dsItem = ds.Get(dsContext, id); } } else { dsContext.Single = true; dsItem = ds.Get(dsContext, null); } int createdByUserid = -1; var json = ds.GetAlpaca(dsContext, true, true, true); if (ds is IDataActions) { var actions = ((IDataActions)ds).GetActions(dsContext, dsItem); if (json["options"] == null) { json["options"] = new JObject(); } if (json["options"]["form"] == null) { json["options"]["form"] = new JObject(); } if (json["options"]["form"]["buttons"] == null) { json["options"]["form"]["buttons"] = new JObject(); } var buttons = json["options"]["form"]["buttons"] as JObject; var newButtons = new JObject(); foreach (var act in actions) { var but = buttons[act.Name]; if (but == null) { but = new JObject(); } but["after"] = act.AfterExecute; newButtons[act.Name] = but; } json["options"]["form"]["buttons"] = newButtons; } string itemKey; if (dsItem == null) { itemKey = ObjectId.NewObjectId().ToString(); } else { itemKey = dsItem.Key; json["data"] = dsItem.Data; if (json["schema"]["properties"]["ModuleTitle"] is JObject) { if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.String) { json["data"]["ModuleTitle"] = ActiveModule.ModuleTitle; } else if (json["data"]["ModuleTitle"] != null && json["data"]["ModuleTitle"].Type == JTokenType.Object) { json["data"]["ModuleTitle"][DnnLanguageUtils.GetCurrentCultureCode()] = ActiveModule.ModuleTitle; } } var versions = ds.GetVersions(dsContext, dsItem); if (versions != null) { json["versions"] = versions; } createdByUserid = dsItem.CreatedByUserId; } var context = new JObject(); var currentLocale = DnnLanguageUtils.GetCurrentLocale(PortalSettings.PortalId); context["culture"] = currentLocale.Code; //todo why not use DnnLanguageUtils.GetCurrentCultureCode() ??? context["defaultCulture"] = LocaleController.Instance.GetDefaultLocale(PortalSettings.PortalId).Code; context["numberDecimalSeparator"] = currentLocale.Culture.NumberFormat.NumberDecimalSeparator; context["rootUrl"] = System.Web.VirtualPathUtility.ToAbsolute(string.Concat(System.Web.HttpRuntime.AppDomainAppVirtualPath, "/")); context["alpacaCulture"] = AlpacaEngine.AlpacaCulture(currentLocale.Code); context["bootstrap"] = App.Services.CreateGlobalSettingsRepository(PortalSettings.PortalId).GetEditLayout() != AlpacaLayoutEnum.DNN; context["horizontal"] = App.Services.CreateGlobalSettingsRepository(PortalSettings.PortalId).GetEditLayout() == AlpacaLayoutEnum.BootstrapHorizontal; context["itemKey"] = itemKey; json["context"] = context; //todo: can't we do some of these checks at the beginning of this method to fail faster? if (!DnnPermissionsUtils.HasEditPermissions(module, module.Settings.Manifest.GetEditRole(), createdByUserid)) { return(Request.CreateResponse(HttpStatusCode.Unauthorized)); } return(Request.CreateResponse(HttpStatusCode.OK, json)); } catch (Exception exc) { App.Services.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public HttpResponseMessage Lookup(LookupRequestDTO req) { int moduleid = req.moduleid > 0 ? req.moduleid : ActiveModule.ModuleID; int tabid = req.tabid > 0 ? req.tabid : ActiveModule.TabID; var module = OpenContentModuleConfig.Create(moduleid, tabid, PortalSettings); if (module == null) { throw new Exception($"Can not find ModuleInfo (tabid:{req.tabid}, moduleid:{req.moduleid})"); } List <LookupResultDTO> res = new List <LookupResultDTO>(); try { IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module, UserInfo.UserID); if (module.IsListMode()) { var items = ds.GetAll(dsContext, null).Items; if (items != null) { foreach (var item in items) { var json = item.Data; if (!string.IsNullOrEmpty(req.dataMember) && json[req.dataMember] != null) { json = json[req.dataMember]; } json = json.DeepClone(); JsonUtils.SimplifyJson(json, DnnLanguageUtils.GetCurrentCultureCode()); var array = json as JArray; if (array != null) { res.AddRange(array.Select(childItem => new LookupResultDTO { value = string.IsNullOrEmpty(req.valueField) || childItem[req.valueField] == null ? "" : childItem[req.valueField].ToString(), text = string.IsNullOrEmpty(req.textField) || childItem[req.textField] == null ? "" : childItem[req.textField].ToString() } ) ); } else { res.Add(new LookupResultDTO { value = string.IsNullOrEmpty(req.valueField) || json[req.valueField] == null ? item.Id : json[req.valueField].ToString(), text = string.IsNullOrEmpty(req.textField) || json[req.textField] == null ? item.Title : json[req.textField].ToString() }); } } } } else { dsContext.Single = true; var struc = ds.Get(dsContext, null); if (struc != null) { JToken json = struc.Data; if (!string.IsNullOrEmpty(req.dataMember)) { json = json[req.dataMember]; json = json.DeepClone(); JsonUtils.SimplifyJson(json, DnnLanguageUtils.GetCurrentCultureCode()); if (json is JArray) { foreach (JToken item in (JArray)json) { res.Add(new LookupResultDTO() { value = item[req.valueField] == null ? "" : item[req.valueField].ToString(), text = item[req.textField] == null ? "" : item[req.textField].ToString() }); } } } } } return(Request.CreateResponse(HttpStatusCode.OK, res)); } catch (Exception exc) { App.Services.Logger.Error(exc); return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc)); } }
public List <PageDto> GetDetailPages(string template, int tabModuleId) { string format; int othermoduleTabId = ActiveModule.TabID; int moduleId = ActiveModule.ModuleID; var listItems = new List <PageDto>(); var templateUri = new FileUri(template); var manifest = templateUri.ToTemplateManifest(); int othermoduleDetailTabId = -1; if (manifest != null && manifest.IsListTemplate && manifest.Manifest.Templates.Any(t => t.Value.Detail != null)) { if (tabModuleId > 0) { var dsModule = (new ModuleController()).GetTabModule(tabModuleId); othermoduleTabId = dsModule.TabID; moduleId = dsModule.ModuleID; othermoduleDetailTabId = GetOtherModuleDetailTabId(othermoduleTabId, moduleId); //if (othermoduleDetailTabId > 0) //{ // //add extra li with "Default Detail Page" directly to dropdown // format = LogContext.IsLogActive ? "Main Module Detail Page - [{0}]" : "Main Module Detail Page"; // listItems.Add(new PageDto() // { // Text = string.Format(format, othermoduleDetailTabId), // TabId = othermoduleDetailTabId // }); //} } Dictionary <string, int> tabs = TabController.GetTabPathDictionary(ActiveModule.PortalID, DnnLanguageUtils.GetCurrentCultureCode()); foreach (var tabId in tabs.Where(i => IsTabWithModuleWithSameMainModule(i.Value, moduleId) && IsAccessibleTab(i.Value))) { string tabname = tabId.Key.Replace("//", " / ").TrimStart(" / "); List <string> infoText = new List <string>(); if (othermoduleDetailTabId > 0 && tabId.Value == othermoduleDetailTabId) { infoText.Add("Main Module Detail"); } if ((othermoduleTabId > 0 && tabId.Value == othermoduleTabId) || (othermoduleTabId == -1 && tabId.Value == ActiveModule.TabID)) { //add extra li with "Main Module Page" directly to dropdown //format = LogContext.IsLogActive ? "Main Module Page - {0} [{1}]" : "Main Module Page"; //listItems.Add(new PageDto() //{ // Text = string.Format(format, tabname, tabId.Value), // TabId = -1 //}); infoText.Add("Main Module "); } if (othermoduleTabId > 0 && tabId.Value == ActiveModule.TabID) { //add extra li with "CurrentPage" directly to dropdown //format = LogContext.IsLogActive ? "Current Page - {0} [{1}]" : "Current Page"; //listItems.Add(new PageDto() //{ // Text = string.Format(format, tabname, tabId.Value), // TabId = tabId.Value //}); infoText.Add("Current"); } format = LogContext.IsLogActive ? "{0} [{1}]" : "{0}"; if (othermoduleTabId > 0 && tabId.Value == ActiveModule.TabID) { listItems.Add(new PageDto() { Text = string.Format(format, tabname, tabId.Value) + " (Current)", TabId = tabId.Value }); } else { listItems.Add(new PageDto() { Text = string.Format(format, tabname, tabId.Value) + (infoText.Any() ? " (" + string.Join(",", infoText.ToArray()) + ")" : ""), TabId = tabId.Value }); } } return(listItems.OrderBy(x => x.Text).ToList()); } return(listItems); }
public override IList <SearchDocument> GetModifiedSearchDocuments(ModuleInfo modInfo, DateTime beginDateUtc) { Log.Logger.TraceFormat("Indexing content Module {0} - Tab {1} - indexing from {3}", modInfo.ModuleID, modInfo.TabID, modInfo.CultureCode, beginDateUtc); var searchDocuments = new List <SearchDocument>(); //If module is marked as "don't index" then return no results if (modInfo.ModuleSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - MODULE Indexing disabled", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } //If tab of the module is marked as "don't index" then return no results if (modInfo.ParentTab.TabSettings.GetValue("AllowIndex", "True") == "False") { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - TAB Indexing disabled", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } //If tab is marked as "inactive" then return no results if (modInfo.ParentTab.DisableLink) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - TAB is inactive", modInfo.ModuleID, modInfo.CultureCode); return(searchDocuments); } var module = new OpenContentModuleInfo(modInfo); OpenContentSettings settings = modInfo.OpenContentSettings(); //if (settings.Template?.Main == null || !settings.Template.Main.DnnSearch) //{ // Log.Logger.TraceFormat("Indexing content Module {0} - Tab {1} - settings.Template?.Main == null || !settings.Template.Main.DnnSearch", modInfo.ModuleID, modInfo.TabID, modInfo.CultureCode); // return searchDocuments; //} if (settings.IsOtherModule) { return(searchDocuments); } IDataSource ds = DataSourceManager.GetDataSource(module.Settings.Manifest.DataSource); var dsContext = OpenContentUtils.CreateDataContext(module); IDataItems contentList = ds.GetAll(dsContext, null); if (!contentList.Items.Any()) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - No content found", modInfo.ModuleID, modInfo.CultureCode); } foreach (IDataItem content in contentList.Items) { if (content == null) { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - Content is Null", modInfo.ModuleID, modInfo.CultureCode); } else if (content.LastModifiedOnDate.ToUniversalTime() > beginDateUtc && content.LastModifiedOnDate.ToUniversalTime() < DateTime.UtcNow) { SearchDocument searchDoc; if (DnnLanguageUtils.IsMultiLingualPortal(modInfo.PortalID)) { searchDoc = GetLocalizedItem(modInfo, settings, content); searchDocuments.Add(searchDoc); if (modInfo.LocalizedModules != null) { foreach (var localizedModule in modInfo.LocalizedModules) { SearchDocument localizedSearchDoc = GetLocalizedItem(localizedModule.Value, settings, content); searchDocuments.Add(localizedSearchDoc); } } } else { searchDoc = CreateSearchDocument(modInfo, settings, content.Data, content.Id, "", content.Title, JsonToSearchableString(content.Data), content.LastModifiedOnDate.ToUniversalTime()); searchDocuments.Add(searchDoc); Log.Logger.TraceFormat("Indexing content {0}|{5} - OK! {1} ({2}) of {3}", modInfo.ModuleID, searchDoc.Title, modInfo.TabID, content.LastModifiedOnDate.ToUniversalTime(), modInfo.CultureCode); } } else { Log.Logger.TraceFormat("Indexing content {0}|{1} - NOT - No need to index: lastmod {2} ", modInfo.ModuleID, modInfo.CultureCode, content.LastModifiedOnDate.ToUniversalTime()); } } return(searchDocuments); }