// //==================================================================================================== /// <summary> /// coreClass constructor for a web request/response environment. coreClass is the primary object internally, created by cp. /// </summary> public CoreController(CPClass cp, string applicationName, System.Web.HttpContext httpContext) { try { this.cpParent = cp; this.cpParent.core = this; _mockNow = null; LogController.log(this, "CoreController constructor-4, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // metaDataDictionary = new Dictionary <string, Models.Domain.ContentMetadataModel>(); tableSchemaDictionary = null; // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // serverConfig = ServerConfigModel.getObject(this); serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; appConfig = AppConfigModel.getObject(this, serverConfig, applicationName); if (appConfig != null) { webServer.initWebContext(httpContext); constructorInitialize(true); } LogController.log(this, "CoreController constructor-4, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); } catch (Exception ex) { LogController.logLocalOnly("CoreController constructor-4, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal); throw; } }
public void ChangePiece(CPClass _chessPiece) //Changes piece location { chessPiece = _chessPiece; if (chessPiece != null) { chessPiece.x = locationX; chessPiece.y = locationY; } if (thisButton != null) { if (chessPiece == null) //empty piece { thisButton.Text = ""; } else { thisButton.Text = chessPiece.CPName; if (chessPiece.pieceColor == ChessPieceColor.White) { thisButton.ForeColor = System.Drawing.Color.White; } else //Black { thisButton.ForeColor = System.Drawing.Color.Black; } } ChangeColor(ChessBoardNodeColor.None); } }
// //==================================================================================================== /// <summary> /// coreClass constructor for app, non-Internet use. coreClass is the primary object internally, created by cp. /// </summary> /// <param name="cp"></param> /// <remarks></remarks> public CoreController(CPClass cp, string applicationName, ServerConfigModel serverConfig) { try { cpParent = cp; deleteSessionOnExit = true; _mockNow = null; LogController.log(this, "CoreController constructor-2, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // metaDataDictionary = new Dictionary <string, Models.Domain.ContentMetadataModel>(); tableSchemaDictionary = null; // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // this.serverConfig = serverConfig; this.serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; appConfig = AppConfigModel.getObject(this, serverConfig, applicationName); appConfig.appStatus = AppConfigModel.AppStatusEnum.ok; webServer.iisContext = null; constructorInitialize(false); LogController.log(this, "CoreController constructor-2, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); } catch (Exception ex) { LogController.logLocalOnly("CoreController constructor-2, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal); throw; } }
// //==================================================================================================== /// <summary> /// Timer tick /// </summary> public void processTimerTick(object sender, EventArgs e) { try { // windows holds one instance of this class. This check needs a lock to catch the non-threadsafe check-then-set here if (!ProcessTimerInProcess) { ProcessTimerInProcess = true; using (CPClass cp = new CPClass()) { if (cp.core.serverConfig.allowTaskSchedulerService) { scheduleTasks(cp.core); } // // -- log memory usage -- info long workingSetMemory = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64; long virtualMemory = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64; long privateMemory = System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; LogController.log(cp.core, "TaskScheduler exit, workingSetMemory [" + workingSetMemory + "], virtualMemory [" + virtualMemory + "], privateMemory [" + privateMemory + "]", BaseClasses.CPLogBaseClass.LogLevel.Info); } } } catch (Exception ex) { using (CPClass cp = new CPClass()) { LogController.logError(cp.core, ex); } } finally { ProcessTimerInProcess = false; } }
// //==================================================================================================== /// <summary> /// Process the Start signal from the Server Control Manager /// </summary> /// <param name="setVerbose"></param> /// <param name="singleThreaded"></param> /// <returns></returns> public bool startTimerEvents() { bool returnStartedOk = false; try { // todo StartServiceInProgress does nothing. windows will not call it twice if (!StartServiceInProgress) { StartServiceInProgress = true; processTimer = new System.Timers.Timer(ProcessTimerMsecPerTick); processTimer.Elapsed += processTimerTick; processTimer.Enabled = true; returnStartedOk = true; StartServiceInProgress = false; } using (CPClass cp = new CPClass()) { LogController.logTrace(cp.core, "stopTimerEvents"); } } catch (Exception ex) { using (CPClass cp = new CPClass()) { LogController.logError(cp.core, ex); } } return(returnStartedOk); }
// //============================================================================= // public static string getWhatsRelated(CoreController core) { try { CPClass cp = core.cpParent; if (core.doc.pageController.page.id == 0) { return(string.Empty); } StringBuilder items = new StringBuilder(); using (var cs = new CsModel(core)) { string sql = "select rp.id,rp.name,rp.menuheadline,rp.briefFilename" + " from ccpagecontenttopicrules sr" + " left join ccpagecontenttopicrules rr on rr.topicid=sr.topicid" + " left join ccpagecontent rp on rp.id=rr.pageid" + " group by rp.id,rp.name,rp.menuheadline,rp.briefFilename" + " order by count(rp.id)"; if (cs.openSql(sql)) { do { int pageId = cs.getInteger("id"); if (!pageId.Equals(core.doc.pageController.page.id)) { string link = cp.Content.GetPageLink(pageId); if (!string.IsNullOrWhiteSpace(link)) { if (!link.Contains("://")) { link = core.webServer.requestProtocol + link; } string menuHeadline = cs.getText("menuheadline"); string content = HtmlController.a(string.IsNullOrWhiteSpace(menuHeadline) ? cs.getText("name") : menuHeadline, link); string briefFilename = cs.getText("briefFilename"); if (!string.IsNullOrWhiteSpace(briefFilename)) { content += HtmlController.div(cp.CdnFiles.Read(briefFilename), "ccListCopy"); } items.Append(HtmlController.li(content, "wrItem")); } } cs.goNext(); } while (cs.ok()); } } if (items.Length > 0) { return(HtmlController.div(HtmlController.h4("Whats Related") + HtmlController.ul(items.ToString(), "ccList"), "ccWhatsRelated")); } if (cp.User.IsEditing("")) { return(HtmlController.div(HtmlController.h4("Whats Related") + HtmlController.ul("<li>[empty list]</li>", "ccList"), "ccWhatsRelated")); } return(string.Empty); } catch (Exception ex) { LogController.logError(core, ex); return(string.Empty); } }
// //==================================================================================================== /// <summary> /// Stop all activity through the content server, but do not unload /// </summary> public void stopTimerEvents() { try { processTimer.Enabled = false; using (CPClass cp = new CPClass()) { LogController.logTrace(cp.core, "stopTimerEvents"); } } catch (Exception ex) { using (CPClass cp = new CPClass()) { LogController.logError(cp.core, ex); } } }
// //============================================================================= // Create a child content //============================================================================= // private static string GetContentChildTool_Options(CPClass cp, int ParentId, int DefaultValue) { string returnOptions = ""; try { // string SQL = null; int RecordId = 0; string RecordName = null; // if (ParentId == 0) { SQL = "select Name, ID from ccContent where ((ParentID<1)or(Parentid is null)) and (AllowContentChildTool<>0);"; } else { SQL = "select Name, ID from ccContent where ParentID=" + ParentId + " and (AllowContentChildTool<>0) and not (allowcontentchildtool is null);"; } using (var csData = new CsModel(cp.core)) { csData.openSql(SQL); while (csData.ok()) { RecordName = csData.getText("Name"); RecordId = csData.getInteger("ID"); if (RecordId == DefaultValue) { returnOptions = returnOptions + "<option value=\"" + RecordId + "\" selected>" + csData.getText("name") + "</option>"; } else { returnOptions = returnOptions + "<option value=\"" + RecordId + "\" >" + csData.getText("name") + "</option>"; } returnOptions = returnOptions + GetContentChildTool_Options(cp, RecordId, DefaultValue); csData.goNext(); } csData.close(); } } catch (Exception ex) { LogController.logError(cp.core, ex); throw; } return(returnOptions); }
// //==================================================================================================== /// <summary> /// coreClass constructor for cluster use. /// </summary> /// <param name="cp"></param> /// <remarks></remarks> public CoreController(CPClass cp) { cpParent = cp; _mockNow = null; deleteSessionOnExit = true; LogController.log(this, "CoreController constructor-0, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // metaDataDictionary = new Dictionary <string, ContentMetadataModel>(); tableSchemaDictionary = null; // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // serverConfig = ServerConfigModel.getObject(this); this.serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; webServer.iisContext = null; constructorInitialize(false); LogController.log(this, "CoreController constructor-0, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); }
// //==================================================================================================== /// <summary> /// Timer tick /// </summary> protected void processTimerTick(object sender, EventArgs e) { try { // non-thread safe. Use lock to prevent re-entry? if (processTimerInProcess) { // // -- trace log without core } else { processTimerInProcess = true; // // run tasks in task // using (CPClass cpServerGroup = new CPClass()) { if (!cpServerGroup.core.serverConfig.allowTaskRunnerService) { LogController.logTrace(cpServerGroup.core, "taskRunner.processTimerTick, skip -- allowTaskRunnerService false"); } else { runTasks(cpServerGroup.core); } // // -- log memory usage -- info long workingSetMemory = System.Diagnostics.Process.GetCurrentProcess().WorkingSet64; long virtualMemory = System.Diagnostics.Process.GetCurrentProcess().VirtualMemorySize64; long privateMemory = System.Diagnostics.Process.GetCurrentProcess().PrivateMemorySize64; LogController.log(cpServerGroup.core, "TaskRunner exit, workingSetMemory [" + workingSetMemory + "], virtualMemory [" + virtualMemory + "], privateMemory [" + privateMemory + "]", BaseClasses.CPLogBaseClass.LogLevel.Info); } processTimerInProcess = false; } } catch (Exception ex) { using (CPClass cp = new CPClass()) { LogController.logError(cp.core, ex); } } }
// //==================================================================================================== /// <summary> /// coreClass constructor for app, non-Internet use. coreClass is the primary object internally, created by cp. /// </summary> /// <param name="cp"></param> /// <remarks></remarks> public CoreController(CPClass cp, string applicationName, ServerConfigModel serverConfig, System.Web.HttpContext httpContext) { try { this.cpParent = cp; this.cpParent.core = this; _mockNow = null; deleteSessionOnExit = false; LogController.log(this, "CoreController constructor-3, enter", BaseClasses.CPLogBaseClass.LogLevel.Trace); // // -- create default auth objects for non-user methods, or until auth is available session = new SessionController(this); // this.serverConfig = serverConfig; this.serverConfig.defaultDataSourceType = ServerConfigBaseModel.DataSourceTypeEnum.sqlServer; appConfig = AppConfigModel.getObject(this, serverConfig, applicationName); this.appConfig.appStatus = AppConfigModel.AppStatusEnum.ok; webServer.initWebContext(httpContext); constructorInitialize(true); LogController.log(this, "CoreController constructor-3, exit", BaseClasses.CPLogBaseClass.LogLevel.Trace); } catch (Exception ex) { LogController.logLocalOnly("CoreController constructor-3, exception [" + ex.ToString() + "]", BaseClasses.CPLogBaseClass.LogLevel.Fatal); throw; } }
// //==================================================================================================== /// <summary> /// Iterate through all apps and execute tasks in processes /// </summary> private void runTasks(CoreController serverCore) { try { Stopwatch swProcess = new Stopwatch(); swProcess.Start(); // foreach (var appKVP in serverCore.serverConfig.apps) { if (appKVP.Value.enabled && appKVP.Value.appStatus.Equals(AppConfigModel.AppStatusEnum.ok)) { // // query tasks that need to be run // using (CPClass cpApp = new CPClass(appKVP.Value.name)) { // LogController.logTrace(cpApp.core, "runTasks, appname=[" + appKVP.Value.name + "]"); // try { int recordsAffected = 0; int sequentialTaskCount = 0; do { // // for now run an sql to get processes, eventually cache in variant cache string sqlCmdRunner = DbController.encodeSQLText(runnerGuid); string sql = "" + Environment.NewLine + " BEGIN TRANSACTION" + Environment.NewLine + " update cctasks set cmdRunner=" + sqlCmdRunner + " where id in (select top 1 id from cctasks where (cmdRunner is null)and(datestarted is null) order by id)" + Environment.NewLine + " COMMIT TRANSACTION"; cpApp.core.db.executeNonQuery(sql, ref recordsAffected); if (recordsAffected == 0) { // // -- no tasks found LogController.logTrace(cpApp.core, "runTasks, appname=[" + appKVP.Value.name + "], no tasks"); } else { // // -- select task to get timeout List <TaskModel> taskList = DbBaseModel.createList <TaskModel>(cpApp, "(cmdRunner=" + sqlCmdRunner + ")"); if (taskList.Count > 0) { TaskModel task = taskList.First(); Stopwatch swTask = new Stopwatch(); swTask.Start(); // // -- track multiple executions if (sequentialTaskCount > 0) { LogController.logTrace(cpApp.core, "runTasks, appname=[" + appKVP.Value.name + "], multiple tasks run in a single cycle, sequentialTaskCount [" + sequentialTaskCount + "]"); } // // -- two execution methods, 1) run task here, 2) start process and wait (so bad addon code does not memory link) bool runInServiceProcess = cpApp.Site.GetBoolean("Run tasks in service process"); string cliPathFilename = cpApp.core.programFiles.localAbsRootPath + "cc.exe"; if (!runInServiceProcess && !System.IO.File.Exists(cliPathFilename)) { runInServiceProcess = true; LogController.logError(cpApp.core, "TaskRunner cannot run out of process because command line program cc.exe not found in program files folder [" + cpApp.core.programFiles.localAbsRootPath + "]"); } if (runInServiceProcess) { // // -- execute here executeRunnerTasks(cpApp.Site.Name, runnerGuid); } else { // // -- execute in new process string filename = "cc.exe"; string workingDirectory = cpApp.core.programFiles.localAbsRootPath; string arguments = "-a \"" + appKVP.Value.name + "\" --runTask \"" + runnerGuid + "\""; LogController.logInfo(cpApp.core, "TaskRunner starting process to execute task for filename [" + filename + "], workingDirectory [" + workingDirectory + "], arguments [" + arguments + "]"); // // todo manage multiple executing processes using (Process process = new Process()) { process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = filename; process.StartInfo.WorkingDirectory = workingDirectory; process.StartInfo.Arguments = arguments; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); // // -- determine how long to wait int timeoutMsec = 0; if ((int.MaxValue / 1000) >= task.timeout) { // minus 1 because maxvalue causes wait for ever timeoutMsec = int.MaxValue - 1; } else { timeoutMsec = task.timeout * 1000; } if (timeoutMsec == 0) { // // --no timeout, just run the task process.WaitForExit(); } else { process.WaitForExit(timeoutMsec); } if (!process.HasExited) { LogController.logError(cpApp.core, "TaskRunner Killing process, process timed out, app [" + appKVP.Value.name + "]."); process.Kill(); process.WaitForExit(); } process.Close(); } } LogController.logTrace(cpApp.core, "runTasks, app [" + appKVP.Value.name + "], task complete (" + swTask.ElapsedMilliseconds + "ms)"); } } sequentialTaskCount++; } while (recordsAffected > 0); } catch (Exception ex) { LogController.logError(cpApp.core, ex); } } } } // // -- trace log without core } catch (Exception ex) { LogController.logError(serverCore, ex); } }
// //======================================================================== // //======================================================================== // public static string get(CPClass cp) { string tempGetForm_HouseKeepingControl = null; try { // StringBuilderLegacyController Content = new StringBuilderLegacyController(); string Copy = null; string SQL = null; string Button = null; int PagesTotal = 0; string Caption = null; DateTime DateValue = default(DateTime); string AgeInDays = null; int ArchiveRecordAgeDays = 0; string ArchiveTimeOfDay = null; bool ArchiveAllowFileClean = false; string ButtonList = ""; string Description = null; // Button = cp.core.docProperties.getText(RequestNameButton); if (Button == ButtonCancel) { // // // return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "HouseKeepingControl, Cancel Button Pressed")); } else if (!cp.core.session.isAuthenticatedAdmin()) { // // // ButtonList = ButtonCancel; Content.add(AdminUIController.getFormBodyAdminOnly()); } else { // string tableBody = ""; // // Set defaults // ArchiveRecordAgeDays = (cp.core.siteProperties.getInteger("ArchiveRecordAgeDays", 0)); ArchiveTimeOfDay = cp.core.siteProperties.getText("ArchiveTimeOfDay", "12:00:00 AM"); ArchiveAllowFileClean = (cp.core.siteProperties.getBoolean("ArchiveAllowFileClean", false)); // // Process Requests // switch (Button) { case ButtonOK: case ButtonSave: // ArchiveRecordAgeDays = cp.core.docProperties.getInteger("ArchiveRecordAgeDays"); cp.core.siteProperties.setProperty("ArchiveRecordAgeDays", GenericController.encodeText(ArchiveRecordAgeDays)); // ArchiveTimeOfDay = cp.core.docProperties.getText("ArchiveTimeOfDay"); cp.core.siteProperties.setProperty("ArchiveTimeOfDay", ArchiveTimeOfDay); // ArchiveAllowFileClean = cp.core.docProperties.getBoolean("ArchiveAllowFileClean"); cp.core.siteProperties.setProperty("ArchiveAllowFileClean", GenericController.encodeText(ArchiveAllowFileClean)); break; } // if (Button == ButtonOK) { return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "StaticPublishControl, OK Button Pressed")); } // // ----- Status // tableBody += HtmlController.tableRowStart() + "<td colspan=\"3\" class=\"ccPanel3D ccAdminEditSubHeader\"><b>Status</b>" + tableCellEnd + kmaEndTableRow; // // ----- Visits Found // PagesTotal = 0; SQL = "SELECT Count(ID) as Result FROM ccVisits;"; using (var csData = new CsModel(cp.core)) { csData.openSql(SQL); if (csData.ok()) { PagesTotal = csData.getInteger("Result"); } } tableBody += AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + PagesTotal, "Visits Found", "", false, false, ""); // // ----- Oldest Visit // Copy = "unknown"; AgeInDays = "unknown"; using (var csData = new CsModel(cp.core)) { SQL = cp.core.db.getSQLSelect("ccVisits", "DateAdded", "", "ID", "", 1); csData.openSql(SQL); if (csData.ok()) { DateValue = csData.getDate("DateAdded"); if (DateValue != DateTime.MinValue) { Copy = GenericController.encodeText(DateValue); AgeInDays = GenericController.encodeText(encodeInteger(Math.Floor(encodeNumber(cp.core.doc.profileStartTime - DateValue)))); } } } tableBody += (AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + Copy + " (" + AgeInDays + " days)", "Oldest Visit", "", false, false, "")); // // ----- Viewings Found // PagesTotal = 0; SQL = "SELECT Count(ID) as result FROM ccViewings;"; using (var csData = new CsModel(cp.core)) { csData.openSql(SQL); if (csData.ok()) { PagesTotal = csData.getInteger("Result"); } csData.close(); } tableBody += (AdminUIController.getEditRowLegacy(cp.core, SpanClassAdminNormal + PagesTotal, "Viewings Found", "", false, false, "")); // tableBody += (HtmlController.tableRowStart() + "<td colspan=\"3\" class=\"ccPanel3D ccAdminEditSubHeader\"><b>Options</b>" + tableCellEnd + kmaEndTableRow); // Caption = "Archive Age"; Copy = HtmlController.inputText_Legacy(cp.core, "ArchiveRecordAgeDays", ArchiveRecordAgeDays.ToString(), -1, 20) + " Number of days to keep visit records. 0 disables housekeeping."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Caption = "Housekeeping Time"; Copy = HtmlController.inputText_Legacy(cp.core, "ArchiveTimeOfDay", ArchiveTimeOfDay, -1, 20) + " The time of day when record deleting should start."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Caption = "Purge Content Files"; Copy = HtmlController.checkbox("ArchiveAllowFileClean", ArchiveAllowFileClean) + " Delete Contensive content files with no associated database record."; tableBody += (AdminUIController.getEditRowLegacy(cp.core, Copy, Caption)); // Content.add(AdminUIController.editTable(tableBody)); Content.add(HtmlController.inputHidden(rnAdminSourceForm, AdminformHousekeepingControl)); ButtonList = ButtonCancel + ",Refresh," + ButtonSave + "," + ButtonOK; } // Caption = "Data Housekeeping Control"; Description = "This tool is used to control the database record housekeeping process. This process deletes visit history records, so care should be taken before making any changes."; tempGetForm_HouseKeepingControl = AdminUIController.getToolBody(cp.core, Caption, ButtonList, "", false, false, Description, "", 0, Content.text); // cp.core.html.addTitle(Caption); } catch (Exception ex) { LogController.logError(cp.core, ex); } return(tempGetForm_HouseKeepingControl); }
// //==================================================================================================== /// <summary> /// create a new app. Must run in in task-service with elevated permissions /// </summary> /// <param name="cp"></param> /// <returns></returns> public override object Execute(Contensive.BaseClasses.CPBaseClass cpRootApp) { try { string appName = cpRootApp.Doc.GetText("appName"); string domainName = cpRootApp.Doc.GetText("domainName"); // using (CPClass cpServer = new CPClass()) { AppConfigModel appConfig = new AppConfigModel { // // -- enable it enabled = true, // // -- private key privateKey = Processor.Controllers.GenericController.getGUIDNaked(), // // -- allow site monitor allowSiteMonitor = false, name = appName, // // -- admin route adminRoute = "admin" }; // // -- domain domainName = "www." + appConfig.name + ".com"; appConfig.domainList.Add(domainName); // // -- file architectur appConfig.localWwwPath = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\www\\"; appConfig.localFilesPath = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\files\\"; appConfig.localPrivatePath = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\private\\"; appConfig.localTempPath = cpServer.core.serverConfig.localDataDriveLetter + ":\\inetpub\\" + appConfig.name + "\\temp\\"; if (cpServer.core.serverConfig.isLocalFileSystem) { // // -- no prompts, local file system appConfig.remoteWwwPath = ""; appConfig.remoteFilePath = ""; appConfig.remotePrivatePath = ""; appConfig.cdnFileUrl = "/" + appConfig.name + "/files/"; } else { // // -- no prompts, remote file system appConfig.remoteWwwPath = "/" + appConfig.name + "/www/"; appConfig.remoteFilePath = "/" + appConfig.name + "/files/"; appConfig.remotePrivatePath = "/" + appConfig.name + "/private/"; appConfig.cdnFileUrl = "https://s3.amazonaws.com/" + cpServer.core.serverConfig.awsBucketName + "/" + appConfig.name + "/files/"; } Contensive.Processor.Controllers.LogController.logInfo(cpServer.core, "Create local folders."); setupDirectory(appConfig.localWwwPath); setupDirectory(appConfig.localFilesPath); setupDirectory(appConfig.localPrivatePath); setupDirectory(appConfig.localTempPath); // // -- save the app configuration and reload the server using this app Contensive.Processor.Controllers.LogController.logInfo(cpServer.core, "Save app configuration."); appConfig.appStatus = AppConfigModel.AppStatusEnum.maintenance; cpServer.core.serverConfig.apps.Add(appConfig.name, appConfig); cpServer.core.serverConfig.save(cpServer.core); cpServer.core.serverConfig = ServerConfigModel.getObject(cpServer.core); cpServer.core.appConfig = AppConfigModel.getObject(cpServer.core, cpServer.core.serverConfig, appConfig.name); // // update local host file // try { LogController.logInfo(cpServer.core, "Update host file to add domain [127.0.0.1 " + appConfig.name + "]."); File.AppendAllText("c:\\windows\\system32\\drivers\\etc\\hosts", System.Environment.NewLine + "127.0.0.1\t" + appConfig.name); } catch (Exception ex) { LogController.logWarn(cpServer.core, "Error attempting to update local host file:" + ex); LogController.logWarn(cpServer.core, "Please manually add the following line to your host file (c:\\windows\\system32\\drivers\\etc\\hosts):" + "127.0.0.1\t" + appConfig.name); } // // create the database on the server // LogController.logInfo(cpServer.core, "Create database."); cpServer.core.dbServer.createCatalog(appConfig.name); } // // initialize the new app, use the save authentication that was used to authorize this object // using (CPClass cp = new CPClass(appName)) { LogController.logInfo(cp.core, "Verify website."); // const string iisDefaultDoc = "default.aspx"; cp.core.webServer.verifySite(appName, domainName, cp.core.appConfig.localWwwPath, iisDefaultDoc); // LogController.logInfo(cp.core, "Run db upgrade."); BuildController.upgrade(cp.core, true, true); // // -- set the application back to normal mode cp.core.serverConfig.save(cp.core); cp.core.siteProperties.setProperty(Constants.siteproperty_serverPageDefault_name, iisDefaultDoc); // LogController.logInfo(cp.core, "Upgrade complete."); LogController.logInfo(cp.core, "Use IIS Import Application to install either you web application, or the Contensive IISDefault.zip application."); } // return(string.Empty); } catch (Exception ex) { cpRootApp.Site.ErrorReport(ex); return("ERROR, unexpected exception during NewApp"); } }
// //==================================================================================================== /// <summary> /// when breaking changes are required for data, update them here /// </summary> /// <param name="core"></param> /// <param name="DataBuildVersion"></param> public static void migrateData(CoreController core, string DataBuildVersion, string logPrefix) { try { CPClass cp = core.cpParent; // // -- Roll the style sheet cache if it is setup core.siteProperties.setProperty("StylesheetSerialNumber", (-1).ToString()); // // -- verify ID is primary key on all tables with an id foreach (TableModel table in DbBaseModel.createList <TableModel>(cp)) { if (!string.IsNullOrWhiteSpace(table.name)) { bool tableHasId = false; { // // -- verify table as an id field string sql = "SELECT name FROM sys.columns WHERE Name = N'ID' AND Object_ID = Object_ID(N'ccmembers')"; DataTable dt = cp.Db.ExecuteQuery(sql); if (dt != null) { tableHasId = !dt.Rows.Equals(0); } } if (tableHasId) { // // -- table has id field, make sure it is primary key string sql = "" + " select Col.Column_Name" + " from INFORMATION_SCHEMA.TABLE_CONSTRAINTS Tab, INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE Col" + " where (Col.Constraint_Name = Tab.Constraint_Name) AND (Col.Table_Name = Tab.Table_Name) AND (Constraint_Type = 'PRIMARY KEY') AND (Col.Table_Name = '" + table.name + "')"; bool idPrimaryKeyFound = false; foreach (DataRow dr in core.db.executeQuery(sql).Rows) { if (GenericController.encodeText(dr["Column_Name"]).ToLower().Equals("id")) { idPrimaryKeyFound = true; break; } } if (!idPrimaryKeyFound) { try { core.db.executeNonQuery("alter table " + table.name + " add primary key (ID)"); } catch (Exception ex) { LogController.logError(core, ex, "Content Table [" + table.name + "] does not include column ID. Exception happened while adding column and setting it primarykey."); } } } } } // // -- continue only if a previous build exists if (!string.IsNullOrEmpty(DataBuildVersion)) { // // -- 4.1 to 5 conversions if (GenericController.versionIsOlder(DataBuildVersion, "4.1")) { // // -- create Data Migration Assets collection var migrationCollection = DbBaseModel.createByUniqueName <AddonCollectionModel>(cp, "Data Migration Assets"); if (migrationCollection == null) { migrationCollection = DbBaseModel.addDefault <AddonCollectionModel>(cp); migrationCollection.name = "Data Migration Assets"; } // // -- remove all addon content fieldtype rules Contensive.Models.Db.DbBaseModel.deleteRows <Contensive.Models.Db.AddonContentFieldTypeRulesModel>(cp, "(1=1)"); // // -- delete /admin www subfolder core.wwwFiles.deleteFolder("admin"); // // -- delete .asp and .php files foreach (BaseClasses.CPFileSystemBaseClass.FileDetail file in core.wwwFiles.getFileList("")) { if (file == null) { continue; } if (string.IsNullOrWhiteSpace(file.Name)) { continue; } if (file.Name.Length < 4) { continue; } string extension = System.IO.Path.GetExtension(file.Name).ToLower(CultureInfo.InvariantCulture); if ((extension == ".php") || (extension == ".asp")) { core.wwwFiles.deleteFile(file.Name); } } // // -- create www /cclib folder and copy in legacy resources core.programFiles.copyFile("cclib.zip", "cclib.zip", core.wwwFiles); core.wwwFiles.unzipFile("cclib.zip"); // // -- remove all the old menu entries and leave the navigation entries var navContent = DbBaseModel.createByUniqueName <ContentModel>(cp, Contensive.Models.Db.NavigatorEntryModel.tableMetadata.contentName); if (navContent != null) { core.db.executeNonQuery("delete from ccMenuEntries where ((contentcontrolid<>0)and(contentcontrolid<>" + navContent.id + ")and(contentcontrolid is not null))"); } // // -- reinstall newest font-awesome collection string returnErrorMessage = ""; var context = new Stack <string>(); var nonCritialErrorList = new List <string>(); var collectionsInstalledList = new List <string>(); CollectionLibraryController.installCollectionFromLibrary(core, false, context, Constants.fontAwesomeCollectionGuid, ref returnErrorMessage, false, true, ref nonCritialErrorList, logPrefix, ref collectionsInstalledList); // // -- reinstall newest redactor collection returnErrorMessage = ""; context = new Stack <string>(); nonCritialErrorList = new List <string>(); collectionsInstalledList = new List <string>(); CollectionLibraryController.installCollectionFromLibrary(core, false, context, Constants.redactorCollectionGuid, ref returnErrorMessage, false, true, ref nonCritialErrorList, logPrefix, ref collectionsInstalledList); // // -- addons with active-x -- remove programid and add script code that logs error string newCode = "" + "function m" + " ' + CHAR(13)+CHAR(10) + ' \ncp.Site.ErrorReport(\"deprecated active-X add-on executed [#\" & cp.addon.id & \", \" & cp.addon.name & \"]\")" + " ' + CHAR(13)+CHAR(10) + ' \nend function" + ""; string sql = "update ccaggregatefunctions set help='Legacy activeX: ' + objectprogramId, objectprogramId=null, ScriptingCode='" + newCode + "' where (ObjectProgramID is not null)"; LogController.logInfo(core, "MigrateData, removing activex addons, adding exception logging, sql [" + sql + "]"); core.db.executeNonQuery(sql); // // -- create page menus from section menus using (var cs = new CsModel(core)) { sql = "select m.name as menuName, m.id as menuId, p.name as pageName, p.id as pageId, s.name as sectionName, m.*" + " from ccDynamicMenus m" + " left join ccDynamicMenuSectionRules r on r.DynamicMenuId = m.id" + " left join ccSections s on s.id = r.SectionID" + " left join ccPageContent p on p.id = s.RootPageID" + " where (p.id is not null)and(s.active>0)" + " order by m.id, s.sortorder,s.id"; if (cs.openSql(sql)) { int sortOrder = 0; do { string menuName = cs.getText("menuName"); if (!string.IsNullOrWhiteSpace(menuName)) { var menu = DbBaseModel.createByUniqueName <MenuModel>(cp, menuName); if (menu == null) { menu = DbBaseModel.addEmpty <MenuModel>(cp); menu.name = menuName; try { menu.classItemActive = cs.getText("classItemActive"); menu.classItemFirst = cs.getText("classItemFirst"); menu.classItemHover = cs.getText("classItemHover"); menu.classItemLast = cs.getText("classItemLast"); menu.classTierAnchor = cs.getText("classTierItem"); menu.classTierItem = cs.getText("classTierItem"); menu.classTierList = cs.getText("classTierList"); menu.classTopAnchor = cs.getText("classTopItem"); menu.classTopItem = cs.getText("classTopItem"); menu.classTopList = cs.getText("classTopList"); menu.classTopWrapper = cs.getText("classTopWrapper"); } catch (Exception ex) { LogController.logError(core, ex, "migrateData error populating menu from dynamic menu."); } menu.save(cp); } // // -- set the root page's menuHeadline to the section name var page = DbBaseModel.create <PageContentModel>(cp, cs.getInteger("pageId")); if (page != null) { page.menuHeadline = cs.getText("sectionName"); page.save(cp); // // -- create a menu-page rule to attach this page to the menu in the current order var menuPageRule = DbBaseModel.addEmpty <MenuPageRuleModel>(cp); if (menuPageRule != null) { menuPageRule.name = "Created from v4.1 menu sections " + core.dateTimeNowMockable.ToString(); menuPageRule.pageId = page.id; menuPageRule.menuId = menu.id; menuPageRule.active = true; menuPageRule.sortOrder = sortOrder.ToString().PadLeft(4, '0'); menuPageRule.save(cp); sortOrder += 10; } } } cs.goNext(); } while (cs.ok()); } } // // -- create a theme addon for each template for styles and meta content using (var csTemplate = cp.CSNew()) { if (csTemplate.Open("page templates")) { do { int templateId = csTemplate.GetInteger("id"); string templateStylePrepend = ""; string templateStyles = csTemplate.GetText("StylesFilename"); // // -- add shared styles to the template stylesheet using (var csStyleRule = cp.CSNew()) { if (csStyleRule.Open("shared styles template rules", "(TemplateID=" + templateId + ")")) { do { int sharedStyleId = csStyleRule.GetInteger("styleid"); using (var csStyle = cp.CSNew()) { if (csStyleRule.Open("shared styles", "(id=" + sharedStyleId + ")")) { // // -- prepend lines beginning with @ t string styles = csStyleRule.GetText("StyleFilename"); if (!string.IsNullOrWhiteSpace(styles)) { // // -- trim off leading spaces, newlines, comments styles = styles.Trim(); while (!string.IsNullOrWhiteSpace(styles) && styles.Substring(0, 1).Equals("@")) { if (styles.IndexOf(Environment.NewLine) >= 0) { templateStylePrepend += styles.Substring(0, styles.IndexOf(Environment.NewLine)); styles = styles.Substring(styles.IndexOf(Environment.NewLine) + 1).Trim(); } else { templateStylePrepend += styles; styles = string.Empty; } } ; templateStyles += Environment.NewLine + styles; } } } csStyleRule.GoNext(); } while (csStyleRule.OK()); } } // // -- create an addon var themeAddon = DbBaseModel.addDefault <AddonModel>(cp); themeAddon.name = "Theme assets for template " + csTemplate.GetText("name"); themeAddon.otherHeadTags = csTemplate.GetText("otherheadtags"); themeAddon.javaScriptBodyEnd = csTemplate.GetText("jsendbody"); themeAddon.stylesFilename.content = templateStylePrepend + Environment.NewLine + templateStyles; themeAddon.collectionId = migrationCollection.id; themeAddon.save(cp); // // -- create an addon template rule to set dependency var rule = DbBaseModel.addEmpty <AddonTemplateRuleModel>(cp); rule.addonId = themeAddon.id; rule.templateId = templateId; rule.save(cp); // csTemplate.GoNext(); } while (csTemplate.OK()); } } // // -- reset the html minify so it is easier to resolve other issues core.siteProperties.setProperty("ALLOW HTML MINIFY", false); // // -- remove contentcategoryid from all edit page cp.Db.ExecuteNonQuery("update ccfields set Authorable=0 where name='contentcategoryid'"); cp.Db.ExecuteNonQuery("update ccfields set Authorable=0 where name='editsourceid'"); cp.Db.ExecuteNonQuery("update ccfields set Authorable=0 where name='editarchive'"); cp.Db.ExecuteNonQuery("update ccfields set Authorable=0 where name='editblank'"); // // -- remove legacy workflow fields UpgradeController.dropLegacyWorkflowField(core, "editsourceid"); cp.Db.ExecuteNonQuery("delete from ccfields where name='editsourceid'"); // UpgradeController.dropLegacyWorkflowField(core, "editblank"); cp.Db.ExecuteNonQuery("delete from ccfields where name='editblank'"); // UpgradeController.dropLegacyWorkflowField(core, "editarchive"); cp.Db.ExecuteNonQuery("delete from ccfields where name='editarchive'"); // UpgradeController.dropLegacyWorkflowField(core, "contentcategoryid"); cp.Db.ExecuteNonQuery("delete from ccfields where name='contentcategoryid'"); // // // -- end of 4.1 to 5 conversion } // // -- 5.19.1223 conversion -- render AddonList no copyFilename if (GenericController.versionIsOlder(DataBuildVersion, "5.19.1223")) { // // -- verify design block installation string returnUserError = ""; if (!cp.Db.IsTable("dbtext")) { if (!cp.Addon.InstallCollectionFromLibrary(Constants.designBlockCollectionGuid, ref returnUserError)) { throw new Exception("Error installing Design Blocks, required for data upgrade. " + returnUserError); } } // // -- add a text block and childPageList to every page without an addonlist foreach (var page in DbBaseModel.createList <PageContentModel>(cp, "(addonList is null)")) { convertPageContentToAddonList(core, page); } core.siteProperties.setProperty("PageController Render Legacy Copy", false); } // // -- 5.2005.9.4 conversion -- collections incorrectly marked not-updateable - mark all except themes (templates) if (GenericController.versionIsOlder(DataBuildVersion, "5.2005.9.4")) { // // -- cp.Db.ExecuteNonQuery("update ccaddoncollections set updatable=1 where name not like '%theme%'"); } // // -- 5.2005.19.1 conversion -- rename site property EmailUrlRootRelativePrefix to LocalFileModeProtocolDomain if (GenericController.versionIsOlder(DataBuildVersion, "5.2005.19.1")) { // // -- if (string.IsNullOrWhiteSpace(cp.Site.GetText("webAddressProtocolDomain"))) { cp.Site.SetProperty("webAddressProtocolDomain", cp.Site.GetText("EmailUrlRootRelativePrefix")); } } // // -- delete legacy corehelp collection. Created with fields that have only field name, legacy install layed collections over the application collection // new install loads fields directly from collection, which coreHelp then marks all fields inactive. core.db.delete("{6e905db1-d3f0-40af-aac4-4bd78e680fae}", "ccaddoncollections"); } // -- Reload core.cache.invalidateAll(); core.clearMetaData(); } catch (Exception ex) { LogController.logError(core, ex); throw; } }
// //============================================================================= // Create a child content //============================================================================= // public static string get(CPClass cp) { string result = ""; try { // bool IsEmptyList = false; int ParentContentId = 0; string ChildContentName = ""; int ChildContentId = 0; bool AddAdminMenuEntry = false; StringBuilderLegacyController Content = new StringBuilderLegacyController(); string FieldValue = null; bool NewGroup = false; int GroupId = 0; string NewGroupName = ""; string Button = null; string Caption = null; string Description = ""; string ButtonList = ""; bool BlockForm = false; // Button = cp.core.docProperties.getText(RequestNameButton); if (Button == ButtonCancel) { // // // return(cp.core.webServer.redirect("/" + cp.core.appConfig.adminRoute, "GetContentChildTool, Cancel Button Pressed")); } else if (!cp.core.session.isAuthenticatedAdmin()) { // // // ButtonList = ButtonCancel; Content.add(AdminUIController.getFormBodyAdminOnly()); } else { // if (Button != ButtonOK) { // // Load defaults // ParentContentId = cp.core.docProperties.getInteger("ParentContentID"); if (ParentContentId == 0) { ParentContentId = ContentMetadataModel.getContentId(cp.core, "Page Content"); } AddAdminMenuEntry = true; GroupId = 0; } else { // // Process input // ParentContentId = cp.core.docProperties.getInteger("ParentContentID"); var parentContentMetadata = ContentMetadataModel.create(cp.core, ParentContentId); ChildContentName = cp.core.docProperties.getText("ChildContentName"); AddAdminMenuEntry = cp.core.docProperties.getBoolean("AddAdminMenuEntry"); GroupId = cp.core.docProperties.getInteger("GroupID"); NewGroup = cp.core.docProperties.getBoolean("NewGroup"); NewGroupName = cp.core.docProperties.getText("NewGroupName"); // if ((parentContentMetadata == null) || (string.IsNullOrEmpty(ChildContentName))) { Processor.Controllers.ErrorController.addUserError(cp.core, "You must select a parent and provide a child name."); } else { // // Create Definition // Description = Description + "<div> </div>" + "<div>Creating content [" + ChildContentName + "] from [" + parentContentMetadata.name + "]</div>"; var childContentMetadata = parentContentMetadata.createContentChild(cp.core, ChildContentName, cp.core.session.user.id); ChildContentId = ContentMetadataModel.getContentId(cp.core, ChildContentName); // // Create Group and Rule // if (NewGroup && (!string.IsNullOrEmpty(NewGroupName))) { using (var csData = new CsModel(cp.core)) { csData.open("Groups", "name=" + DbController.encodeSQLText(NewGroupName)); if (csData.ok()) { Description = Description + "<div>Group [" + NewGroupName + "] already exists, using existing group.</div>"; GroupId = csData.getInteger("ID"); } else { Description = Description + "<div>Creating new group [" + NewGroupName + "]</div>"; csData.close(); csData.insert("Groups"); if (csData.ok()) { GroupId = csData.getInteger("ID"); csData.set("Name", NewGroupName); csData.set("Caption", NewGroupName); } } } } if (GroupId != 0) { using (var csData = new CsModel(cp.core)) { csData.insert("Group Rules"); if (csData.ok()) { Description = Description + "<div>Assigning group [" + MetadataController.getRecordName(cp.core, "Groups", GroupId) + "] to edit content [" + ChildContentName + "].</div>"; csData.set("GroupID", GroupId); csData.set("ContentID", ChildContentId); } } } // // Add Admin Menu Entry // if (AddAdminMenuEntry) { // // Add Navigator entries } // Description = Description + "<div> </div>" + "<div>Your new content is ready. <a href=\"?" + rnAdminForm + "=22\">Click here</a> to create another Content Definition, or hit [Cancel] to return to the main menu.</div>"; ButtonList = ButtonCancel; BlockForm = true; } cp.core.clearMetaData(); cp.core.cache.invalidateAll(); } // // Get the form // if (!BlockForm) { string tableBody = ""; // FieldValue = "<select size=\"1\" name=\"ParentContentID\" ID=\"\"><option value=\"\">Select One</option>"; FieldValue = FieldValue + GetContentChildTool_Options(cp, 0, ParentContentId); FieldValue = FieldValue + "</select>"; tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "Parent Content Name", "", false, false, ""); // FieldValue = HtmlController.inputText_Legacy(cp.core, "ChildContentName", ChildContentName, 1, 40); tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "New Child Content Name", "", false, false, ""); // FieldValue = "" + HtmlController.inputRadio("NewGroup", false.ToString(), NewGroup.ToString()) + cp.core.html.selectFromContent("GroupID", GroupId, "Groups", "", "", "", ref IsEmptyList) + "(Select a current group)" + "<br>" + HtmlController.inputRadio("NewGroup", true.ToString(), NewGroup.ToString()) + HtmlController.inputText_Legacy(cp.core, "NewGroupName", NewGroupName) + "(Create a new group)"; tableBody += AdminUIController.getEditRowLegacy(cp.core, FieldValue, "Content Manager Group", "", false, false, ""); // Content.add(AdminUIController.editTable(tableBody)); Content.add("</td></tr>" + kmaEndTable); // ButtonList = ButtonOK + "," + ButtonCancel; } Content.add(HtmlController.inputHidden(rnAdminSourceForm, AdminFormContentChildTool)); } // Caption = "Create Content Definition"; Description = "<div>This tool is used to create content definitions that help segregate your content into authorable segments.</div>" + Description; result = AdminUIController.getToolBody(cp.core, Caption, ButtonList, "", false, false, Description, "", 0, Content.text); } catch (Exception ex) { LogController.logError(cp.core, ex); } return(result); }
// //================================================================================= // //================================================================================= // public static string get(CPClass cp, CoreController core, AdminDataModel adminData) { string returnForm = ""; try { // string SearchValue = null; FindWordMatchEnum MatchOption = 0; int FormFieldPtr = 0; int FormFieldCnt = 0; ContentMetadataModel CDef = null; string FieldName = null; StringBuilderLegacyController Stream = new StringBuilderLegacyController(); int FieldPtr = 0; bool RowEven = false; string RQS = null; string[] FieldNames = { }; string[] FieldCaption = { }; int[] fieldId = null; CPContentBaseClass.FieldTypeIdEnum[] fieldTypeId = { }; string[] FieldValue = { }; int[] FieldMatchOptions = { }; int FieldMatchOption = 0; string[] FieldLookupContentName = { }; string[] FieldLookupList = { }; int ContentId = 0; int FieldCnt = 0; int FieldSize = 0; int RowPointer = 0; string LeftButtons = ""; string ButtonBar = null; string Title = null; string TitleBar = null; string Content = null; // // Process last form // string Button = core.docProperties.getText("button"); IndexConfigClass IndexConfig = null; if (!string.IsNullOrEmpty(Button)) { switch (Button) { case ButtonSearch: IndexConfig = IndexConfigClass.get(core, adminData); FormFieldCnt = core.docProperties.getInteger("fieldcnt"); if (FormFieldCnt > 0) { for (FormFieldPtr = 0; FormFieldPtr < FormFieldCnt; FormFieldPtr++) { FieldName = GenericController.toLCase(core.docProperties.getText("fieldname" + FormFieldPtr)); MatchOption = (FindWordMatchEnum)core.docProperties.getInteger("FieldMatch" + FormFieldPtr); switch (MatchOption) { case FindWordMatchEnum.MatchEquals: case FindWordMatchEnum.MatchGreaterThan: case FindWordMatchEnum.matchincludes: case FindWordMatchEnum.MatchLessThan: SearchValue = core.docProperties.getText("FieldValue" + FormFieldPtr); break; default: SearchValue = ""; break; } if (!IndexConfig.findWords.ContainsKey(FieldName)) { // // fieldname not found, save if not FindWordMatchEnum.MatchIgnore // if (MatchOption != FindWordMatchEnum.MatchIgnore) { IndexConfig.findWords.Add(FieldName, new IndexConfigFindWordClass { Name = FieldName, MatchOption = MatchOption, Value = SearchValue }); } } else { // // fieldname was found // IndexConfig.findWords[FieldName].MatchOption = MatchOption; IndexConfig.findWords[FieldName].Value = SearchValue; } } } GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig); return(string.Empty); case ButtonCancel: return(string.Empty); } } IndexConfig = IndexConfigClass.get(core, adminData); Button = "CriteriaSelect"; RQS = core.doc.refreshQueryString; // // ----- ButtonBar // if (adminData.ignore_legacyMenuDepth > 0) { LeftButtons += AdminUIController.getButtonPrimary(ButtonClose, "window.close();"); } else { LeftButtons += AdminUIController.getButtonPrimary(ButtonCancel); } LeftButtons += AdminUIController.getButtonPrimary(ButtonSearch); ButtonBar = AdminUIController.getSectionButtonBar(core, LeftButtons, ""); // // ----- TitleBar // Title = adminData.adminContent.name; Title = Title + " Advanced Search"; string TitleDescription = "<div>Enter criteria for each field to identify and select your results. The results of a search will have to have all of the criteria you enter.</div>"; TitleBar = AdminUIController.getSectionHeader(core, Title, TitleDescription); // // ----- List out all fields // CDef = ContentMetadataModel.createByUniqueName(core, adminData.adminContent.name); FieldSize = 100; Array.Resize(ref FieldNames, FieldSize + 1); Array.Resize(ref FieldCaption, FieldSize + 1); Array.Resize(ref fieldId, FieldSize + 1); Array.Resize(ref fieldTypeId, FieldSize + 1); Array.Resize(ref FieldValue, FieldSize + 1); Array.Resize(ref FieldMatchOptions, FieldSize + 1); Array.Resize(ref FieldLookupContentName, FieldSize + 1); Array.Resize(ref FieldLookupList, FieldSize + 1); foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if (FieldPtr >= FieldSize) { FieldSize = FieldSize + 100; Array.Resize(ref FieldNames, FieldSize + 1); Array.Resize(ref FieldCaption, FieldSize + 1); Array.Resize(ref fieldId, FieldSize + 1); Array.Resize(ref fieldTypeId, FieldSize + 1); Array.Resize(ref FieldValue, FieldSize + 1); Array.Resize(ref FieldMatchOptions, FieldSize + 1); Array.Resize(ref FieldLookupContentName, FieldSize + 1); Array.Resize(ref FieldLookupList, FieldSize + 1); } FieldName = GenericController.toLCase(field.nameLc); FieldNames[FieldPtr] = FieldName; FieldCaption[FieldPtr] = field.caption; fieldId[FieldPtr] = field.id; fieldTypeId[FieldPtr] = field.fieldTypeId; if (fieldTypeId[FieldPtr] == CPContentBaseClass.FieldTypeIdEnum.Lookup) { ContentId = field.lookupContentId; if (ContentId > 0) { FieldLookupContentName[FieldPtr] = MetadataController.getContentNameByID(core, ContentId); } FieldLookupList[FieldPtr] = field.lookupList; } // // set prepoplate value from indexconfig // if (IndexConfig.findWords.ContainsKey(FieldName)) { FieldValue[FieldPtr] = IndexConfig.findWords[FieldName].Value; FieldMatchOptions[FieldPtr] = (int)IndexConfig.findWords[FieldName].MatchOption; } FieldPtr += 1; } FieldCnt = FieldPtr; // // Add headers to stream // returnForm = returnForm + "<table border=0 width=100% cellspacing=0 cellpadding=4>"; // RowPointer = 0; for (FieldPtr = 0; FieldPtr < FieldCnt; FieldPtr++) { returnForm = returnForm + HtmlController.inputHidden("fieldname" + FieldPtr, FieldNames[FieldPtr]); RowEven = ((RowPointer % 2) == 0); FieldMatchOption = FieldMatchOptions[FieldPtr]; switch (fieldTypeId[FieldPtr]) { case CPContentBaseClass.FieldTypeIdEnum.Date: // // Date returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEquals).ToString(), FieldMatchOption.ToString(), "") + "=</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "></div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "<</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputDate(core, "fieldvalue" + FieldPtr, encodeDate(FieldValue[FieldPtr])).Replace(">", " onFocus=\"ccAdvSearchText\">") + "</div>" + "</div>" + "</td>" + "</tr>"; break; case CPContentBaseClass.FieldTypeIdEnum.Currency: case CPContentBaseClass.FieldTypeIdEnum.Float: case CPContentBaseClass.FieldTypeIdEnum.Integer: case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement: // // -- Numeric - changed FindWordMatchEnum.MatchEquals to MatchInclude to be compatible with Find Search returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "n" + FieldPtr) + "=</div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "></div>" + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "<</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('n" + FieldPtr + "');e.checked=1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer += 1; break; case CPContentBaseClass.FieldTypeIdEnum.File: case CPContentBaseClass.FieldTypeIdEnum.FileImage: // // File // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; case CPContentBaseClass.FieldTypeIdEnum.Boolean: // // Boolean // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchTrue).ToString(), FieldMatchOption.ToString(), "") + "true</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchFalse).ToString(), FieldMatchOption.ToString(), "") + "false</div>" + "</div>" + "</td>" + "</tr>"; break; case CPContentBaseClass.FieldTypeIdEnum.Text: case CPContentBaseClass.FieldTypeIdEnum.LongText: case CPContentBaseClass.FieldTypeIdEnum.HTML: case CPContentBaseClass.FieldTypeIdEnum.HTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileHTML: case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: case CPContentBaseClass.FieldTypeIdEnum.FileCSS: case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: case CPContentBaseClass.FieldTypeIdEnum.FileXML: // // Text // returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "');e.checked=1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; case CPContentBaseClass.FieldTypeIdEnum.Lookup: case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: // // Lookup returnForm = returnForm + "<tr>" + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>" + "<td class=\"ccAdminEditField\">" + "<div style=\"display:block;float:left;width:800px;\">" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>" + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not empty</div>" + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>" + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "'); e.checked= 1;\">") + "</div>" + "</div>" + "</td>" + "</tr>"; RowPointer = RowPointer + 1; break; } } returnForm = returnForm + HtmlController.tableRowStart(); returnForm = returnForm + HtmlController.tableCellStart("120", 1, RowEven, "right") + "<img src=" + cdnPrefix + "images/spacer.gif width=120 height=1></td>"; returnForm = returnForm + HtmlController.tableCellStart("99%", 1, RowEven, "left") + "<img src=" + cdnPrefix + "images/spacer.gif width=1 height=1></td>"; returnForm = returnForm + kmaEndTableRow; returnForm = returnForm + "</table>"; Content = returnForm; // // Assemble LiveWindowTable Stream.add(ButtonBar); Stream.add(TitleBar); Stream.add(Content); Stream.add(ButtonBar); Stream.add("<input type=hidden name=fieldcnt VALUE=" + FieldCnt + ">"); Stream.add("<input type=hidden name=" + RequestNameAdminSubForm + " VALUE=" + AdminFormIndex_SubFormAdvancedSearch + ">"); returnForm = HtmlController.form(core, Stream.text); core.html.addTitle(adminData.adminContent.name + " Advanced Search"); } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnForm); }
// //==================================================================================================== /// <summary> /// Run manual query /// </summary> /// <param name="cp"></param> /// <returns></returns> public static string get(CPClass cp) { string returnHtml = ""; CoreController core = cp.core; try { StringBuilderLegacyController Stream = new StringBuilderLegacyController(); Stream.add(AdminUIController.getHeaderTitleDescription("Run Manual Query", "This tool runs an SQL statement on a selected datasource. If there is a result set, the set is printed in a table.")); // // Get the members SQL Queue // string SQLFilename = core.userProperty.getText("SQLArchive"); if (string.IsNullOrEmpty(SQLFilename)) { SQLFilename = "SQLArchive" + core.session.user.id.ToString("000000000") + ".txt"; core.userProperty.setProperty("SQLArchive", SQLFilename); } string SQLArchive = core.cdnFiles.readFileText(SQLFilename); // // Read in arguments if available // int Timeout = core.docProperties.getInteger("Timeout"); if (Timeout == 0) { Timeout = 30; } // int pageSize = core.docProperties.getInteger("PageSize"); if (pageSize == 0) { pageSize = 10; } // int pageNumber = core.docProperties.getInteger("PageNumber"); if (pageNumber == 0) { pageNumber = 1; } // string SQL = core.docProperties.getText("SQL"); if (string.IsNullOrEmpty(SQL)) { SQL = core.docProperties.getText("SQLList"); } DataSourceModel datasource = DataSourceModel.create(core.cpParent, core.docProperties.getInteger("dataSourceid")); // if ((core.docProperties.getText("button")) == ButtonRun) { // // Add this SQL to the members SQL list // if (!string.IsNullOrEmpty(SQL)) { string SQLArchiveOld = SQLArchive.Replace(SQL + Environment.NewLine, ""); SQLArchive = SQL.Replace(Environment.NewLine, " ") + Environment.NewLine; int LineCounter = 0; while ((LineCounter < 10) && (!string.IsNullOrEmpty(SQLArchiveOld))) { string line = getLine(ref SQLArchiveOld).Trim(); if (!string.IsNullOrWhiteSpace(line)) { SQLArchive += line + Environment.NewLine; } } core.cdnFiles.saveFile(SQLFilename, SQLArchive); } // // Run the SQL // string errBefore = ErrorController.getDocExceptionHtmlList(core); if (!string.IsNullOrWhiteSpace(errBefore)) { // -- error in interface, should be fixed before attempting query Stream.add("<br>" + core.dateTimeNowMockable + " SQL NOT executed. The following errors were detected before execution"); Stream.add(errBefore); } else { Stream.add("<p>" + core.dateTimeNowMockable + " Executing sql [" + SQL + "] on DataSource [" + datasource.name + "]"); DataTable dt = null; try { dt = core.db.executeQuery(SQL, DbController.getStartRecord(pageSize, pageNumber), pageSize); } catch (Exception ex) { // // ----- error Stream.add("<br>" + core.dateTimeNowMockable + " SQL execution returned the following error"); Stream.add("<br>" + ex.Message); } string errSql = ErrorController.getDocExceptionHtmlList(core); if (!string.IsNullOrWhiteSpace(errSql)) { Stream.add("<br>" + core.dateTimeNowMockable + " SQL execution returned the following error"); Stream.add("<br>" + errSql); core.doc.errorList.Clear(); } else { Stream.add("<br>" + core.dateTimeNowMockable + " SQL executed successfully"); if (dt == null) { Stream.add("<br>" + core.dateTimeNowMockable + " SQL returned invalid data."); } else if (dt.Rows == null) { Stream.add("<br>" + core.dateTimeNowMockable + " SQL returned invalid data rows."); } else if (dt.Rows.Count == 0) { Stream.add("<br>" + core.dateTimeNowMockable + " The SQL returned no data."); } else { // // ----- print results // Stream.add("<br>" + core.dateTimeNowMockable + " The following results were returned"); Stream.add("<br></p>"); // // --- Create the Fields for the new table // int FieldCount = dt.Columns.Count; Stream.add("<table class=\"table table-bordered table-hover table-sm table-striped\">"); Stream.add("<thead class=\"thead - inverse\"><tr>"); foreach (DataColumn dc in dt.Columns) { Stream.add("<th>" + dc.ColumnName + "</th>"); } Stream.add("</tr></thead>"); // string[,] resultArray = core.db.convertDataTabletoArray(dt); // int RowMax = resultArray.GetUpperBound(1); int ColumnMax = resultArray.GetUpperBound(0); string RowStart = "<tr>"; string RowEnd = "</tr>"; string ColumnStart = "<td>"; string ColumnEnd = "</td>"; int RowPointer = 0; for (RowPointer = 0; RowPointer <= RowMax; RowPointer++) { Stream.add(RowStart); int ColumnPointer = 0; for (ColumnPointer = 0; ColumnPointer <= ColumnMax; ColumnPointer++) { string CellData = resultArray[ColumnPointer, RowPointer]; if (isNull(CellData)) { Stream.add(ColumnStart + "[null]" + ColumnEnd); } else if (string.IsNullOrEmpty(CellData)) { Stream.add(ColumnStart + "[empty]" + ColumnEnd); } else { Stream.add(ColumnStart + HtmlController.encodeHtml(GenericController.encodeText(CellData)) + ColumnEnd); } } Stream.add(RowEnd); } Stream.add("</table>"); } } } Stream.add("<p>" + core.dateTimeNowMockable + " Done</p>"); } // // Display form { // // -- sql form int SQLRows = core.docProperties.getInteger("SQLRows"); if (SQLRows == 0) { SQLRows = core.userProperty.getInteger("ManualQueryInputRows", 5); } else { core.userProperty.setProperty("ManualQueryInputRows", SQLRows.ToString()); } Stream.add(AdminUIEditorController.getHtmlCodeEditor(core, "SQL", SQL, false, "SQL", false)); Stream.add(" <INPUT TYPE=\"Text\" TabIndex=-1 NAME=\"SQLRows\" SIZE=\"3\" VALUE=\"" + SQLRows + "\" ID=\"\" onchange=\"SQL.rows=SQLRows.value; return true\"> Rows"); } // // -- data source bool isEmptyList = false; Stream.add(AdminUIController.getToolFormInputRow(core, "Data Source", AdminUIEditorController.getLookupContentEditor(core, "DataSourceID", datasource.id, ContentMetadataModel.getContentId(core, "data sources"), ref isEmptyList, false, "", "", false, ""))); { // // -- sql list string js = "var e = document.getElementById('SQLList');SQL.value=e.options[e.selectedIndex].text;"; List <string> lookupList = SQLArchive.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); string inputSelect = AdminUIEditorController.getLookupListEditor(core, "SQLList", 0, lookupList, false, "SQLList", "", false); inputSelect = inputSelect.Replace("<select ", "<select onChange=\"" + js + "\" "); Stream.add(AdminUIController.getToolFormInputRow(core, "Previous Queries", inputSelect)); } // // -- page size if (isNull(pageSize)) { pageSize = 100; } Stream.add(AdminUIController.getToolFormInputRow(core, "Page Size", AdminUIEditorController.getTextEditor(core, "PageSize", pageSize.ToString()))); // // -- page number if (isNull(pageNumber)) { pageNumber = 1; } Stream.add(AdminUIController.getToolFormInputRow(core, "Page Number", AdminUIEditorController.getTextEditor(core, "PageNumber", pageNumber.ToString()))); // // -- timeout if (isNull(Timeout)) { Timeout = 30; } Stream.add(AdminUIController.getToolFormInputRow(core, "Timeout (sec)", AdminUIEditorController.getTextEditor(core, "Timeout", Timeout.ToString()))); // // -- assemble form returnHtml = AdminUIController.getToolForm(core, Stream.text, ButtonCancel + "," + ButtonRun); } catch (Exception ex) { LogController.logError(core, ex); throw; } return(returnHtml); }
// //==================================================================================================== /// <summary> /// Iterate through all apps, find addosn that need to run and add them to the task queue /// </summary> private void scheduleTasks(CoreController core) { try { // // -- run tasks for each app foreach (var appKvp in core.serverConfig.apps) { if (appKvp.Value.enabled && appKvp.Value.appStatus.Equals(AppConfigModel.AppStatusEnum.ok)) { LogController.logTrace(core, "scheduleTasks, app=[" + appKvp.Value.name + "]"); using (CPClass cpApp = new CPClass(appKvp.Value.name)) { // // Execute Processes try { string sqlAddonsCriteria = "" + "(active<>0)" + " and(name<>'')" + " and(" + " ((ProcessRunOnce is not null)and(ProcessRunOnce<>0))" + " or((ProcessInterval is not null)and(ProcessInterval<>0)and(ProcessNextRun is null))" + " or(ProcessNextRun<" + DbController.encodeSQLDate(core.dateTimeNowMockable) + ")" + " )"; var addonList = DbBaseModel.createList <AddonModel>(cpApp, sqlAddonsCriteria); foreach (var addon in addonList) { // int addonProcessInterval = encodeInteger(addon.processInterval); if (addon.processRunOnce) { // // -- run once checked addon.processNextRun = core.dateTimeNowMockable; addon.processRunOnce = false; } else if ((addon.processNextRun == null) && (addonProcessInterval > 0)) { // // -- processInterval set but everything else blank ) addon.processNextRun = core.dateTimeNowMockable.AddMinutes(addonProcessInterval); } if (addon.processNextRun <= core.dateTimeNowMockable) { // LogController.logInfo(cpApp.core, "scheduleTasks, addon [" + addon.name + "], add task, addonProcessRunOnce [" + addon.processRunOnce + "], addonProcessNextRun [" + addon.processNextRun + "]"); // // -- add task to queue for runner addTaskToQueue(cpApp.core, new TaskModel.CmdDetailClass { addonId = addon.id, addonName = addon.name, args = GenericController.convertAddonArgumentstoDocPropertiesList(cpApp.core, addon.argumentList) }, true); if (addonProcessInterval > 0) { // // -- interval set, update the next run addon.processNextRun = core.dateTimeNowMockable.AddMinutes(addonProcessInterval); } else { // // -- no interval, no next run addon.processNextRun = null; } } addon.save(cpApp); } } catch (Exception ex) { LogController.logTrace(cpApp.core, "scheduleTasks, exception [" + ex + "]"); LogController.logError(cpApp.core, ex); } } } } } catch (Exception ex) { LogController.logTrace(core, "scheduleTasks, exeception [" + ex + "]"); LogController.logError(core, ex); } }
// /// <summary> /// /// </summary> /// <param name="cp"></param> /// <returns></returns> // public static string sampleTool(CPClass cp) { string result = ""; CoreController core = cp.core; try { var resultForm = new StringBuilder(); resultForm.Append(AdminUIController.getHeaderTitleDescription("Sample Tool", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Erat imperdiet sed euismod nisi. In vitae turpis massa sed elementum tempus egestas sed sed. Tortor consequat id porta nibh. Pulvinar sapien et ligula ullamcorper malesuada. Facilisi nullam vehicula ipsum a. Nibh venenatis cras sed felis eget. Lectus magna fringilla urna porttitor rhoncus dolor. Auctor urna nunc id cursus metus aliquam. Gravida neque convallis a cras semper auctor neque. Faucibus nisl tincidunt eget nullam non nisi est sit amet. In nisl nisi scelerisque eu ultrices vitae auctor eu augue. In egestas erat imperdiet sed euismod nisi. Adipiscing diam donec adipiscing tristique. Ullamcorper eget nulla facilisi etiam dignissim diam quis enim. Sed libero enim sed faucibus turpis in eu. Ultrices neque ornare aenean euismod elementum nisi quis eleifend.")); // // process form string button = cp.Doc.GetText("button"); string PageSize = cp.Doc.GetText("pageSize"); int countryId = cp.Doc.GetInteger("countryId"); var buttonList = new List <string> { ButtonCancel }; if (button == ButtonCancel) { // // Cancel just exits with no content // return(string.Empty); } else if (!core.session.isAuthenticatedAdmin()) { // // Not Admin Error // resultForm.Append(AdminUIController.getFormBodyAdminOnly()); } else { // // Process Requests // switch (button) { case ButtonSave: case ButtonOK: { // // perform action break; } default: { // nothing break; } } if (button.Equals(ButtonOK)) { // // Exit on OK // return(string.Empty); } } // // display form resultForm.Append(cp.Html5.P("Enter sample data.")); resultForm.Append(HtmlController.inputTextarea(core, "sampleText", "", 10)); // // Buttons // buttonList.Add(ButtonSave); buttonList.Add(ButtonOK); // // Close Tables // resultForm.Append(HtmlController.inputHidden(rnAdminSourceForm, AdminFormSecurityControl)); bool isEmptyList = false; resultForm.Append(AdminUIController.getToolFormInputRow(core, "Caption", AdminUIEditorController.getLookupContentEditor(core, "countryId", countryId, ContentMetadataModel.getContentId(core, "countries"), ref isEmptyList, false, "", "", false, ""))); resultForm.Append(AdminUIController.getToolFormInputRow(core, "Caption", AdminUIEditorController.getTextEditor(core, "PageSize", PageSize.ToString()))); // // -- assemble form result = AdminUIController.getToolForm(core, resultForm.ToString(), String.Join(",", buttonList)); } catch (Exception ex) { LogController.logError(core, ex); throw; } return(result); }
// //============================================================================= // Print the manual query form //============================================================================= // public static string getForm_CacheTool(CPClass cp) { CoreController core = cp.core; try { var form = cp.AdminUI.NewToolForm(); form.Title = "Cache Tool"; form.Description = "Use this tool to get/store/invalidate the application's cache."; //Stream.add(AdminUIController.getHeaderTitleDescription("Cache Tool", "Use this tool to get/store/invalidate the application's cache.")); // string cacheKey = cp.Doc.GetText("cacheKey"); string cacheValue = cp.Doc.GetText("cacheValue"); string button = cp.Doc.GetText("button"); // StringBuilderLegacyController formBody = new StringBuilderLegacyController(); if (button == ButtonCacheGet) { // // -- Get Cache formBody.add("<div>" + core.dateTimeNowMockable + " cache.getObject(" + cacheKey + ")</div>"); object resultObj = cp.Cache.GetObject(cacheKey); if (resultObj == null) { formBody.add("<div>" + core.dateTimeNowMockable + " NULL returned</div>"); } else { try { cacheValue = Newtonsoft.Json.JsonConvert.SerializeObject(resultObj); formBody.add("<div>" + core.dateTimeNowMockable + "CacheValue object returned, json serialized, length [" + cacheValue.Length + "]</div>"); } catch (Exception ex) { formBody.add("<div>" + core.dateTimeNowMockable + " exception during serialization, ex [" + ex + "]</div>"); } } formBody.add("<p>" + core.dateTimeNowMockable + " Done</p>"); } else if (button == ButtonCacheStore) { // // -- Store Cache formBody.add("<div>" + core.dateTimeNowMockable + " cache.store(" + cacheKey + "," + cacheValue + ")</div>"); cp.Cache.Store(cacheKey, cacheValue); formBody.add("<p>" + core.dateTimeNowMockable + " Done</p>"); } else if (button == ButtonCacheInvalidate) { // // -- Invalidate cacheValue = ""; formBody.add("<div>" + core.dateTimeNowMockable + " cache.Invalidate(" + cacheKey + ")</div>"); cp.Cache.Invalidate(cacheKey); formBody.add("<p>" + core.dateTimeNowMockable + " Done</p>"); } else if (button == ButtonCacheInvalidateAll) { // // -- Store Cache cacheValue = ""; formBody.add("<div>" + core.dateTimeNowMockable + " cache.InvalidateAll()</div>"); cp.Cache.InvalidateAll(); formBody.add("<p>" + core.dateTimeNowMockable + " Done</p>"); } // // Display form { // // -- cache key formBody.add(cp.Html5.H4("Cache Key")); formBody.add(cp.Html5.Div(cp.AdminUI.GetTextEditor("cacheKey", cacheKey, "cacheKey", false))); } { // // -- cache value formBody.add(cp.Html5.H4("Cache Value")); formBody.add(cp.Html5.Div(cp.AdminUI.GetTextEditor("cacheValue", cacheValue, "cacheValue", false))); } // // -- assemble form form.Body = formBody.text; form.AddFormButton(ButtonCancel); form.AddFormButton(ButtonCacheGet); form.AddFormButton(ButtonCacheStore); form.AddFormButton(ButtonCacheInvalidate); form.AddFormButton(ButtonCacheInvalidateAll); return(form.GetHtml(cp)); } catch (Exception ex) { LogController.logError(core, ex); throw; } }
// //==================================================================================================== /// <summary> /// Get the Configure Edit /// </summary> /// <param name="cp"></param> /// <returns></returns> public static string get(CPClass cp) { CoreController core = cp.core; try { KeyPtrController Index = new KeyPtrController(); int ContentId = cp.Doc.GetInteger(RequestNameToolContentId); var contentMetadata = ContentMetadataModel.create(core, ContentId, true, true); int RecordCount = 0; int formFieldId = 0; string StatusMessage = ""; string ErrorMessage = ""; bool ReloadCDef = cp.Doc.GetBoolean("ReloadCDef"); if (contentMetadata != null) { string ToolButton = cp.Doc.GetText("Button"); // if (!string.IsNullOrEmpty(ToolButton)) { bool AllowContentAutoLoad = false; if (ToolButton != ButtonCancel) { // // Save the form changes // AllowContentAutoLoad = cp.Site.GetBoolean("AllowContentAutoLoad", true); cp.Site.SetProperty("AllowContentAutoLoad", "false"); // // ----- Save the input // RecordCount = GenericController.encodeInteger(cp.Doc.GetInteger("dtfaRecordCount")); if (RecordCount > 0) { int RecordPointer = 0; for (RecordPointer = 0; RecordPointer < RecordCount; RecordPointer++) { // string formFieldName = cp.Doc.GetText("dtfaName." + RecordPointer); CPContentBaseClass.FieldTypeIdEnum formFieldTypeId = (CPContentBaseClass.FieldTypeIdEnum)cp.Doc.GetInteger("dtfaType." + RecordPointer); formFieldId = GenericController.encodeInteger(cp.Doc.GetInteger("dtfaID." + RecordPointer)); bool formFieldInherited = cp.Doc.GetBoolean("dtfaInherited." + RecordPointer); // // problem - looking for the name in the Db using the form's name, but it could have changed. // have to look field up by id // foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> cdefFieldKvp in contentMetadata.fields) { if (cdefFieldKvp.Value.id == formFieldId) { // // Field was found in CDef // if (cdefFieldKvp.Value.inherited && (!formFieldInherited)) { // // Was inherited, but make a copy of the field // using (var CSTarget = new CsModel(core)) { if (CSTarget.insert("Content Fields")) { using (var CSSource = new CsModel(core)) { if (CSSource.openRecord("Content Fields", formFieldId)) { CSSource.copyRecord(CSTarget); } } formFieldId = CSTarget.getInteger("ID"); CSTarget.set("ContentID", ContentId); } CSTarget.close(); } ReloadCDef = true; } else if ((!cdefFieldKvp.Value.inherited) && (formFieldInherited)) { // // Was a field, make it inherit from it's parent MetadataController.deleteContentRecord(core, "Content Fields", formFieldId); ReloadCDef = true; } else if ((!cdefFieldKvp.Value.inherited) && (!formFieldInherited)) { // // not inherited, save the field values and mark for a reload // { if (formFieldName.IndexOf(" ") != -1) { // // remoave spaces from new name // StatusMessage = StatusMessage + "<LI>Field [" + formFieldName + "] was renamed [" + GenericController.strReplace(formFieldName, " ", "") + "] because the field name can not include spaces.</LI>"; formFieldName = GenericController.strReplace(formFieldName, " ", ""); } // string SQL = null; // if ((!string.IsNullOrEmpty(formFieldName)) && ((int)formFieldTypeId != 0) && ((cdefFieldKvp.Value.nameLc == "") || (cdefFieldKvp.Value.fieldTypeId == 0))) { // // Create Db field, Field is good but was not before // core.db.createSQLTableField(contentMetadata.tableName, formFieldName, formFieldTypeId); StatusMessage = StatusMessage + "<LI>Field [" + formFieldName + "] was saved to this content definition and a database field was created in [" + contentMetadata.tableName + "].</LI>"; } else if ((string.IsNullOrEmpty(formFieldName)) || ((int)formFieldTypeId == 0)) { // // name blank or type=0 - do nothing but tell them // if (string.IsNullOrEmpty(formFieldName) && ((int)formFieldTypeId == 0)) { ErrorMessage += "<LI>Field number " + (RecordPointer + 1) + " was saved to this content definition but no database field was created because a name and field type are required.</LI>"; } else if (formFieldName == "unnamedfield" + formFieldId.ToString()) { ErrorMessage += "<LI>Field number " + (RecordPointer + 1) + " was saved to this content definition but no database field was created because a field name is required.</LI>"; } else { ErrorMessage += "<LI>Field [" + formFieldName + "] was saved to this content definition but no database field was created because a field type are required.</LI>"; } } else if ((formFieldName == cdefFieldKvp.Value.nameLc) && (formFieldTypeId != cdefFieldKvp.Value.fieldTypeId)) { // // Field Type changed, must be done manually // ErrorMessage += "<LI>Field [" + formFieldName + "] changed type from [" + DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)cdefFieldKvp.Value.fieldTypeId) + "] to [" + DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)formFieldTypeId) + "]. This may have caused a problem converting content.</LI>"; int DataSourceTypeId = core.db.getDataSourceType(); switch (DataSourceTypeId) { case DataSourceTypeODBCMySQL: SQL = "alter table " + contentMetadata.tableName + " change " + cdefFieldKvp.Value.nameLc + " " + cdefFieldKvp.Value.nameLc + " " + core.db.getSQLAlterColumnType(formFieldTypeId) + ";"; break; default: SQL = "alter table " + contentMetadata.tableName + " alter column " + cdefFieldKvp.Value.nameLc + " " + core.db.getSQLAlterColumnType(formFieldTypeId) + ";"; break; } core.db.executeNonQuery(SQL); } SQL = "Update ccFields" + " Set name=" + DbController.encodeSQLText(formFieldName) + ",type=" + (int)formFieldTypeId + ",caption=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaCaption." + RecordPointer)) + ",DefaultValue=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaDefaultValue." + RecordPointer)) + ",EditSortPriority=" + DbController.encodeSQLText(GenericController.encodeText(cp.Doc.GetInteger("dtfaEditSortPriority." + RecordPointer))) + ",Active=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaActive." + RecordPointer)) + ",ReadOnly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaReadOnly." + RecordPointer)) + ",Authorable=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaAuthorable." + RecordPointer)) + ",Required=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaRequired." + RecordPointer)) + ",UniqueName=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaUniqueName." + RecordPointer)) + ",TextBuffered=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaTextBuffered." + RecordPointer)) + ",Password="******"dtfaPassword." + RecordPointer)) + ",HTMLContent=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaHTMLContent." + RecordPointer)) + ",EditTab=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaEditTab." + RecordPointer)) + ",Scramble=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaScramble." + RecordPointer)) + ""; if (core.session.isAuthenticatedAdmin()) { SQL += ",adminonly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaAdminOnly." + RecordPointer)); } if (core.session.isAuthenticatedDeveloper()) { SQL += ",DeveloperOnly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaDeveloperOnly." + RecordPointer)); } SQL += " where ID=" + formFieldId; core.db.executeNonQuery(SQL); ReloadCDef = true; } } break; } } } } core.cache.invalidateAll(); core.clearMetaData(); } if (ToolButton == ButtonAdd) { // // ----- Insert a blank Field var defaultValues = ContentMetadataModel.getDefaultValueDict(core, ContentFieldModel.tableMetadata.contentName); var field = ContentFieldModel.addDefault <ContentFieldModel>(core.cpParent, defaultValues); field.name = "unnamedField" + field.id.ToString(); field.contentId = ContentId; field.editSortPriority = 0; field.save(core.cpParent); ReloadCDef = true; } // // ----- Button Reload CDef if (ToolButton == ButtonSaveandInvalidateCache) { core.cache.invalidateAll(); core.clearMetaData(); } // // ----- Restore Content Autoload site property // if (AllowContentAutoLoad) { cp.Site.SetProperty("AllowContentAutoLoad", AllowContentAutoLoad.ToString()); } // // ----- Cancel or Save, reload CDef and go // if ((ToolButton == ButtonCancel) || (ToolButton == ButtonOK)) { // // ----- Exit back to menu // return(core.webServer.redirect(core.appConfig.adminRoute, "Tool-ConfigureContentEdit, ok or cancel button, go to root.")); } } } // // Print Output string description = "" + HtmlController.p("Use this tool to add or modify content definition fields and the underlying sql table fields.") + ((ContentId.Equals(0)) ? "" : "" + HtmlController.ul("" + HtmlController.li(HtmlController.a("Edit Content", "?aa=0&cid=3&id=" + ContentId + "&tx=&ad=0&asf=1&af=4", "nav-link btn btn-primary"), "nav-item mr-1") + HtmlController.li(HtmlController.a("Edit Records", "?cid=" + ContentId, "nav-link btn btn-primary"), "nav-item mr-1") + HtmlController.li(HtmlController.a("Select Different Fields", "?af=105", "nav-link btn btn-primary"), "nav-item mr-1") , "nav") ); StringBuilderLegacyController Stream = new StringBuilderLegacyController(); Stream.add(AdminUIController.getHeaderTitleDescription("Manage Admin Edit Fields", description)); // // -- status of last operation if (!string.IsNullOrEmpty(StatusMessage)) { Stream.add(AdminUIController.getToolFormRow(core, "<UL>" + StatusMessage + "</UL>")); } // // -- errors with last operations if (!string.IsNullOrEmpty(ErrorMessage)) { Stream.add(HtmlController.div("There was a problem saving these changes" + "<UL>" + ErrorMessage + "</UL>", "ccError")); } if (ReloadCDef) { contentMetadata = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, true, true); } string ButtonList = ButtonCancel + "," + ButtonSelect; if (ContentId == 0) { // // content tables that have edit forms to Configure bool isEmptyList = false; Stream.add(AdminUIController.getToolFormInputRow(core, "Select a Content Definition to Configure", AdminUIEditorController.getLookupContentEditor(core, RequestNameToolContentId, ContentId, ContentMetadataModel.getContentId(core, "Content"), ref isEmptyList, false, "", "", false, ""))); } else { // // Configure edit form Stream.add(HtmlController.inputHidden(RequestNameToolContentId, ContentId)); Stream.add(core.html.getPanelTop()); ButtonList = ButtonCancel + "," + ButtonSave + "," + ButtonOK + "," + ButtonAdd; // // Get a new copy of the content definition // Stream.add(SpanClassAdminNormal + "<P><B>" + contentMetadata.name + "</b></P>"); Stream.add("<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">"); // int ParentContentId = contentMetadata.parentId; bool AllowCDefInherit = false; Processor.Models.Domain.ContentMetadataModel ParentCDef = null; if (ParentContentId == -1) { AllowCDefInherit = false; } else { AllowCDefInherit = true; string ParentContentName = MetadataController.getContentNameByID(core, ParentContentId); ParentCDef = Processor.Models.Domain.ContentMetadataModel.create(core, ParentContentId, true, true); } bool NeedFootNote1 = false; bool NeedFootNote2 = false; if (contentMetadata.fields.Count > 0) { // // -- header row Stream.add("<tr>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\"></td>"); if (!AllowCDefInherit) { Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Inherited*</b></span></td>"); NeedFootNote1 = true; } else { Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Inherited</b></span></td>"); } Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Field</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Caption</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Edit Tab</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Default</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Type</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Edit<br>Order</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Active</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Read<br>Only</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Auth</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Req</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Unique</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Text<br>Buffer</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Pass</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Text<br>Scrm</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>HTML</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Admin<br>Only</b></span></td>"); Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Dev<br>Only</b></span></td>"); Stream.add("</tr>"); RecordCount = 0; // // Build a select template for Type // string TypeSelectTemplate = core.html.selectFromContent("menuname", -1, "Content Field Types", "", "unknown"); // // Index the sort order // List <FieldSortClass> fieldList = new List <FieldSortClass>(); int FieldCount = contentMetadata.fields.Count; foreach (var keyValuePair in contentMetadata.fields) { FieldSortClass fieldSort = new FieldSortClass(); string sortOrder = ""; fieldSort.field = keyValuePair.Value; sortOrder = ""; if (fieldSort.field.active) { sortOrder += "0"; } else { sortOrder += "1"; } if (fieldSort.field.authorable) { sortOrder += "0"; } else { sortOrder += "1"; } sortOrder += fieldSort.field.editTabName + getIntegerString(fieldSort.field.editSortPriority, 10) + getIntegerString(fieldSort.field.id, 10); fieldSort.sort = sortOrder; fieldList.Add(fieldSort); } fieldList.Sort((p1, p2) => p1.sort.CompareTo(p2.sort)); StringBuilderLegacyController StreamValidRows = new StringBuilderLegacyController(); var contentFieldsCdef = Processor.Models.Domain.ContentMetadataModel.createByUniqueName(core, "content fields"); foreach (FieldSortClass fieldsort in fieldList) { StringBuilderLegacyController streamRow = new StringBuilderLegacyController(); bool rowValid = true; // // If Field has name and type, it is locked and can not be changed // bool FieldLocked = (fieldsort.field.nameLc != "") && (fieldsort.field.fieldTypeId != 0); // // put the menu into the current menu format // formFieldId = fieldsort.field.id; streamRow.add(HtmlController.inputHidden("dtfaID." + RecordCount, formFieldId)); streamRow.add("<tr>"); // // edit button // streamRow.add("<td class=\"ccPanelInput\" align=\"left\">" + AdminUIController.getRecordEditAnchorTag(core, contentFieldsCdef, formFieldId) + "</td>"); // // Inherited // if (!AllowCDefInherit) { // // no parent // streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "False</span></td>"); } else if (fieldsort.field.inherited) { // // inherited property // streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + HtmlController.checkbox("dtfaInherited." + RecordCount, fieldsort.field.inherited) + "</td>"); } else { Processor.Models.Domain.ContentFieldMetadataModel parentField = null; // // CDef has a parent, but the field is non-inherited, test for a matching Parent Field // if (ParentCDef == null) { foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> kvp in ParentCDef.fields) { if (kvp.Value.nameLc == fieldsort.field.nameLc) { parentField = kvp.Value; break; } } } if (parentField == null) { streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "False**</span></td>"); NeedFootNote2 = true; } else { streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + HtmlController.checkbox("dtfaInherited." + RecordCount, fieldsort.field.inherited) + "</td>"); } } // // name // bool tmpValue = string.IsNullOrEmpty(fieldsort.field.nameLc); rowValid = rowValid && !tmpValue; streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { streamRow.add(SpanClassAdminSmall + fieldsort.field.nameLc + " </SPAN>"); } else if (FieldLocked) { streamRow.add(SpanClassAdminSmall + fieldsort.field.nameLc + " </SPAN><input type=hidden name=dtfaName." + RecordCount + " value=\"" + fieldsort.field.nameLc + "\">"); } else { streamRow.add(HtmlController.inputText_Legacy(core, "dtfaName." + RecordCount, fieldsort.field.nameLc, 1, 10)); } streamRow.add("</nobr></td>"); // // caption // streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { streamRow.add(SpanClassAdminSmall + fieldsort.field.caption + "</SPAN>"); } else { streamRow.add(HtmlController.inputText_Legacy(core, "dtfaCaption." + RecordCount, fieldsort.field.caption, 1, 10)); } streamRow.add("</nobr></td>"); // // Edit Tab // streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { streamRow.add(SpanClassAdminSmall + fieldsort.field.editTabName + "</SPAN>"); } else { streamRow.add(HtmlController.inputText_Legacy(core, "dtfaEditTab." + RecordCount, fieldsort.field.editTabName, 1, 10)); } streamRow.add("</nobr></td>"); // // default // streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { streamRow.add(SpanClassAdminSmall + GenericController.encodeText(fieldsort.field.defaultValue) + "</SPAN>"); } else { streamRow.add(HtmlController.inputText_Legacy(core, "dtfaDefaultValue." + RecordCount, GenericController.encodeText(fieldsort.field.defaultValue), 1, 10)); } streamRow.add("</nobr></td>"); // // type // rowValid = rowValid && (fieldsort.field.fieldTypeId > 0); streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { using (var csData = new CsModel(core)) { csData.openRecord("Content Field Types", (int)fieldsort.field.fieldTypeId); if (!csData.ok()) { streamRow.add(SpanClassAdminSmall + "Unknown[" + fieldsort.field.fieldTypeId + "]</SPAN>"); } else { streamRow.add(SpanClassAdminSmall + csData.getText("Name") + "</SPAN>"); } } } else if (FieldLocked) { streamRow.add(DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)fieldsort.field.fieldTypeId) + HtmlController.inputHidden("dtfaType." + RecordCount, (int)fieldsort.field.fieldTypeId)); } else { string TypeSelect = TypeSelectTemplate; TypeSelect = GenericController.strReplace(TypeSelect, "menuname", "dtfaType." + RecordCount, 1, 99, 1); TypeSelect = GenericController.strReplace(TypeSelect, "=\"" + fieldsort.field.fieldTypeId + "\"", "=\"" + fieldsort.field.fieldTypeId + "\" selected", 1, 99, 1); streamRow.add(TypeSelect); } streamRow.add("</nobr></td>"); // // sort priority // streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>"); if (fieldsort.field.inherited) { streamRow.add(SpanClassAdminSmall + fieldsort.field.editSortPriority + "</SPAN>"); } else { streamRow.add(HtmlController.inputText_Legacy(core, "dtfaEditSortPriority." + RecordCount, fieldsort.field.editSortPriority.ToString(), 1, 10)); } streamRow.add("</nobr></td>"); // // active // streamRow.add(configureEdit_CheckBox("dtfaActive." + RecordCount, fieldsort.field.active, fieldsort.field.inherited)); // // read only // streamRow.add(configureEdit_CheckBox("dtfaReadOnly." + RecordCount, fieldsort.field.readOnly, fieldsort.field.inherited)); // // authorable // streamRow.add(configureEdit_CheckBox("dtfaAuthorable." + RecordCount, fieldsort.field.authorable, fieldsort.field.inherited)); // // required // streamRow.add(configureEdit_CheckBox("dtfaRequired." + RecordCount, fieldsort.field.required, fieldsort.field.inherited)); // // UniqueName // streamRow.add(configureEdit_CheckBox("dtfaUniqueName." + RecordCount, fieldsort.field.uniqueName, fieldsort.field.inherited)); // // text buffered // streamRow.add(configureEdit_CheckBox("dtfaTextBuffered." + RecordCount, fieldsort.field.textBuffered, fieldsort.field.inherited)); // // password // streamRow.add(configureEdit_CheckBox("dtfaPassword." + RecordCount, fieldsort.field.password, fieldsort.field.inherited)); // // scramble // streamRow.add(configureEdit_CheckBox("dtfaScramble." + RecordCount, fieldsort.field.scramble, fieldsort.field.inherited)); // // HTML Content // streamRow.add(configureEdit_CheckBox("dtfaHTMLContent." + RecordCount, fieldsort.field.htmlContent, fieldsort.field.inherited)); // // Admin Only // if (core.session.isAuthenticatedAdmin()) { streamRow.add(configureEdit_CheckBox("dtfaAdminOnly." + RecordCount, fieldsort.field.adminOnly, fieldsort.field.inherited)); } // // Developer Only // if (core.session.isAuthenticatedDeveloper()) { streamRow.add(configureEdit_CheckBox("dtfaDeveloperOnly." + RecordCount, fieldsort.field.developerOnly, fieldsort.field.inherited)); } // streamRow.add("</tr>"); RecordCount = RecordCount + 1; // // rows are built - put the blank rows at the top // if (!rowValid) { Stream.add(streamRow.text); } else { StreamValidRows.add(streamRow.text); } } Stream.add(StreamValidRows.text); Stream.add(HtmlController.inputHidden("dtfaRecordCount", RecordCount)); } Stream.add("</table>"); // Stream.add(core.html.getPanelBottom()); if (NeedFootNote1) { Stream.add("<br>*Field Inheritance is not allowed because this Content Definition has no parent."); } if (NeedFootNote2) { Stream.add("<br>**This field can not be inherited because the Parent Content Definition does not have a field with the same name."); } } Stream.add(HtmlController.inputHidden("ReloadCDef", ReloadCDef)); // // -- assemble form return(AdminUIController.getToolForm(core, Stream.text, ButtonList)); } catch (Exception ex) { LogController.logError(core, ex); return(toolExceptionMessage); } }
// //============================================================================= // Print the Configure Index Form //============================================================================= // public static string get(CPClass cp, CoreController core, AdminDataModel adminData) { string result = ""; try { // todo refactor out ContentMetadataModel adminContent = adminData.adminContent; string Button = core.docProperties.getText(RequestNameButton); if (Button == ButtonOK) { // // -- Process OK, remove subform from querystring and return empty cp.Doc.AddRefreshQueryString(RequestNameAdminSubForm, ""); return(result); } // // Load Request if (Button == ButtonReset) { // // -- Process reset core.userProperty.setProperty(AdminDataModel.IndexConfigPrefix + adminContent.id.ToString(), ""); } IndexConfigClass IndexConfig = IndexConfigClass.get(core, adminData); int ToolsAction = core.docProperties.getInteger("dta"); int TargetFieldId = core.docProperties.getInteger("fi"); string TargetFieldName = core.docProperties.getText("FieldName"); int ColumnPointer = core.docProperties.getInteger("dtcn"); const string RequestNameAddField = "addfield"; string FieldNameToAdd = GenericController.toUCase(core.docProperties.getText(RequestNameAddField)); const string RequestNameAddFieldId = "addfieldID"; int FieldIDToAdd = core.docProperties.getInteger(RequestNameAddFieldId); bool normalizeSaveLoad = core.docProperties.getBoolean("NeedToReloadConfig"); bool AllowContentAutoLoad = false; StringBuilderLegacyController Stream = new StringBuilderLegacyController(); string Title = "Set Columns: " + adminContent.name; string Description = "Use the icons to add, remove and modify your personal column prefernces for this content (" + adminContent.name + "). Hit OK when complete. Hit Reset to restore your column preferences for this content to the site's default column preferences."; Stream.add(AdminUIController.getHeaderTitleDescription(Title, Description)); // //-------------------------------------------------------------------------------- // Process actions //-------------------------------------------------------------------------------- // if (adminContent.id != 0) { var CDef = ContentMetadataModel.create(core, adminContent.id); int ColumnWidthTotal = 0; if (ToolsAction != 0) { // // Block contentautoload, then force a load at the end // AllowContentAutoLoad = (core.siteProperties.getBoolean("AllowContentAutoLoad", true)); core.siteProperties.setProperty("AllowContentAutoLoad", false); bool reloadMetadata = false; int SourceContentId = 0; string SourceName = null; // // Make sure the FieldNameToAdd is not-inherited, if not, create new field // if (FieldIDToAdd != 0) { foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; if (field.id == FieldIDToAdd) { if (field.inherited) { SourceContentId = field.contentId; SourceName = field.nameLc; // // -- copy the field using (var CSSource = new CsModel(core)) { if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")")) { using (var CSTarget = new CsModel(core)) { if (CSTarget.insert("Content Fields")) { CSSource.copyRecord(CSTarget); CSTarget.set("ContentID", adminContent.id); reloadMetadata = true; } } } } } break; } } } // // Make sure all fields are not-inherited, if not, create new fields // foreach (var column in IndexConfig.columns) { ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; if (field.inherited) { SourceContentId = field.contentId; SourceName = field.nameLc; using (var CSSource = new CsModel(core)) { if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")")) { using (var CSTarget = new CsModel(core)) { if (CSTarget.insert("Content Fields")) { CSSource.copyRecord(CSTarget); CSTarget.set("ContentID", adminContent.id); reloadMetadata = true; } } } } } } // // get current values for Processing // foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } // // ----- Perform any actions first // switch (ToolsAction) { case ToolsActionAddField: { // // Add a field to the index form // if (FieldIDToAdd != 0) { IndexConfigColumnClass column = null; foreach (var columnx in IndexConfig.columns) { columnx.Width = encodeInteger((columnx.Width * 80) / (double)ColumnWidthTotal); } { column = new IndexConfigColumnClass(); using (var csData = new CsModel(core)) { if (csData.openRecord("Content Fields", FieldIDToAdd)) { column.Name = csData.getText("name"); column.Width = 20; } } IndexConfig.columns.Add(column); normalizeSaveLoad = true; } } // break; } case ToolsActionRemoveField: { // // Remove a field to the index form int columnWidthTotal = 0; var dstColumns = new List <IndexConfigColumnClass>(); foreach (var column in IndexConfig.columns) { if (column.Name != TargetFieldName.ToLowerInvariant()) { dstColumns.Add(column); columnWidthTotal += column.Width; } } IndexConfig.columns = dstColumns; normalizeSaveLoad = true; break; } case ToolsActionMoveFieldLeft: { if (IndexConfig.columns.First().Name != TargetFieldName.ToLowerInvariant()) { int listIndex = 0; foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { break; } listIndex += 1; } IndexConfig.columns.swap(listIndex, listIndex - 1); normalizeSaveLoad = true; } break; } case ToolsActionMoveFieldRight: { if (IndexConfig.columns.Last().Name != TargetFieldName.ToLowerInvariant()) { int listIndex = 0; foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { break; } listIndex += 1; } IndexConfig.columns.swap(listIndex, listIndex + 1); normalizeSaveLoad = true; } break; } case ToolsActionExpand: { foreach (var column in IndexConfig.columns) { if (column.Name == TargetFieldName.ToLowerInvariant()) { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1); } else { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9); } } normalizeSaveLoad = true; break; } case ToolsActionContract: { foreach (var column in IndexConfig.columns) { if (column.Name != TargetFieldName.ToLowerInvariant()) { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1); } else { column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9); } } normalizeSaveLoad = true; break; } } // // Reload CDef if it changed // if (reloadMetadata) { core.clearMetaData(); core.cache.invalidateAll(); CDef = ContentMetadataModel.createByUniqueName(core, adminContent.name); } // // save indexconfig // if (normalizeSaveLoad) { // // Normalize the widths of the remaining columns ColumnWidthTotal = 0; foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } foreach (var column in IndexConfig.columns) { column.Width = encodeInteger((1000 * column.Width) / (double)ColumnWidthTotal); } GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig); IndexConfig = IndexConfigClass.get(core, adminData); } } // //-------------------------------------------------------------------------------- // Display the form //-------------------------------------------------------------------------------- // Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>"); Stream.add("<td width=\"5%\"> </td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>10%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>20%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>30%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>40%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>50%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>60%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>70%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>80%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>90%</nobr></td>"); Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>100%</nobr></td>"); Stream.add("<td width=\"4%\" align=\"center\"> </td>"); Stream.add("</tr></table>"); // Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>"); Stream.add("</tr></table>"); // // print the column headers // ColumnWidthTotal = 0; int InheritedFieldCount = 0; if (IndexConfig.columns.Count > 0) { // // Calc total width // foreach (var column in IndexConfig.columns) { ColumnWidthTotal += column.Width; } if (ColumnWidthTotal > 0) { Stream.add("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"90%\">"); // // -- header Stream.add("<tr>"); int ColumnWidth = 0; int fieldId = 0; string Caption = null; foreach (var column in IndexConfig.columns) { // // print column headers - anchored so they sort columns // ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal)); ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; fieldId = field.id; Caption = field.caption; if (field.inherited) { Caption = Caption + "*"; InheritedFieldCount = InheritedFieldCount + 1; } Stream.add("<td class=\"small\" width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\" style=\"background-color:white;border: 1px solid #555;\">" + Caption + "</td>"); } Stream.add("</tr>"); // // -- body Stream.add("<tr>"); foreach (var column in IndexConfig.columns) { // // print column headers - anchored so they sort columns // ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal)); ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()]; fieldId = field.id; Caption = field.caption; if (field.inherited) { Caption = Caption + "*"; InheritedFieldCount = InheritedFieldCount + 1; } int ColumnPtr = 0; string link = "?" + core.doc.refreshQueryString + "&FieldName=" + HtmlController.encodeHtml(field.nameLc) + "&fi=" + fieldId + "&dtcn=" + ColumnPtr + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns; Stream.add("<td width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\">"); Stream.add(HtmlController.div(AdminUIController.getDeleteLink(link + "&dta=" + ToolsActionRemoveField), "text-center")); Stream.add(HtmlController.div(AdminUIController.getArrowRightLink(link + "&dta=" + ToolsActionMoveFieldRight), "text-center")); Stream.add(HtmlController.div(AdminUIController.getArrowLeftLink(link + "&dta=" + ToolsActionMoveFieldLeft), "text-center")); Stream.add(HtmlController.div(AdminUIController.getExpandLink(link + "&dta=" + ToolsActionExpand), "text-center")); Stream.add(HtmlController.div(AdminUIController.getContractLink(link + "&dta=" + ToolsActionContract), "text-center")); Stream.add("</td>"); } Stream.add("</tr>"); Stream.add("</table>"); } } // // ----- If anything was inherited, put up the message // if (InheritedFieldCount > 0) { Stream.add("<p class=\"ccNormal\">* This field was inherited from the Content Definition's Parent. Inherited fields will automatically change when the field in the parent is changed. If you alter these settings, this connection will be broken, and the field will no longer inherit it's properties.</P class=\"ccNormal\">"); } // // ----- now output a list of fields to add // if (CDef.fields.Count == 0) { Stream.add(SpanClassAdminNormal + "This Content Definition has no fields</span><br>"); } else { foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields) { ContentFieldMetadataModel field = keyValuePair.Value; // // display the column if it is not in use if ((IndexConfig.columns.Find(x => x.Name == field.nameLc) == null)) { if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.File) { // // file can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (text file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTML) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode) { // // filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html code file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS) { // // css filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (css file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML) { // // xml filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (xml file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript) { // // javascript filename can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (javascript file field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (long text field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.HTML) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (html field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (image field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect) { // // can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (redirect field)")); } else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.ManyToMany) { // // many to many can not be search Stream.add(HtmlController.div(iconNotAvailable + " " + field.caption + " (many-to-many field)")); } else { // // can be used as column header string link = "?" + core.doc.refreshQueryString + "&fi=" + field.id + "&dta=" + ToolsActionAddField + "&" + RequestNameAddFieldId + "=" + field.id + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns; Stream.add(HtmlController.div(AdminUIController.getPlusLink(link, " " + field.caption))); } } } } } // //-------------------------------------------------------------------------------- // print the content tables that have index forms to Configure //-------------------------------------------------------------------------------- // core.siteProperties.setProperty("AllowContentAutoLoad", GenericController.encodeText(AllowContentAutoLoad)); string Content = "" + Stream.text + HtmlController.inputHidden("cid", adminContent.id.ToString()) + HtmlController.inputHidden(rnAdminForm, "1") + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormSetColumns) + ""; // // -- assemble form result = AdminUIController.getToolForm(core, Content, ButtonOK + "," + ButtonReset); core.html.addTitle(Title); } catch (Exception ex) { LogController.logError(core, ex); } return(result); }