Inheritance: BaseController
Exemplo n.º 1
0
        public void TestCountAndIsEmpty()
        {
            GenericController controller = new GenericController();

            Assert.AreEqual(true, controller.IsEmpty());

            controller.Enqueue(NewPacket(10, 0), 0);

            Assert.AreEqual(false, controller.IsEmpty());

            controller.Enqueue(NewPacket(10, 0), 0);
            controller.Enqueue(NewPacket(10, 1), 1);
            controller.Enqueue(NewPacket(10, 1), 1);
            controller.Enqueue(NewPacket(10, 2), 2);
            controller.Enqueue(NewPacket(10, 3), 3);
            controller.Enqueue(NewPacket(10, 3), 3);
            controller.Enqueue(NewPacket(10, 4), 4);

            Assert.AreEqual(false, controller.IsEmpty());

            Assert.AreEqual(8, controller.Count);

            for (int i = 0; i < 8; i++)
            {
                controller.Dequeue();
            }

            Assert.AreEqual(true, controller.IsEmpty());
        }
Exemplo n.º 2
0
 //
 //====================================================================================================
 //
 private void loadFromDb(int keyId)
 {
     try {
         //
         propertyCache_nameIndex = new KeyPtrController();
         propertyCacheCnt        = 0;
         //
         using (DataTable dt = core.db.executeQuery("select Name,FieldValue,ID from ccProperties where (active<>0)and(TypeID=" + (int)propertyType + ")and(KeyID=" + keyId + ")")) {
             if (dt.Rows.Count > 0)
             {
                 propertyCache = new string[3, dt.Rows.Count];
                 foreach (DataRow dr in dt.Rows)
                 {
                     string Name = GenericController.encodeText(dr[0]);
                     propertyCache[0, propertyCacheCnt] = Name;
                     propertyCache[1, propertyCacheCnt] = GenericController.encodeText(dr[1]);
                     propertyCache[2, propertyCacheCnt] = GenericController.encodeInteger(dr[2]).ToString();
                     propertyCache_nameIndex.setPtr(Name.ToLowerInvariant(), propertyCacheCnt);
                     propertyCacheCnt += 1;
                 }
                 propertyCacheCnt = dt.Rows.Count;
             }
         }
         propertyCacheLoaded = true;
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
        //
        // ====================================================================================================

        public static string get(CPBaseClass cp, PageTemplateModel template)
        {
            try {
                string addonList = "";
                foreach (var rule in DbBaseModel.createList <AddonTemplateRuleModel>(cp, "(templateId=" + template.id + ")"))
                {
                    AddonModel addon = DbBaseModel.create <AddonModel>(cp, rule.addonId);
                    if (addon != null)
                    {
                        addonList += System.Environment.NewLine + "\t\t" + "<IncludeAddon name=\"" + addon.name + "\" guid=\"" + addon.ccguid + "\" />";
                    }
                }
                return(""
                       + System.Environment.NewLine + "\t" + "<Template"
                       + " name=\"" + System.Net.WebUtility.HtmlEncode(template.name) + "\""
                       + " guid=\"" + template.ccguid + "\""
                       + " issecure=\"" + GenericController.getYesNo(template.isSecure) + "\""
                       + " >"
                       + addonList
                       + System.Environment.NewLine + "\t\t" + "<BodyHtml>" + ExportController.tabIndent(cp, ExportController.EncodeCData(template.bodyHTML)) + "</BodyHtml>"
                       + System.Environment.NewLine + "\t" + "</Template>");
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex, "GetAddonNode");
                return(string.Empty);
            }
        }
Exemplo n.º 4
0
 //
 //====================================================================================================
 /// <summary>
 /// set property
 /// </summary>
 /// <param name="propertyName"></param>
 /// <param name="propertyValue"></param>
 /// <param name="keyId">keyId is like vistiId, vistorId, userId</param>
 public void setProperty(string propertyName, string propertyValue, int keyId)
 {
     try {
         if (!propertyCacheLoaded)
         {
             loadFromDb(keyId);
         }
         int Ptr = -1;
         if (propertyCacheCnt > 0)
         {
             Ptr = propertyCache_nameIndex.getPtr(propertyName);
         }
         if (Ptr < 0)
         {
             Ptr = propertyCacheCnt;
             propertyCacheCnt += 1;
             string[,] tempVar = new string[3, Ptr + 1];
             if (propertyCache != null)
             {
                 for (int Dimension0 = 0; Dimension0 < propertyCache.GetLength(0); Dimension0++)
                 {
                     int CopyLength = Math.Min(propertyCache.GetLength(1), tempVar.GetLength(1));
                     for (int Dimension1 = 0; Dimension1 < CopyLength; Dimension1++)
                     {
                         tempVar[Dimension0, Dimension1] = propertyCache[Dimension0, Dimension1];
                     }
                 }
             }
             propertyCache         = tempVar;
             propertyCache[0, Ptr] = propertyName;
             propertyCache[1, Ptr] = propertyValue;
             propertyCache_nameIndex.setPtr(propertyName, Ptr);
             //
             // insert a new property record, get the ID back and save it in cache
             //
             using (var csData = new CsModel(core)) {
                 if (csData.insert("Properties"))
                 {
                     propertyCache[2, Ptr] = csData.getText("ID");
                     csData.set("name", propertyName);
                     csData.set("FieldValue", propertyValue);
                     csData.set("TypeID", (int)propertyType);
                     csData.set("KeyID", keyId.ToString());
                 }
             }
         }
         else if (propertyCache[1, Ptr] != propertyValue)
         {
             propertyCache[1, Ptr] = propertyValue;
             int    RecordId = GenericController.encodeInteger(propertyCache[2, Ptr]);
             string SQLNow   = DbController.encodeSQLDate(core.dateTimeNowMockable);
             //
             // save the value in the property that was found
             //
             core.db.executeNonQuery("update ccProperties set FieldValue=" + DbController.encodeSQLText(propertyValue) + ",ModifiedDate=" + SQLNow + " where id=" + RecordId);
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
Exemplo n.º 5
0
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                //
                core.doc.addRefreshQueryString(RequestNameHardCodedPage, HardCodedPageSiteExplorer);
                string LinkObjectName = core.docProperties.getText("LinkObjectName");
                if (!string.IsNullOrEmpty(LinkObjectName))
                {
                    //
                    // Open a page compatible with a dialog
                    //
                    core.doc.addRefreshQueryString("LinkObjectName", LinkObjectName);
                    core.html.addTitle("Site Explorer");
                    core.doc.setMetaContent(0, 0);
                    string copy = core.addon.execute(AddonModel.createByUniqueName(core.cpParent, "Site Explorer"), new CPUtilsBaseClass.addonExecuteContext {
                        addonType           = CPUtilsBaseClass.addonContext.ContextPage,
                        errorContextMessage = "processing site explorer response"
                    });
                    core.html.addScriptCode_onLoad("document.body.style.overflow='scroll';", "Site Explorer");
                    string htmlBodyTag = "<body class=\"container-fluid ccBodyAdmin ccCon\" style=\"overflow:scroll\">";
                    string htmlBody    = ""
                                         + GenericController.nop(core.html.getPanelHeader("Contensive Site Explorer")) + "\r<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\"><tr><td>"
                                         + GenericController.nop(copy) + "\r</td></tr></table>"
                                         + "";
                    result = core.html.getHtmlDoc(htmlBody, htmlBodyTag, false, false);
                    core.doc.continueProcessing = false;
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Creates a controller instance and sets its ControllerContext depending on the current Http context.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="routeData">The route data.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">Can't create Controller Context if no active HttpContext instance is available.</exception>
        public virtual Controller CreateController(RouteData routeData = null)
        {
            // create a disconnected controller instance
            var controller = new GenericController();
            HttpContextBase context = null;

            // get context wrapper from HttpContext if available
            if (SystemManager.CurrentHttpContext != null)
                context = SystemManager.CurrentHttpContext;
            else
                throw new InvalidOperationException("Can not create ControllerContext if no active HttpContext instance is available.");

            if (routeData == null)
                routeData = new RouteData();

            // add the controller routing if not existing
            if (!routeData.Values.ContainsKey("controller") &&
                !routeData.Values.ContainsKey("Controller"))
            {
                routeData.Values.Add("controller", "Generic");
            }

            controller.UpdateViewEnginesCollection(this.GetPathTransformations());

            // here we create the context for the controller passing the just created controller the httpcontext and the route data that we built above
            controller.ControllerContext = new ControllerContext(context, routeData, controller);

            return controller;
        }
        //
        //====================================================================================================
        //   Get an LocalElements attribute value
        //
        public string elementAttribute(int ElementPointer, string Name)
        {
            string tempElementAttribute = null;

            try {
                //
                int    AttributePointer = 0;
                string UcaseName        = null;
                //
                tempElementAttribute = "";
                LoadElement(ElementPointer);
                if (ElementPointer < elementCount)
                {
                    if (LocalElements[ElementPointer].AttributeCount > 0)
                    {
                        UcaseName = GenericController.toUCase(Name);
                        int tempVar = LocalElements[ElementPointer].AttributeCount;
                        for (AttributePointer = 0; AttributePointer < tempVar; AttributePointer++)
                        {
                            if (LocalElements[ElementPointer].Attributes[AttributePointer].UcaseName == UcaseName)
                            {
                                tempElementAttribute = LocalElements[ElementPointer].Attributes[AttributePointer].Value;
                                break;
                            }
                        }
                    }
                }
                //
                return(tempElementAttribute);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(tempElementAttribute);
        }
Exemplo n.º 8
0
 //
 //====================================================================================================
 //
 public override void OpenCopy(string copyRecordNameOrGuid)
 {
     try {
         accum = "";
         CopyContentModel copy;
         if (copyRecordNameOrGuid.isNumeric())
         {
             //
             // -- recordId
             copy = CopyContentModel.create <CopyContentModel>(cp, GenericController.encodeInteger(copyRecordNameOrGuid));
         }
         else if (GenericController.isGuid(copyRecordNameOrGuid))
         {
             //
             // -- record guid
             copy = CopyContentModel.create <CopyContentModel>(cp, copyRecordNameOrGuid);
         }
         else
         {
             //
             // -- record name
             copy = DbBaseModel.createByUniqueName <CopyContentModel>(cp, copyRecordNameOrGuid);
         }
         if (copy != null)
         {
             accum = copy.copy;
         }
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
         throw;
     }
 }
Exemplo n.º 9
0
        // GET: /
        public static HttpResponse HomeIndex(HttpRequest request)
        {
            GenericController controller = new GenericController();
            var response = controller.GetWelcome();

            return(CreateHttpResponse(response));
        }
Exemplo n.º 10
0
    public IEnumerator DetermineMezmerize(double mez)
    {
        double net_mez = mez - mezmerize_resistance;

        if (net_mez > 0 && !mezmerized && rand.NextDouble() < net_mez * 6)
        {
            GenericController controller = GetComponentInChildren <GenericController>();
            mezmerized = true;
            foreach (Gun gun in controller.weapons)
            {
                if (gun)
                {
                    gun.mez_threshold = (int)(net_mez * 100) / 2;
                }
            }
            float time      = (float)(net_mez * 150);
            float next_time = Time.time + time;
            RpcUpdateAilments("\r\n <color=purple>Mezmerize</color> ", time);
            while (Time.time < next_time && HP != 0)
            {
                yield return(new WaitForEndOfFrame());
            }
            foreach (Gun gun in controller.weapons)
            {
                if (gun)
                {
                    gun.mez_threshold = 0;
                }
            }
            mezmerized = false;
        }
    }
Exemplo n.º 11
0
 //
 //=================================================================================
 /// <summary>
 /// Get a record lock status. If session.user is the lock holder, returns unlocked
 /// </summary>
 /// <param name="ContentName"></param>
 /// <param name="recordId"></param>
 /// <param name="ReturnMemberID"></param>
 /// <param name="ReturnDateExpires"></param>
 /// <returns></returns>
 public static editLockClass getEditLock(CoreController core, int tableId, int recordId)
 {
     try {
         var table = DbBaseModel.create <TableModel>(core.cpParent, tableId);
         if (table != null)
         {
             //
             // -- get the edit control for this record (not by this person) with the oldest expiration date
             string criteria             = "(createdby<>" + core.session.user.id + ")and" + getAuthoringControlCriteria(getTableRecordKey(table.id, recordId), AuthoringControls.Editing, core.dateTimeNowMockable);
             var    authoringControlList = DbBaseModel.createList <AuthoringControlModel>(core.cpParent, criteria, "dateexpires desc");
             if (authoringControlList.Count > 0)
             {
                 var person = DbBaseModel.create <PersonModel>(core.cpParent, GenericController.encodeInteger(authoringControlList.First().createdBy));
                 return(new editLockClass {
                     isEditLocked = true,
                     editLockExpiresDate = authoringControlList.First().dateExpires,
                     editLockByMemberId = (person == null) ? 0 : person.id,
                     editLockByMemberName = (person == null) ? "" : person.name
                 });
             }
         }
         ;
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
     return(new editLockClass {
         isEditLocked = false
     });
 }
Exemplo n.º 12
0
        //
        //========================================================================
        //   Returns the next matching pointer from a ContentIndex
        //   Returns -1 if there is no match
        //========================================================================
        //
        public int getNextPtrMatch(string Key)
        {
            int nextPointerMatch = -1;

            try {
                string UcaseKey = null;
                //
                if (store.ArrayPointer < (store.ArrayCount - 1))
                {
                    store.ArrayPointer = store.ArrayPointer + 1;
                    UcaseKey           = GenericController.toUCase(Key);
                    if (store.UcaseKeyArray[store.ArrayPointer] == UcaseKey)
                    {
                        nextPointerMatch = GenericController.encodeInteger(store.PointerArray[store.ArrayPointer]);
                    }
                    else
                    {
                        store.ArrayPointer = store.ArrayPointer - 1;
                    }
                }
            } catch (Exception ex) {
                throw new IndexException("GetNextPointerMatch error", ex);
            }
            return(nextPointerMatch);
        }
Exemplo n.º 13
0
 public override string ExecuteAddonAsProcess(string addonIDGuidOrName)
 {
     try {
         AddonModel addon = null;
         if (addonIDGuidOrName.isNumeric())
         {
             addon = cp.core.addonCache.getAddonById(EncodeInteger(addonIDGuidOrName));
         }
         else if (GenericController.isGuid(addonIDGuidOrName))
         {
             addon = cp.core.addonCache.getAddonByGuid(addonIDGuidOrName);
         }
         else
         {
             addon = cp.core.addonCache.getAddonByName(addonIDGuidOrName);
         }
         if (addon != null)
         {
             cp.core.addon.executeAsync(addon);
         }
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
     }
     return(string.Empty);
 }
Exemplo n.º 14
0
        //
        //========================================================================
        //   Returns the matching pointer from a ContentIndex
        //   Returns -1 if there is no match
        //========================================================================
        //
        public int getPtr(string Key)
        {
            int returnKey = -1;

            try {
                bool   MatchFound = false;
                string UcaseKey   = null;
                //
                UcaseKey           = GenericController.strReplace(Key.ToUpper(), Environment.NewLine, "");
                store.ArrayPointer = GetArrayPointer(Key);
                if (store.ArrayPointer > -1)
                {
                    MatchFound = true;
                    while (MatchFound)
                    {
                        store.ArrayPointer = store.ArrayPointer - 1;
                        if (store.ArrayPointer < 0)
                        {
                            MatchFound = false;
                        }
                        else
                        {
                            MatchFound = (store.UcaseKeyArray[store.ArrayPointer] == UcaseKey);
                        }
                    }
                    store.ArrayPointer = store.ArrayPointer + 1;
                    returnKey          = GenericController.encodeInteger(store.PointerArray[store.ArrayPointer]);
                }
            } catch (Exception ex) {
                throw new IndexException("GetPointer error", ex);
            }
            return(returnKey);
        }
Exemplo n.º 15
0
        //
        //====================================================================================================
        // Replace with main_GetPageArgs()
        //
        // Used Interally by main_GetPageLink to main_Get the TemplateID of the parents
        //====================================================================================================
        //
        internal int getPageDynamicLink_GetTemplateID(int PageID, string UsedIDList)
        {
            int result = 0;

            try {
                int ParentID   = 0;
                int templateId = 0;
                using (var csData = new CsModel(core)) {
                    if (csData.openRecord("Page Content", PageID, "TemplateID,ParentID"))
                    {
                        templateId = csData.getInteger("TemplateID");
                        ParentID   = csData.getInteger("ParentID");
                    }
                }
                //
                // Chase page tree to main_Get templateid
                if (templateId == 0 && ParentID != 0)
                {
                    if (!GenericController.isInDelimitedString(UsedIDList, ParentID.ToString(), ","))
                    {
                        result = getPageDynamicLink_GetTemplateID(ParentID, UsedIDList + "," + ParentID);
                    }
                }
                return(result);
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
        }
Exemplo n.º 16
0
        //
        //====================================================================================================
        //
        public override string GetRemoteQueryKey(string sql, int pageSize)
        {
            string returnKey = "";

            try {
                using (var cs = new CPCSClass(cp)) {
                    //
                    if (pageSize == 0)
                    {
                        pageSize = 9999;
                    }
                    if (cs.Insert("Remote Queries"))
                    {
                        returnKey = GenericController.getGUIDNaked();
                        int dataSourceId = cp.Content.GetRecordID("Data Sources", "");
                        cs.SetField("remotekey", returnKey);
                        cs.SetField("datasourceid", dataSourceId.ToString());
                        cs.SetField("sqlquery", sql);
                        cs.SetField("maxRows", pageSize.ToString());
                        cs.SetField("dateexpires", cp.core.dateTimeNowMockable.AddDays(1).ToString());
                        cs.SetField("QueryTypeID", RemoteQueryType.sql.ToString());
                        cs.SetField("VisitID", cp.Visit.Id.ToString());
                    }
                    cs.Close();
                    //
                }
            } catch (Exception ex) {
                LogController.logError(cp.core, ex);
            }
            return(returnKey);
        }
Exemplo n.º 17
0
 //
 //
 public void sendPublishSubmitNotice(string ContentName, int RecordID, string RecordName)
 {
     try {
         Models.Domain.ContentMetadataModel CDef = null;
         string Copy        = null;
         string Link        = null;
         string FromAddress = null;
         //
         FromAddress = core.siteProperties.getText("EmailPublishSubmitFrom", core.siteProperties.emailAdmin);
         CDef        = Models.Domain.ContentMetadataModel.createByUniqueName(core, ContentName);
         Link        = "/" + core.appConfig.adminRoute + "?af=" + AdminFormPublishing;
         Copy        = Msg_AuthoringSubmittedNotification;
         Copy        = GenericController.strReplace(Copy, "<DOMAINNAME>", "<a href=\"" + HtmlController.encodeHtml(Link) + "\">" + core.webServer.requestDomain + "</a>");
         Copy        = GenericController.strReplace(Copy, "<RECORDNAME>", RecordName);
         Copy        = GenericController.strReplace(Copy, "<CONTENTNAME>", ContentName);
         Copy        = GenericController.strReplace(Copy, "<RECORDID>", RecordID.ToString());
         Copy        = GenericController.strReplace(Copy, "<SUBMITTEDDATE>", core.doc.profileStartTime.ToString());
         Copy        = GenericController.strReplace(Copy, "<SUBMITTEDNAME>", core.session.user.name);
         //
         EmailController.queueGroupEmail(core, core.siteProperties.getText("WorkflowEditorGroup", "Site Managers"), FromAddress, "Authoring Submitted Notification", Copy, false, true);
         //
         return;
         //
         // ----- Error Trap
         //
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
Exemplo n.º 18
0
 //
 //====================================================================================================
 //
 public override void OpenLayout(string layoutRecordNameOrGuid)
 {
     try {
         accum = "";
         LayoutModel layout;
         if (layoutRecordNameOrGuid.isNumeric())
         {
             //
             // -- recordId
             layout = DbBaseModel.create <LayoutModel>(cp, GenericController.encodeInteger(layoutRecordNameOrGuid));
         }
         else if (GenericController.isGuid(layoutRecordNameOrGuid))
         {
             //
             // -- record guid
             layout = LayoutModel.create <LayoutModel>(cp, layoutRecordNameOrGuid);
         }
         else
         {
             //
             // -- record name
             layout = LayoutModel.createByUniqueName <LayoutModel>(cp, layoutRecordNameOrGuid);
         }
         if (layout != null)
         {
             accum = layout.layout.content;
         }
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
         throw;
     }
 }
Exemplo n.º 19
0
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            landingPageController = await ControllerBase.GetNamedInstance <GenericController>("LandingPage", "BrickPi.NxtColor.Port_S3");

            landingPageController.OnResponseReceived += LandingPageController_OnResponseReceived;
            base.OnNavigatedTo(e);
        }
Exemplo n.º 20
0
        //
        //====================================================================================================
        /// <summary>
        /// getFieldEditorPreference remote method
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core = ((CPClass)cp).core;
                if (core.session.isAuthenticated && core.session.isAuthenticatedAdmin())
                {
                    //
                    // Save the site sites
                    //
                    core.wwwFiles.saveFile(DynamicStylesFilename, core.docProperties.getText("SiteStyles"));
                    if (core.docProperties.getBoolean(RequestNameInlineStyles))
                    {
                        //
                        // Inline Styles
                        //
                        core.siteProperties.setProperty("StylesheetSerialNumber", "0");
                    }
                    else
                    {
                        //
                        // Linked Styles
                        // Bump the Style Serial Number so next fetch is not cached
                        //
                        int StyleSN = core.siteProperties.getInteger("StylesheetSerialNumber", 0);
                        StyleSN = StyleSN + 1;
                        core.siteProperties.setProperty("StylesheetSerialNumber", GenericController.encodeText(StyleSN));
                    }
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Creates a controller instance and sets its ControllerContext depending on the current Http context.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="routeData">The route data.</param>
        /// <param name="context">The context.</param>
        /// <returns></returns>
        /// <exception cref="System.InvalidOperationException">Can't create Controller Context if no active HttpContext instance is available.</exception>
        public virtual Controller CreateController(RouteData routeData = null)
        {
            // create a disconnected controller instance
            var             controller = new GenericController();
            HttpContextBase context    = null;

            // get context wrapper from HttpContext if available
            if (SystemManager.CurrentHttpContext != null)
            {
                context = SystemManager.CurrentHttpContext;
            }
            else
            {
                throw new InvalidOperationException("Can not create ControllerContext if no active HttpContext instance is available.");
            }

            if (routeData == null)
            {
                routeData = new RouteData();
            }

            // add the controller routing if not existing
            if (!routeData.Values.ContainsKey("controller") &&
                !routeData.Values.ContainsKey("Controller"))
            {
                routeData.Values.Add("controller", "Generic");
            }

            controller.UpdateViewEnginesCollection(this.GetPathTransformations());

            // here we create the context for the controller passing the just created controller the httpcontext and the route data that we built above
            controller.ControllerContext = new ControllerContext(context, routeData, controller);

            return(controller);
        }
Exemplo n.º 22
0
        // During Input.Initialize, controllers are generated. I think they are assigned to the MPPlayer profiles but i'm not sure.
        // Either way, the game crashes without them so I generate the extra ones for the new MPPlayer profiles.
        public static void AddExtraDevices() // Extends what Initialize() does
        {
            Type inputType = typeof(Input);

            FieldInfo _devicesField = inputType.GetField("_devices", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            dynamic   _devicesVal   = _devicesField.GetValue(null);

            FieldInfo _gamePadsField = inputType.GetField("_gamePads", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
            dynamic   _gamePadsVal   = _gamePadsField.GetValue(null);

            // Player 5
            GenericController genericController5 = new GenericController(4);

            _devicesVal.Add((InputDevice)genericController5);
            _gamePadsVal.Add(genericController5);

            // Player 6
            GenericController genericController6 = new GenericController(5);

            _devicesVal.Add((InputDevice)genericController6);
            _gamePadsVal.Add(genericController6);

            // Player 7
            GenericController genericController7 = new GenericController(6);

            _devicesVal.Add((InputDevice)genericController7);
            _gamePadsVal.Add(genericController7);

            // Player 8
            GenericController genericController8 = new GenericController(7);

            _devicesVal.Add((InputDevice)genericController8);
            _gamePadsVal.Add(genericController8);
        }
Exemplo n.º 23
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;
            }
        }
Exemplo n.º 24
0
        //
        //====================================================================================================
        /// <summary>
        /// Add meta data for favicon to meta data
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public override object Execute(Contensive.BaseClasses.CPBaseClass cp)
        {
            string result = "";

            try {
                CoreController core     = ((CPClass)cp).core;
                string         Filename = core.siteProperties.getText("FaviconFilename", "");
                if (string.IsNullOrEmpty(Filename))
                {
                    //
                    // no favicon, 404 the call
                    //
                    core.webServer.setResponseStatus(WebServerController.httpResponseStatus404_NotFound);
                    core.webServer.setResponseContentType("image/gif");
                    core.doc.continueProcessing = false;
                    return(string.Empty);
                }
                else
                {
                    core.doc.continueProcessing = false;
                    return(core.webServer.redirect(GenericController.getCdnFileLink(core, Filename), "favicon request", false, false));
                }
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
            }
            return(result);
        }
Exemplo n.º 25
0
 public MappingSelectionArgs(GenericController controller, ControllerType target, Skin previewSkin, ControllerMapping mapping)
 {
     Controller  = controller;
     Target      = target;
     PreviewSkin = previewSkin;
     Mapping     = mapping;
 }
Exemplo n.º 26
0
 //
 //
 //
 //==========================================================================================
 /// <summary>
 /// add querystring to the doc properties
 /// </summary>
 /// <param name="QS"></param>
 public void addQueryString(string QS)
 {
     try {
         string[] ampSplit = QS.Split('&');
         for (int Ptr = 0; Ptr < ampSplit.GetUpperBound(0) + 1; Ptr++)
         {
             string nameValuePair = ampSplit[Ptr];
             if (!string.IsNullOrEmpty(nameValuePair))
             {
                 if (GenericController.strInstr(1, nameValuePair, "=") != 0)
                 {
                     string[] ValuePair = nameValuePair.Split('=');
                     string   key       = decodeResponseVariable(encodeText(ValuePair[0]));
                     if (!string.IsNullOrEmpty(key))
                     {
                         DocPropertyModel docProperty = new DocPropertyModel {
                             name         = key,
                             propertyType = DocPropertyModel.DocPropertyTypesEnum.queryString,
                             value        = (ValuePair.GetUpperBound(0) > 0) ? decodeResponseVariable(encodeText(ValuePair[1])) : ""
                         };
                         core.docProperties.setProperty(key, docProperty);
                     }
                 }
             }
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
Exemplo n.º 27
0
 //
 //====================================================================================================
 /// <summary>
 /// deprecated. Use the integer toUserId method
 /// </summary>
 /// <param name="toUserId"></param>
 /// <param name="FromAddress"></param>
 /// <param name="Subject"></param>
 /// <param name="Body"></param>
 [Obsolete()] public override void sendUser(string toUserId, string FromAddress, string Subject, string Body)
 {
     if (GenericController.encodeInteger(toUserId) <= 0)
     {
         throw new ArgumentException("The To-User argument is not valid, [" + toUserId + "]");
     }
     sendUser(GenericController.encodeInteger(toUserId), FromAddress, Subject, Body);
 }
 public GenericOneToManyController(ControllerObject controller) : base(controller)
 {
     Constructing();
     OneEntityController  = CreateFirstEntityController(this);
     ManyEntityController = CreateSecondEntityController(this);
     ChangedSessionToken += GenericOneToManyController_ChangedSessionToken;
     Constructed();
 }
Exemplo n.º 29
0
        public void SetupTest()
        {
            InitializeNakedObjectsFramework(this);
            StartTest();

            controller = new GenericController(Surface, IdHelper);
            mocks      = new ContextMocks(controller);
        }
 public GenericOneToOneController(DataContext.IContext context) : base(context)
 {
     Constructing();
     FirstEntityController  = CreateFirstEntityController(this);
     SecondEntityController = CreateSecondEntityController(this);
     ChangedSessionToken   += GenericOneToOneController_ChangedSessionToken;
     Constructed();
 }
Exemplo n.º 31
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);
        }
Exemplo n.º 32
0
        /// <summary>
        /// Creates a controller in the mocked context.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="routeData">The route data.</param>
        /// <returns></returns>
        public Controller CreateController(RouteData routeData = null)
        {
            Controller controller = new GenericController();
            var context = new HttpContextWrapper(new System.Web.HttpContext(
               new HttpRequest(null, "http://tempuri.org", null),
               new HttpResponse(null)));
            context.Items["CurrentResourcePackage"] = "test";

            var baseTemplateBuilder = (LayoutRenderer)this;

            SystemManager.RunWithHttpContext(
                context,
                () => { controller = baseTemplateBuilder.CreateController(routeData); });

            return controller;
        }
Exemplo n.º 33
0
 protected void AddJoystickButtonMap(GenericController.eMicrosoftButtonId buttonId, int inputKey)
 {
     AddJoystickButtonMap((BaseController.eButtonId)buttonId, inputKey);
 }
    private BaseController CreateController(string joystickName)
    {
        BaseController controller = null;

        foreach (Type controllerType in SUPPORTED_CONTROLLERS)
        {
            string controllerName = GetControllerDetectionName(controllerType);

            // Special case a empty name controller.
            if ((string.IsNullOrEmpty(controllerName) && string.IsNullOrEmpty(joystickName)) || (!string.IsNullOrEmpty(controllerName) && joystickName.Contains(controllerName)))
            {
                controller = Activator.CreateInstance(controllerType) as BaseController;
                break;
            }
        }

        if (controller == null)
        {
            // Default configurations.
            controller = new GenericController();
        }

        return controller;
    }