Exemple #1
0
        //
        //=============================================================================
        /// <summary>
        /// Get the link for a Content Record by its ContentRecordKey
        /// </summary>
        /// <param name="ContentRecordKey"></param>
        /// <param name="DefaultLink"></param>
        /// <param name="IncrementClicks"></param>
        /// <returns></returns>
        public string getContentWatchLinkByKey(string ContentRecordKey, string DefaultLink, bool IncrementClicks)
        {
            string result = "";

            try {
                using (var csData = new CsModel(core)) {
                    if (csData.open("Content Watch", "ContentRecordKey=" + DbController.encodeSQLText(ContentRecordKey), "", false, 0, "Link,Clicks"))
                    {
                        result = csData.getText("Link");
                        if (GenericController.encodeBoolean(IncrementClicks))
                        {
                            csData.set("Clicks", csData.getInteger("clicks") + 1);
                        }
                    }
                    else
                    {
                        result = GenericController.encodeText(DefaultLink);
                    }
                }
                return(GenericController.encodeVirtualPath(result, core.appConfig.cdnFileUrl, appRootPath, core.webServer.requestDomain));
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
        }
Exemple #2
0
        //
        //====================================================================================================
        //
        public static string getActiveEditor(CoreController core, string ContentName, int RecordID, string FieldName, string FormElements = "")
        {
            //
            int    ContentID      = 0;
            string Copy           = null;
            string Stream         = "";
            string ButtonPanel    = null;
            string EditorPanel    = null;
            string PanelCopy      = null;
            string intContentName = null;
            int    intRecordId    = 0;
            string strFieldName   = null;

            //
            intContentName = GenericController.encodeText(ContentName);
            intRecordId    = GenericController.encodeInteger(RecordID);
            strFieldName   = GenericController.encodeText(FieldName);
            //
            EditorPanel = "";
            ContentID   = Models.Domain.ContentMetadataModel.getContentId(core, intContentName);
            if ((ContentID < 1) || (intRecordId < 1) || (string.IsNullOrEmpty(strFieldName)))
            {
                PanelCopy   = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>";
                EditorPanel = EditorPanel + core.html.getPanel(PanelCopy);
            }
            else
            {
                intContentName = MetadataController.getContentNameByID(core, ContentID);
                if (!string.IsNullOrEmpty(intContentName))
                {
                    using (var csData = new CsModel(core)) {
                        csData.open(intContentName, "ID=" + intRecordId);
                        if (!csData.ok())
                        {
                            PanelCopy   = SpanClassAdminNormal + "The information you have selected can not be accessed.</span>";
                            EditorPanel = EditorPanel + core.html.getPanel(PanelCopy);
                        }
                        else
                        {
                            Copy        = csData.getText(strFieldName);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("Type", FormTypeActiveEditor);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("cid", ContentID);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("ID", intRecordId);
                            EditorPanel = EditorPanel + HtmlController.inputHidden("fn", strFieldName);
                            EditorPanel = EditorPanel + GenericController.encodeText(FormElements);
                            EditorPanel = EditorPanel + core.html.getFormInputHTML("ContentCopy", Copy, "3", "45", false, true);
                            ButtonPanel = core.html.getPanelButtons(ButtonCancel + "," + ButtonSave);
                            EditorPanel = EditorPanel + ButtonPanel;
                        }
                        csData.close();
                    }
                }
            }
            Stream = Stream + core.html.getPanelHeader("Contensive Active Content Editor");
            Stream = Stream + core.html.getPanel(EditorPanel);
            Stream = HtmlController.form(core, Stream);
            return(Stream);
        }
Exemple #3
0
 //
 //====================================================================================================
 //
 public override bool Open(string contentName, string sqlCriteria, string sortFieldList, bool activeOnly, string selectFieldList, int pageSize, int pageNumber)
 {
     try {
         return(cs.open(contentName, sqlCriteria, sortFieldList, activeOnly, 0, selectFieldList, pageSize, pageNumber));
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
         throw;
     }
 }
Exemple #4
0
        //=============================================================================
        /// <summary>
        /// Go through all Content Definitions and create appropriate tables and fields.
        /// </summary>
        /// <returns></returns>
        public static string get(CoreController core)
        {
            string returnValue = "";

            try {
                Processor.Models.Domain.ContentMetadataModel metadata = null;
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                string[,] ContentNameArray = null;
                int    ContentNameCount = 0;
                string TableName        = null;
                string ButtonList;
                //
                ButtonList = ButtonCancel + "," + ButtonRun;
                //
                Stream.add(AdminUIController.getHeaderTitleDescription("Synchronize Tables to Content Definitions", "This tools goes through all Content Definitions and creates any necessary Tables and Table Fields to support the Definition."));
                //
                if (core.docProperties.getText("Button") != "")
                {
                    //
                    //   Run Tools
                    //
                    Stream.add("Synchronizing Tables to Content Definitions<br>");
                    using (var csData = new CsModel(core)) {
                        csData.open("Content", "", "", false, 0, "id");
                        if (csData.ok())
                        {
                            do
                            {
                                metadata  = Processor.Models.Domain.ContentMetadataModel.create(core, csData.getInteger("id"));
                                TableName = metadata.tableName;
                                Stream.add("Synchronizing Content " + metadata.name + " to table " + TableName + "<br>");
                                using (var db = new DbController(core, metadata.dataSourceName)) {
                                    db.createSQLTable(TableName);
                                    if (metadata.fields.Count > 0)
                                    {
                                        foreach (var keyValuePair in metadata.fields)
                                        {
                                            ContentFieldMetadataModel field = keyValuePair.Value;
                                            Stream.add("...Field " + field.nameLc + "<br>");
                                            db.createSQLTableField(TableName, field.nameLc, field.fieldTypeId);
                                        }
                                    }
                                }
                                csData.goNext();
                            } while (csData.ok());
                            ContentNameArray = csData.getRows();
                            ContentNameCount = ContentNameArray.GetUpperBound(1) + 1;
                        }
                    }
                }
                returnValue = AdminUIController.getToolForm(core, Stream.text, ButtonList);
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnValue);
        }
 //
 //=============================================================================
 // Print the See Also listing
 //   ContentName is the name of the parent table
 //   RecordID is the parent RecordID
 //=============================================================================
 //
 public static string getSeeAlso(CoreController core)
 {
     try {
         if (core.doc.pageController.page.id == 0)
         {
             return(string.Empty);
         }
         int    SeeAlsoCount = 0;
         string result       = "";
         using (var cs = new CsModel(core)) {
             if (cs.open("See Also", "(RecordID=" + core.doc.pageController.page.id + ")"))
             {
                 do
                 {
                     string link = cs.getText("Link");
                     if ((!string.IsNullOrWhiteSpace(link)) && (!link.Contains("://")))
                     {
                         link = core.webServer.requestProtocol + link;
                     }
                     string editAnchorTag = (!core.session.isEditing() ? "" : AdminUIController.getRecordEditAnchorTag(core, "See Also", cs.getInteger("ID")));
                     string pageAnchorTag = HtmlController.a(cs.getText("name"), HtmlController.encodeHtml(link));
                     string brief         = cs.getText("Brief");
                     if (!string.IsNullOrEmpty(brief))
                     {
                         brief = HtmlController.p(brief, "ccListCopy");
                     }
                     result       += HtmlController.li(editAnchorTag + pageAnchorTag + brief, "ccListItem");
                     SeeAlsoCount += 1;
                     cs.goNext();
                 } while (cs.ok());
             }
         }
         if (core.session.isEditing())
         {
             SeeAlsoCount += 1;
             foreach (var AddLink in AdminUIController.getRecordAddAnchorTag(core, "See Also", "RecordID=" + core.doc.pageController.page.id))
             {
                 if (!string.IsNullOrEmpty(AddLink))
                 {
                     result += HtmlController.li(AddLink, "ccEditWrapper ccListItem");
                 }
             }
         }
         if (SeeAlsoCount == 0)
         {
             return(string.Empty);
         }
         return(HtmlController.div(HtmlController.h4("See Also") + HtmlController.ul(result, "ccList"), "ccSeeAlso"));
     } catch (Exception ex) {
         LogController.logError(core, ex);
         return(string.Empty);
     }
 }
Exemple #6
0
        //
        //====================================================================================================
        /// <summary>
        /// Process the active editor form
        /// </summary>
        /// <param name="core"></param>
        public static void processActiveEditor(CoreController core)
        {
            //
            string Button      = null;
            int    ContentID   = 0;
            string ContentName = null;
            int    RecordID    = 0;
            string FieldName   = null;
            string ContentCopy = null;

            //
            Button = core.docProperties.getText("Button");
            switch (Button)
            {
            case ButtonCancel:
                //
                // ----- Do nothing, the form will reload with the previous contents
                //
                break;

            case ButtonSave:
                //
                // ----- read the form fields
                //
                ContentID   = core.docProperties.getInteger("cid");
                RecordID    = core.docProperties.getInteger("id");
                FieldName   = core.docProperties.getText("fn");
                ContentCopy = core.docProperties.getText("ContentCopy");
                //
                // ----- convert editor active edit icons
                //
                ContentCopy = ActiveContentController.processWysiwygResponseForSave(core, ContentCopy);
                //
                // ----- save the content
                //
                ContentName = MetadataController.getContentNameByID(core, ContentID);
                if (!string.IsNullOrEmpty(ContentName))
                {
                    using (var csData = new CsModel(core)) {
                        csData.open(ContentName, "ID=" + DbController.encodeSQLNumber(RecordID), "", false);
                        if (csData.ok())
                        {
                            csData.set(FieldName, ContentCopy);
                        }
                        csData.close();
                    }
                }
                break;
            }
        }
Exemple #7
0
 //
 //=============================================================================
 /// <summary>
 /// Sets the MetaContent subsystem so the next call to main_GetLastMeta... returns the correct value
 /// </summary>
 /// <param name="contentId"></param>
 /// <param name="recordId"></param>
 public void setMetaContent(int contentId, int recordId)
 {
     if ((contentId != 0) && (recordId != 0))
     {
         //
         // -- open meta content record
         string Criteria      = "(ContentID=" + contentId + ")and(RecordID=" + recordId + ")";
         string FieldList     = "ID,Name,MetaDescription,OtherHeadTags,MetaKeywordList";
         string keywordList   = "";
         int    MetaContentId = 0;
         using (var csData = new CsModel(core)) {
             if (csData.open("Meta Content", Criteria, "", false, 0, FieldList))
             {
                 MetaContentId = csData.getInteger("ID");
                 core.html.addTitle(HtmlController.encodeHtml(csData.getText("Name")), "page content");
                 core.html.addMetaDescription(HtmlController.encodeHtml(csData.getText("MetaDescription")), "page content");
                 core.html.addHeadTag(csData.getText("OtherHeadTags"), "page content");
                 keywordList = csData.getText("MetaKeywordList").Replace(Environment.NewLine, ",");
             }
             csData.close();
         }
         //
         // open Keyword List
         using (var csData = new CsModel(core)) {
             string SQL = "select ccMetaKeywords.Name"
                          + " From ccMetaKeywords"
                          + " LEFT JOIN ccMetaKeywordRules on ccMetaKeywordRules.MetaKeywordID=ccMetaKeywords.ID"
                          + " Where ccMetaKeywordRules.MetaContentID=" + MetaContentId;
             csData.openSql(SQL);
             while (csData.ok())
             {
                 keywordList = keywordList + "," + csData.getText("Name");
                 csData.goNext();
             }
             if (!string.IsNullOrEmpty(keywordList))
             {
                 if (keywordList.left(1) == ",")
                 {
                     keywordList = keywordList.Substring(1);
                 }
                 keywordList = HtmlController.encodeHtml(keywordList);
                 core.html.addMetaKeywordList(keywordList, "page content");
             }
         }
     }
 }
 //
 //====================================================================================================
 //
 public override string getLayout(string layoutName)
 {
     try {
         if (string.IsNullOrWhiteSpace(layoutName))
         {
             return(string.Empty);
         }
         using (var cs = new CsModel(cp.core)) {
             cs.open("layouts", "name=" + DbController.encodeSQLText(layoutName), "id", false, cp.core.session.user.id, "layout");
             if (cs.ok())
             {
                 return(cs.getText("layout"));
             }
         }
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
     }
     return(string.Empty);
 }
Exemple #9
0
        //
        //====================================================================================================
        /// <summary>
        /// GetAjaxDefaultAddonOptionStringClass remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string returnHtml = "";

            try {
                using (CoreController core = ((CPClass)cp).core) {
                    using (var csData = new CsModel(core)) {
                        string AddonGuid = core.docProperties.getText("guid");
                        csData.open(AddonModel.tableMetadata.contentName, "ccguid=" + DbController.encodeSQLText(AddonGuid));
                        if (csData.ok())
                        {
                            string addonArgumentList = csData.getText("argumentlist");
                            bool   addonIsInline     = csData.getBoolean("IsInline");
                            string jsonCommand       = "";
                            returnHtml = AddonController.getDefaultAddonOptions(core, addonArgumentList, AddonGuid, addonIsInline, csData.getText("name"), ref jsonCommand);
                        }
                    }
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(returnHtml);
        }
Exemple #10
0
 //
 //=============================================================================
 //
 public void verifyRegistrationFormPage(CoreController core)
 {
     try {
         MetadataController.deleteContentRecords(core, "Form Pages", "name=" + DbController.encodeSQLText("Registration Form"));
         using (var csData = new CsModel(core)) {
             if (!csData.open("Form Pages", "name=" + DbController.encodeSQLText("Registration Form")))
             {
                 //
                 // create Version 1 template - just to main_Get it started
                 //
                 if (csData.insert("Form Pages"))
                 {
                     csData.set("name", "Registration Form");
                     string Copy = ""
                                   + Environment.NewLine + "<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\" width=\"100%\">"
                                   + Environment.NewLine + "{{REPEATSTART}}<tr><td align=right style=\"height:22px;\">{{CAPTION}}&nbsp;</td><td align=left>{{FIELD}}</td></tr>{{REPEATEND}}"
                                   + Environment.NewLine + "<tr><td align=right><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=135 height=1></td><td width=\"100%\">&nbsp;</td></tr>"
                                   + Environment.NewLine + "<tr><td colspan=2>&nbsp;<br>" + core.html.getPanelButtons(ButtonRegister) + "</td></tr>"
                                   + Environment.NewLine + "</table>";
                     csData.set("Body", Copy);
                     Copy = ""
                            + "1"
                            + Environment.NewLine + "Registered\r\ntrue"
                            + Environment.NewLine + "1,First Name,true,FirstName"
                            + Environment.NewLine + "1,Last Name,true,LastName"
                            + Environment.NewLine + "1,Email Address,true,Email"
                            + Environment.NewLine + "1,Phone,true,Phone"
                            + Environment.NewLine + "2,Please keep me informed of news and events,false,Subscribers"
                            + "";
                     csData.set("Instructions", Copy);
                 }
             }
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
        //
        //========================================================================
        /// <summary>
        /// Control edit tab
        /// </summary>
        /// <param name="core"></param>
        /// <param name="adminData"></param>
        /// <returns></returns>
        public static string get(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv)
        {
            string result = null;

            try {
                bool disabled = false;
                //
                var tabPanel = new StringBuilderLegacyController();
                if (string.IsNullOrEmpty(adminData.adminContent.name))
                {
                    //
                    // Content not found or not loaded
                    if (adminData.adminContent.id == 0)
                    {
                        //
                        LogController.logError(core, new GenericException("No content definition was specified for this page"));
                        return(HtmlController.p("No content was specified."));
                    }
                    else
                    {
                        //
                        // Content Definition was not specified
                        LogController.logError(core, new GenericException("The content definition specified for this page [" + adminData.adminContent.id + "] was not found"));
                        return(HtmlController.p("No content was specified."));
                    }
                }
                //
                // ----- Authoring status
                bool FieldRequired = false;


                List <string> TabsFound = new List <string>();
                foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields)
                {
                    ContentFieldMetadataModel field = keyValuePair.Value;
                    if ((field.editTabName.ToLowerInvariant().Equals("control info")) && (field.authorable) && (field.active))
                    {
                        tabPanel.add(EditorRowClass.getEditorRow(core, field, adminData, editorEnv));
                    }
                }
                //
                // ----- RecordID
                {
                    string fieldValue  = (adminData.editRecord.id == 0) ? "(available after save)" : adminData.editRecord.id.ToString();
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, "");
                    string fieldHelp   = "This is the unique number that identifies this record within this content.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Record Number", fieldHelp, true, false, ""));
                }
                //
                // -- Active
                {
                    string htmlId      = "fieldActive";
                    string fieldEditor = HtmlController.checkbox("active", adminData.editRecord.active, htmlId, disabled, "", adminData.editRecord.userReadOnly);
                    string fieldHelp   = "When unchecked, add-ons can ignore this record as if it was temporarily deleted.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Active", fieldHelp, false, false, htmlId));
                }
                //
                // -- GUID
                {
                    string guidSetHtmlId   = "guidSet" + GenericController.getRandomInteger(core).ToString();
                    string guidInputHtmlId = "guidInput" + GenericController.getRandomInteger(core).ToString();
                    string fieldValue      = GenericController.encodeText(adminData.editRecord.fieldsLc["ccguid"].value);
                    string fieldEditor     = "";
                    if (adminData.editRecord.userReadOnly)
                    {
                        //
                        // -- readonly
                        fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, "");
                    }
                    else if (string.IsNullOrEmpty(fieldValue))
                    {
                        //
                        // add a set button
                        string setButton        = "<input id=\"" + guidSetHtmlId + "\" type=\"submit\" value=\"Set\" class=\"btn btn-primary btn-sm\">";
                        string setButtonWrapped = "<div class=\"input-group-append\">" + setButton + "</div>";
                        string inputCell        = AdminUIEditorController.getTextEditor(core, "ccguid", "", false, guidInputHtmlId);
                        fieldEditor = HtmlController.div(inputCell + setButtonWrapped, "input-group");
                        string newGuid   = GenericController.getGUID(true);
                        string onClickFn = "function(e){e.preventDefault();e.stopPropagation();$('#" + guidInputHtmlId + "').val('" + newGuid + "');}";
                        string script    = "$('body').on('click','#" + guidSetHtmlId + "'," + onClickFn + ")";
                        core.html.addScriptCode(script, "Admin edit control-info-tab guid set button");
                    }
                    else
                    {
                        //
                        // field is read-only except for developers
                        fieldEditor = AdminUIEditorController.getTextEditor(core, "ccguid", fieldValue, !core.session.isAuthenticatedDeveloper(), guidInputHtmlId);
                    }
                    string FieldHelp = "This is a unique number that identifies this record globally. A GUID is not required, but when set it should never be changed. GUIDs are used to synchronize records. When empty, you can create a new guid. Only Developers can modify the guid.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "GUID", FieldHelp, false, false, guidInputHtmlId));
                }
                //
                // ----- EID (Encoded ID)
                {
                    if (GenericController.toUCase(adminData.adminContent.tableName) == GenericController.toUCase("ccMembers"))
                    {
                        string htmlId      = "fieldGuid";
                        bool   AllowEId    = (core.siteProperties.getBoolean("AllowLinkLogin", true)) || (core.siteProperties.getBoolean("AllowLinkRecognize", true));
                        string fieldHelp   = "This string is an authentication token that can be used in the URL for the next 15 minutes to log in as this user.";
                        string fieldEditor = "";
                        if (!AllowEId)
                        {
                            fieldEditor = "(link login and link recognize are disabled in security preferences)";
                        }
                        else if (adminData.editRecord.id == 0)
                        {
                            fieldEditor = "(available after save)";
                        }
                        else
                        {
                            string eidQueryString = "eid=" + WebUtility.UrlEncode(SecurityController.encodeToken(core, adminData.editRecord.id, core.doc.profileStartTime.AddMinutes(15)));
                            string sampleUrl      = core.webServer.requestProtocol + core.webServer.requestDomain + "/" + core.siteProperties.serverPageDefault + "?" + eidQueryString;
                            if (core.siteProperties.getBoolean("AllowLinkLogin", true))
                            {
                                fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be logged in as this person.";
                            }
                            else
                            {
                                fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be recognized in as this person, but not logged in.";
                            }
                            fieldHelp  += " To enable, disable or modify this feature, use the security tab on the Preferences page.";
                            fieldHelp  += "<br>For example: " + sampleUrl;
                            fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_eid", eidQueryString, true, htmlId);
                        }
                        tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Member Link Login Querystring", fieldHelp, true, false, htmlId));
                    }
                }
                //
                // ----- Controlling Content
                {
                    string HTMLFieldString          = "";
                    string FieldHelp                = "The content in which this record is stored. This is similar to a database table.";
                    ContentFieldMetadataModel field = null;
                    if (adminData.adminContent.fields.ContainsKey("contentcontrolid"))
                    {
                        field = adminData.adminContent.fields["contentcontrolid"];
                        //
                        // if this record has a parent id, only include CDefs compatible with the parent record - otherwise get all for the table
                        FieldHelp     = GenericController.encodeText(field.helpMessage);
                        FieldRequired = GenericController.encodeBoolean(field.required);
                        int FieldValueInteger = (adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId;
                        if (!core.session.isAuthenticatedAdmin())
                        {
                            HTMLFieldString = HTMLFieldString + HtmlController.inputHidden("contentControlId", FieldValueInteger);
                        }
                        else
                        {
                            string RecordContentName = adminData.editRecord.contentControlId_Name;
                            string TableName2        = MetadataController.getContentTablename(core, RecordContentName);
                            int    TableId           = MetadataController.getRecordIdByUniqueName(core, "Tables", TableName2);
                            //
                            // Test for parentid
                            int  ParentId = 0;
                            bool ContentSupportsParentId = false;
                            if (adminData.editRecord.id > 0)
                            {
                                using (var csData = new CsModel(core)) {
                                    if (csData.openRecord(RecordContentName, adminData.editRecord.id))
                                    {
                                        ContentSupportsParentId = csData.isFieldSupported("ParentID");
                                        if (ContentSupportsParentId)
                                        {
                                            ParentId = csData.getInteger("ParentID");
                                        }
                                    }
                                }
                            }
                            bool IsEmptyList = false;
                            if (core.session.isAuthenticatedAdmin())
                            {
                                //
                                // administrator, and either ( no parentid or does not support it), let them select any content compatible with the table
                                string sqlFilter  = "(ContentTableID=" + TableId + ")";
                                int    contentCId = MetadataController.getRecordIdByUniqueName(core, ContentModel.tableMetadata.contentName, ContentModel.tableMetadata.contentName);
                                HTMLFieldString += AdminUIEditorController.getLookupContentEditor(core, "contentcontrolid", FieldValueInteger, contentCId, ref IsEmptyList, adminData.editRecord.userReadOnly, "", "", true, sqlFilter);
                                FieldHelp        = FieldHelp + " (Only administrators have access to this control. Changing the Controlling Content allows you to change who can author the record, as well as how it is edited.)";
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(HTMLFieldString))
                    {
                        HTMLFieldString = adminData.editRecord.contentControlId_Name;
                    }
                    tabPanel.add(AdminUIController.getEditRow(core, HTMLFieldString, "Controlling Content", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Created By
                {
                    string FieldHelp  = "The people account of the user who created this record.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else if (adminData.editRecord.createdBy == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else
                    {
                        int FieldValueInteger = adminData.editRecord.createdBy.id;
                        if (FieldValueInteger == 0)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            using (var csData = new CsModel(core)) {
                                csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false);
                                if (!csData.ok())
                                {
                                    fieldValue = "#" + FieldValueInteger + ", (deleted)";
                                }
                                else
                                {
                                    fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name");
                                    if (!csData.getBoolean("active"))
                                    {
                                        fieldValue += " (inactive)";
                                    }
                                }
                                csData.close();
                            }
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created By", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Created Date
                {
                    string FieldHelp  = "The date and time when this record was originally created.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else
                    {
                        if (GenericController.encodeDateMinValue(adminData.editRecord.dateAdded) == DateTime.MinValue)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            fieldValue = adminData.editRecord.dateAdded.ToString();
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdDate", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created Date", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Modified By
                {
                    string FieldHelp  = "The people account of the last user who modified this record.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else if (adminData.editRecord.modifiedBy == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else
                    {
                        int FieldValueInteger = adminData.editRecord.modifiedBy.id;
                        if (FieldValueInteger == 0)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            using (var csData = new CsModel(core)) {
                                csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false);
                                if (!csData.ok())
                                {
                                    fieldValue = "#" + FieldValueInteger + ", (deleted)";
                                }
                                else
                                {
                                    fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name");
                                    if (!csData.getBoolean("active"))
                                    {
                                        fieldValue += " (inactive)";
                                    }
                                }
                                csData.close();
                            }
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified By", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Modified Date
                {
                    string FieldHelp  = "The date and time when this record was last modified.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else
                    {
                        if (GenericController.encodeDateMinValue(adminData.editRecord.modifiedDate) == DateTime.MinValue)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            fieldValue = adminData.editRecord.modifiedDate.ToString();
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified Date", FieldHelp, false, false, ""));
                }
                string s = AdminUIController.editTable(tabPanel.text);
                result = AdminUIController.getEditPanel(core, true, "Control Information", "", s);
                adminData.editSectionPanelCount += 1;
                tabPanel = null;
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
        //
        //=============================================================================
        // 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>&nbsp;</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>&nbsp;</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);
        }
        //
        //=============================================================================
        /// <summary>
        /// Remove all Content Fields and rebuild them from the fields found in a table
        /// </summary>
        /// <param name="core"></param>
        /// <returns></returns>
        //
        public static string get(CoreController core)
        {
            string result = "";

            try {
                string Button = core.docProperties.getText("Button");
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                //
                //   print out the submit form
                //
                Stream.add("<table border=\"0\" cellpadding=\"11\" cellspacing=\"0\" width=\"100%\">");
                //
                Stream.add("<tr><td colspan=\"2\">" + SpanClassAdminNormal);
                Stream.add("Delete the current content field definitions for this Content Definition, and recreate them from the table referenced by this content.");
                Stream.add("</SPAN></td></tr>");
                //
                Stream.add("<tr>");
                Stream.add("<TD>" + SpanClassAdminNormal + "Content Name</SPAN></td>");
                Stream.add("<TD><Select name=\"ContentName\">");
                int ItemCount = 0;
                using (var csData = new CsModel(core)) {
                    csData.open("Content", "", "name");
                    while (csData.ok())
                    {
                        Stream.add("<option value=\"" + csData.getText("name") + "\">" + csData.getText("name") + "</option>");
                        ItemCount = ItemCount + 1;
                        csData.goNext();
                    }
                }
                if (ItemCount == 0)
                {
                    Stream.add("<option value=\"-1\">System</option>");
                }
                Stream.add("</select></td>");
                Stream.add("</tr>");
                //
                Stream.add("<tr>");
                Stream.add("<TD>&nbsp;</td>");
                Stream.add("<TD>" + HtmlController.inputSubmit(ButtonCreateFields) + "</td>");
                Stream.add("</tr>");
                //
                Stream.add("<tr>");
                Stream.add("<td width=\"150\"><IMG alt=\"\" src=\"" + cdnPrefix + "Images/spacer.gif\" width=\"150\" height=\"1\"></td>");
                Stream.add("<td width=\"99%\"><IMG alt=\"\" src=\"" + cdnPrefix + "Images/spacer.gif\" width=\"100%\" height=\"1\"></td>");
                Stream.add("</tr>");
                Stream.add("</TABLE>");
                Stream.add("</form>");
                //
                //   process the button if present
                //
                if (Button == ButtonCreateFields)
                {
                    string ContentName = core.docProperties.getText("ContentName");
                    if (string.IsNullOrEmpty(ContentName))
                    {
                        Stream.add("Select a content before submitting. Fields were not changed.");
                    }
                    else
                    {
                        int ContentId = ContentMetadataModel.getContentId(core, ContentName);
                        if (ContentId == 0)
                        {
                            Stream.add("GetContentID failed. Fields were not changed.");
                        }
                        else
                        {
                            MetadataController.deleteContentRecords(core, "Content Fields", "ContentID=" + DbController.encodeSQLNumber(ContentId));
                            //
                            // todo -- looks like the tool code did not come with the migration ?
                            //
                        }
                    }
                }
                string ButtonList = "";
                result = AdminUIController.getToolForm(core, Stream.text, ButtonList);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
        //
        //=============================================================================
        // Normalize the Index page Columns, setting proper values for IndexColumn, etc.
        //=============================================================================
        //
        private static void NormalizeIndexColumns(CoreController core, int ContentID)
        {
            try {
                //
                int ColumnWidth      = 0;
                int ColumnWidthTotal = 0;
                int ColumnCounter    = 0;
                int IndexColumn      = 0;
                using (var csData = new CsModel(core)) {
                    csData.open("Content Fields", "(ContentID=" + ContentID + ")", "IndexColumn");
                    if (!csData.ok())
                    {
                        throw (new GenericException("Unexpected exception")); // Call handleLegacyClassErrors2("NormalizeIndexColumns", "Could not read Content Field Definitions")
                    }
                    else
                    {
                        //
                        // Adjust IndexSortOrder to be 0 based, count by 1
                        //
                        ColumnCounter = 0;
                        while (csData.ok())
                        {
                            IndexColumn = csData.getInteger("IndexColumn");
                            ColumnWidth = csData.getInteger("IndexWidth");
                            if ((IndexColumn == 0) || (ColumnWidth == 0))
                            {
                                csData.set("IndexColumn", 0);
                                csData.set("IndexWidth", 0);
                                csData.set("IndexSortPriority", 0);
                            }
                            else
                            {
                                //
                                // Column appears in Index, clean it up
                                //
                                csData.set("IndexColumn", ColumnCounter);
                                ColumnCounter    += 1;
                                ColumnWidthTotal += ColumnWidth;
                            }
                            csData.goNext();
                        }
                        if (ColumnCounter == 0)
                        {
                            //
                            // No columns found, set name as Column 0, active as column 1
                            //
                            csData.goFirst();
                            while (csData.ok())
                            {
                                switch (GenericController.toUCase(csData.getText("name")))
                                {
                                case "ACTIVE": {
                                    csData.set("IndexColumn", 0);
                                    csData.set("IndexWidth", 20);
                                    ColumnWidthTotal += 20;
                                    break;
                                }

                                case "NAME": {
                                    csData.set("IndexColumn", 1);
                                    csData.set("IndexWidth", 80);
                                    ColumnWidthTotal += 80;
                                    break;
                                }

                                default: {
                                    // do nothing
                                    break;
                                }
                                }
                                csData.goNext();
                            }
                        }
                        //
                        // ----- Now go back and set a normalized Width value
                        //
                        if (ColumnWidthTotal > 0)
                        {
                            csData.goFirst();
                            while (csData.ok())
                            {
                                ColumnWidth = csData.getInteger("IndexWidth");
                                ColumnWidth = encodeInteger((ColumnWidth * 100) / (double)ColumnWidthTotal);
                                csData.set("IndexWidth", ColumnWidth);
                                csData.goNext();
                            }
                        }
                    }
                }
                //
                // ----- now fixup Sort Priority so only visible fields are sorted.
                //
                using (var csData = new CsModel(core)) {
                    csData.open("Content Fields", "(ContentID=" + ContentID + ")", "IndexSortPriority, IndexColumn");
                    if (!csData.ok())
                    {
                        throw (new GenericException("Unexpected exception")); // Call handleLegacyClassErrors2("NormalizeIndexColumns", "Error reading Content Field Definitions")
                    }
                    else
                    {
                        //
                        // Go through all fields, clear Sort Priority if it does not appear
                        //
                        int SortValue     = 0;
                        int SortDirection = 0;
                        SortValue = 0;
                        while (csData.ok())
                        {
                            SortDirection = 0;
                            if (csData.getInteger("IndexColumn") == 0)
                            {
                                csData.set("IndexSortPriority", 0);
                            }
                            else
                            {
                                csData.set("IndexSortPriority", SortValue);
                                SortDirection = csData.getInteger("IndexSortDirection");
                                if (SortDirection == 0)
                                {
                                    SortDirection = 1;
                                }
                                else
                                {
                                    if (SortDirection > 0)
                                    {
                                        SortDirection = 1;
                                    }
                                    else
                                    {
                                        SortDirection = -1;
                                    }
                                }
                                SortValue += 1;
                            }
                            csData.set("IndexSortDirection", SortDirection);
                            csData.goNext();
                        }
                    }
                }
                return;
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
        }
        //====================================================================================================
        /// <summary>
        /// Summarize the page views, excludes non-cookie visits, excludes administrator and developer visits, excludes authenticated users with ExcludeFromReporting
        /// </summary>
        /// <param name="core"></param>
        /// <param name="StartTimeDate"></param>
        /// <param name="EndTimeDate"></param>
        /// <param name="HourDuration"></param>
        /// <param name="BuildVersion"></param>
        /// <param name="OldestVisitSummaryWeCareAbout"></param>
        //
        public static void pageViewSummary(CoreController core, DateTime StartTimeDate, DateTime EndTimeDate, int HourDuration, string BuildVersion, DateTime OldestVisitSummaryWeCareAbout)
        {
            int    hint    = 0;
            string hinttxt = "";

            try {
                XmlDocument LibraryCollections = new XmlDocument();
                XmlDocument LocalCollections   = new XmlDocument();
                XmlDocument Doc = new XmlDocument();
                {
                    hint = 1;
                    DateTime PeriodStart = default;
                    PeriodStart = StartTimeDate;
                    if (PeriodStart < OldestVisitSummaryWeCareAbout)
                    {
                        PeriodStart = OldestVisitSummaryWeCareAbout;
                    }
                    DateTime PeriodDatePtr = default;
                    PeriodDatePtr = PeriodStart.Date;
                    while (PeriodDatePtr < EndTimeDate)
                    {
                        hint = 2;
                        //
                        hinttxt = ", HourDuration [" + HourDuration + "], PeriodDatePtr [" + PeriodDatePtr + "], PeriodDatePtr.AddHours(HourDuration / 2.0) [" + PeriodDatePtr.AddHours(HourDuration / 2.0) + "]";
                        int DateNumber = encodeInteger((PeriodDatePtr - default(DateTime)).TotalDays);
                        // encodeInteger(PeriodDatePtr.AddHours(HourDuration / 2.0).ToOADate());
                        int      TimeNumber = encodeInteger(PeriodDatePtr.TimeOfDay.TotalHours);
                        DateTime DateStart  = default(DateTime);
                        DateStart = PeriodDatePtr.Date;
                        DateTime DateEnd = default(DateTime);
                        DateEnd = PeriodDatePtr.AddHours(HourDuration).Date;
                        string PageTitle = "";
                        int    PageId    = 0;
                        int    PageViews = 0;
                        int    AuthenticatedPageViews = 0;
                        int    MobilePageViews        = 0;
                        int    BotPageViews           = 0;
                        int    NoCookiePageViews      = 0;
                        //
                        // Loop through all the pages hit during this period
                        //
                        //
                        // for now ignore the problem caused by addons like Blogs creating multiple 'pages' within on pageid
                        // One way to handle this is to expect the addon to set something unquie in he page title
                        // then use the title to distinguish a page. The problem with this is the current system puts the
                        // visit number and page number in the name. if we select on district name, they will all be.
                        //
                        using (var csPages = new CsModel(core)) {
                            string sql = "select distinct recordid,pagetitle from ccviewings h"
                                         + " where (h.recordid<>0)"
                                         + " and(h.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                                         + " and (h.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                                         + " and((h.ExcludeFromAnalytics is null)or(h.ExcludeFromAnalytics=0))"
                                         + "order by recordid";
                            hint = 3;
                            if (!csPages.openSql(sql))
                            {
                                //
                                // no hits found - add or update a single record for this day so we know it has been calculated
                                csPages.open("Page View Summary", "(timeduration=" + HourDuration + ")and(DateNumber=" + DateNumber + ")and(TimeNumber=" + TimeNumber + ")and(pageid=" + PageId + ")and(pagetitle=" + DbController.encodeSQLText(PageTitle) + ")");
                                if (!csPages.ok())
                                {
                                    csPages.close();
                                    csPages.insert("Page View Summary");
                                }
                                //
                                if (csPages.ok())
                                {
                                    csPages.set("name", HourDuration + " hr summary for " + DateTime.MinValue.AddDays(DateNumber) + " " + TimeNumber + ":00, " + PageTitle);
                                    csPages.set("DateNumber", DateNumber);
                                    csPages.set("TimeNumber", TimeNumber);
                                    csPages.set("TimeDuration", HourDuration);
                                    csPages.set("PageViews", PageViews);
                                    csPages.set("PageID", PageId);
                                    csPages.set("PageTitle", PageTitle);
                                    csPages.set("AuthenticatedPageViews", AuthenticatedPageViews);
                                    csPages.set("NoCookiePageViews", NoCookiePageViews);
                                    {
                                        csPages.set("MobilePageViews", MobilePageViews);
                                        csPages.set("BotPageViews", BotPageViews);
                                    }
                                }
                                csPages.close();
                                hint = 4;
                            }
                            else
                            {
                                hint = 5;
                                //
                                // add an entry for each page hit on this day
                                //
                                while (csPages.ok())
                                {
                                    PageId    = csPages.getInteger("recordid");
                                    PageTitle = csPages.getText("pagetitle");
                                    string baseCriteria = ""
                                                          + " (h.recordid=" + PageId + ")"
                                                          + " "
                                                          + " and(h.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                                                          + " and(h.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                                                          + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                                                          + " and((h.ExcludeFromAnalytics is null)or(h.ExcludeFromAnalytics=0))"
                                                          + "";
                                    if (!string.IsNullOrEmpty(PageTitle))
                                    {
                                        baseCriteria = baseCriteria + "and(h.pagetitle=" + DbController.encodeSQLText(PageTitle) + ")";
                                    }
                                    hint = 6;
                                    //
                                    // Total Page Views
                                    using (var csPageViews = new CsModel(core)) {
                                        sql = "select count(h.id) as cnt"
                                              + " from ccviewings h left join ccvisits v on h.visitid=v.id"
                                              + " where " + baseCriteria + " and (v.CookieSupport<>0)"
                                              + "";
                                        csPageViews.openSql(sql);
                                        if (csPageViews.ok())
                                        {
                                            PageViews = csPageViews.getInteger("cnt");
                                        }
                                    }
                                    //
                                    // Authenticated Visits
                                    //
                                    using (var csAuthPages = new CsModel(core)) {
                                        sql = "select count(h.id) as cnt"
                                              + " from ccviewings h left join ccvisits v on h.visitid=v.id"
                                              + " where " + baseCriteria + " and(v.CookieSupport<>0)"
                                              + " and(v.visitAuthenticated<>0)"
                                              + "";
                                        csAuthPages.openSql(sql);
                                        if (csAuthPages.ok())
                                        {
                                            AuthenticatedPageViews = csAuthPages.getInteger("cnt");
                                        }
                                    }
                                    //
                                    // No Cookie Page Views
                                    //
                                    using (var csNoCookie = new CsModel(core)) {
                                        sql = "select count(h.id) as NoCookiePageViews"
                                              + " from ccviewings h left join ccvisits v on h.visitid=v.id"
                                              + " where " + baseCriteria + " and((v.CookieSupport=0)or(v.CookieSupport is null))"
                                              + "";
                                        csNoCookie.openSql(sql);
                                        if (csNoCookie.ok())
                                        {
                                            NoCookiePageViews = csNoCookie.getInteger("NoCookiePageViews");
                                        }
                                    }
                                    //
                                    //
                                    // Mobile Visits
                                    using (var csMobileVisits = new CsModel(core)) {
                                        sql = "select count(h.id) as cnt"
                                              + " from ccviewings h left join ccvisits v on h.visitid=v.id"
                                              + " where " + baseCriteria + " and(v.CookieSupport<>0)"
                                              + " and(v.mobile<>0)"
                                              + "";
                                        csMobileVisits.openSql(sql);
                                        if (csMobileVisits.ok())
                                        {
                                            MobilePageViews = csMobileVisits.getInteger("cnt");
                                        }
                                    }
                                    //
                                    // Bot Visits
                                    using (var csBotVisits = new CsModel(core)) {
                                        sql = "select count(h.id) as cnt"
                                              + " from ccviewings h left join ccvisits v on h.visitid=v.id"
                                              + " where " + baseCriteria + " and(v.CookieSupport<>0)"
                                              + " and(v.bot<>0)"
                                              + "";
                                        csBotVisits.openSql(sql);
                                        if (csBotVisits.ok())
                                        {
                                            BotPageViews = csBotVisits.getInteger("cnt");
                                        }
                                    }
                                    //
                                    // Add or update the Visit Summary Record
                                    //
                                    using (var csPVS = new CsModel(core)) {
                                        if (!csPVS.open("Page View Summary", "(timeduration=" + HourDuration + ")and(DateNumber=" + DateNumber + ")and(TimeNumber=" + TimeNumber + ")and(pageid=" + PageId + ")and(pagetitle=" + DbController.encodeSQLText(PageTitle) + ")"))
                                        {
                                            csPVS.insert("Page View Summary");
                                        }
                                        //
                                        if (csPVS.ok())
                                        {
                                            hint = 11;
                                            string PageName = "";
                                            if (string.IsNullOrEmpty(PageTitle))
                                            {
                                                PageName = MetadataController.getRecordName(core, "page content", PageId);
                                                csPVS.set("name", HourDuration + " hr summary for " + DateTime.MinValue.AddDays(DateNumber) + " " + TimeNumber + ":00, " + PageName);
                                                csPVS.set("PageTitle", PageName);
                                            }
                                            else
                                            {
                                                csPVS.set("name", HourDuration + " hr summary for " + DateTime.MinValue.AddDays(DateNumber) + " " + TimeNumber + ":00, " + PageTitle);
                                                csPVS.set("PageTitle", PageTitle);
                                            }
                                            csPVS.set("DateNumber", DateNumber);
                                            csPVS.set("TimeNumber", TimeNumber);
                                            csPVS.set("TimeDuration", HourDuration);
                                            csPVS.set("PageViews", PageViews);
                                            csPVS.set("PageID", PageId);
                                            csPVS.set("AuthenticatedPageViews", AuthenticatedPageViews);
                                            csPVS.set("NoCookiePageViews", NoCookiePageViews);
                                            hint = 12;
                                            {
                                                csPVS.set("MobilePageViews", MobilePageViews);
                                                csPVS.set("BotPageViews", BotPageViews);
                                            }
                                        }
                                    }
                                    csPages.goNext();
                                }
                            }
                        }
                        PeriodDatePtr = PeriodDatePtr.AddHours(HourDuration);
                    }
                }
                //
                return;
            } catch (Exception ex) {
                LogController.logError(core, ex, "hint [" + hint + "]");
            }
        }
Exemple #16
0
        //
        //========================================================================
        //
        public static string getForm_Edit_LinkAliases(CoreController core, AdminDataModel adminData, bool readOnlyField)
        {
            string tempGetForm_Edit_LinkAliases = null;

            try {
                //
                // Link Alias value from the admin data
                //
                string TabDescription = "Link Aliases are URLs used for this content that are more friendly to users and search engines. If you set the Link Alias field, this name will be used on the URL for this page. If you leave the Link Alias blank, the page name will be used. Below is a list of names that have been used previously and are still active. All of these entries when used in the URL will resolve to this page. The first entry in this list will be used to create menus on the site. To move an entry to the top, type it into the Link Alias field and save.";
                string tabContent     = "&nbsp;";
                if (!core.siteProperties.allowLinkAlias)
                {
                    //
                    // Disabled
                    //
                    TabDescription = "<p>The Link Alias feature is currently disabled. To enable Link Aliases, check the box marked 'Allow Link Alias' on the Page Settings page found on the Navigator under 'Settings'.</p><p>" + TabDescription + "</p>";
                }
                else
                {
                    //
                    // Link Alias Field
                    //
                    string linkAlias = "";
                    if (adminData.adminContent.fields.ContainsKey("linkalias"))
                    {
                        linkAlias = GenericController.encodeText(adminData.editRecord.fieldsLc["linkalias"].value);
                    }
                    StringBuilderLegacyController form = new StringBuilderLegacyController();
                    form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Link Alias</td>");
                    form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal);
                    if (readOnlyField)
                    {
                        form.add(linkAlias);
                    }
                    else
                    {
                        form.add(HtmlController.inputText_Legacy(core, "LinkAlias", linkAlias));
                    }
                    form.add("</span></td></tr>");
                    //
                    // Override Duplicates
                    //
                    form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Override Duplicates</td>");
                    form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal);
                    if (readOnlyField)
                    {
                        form.add("No");
                    }
                    else
                    {
                        form.add(HtmlController.checkbox("OverrideDuplicate", false));
                    }
                    form.add("</span></td></tr>");
                    //
                    // Table of old Link Aliases
                    //
                    // todo
                    int    LinkCnt  = 0;
                    string LinkList = "";
                    using (var csData = new CsModel(core)) {
                        csData.open("Link Aliases", "pageid=" + adminData.editRecord.id, "ID Desc", true, 0, "name");
                        while (csData.ok())
                        {
                            LinkList += "<div style=\"margin-left:4px;margin-bottom:4px;\">" + HtmlController.encodeHtml(csData.getText("name")) + "</div>";
                            LinkCnt  += 1;
                            csData.goNext();
                        }
                    }
                    if (LinkCnt > 0)
                    {
                        form.add("<tr><td class=\"ccAdminEditCaption\">" + SpanClassAdminSmall + "Previous Link Alias List</td>");
                        form.add("<td class=\"ccAdminEditField\" align=\"left\" colspan=\"2\">" + SpanClassAdminNormal);
                        form.add(LinkList);
                        form.add("</span></td></tr>");
                    }
                    tabContent = AdminUIController.editTable(form.text);
                }
                //
                tempGetForm_Edit_LinkAliases     = AdminUIController.getEditPanel(core, true, "Link Aliases", TabDescription, tabContent);
                adminData.editSectionPanelCount += 1;
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(tempGetForm_Edit_LinkAliases);
        }
        //
        //=============================================================================
        //   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%\">&nbsp;</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\">&nbsp;</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 + "&nbsp;" + field.caption + " (file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (text file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTML)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html code file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS)
                                {
                                    //
                                    // css filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (css file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML)
                                {
                                    //
                                    // xml filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (xml file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript)
                                {
                                    //
                                    // javascript filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (javascript file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (long text field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.HTML)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (image field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (redirect field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.ManyToMany)
                                {
                                    //
                                    // many to many can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + 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, "&nbsp;" + 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);
        }
        //
        //====================================================================================================
        //
        public static string get(CoreController core)
        {
            string result = "";

            try {
                //
                int    ContentId   = 0;
                string TableName   = "";
                string ContentName = "";
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                string          ButtonList           = null;
                string          Description          = null;
                string          Caption     = null;
                int             NavId       = 0;
                int             ParentNavId = 0;
                DataSourceModel datasource  = DataSourceModel.create(core.cpParent, core.docProperties.getInteger("DataSourceID"));
                //
                ButtonList  = ButtonCancel + "," + ButtonRun;
                Caption     = "Create Content Definition";
                Description = "This tool creates a Content Definition. If the SQL table exists, it is used. If it does not exist, it is created. If records exist in the table with a blank ContentControlID, the ContentControlID will be populated from this new definition. A Navigator Menu entry will be added under Manage Site Content - Advanced.";
                //
                //   print out the submit form
                //
                if (core.docProperties.getText("Button") != "")
                {
                    //
                    // Process input
                    //
                    ContentName = core.docProperties.getText("ContentName");
                    TableName   = core.docProperties.getText("TableName");
                    //
                    Stream.add(SpanClassAdminSmall);
                    Stream.add("<P>Creating content [" + ContentName + "] on table [" + TableName + "] on Datasource [" + datasource.name + "].</P>");
                    if ((!string.IsNullOrEmpty(ContentName)) && (!string.IsNullOrEmpty(TableName)) && (!string.IsNullOrEmpty(datasource.name)))
                    {
                        using (var db = new DbController(core, datasource.name)) {
                            db.createSQLTable(TableName);
                        }
                        ContentMetadataModel.createFromSQLTable(core, datasource, TableName, ContentName);
                        core.cache.invalidateAll();
                        core.clearMetaData();
                        ContentId   = Processor.Models.Domain.ContentMetadataModel.getContentId(core, ContentName);
                        ParentNavId = MetadataController.getRecordIdByUniqueName(core, NavigatorEntryModel.tableMetadata.contentName, "Manage Site Content");
                        if (ParentNavId != 0)
                        {
                            ParentNavId = 0;
                            using (var csSrc = new CsModel(core)) {
                                if (csSrc.open(NavigatorEntryModel.tableMetadata.contentName, "(name=" + DbController.encodeSQLText("Advanced") + ")and(parentid=" + ParentNavId + ")"))
                                {
                                    ParentNavId = csSrc.getInteger("ID");
                                }
                            }
                            if (ParentNavId != 0)
                            {
                                using (var csDest = new CsModel(core)) {
                                    csDest.open(NavigatorEntryModel.tableMetadata.contentName, "(name=" + DbController.encodeSQLText(ContentName) + ")and(parentid=" + NavId + ")");
                                    if (!csDest.ok())
                                    {
                                        csDest.close();
                                        csDest.insert(NavigatorEntryModel.tableMetadata.contentName);
                                    }
                                    if (csDest.ok())
                                    {
                                        csDest.set("name", ContentName);
                                        csDest.set("parentid", ParentNavId);
                                        csDest.set("contentid", ContentId);
                                    }
                                }
                            }
                        }
                        ContentId = ContentMetadataModel.getContentId(core, ContentName);
                        Stream.add("<P>Content Definition was created. An admin menu entry for this definition has been added under 'Site Content', and will be visible on the next page view. Use the [<a href=\"?af=105&ContentID=" + ContentId + "\">Edit Content Definition Fields</a>] tool to review and edit this definition's fields.</P>");
                    }
                    else
                    {
                        Stream.add("<P>Error, a required field is missing. Content not created.</P>");
                    }
                    Stream.add("</SPAN>");
                }
                Stream.add(SpanClassAdminNormal);
                Stream.add("Data Source<br>");
                Stream.add(core.html.selectFromContent("DataSourceID", datasource.id, "Data Sources", "", "Default"));
                Stream.add("<br><br>");
                Stream.add("Content Name<br>");
                Stream.add(HtmlController.inputText_Legacy(core, "ContentName", ContentName, 1, 40));
                Stream.add("<br><br>");
                Stream.add("Table Name<br>");
                Stream.add(HtmlController.inputText_Legacy(core, "TableName", TableName, 1, 40));
                Stream.add("<br><br>");
                Stream.add("</SPAN>");
                result = AdminUIController.getToolBody(core, Caption, ButtonList, "", false, false, Description, "", 10, Stream.text);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
Exemple #19
0
        //
        //====================================================================================================
        //
        public static string exportAscii_GetAsciiExport(CoreController core, string ContentName, int PageSize, int PageNumber)
        {
            string result = "";

            try {
                string Delimiter             = null;
                string Copy                  = "";
                string TableName             = null;
                string FieldNameVariant      = null;
                string FieldName             = null;
                string UcaseFieldName        = null;
                string iContentName          = null;
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                string TestFilename;
                //
                TestFilename = "AsciiExport" + GenericController.getRandomInteger(core) + ".txt";
                //
                iContentName = GenericController.encodeText(ContentName);
                if (PageSize == 0)
                {
                    PageSize = 1000;
                }
                if (PageNumber == 0)
                {
                    PageNumber = 1;
                }
                //
                // ----- Check for special case iContentNames
                //
                core.webServer.setResponseContentType("text/plain");
                core.html.enableOutputBuffer(false);
                TableName = DbController.getDbObjectTableName(MetadataController.getContentTablename(core, iContentName));
                switch (GenericController.toUCase(TableName))
                {
                case "CCMEMBERS":
                    //
                    // ----- People and member content export
                    //
                    if (!core.session.isAuthenticatedAdmin())
                    {
                        sb.Append("Warning: You must be a site administrator to export this information.");
                    }
                    else
                    {
                        using (var csData = new CsModel(core)) {
                            csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber);
                            //
                            // ----- print out the field names
                            //
                            if (csData.ok())
                            {
                                sb.Append("\"EID\"");
                                Delimiter        = ",";
                                FieldNameVariant = csData.getFirstFieldName();
                                while (!string.IsNullOrEmpty(FieldNameVariant))
                                {
                                    FieldName      = GenericController.encodeText(FieldNameVariant);
                                    UcaseFieldName = GenericController.toUCase(FieldName);
                                    if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD"))
                                    {
                                        sb.Append(Delimiter + "\"" + FieldName + "\"");
                                    }
                                    FieldNameVariant = csData.getNextFieldName();
                                }
                                sb.Append(Environment.NewLine);
                            }
                            //
                            // ----- print out the values
                            //
                            while (csData.ok())
                            {
                                if (!(csData.getBoolean("Developer")))
                                {
                                    Copy = SecurityController.encodeToken(core, csData.getInteger("ID"), core.doc.profileStartTime.AddDays(30));
                                    sb.Append("\"" + Copy + "\"");
                                    Delimiter        = ",";
                                    FieldNameVariant = csData.getFirstFieldName();
                                    while (!string.IsNullOrEmpty(FieldNameVariant))
                                    {
                                        FieldName      = GenericController.encodeText(FieldNameVariant);
                                        UcaseFieldName = GenericController.toUCase(FieldName);
                                        if ((UcaseFieldName != "USERNAME") && (UcaseFieldName != "PASSWORD"))
                                        {
                                            Copy = csData.getText(FieldName);
                                            if (!string.IsNullOrEmpty(Copy))
                                            {
                                                Copy = GenericController.strReplace(Copy, "\"", "'");
                                                Copy = GenericController.strReplace(Copy, Environment.NewLine, " ");
                                                Copy = GenericController.strReplace(Copy, "\r", " ");
                                                Copy = GenericController.strReplace(Copy, "\n", " ");
                                            }
                                            sb.Append(Delimiter + "\"" + Copy + "\"");
                                        }
                                        FieldNameVariant = csData.getNextFieldName();
                                    }
                                    sb.Append(Environment.NewLine);
                                }
                                csData.goNext();
                            }
                        }
                    }
                    // End Case
                    break;

                default:
                    //
                    // ----- All other content
                    //
                    if (!core.session.isAuthenticatedContentManager(iContentName))
                    {
                        sb.Append("Error: You must be a content manager to export this data.");
                    }
                    else
                    {
                        using (var csData = new CsModel(core)) {
                            csData.open(iContentName, "", "ID", false, 0, "", PageSize, PageNumber);
                            //
                            // ----- print out the field names
                            if (csData.ok())
                            {
                                Delimiter        = "";
                                FieldNameVariant = csData.getFirstFieldName();
                                while (!string.IsNullOrEmpty(FieldNameVariant))
                                {
                                    core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + FieldNameVariant + "\"");
                                    Delimiter        = ",";
                                    FieldNameVariant = csData.getNextFieldName();
                                }
                                core.wwwFiles.appendFile(TestFilename, Environment.NewLine);
                            }
                            //
                            // ----- print out the values
                            while (csData.ok())
                            {
                                Delimiter        = "";
                                FieldNameVariant = csData.getFirstFieldName();
                                while (!string.IsNullOrEmpty(FieldNameVariant))
                                {
                                    switch (csData.getFieldTypeId(GenericController.encodeText(FieldNameVariant)))
                                    {
                                    case CPContentBaseClass.FieldTypeIdEnum.FileText:
                                    case CPContentBaseClass.FieldTypeIdEnum.FileCSS:
                                    case CPContentBaseClass.FieldTypeIdEnum.FileXML:
                                    case CPContentBaseClass.FieldTypeIdEnum.FileJavascript:
                                    case CPContentBaseClass.FieldTypeIdEnum.FileHTML:
                                    case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode:
                                        Copy = csData.getTextEncoded(GenericController.encodeText(FieldNameVariant));
                                        break;

                                    case CPContentBaseClass.FieldTypeIdEnum.Lookup:
                                        Copy = csData.getText(GenericController.encodeText(FieldNameVariant));
                                        break;

                                    case CPContentBaseClass.FieldTypeIdEnum.Redirect:
                                    case CPContentBaseClass.FieldTypeIdEnum.ManyToMany:
                                        break;

                                    default:
                                        Copy = csData.getText(GenericController.encodeText(FieldNameVariant));
                                        break;
                                    }
                                    if (!string.IsNullOrEmpty(Copy))
                                    {
                                        Copy = GenericController.strReplace(Copy, "\"", "'");
                                        Copy = GenericController.strReplace(Copy, Environment.NewLine, " ");
                                        Copy = GenericController.strReplace(Copy, "\r", " ");
                                        Copy = GenericController.strReplace(Copy, "\n", " ");
                                    }
                                    core.wwwFiles.appendFile(TestFilename, Delimiter + "\"" + Copy + "\"");
                                    Delimiter        = ",";
                                    FieldNameVariant = csData.getNextFieldName();
                                }
                                core.wwwFiles.appendFile(TestFilename, Environment.NewLine);
                                csData.goNext();
                            }
                        }
                    }
                    break;
                }
                result = core.wwwFiles.readFileText(TestFilename);
                core.wwwFiles.deleteFile(TestFilename);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
Exemple #20
0
 //
 //========================================================================
 //
 public static void processJoinForm(CoreController core)
 {
     try {
         string ErrorMessage = "";
         string FirstName    = null;
         string LastName     = null;
         string FullName     = null;
         string Email        = null;
         int    errorCode    = 0;
         //
         string loginForm_Username = "";
         string loginForm_Password = "";
         loginForm_Username = core.docProperties.getText("username");
         loginForm_Password = core.docProperties.getText("password");
         //
         if (!GenericController.encodeBoolean(core.siteProperties.getBoolean("AllowMemberJoin", false)))
         {
             ErrorController.addUserError(core, "This site does not accept public main_MemberShip.");
         }
         else
         {
             if (!core.session.isNewCredentialOK(loginForm_Username, loginForm_Password, ref ErrorMessage, ref errorCode))
             {
                 ErrorController.addUserError(core, ErrorMessage);
             }
             else
             {
                 if (!(!core.doc.userErrorList.Count.Equals(0)))
                 {
                     using (var csData = new CsModel(core)) {
                         csData.open("people", "ID=" + DbController.encodeSQLNumber(core.session.user.id));
                         if (!csData.ok())
                         {
                             LogController.logError(core, new Exception("Could not open the current members account to set the username and password."));
                         }
                         else
                         {
                             if ((csData.getText("username") != "") || (csData.getText("password") != "") || (csData.getBoolean("admin")) || (csData.getBoolean("developer")))
                             {
                                 //
                                 // if the current account can be logged into, you can not join 'into' it
                                 //
                                 core.session.logout();
                             }
                             FirstName = core.docProperties.getText("firstname");
                             LastName  = core.docProperties.getText("lastname");
                             FullName  = FirstName + " " + LastName;
                             Email     = core.docProperties.getText("email");
                             csData.set("FirstName", FirstName);
                             csData.set("LastName", LastName);
                             csData.set("Name", FullName);
                             csData.set("username", loginForm_Username);
                             csData.set("password", loginForm_Password);
                             core.session.authenticateById(core.session.user.id, core.session);
                         }
                         csData.close();
                     }
                 }
             }
         }
         PersonModel.invalidateCacheOfRecord <PersonModel>(core.cpParent, core.session.user.id);
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Exemple #21
0
        //
        //======================================================================================================
        //
        public static void installNode(CoreController core, XmlNode AddonNode, string AddonGuidFieldName, int CollectionID, ref bool return_UpgradeOK, ref string return_ErrorMessage, ref bool collectionIncludesDiagnosticAddons)
        {
            // todo - return bool
            return_ErrorMessage = "";
            return_UpgradeOK    = true;
            try {
                string Basename = GenericController.toLCase(AddonNode.Name);
                if ((Basename == "page") || (Basename == "process") || (Basename == "addon") || (Basename == "add-on"))
                {
                    bool   IsFound   = false;
                    string addonName = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "name", "No Name");
                    if (string.IsNullOrEmpty(addonName))
                    {
                        addonName = "No Name";
                    }
                    string addonGuid = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "guid", addonName);
                    if (string.IsNullOrEmpty(addonGuid))
                    {
                        addonGuid = addonName;
                    }
                    string navTypeName = XmlController.getXMLAttribute(core, ref IsFound, AddonNode, "type", "");
                    int    navTypeId   = getListIndex(navTypeName, navTypeIDList);
                    if (navTypeId == 0)
                    {
                        navTypeId = NavTypeIDAddon;
                    }
                    using (var cs = new CsModel(core)) {
                        string Criteria = "(" + AddonGuidFieldName + "=" + DbController.encodeSQLText(addonGuid) + ")";
                        cs.open(AddonModel.tableMetadata.contentName, Criteria, "", false);
                        if (cs.ok())
                        {
                            //
                            // Update the Addon
                            //
                            LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, GUID match with existing Add-on, Updating Add-on [" + addonName + "], Guid [" + addonGuid + "]");
                        }
                        else
                        {
                            //
                            // not found by GUID - search name against name to update legacy Add-ons
                            //
                            cs.close();
                            Criteria = "(name=" + DbController.encodeSQLText(addonName) + ")and(" + AddonGuidFieldName + " is null)";
                            cs.open(AddonModel.tableMetadata.contentName, Criteria, "", false);
                            if (cs.ok())
                            {
                                LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Add-on name matched an existing Add-on that has no GUID, Updating legacy Aggregate Function to Add-on [" + addonName + "], Guid [" + addonGuid + "]");
                            }
                        }
                        if (!cs.ok())
                        {
                            //
                            // not found by GUID or by name, Insert a new addon
                            //
                            cs.close();
                            cs.insert(AddonModel.tableMetadata.contentName);
                            if (cs.ok())
                            {
                                LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Creating new Add-on [" + addonName + "], Guid [" + addonGuid + "]");
                            }
                        }
                        if (!cs.ok())
                        {
                            //
                            // Could not create new Add-on
                            //
                            LogController.logInfo(core, MethodInfo.GetCurrentMethod().Name + ", UpgradeAppFromLocalCollection, Add-on could not be created, skipping Add-on [" + addonName + "], Guid [" + addonGuid + "]");
                        }
                        else
                        {
                            int addonId = cs.getInteger("ID");
                            MetadataController.deleteContentRecords(core, "Add-on Include Rules", "addonid=" + addonId);
                            MetadataController.deleteContentRecords(core, "Add-on Content Trigger Rules", "addonid=" + addonId);
                            //
                            cs.set("collectionid", CollectionID);
                            cs.set(AddonGuidFieldName, addonGuid);
                            cs.set("name", addonName);
                            cs.set("navTypeId", navTypeId);
                            var ArgumentList = new StringBuilder();
                            var StyleSheet   = new StringBuilder();
                            if (AddonNode.ChildNodes.Count > 0)
                            {
                                foreach (XmlNode Addonfield in AddonNode.ChildNodes)
                                {
                                    if (!(Addonfield is XmlComment))
                                    {
                                        XmlNode PageInterface = Addonfield;
                                        string  fieldName     = null;
                                        string  FieldValue    = "";
                                        switch (GenericController.toLCase(Addonfield.Name))
                                        {
                                        case "activexdll": {
                                            //
                                            // This is handled in BuildLocalCollectionFolder
                                            //
                                            break;
                                        }

                                        case "editors": {
                                            //
                                            // list of editors
                                            //
                                            foreach (XmlNode TriggerNode in Addonfield.ChildNodes)
                                            {
                                                //
                                                int    fieldTypeId = 0;
                                                string fieldType   = null;
                                                switch (GenericController.toLCase(TriggerNode.Name))
                                                {
                                                case "type": {
                                                    fieldType   = TriggerNode.InnerText;
                                                    fieldTypeId = MetadataController.getRecordIdByUniqueName(core, "Content Field Types", fieldType);
                                                    if (fieldTypeId > 0)
                                                    {
                                                        using (var CS2 = new CsModel(core)) {
                                                            Criteria = "(addonid=" + addonId + ")and(contentfieldTypeID=" + fieldTypeId + ")";
                                                            CS2.open("Add-on Content Field Type Rules", Criteria);
                                                            if (!CS2.ok())
                                                            {
                                                                CS2.insert("Add-on Content Field Type Rules");
                                                            }
                                                            if (CS2.ok())
                                                            {
                                                                CS2.set("addonid", addonId);
                                                                CS2.set("contentfieldTypeID", fieldTypeId);
                                                            }
                                                        }
                                                    }
                                                    break;
                                                }

                                                default: {
                                                    // do nothing
                                                    break;
                                                }
                                                }
                                            }
                                            break;
                                        }

                                        case "processtriggers": {
                                            //
                                            // list of events that trigger a process run for this addon
                                            //
                                            foreach (XmlNode TriggerNode in Addonfield.ChildNodes)
                                            {
                                                switch (GenericController.toLCase(TriggerNode.Name))
                                                {
                                                case "contentchange": {
                                                    int    TriggerContentId  = 0;
                                                    string ContentNameorGuid = TriggerNode.InnerText;
                                                    if (string.IsNullOrEmpty(ContentNameorGuid))
                                                    {
                                                        ContentNameorGuid = XmlController.getXMLAttribute(core, ref IsFound, TriggerNode, "guid", "");
                                                        if (string.IsNullOrEmpty(ContentNameorGuid))
                                                        {
                                                            ContentNameorGuid = XmlController.getXMLAttribute(core, ref IsFound, TriggerNode, "name", "");
                                                        }
                                                    }
                                                    using (var CS2 = new CsModel(core)) {
                                                        Criteria = "(ccguid=" + DbController.encodeSQLText(ContentNameorGuid) + ")";
                                                        CS2.open("Content", Criteria);
                                                        if (!CS2.ok())
                                                        {
                                                            Criteria = "(ccguid is null)and(name=" + DbController.encodeSQLText(ContentNameorGuid) + ")";
                                                            CS2.open("content", Criteria);
                                                        }
                                                        if (CS2.ok())
                                                        {
                                                            TriggerContentId = CS2.getInteger("ID");
                                                        }
                                                    }
                                                    if (TriggerContentId != 0)
                                                    {
                                                        using (var CS2 = new CsModel(core)) {
                                                            Criteria = "(addonid=" + addonId + ")and(contentid=" + TriggerContentId + ")";
                                                            CS2.open("Add-on Content Trigger Rules", Criteria);
                                                            if (!CS2.ok())
                                                            {
                                                                CS2.insert("Add-on Content Trigger Rules");
                                                                if (CS2.ok())
                                                                {
                                                                    CS2.set("addonid", addonId);
                                                                    CS2.set("contentid", TriggerContentId);
                                                                }
                                                            }
                                                            CS2.close();
                                                        }
                                                    }
                                                    break;
                                                }

                                                default: {
                                                    // do nothing
                                                    break;
                                                }
                                                }
                                            }
                                            break;
                                        }

                                        case "scripting": {
                                            //
                                            // include add-ons - NOTE - import collections must be run before interfaces
                                            // when importing a collectin that will be used for an include
                                            int    scriptinglanguageid = (int)AddonController.ScriptLanguages.VBScript;
                                            string ScriptingLanguage   = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "language", "").ToLowerInvariant();
                                            if (ScriptingLanguage.Equals("javascript") || ScriptingLanguage.Equals("jscript"))
                                            {
                                                scriptinglanguageid = (int)AddonController.ScriptLanguages.Javascript;
                                            }
                                            cs.set("scriptinglanguageid", scriptinglanguageid);
                                            string ScriptingEntryPoint = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "entrypoint", "");
                                            cs.set("ScriptingEntryPoint", ScriptingEntryPoint);
                                            int ScriptingTimeout = GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "timeout", "5000"));
                                            cs.set("ScriptingTimeout", ScriptingTimeout);
                                            string ScriptingCode = "";
                                            foreach (XmlNode ScriptingNode in Addonfield.ChildNodes)
                                            {
                                                switch (GenericController.toLCase(ScriptingNode.Name))
                                                {
                                                case "code": {
                                                    ScriptingCode += ScriptingNode.InnerText;
                                                    break;
                                                }

                                                default: {
                                                    // do nothing
                                                    break;
                                                }
                                                }
                                            }
                                            cs.set("ScriptingCode", ScriptingCode);
                                            break;
                                        }

                                        case "activexprogramid": {
                                            //
                                            // save program id
                                            //
                                            FieldValue = Addonfield.InnerText;
                                            cs.set("ObjectProgramID", FieldValue);
                                            break;
                                        }

                                        case "navigator": {
                                            //
                                            // create a navigator entry with a parent set to this
                                            //
                                            cs.save();
                                            string menuNameSpace = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "NameSpace", "");
                                            if (!string.IsNullOrEmpty(menuNameSpace))
                                            {
                                                string NavIconTypeString = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "type", "");
                                                if (string.IsNullOrEmpty(NavIconTypeString))
                                                {
                                                    NavIconTypeString = "Addon";
                                                }
                                                BuildController.verifyNavigatorEntry(core, new MetadataMiniCollectionModel.MiniCollectionMenuModel {
                                                        menuNameSpace = menuNameSpace,
                                                        name          = addonName,
                                                        adminOnly     = false,
                                                        developerOnly = false,
                                                        newWindow     = false,
                                                        active        = true,
                                                        addonName     = addonName,
                                                        navIconType   = NavIconTypeString,
                                                        navIconTitle  = addonName
                                                    }, CollectionID);
                                            }
                                            break;
                                        }

                                        case "argument":
                                        case "argumentlist": {
                                            //
                                            // multiple argumentlist elements are concatinated with crlf
                                            ArgumentList.Append(Addonfield.InnerText.Trim(' ') + Environment.NewLine);
                                            break;
                                        }

                                        case "style": {
                                            //
                                            // import exclusive style
                                            //
                                            string NodeName = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "name", "");
                                            string NewValue = encodeText(Addonfield.InnerText).Trim(' ');
                                            if (NewValue.left(1) != "{")
                                            {
                                                NewValue = "{" + NewValue;
                                            }
                                            if (NewValue.Substring(NewValue.Length - 1) != "}")
                                            {
                                                NewValue += "}";
                                            }
                                            StyleSheet.Append(NodeName + " " + NewValue + Environment.NewLine);
                                            break;
                                        }

                                        case "stylesheet":
                                        case "styles": {
                                            //
                                            // import exclusive stylesheet if more then whitespace
                                            //
                                            string test = Addonfield.InnerText;
                                            test = strReplace(test, " ", "");
                                            test = strReplace(test, "\r", "");
                                            test = strReplace(test, "\n", "");
                                            test = strReplace(test, "\t", "");
                                            if (!string.IsNullOrEmpty(test))
                                            {
                                                StyleSheet.Append(Addonfield.InnerText + Environment.NewLine);
                                            }
                                            break;
                                        }

                                        case "template":
                                        case "content":
                                        case "admin": {
                                            //
                                            // these add-ons will be "non-developer only" in navigation
                                            //
                                            fieldName  = Addonfield.Name;
                                            FieldValue = Addonfield.InnerText;
                                            if (!cs.isFieldSupported(fieldName))
                                            {
                                                //
                                                // Bad field name - need to report it somehow
                                                //
                                            }
                                            else
                                            {
                                                cs.set(fieldName, FieldValue);
                                                if (GenericController.encodeBoolean(Addonfield.InnerText))
                                                {
                                                    //
                                                    // if template, admin or content - let non-developers have navigator entry
                                                    //
                                                }
                                            }
                                            break;
                                        }

                                        case "icon": {
                                            //
                                            // icon
                                            //
                                            FieldValue = XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "link", "");
                                            if (!string.IsNullOrEmpty(FieldValue))
                                            {
                                                //
                                                // Icons can be either in the root of the website or in content files
                                                //
                                                FieldValue = GenericController.strReplace(FieldValue, "\\", "/");         // make it a link, not a file
                                                if (GenericController.strInstr(1, FieldValue, "://") != 0)
                                                {
                                                    //
                                                    // the link is an absolute URL, leave it link this
                                                    //
                                                }
                                                else
                                                {
                                                    if (FieldValue.left(1) != "/")
                                                    {
                                                        //
                                                        // make sure it starts with a slash to be consistance
                                                        //
                                                        FieldValue = "/" + FieldValue;
                                                    }
                                                    if (FieldValue.left(17) == "/contensivefiles/")
                                                    {
                                                        //
                                                        // in content files, start link without the slash
                                                        //
                                                        FieldValue = FieldValue.Substring(17);
                                                    }
                                                }
                                                cs.set("IconFilename", FieldValue);
                                                {
                                                    cs.set("IconWidth", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "width", "0")));
                                                    cs.set("IconHeight", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "height", "0")));
                                                    cs.set("IconSprites", GenericController.encodeInteger(XmlController.getXMLAttribute(core, ref IsFound, Addonfield, "sprites", "0")));
                                                }
                                            }
                                            break;
                                        }

                                        case "includeaddon":
                                        case "includeadd-on":
                                        case "include addon":
                                        case "include add-on": {
                                            //
                                            // processed in phase2 of this routine, after all the add-ons are installed
                                            //
                                            break;
                                        }

                                        case "form": {
                                            //
                                            // The value of this node is the xml instructions to create a form. Take then
                                            //   entire node, children and all, and save them in the formxml field.
                                            //   this replaces the settings add-on type, and soo to be report add-on types as well.
                                            //   this removes the ccsettingpages and settingcollectionrules, etc.
                                            //
                                            {
                                                cs.set("formxml", Addonfield.InnerXml);
                                            }
                                            break;
                                        }

                                        case "javascript":
                                        case "javascriptinhead": {
                                            //
                                            // these all translate to JSFilename
                                            //
                                            fieldName = "jsfilename";
                                            cs.set(fieldName, Addonfield.InnerText);

                                            break;
                                        }

                                        case "iniframe": {
                                            //
                                            // typo - field is inframe
                                            //
                                            fieldName = "inframe";
                                            cs.set(fieldName, Addonfield.InnerText);
                                            break;
                                        }

                                        case "diagnostic": {
                                            bool fieldValue = encodeBoolean(Addonfield.InnerText);
                                            cs.set("diagnostic", fieldValue);
                                            collectionIncludesDiagnosticAddons = collectionIncludesDiagnosticAddons || fieldValue;
                                            break;
                                        }

                                        case "category": {
                                            if (!string.IsNullOrWhiteSpace(Addonfield.InnerText))
                                            {
                                                AddonCategoryModel category = DbBaseModel.createByUniqueName <AddonCategoryModel>(core.cpParent, Addonfield.InnerText);
                                                if (category == null)
                                                {
                                                    category      = DbBaseModel.addDefault <AddonCategoryModel>(core.cpParent);
                                                    category.name = Addonfield.InnerText;
                                                    category.save(core.cpParent);
                                                }
                                                cs.set("addonCategoryId", category.id);
                                            }
                                            break;
                                        }

                                        case "instancesettingprimarycontentid": {
                                            int lookupContentId = 0;
                                            if (!string.IsNullOrWhiteSpace(Addonfield.InnerText))
                                            {
                                                ContentModel lookupContent = DbBaseModel.createByUniqueName <ContentModel>(core.cpParent, Addonfield.InnerText);
                                                if (lookupContent != null)
                                                {
                                                    lookupContentId = lookupContent.id;
                                                }
                                            }
                                            cs.set("instancesettingprimarycontentid", lookupContentId);
                                            break;
                                        }

                                        default: {
                                            //
                                            // All the other fields should match the Db fields
                                            //
                                            fieldName  = Addonfield.Name;
                                            FieldValue = Addonfield.InnerText;
                                            if (!cs.isFieldSupported(fieldName))
                                            {
                                                //
                                                // Bad field name - need to report it somehow
                                                //
                                                LogController.logError(core, new ApplicationException("bad field found [" + fieldName + "], in addon node [" + addonName + "], of collection [" + MetadataController.getRecordName(core, "add-on collections", CollectionID) + "]"));
                                            }
                                            else
                                            {
                                                cs.set(fieldName, FieldValue);
                                            }
                                            break;
                                        }
                                        }
                                    }
                                }
                            }
                            cs.set("ArgumentList", ArgumentList.ToString());
                            cs.set("StylesFilename", StyleSheet.ToString());
                        }
                        cs.close();
                    }
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
        }
Exemple #22
0
        //
        //====================================================================================================
        /// <summary>
        /// Process manual changes needed for special cases
        /// </summary>
        /// <param name="isDelete"></param>
        /// <param name="contentName"></param>
        /// <param name="recordId"></param>
        /// <param name="recordName"></param>
        /// <param name="recordParentID"></param>
        /// <param name="useContentWatchLink"></param>
        public static void processAfterSave(CoreController core, bool isDelete, string contentName, int recordId, string recordName, int recordParentID, bool useContentWatchLink)
        {
            try {
                PageContentModel.markReviewed(core.cpParent, recordId);
                string tableName = MetadataController.getContentTablename(core, contentName);
                //
                // -- invalidate the specific cache for this record
                core.cache.invalidateDbRecord(recordId, tableName);
                //
                string tableNameLower = tableName.ToLower(CultureInfo.InvariantCulture);
                if (tableNameLower == AddonCollectionModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- addon collection
                    processAfterSave_AddonCollection(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink);
                }
                else if (tableNameLower == LinkForwardModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- link forward
                    core.routeMapCacheClear();
                }
                else if (tableNameLower == LinkAliasModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- link alias
                    core.routeMapCacheClear();
                }
                else if (tableNameLower == AddonModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- addon
                    core.routeMapCacheClear();
                }
                else if (tableNameLower == PersonModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- PersonModel
                    var person = PersonModel.create <PersonModel>(core.cpParent, recordId);
                    if (person != null)
                    {
                        if (isDelete)
                        {
                            LogController.addSiteActivity(core, "deleting user #" + recordId + " (" + recordName + ")", recordId, person.organizationId);
                        }
                        else
                        {
                            LogController.addSiteActivity(core, "saving changes to user #" + recordId + " (" + recordName + ")", recordId, person.organizationId);
                        }
                    }
                }
                else if (tableNameLower == OrganizationModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- Log Activity for changes to people and organizattions
                    if (isDelete)
                    {
                        LogController.addSiteActivity(core, "deleting organization #" + recordId + " (" + recordName + ")", 0, recordId);
                    }
                    else
                    {
                        LogController.addSiteActivity(core, "saving changes to organization #" + recordId + " (" + recordName + ")", 0, recordId);
                    }
                }
                else if (tableNameLower == SitePropertyModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- Site Properties
                    switch (GenericController.toLCase(recordName))
                    {
                    case "allowlinkalias":
                        PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent);
                        break;

                    case "sectionlandinglink":
                        PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent);
                        break;

                    case Constants._siteproperty_serverPageDefault_name:
                        PageContentModel.invalidateCacheOfTable <PageContentModel>(core.cpParent);
                        break;
                    }
                }
                else if (tableNameLower == PageContentModel.tableMetadata.tableNameLower)
                {
                    //
                    // -- set ChildPagesFound true for parent page
                    if (recordParentID > 0)
                    {
                        if (!isDelete)
                        {
                            core.db.executeNonQuery("update ccpagecontent set ChildPagesfound=1 where ID=" + recordParentID);
                        }
                    }
                    if (isDelete)
                    {
                        //
                        // Clear the Landing page and page not found site properties
                        if (recordId == GenericController.encodeInteger(core.siteProperties.getText("PageNotFoundPageID", "0")))
                        {
                            core.siteProperties.setProperty("PageNotFoundPageID", "0");
                        }
                        if (recordId == core.siteProperties.landingPageID)
                        {
                            core.siteProperties.setProperty("landingPageId", "0");
                        }
                        //
                        // Delete Link Alias entries with this PageID
                        core.db.executeNonQuery("delete from cclinkAliases where PageID=" + recordId);
                    }
                    DbBaseModel.invalidateCacheOfRecord <PageContentModel>(core.cpParent, recordId);
                }
                else if (tableNameLower == LibraryFilesModel.tableMetadata.tableNameLower)
                {
                    //
                    // --
                    processAfterSave_LibraryFiles(core, isDelete, contentName, recordId, recordName, recordParentID, useContentWatchLink);
                }
                //
                // Process Addons marked to trigger a process call on content change
                //
                Dictionary <string, string> instanceArguments;
                bool onChangeAddonsAsync = core.siteProperties.getBoolean("execute oncontentchange addons async", false);
                using (var csData = new CsModel(core)) {
                    int contentId = ContentMetadataModel.getContentId(core, contentName);
                    csData.open("Add-on Content Trigger Rules", "ContentID=" + contentId, "", false, 0, "addonid");
                    string Option_String = null;
                    if (isDelete)
                    {
                        instanceArguments = new Dictionary <string, string> {
                            { "action", "contentdelete" },
                            { "contentid", contentId.ToString() },
                            { "recordid", recordId.ToString() }
                        };
                        Option_String = ""
                                        + Environment.NewLine + "action=contentdelete"
                                        + Environment.NewLine + "contentid=" + contentId
                                        + Environment.NewLine + "recordid=" + recordId + "";
                    }
                    else
                    {
                        instanceArguments = new Dictionary <string, string> {
                            { "action", "contentchange" },
                            { "contentid", contentId.ToString() },
                            { "recordid", recordId.ToString() }
                        };
                        Option_String = ""
                                        + Environment.NewLine + "action=contentchange"
                                        + Environment.NewLine + "contentid=" + contentId
                                        + Environment.NewLine + "recordid=" + recordId + "";
                    }
                    while (csData.ok())
                    {
                        var addon = DbBaseModel.create <AddonModel>(core.cpParent, csData.getInteger("Addonid"));
                        if (addon != null)
                        {
                            if (onChangeAddonsAsync)
                            {
                                //
                                // -- execute addon async
                                core.addon.executeAsync(addon, instanceArguments);
                            }
                            else
                            {
                                //
                                // -- execute addon
                                core.addon.execute(addon, new CPUtilsBaseClass.addonExecuteContext {
                                    addonType             = CPUtilsBaseClass.addonContext.ContextOnContentChange,
                                    backgroundProcess     = false,
                                    errorContextMessage   = "",
                                    argumentKeyValuePairs = instanceArguments
                                });
                            }
                        }
                        csData.goNext();
                    }
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
        }
Exemple #23
0
        //
        //====================================================================================================
        /// <summary>
        /// Send the Member his username and password
        /// </summary>
        /// <param name="Email"></param>
        /// <returns></returns>
        public static bool sendPassword(CoreController core, string Email, ref string returnUserMessage)
        {
            bool result = false;

            returnUserMessage = "";
            try {
                const string passwordChrs       = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345678999999";
                const int    passwordChrsLength = 62;
                //
                string workingEmail = GenericController.encodeText(Email);
                //
                string Message     = "";
                string FromAddress = "";
                string subject     = "";
                if (string.IsNullOrEmpty(workingEmail))
                {
                    ErrorController.addUserError(core, "Please enter your email address before requesting your username and password.");
                }
                else
                {
                    int atPtr = GenericController.strInstr(1, workingEmail, "@");
                    if (atPtr < 2)
                    {
                        //
                        // email not valid
                        //
                        ErrorController.addUserError(core, "Please enter a valid email address before requesting your username and password.");
                    }
                    else
                    {
                        string EMailName = strMid(workingEmail, 1, atPtr - 1);
                        //
                        LogController.addSiteActivity(core, "password request for email " + workingEmail, core.session.user.id, core.session.user.organizationId);
                        //
                        bool allowEmailLogin = core.siteProperties.getBoolean("allowEmailLogin", false);
                        int  recordCnt       = 0;
                        using (var csData = new CsModel(core)) {
                            string sqlCriteria = "(email=" + DbController.encodeSQLText(workingEmail) + ")";
                            sqlCriteria = sqlCriteria + "and((dateExpires is null)or(dateExpires>" + DbController.encodeSQLDate(core.dateTimeNowMockable) + "))";
                            csData.open("People", sqlCriteria, "ID", true, core.session.user.id, "username,password", 1);
                            if (!csData.ok())
                            {
                                //
                                // valid login account for this email not found
                                //
                                if (encodeText(strMid(workingEmail, atPtr + 1)).ToLowerInvariant() == "contensive.com")
                                {
                                    //
                                    // look for expired account to renew
                                    //
                                    csData.close();
                                    csData.open("People", "((email=" + DbController.encodeSQLText(workingEmail) + "))", "ID");
                                    if (csData.ok())
                                    {
                                        //
                                        // renew this old record
                                        //
                                        csData.set("developer", "1");
                                        csData.set("admin", "1");
                                        if (csData.getDate("dateExpires") > DateTime.MinValue)
                                        {
                                            csData.set("dateExpires", core.dateTimeNowMockable.AddDays(7).Date.ToString());
                                        }
                                    }
                                    else
                                    {
                                        //
                                        // inject support record
                                        //
                                        csData.close();
                                        csData.insert("people");
                                        csData.set("name", "Contensive Support");
                                        csData.set("email", workingEmail);
                                        csData.set("developer", "1");
                                        csData.set("admin", "1");
                                        csData.set("dateExpires", core.dateTimeNowMockable.AddDays(7).Date.ToString());
                                    }
                                }
                                else
                                {
                                    ErrorController.addUserError(core, "No current user was found matching this email address. Please try again. ");
                                }
                            }
                            if (csData.ok())
                            {
                                FromAddress = core.siteProperties.getText("EmailFromAddress", "info@" + core.webServer.requestDomain);
                                subject     = "Password Request at " + core.webServer.requestDomain;
                                Message     = "";
                                while (csData.ok())
                                {
                                    bool updateUser = false;
                                    if (string.IsNullOrEmpty(Message))
                                    {
                                        Message  = "This email was sent in reply to a request at " + core.webServer.requestDomain + " for the username and password associated with this email address. ";
                                        Message += "If this request was made by you, please return to the login screen and use the following:\r\n";
                                        Message += Environment.NewLine;
                                    }
                                    else
                                    {
                                        Message += Environment.NewLine;
                                        Message += "Additional user accounts with the same email address: \r\n";
                                    }
                                    //
                                    // username
                                    //
                                    string Username   = csData.getText("Username");
                                    bool   usernameOK = true;
                                    int    Ptr        = 0;
                                    if (!allowEmailLogin)
                                    {
                                        if (Username != Username.Trim())
                                        {
                                            Username   = Username.Trim();
                                            updateUser = true;
                                        }
                                        if (string.IsNullOrEmpty(Username))
                                        {
                                            usernameOK = false;
                                            Ptr        = 0;
                                            while (!usernameOK && (Ptr < 100))
                                            {
                                                Username   = EMailName + encodeInteger(Math.Floor(encodeNumber(Microsoft.VisualBasic.VBMath.Rnd() * 9999)));
                                                usernameOK = !core.session.isLoginOK(Username, "test");
                                                Ptr        = Ptr + 1;
                                            }
                                            if (usernameOK)
                                            {
                                                updateUser = true;
                                            }
                                        }
                                        Message += " username: "******"Password");
                                        if (Password.Trim() != Password)
                                        {
                                            Password   = Password.Trim();
                                            updateUser = true;
                                        }
                                        if (string.IsNullOrEmpty(Password))
                                        {
                                            for (Ptr = 0; Ptr <= 8; Ptr++)
                                            {
                                                int Index = encodeInteger(Microsoft.VisualBasic.VBMath.Rnd() * passwordChrsLength);
                                                Password = Password + strMid(passwordChrs, Index, 1);
                                            }
                                            updateUser = true;
                                        }
                                        Message += " password: "******"username", Username);
                                            csData.set("password", Password);
                                        }
                                        recordCnt = recordCnt + 1;
                                    }
                                    csData.goNext();
                                }
                            }
                        }
                    }
                }
                if (result)
                {
                    string sendStatus = "";
                    EmailController.queueAdHocEmail(core, "Password Email", core.session.user.id, workingEmail, FromAddress, subject, Message, "", "", "", true, false, 0, ref sendStatus);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(result);
        }
        //
        //====================================================================================================
        /// <summary>
        /// add a link alias to a page as the primary
        /// </summary>
        public static void addLinkAlias(CoreController core, string linkAlias, int pageId, string queryStringSuffix, bool overRideDuplicate, bool dupCausesWarning, ref string return_WarningMessage)
        {
            string hint = "";

            try {
                //
                LogController.logTrace(core, "addLinkAlias, enter, linkAlias [" + linkAlias + "], pageID [" + pageId + "], queryStringSuffix [" + queryStringSuffix + "], overRideDuplicate [" + overRideDuplicate + "], dupCausesWarning [" + dupCausesWarning + "]");
                //
                const string SafeStringLc   = "0123456789abcdefghijklmnopqrstuvwxyz-_/.";
                bool         AllowLinkAlias = core.siteProperties.getBoolean("allowLinkAlias", true);
                //
                string normalizedLinkAlias = linkAlias;
                if (!string.IsNullOrEmpty(normalizedLinkAlias))
                {
                    //
                    // remove nonsafe URL characters
                    string Src = normalizedLinkAlias.Replace('\t', ' ');
                    normalizedLinkAlias = "";
                    for (int srcPtr = 0; srcPtr < Src.Length; srcPtr++)
                    {
                        string TestChr = Src.Substring(srcPtr, 1).ToLowerInvariant();
                        if (!SafeStringLc.Contains(TestChr))
                        {
                            TestChr = "\t";
                        }
                        normalizedLinkAlias += TestChr;
                    }
                    int Ptr = 0;
                    while (normalizedLinkAlias.Contains("\t\t") && (Ptr < 100))
                    {
                        normalizedLinkAlias = GenericController.strReplace(normalizedLinkAlias, "\t\t", "\t");
                        Ptr = Ptr + 1;
                    }
                    if (normalizedLinkAlias.Substring(normalizedLinkAlias.Length - 1) == "\t")
                    {
                        normalizedLinkAlias = normalizedLinkAlias.left(normalizedLinkAlias.Length - 1);
                    }
                    if (normalizedLinkAlias.left(1) == "\t")
                    {
                        normalizedLinkAlias = normalizedLinkAlias.Substring(1);
                    }
                    normalizedLinkAlias = GenericController.strReplace(normalizedLinkAlias, "\t", "-");
                    if (!string.IsNullOrEmpty(normalizedLinkAlias))
                    {
                        if (normalizedLinkAlias.left(1) != "/")
                        {
                            normalizedLinkAlias = "/" + normalizedLinkAlias;
                        }
                        //
                        LogController.logTrace(core, "addLinkAlias, normalized normalizedLinkAlias [" + normalizedLinkAlias + "]");
                        //
                        // Make sure there is not a folder or page in the wwwroot that matches this Alias
                        //
                        if (GenericController.toLCase(normalizedLinkAlias) == GenericController.toLCase("/" + core.appConfig.name))
                        {
                            //
                            // This alias points to the cclib folder
                            //
                            if (AllowLinkAlias)
                            {
                                return_WarningMessage = ""
                                                        + "The Link Alias being created (" + normalizedLinkAlias + ") can not be used because there is a virtual directory in your website directory that already uses this name."
                                                        + " Please change it to ensure the Link Alias is unique. To set or change the Link Alias, use the Link Alias tab and select a name not used by another page.";
                            }
                        }
                        else if (GenericController.toLCase(normalizedLinkAlias) == "/cclib")
                        {
                            //
                            // This alias points to the cclib folder
                            //
                            if (AllowLinkAlias)
                            {
                                return_WarningMessage = ""
                                                        + "The Link Alias being created (" + normalizedLinkAlias + ") can not be used because there is a virtual directory in your website directory that already uses this name."
                                                        + " Please change it to ensure the Link Alias is unique. To set or change the Link Alias, use the Link Alias tab and select a name not used by another page.";
                            }
                        }
                        else if (core.wwwFiles.pathExists(core.appConfig.localWwwPath + "\\" + normalizedLinkAlias.Substring(1)))
                        {
                            //
                            // This alias points to a different link, call it an error
                            //
                            if (AllowLinkAlias)
                            {
                                return_WarningMessage = ""
                                                        + "The Link Alias being created (" + normalizedLinkAlias + ") can not be used because there is a folder in your website directory that already uses this name."
                                                        + " Please change it to ensure the Link Alias is unique. To set or change the Link Alias, use the Link Alias tab and select a name not used by another page.";
                            }
                        }
                        else
                        {
                            //
                            // Make sure there is one here for this
                            //
                            bool flushLinkAliasCache = false;
                            int  linkAliasId         = 0;
                            using (var csData = new CsModel(core)) {
                                csData.open("Link Aliases", "name=" + DbController.encodeSQLText(normalizedLinkAlias), "", false, 0, "Name,PageID,QueryStringSuffix");
                                if (!csData.ok())
                                {
                                    //
                                    LogController.logTrace(core, "addLinkAlias, not found in Db, add");
                                    //
                                    // Alias not found, create a Link Aliases
                                    //
                                    csData.close();
                                    csData.insert("Link Aliases");
                                    if (csData.ok())
                                    {
                                        csData.set("Name", normalizedLinkAlias);
                                        csData.set("Pageid", pageId);
                                        csData.set("QueryStringSuffix", queryStringSuffix);
                                        flushLinkAliasCache = true;
                                    }
                                }
                                else
                                {
                                    int    recordPageId = csData.getInteger("pageID");
                                    string recordQss    = csData.getText("QueryStringSuffix").ToLowerInvariant();
                                    //
                                    LogController.logTrace(core, "addLinkAlias, linkalias record found by its name, record recordPageId [" + recordPageId + "], record QueryStringSuffix [" + recordQss + "]");
                                    //
                                    // Alias found, verify the pageid & QueryStringSuffix
                                    //
                                    int  CurrentLinkAliasId = 0;
                                    bool resaveLinkAlias    = false;
                                    if ((recordQss == queryStringSuffix.ToLowerInvariant()) && (pageId == recordPageId))
                                    {
                                        CurrentLinkAliasId = csData.getInteger("id");
                                        //
                                        LogController.logTrace(core, "addLinkAlias, linkalias matches name, pageid, and querystring of linkalias [" + CurrentLinkAliasId + "]");
                                        //
                                        // it maches a current entry for this link alias, if the current entry is not the highest number id,
                                        //   remove it and add this one
                                        //
                                        string sql = "select top 1 id from ccLinkAliases where (pageid=" + recordPageId + ")and(QueryStringSuffix=" + DbController.encodeSQLText(queryStringSuffix) + ") order by id desc";
                                        using (var CS3 = new CsModel(core)) {
                                            CS3.openSql(sql);
                                            if (CS3.ok())
                                            {
                                                resaveLinkAlias = (CurrentLinkAliasId != CS3.getInteger("id"));
                                            }
                                        }
                                        if (resaveLinkAlias)
                                        {
                                            //
                                            LogController.logTrace(core, "addLinkAlias, another link alias matches this pageId and QS. Move this to the top position");
                                            //
                                            core.db.executeNonQuery("delete from ccLinkAliases where id=" + CurrentLinkAliasId);
                                            using (var CS3 = new CsModel(core)) {
                                                CS3.insert("Link Aliases");
                                                if (CS3.ok())
                                                {
                                                    CS3.set("Name", normalizedLinkAlias);
                                                    CS3.set("Pageid", pageId);
                                                    CS3.set("QueryStringSuffix", queryStringSuffix);
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        //
                                        LogController.logTrace(core, "addLinkAlias, linkalias matches name, but pageid and querystring are different. Add this a newest linkalias");
                                        //
                                        // link alias matches, but id/qs does not -- this is either a change, or a duplicate that needs to be blocked
                                        //
                                        if (overRideDuplicate)
                                        {
                                            //
                                            LogController.logTrace(core, "addLinkAlias, overRideDuplicate true, change the Link Alias to the new link");
                                            //
                                            // change the Link Alias to the new link
                                            csData.set("Pageid", pageId);
                                            csData.set("QueryStringSuffix", queryStringSuffix);
                                            flushLinkAliasCache = true;
                                        }
                                        else if (dupCausesWarning)
                                        {
                                            //
                                            LogController.logTrace(core, "addLinkAlias, overRideDuplicate false, dupCausesWarning true, just return user warning if this is from admin");
                                            //
                                            if (recordPageId == 0)
                                            {
                                                int PageContentCId = Models.Domain.ContentMetadataModel.getContentId(core, "Page Content");
                                                return_WarningMessage = ""
                                                                        + "This page has been saved, but the Link Alias could not be created (" + normalizedLinkAlias + ") because it is already in use for another page."
                                                                        + " To use Link Aliasing (friendly page names) for this page, the Link Alias value must be unique on this site. To set or change the Link Alias, clicke the Link Alias tab and select a name not used by another page or a folder in your website.";
                                            }
                                            else
                                            {
                                                int PageContentCid = Models.Domain.ContentMetadataModel.getContentId(core, "Page Content");
                                                return_WarningMessage = ""
                                                                        + "This page has been saved, but the Link Alias could not be created (" + normalizedLinkAlias + ") because it is already in use for another page (<a href=\"?af=4&cid=" + PageContentCid + "&id=" + recordPageId + "\">edit</a>)."
                                                                        + " To use Link Aliasing (friendly page names) for this page, the Link Alias value must be unique. To set or change the Link Alias, click the Link Alias tab and select a name not used by another page or a folder in your website.";
                                            }
                                        }
                                    }
                                }
                                linkAliasId = csData.getInteger("id");
                                csData.close();
                            }
                            if (flushLinkAliasCache)
                            {
                                //
                                // -- invalidate all linkAlias
                                core.cache.invalidateDbRecord(linkAliasId, LinkAliasModel.tableMetadata.tableNameLower);
                                //
                                // -- invalidate routemap
                                Models.Domain.RouteMapModel.invalidateCache(core);
                                core.routeMapCacheClear();
                            }
                        }
                    }
                }
                //
                LogController.logTrace(core, "addLinkAlias, exit");
                //
            } catch (Exception ex) {
                LogController.logError(core, ex, "addLinkAlias exception, hint [" + hint + "]");
                throw;
            }
        }
        //
        //=============================================================================
        // Find and Replace launch tool
        //=============================================================================
        //
        public static string get(CoreController core)
        {
            string result = "";

            try {
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                //
                Stream.add(AdminUIController.getHeaderTitleDescription("Find and Replace", "This tool runs a find and replace operation on content throughout the site."));
                //
                // Process the form
                //
                string Button      = core.docProperties.getText("button");
                bool   IsDeveloper = core.session.isAuthenticatedDeveloper();
                int    RowPtr      = 0;
                string CDefList    = "";
                string FindText    = "";
                string ReplaceText = "";
                string lcName      = null;
                if (Button == ButtonFindAndReplace)
                {
                    int RowCnt = core.docProperties.getInteger("CDefRowCnt");
                    if (RowCnt > 0)
                    {
                        for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                        {
                            if (core.docProperties.getBoolean("Cdef" + RowPtr))
                            {
                                lcName = GenericController.toLCase(core.docProperties.getText("CDefName" + RowPtr));
                                if (IsDeveloper || (lcName == "page content") || (lcName == "copy content") || (lcName == "page templates"))
                                {
                                    CDefList = CDefList + "," + lcName;
                                }
                            }
                        }
                        if (!string.IsNullOrEmpty(CDefList))
                        {
                            CDefList = CDefList.Substring(1);
                        }
                        FindText    = core.docProperties.getText("FindText");
                        ReplaceText = core.docProperties.getText("ReplaceText");
                        //string QS = "app=" + encodeNvaArgument(core.appConfig.name) + "&FindText=" + encodeNvaArgument(FindText) + "&ReplaceText=" + encodeNvaArgument(ReplaceText) + "&CDefNameList=" + encodeNvaArgument(CDefList);
                        var cmdDetail = new TaskModel.CmdDetailClass {
                            addonId   = 0,
                            addonName = "GetForm_FindAndReplace",
                            args      = new System.Collections.Generic.Dictionary <string, string> {
                                { "app", core.appConfig.name },
                                { "FindText", FindText },
                                { "ReplaceText", ReplaceText },
                                { "CDefNameList", CDefList }
                            }
                        };
                        TaskSchedulerController.addTaskToQueue(core, cmdDetail, false);
                        Stream.add("Find and Replace has been requested for content definitions [" + CDefList + "], finding [" + FindText + "] and replacing with [" + ReplaceText + "]");
                    }
                }
                else
                {
                    CDefList    = "Page Content,Copy Content,Page Templates";
                    FindText    = "";
                    ReplaceText = "";
                }
                //
                // Display form
                //
                int FindRows = core.docProperties.getInteger("SQLRows");
                if (FindRows == 0)
                {
                    FindRows = core.userProperty.getInteger("FindAndReplaceFindRows", 1);
                }
                else
                {
                    core.userProperty.setProperty("FindAndReplaceFindRows", FindRows.ToString());
                }
                int ReplaceRows = core.docProperties.getInteger("ReplaceRows");
                if (ReplaceRows == 0)
                {
                    ReplaceRows = core.userProperty.getInteger("FindAndReplaceReplaceRows", 1);
                }
                else
                {
                    core.userProperty.setProperty("FindAndReplaceReplaceRows", ReplaceRows.ToString());
                }
                //
                Stream.add("<div>Find</div>");
                Stream.add("<TEXTAREA NAME=\"FindText\" ROWS=\"" + FindRows + "\" ID=\"FindText\" STYLE=\"width: 800px;\">" + FindText + "</TEXTAREA>");
                Stream.add("&nbsp;<INPUT TYPE=\"Text\" TabIndex=-1 NAME=\"FindTextRows\" SIZE=\"3\" VALUE=\"" + FindRows + "\" ID=\"\"  onchange=\"FindText.rows=FindTextRows.value; return true\"> Rows");
                Stream.add("<br><br>");
                //
                Stream.add("<div>Replace it with</div>");
                Stream.add("<TEXTAREA NAME=\"ReplaceText\" ROWS=\"" + ReplaceRows + "\" ID=\"ReplaceText\" STYLE=\"width: 800px;\">" + ReplaceText + "</TEXTAREA>");
                Stream.add("&nbsp;<INPUT TYPE=\"Text\" TabIndex=-1 NAME=\"ReplaceTextRows\" SIZE=\"3\" VALUE=\"" + ReplaceRows + "\" ID=\"\"  onchange=\"ReplaceText.rows=ReplaceTextRows.value; return true\"> Rows");
                Stream.add("<br><br>");
                string TopHalf    = "";
                string BottomHalf = "";
                //
                using (var csData = new CsModel(core)) {
                    csData.open("Content");
                    while (csData.ok())
                    {
                        string RecordName = csData.getText("Name");
                        lcName = GenericController.toLCase(RecordName);
                        if (IsDeveloper || (lcName == "page content") || (lcName == "copy content") || (lcName == "page templates"))
                        {
                            int RecordId = csData.getInteger("ID");
                            if (GenericController.strInstr(1, "," + CDefList + ",", "," + RecordName + ",") != 0)
                            {
                                TopHalf = TopHalf + "<div>" + HtmlController.checkbox("Cdef" + RowPtr, true) + HtmlController.inputHidden("CDefName" + RowPtr, RecordName) + "&nbsp;" + csData.getText("Name") + "</div>";
                            }
                            else
                            {
                                BottomHalf = BottomHalf + "<div>" + HtmlController.checkbox("Cdef" + RowPtr, false) + HtmlController.inputHidden("CDefName" + RowPtr, RecordName) + "&nbsp;" + csData.getText("Name") + "</div>";
                            }
                        }
                        csData.goNext();
                        RowPtr += 1;
                    }
                }
                Stream.add(TopHalf + BottomHalf + HtmlController.inputHidden("CDefRowCnt", RowPtr));
                //
                result = AdminUIController.getToolForm(core, Stream.text, ButtonCancel + "," + ButtonFindAndReplace);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
Exemple #26
0
        //
        //========================================================================
        //
        public static string get(CoreController core)
        {
            try {
                //
                string   Button        = null;
                string   SQL           = null;
                string   RQS           = null;
                int      PageSize      = 0;
                int      PageNumber    = 0;
                int      TopCount      = 0;
                int      RowPointer    = 0;
                int      DataRowCount  = 0;
                string   PreTableCopy  = "";
                string   PostTableCopy = "";
                int      ColumnPtr     = 0;
                string[] ColCaption    = null;
                string[] ColAlign      = null;
                string[] ColWidth      = null;
                string[,] Cells = null;
                string AdminURL                    = null;
                int    RowCnt                      = 0;
                int    RowPtr                      = 0;
                int    ContentId                   = 0;
                string Format                      = null;
                string Name                        = null;
                string title                       = null;
                string Description                 = null;
                string ButtonCommaListLeft         = null;
                string ButtonCommaListRight        = null;
                int    ContentPadding              = 0;
                string ContentSummary              = "";
                StringBuilderLegacyController Tab0 = new StringBuilderLegacyController();
                StringBuilderLegacyController Tab1 = new StringBuilderLegacyController();
                string Content                     = "";
                string SQLFieldName                = null;
                var    adminMenu                   = new EditTabModel();
                //
                const int ColumnCnt = 4;
                //
                Button    = core.docProperties.getText(RequestNameButton);
                ContentId = core.docProperties.getInteger("ContentID");
                Format    = core.docProperties.getText("Format");
                //
                title                = "Custom Report Manager";
                Description          = "Custom Reports are a way for you to create a snapshot of data to view or download. To request a report, select the Custom Reports tab, check the report(s) you want, and click the [Request Download] Button. When your report is ready, it will be available in the <a href=\"?" + rnAdminForm + "=30\">Download Manager</a>. To create a new custom report, select the Request New Report tab, enter a name and SQL statement, and click the Apply button.";
                ContentPadding       = 0;
                ButtonCommaListLeft  = ButtonCancel + "," + ButtonDelete + "," + ButtonRequestDownload;
                ButtonCommaListRight = "";
                SQLFieldName         = "SQLQuery";
                //
                if (!core.session.isAuthenticatedAdmin())
                {
                    //
                    // Must be a developer
                    //
                    Description = Description + "You can not access the Custom Report Manager because your account is not configured as an administrator.";
                }
                else
                {
                    //
                    // Process Requests
                    //
                    if (!string.IsNullOrEmpty(Button))
                    {
                        switch (Button)
                        {
                        case ButtonCancel:
                            return(core.webServer.redirect("/" + core.appConfig.adminRoute, "CustomReports, Cancel Button Pressed"));

                        case ButtonDelete:
                            RowCnt = core.docProperties.getInteger("RowCnt");
                            if (RowCnt > 0)
                            {
                                for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                                {
                                    if (core.docProperties.getBoolean("Row" + RowPtr))
                                    {
                                        MetadataController.deleteContentRecord(core, "Custom Reports", core.docProperties.getInteger("RowID" + RowPtr));
                                    }
                                }
                            }
                            break;

                        case ButtonRequestDownload:
                        case ButtonApply:
                            //
                            Name = core.docProperties.getText("name");
                            SQL  = core.docProperties.getText(SQLFieldName);
                            if (!string.IsNullOrEmpty(Name) || !string.IsNullOrEmpty(SQL))
                            {
                                if ((string.IsNullOrEmpty(Name)) || (string.IsNullOrEmpty(SQL)))
                                {
                                    Processor.Controllers.ErrorController.addUserError(core, "A name and SQL Query are required to save a new custom report.");
                                }
                                else
                                {
                                    int customReportId = 0;
                                    using (var csData = new CsModel(core)) {
                                        csData.insert("Custom Reports");
                                        if (csData.ok())
                                        {
                                            customReportId = csData.getInteger("id");
                                            csData.set("Name", Name);
                                            csData.set(SQLFieldName, SQL);
                                        }
                                        csData.close();
                                    }
                                    requestDownload(core, customReportId);
                                }
                            }
                            //
                            RowCnt = core.docProperties.getInteger("RowCnt");
                            if (RowCnt > 0)
                            {
                                for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                                {
                                    if (core.docProperties.getBoolean("Row" + RowPtr))
                                    {
                                        int customReportId = core.docProperties.getInteger("RowID" + RowPtr);
                                        using (var csData = new CsModel(core)) {
                                            csData.openRecord("Custom Reports", customReportId);
                                            if (csData.ok())
                                            {
                                                SQL  = csData.getText(SQLFieldName);
                                                Name = csData.getText("Name");
                                            }
                                        }
                                        requestDownload(core, customReportId);
                                    }
                                }
                            }
                            break;
                        }
                    }
                    //
                    // Build Tab0
                    //
                    Tab0.add("<p>The following is a list of available custom reports.</p>");
                    //
                    RQS      = core.doc.refreshQueryString;
                    PageSize = core.docProperties.getInteger(RequestNamePageSize);
                    if (PageSize == 0)
                    {
                        PageSize = 50;
                    }
                    PageNumber = core.docProperties.getInteger(RequestNamePageNumber);
                    if (PageNumber == 0)
                    {
                        PageNumber = 1;
                    }
                    AdminURL = "/" + core.appConfig.adminRoute;
                    TopCount = PageNumber * PageSize;
                    //
                    // Setup Headings
                    //
                    ColCaption = new string[ColumnCnt + 1];
                    ColAlign   = new string[ColumnCnt + 1];
                    ColWidth   = new string[ColumnCnt + 1];
                    Cells      = new string[PageSize + 1, ColumnCnt + 1];
                    //
                    ColCaption[ColumnPtr] = "Select<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=10 height=1>";
                    ColAlign[ColumnPtr]   = "center";
                    ColWidth[ColumnPtr]   = "10";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Name";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "100%";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Created By<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=100 height=1>";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "100";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Date Created<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=150 height=1>";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "150";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    //   Get Data
                    //
                    using (var csData = new CsModel(core)) {
                        RowPointer = 0;
                        if (!csData.open("Custom Reports"))
                        {
                            Cells[0, 1] = "There are no custom reports defined";
                            RowPointer  = 1;
                        }
                        else
                        {
                            DataRowCount = csData.getRowCount();
                            while (csData.ok() && (RowPointer < PageSize))
                            {
                                int customReportId = csData.getInteger("ID");
                                Cells[RowPointer, 0] = HtmlController.checkbox("Row" + RowPointer) + HtmlController.inputHidden("RowID" + RowPointer, customReportId);
                                Cells[RowPointer, 1] = csData.getText("name");
                                Cells[RowPointer, 2] = csData.getText("CreatedBy");
                                Cells[RowPointer, 3] = csData.getDate("DateAdded").ToShortDateString();
                                RowPointer           = RowPointer + 1;
                                csData.goNext();
                            }
                        }
                        csData.close();
                    }
                    string Cell = null;
                    Tab0.add(HtmlController.inputHidden("RowCnt", RowPointer));
                    Cell = AdminUIController.getReport(core, RowPointer, ColCaption, ColAlign, ColWidth, Cells, PageSize, PageNumber, PreTableCopy, PostTableCopy, DataRowCount, "ccPanel");
                    Tab0.add("<div>" + Cell + "</div>");
                    //
                    // Build RequestContent Form
                    //
                    Tab1.add("<p>Use this form to create a new custom report. Enter the SQL Query for the report, and a name that will be used as a caption.</p>");
                    //
                    Tab1.add("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">");
                    //
                    Tab1.add("<tr>");
                    Tab1.add("<td align=right>Name</td>");
                    Tab1.add("<td>" + HtmlController.inputText_Legacy(core, "Name", "", 1, 40) + "</td>");
                    Tab1.add("</tr>");
                    //
                    Tab1.add("<tr>");
                    Tab1.add("<td align=right>SQL Query</td>");
                    Tab1.add("<td>" + HtmlController.inputText_Legacy(core, SQLFieldName, "", 8, 40) + "</td>");
                    Tab1.add("</tr>");
                    //
                    Tab1.add("<tr><td width=\"120\"><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"120\" height=\"1\"></td><td width=\"100%\">&nbsp;</td></tr></table>");
                    //
                    // Build and add tabs
                    //
                    adminMenu.addEntry("Custom&nbsp;Reports", Tab0.text, "ccAdminTab");
                    adminMenu.addEntry("Request&nbsp;New&nbsp;Report", Tab1.text, "ccAdminTab");
                    Content = adminMenu.getTabs(core);
                    //
                }
                //
                core.html.addTitle("Custom Reports");
                //
                return(AdminUIController.getToolBody(core, title, ButtonCommaListLeft, ButtonCommaListRight, true, true, Description, ContentSummary, ContentPadding, Content));
            } catch (Exception ex) {
                LogController.logError(core, ex);
                return(toolExceptionMessage);
            }
        }
        //
        //====================================================================================================
        //
        public static string get(CoreController core)
        {
            string result = "";

            try {
                string Button = core.docProperties.getText("Button");
                if (Button == ButtonCancelAll)
                {
                    //
                    // Cancel to the admin site
                    return(core.webServer.redirect(core.appConfig.adminRoute, "Tools-List, cancel button"));
                }
                //
                const string RequestNameAddField     = "addfield";
                const string RequestNameAddFieldId   = "addfieldID";
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                Stream.add(AdminUIController.getHeaderTitleDescription("Configure Admin Listing", "Configure the Administration Content Listing Page."));
                //
                //   Load Request
                int    ToolsAction          = core.docProperties.getInteger("dta");
                int    TargetFieldID        = core.docProperties.getInteger("fi");
                int    ContentId            = core.docProperties.getInteger(RequestNameToolContentId);
                string FieldNameToAdd       = GenericController.toUCase(core.docProperties.getText(RequestNameAddField));
                int    FieldIDToAdd         = core.docProperties.getInteger(RequestNameAddFieldId);
                string ButtonList           = ButtonCancel + "," + ButtonSelect;
                bool   ReloadCDef           = core.docProperties.getBoolean("ReloadCDef");
                bool   AllowContentAutoLoad = false;
                //
                //--------------------------------------------------------------------------------
                // Process actions
                //--------------------------------------------------------------------------------
                //
                if (ContentId != 0)
                {
                    ButtonList = ButtonCancel + "," + ButtonSaveandInvalidateCache;
                    string ContentName = Local_GetContentNameByID(core, ContentId);
                    Processor.Models.Domain.ContentMetadataModel CDef = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, false, true);
                    string FieldName        = null;
                    int    ColumnWidthTotal = 0;
                    int    fieldId          = 0;
                    if (ToolsAction != 0)
                    {
                        //
                        // Block contentautoload, then force a load at the end
                        //
                        AllowContentAutoLoad = (core.siteProperties.getBoolean("AllowContentAutoLoad", true));
                        core.siteProperties.setProperty("AllowContentAutoLoad", false);
                        int    SourceContentId = 0;
                        string SourceName      = null;
                        //
                        // Make sure the FieldNameToAdd is not-inherited, if not, create new field
                        //
                        if (FieldIDToAdd != 0)
                        {
                            foreach (var keyValuePair in CDef.fields)
                            {
                                Processor.Models.Domain.ContentFieldMetadataModel field = keyValuePair.Value;
                                if (field.id == FieldIDToAdd)
                                {
                                    if (field.inherited)
                                    {
                                        SourceContentId = field.contentId;
                                        SourceName      = field.nameLc;
                                        using (var CSSource = new CsModel(core)) {
                                            CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")");
                                            if (CSSource.ok())
                                            {
                                                using (var CSTarget = new CsModel(core)) {
                                                    CSTarget.insert("Content Fields");
                                                    if (CSTarget.ok())
                                                    {
                                                        CSSource.copyRecord(CSTarget);
                                                        CSTarget.set("ContentID", ContentId);
                                                        ReloadCDef = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        //
                        // Make sure all fields are not-inherited, if not, create new fields
                        //
                        int ColumnNumberMax = 0;
                        foreach (var keyValuePair in CDef.adminColumns)
                        {
                            Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                            Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                            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", ContentId);
                                                ReloadCDef = true;
                                            }
                                        }
                                    }
                                }
                            }
                            if (ColumnNumberMax < field.indexColumn)
                            {
                                ColumnNumberMax = field.indexColumn;
                            }
                            ColumnWidthTotal += adminColumn.Width;
                        }
                        //
                        // ----- Perform any actions first
                        //
                        int  columnPtr      = 0;
                        bool MoveNextColumn = false;
                        switch (ToolsAction)
                        {
                        case ToolsActionAddField: {
                            //
                            // Add a field to the Listing Page
                            //
                            if (FieldIDToAdd != 0)
                            {
                                columnPtr = 0;
                                if (CDef.adminColumns.Count > 1)
                                {
                                    foreach (var keyValuePair in CDef.adminColumns)
                                    {
                                        Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                        Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                        using (var csData = new CsModel(core)) {
                                            csData.openRecord("Content Fields", field.id);
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            csData.set("IndexWidth", Math.Floor((adminColumn.Width * 80) / (double)ColumnWidthTotal));
                                        }
                                        columnPtr += 1;
                                    }
                                }
                                using (var csData = new CsModel(core)) {
                                    if (csData.openRecord("Content Fields", FieldIDToAdd))
                                    {
                                        csData.set("IndexColumn", columnPtr * 10);
                                        csData.set("IndexWidth", 20);
                                        csData.set("IndexSortPriority", 99);
                                        csData.set("IndexSortDirection", 1);
                                    }
                                }
                                ReloadCDef = true;
                            }
                            //
                            break;
                        }

                        case ToolsActionRemoveField: {
                            //
                            // Remove a field to the Listing Page
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                columnPtr = 0;
                                foreach (var keyValuePair in CDef.adminColumns)
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if (fieldId == TargetFieldID)
                                        {
                                            csData.set("IndexColumn", 0);
                                            csData.set("IndexWidth", 0);
                                            csData.set("IndexSortPriority", 0);
                                            csData.set("IndexSortDirection", 0);
                                        }
                                        else
                                        {
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                        }
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            break;
                        }

                        case ToolsActionMoveFieldRight: {
                            //
                            // Move column field right
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                MoveNextColumn = false;
                                columnPtr      = 0;
                                foreach (var keyValuePair in CDef.adminColumns)
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    FieldName = adminColumn.Name;
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if ((CDef.fields[FieldName.ToLowerInvariant()].id == TargetFieldID) && (columnPtr < CDef.adminColumns.Count))
                                        {
                                            csData.set("IndexColumn", (columnPtr + 1) * 10);
                                            //
                                            MoveNextColumn = true;
                                        }
                                        else if (MoveNextColumn)
                                        {
                                            //
                                            // This is one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr - 1) * 10);
                                            MoveNextColumn = false;
                                        }
                                        else
                                        {
                                            //
                                            // not target or one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            MoveNextColumn = false;
                                        }
                                        csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            // end case
                            break;
                        }

                        case ToolsActionMoveFieldLeft: {
                            //
                            // Move Index column field left
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                MoveNextColumn = false;
                                columnPtr      = 0;
                                foreach (var keyValuePair in CDef.adminColumns.Reverse())
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    FieldName = adminColumn.Name;
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if ((field.id == TargetFieldID) && (columnPtr < CDef.adminColumns.Count))
                                        {
                                            csData.set("IndexColumn", (columnPtr - 1) * 10);
                                            //
                                            MoveNextColumn = true;
                                        }
                                        else if (MoveNextColumn)
                                        {
                                            //
                                            // This is one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr + 1) * 10);
                                            MoveNextColumn = false;
                                        }
                                        else
                                        {
                                            //
                                            // not target or one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            MoveNextColumn = false;
                                        }
                                        csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            break;
                        }

                        default: {
                            // do nothing
                            break;
                        }
                        }
                        //
                        // Get a new copy of the content definition
                        //
                        CDef = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, false, true);
                    }
                    if (Button == ButtonSaveandInvalidateCache)
                    {
                        core.cache.invalidateAll();
                        core.clearMetaData();
                        return(core.webServer.redirect("?af=" + AdminFormToolConfigureListing + "&ContentID=" + ContentId, "Tools-ConfigureListing, Save and Invalidate Cache, Go to back ConfigureListing tools"));
                    }
                    //
                    //--------------------------------------------------------------------------------
                    //   Display the form
                    //--------------------------------------------------------------------------------
                    //
                    if (!string.IsNullOrEmpty(ContentName))
                    {
                        Stream.add("<br><br><B>" + ContentName + "</b><br>");
                    }
                    Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>");
                    Stream.add("<td width=\"5%\">&nbsp;</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\">&nbsp;</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=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("</tr></TABLE>");
                    //
                    // print the column headers
                    //
                    ColumnWidthTotal = 0;
                    int InheritedFieldCount = 0;
                    if (CDef.adminColumns.Count > 0)
                    {
                        //
                        // Calc total width
                        //
                        foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                        {
                            ColumnWidthTotal += kvp.Value.Width;
                        }
                        if (ColumnWidthTotal > 0)
                        {
                            Stream.add("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"90%\">");
                            int ColumnCount = 0;
                            foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                            {
                                //
                                // print column headers - anchored so they sort columns
                                //
                                int ColumnWidth = encodeInteger(100 * (kvp.Value.Width / (double)ColumnWidthTotal));
                                FieldName = kvp.Value.Name;
                                var tempVar = CDef.fields[FieldName.ToLowerInvariant()];
                                fieldId = tempVar.id;
                                string Caption = tempVar.caption;
                                if (tempVar.inherited)
                                {
                                    Caption             += "*";
                                    InheritedFieldCount += 1;
                                }
                                string AStart = "<A href=\"" + core.webServer.requestPage + "?" + RequestNameToolContentId + "=" + ContentId + "&af=" + AdminFormToolConfigureListing + "&fi=" + fieldId + "&dtcn=" + ColumnCount;
                                Stream.add("<td width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\">" + SpanClassAdminNormal + Caption + "<br>");
                                Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.GIF\" width=\"100%\" height=\"1\">");
                                Stream.add(AStart + "&dta=" + ToolsActionRemoveField + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonDeleteUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionMoveFieldRight + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonMoveRightUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionMoveFieldLeft + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonMoveLeftUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionSetAZ + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonSortazUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionSetZA + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonSortzaUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionExpand + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonOpenUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionContract + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonCloseUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A>");
                                Stream.add("</SPAN></td>");
                                ColumnCount += 1;
                            }
                            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
                    {
                        Stream.add(SpanClassAdminNormal + "<br>");
                        bool skipField = false;
                        foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> keyValuePair in CDef.fields)
                        {
                            Processor.Models.Domain.ContentFieldMetadataModel field = keyValuePair.Value;
                            //
                            // test if this column is in use
                            //
                            skipField = false;
                            if (CDef.adminColumns.Count > 0)
                            {
                                foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                                {
                                    if (field.nameLc == kvp.Value.Name)
                                    {
                                        skipField = true;
                                        break;
                                    }
                                }
                            }
                            //
                            // display the column if it is not in use
                            //
                            if (skipField)
                            {
                                if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (text file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (css file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (xml file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (javascript file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (long text field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (image field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (redirect field)<br>");
                                }
                                else
                                {
                                    //
                                    // can be used as column header
                                    //
                                    Stream.add("<A href=\"" + core.webServer.requestPage + "?" + RequestNameToolContentId + "=" + ContentId + "&af=" + AdminFormToolConfigureListing + "&fi=" + field.id + "&dta=" + ToolsActionAddField + "&" + RequestNameAddFieldId + "=" + field.id + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonAddUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A> " + field.caption + "<br>");
                                }
                            }
                        }
                    }
                }
                //
                //--------------------------------------------------------------------------------
                // print the content tables that have Listing Pages to Configure
                //--------------------------------------------------------------------------------
                //
                string FormPanel = SpanClassAdminNormal + "Select a Content Definition to Configure its Listing Page<br>";
                FormPanel += core.html.selectFromContent("ContentID", ContentId, "Content");
                Stream.add(core.html.getPanel(FormPanel));
                core.siteProperties.setProperty("AllowContentAutoLoad", AllowContentAutoLoad);
                Stream.add(HtmlController.inputHidden("ReloadCDef", ReloadCDef));
                result = AdminUIController.getToolForm(core, Stream.text, ButtonList);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
Exemple #28
0
 //
 //=========================================================================================
 // Summarize the visits
 //   excludes non-cookie visits
 //   excludes administrator and developer visits
 //   excludes authenticated users with ExcludeFromReporting
 //
 // Average time on site
 //
 //   Example data
 //   Pages       TimeToLastHit
 //   1           0           - hit 1 page, start time = last time
 //   10          3510        - hit 10 pages, first hit time - last hit time = 3510
 //   2           30          - hit 2 pages, first hit time - last hit time = 30
 //
 // AveReadTime is the average time spent reading pages
 //   this is calculated from the multi-page visits only
 //   = MultiPageTimeToLastHitSum / ( MultiPageHitCnt - MultiPageVisitCnt )
 //   = ( 3510 + 30 ) / ((10+2) - 2 )
 //   = 354
 //
 // TotalTimeOnSite is the total time people spent reading pages
 //   There are two parts:
 //     1) the TimeToLastHit, which covers all but the last hit of each visit
 //     2) assume the last hit of each visit is the AveReadTime
 //   = MultiPageTimeToLastHitSum + ( AveReadTime * VisitCnt )
 //   = ( 3510 + 30 ) + ( 354 * 3 )
 //   = 4602
 //
 // AveTimeOnSite
 //   = TotalTimeOnSite / TotalHits
 //   = 4602 / 3
 //   = 1534
 //
 //=========================================================================================
 //
 private static void summarizePeriod(CoreController core, HouseKeepEnvironmentModel env, DateTime StartTimeDate, DateTime EndTimeDate, int HourDuration, string BuildVersion, DateTime OldestVisitSummaryWeCareAbout)
 {
     try {
         //
         if (string.CompareOrdinal(BuildVersion, CoreController.codeVersion()) >= 0)
         {
             DateTime PeriodStart = default(DateTime);
             PeriodStart = StartTimeDate;
             if (PeriodStart < OldestVisitSummaryWeCareAbout)
             {
                 PeriodStart = OldestVisitSummaryWeCareAbout;
             }
             double StartTimeHoursSinceMidnight = PeriodStart.TimeOfDay.TotalHours;
             PeriodStart = PeriodStart.Date.AddHours(StartTimeHoursSinceMidnight);
             DateTime PeriodDatePtr = default(DateTime);
             PeriodDatePtr = PeriodStart;
             while (PeriodDatePtr < EndTimeDate)
             {
                 //
                 int      DateNumber = encodeInteger(PeriodDatePtr.AddHours(HourDuration / 2.0).ToOADate());
                 int      TimeNumber = encodeInteger(PeriodDatePtr.TimeOfDay.TotalHours);
                 DateTime DateStart  = default(DateTime);
                 DateStart = PeriodDatePtr.Date;
                 DateTime DateEnd = default(DateTime);
                 DateEnd = PeriodDatePtr.AddHours(HourDuration).Date;
                 //
                 // No Cookie Visits
                 //
                 string SQL = "select count(v.id) as NoCookieVisits"
                              + " from ccvisits v"
                              + " where (v.CookieSupport<>1)"
                              + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                              + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                              + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                              + "";
                 int NoCookieVisits = 0;
                 using (var csData = new CsModel(core)) {
                     core.db.sqlCommandTimeout = 180;
                     csData.openSql(SQL);
                     if (csData.ok())
                     {
                         NoCookieVisits = csData.getInteger("NoCookieVisits");
                     }
                 }
                 //
                 // Total Visits
                 //
                 SQL = "select count(v.id) as VisitCnt ,Sum(v.PageVisits) as HitCnt ,sum(v.TimetoLastHit) as TimeOnSite"
                       + " from ccvisits v"
                       + " where (v.CookieSupport<>0)"
                       + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                       + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                       + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                       + "";
                 //
                 int VisitCnt = 0;
                 int HitCnt   = 0;
                 using (var csData = new CsModel(core)) {
                     core.db.sqlCommandTimeout = 180;
                     csData.openSql(SQL);
                     if (csData.ok())
                     {
                         VisitCnt = csData.getInteger("VisitCnt");
                         HitCnt   = csData.getInteger("HitCnt");
                         double TimeOnSite = csData.getNumber("TimeOnSite");
                     }
                 }
                 //
                 // -- Visits by new visitors
                 int    NewVisitorVisits    = 0;
                 int    SinglePageVisits    = 0;
                 int    AuthenticatedVisits = 0;
                 int    MobileVisits        = 0;
                 int    BotVisits           = 0;
                 double AveTimeOnSite       = 0;
                 if (VisitCnt > 0)
                 {
                     SQL = "select count(v.id) as NewVisitorVisits"
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(v.VisitorNew<>0)"
                           + "";
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             NewVisitorVisits = csData.getInteger("NewVisitorVisits");
                         }
                     }
                     //
                     // Single Page Visits
                     //
                     SQL = "select count(v.id) as SinglePageVisits"
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(v.PageVisits=1)"
                           + "";
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             SinglePageVisits = csData.getInteger("SinglePageVisits");
                         }
                     }
                     //
                     // Multipage Visits
                     //
                     SQL = "select count(v.id) as VisitCnt ,sum(v.PageVisits) as HitCnt ,sum(v.TimetoLastHit) as TimetoLastHitSum "
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(PageVisits>1)"
                           + "";
                     int    MultiPageHitCnt           = 0;
                     int    MultiPageVisitCnt         = 0;
                     double MultiPageTimetoLastHitSum = 0;
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             MultiPageVisitCnt         = csData.getInteger("VisitCnt");
                             MultiPageHitCnt           = csData.getInteger("HitCnt");
                             MultiPageTimetoLastHitSum = csData.getNumber("TimetoLastHitSum");
                         }
                     }
                     //
                     // Authenticated Visits
                     //
                     SQL = "select count(v.id) as AuthenticatedVisits "
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(VisitAuthenticated<>0)"
                           + "";
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             AuthenticatedVisits = csData.getInteger("AuthenticatedVisits");
                         }
                     }
                     //
                     //
                     // Mobile Visits
                     //
                     SQL = "select count(v.id) as cnt "
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(Mobile<>0)"
                           + "";
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             MobileVisits = csData.getInteger("cnt");
                         }
                     }
                     //
                     // Bot Visits
                     //
                     SQL = "select count(v.id) as cnt "
                           + " from ccvisits v"
                           + " where (v.CookieSupport<>0)"
                           + " and(v.dateadded>=" + DbController.encodeSQLDate(DateStart) + ")"
                           + " and (v.dateadded<" + DbController.encodeSQLDate(DateEnd) + ")"
                           + " and((v.ExcludeFromAnalytics is null)or(v.ExcludeFromAnalytics=0))"
                           + " and(Bot<>0)"
                           + "";
                     using (var csData = new CsModel(core)) {
                         core.db.sqlCommandTimeout = 180;
                         csData.openSql(SQL);
                         if (csData.ok())
                         {
                             BotVisits = csData.getInteger("cnt");
                         }
                     }
                     //
                     if ((MultiPageHitCnt > MultiPageVisitCnt) && (HitCnt > 0))
                     {
                         int    AveReadTime     = encodeInteger(MultiPageTimetoLastHitSum / (MultiPageHitCnt - MultiPageVisitCnt));
                         double TotalTimeOnSite = MultiPageTimetoLastHitSum + (AveReadTime * VisitCnt);
                         AveTimeOnSite = TotalTimeOnSite / VisitCnt;
                     }
                 }
                 //
                 // Add or update the Visit Summary Record
                 //
                 using (var csData = new CsModel(core)) {
                     core.db.sqlCommandTimeout = 180;
                     csData.open("Visit Summary", "(timeduration=" + HourDuration + ")and(DateNumber=" + DateNumber + ")and(TimeNumber=" + TimeNumber + ")");
                     if (!csData.ok())
                     {
                         csData.close();
                         csData.insert("Visit Summary");
                     }
                     //
                     if (csData.ok())
                     {
                         csData.set("name", HourDuration + " hr summary for " + DateTime.FromOADate(DateNumber).ToShortDateString() + " " + TimeNumber + ":00");
                         csData.set("DateNumber", DateNumber);
                         csData.set("TimeNumber", TimeNumber);
                         csData.set("Visits", VisitCnt);
                         csData.set("PagesViewed", HitCnt);
                         csData.set("TimeDuration", HourDuration);
                         csData.set("NewVisitorVisits", NewVisitorVisits);
                         csData.set("SinglePageVisits", SinglePageVisits);
                         csData.set("AuthenticatedVisits", AuthenticatedVisits);
                         csData.set("NoCookieVisits", NoCookieVisits);
                         csData.set("AveTimeOnSite", AveTimeOnSite);
                         {
                             csData.set("MobileVisits", MobileVisits);
                             csData.set("BotVisits", BotVisits);
                         }
                     }
                 }
                 PeriodDatePtr = PeriodDatePtr.AddHours(HourDuration);
             }
             {
                 //
                 // Delete any daily visit summary duplicates during this period(keep the first)
                 //
                 string SQL = "delete from ccvisitsummary"
                              + " where id in ("
                              + " select d.id from ccvisitsummary d,ccvisitsummary f"
                              + " where f.datenumber=d.datenumber"
                              + " and f.datenumber>" + env.oldestVisitSummaryWeCareAbout.ToOADate() + " and f.datenumber<" + env.yesterday.ToOADate() + " and f.TimeDuration=24"
                              + " and d.TimeDuration=24"
                              + " and f.id<d.id"
                              + ")";
                 core.db.sqlCommandTimeout = 180;
                 core.db.executeNonQuery(SQL);
                 //
                 // Find missing daily summaries, summarize that date
                 //
                 SQL = core.db.getSQLSelect("ccVisitSummary", "DateNumber", "TimeDuration=24 and DateNumber>=" + env.oldestVisitSummaryWeCareAbout.Date.ToOADate(), "DateNumber,TimeNumber");
                 using (var csData = new CsModel(core)) {
                     csData.openSql(SQL);
                     DateTime datePtr = env.oldestVisitSummaryWeCareAbout;
                     while (datePtr <= env.yesterday)
                     {
                         if (!csData.ok())
                         {
                             //
                             // Out of data, start with this DatePtr
                             //
                             VisitSummaryClass.summarizePeriod(core, env, datePtr, datePtr, 24, core.siteProperties.dataBuildVersion, env.oldestVisitSummaryWeCareAbout);
                         }
                         else
                         {
                             DateTime workingDate = DateTime.MinValue.AddDays(csData.getInteger("DateNumber"));
                             if (datePtr < workingDate)
                             {
                                 //
                                 // There are missing dates, update them
                                 //
                                 VisitSummaryClass.summarizePeriod(core, env, datePtr, workingDate.AddDays(-1), 24, core.siteProperties.dataBuildVersion, env.oldestVisitSummaryWeCareAbout);
                             }
                         }
                         if (csData.ok())
                         {
                             //
                             // if there is more data, go to the next record
                             //
                             csData.goNext();
                         }
                         datePtr = datePtr.AddDays(1).Date;
                     }
                     csData.close();
                 }
             }
         }
         //
         return;
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
Exemple #29
0
        //
        //========================================================================
        //   Print the root form
        //
        public static string getForm_Root(CoreController core)
        {
            string returnHtml = "";

            try {
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                int    addonId     = 0;
                string AddonIDText = null;
                //
                // This is really messy -- there must be a better way
                //
                addonId = 0;
                if (core.session.visit.id == core.docProperties.getInteger(RequestNameDashboardReset))
                {
                    //$$$$$ cache this
                    using (var csData = new CsModel(core)) {
                        csData.open(AddonModel.tableMetadata.contentName, "ccguid=" + DbController.encodeSQLText(addonGuidDashboard));
                        if (csData.ok())
                        {
                            addonId = csData.getInteger("id");
                            core.siteProperties.setProperty("AdminRootAddonID", GenericController.encodeText(addonId));
                        }
                    }
                }
                if (addonId == 0)
                {
                    //
                    // Get AdminRootAddon
                    //
                    AddonIDText = core.siteProperties.getText("AdminRootAddonID", "");
                    if (string.IsNullOrEmpty(AddonIDText))
                    {
                        //
                        // the desktop is likely unset, auto set it to dashboard
                        //
                        addonId = -1;
                    }
                    else if (AddonIDText == "0")
                    {
                        //
                        // the desktop has been set to none - go with default desktop
                        //
                        addonId = 0;
                    }
                    else if (AddonIDText.isNumeric())
                    {
                        //
                        // it has been set to a non-zero number
                        //
                        addonId = GenericController.encodeInteger(AddonIDText);
                        //
                        // Verify it so there is no error when it runs
                        if (DbBaseModel.create <AddonModel>(core.cpParent, addonId) == null)
                        {
                            addonId = -1;
                            core.siteProperties.setProperty("AdminRootAddonID", "");
                        }
                    }
                    if (addonId == -1)
                    {
                        //
                        // This has never been set, try to get the dashboard ID
                        var addon = DbBaseModel.create <AddonModel>(core.cpParent, addonGuidDashboard);
                        if (addon != null)
                        {
                            addonId = addon.id;
                            core.siteProperties.setProperty("AdminRootAddonID", addonId);
                        }
                    }
                }
                if (addonId != 0)
                {
                    //
                    // Display the Addon
                    //
                    if (!core.doc.userErrorList.Count.Equals(0))
                    {
                        returnHtml = returnHtml + "<div style=\"clear:both;margin-top:20px;\">&nbsp;</div>"
                                     + "<div style=\"clear:both;margin-top:20px;\">" + Processor.Controllers.ErrorController.getUserError(core) + "</div>";
                    }
                    returnHtml += core.addon.execute(DbBaseModel.create <AddonModel>(core.cpParent, addonId), new BaseClasses.CPUtilsBaseClass.addonExecuteContext {
                        addonType           = BaseClasses.CPUtilsBaseClass.addonContext.ContextAdmin,
                        errorContextMessage = "executing addon id:" + addonId + " set as Admin Root addon"
                    });
                }
                if (string.IsNullOrEmpty(returnHtml))
                {
                    //
                    // Nothing Displayed, show default root page
                    //
                    returnHtml = returnHtml + Environment.NewLine + "<div style=\"padding:20px;height:450px\">"
                                 + Environment.NewLine + "<div><a href=http://www.Contensive.com target=_blank><img style=\"border:1px solid #000;\" src=\"" + cdnPrefix + "images/ContensiveAdminLogo.GIF\" border=0 ></A></div>"
                                 + Environment.NewLine + "<div><strong>Contensive/" + CoreController.codeVersion() + "</strong></div>"
                                 + Environment.NewLine + "<div style=\"clear:both;height:18px;margin-top:10px\"><div style=\"float:left;width:200px;\">Domain Name</div><div style=\"float:left;\">" + core.webServer.requestDomain + "</div></div>"
                                 + Environment.NewLine + "<div style=\"clear:both;height:18px;\"><div style=\"float:left;width:200px;\">Login Member Name</div><div style=\"float:left;\">" + core.session.user.name + "</div></div>"
                                 + Environment.NewLine + "<div style=\"clear:both;height:18px;\"><div style=\"float:left;width:200px;\">Quick Reports</div><div style=\"float:left;\"><a Href=\"?" + rnAdminForm + "=" + AdminFormQuickStats + "\">Real-Time Activity</A></div></div>"
                                 + Environment.NewLine + "<div style=\"clear:both;height:18px;\"><div style=\"float:left;width:200px;\"><a Href=\"?" + RequestNameDashboardReset + "=" + core.session.visit.id + "\">Run Dashboard</A></div></div>"
                                 + Environment.NewLine + "<div style=\"clear:both;height:18px;\"><div style=\"float:left;width:200px;\"><a Href=\"?addonguid=" + addonGuidAddonManager + "\">Add-on Manager</A></div></div>";
                    //
                    if (!core.doc.userErrorList.Count.Equals(0))
                    {
                        returnHtml = returnHtml + "<div style=\"clear:both;margin-top:20px;\">&nbsp;</div>"
                                     + "<div style=\"clear:both;margin-top:20px;\">" + Processor.Controllers.ErrorController.getUserError(core) + "</div>";
                    }
                    //
                    returnHtml = returnHtml + Environment.NewLine + "</div>"
                                 + "";
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnHtml);
        }