Ejemplo n.º 1
0
 //====================================================================================================
 /// <summary>
 /// get the portal html provided the Sql select criteria for portal. Blank returns the first order by id.
 /// </summary>
 /// <param name="CP"></param>
 /// <param name="portalSelectSqlCriteria"></param>
 /// <returns></returns>
 public string getHtml(CPBaseClass CP, string portalSelectSqlCriteria)
 {
     string returnHtml = "";
     //
     try {
         if (!CP.User.IsAdmin) {
             returnHtml = blockedMessage;
         } else {
             CPBlockBaseClass form = CP.BlockNew();
             string frameRqs = CP.Doc.RefreshQueryString;
             adminFramework.pageWithNavClass innerForm = new adminFramework.pageWithNavClass();
             string body = "";
             CPCSBaseClass cs = CP.CSNew();
             string dstFeatureGuid = CP.Doc.GetText(rnDstFeatureGuid);
             portalFeatureDataClass feature;
             int portalid = CP.Doc.GetInteger(rnPortalId);
             string activeNavHeading = "";
             //
             // build portal
             //
             portalDataClass portal = loadPortalFromDb(CP, portalSelectSqlCriteria);
             frameRqs = CP.Utils.ModifyQueryString(frameRqs, rnSetPortalId, portal.id.ToString(), true);
             //
             // portal interface - add tabs
             //
             foreach (KeyValuePair<string, portalFeatureDataClass> kvp in portal.featureList) {
                 feature = kvp.Value;
                 if (feature.parentFeatureId == 0)
                 {
                     innerForm.addNav();
                     innerForm.navCaption = feature.heading;
                     innerForm.navLink = "?" + CP.Utils.ModifyQueryString(frameRqs, rnDstFeatureGuid, feature.guid);
                 }
             }
             //
             // add developer tab
             //
             if (CP.User.IsDeveloper)
             {
                 if (portal.featureList.ContainsKey(devToolGuid))
                 {
                     CP.Site.ErrorReport("loadPortalFromDb, the portal [" + portal.name + "] appears to have the devTool feature saved in either the Db features or the defaultConfig. This is not allowed.");
                 }
                 else
                 {
                     innerForm.addNav();
                     innerForm.navCaption = "Developer Tool";
                     innerForm.navLink = "?" + CP.Utils.ModifyQueryString(frameRqs, rnDstFeatureGuid, devToolGuid);
                 }
             }
             //
             // add linked features
             //
             if (portal.linkedPortals.Count > 0)
             {
                 foreach(portalDataClass linkedPortal in portal.linkedPortals)
                 {
                     innerForm.addNav();
                     innerForm.navCaption = linkedPortal.name;
                     innerForm.navLink = "?" + CP.Utils.ModifyQueryString(frameRqs, rnSetPortalId, linkedPortal.id.ToString() );
                 }
             }
             //
             //   execute feature, if it returns empty, display default feature
             //
             if (dstFeatureGuid == devToolGuid)
             {
                 //
                 // execute developer tools
                 //
                 CP.Doc.AddRefreshQueryString(rnDstFeatureGuid, devToolGuid);
                 body = getDevTool(CP, portal, frameRqs );
                 activeNavHeading = "Developer Tool";
             }
             else
             {
                 if (portal.featureList.ContainsKey(dstFeatureGuid))
                 {
                     //
                     // add feature guid to frameRqs so if the feature uses ajax, the featureGuid will be part of it
                     // add feature guid to rqs so if an addon is used that does not support frameRqs it will work
                     //
                     feature = portal.featureList[dstFeatureGuid];
                     frameRqs = CP.Utils.ModifyQueryString(frameRqs, rnDstFeatureGuid, feature.guid);
                     if (feature.addonId != 0)
                     {
                         //
                         // feature is an addon, execute it
                         //
                         CP.Doc.SetProperty(rnFrameRqs, frameRqs);
                         CP.Doc.AddRefreshQueryString(rnDstFeatureGuid, feature.guid);
                         body = CP.Utils.ExecuteAddon(feature.addonId.ToString());
                         //if (feature.parentFeatureId == 0)
                         //{
                         //    activeNavHeading = feature.heading;
                         //}
                         //else
                         //{
                         //    foreach (KeyValuePair<string, portalFeatureDataClass> kvp in portal.featureList)
                         //    {
                         //        portalFeatureDataClass parentFeature = kvp.Value;
                         //        if (parentFeature.id == feature.parentFeatureId)
                         //        {
                         //            activeNavHeading = parentFeature.heading;
                         //            //
                         //            // if feature returned empty and it is in a feature list, execute the feature list
                         //            //
                         //            if (string.IsNullOrEmpty(body))
                         //            {
                         //                body = getFeatureList(CP, portal, parentFeature, frameRqs);
                         //            }
                         //        }
                         //    }
                         //}
                     }
                     else if (feature.dataContentId != 0)
                     {
                         //
                         // this is a data content feature -- should not be here, link should have taken them to the content
                         //
                         CP.Response.Redirect("?cid=" + feature.dataContentId.ToString());
                         formSimpleClass content = new formSimpleClass();
                         content.title = feature.heading;
                         content.body = "Redirecting to content";
                         body = content.getHtml(CP);
                     }
                     else
                     {
                         //
                         // this is a feature list, display the feature list
                         //
                         body = getFeatureList(CP, portal, feature, frameRqs);
                     }
                     //
                     // set active heading
                     //
                     if (feature.parentFeatureId == 0)
                     {
                         activeNavHeading = feature.heading;
                     }
                     else
                     {
                         foreach (KeyValuePair<string, portalFeatureDataClass> kvp in portal.featureList)
                         {
                             portalFeatureDataClass parentFeature = kvp.Value;
                             if (parentFeature.id == feature.parentFeatureId)
                             {
                                 activeNavHeading = parentFeature.heading;
                                 //
                                 // if feature returned empty and it is in a feature list, execute the feature list
                                 //
                                 if (string.IsNullOrEmpty(body))
                                 {
                                     body = getFeatureList(CP, portal, parentFeature, frameRqs);
                                 }
                             }
                         }
                     }
                     if (feature.addPadding)
                     {
                         body = CP.Html.div(body, "", "afwBodyPad", "");
                     }
                 }
             }
             if (string.IsNullOrEmpty(body)) {
                 //
                 // if the feature turns blank, run the default feature
                 //
                 if (portal.defaultFeature!=null)
                 {
                     feature = portal.defaultFeature;
                     activeNavHeading = feature.heading;
                     frameRqs = CP.Utils.ModifyQueryString(frameRqs, rnDstFeatureGuid, feature.guid);
                     CP.Doc.SetProperty(rnFrameRqs, frameRqs);
                     CP.Doc.AddRefreshQueryString(rnDstFeatureGuid, feature.guid);
                     body = CP.Utils.ExecuteAddon(feature.addonId.ToString());
                     if (feature.addPadding)
                     {
                         body = CP.Html.div(body, "", "afwBodyPad", "");
                     }
                 }
                 if(string.IsNullOrEmpty(body))
                 {
                     formSimpleClass simple = new formSimpleClass();
                     simple.body = "This portal feature has no content.";
                     body = simple.getHtml(CP);
                 }
             }
             innerForm.setActiveNav(activeNavHeading);
             //
             //Assemble
             //
             innerForm.body = CP.Html.div(body, "" ,"" , "afwBodyFrame");
             innerForm.title = portal.name;
             innerForm.isOuterContainer = true;
             returnHtml = innerForm.getHtml(CP);
             //
             // assemble body
             //
             CP.Doc.AddHeadStyle(Properties.Resources.styles);
             CP.Doc.AddHeadJavascript("var afwFrameRqs='" + frameRqs + "';");
             CP.Doc.AddHeadJavascript(Properties.Resources.javascript);
         }
     } catch (Exception ex) {
         CP.Site.ErrorReport(ex, "error in Contensive.Addons.aoAccountBilling.adminClass.execute");
     }
     return returnHtml;
 }
Ejemplo n.º 2
0
        //
        // execute method is the only public
        //
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string returnHtml = "Hello World";

            try
            {
                // rqs defined once and passed so when we do ajax integration, the rqs will be passed from
                //      from the ajax call so it can be the rqs of the original page, not the /remoteMethod rqs
                //      you get from cp.doc.RefreshQueryString.
                // srcFormId - passed from a submitting form. Otherwise 0.
                // dstFormId - the next for to display. used for links to new pages. Will be over-ridden
                //      by the formProcessing of srcFormId if it is present.
                // appId - Forms typically save data back to the Db. The 'application' is the table
                //      when the data is saved.
                // rightNow - the date and time when the page is hit. Set once and passed as argument to
                //      enable a test-mode where the time can be hard-coded.
                //
                int           srcFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnSrcFormId, ""));
                int           dstFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnDstFormId, ""));
                int           appId     = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnAppId, ""));
                string        rqs       = cp.Doc.RefreshQueryString;
                DateTime      rightNow  = DateTime.Now;
                CPCSBaseClass cs        = cp.CSNew();
                adminFramework.pageWithNavClass page = new adminFramework.pageWithNavClass();
                blankClass blank = new blankClass();
                //
                //------------------------------------------------------------------------
                // add common page elements
                //------------------------------------------------------------------------
                //
                page.title       = "Manager Sample Addon";
                page.description = "This is the visual studio c# addon template called Manager Sample. A manager addon is a set of forms that together manage a feature.";
                //
                //------------------------------------------------------------------------
                // process submitted form
                //------------------------------------------------------------------------
                //
                if (srcFormId != 0)
                {
                    switch (srcFormId)
                    {
                    // add a case for each form process needed
                    case statics.formIdBlank:
                        dstFormId = blank.processForm(cp, srcFormId, rqs, rightNow, ref appId);
                        break;
                    }
                }
                //
                //------------------------------------------------------------------------
                // add page navigation
                //------------------------------------------------------------------------
                //
                page.addNav();
                page.navCaption = "Home";
                page.navLink    = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, "0", true);
                //
                page.addNav();
                page.navCaption = "Blank Form";
                page.navLink    = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, statics.formIdBlank.ToString(), true);
                //
                switch (dstFormId)
                {
                case (statics.formIdBlank):
                    page.body = blank.getForm(cp, dstFormId, rqs, rightNow, ref appId);
                    break;

                default:
                    page.body = "<p>Welcome to the default form.</p>";
                    break;
                }
                //
                //------------------------------------------------------------------------
                // output the page
                //------------------------------------------------------------------------
                //
                returnHtml = page.getHtml(cp);
                cp.Doc.AddHeadStyle(page.styleSheet);
            }
            catch (Exception ex)
            {
                errorReport(cp, ex, "execute");
            }
            return(returnHtml);
        }
Ejemplo n.º 3
0
 //
 // execute method is the only public
 //
 public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
 {
     string returnHtml = "Hello World";
     try
     {
         // rqs defined once and passed so when we do ajax integration, the rqs will be passed from
         //      from the ajax call so it can be the rqs of the original page, not the /remoteMethod rqs
         //      you get from cp.doc.RefreshQueryString.
         // srcFormId - passed from a submitting form. Otherwise 0.
         // dstFormId - the next for to display. used for links to new pages. Will be over-ridden
         //      by the formProcessing of srcFormId if it is present.
         // appId - Forms typically save data back to the Db. The 'application' is the table
         //      when the data is saved.
         // rightNow - the date and time when the page is hit. Set once and passed as argument to
         //      enable a test-mode where the time can be hard-coded.
         //
         int srcFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnSrcFormId, ""));
         int dstFormId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnDstFormId, ""));
         int appId = cp.Utils.EncodeInteger(cp.Doc.GetProperty(statics.rnAppId, ""));
         string rqs = cp.Doc.RefreshQueryString;
         DateTime rightNow = DateTime.Now;
         CPCSBaseClass cs = cp.CSNew();
         adminFramework.pageWithNavClass page = new adminFramework.pageWithNavClass();
         blankClass blank = new blankClass();
         //
         //------------------------------------------------------------------------
         // add common page elements
         //------------------------------------------------------------------------
         //
         page.title = "Manager Sample Addon";
         page.description = "This is the visual studio c# addon template called Manager Sample. A manager addon is a set of forms that together manage a feature.";
         //
         //------------------------------------------------------------------------
         // process submitted form
         //------------------------------------------------------------------------
         //
         if (srcFormId != 0)
         {
             switch (srcFormId)
             {
                 // add a case for each form process needed
                 case statics.formIdBlank:
                     dstFormId = blank.processForm(cp, srcFormId, rqs, rightNow, ref appId);
                     break;
             }
         }
         //
         //------------------------------------------------------------------------
         // add page navigation
         //------------------------------------------------------------------------
         //
         page.addNav();
         page.navCaption = "Home";
         page.navLink = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, "0", true);
         //
         page.addNav();
         page.navCaption = "Blank Form";
         page.navLink = "?" + cp.Utils.ModifyQueryString(rqs, statics.rnDstFormId, statics.formIdBlank.ToString(), true);
         //
         switch (dstFormId)
         {
             case (statics.formIdBlank):
                 page.body = blank.getForm(cp, dstFormId, rqs, rightNow, ref appId);
                 break;
             default:
                 page.body = "<p>Welcome to the default form.</p>";
                 break;
         }
         //
         //------------------------------------------------------------------------
         // output the page
         //------------------------------------------------------------------------
         //
         returnHtml = page.getHtml(cp);
         cp.Doc.AddHeadStyle(page.styleSheet);
     }
     catch (Exception ex)
     {
         errorReport(cp, ex, "execute");
     }
     return returnHtml;
 }