// //==================================================================================================== /// <summary> /// Process manual changes needed for special cases /// </summary> /// <param name="isDelete"></param> /// <param name="contentName"></param> /// <param name="recordId"></param> /// <param name="recordName"></param> /// <param name="recordParentID"></param> /// <param name="useContentWatchLink"></param> public static void processAfterSave(CoreController core, bool isDelete, string contentName, int recordId, string recordName, int recordParentID, bool useContentWatchLink) { try { PageContentModel.markReviewed(core.cpParent, recordId); string tableName = MetadataController.getContentTablename(core, contentName); // // -- invalidate the specific cache for this record core.cache.invalidateDbRecord(recordId, tableName); // string tableNameLower = tableName.ToLower(CultureInfo.InvariantCulture); if (tableNameLower == AddonCollectionModel.tableMetadata.tableNameLower) { // // -- addon collection processAfterSave_AddonCollection(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink); } else if (tableNameLower == LinkForwardModel.tableMetadata.tableNameLower) { // // -- link forward core.routeMapCacheClear(); } else if (tableNameLower == LinkAliasModel.tableMetadata.tableNameLower) { // // -- link alias core.routeMapCacheClear(); } else if (tableNameLower == AddonModel.tableMetadata.tableNameLower) { // // -- addon core.routeMapCacheClear(); } else if (tableNameLower == PersonModel.tableMetadata.tableNameLower) { // // -- PersonModel var person = PersonModel.create <PersonModel>(core.cpParent, recordId); if (person != null) { if (isDelete) { LogController.addSiteActivity(core, "deleting user #" + recordId + " (" + recordName + ")", recordId, person.organizationId); } else { LogController.addSiteActivity(core, "saving changes to user #" + recordId + " (" + recordName + ")", recordId, person.organizationId); } } } else if (tableNameLower == OrganizationModel.tableMetadata.tableNameLower) { // // -- Log Activity for changes to people and organizattions if (isDelete) { LogController.addSiteActivity(core, "deleting organization #" + recordId + " (" + recordName + ")", 0, recordId); } else { LogController.addSiteActivity(core, "saving changes to organization #" + recordId + " (" + recordName + ")", 0, recordId); } } else if (tableNameLower == SitePropertyModel.tableMetadata.tableNameLower) { // // -- Site Properties switch (GenericController.toLCase(recordName)) { case "allowlinkalias": PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; case "sectionlandinglink": PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; case Constants._siteproperty_serverPageDefault_name: PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent); break; } } else if (tableNameLower == PageContentModel.tableMetadata.tableNameLower) { // // -- set ChildPagesFound true for parent page if (recordParentID > 0) { if (!isDelete) { core.db.executeNonQuery("update ccpagecontent set ChildPagesfound=1 where ID=" + recordParentID); } } if (isDelete) { // // Clear the Landing page and page not found site properties if (recordId == GenericController.encodeInteger(core.siteProperties.getText("PageNotFoundPageID", "0"))) { core.siteProperties.setProperty("PageNotFoundPageID", "0"); } if (recordId == core.siteProperties.landingPageID) { core.siteProperties.setProperty("landingPageId", "0"); } // // Delete Link Alias entries with this PageID core.db.executeNonQuery("delete from cclinkAliases where PageID=" + recordId); } DbBaseModel.invalidateCacheOfRecord <PageContentModel>(core.cpParent, recordId); } else if (tableNameLower == LibraryFilesModel.tableMetadata.tableNameLower) { // // -- processAfterSave_LibraryFiles(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink); } // // Process Addons marked to trigger a process call on content change // Dictionary <string, string> instanceArguments; bool onChangeAddonsAsync = core.siteProperties.getBoolean("execute oncontentchange addons async", false); using (var csData = new CsModel(core)) { int contentId = ContentMetadataModel.getContentId(core, contentName); csData.open("Add-on Content Trigger Rules", "ContentID=" + contentId, "", false, 0, "addonid"); string Option_String = null; if (isDelete) { instanceArguments = new Dictionary <string, string> { { "action", "contentdelete" }, { "contentid", contentId.ToString() }, { "recordid", recordId.ToString() } }; Option_String = "" + Environment.NewLine + "action=contentdelete" + Environment.NewLine + "contentid=" + contentId + Environment.NewLine + "recordid=" + recordId + ""; } else { instanceArguments = new Dictionary <string, string> { { "action", "contentchange" }, { "contentid", contentId.ToString() }, { "recordid", recordId.ToString() } }; Option_String = "" + Environment.NewLine + "action=contentchange" + Environment.NewLine + "contentid=" + contentId + Environment.NewLine + "recordid=" + recordId + ""; } while (csData.ok()) { var addon = DbBaseModel.create <AddonModel>(core.cpParent, csData.getInteger("Addonid")); if (addon != null) { if (onChangeAddonsAsync) { // // -- execute addon async core.addon.executeAsync(addon, instanceArguments); } else { // // -- execute addon core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext { addonType = CPUtilsBaseClass.addonContext.ContextOnContentChange, backgroundProcess = false, errorContextMessage = "", argumentKeyValuePairs = instanceArguments }); } } csData.goNext(); } } } catch (Exception ex) { LogController.logError(core, ex); } }
// //==================================================================================================== // public static string exportAscii_GetAsciiExport(CoreController core, string ContentName, int PageSize, int PageNumber) { string result = ""; try { string Delimiter = null; string Copy = ""; string TableName = null; string FieldNameVariant = null; string FieldName = null; string UcaseFieldName = null; string iContentName = null; System.Text.StringBuilder sb = new System.Text.StringBuilder(); string TestFilename; // TestFilename = "AsciiExport" + GenericController.getRandomInteger(core) + ".txt"; // iContentName = GenericController.encodeText(ContentName); if (PageSize == 0) { PageSize = 1000; } if (PageNumber == 0) { PageNumber = 1; } // // ----- Check for special case iContentNames // core.webServer.setResponseContentType("text/plain"); core.html.enableOutputBuffer(false); TableName = DbController.getDbObjectTableName(MetadataController.getContentTablename(core, iContentName)); switch (GenericController.toUCase(TableName)) { case "CCMEMBERS": // // ----- People and member content export // if (!core.session.isAuthenticatedAdmin()) { sb.Append("Warning: You must be a site administrator to export this information."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names // if (csData.ok()) { sb.Append("\"EID\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { sb.Append(Delimiter + "\"" + FieldName + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } // // ----- print out the values // while (csData.ok()) { if (!(csData.getBoolean("Developer"))) { Copy = SecurityController.encodeToken(core, csData.getInteger("ID"), core.doc.profileStartTime.AddDays(30)); sb.Append("\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { FieldName = GenericController.encodeText(FieldNameVariant); UcaseFieldName = GenericController.toUCase(FieldName); if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD")) { Copy = csData.getText(FieldName); if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } sb.Append(Delimiter + "\"" + Copy + "\""); } FieldNameVariant = csData.getNextFieldName(); } sb.Append(Environment.NewLine); } csData.goNext(); } } } // End Case break; default: // // ----- All other content // if (!core.session.isAuthenticatedContentManager(iContentName)) { sb.Append("Error: You must be a content manager to export this data."); } else { using (var csData = new CsModel(core)) { csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber); // // ----- print out the field names if (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + FieldNameVariant + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); } // // ----- print out the values while (csData.ok()) { Delimiter = ""; FieldNameVariant = csData.getFirstFieldName(); while (!string.IsNullOrEmpty(FieldNameVariant)) { switch (csData.getFieldTypeId(GenericController.encodeText(FieldNameVariant))) { case CPContentBaseClass.FieldTypeIdEnum.FileText: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileXML: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: Copy = csData.getTextEncoded(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Lookup: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; case CPContentBaseClass.FieldTypeIdEnum.Redirect: case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: break; default: Copy = csData.getText(GenericController.encodeText(FieldNameVariant)); break; } if (!string.IsNullOrEmpty(Copy)) { Copy = GenericController.strReplace(Copy, "\"", "'"); Copy = GenericController.strReplace(Copy, Environment.NewLine, " "); Copy = GenericController.strReplace(Copy, "\r", " "); Copy = GenericController.strReplace(Copy, "\n", " "); } core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + Copy + "\""); Delimiter = ","; FieldNameVariant = csData.getNextFieldName(); } core.wwwFiles.appendFile(TestFilename, Environment.NewLine); csData.goNext(); } } } break; } result = core.wwwFiles.readFileText(TestFilename); core.wwwFiles.deleteFile(TestFilename); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }