public ModuleSettings(int portalId, int siteModuleId) {
                _portalId = portalId;
                _siteModuleId = siteModuleId;

                ModuleController moduleController = new ModuleController();
                _siteModuleId = moduleController.GetModuleByDefinition(_portalId, ModuleKeys.ModuleDefinitionName).ModuleID;
            }
        public void ConsumeMessagesOnMultipleWorkerThreads()
        {
            const int NumerOfMessages = 1000;

            this.module.ConsumeDelay = TimeSpan.FromMilliseconds(0);
            this.testee = new ModuleController();
            this.testee.Initialize(this.module, 10);

            for (int i = 0; i < NumerOfMessages; i++)
            {
                this.testee.EnqueueMessage(i);
            }

            AutoResetEvent signal = new AutoResetEvent(false);
            int count = 0;
            object padlock = new object();
            this.testee.AfterConsumeMessage += delegate
                {
                    lock (padlock)
                    {
                        count++;
                        if (count == NumerOfMessages)
                        {
                            signal.Set();
                        }
                    }
                };

            this.testee.Start();

            Assert.IsTrue(signal.WaitOne(10000, false), "not all messages consumed. Consumed " + this.module.Messages.Count);
            this.testee.Stop();
        }
        protected override void OnInitialize()
        {
            base.OnInitialize();

            moduleController = Container.GetExportedValue<ModuleController>();
            moduleController.Initialize();
            moduleController.Run();
        }
        public ModuleControllerTest()
        {
            this.module = new TestModule();
            this.testee = new ModuleController();
            this.testee.Initialize(this.module);

            this.module.Controller = this.testee;
        }
        public void StartWithBackgroundThreads()
        {
            ModuleController testee = new ModuleController();
            testee.Initialize(new TestModule(), true);
            testee.Start();

            testee.IsAlive.Should().BeTrue();
        }
 protected override void OnInitialize()
 {
     base.OnInitialize();
     controller = Container.GetExportedValue<ModuleController>();
     shellService = Container.GetExportedValue<IShellService>();
     controller.Initialize();
     controller.Run();
 }
        public void SetUp()
        {
            this.mockery = new Mockery();

            this.module = new TestModule();

            this.testee = new ModuleController();
            this.testee.Initialize(this.module);
        }
        public void SetUp()
        {
            this.module = new TestModule();
            this.testee = new ModuleController();
            this.testee.Initialize(this.module);

            this.module.Controller = this.testee;

            Assert.IsFalse(this.testee.IsAlive, "controller should not be active yet.");
        }
        public void StopControllerWhenMultipleConsumersAreRunning()
        {
            const int NumerOfMessages = 100;

            this.module.ConsumeDelay = TimeSpan.FromMilliseconds(10);
            this.testee = new ModuleController();
            this.testee.Initialize(this.module, 10);

            for (int i = 0; i < NumerOfMessages; i++)
            {
                this.testee.EnqueueMessage(i);
            }

            this.testee.Start();

            Thread.Sleep(50);

            this.testee.Stop();

            Assert.Less(this.module.Messages.Count, NumerOfMessages, "there should not be enough time for all messages to be consumed.");
            Assert.Greater(this.testee.MessageCount, 0, "there should be messages left to consume.");
        }
Example #10
0
        /// -----------------------------------------------------------------------------
        ///         ''' <summary>
        ///         ''' cmdUpdate_Click runs when the update button is clicked
        ///         ''' </summary>
        ///         ''' <remarks>
        ///         ''' </remarks>
        ///         ''' <history>
        ///         '''     [cnurse]	9/23/2004	Updated to reflect design changes for Help, 508 support
        ///         '''                       and localisation
        ///         ''' </history>
        ///         ''' -----------------------------------------------------------------------------
        public void cmdUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true & ctlURL.Url != "")
                {
                    Link objLink = new Link();

                    // bind text values to object
                    objLink.ItemId        = itemId;
                    objLink.ModuleId      = ModuleId;
                    objLink.CreatedByUser = UserInfo.UserID;
                    objLink.CreatedDate   = DateTime.Now;
                    objLink.Title         = txtTitle.Text;
                    objLink.Url           = ctlURL.Url;

                    int refreshInterval = 0;

                    if (ctlURL.UrlType == "U")
                    {
                        refreshInterval = System.Convert.ToInt32(ddlGetContentInterval.SelectedValue);
                    }

                    objLink.RefreshInterval = refreshInterval;

                    if ((ddlViewOrderLinks.Items.Count > 0))
                    {
                        switch (ddlViewOrder.SelectedValue)
                        {
                        case "B":
                        {
                            objLink.ViewOrder = Convert.ToInt32(ddlViewOrderLinks.SelectedValue) - 1;
                            LinkController.UpdateViewOrder(objLink, -1, this.ModuleId);
                            break;
                        }

                        case "A":
                        {
                            objLink.ViewOrder = Convert.ToInt32(ddlViewOrderLinks.SelectedValue) + 1;
                            LinkController.UpdateViewOrder(objLink, 1, this.ModuleId);
                            break;
                        }

                        default:
                        {
                            objLink.ViewOrder = Null.NullInteger;
                            break;
                        }
                        }
                    }
                    else
                    {
                        objLink.ViewOrder = Null.NullInteger;
                    }

                    objLink.Description = txtDescription.Text;
                    objLink.GrantRoles  = ";";

                    foreach (ListItem cb in cblGrantRoles.Items)
                    {
                        if (cb.Selected)
                        {
                            objLink.GrantRoles += cb.Value + ";";
                        }
                    }

                    if (objLink.GrantRoles.Equals(";"))
                    {
                        objLink.GrantRoles += "0;";
                    }

                    // Create an instance of the Link DB component

                    if (Common.Utilities.Null.IsNull(itemId))
                    {
                        LinkController.AddLink(objLink);
                    }
                    else
                    {
                        LinkController.UpdateLink(objLink);
                    }

                    ModuleController.SynchronizeModule(ModuleId);

                    // url tracking
                    UrlController objUrls = new UrlController();
                    objUrls.UpdateUrl(PortalId, ctlURL.Url, ctlURL.UrlType, ctlURL.Log, ctlURL.Track, ModuleId, ctlURL.NewWindow);

                    // Redirect back to the portal home page
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
                }
            }
            catch (Exception exc)
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #11
0
    // Modified version of BaseInputModule.HandlePointerExitAndEnter that calls EventExecutor instead of
    // UnityEngine.EventSystems.ExecuteEvents.
    private void HandlePointerExitAndEnter(PointerEventData currentPointerData, GameObject newEnterTarget)
    {
        // If we have no target or pointerEnter has been deleted then
        // just send exit events to anything we are tracking.
        // Afterwards, exit.
        if (newEnterTarget == null || currentPointerData.pointerEnter == null)
        {
            for (var i = 0; i < currentPointerData.hovered.Count; ++i)
            {
                EventExecutor.Execute(currentPointerData.hovered[i], currentPointerData, ExecuteEvents.pointerExitHandler);
            }

            currentPointerData.hovered.Clear();

            if (newEnterTarget == null)
            {
                currentPointerData.pointerEnter = newEnterTarget;
                return;
            }
        }

        // If we have not changed hover target.
        if (newEnterTarget && currentPointerData.pointerEnter == newEnterTarget)
        {
            return;
        }

        GameObject commonRoot = ModuleController.FindCommonRoot(currentPointerData.pointerEnter, newEnterTarget);

        // We already an entered object from last time.
        if (currentPointerData.pointerEnter != null)
        {
            // Send exit handler call to all elements in the chain
            // until we reach the new target, or null!
            Transform t = currentPointerData.pointerEnter.transform;

            while (t != null)
            {
                // If we reach the common root break out!
                if (commonRoot != null && commonRoot.transform == t)
                {
                    break;
                }

                EventExecutor.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerExitHandler);
                currentPointerData.hovered.Remove(t.gameObject);
                t = t.parent;
            }
        }

        // Now issue the enter call up to but not including the common root.
        currentPointerData.pointerEnter = newEnterTarget;
        if (newEnterTarget != null)
        {
            Transform t = newEnterTarget.transform;

            while (t != null && t.gameObject != commonRoot)
            {
                EventExecutor.Execute(t.gameObject, currentPointerData, ExecuteEvents.pointerEnterHandler);
                currentPointerData.hovered.Add(t.gameObject);
                t = t.parent;
            }
        }
    }
Example #12
0
        private void BindData()
        {
            this.LocalizeModule();

            Dictionary <int, ModuleInfo> .ValueCollection collModule = new ModuleController().GetTabModules(this.TabId).Values;

            foreach (ModuleInfo objModule in collModule)
            {
                if (objModule.ModuleID == this.ModuleId && objModule.IsDeleted == false)
                {
                    continue;
                }

                if (!string.IsNullOrEmpty(objModule.ModuleTitle.Trim()))
                {
                    this.cboModuleList.Items.Add(new ListItem(objModule.ModuleTitle, objModule.ModuleID.ToString()));
                }
                else
                {
                    this.cboModuleList.Items.Add(new ListItem(this.GetLocalizedString("NoName.Text"), objModule.ModuleID.ToString()));
                }
            }
            this.cboModuleList.Items.Insert(0, new ListItem("---"));

            this.cboModuleView.Items.Add(new ListItem(this.GetLocalizedString("cboModuleView.Items.Comments"), "comments"));
            this.cboModuleView.Items.Add(new ListItem(this.GetLocalizedString("cboModuleView.Items.Combination"), "combination"));
            this.cboModuleView.Items.Add(new ListItem(this.GetLocalizedString("cboModuleView.Items.RecentComments"), "recent-comments"));
            this.cboModuleView.Items.Add(new ListItem(this.GetLocalizedString("cboModuleView.Items.PopularThreads"), "popular-threads"));
            this.cboModuleView.Items.Add(new ListItem(this.GetLocalizedString("cboModuleView.Items.TopCommenters"), "top-commenters"));

            for (int i = 1; i < 21; i++)
            {
                this.cboDisplayItems.Items.Add(new ListItem(i.ToString()));
            }

            this.cboColorTheme.Items.Add(new ListItem(this.GetLocalizedString("cboColorTheme.Items.Blue"), "blue"));
            this.cboColorTheme.Items.Add(new ListItem(this.GetLocalizedString("cboColorTheme.Items.Grey"), "grey"));
            this.cboColorTheme.Items.Add(new ListItem(this.GetLocalizedString("cboColorTheme.Items.Green"), "green"));
            this.cboColorTheme.Items.Add(new ListItem(this.GetLocalizedString("cboColorTheme.Items.Red"), "red"));
            this.cboColorTheme.Items.Add(new ListItem(this.GetLocalizedString("cboColorTheme.Items.Orange"), "orange"));

            this.cboDefaultTab.Items.Add(new ListItem(this.GetLocalizedString("cboDefaultTab.Items.People"), "people"));
            this.cboDefaultTab.Items.Add(new ListItem(this.GetLocalizedString("cboDefaultTab.Items.Recent"), "recent"));
            this.cboDefaultTab.Items.Add(new ListItem(this.GetLocalizedString("cboDefaultTab.Items.Popular"), "popular"));

            this.cboAvatarSize.Items.Add(new ListItem(this.GetLocalizedString("cboAvatarSize.Items.Small"), "24"));
            this.cboAvatarSize.Items.Add(new ListItem(this.GetLocalizedString("cboAvatarSize.Items.Medium"), "32"));
            this.cboAvatarSize.Items.Add(new ListItem(this.GetLocalizedString("cboAvatarSize.Items.Large"), "48"));
            this.cboAvatarSize.Items.Add(new ListItem(this.GetLocalizedString("cboAvatarSize.Items.XLarge"), "92"));
            this.cboAvatarSize.Items.Add(new ListItem(this.GetLocalizedString("cboAvatarSize.Items.Ginormous"), "128"));

            this.cmdReceiverFile.Visible = (!this.DoesReceiverFileExist() || string.IsNullOrEmpty(DisqusApplicationName) == false);
            this.pnlReceiverFile.Visible = (this.DoesReceiverFileExist());

            if (this.pnlReceiverFile.Visible)
            {
                this.lblReceiverFile.Text = this.Page.ResolveUrl(this.CrossDomainReceiverUrlPath());
            }

            pnlHost.Visible = UserInfo.IsSuperUser;

            this.LoadSettings();

            this.LoadFormFields();
        }
 public void InitWithZeroThreadNumberThrowsArgumentException()
 {
     var testee = new ModuleController();
     testee.Invoking(t => t.Initialize(new TestModule(), 0))
         .ShouldThrow<ArgumentException>();
 }
 public void InitWithZeroThreadNumberThrowsArgumentException()
 {
     var testee = new ModuleController();
     Assert.Throws<ArgumentException>(
         () => testee.Initialize(new TestModule(), 0));
 }
Example #15
0
        public override void UpdateSettings()
        {
            var controller = new ModuleController();

            controller.UpdateModuleSetting(ModuleId, "ScriptFile", scriptList.SelectedValue);
        }
Example #16
0
 public void TearDown()
 {
     ModuleController.ClearInstance();
     TabController.ClearInstance();
 }
 public void InitWithModuleWithModuleWithNoMessageConsumerMethod()
 {
     var testee = new ModuleController();
     Assert.Throws<ArgumentException>(
         () => testee.Initialize(new ModuleWithNoMessageConsumerMethod()));
 }
 public PARentals_ScheduleSettings(int tabModuleId)
 {
     controller       = new ModuleController();
     this.tabModuleId = tabModuleId;
 }
Example #19
0
        /// <summary>
        /// ExportModule implements the IPortable ExportModule Interface
        /// </summary>
        /// <param name="moduleId">The Id of the module to be exported</param>
        /// <history>
        ///		[cnurse]	    17 Nov 2004	documented
        ///		[aglenwright]	18 Feb 2006	Added new fields: Createddate, description,
        ///                             modifiedbyuser, modifieddate, OwnedbyUser, SortorderIndex
        ///                             Added DocumentsSettings
        ///   [togrean]     10 Jul 2007 Fixed issues with importing documet settings since new fileds
        ///                             were added: AllowSorting, default folder, list name
        ///   [togrean]     13 Jul 2007 Added support for exporting documents Url tracking options
        /// </history>
        public string ExportModule(int moduleId)
        {
            var mCtrl  = new ModuleController();
            var module = mCtrl.GetModule(moduleId, Null.NullInteger);

            var strXml = new StringBuilder("<documents>");

            try {
                var documents = DocumentsDataProvider.Instance.GetDocuments(moduleId, module.PortalID);

                var now = DateTime.Now;
                if (documents.Any())
                {
                    foreach (var document in documents)
                    {
                        strXml.Append("<document>");
                        strXml.AppendFormat("<title>{0}</title>", XmlUtils.XMLEncode(document.Title));
                        strXml.AppendFormat("<url>{0}</url>", XmlUtils.XMLEncode(document.Url));
                        strXml.AppendFormat("<category>{0}</category>", XmlUtils.XMLEncode(document.Category));
                        strXml.AppendFormat(
                            "<description>{0}</description>",
                            XmlUtils.XMLEncode(document.Description));
                        strXml.AppendFormat(
                            "<forcedownload>{0}</forcedownload>",
                            XmlUtils.XMLEncode(document.ForceDownload.ToString()));
                        strXml.AppendFormat("<startDate>{0}</startDate>", XmlUtils.XMLEncode(document.StartDate.ToString()));
                        strXml.AppendFormat("<endDate>{0}</endDate>", XmlUtils.XMLEncode(document.EndDate.ToString()));
                        strXml.AppendFormat(
                            "<ownedbyuserid>{0}</ownedbyuserid>",
                            XmlUtils.XMLEncode(document.OwnedByUserId.ToString()));
                        strXml.AppendFormat(
                            "<sortorderindex>{0}</sortorderindex>",
                            XmlUtils.XMLEncode(document.SortOrderIndex.ToString()));
                        strXml.AppendFormat(
                            "<linkattributes>{0}</linkattributes>",
                            XmlUtils.XMLEncode(document.LinkAttributes));

                        // Export Url Tracking options too
                        var urlCtrl         = new UrlController();
                        var urlTrackingInfo = urlCtrl.GetUrlTracking(module.PortalID, document.Url, moduleId);

                        if ((urlTrackingInfo != null))
                        {
                            strXml.AppendFormat(
                                "<logactivity>{0}</logactivity>",
                                XmlUtils.XMLEncode(urlTrackingInfo.LogActivity.ToString()));
                            strXml.AppendFormat(
                                "<trackclicks>{0}</trackclicks>",
                                XmlUtils.XMLEncode(urlTrackingInfo.TrackClicks.ToString()));
                            strXml.AppendFormat("<newwindow>{0}</newwindow>", XmlUtils.XMLEncode(urlTrackingInfo.NewWindow.ToString()));
                        }
                        strXml.Append("</document>");
                    }
                }

                ExportSettings(module, strXml);
            }
            catch (Exception ex) {
                Exceptions.LogException(ex);
            }
            finally {
                // make sure XML is valid
                strXml.Append("</documents>");
            }

            return(strXml.ToString());
        }
        //Private Sub tsTags_Callback(ByVal sender As Object, ByVal e As Modules.ActiveForums.Controls.CallBackEventArgs) Handles tsTags.Callback
        //    tsTags.Datasource = DataProvider.Instance.Tags_Search(PortalId, ModuleId, e.Parameter.ToString + "%")
        //    tsTags.Refresh(e.Output)
        //End Sub

        private void lnkUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                // Construct Forums
                var forums = string.Empty;
                if (GetNodeCount() != trForums.CheckedNodes.Count)
                {
                    if (trForums.CheckedNodes.Count > 1)
                    {
                        forums = string.Empty;
                        foreach (TreeNode tr in trForums.CheckedNodes)
                        {
                            if (tr.Value.Contains("F:"))
                            {
                                forums += tr.Value.Split(':')[1] + ":";
                            }
                        }
                    }
                    else
                    {
                        var sv = trForums.CheckedNodes[0].Value;
                        if (sv.Contains("F:"))
                        {
                            forums = sv.Split(':')[1];
                        }
                    }
                }

                var mc = new ModuleController();

                // Load the current settings
                var settings = WhatsNewModuleSettings.CreateFromModuleSettings(mc.GetModuleSettings(ModuleId));

                // Update Settings Values
                settings.Forums = forums;

                int rows;
                if (int.TryParse(txtNumItems.Text, out rows))
                {
                    settings.Rows = int.Parse(txtNumItems.Text);
                }

                settings.Format      = txtTemplate.Text;
                settings.Header      = txtHeader.Text;
                settings.Footer      = txtFooter.Text;
                settings.RSSEnabled  = chkRSS.Checked;
                settings.TopicsOnly  = chkTopicsOnly.Checked;
                settings.RandomOrder = chkRandomOrder.Checked;
                settings.Tags        = txtTags.Text;

                if (chkRSS.Checked)
                {
                    settings.RSSIgnoreSecurity = chkIgnoreSecurity.Checked;
                    settings.RSSIncludeBody    = chkIncludeBody.Checked;

                    int rssCacheTimeout;
                    if (int.TryParse(txtCache.Text, out rssCacheTimeout))
                    {
                        settings.RSSCacheTimeout = rssCacheTimeout;
                    }
                }

                // Save Settings
                settings.Save(mc, ModuleId);

                // Redirect back to the portal home page
                Response.Redirect(Common.Globals.NavigateURL(), true);
            }
            catch (Exception exc)
            {
                Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Example #21
0
        public static List <UrlRule> GetRules(int portalId)
        {
            object padlock = new object();

            lock (padlock)
            {
                List <UrlRule> rules    = new List <UrlRule>();
                List <UrlRule> catrules = new List <UrlRule>();

                #if DEBUG
                decimal speed;
                string  mess;
                var     stopwatch = new System.Diagnostics.Stopwatch();
                stopwatch.Start();
                #endif

                var purgeResult    = UrlRulesCaching.PurgeExpiredItems(portalId);
                var portalCacheKey = UrlRulesCaching.GeneratePortalCacheKey(portalId, null);
                var portalRules    = UrlRulesCaching.GetCache(portalId, portalCacheKey, purgeResult.ValidCacheItems);
                if (portalRules != null && portalRules.Count > 0)
                {
                    #if DEBUG
                    stopwatch.Stop();
                    speed = stopwatch.Elapsed.Milliseconds;
                    mess  = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. All Cached. PurgedItems: {purgeResult.PurgedItemCount}. Speed: {speed}";
                    Logger.Error(mess);
                    #endif
                    return(portalRules);
                }

                Dictionary <string, Locale> dicLocales = LocaleController.Instance.GetLocales(portalId);

                var objCtrl = new NBrightBuyController();

                var storesettings = new StoreSettings(portalId);

                ModuleController mc  = new ModuleController();
                var modules          = mc.GetModulesByDefinition(portalId, "NBS_ProductDisplay").OfType <ModuleInfo>();
                var modulesOldModule = mc.GetModulesByDefinition(portalId, "NBS_ProductView").OfType <ModuleInfo>();
                modules = modules.Concat(modulesOldModule);

                // ------- Category URL ---------------

                #region "Category Url"

                // Not using the module loop!!
                // becuase tabs that are defined in the url are dealt with by open url rewriter, so we only need use the default tab which is defined by the store settings.

                foreach (KeyValuePair <string, Locale> key in dicLocales)
                {
                    try
                    {
                        string cultureCode     = key.Value.Code;
                        string ruleCultureCode = (dicLocales.Count > 1 ? cultureCode : null);

                        var grpCatCtrl = new GrpCatController(cultureCode, portalId);

                        // get all products in portal, with lang data
                        var catitems = objCtrl.GetList(portalId, -1, "CATEGORY");

                        foreach (var catData in catitems)
                        {
                            var catDataLang = objCtrl.GetDataLang(catData.ItemID, cultureCode);

                            if (catDataLang != null && !catData.GetXmlPropertyBool("genxml/checkbox/chkishidden"))
                            {
                                var            catCacheKey   = portalCacheKey + "_" + catDataLang.ItemID + "_" + cultureCode;
                                List <UrlRule> categoryRules = UrlRulesCaching.GetCache(portalId, catCacheKey, purgeResult.ValidCacheItems);
                                if (categoryRules != null && categoryRules.Count > 0)
                                {
                                    rules.AddRange(categoryRules);
                                }
                                else
                                {
                                    catrules = new List <UrlRule>();

                                    var caturlname   = catDataLang.GUIDKey;
                                    var SEOName      = catDataLang.GetXmlProperty("genxml/textbox/txtseoname");
                                    var categoryName = catDataLang.GetXmlProperty("genxml/textbox/txtcategoryname");

                                    var newcatUrl = grpCatCtrl.GetBreadCrumb(catData.ItemID, 0, "/", false);

                                    var url = newcatUrl;
                                    if (!string.IsNullOrEmpty(url))
                                    {
                                        // ------- Category URL ---------------

                                        var rule = new UrlRule
                                        {
                                            CultureCode = ruleCultureCode,
                                            TabId       = storesettings.ProductListTabId,
                                            Parameters  = "catref=" + caturlname,
                                            Url         = url
                                        };
                                        var reducedRules =
                                            rules.Where(r => r.CultureCode == rule.CultureCode && r.TabId == rule.TabId)
                                            .ToList();
                                        bool ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                        if (!ruleExist)
                                        {
                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                            {
                                                rule.Url = catData.ItemID + "-" + url;
                                            }
                                            rules.Add(rule);
                                            catrules.Add(rule);
                                        }

                                        var proditems = objCtrl.GetList(catData.PortalId, -1, "CATXREF", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        var l2        = objCtrl.GetList(catData.PortalId, -1, "CATCASCADE", " and NB1.XRefItemId = " + catData.ItemID.ToString(""));
                                        proditems.AddRange(l2);

                                        var pageurl  = "";
                                        var pageurl1 = rule.Url;
                                        // do paging for category (on all product modules.)
                                        foreach (var module in modules)
                                        {
                                            // ------- Paging URL ---------------
                                            var modsetting        = NBrightBuyUtils.GetSettings(portalId, module.ModuleID);
                                            var pagesize          = modsetting.GetXmlPropertyInt("genxml/textbox/pagesize");
                                            var staticlist        = modsetting.GetXmlPropertyBool("genxml/checkbox/staticlist");
                                            var defaultcatid      = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultpropertyid");
                                            var defaultpropertyid = modsetting.GetXmlPropertyBool("genxml/dropdownlist/defaultcatid");
                                            if (pagesize > 0)
                                            {
                                                if (module.TabID != storesettings.ProductListTabId || staticlist)
                                                {
                                                    // on the non-default product list tab, add the moduleid, so we dont; get duplicates.
                                                    // NOTE: this only supports defaut paging url for 1 module on the defaut product list page. Other modules will have moduleid added to the url.

                                                    //pageurl = module.ModuleID + "-" + pageurl1;

                                                    //IGNORE NON DEFAULT MODULES.
                                                }
                                                else
                                                {
                                                    pageurl = pageurl1;


                                                    var pagetotal = Convert.ToInt32((proditems.Count / pagesize) + 1);
                                                    for (int i = 1; i <= pagetotal; i++)
                                                    {
                                                        rule = new UrlRule
                                                        {
                                                            CultureCode = ruleCultureCode,
                                                            TabId       = module.TabID,
                                                            Parameters  = "catref=" + caturlname + "&page=" + i + "&pagemid=" + module.ModuleID,
                                                            Url         = pageurl + "-" + i
                                                        };
                                                        ruleExist = reducedRules.Any(r => r.Parameters == rule.Parameters);
                                                        if (!ruleExist)
                                                        {
                                                            if (reducedRules.Any(r => r.Url == rule.Url)) // if duplicate url
                                                            {
                                                                rule.Url = module.ModuleID + "-" + rule.Url;
                                                            }
                                                            rules.Add(rule);
                                                            catrules.Add(rule);
                                                        }
                                                    }
                                                }
                                            }
                                        }

                                        // ------- Product URL ---------------
                                        foreach (var xrefData in proditems)
                                        {
                                            //var product = new ProductData(xrefData.ParentItemId, cultureCode, false);
                                            var prdData = objCtrl.GetData(xrefData.ParentItemId, cultureCode);

                                            var pref = prdData.GetXmlProperty("genxml/textbox/txtproductref");

                                            string produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtseoname");
                                            ;
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.GetXmlProperty("genxml/lang/genxml/textbox/txtproductname");
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = pref;
                                            }
                                            if (string.IsNullOrEmpty(produrl))
                                            {
                                                produrl = prdData.ItemID.ToString("");
                                            }
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            //if (catref != "") produrl = catref + "-" + produrl;
                                            produrl = newcatUrl + "/" + Utils.UrlFriendly(produrl);
                                            var prodrule = new UrlRule
                                            {
                                                CultureCode = ruleCultureCode,
                                                TabId       = storesettings.ProductDetailTabId,
                                                Parameters  = "catref=" + catDataLang.GUIDKey + "&ref=" + prdData.GUIDKey,
                                                Url         = produrl
                                            };
                                            reducedRules =
                                                rules.Where(
                                                    r => r.CultureCode == prodrule.CultureCode && r.TabId == prodrule.TabId)
                                                .ToList();
                                            ruleExist = reducedRules.Any(r => r.Parameters == prodrule.Parameters);
                                            if (!ruleExist)
                                            {
                                                if (reducedRules.Any(r => r.Url == prodrule.Url)) // if duplicate url
                                                {
                                                    prodrule.Url = prdData.ItemID + "-" + produrl;
                                                }
                                                rules.Add(prodrule);
                                                catrules.Add(prodrule);
                                            }
                                        }
                                    }
                                    UrlRulesCaching.SetCache(portalId, catCacheKey, new TimeSpan(1, 0, 0, 0), catrules);
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.Error("Failed to generate url for module NBS", ex);
                    }
                }

                #endregion


                UrlRulesCaching.SetCache(portalId, portalCacheKey, new TimeSpan(1, 0, 0, 0), rules);


                #if DEBUG
                stopwatch.Stop();
                mess = $"PortalId: {portalId}. Time elapsed: {stopwatch.Elapsed.Milliseconds}ms. Module Count: {modules.Count()}. PurgedItems: {purgeResult.PurgedItemCount}";
                Logger.Error(mess);
                Console.WriteLine(mess);
                #endif


                return(rules);
            }
        }
        /// <summary>
        /// Fills the active forums list.
        /// </summary>
        private void FillActiveForumsList()
        {
            var objTabController = new TabController();

            var objDesktopModuleInfo =
                DesktopModuleController.GetDesktopModuleByModuleName("Active Forums", this.PortalId);

            if (objDesktopModuleInfo == null)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
                return;
            }

            var tabs = TabController.GetPortalTabs(this.PortalSettings.PortalId, -1, true, true);

            foreach (var tabInfo in tabs.Where(tab => !tab.IsDeleted))
            {
                var moduleController = new ModuleController();

                foreach (var pair in moduleController.GetTabModules(tabInfo.TabID))
                {
                    var moduleInfo = pair.Value;

                    if (moduleInfo.IsDeleted)
                    {
                        continue;
                    }

                    if (moduleInfo.DesktopModuleID != objDesktopModuleInfo.DesktopModuleID)
                    {
                        continue;
                    }

                    var path        = tabInfo.TabName;
                    var tabSelected = tabInfo;

                    while (tabSelected.ParentId != Null.NullInteger)
                    {
                        tabSelected = objTabController.GetTab(tabSelected.ParentId, tabInfo.PortalID, false);
                        if (tabSelected == null)
                        {
                            break;
                        }

                        path = $"{tabSelected.TabName} -> {path}";
                    }

                    var objListItem = new ListItem
                    {
                        Value = moduleInfo.ModuleID.ToString(),
                        Text  = $"{path} -> {moduleInfo.ModuleTitle}"
                    };

                    this.ActiveForums.Items.Add(objListItem);
                }
            }

            if (this.ActiveForums.Items.Count == 0)
            {
                this.ActiveForumsPlaceHolder.Visible = false;
            }
        }
    private void CastRay()
    {
        Vector2 currentPose = lastPose;

        if (IsPointerActiveAndAvailable())
        {
            currentPose = GvrMathHelpers.NormalizedCartesianToSpherical(Pointer.PointerTransform.forward);
        }

        if (CurrentEventData == null)
        {
            CurrentEventData = new PointerEventData(ModuleController.eventSystem);
            lastPose         = currentPose;
        }

        // Store the previous raycast result.
        RaycastResult previousRaycastResult = CurrentEventData.pointerCurrentRaycast;

        // The initial cast must use the enter radius.
        if (IsPointerActiveAndAvailable())
        {
            Pointer.ShouldUseExitRadiusForRaycast = false;
        }

        // Cast a ray into the scene
        CurrentEventData.Reset();
        // Set the position to the center of the camera.
        // This is only necessary if using the built-in Unity raycasters.
        RaycastResult raycastResult;

        CurrentEventData.position = GvrVRHelpers.GetViewportCenter();
        bool isPointerActiveAndAvailable = IsPointerActiveAndAvailable();

        if (isPointerActiveAndAvailable)
        {
            RaycastAll();
            raycastResult = ModuleController.FindFirstRaycast(ModuleController.RaycastResultCache);
        }
        else
        {
            raycastResult = new RaycastResult();
            raycastResult.Clear();
        }

        // If we were already pointing at an object we must check that object against the exit radius
        // to make sure we are no longer pointing at it to prevent flicker.
        if (previousRaycastResult.gameObject != null &&
            raycastResult.gameObject != previousRaycastResult.gameObject &&
            isPointerActiveAndAvailable)
        {
            Pointer.ShouldUseExitRadiusForRaycast = true;
            RaycastAll();
            RaycastResult firstResult = ModuleController.FindFirstRaycast(ModuleController.RaycastResultCache);
            if (firstResult.gameObject == previousRaycastResult.gameObject)
            {
                raycastResult = firstResult;
            }
        }

        if (raycastResult.gameObject != null && raycastResult.worldPosition == Vector3.zero)
        {
            raycastResult.worldPosition =
                GvrMathHelpers.GetIntersectionPosition(CurrentEventData.enterEventCamera, raycastResult);
        }

        CurrentEventData.pointerCurrentRaycast = raycastResult;

        // Find the real screen position associated with the raycast
        // Based on the results of the hit and the state of the pointerData.
        if (raycastResult.gameObject != null)
        {
            CurrentEventData.position = raycastResult.screenPosition;
        }
        else if (IsPointerActiveAndAvailable() && CurrentEventData.enterEventCamera != null)
        {
            Vector3 pointerPos = Pointer.MaxPointerEndPoint;
            CurrentEventData.position = CurrentEventData.enterEventCamera.WorldToScreenPoint(pointerPos);
        }

        ModuleController.RaycastResultCache.Clear();
        CurrentEventData.delta = currentPose - lastPose;
        lastPose = currentPose;

        // Check to make sure the Raycaster being used is a GvrRaycaster.
        if (raycastResult.module != null &&
            !(raycastResult.module is GvrPointerGraphicRaycaster) &&
            !(raycastResult.module is GvrPointerPhysicsRaycaster))
        {
            Debug.LogWarning("Using Raycaster (Raycaster: " + raycastResult.module.GetType() +
                             ", Object: " + raycastResult.module.name + "). It is recommended to use " +
                             "GvrPointerPhysicsRaycaster or GvrPointerGrahpicRaycaster with GvrPointerInputModule.");
        }
    }
Example #24
0
        private string GenerateUrl(HccRoute route, string actionName, string controllerName, string protocol,
                                   string hostName, string fragment, RouteValueDictionary routeValues, RouteCollection routeCollection,
                                   RequestContext requestContext, bool includeImplicitMvcValues)
        {
            // Code that search DNN module corresponding to concrete route have to be here
            // Route params have to be added to the url too.

            var urlInfo = new DnnUrlInfo();

            if (route == HccRoute.Login)
            {
                return(Globals.LoginURL((string)routeValues["returnUrl"], false));
            }
            if (route == HccRoute.Terms)
            {
                return(Globals.NavigateURL("Terms"));
            }
            if (route == HccRoute.Logoff)
            {
                return(Globals.NavigateURL("LogOff"));
            }
            if (route == HccRoute.SendPassword)
            {
                return(Globals.NavigateURL("SendPassword"));
            }
            if (route == HccRoute.UserProfile)
            {
                var userId = 0;
                if (int.TryParse((string)routeValues["userId"], out userId))
                {
                    return(Globals.UserProfileURL(userId));
                }
                throw new ApplicationException("UserId is not a number");
            }
            urlInfo = GetTabId(route);

            var paramsList = new List <string>();

            if (!string.IsNullOrEmpty(urlInfo.ControlKey))
            {
                var moduleCtl = new ModuleController();
                var mInfo     = moduleCtl.GetTabModules(urlInfo.TabId)
                                .Where(m => m.Value.DesktopModule.ModuleName == urlInfo.ModuleName)
                                .Select(m => m.Value)
                                .FirstOrDefault();

                if (mInfo != null)
                {
                    paramsList.Add("mid=" + mInfo.ModuleID);
                }
            }

            if (routeValues != null)
            {
                foreach (var newQueryItem in routeValues)
                {
                    var isParamValid = newQueryItem.Value != null;
                    if (newQueryItem.Value is string)
                    {
                        isParamValid = !string.IsNullOrWhiteSpace(newQueryItem.Value as string);
                    }

                    if (isParamValid)
                    {
                        var parameter = string.Format("{0}={1}", newQueryItem.Key, newQueryItem.Value);
                        paramsList.Add(parameter);
                    }
                }
            }

            var portalSettings = CurrentPortalSettings;
            var isSuperTab     = Globals.IsHostTab(urlInfo.TabId);
            var parameters     = paramsList.ToArray();

            var navigateUrl = string.Empty;

            if (PortalSettings.Current != null)
            {
                navigateUrl = Globals.NavigateURL(urlInfo.TabId, isSuperTab, portalSettings, urlInfo.ControlKey, null,
                                                  parameters);
            }
            else
            {
                navigateUrl = NavigateUrl(urlInfo.TabId, isSuperTab, portalSettings, urlInfo.ControlKey, parameters);
            }
            return(navigateUrl);
        }
        public void MessagesAreConsumedMultithreaded()
        {
            this.module = new TestModule();
            this.testee = new ModuleController();
            this.testee.Initialize(this.module, 10);

            this.module.Controller = this.testee;

            const int NumberOfMessages = 1000;

            this.EnqueueAndConsume(NumberOfMessages);
        }
Example #26
0
        private int AddNewModule(TabInfo tab, string title, int desktopModuleId, string paneName, int permissionType, string align)
        {
            TabPermissionCollection objTabPermissions = tab.TabPermissions;
            var objPermissionController = new PermissionController();
            var objModules = new ModuleController();
            int j;
            var mdc = new ModuleDefinitionController();

            foreach (ModuleDefinitionInfo objModuleDefinition in ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.Initialize(tab.PortalID);

                objModule.PortalID = tab.PortalID;
                objModule.TabID    = tab.TabID;
                if (string.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName               = paneName;
                objModule.ModuleDefID            = objModuleDefinition.ModuleDefID;
                objModule.CacheTime              = 0;
                objModule.InheritViewPermissions = true;
                objModule.DisplayTitle           = false;

                // get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                // get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == 0)
                    {
                        //Don't need to explicitly add View permisisons if "Same As Page"
                        continue;
                    }

                    // get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    // loop through the system module permissions
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        // create the module permission
                        PermissionInfo objSystemModulePermission = default(PermissionInfo);
                        objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == 1 && objTabPermission.PermissionKey != "EDIT")
                        {
                            //Only Page Editors get View permissions if "Page Editors Only"
                            continue;
                        }

                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule,
                                                                                       objSystemModulePermission,
                                                                                       objTabPermission.RoleID,
                                                                                       objTabPermission.UserID,
                                                                                       objTabPermission.AllowAccess);

                        // ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule,
                                                                                         (PermissionInfo)arrSystemModuleViewPermissions[0],
                                                                                         objModulePermission.RoleID,
                                                                                         objModulePermission.UserID,
                                                                                         true);
                        }
                    }
                }

                objModule.AllTabs   = false;
                objModule.Alignment = align;

                return(objModules.AddModule(objModule));
            }
            return(-1);
        }
 private Int32 CheckUniqueControlType(int _modulecontriolid, int _moduledefid, int _controlType, int _portalId, bool _isEdit)
 {
     ModuleController objController = new ModuleController();
     return objController.CheckUnquieModuleControlsControlType(_modulecontriolid, _moduledefid, _controlType, _portalId, _isEdit);
 }
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of banner information from the Banners
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the DotNetNuke.BannerDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            cmdUpdate.Click += cmdUpdate_Click;
            cmdCancel.Click += cmdCancel_Click;
            DNNTxtBannerGroup.PopulateOnDemand += DNNTxtBannerGroup_PopulateOnDemand;

            try
            {
                if (!Page.IsPostBack)
                {
                    //Obtain banner information from the Banners table and bind to the list control
                    var objBannerTypes = new BannerTypeController();

                    cboType.DataSource = objBannerTypes.GetBannerTypes();
                    cboType.DataBind();
                    cboType.Items.Insert(0, new ListItem(Localization.GetString("AllTypes", LocalResourceFile), "-1"));

                    if (ModuleId > 0)
                    {
                        //Get settings from the database
                        Hashtable settings = new ModuleController().GetModuleSettings(ModuleId);

                        if (optSource.Items.FindByValue(Convert.ToString(settings["bannersource"])) != null)
                        {
                            optSource.Items.FindByValue(Convert.ToString(settings["bannersource"])).Selected = true;
                        }
                        else
                        {
                            optSource.Items.FindByValue("L").Selected = true;
                        }
                        if (cboType.Items.FindByValue(Convert.ToString(settings["bannertype"])) != null)
                        {
                            cboType.Items.FindByValue(Convert.ToString(settings["bannertype"])).Selected = true;
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(settings["bannergroup"])))
                        {
                            DNNTxtBannerGroup.Text = Convert.ToString(settings["bannergroup"]);
                        }
                        if (optOrientation.Items.FindByValue(Convert.ToString(settings["orientation"])) != null)
                        {
                            optOrientation.Items.FindByValue(Convert.ToString(settings["orientation"])).Selected = true;
                        }
                        else
                        {
                            optOrientation.Items.FindByValue("V").Selected = true;
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(settings["bannercount"])))
                        {
                            txtCount.Text = Convert.ToString(settings["bannercount"]);
                        }
                        else
                        {
                            txtCount.Text = "1";
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(settings["border"])))
                        {
                            txtBorder.Text = Convert.ToString(settings["border"]);
                        }
                        else
                        {
                            txtBorder.Text = "0";
                        }
                        if (!String.IsNullOrEmpty(Convert.ToString(settings["padding"])))
                        {
                            txtPadding.Text = Convert.ToString(settings["padding"]);
                        }
                        else
                        {
                            txtPadding.Text = "4";
                        }
                        txtBorderColor.Text           = Convert.ToString(settings["bordercolor"]);
                        txtRowHeight.Text             = Convert.ToString(settings["rowheight"]);
                        txtColWidth.Text              = Convert.ToString(settings["colwidth"]);
                        txtBannerClickThroughURL.Text = Convert.ToString(settings["bannerclickthroughurl"]);
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
 public void InitWithNullModuleThrowsArgumentNullException()
 {
     var testee = new ModuleController();
     Assert.Throws<ArgumentNullException>(
         () => testee.Initialize(null));
 }
Example #30
0
        protected void enabledCheckbox_CheckChanged(object sender, EventArgs e)
        {
            try
            {
                if ((sender) is DnnCheckBox)
                {
                    var    enabledCheckbox = (DnnCheckBox)sender;
                    int    languageId      = int.Parse(enabledCheckbox.CommandArgument);
                    Locale locale          = LocaleController.Instance.GetLocale(languageId);
                    Locale defaultLocale   = LocaleController.Instance.GetDefaultLocale(PortalId);

                    Dictionary <string, Locale> enabledLanguages = LocaleController.Instance.GetLocales(PortalId);

                    var tabController = new TabController();
                    var localizedTabs = PortalSettings.ContentLocalizationEnabled ?
                                        tabController.GetTabsByPortal(PortalId).WithCulture(locale.Code, false).AsList() : new List <TabInfo>();

                    var redirectUrl = string.Empty;
                    if (enabledCheckbox.Enabled)
                    {
                        // do not touch default language
                        if (enabledCheckbox.Checked)
                        {
                            if (!enabledLanguages.ContainsKey(locale.Code))
                            {
                                //Add language to portal
                                Localization.AddLanguageToPortal(PortalId, languageId, true);
                            }

                            //restore the tabs and modules
                            var moduleController = new ModuleController();
                            foreach (var tab in localizedTabs)
                            {
                                tabController.RestoreTab(tab, PortalSettings);
                                moduleController.GetTabModules(tab.TabID).Values.ToList().ForEach(moduleController.RestoreModule);
                            }
                        }
                        else
                        {
                            //remove language from portal
                            Localization.RemoveLanguageFromPortal(PortalId, languageId);

                            //if the disable language is current language, should redirect to default language.
                            if (locale.Code.Equals(Thread.CurrentThread.CurrentUICulture.ToString(), StringComparison.InvariantCultureIgnoreCase))
                            {
                                redirectUrl = Globals.NavigateURL(PortalSettings.ActiveTab.TabID,
                                                                  PortalSettings.ActiveTab.IsSuperTab,
                                                                  PortalSettings, "", defaultLocale.Code);
                            }

                            //delete the tabs in this language
                            foreach (var tab in localizedTabs)
                            {
                                tab.DefaultLanguageGuid = Guid.Empty;
                                tabController.SoftDeleteTab(tab.TabID, PortalSettings);
                            }
                        }
                    }

                    //Redirect to refresh page (and skinobjects)
                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        redirectUrl = Globals.NavigateURL();
                    }

                    Response.Redirect(redirectUrl, true);
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
        /// <summary>
        /// Get the content data and render it with the given template to the page.
        /// </summary>
        protected void ProcessView(PlaceHolder phOutput, Panel pnlError, Panel pnlMessage)
        {
            #region Check if everything has values and return if not

            if (Template == null)
            {
                ShowError(LocalizeString("TemplateConfigurationMissing.Text"), pnlError);
                return;
            }

            if (Template.AttributeSetID.HasValue && DataSource.GetCache(ZoneId.Value, AppId.Value).GetContentType(Template.AttributeSetID.Value) == null)
            {
                ShowError("The contents of this module cannot be displayed because it's located in another VDB.", pnlError);
                return;
            }

            if (Template.AttributeSetID.HasValue && !Template.DemoEntityID.HasValue && Items.All(e => !e.EntityID.HasValue))
            {
                var toolbar = IsEditable ? "<ul class='sc-menu' data-toolbar='" + Newtonsoft.Json.JsonConvert.SerializeObject(new { sortOrder = Items.First().SortOrder, useModuleList = true, action = "edit" }) + "'></ul>" : "";
                ShowMessage(LocalizeString("NoDemoItem.Text") + " " + toolbar, pnlMessage);
                return;
            }

            #endregion

            try
            {
                //var renderTemplate = Template;
                string renderedTemplate;

                var engine     = EngineFactory.CreateEngine(Template);
                var dataSource = (ViewDataSource)Sexy.GetViewDataSource(this.ModuleId, SexyContent.HasEditPermission(this.ModuleConfiguration), Template);
                engine.Init(Template, Sexy.App, this.ModuleConfiguration, dataSource, Request.QueryString["type"] == "data" ? InstancePurposes.PublishData : InstancePurposes.WebView, Sexy);
                engine.CustomizeData();

                // Output JSON data if type=data in URL
                if (Request.QueryString["type"] == "data")
                {
                    if (dataSource.Publish.Enabled)
                    {
                        var publishedStreams = dataSource.Publish.Streams;
                        renderedTemplate = Sexy.GetJsonFromStreams(dataSource, publishedStreams.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                    }
                    else
                    {
                        Response.StatusCode = 403;
                        var moduleTitle = new ModuleController().GetModule(ModuleId).ModuleTitle;
                        renderedTemplate = Newtonsoft.Json.JsonConvert.SerializeObject(new { error = "2sxc Content (" + ModuleId + "): " + String.Format(LocalizeString("EnableDataPublishing.Text"), ModuleId, moduleTitle) });
                        Response.TrySkipIisCustomErrors = true;
                    }
                    Response.ContentType = "application/json";
                }
                else
                {
                    renderedTemplate = engine.Render();
                }

                // If standalone is specified, output just the template without anything else
                if (StandAlone)
                {
                    Response.Clear();
                    Response.Write(renderedTemplate);
                    Response.Flush();
                    Response.SuppressContent = true;
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                }
                else
                {
                    phOutput.Controls.Add(new LiteralControl(renderedTemplate));
                }
            }
            // Catch errors; log them
            catch (Exception Ex)
            {
                ShowError(LocalizeString("TemplateError.Text") + ": " + HttpUtility.HtmlEncode(Ex.ToString()), pnlError, LocalizeString("TemplateError.Text"), false);
                Exceptions.LogException(Ex);
            }
        }
Example #32
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Adds a New Module to a Pane
        /// </summary>
        /// <param name="align">The alignment for the Modue</param>
        /// <param name="desktopModuleId">The Id of the DesktopModule</param>
        /// <param name="permissionType">The View Permission Type for the Module</param>
        /// <param name="title">The Title for the resulting module</param>
        /// <param name="paneName">The pane to add the module to</param>
        /// <param name="position">The relative position within the pane for the module</param>
        /// <history>
        ///     [cnurse]	01/11/2008  documented
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
        {
            TabPermissionCollection objTabPermissions = PortalSettings.ActiveTab.TabPermissions;
            var objPermissionController = new PermissionController();
            var objModules = new ModuleController();

            try
            {
                DesktopModuleInfo desktopModule;
                if (!DesktopModuleController.GetDesktopModules(PortalSettings.PortalId).TryGetValue(desktopModuleId, out desktopModule))
                {
                    throw new ArgumentException("desktopModuleId");
                }
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
            }
            int UserId = -1;

            if (Request.IsAuthenticated)
            {
                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                UserId = objUserInfo.UserID;
            }
            foreach (ModuleDefinitionInfo objModuleDefinition in
                     ModuleDefinitionController.GetModuleDefinitionsByDesktopModuleID(desktopModuleId).Values)
            {
                var objModule = new ModuleInfo();
                objModule.Initialize(PortalSettings.PortalId);
                objModule.PortalID    = PortalSettings.PortalId;
                objModule.TabID       = PortalSettings.ActiveTab.TabID;
                objModule.ModuleOrder = position;
                if (String.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }
                objModule.PaneName    = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                if (objModuleDefinition.DefaultCacheTime > 0)
                {
                    objModule.CacheTime = objModuleDefinition.DefaultCacheTime;
                    if (PortalSettings.Current.DefaultModuleId > Null.NullInteger && PortalSettings.Current.DefaultTabId > Null.NullInteger)
                    {
                        ModuleInfo defaultModule = objModules.GetModule(PortalSettings.Current.DefaultModuleId, PortalSettings.Current.DefaultTabId, true);
                        if (defaultModule != null)
                        {
                            objModule.CacheTime = defaultModule.CacheTime;
                        }
                    }
                }
                switch (permissionType)
                {
                case ViewPermissionType.View:
                    objModule.InheritViewPermissions = true;
                    break;

                case ViewPermissionType.Edit:
                    objModule.InheritViewPermissions = false;
                    break;
                }

                //get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                //get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    if (objTabPermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.View)
                    {
                        //Don't need to explicitly add View permisisons if "Same As Page"
                        continue;
                    }

                    //get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    //loop through the system module permissions
                    int j;
                    for (j = 0; j <= arrSystemModulePermissions.Count - 1; j++)
                    {
                        PermissionInfo objSystemModulePermission;
                        objSystemModulePermission = (PermissionInfo)arrSystemModulePermissions[j];
                        if (objSystemModulePermission.PermissionKey == "VIEW" && permissionType == ViewPermissionType.Edit && objTabPermission.PermissionKey != "EDIT")
                        {
                            //Only Page Editors get View permissions if "Page Editors Only"
                            continue;
                        }
                        ModulePermissionInfo objModulePermission = AddModulePermission(objModule,
                                                                                       objSystemModulePermission,
                                                                                       objTabPermission.RoleID,
                                                                                       objTabPermission.UserID,
                                                                                       objTabPermission.AllowAccess);

                        //ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" && objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = AddModulePermission(objModule,
                                                                                         (PermissionInfo)arrSystemModuleViewPermissions[0],
                                                                                         objModulePermission.RoleID,
                                                                                         objModulePermission.UserID,
                                                                                         true);
                        }
                    }

                    //Get the custom Module Permissions,  Assume that roles with Edit Tab Permissions
                    //are automatically assigned to the Custom Module Permissions
                    if (objTabPermission.PermissionKey == "EDIT")
                    {
                        ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID);

                        //loop through the custom module permissions
                        for (j = 0; j <= arrCustomModulePermissions.Count - 1; j++)
                        {
                            //create the module permission
                            PermissionInfo objCustomModulePermission;
                            objCustomModulePermission = (PermissionInfo)arrCustomModulePermissions[j];
                            AddModulePermission(objModule, objCustomModulePermission, objTabPermission.RoleID, objTabPermission.UserID, objTabPermission.AllowAccess);
                        }
                    }
                }

                if (PortalSettings.Current.ContentLocalizationEnabled)
                {
                    Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.Current.PortalId);
                    //set the culture of the module to that of the tab
                    var tabInfo = new TabController().GetTab(objModule.TabID, PortalSettings.Current.PortalId, false);
                    objModule.CultureCode = tabInfo != null ? tabInfo.CultureCode : defaultLocale.Code;
                }
                else
                {
                    objModule.CultureCode = Null.NullString;
                }

                objModule.AllTabs   = false;
                objModule.Alignment = align;
                objModules.AddModule(objModule);
            }
        }
Example #33
0
        private void LoadFormFields()
        {
            try
            {
                if (this.AttachedModule > 0)
                {
                    this.cboModuleList.Items.FindByValue(this.AttachedModule.ToString()).Selected = true;
                }
            }
            catch
            {
                ModuleController ctlModule = new ModuleController();
                ctlModule.DeleteModuleSetting(this.ModuleId, "AttachedModuleId");
                ModuleController.SynchronizeModule(this.ModuleId);
                this.cboModuleList.SelectedIndex = 0;
            }

            this.txtAppName.Text       = DisqusApplicationName;
            chkRequireDnnLogin.Checked = RequireDnnLogin;

            if (string.IsNullOrEmpty(this.DisqusView))
            {
                this.cboModuleView.Items.FindByValue("comments").Selected = true;
                this.DisqusView = "comments";
            }
            else
            {
                this.cboModuleView.Items.FindByValue(this.DisqusView).Selected = true;
            }

            if (this.DisplayItems > 0)
            {
                this.cboDisplayItems.Items.FindByValue(this.DisplayItems.ToString()).Selected = true;
            }
            else
            {
                this.cboDisplayItems.Items[0].Selected = true;
            }

            this.chkShowModerators.Checked = this.ShowModerators;

            if (string.IsNullOrEmpty(this.ColorTheme))
            {
                this.cboColorTheme.Items.FindByValue("blue").Selected = true;
            }
            else
            {
                this.cboColorTheme.Items.FindByValue(this.ColorTheme).Selected = true;
            }

            if (string.IsNullOrEmpty(this.DefaultTab))
            {
                this.cboDefaultTab.Items.FindByValue("people").Selected = true;
            }
            else
            {
                this.cboDefaultTab.Items.FindByValue(this.DefaultTab).Selected = true;
            }

            if (this.CommentLength > 0)
            {
                this.txtCommentLength.Text = this.CommentLength.ToString();
            }
            else
            {
                this.txtCommentLength.Text = "200";
            }

            this.chkShowAvatar.Checked = this.ShowAvatar;

            if (this.AvatarSize > 0)
            {
                this.cboAvatarSize.Items.FindByValue(this.AvatarSize.ToString()).Selected = true;
            }
            else
            {
                this.cboAvatarSize.Items[0].Selected = true;
            }

            /* SITE-LEVEL SETTINGS */

            if (string.IsNullOrEmpty(DisqusApiSecret) == false)
            {
                txtApiSecret.Text = DisqusApiSecret;
            }

            if (UserInfo.IsSuperUser)
            {
                chkSchedule.Checked = ScheduleEnabled;
            }

            chkDeveloperMode.Checked = DisqusDeveloperMode;

            chkSsoEnabled.Checked = DisqusSsoEnabled;

            txtSsoApiKey.Text = DisqusSsoApiKey;

            this.ChangeView(this.DisqusView);
        }
Example #34
0
        public void PostModule_TestIfStatus500IsReturnedIfDestinationQueueExceptionHappens()
        {
            // Arrange
            Mock <ICsvLoader>     csvMock = new Mock <ICsvLoader>(MockBehavior.Loose);
            Mock <IModuleService> service = new Mock <IModuleService>(MockBehavior.Loose);

            service.Setup(s => s.SendCreeerModuleCommand(It.IsAny <Module>())).Throws(new DestinationQueueException("No response from service/Couldnt serialize/deserialize input/response"));
            ModuleController sut          = new ModuleController(service.Object, csvMock.Object);
            ModuleViewModel  correctModel = new ModuleViewModel()
            {
                Cohort       = "2017/2018",
                Competenties = new Matrix(),
                Eindeisen    = new List <string>()
                {
                    "Eindeis1", "Eindeis2"
                },
                Moduleleider = new Moduleleider()
                {
                    Email          = "*****@*****.**",
                    Naam           = "dirk-jan",
                    Telefoonnummer = "06742136491"
                },
                Studiefase = new Studiefase()
                {
                    Fase     = "Propedeuse",
                    Perioden = new List <int>()
                    {
                        1, 3
                    }
                },
                Studiejaar     = "Jaar 3",
                AanbevolenVoor = new List <Specialisatie>()
                {
                    new Specialisatie()
                    {
                        Code = "SE",
                        Naam = "Software Engineering"
                    }
                },
                AantalEc      = 3,
                ModuleCode    = "iad1",
                ModuleNaam    = "Algoritmen en Datastructuren 1",
                VerplichtVoor = new List <Specialisatie>()
                {
                    new Specialisatie()
                    {
                        Code = "SE", Naam = "Software Engineering"
                    }
                }
            };

            // Act
            var result = sut.PostModule(correctModel);

            // Assert
            Assert.IsInstanceOfType(result, typeof(ObjectResult));
            var objectResult = (ObjectResult)result;

            Assert.AreEqual(500, objectResult.StatusCode);
            Assert.AreEqual("Er is een fout op de server opgetreden. Probeer het later opnieuw.", objectResult.Value);
        }
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///   UpdateHtmlText creates a new HtmlTextInfo object or updates an existing HtmlTextInfo object
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <param name = "htmlContent">An HtmlTextInfo object</param>
        /// <param name = "MaximumVersionHistory">The maximum number of versions to retain</param>
        public void UpdateHtmlText(HtmlTextInfo htmlContent, int MaximumVersionHistory)
        {
            var  _workflowStateController = new WorkflowStateController();
            bool blnCreateNewVersion      = false;

            // determine if we are creating a new version of content or updating an existing version
            if (htmlContent.ItemID != -1)
            {
                if (htmlContent.WorkflowName != "[REPAIR_WORKFLOW]")
                {
                    HtmlTextInfo objContent = GetTopHtmlText(htmlContent.ModuleID, false, htmlContent.WorkflowID);
                    if (objContent != null)
                    {
                        if (objContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
                        {
                            blnCreateNewVersion = true;
                        }
                    }
                }
            }
            else
            {
                blnCreateNewVersion = true;
            }

            // determine if content is published
            if (htmlContent.StateID == _workflowStateController.GetLastWorkflowStateID(htmlContent.WorkflowID))
            {
                htmlContent.IsPublished = true;
            }
            else
            {
                htmlContent.IsPublished = false;
            }

            if (blnCreateNewVersion)
            {
                // add content
                htmlContent.ItemID = DataProvider.Instance().AddHtmlText(htmlContent.ModuleID,
                                                                         htmlContent.Content,
                                                                         htmlContent.Summary,
                                                                         htmlContent.StateID,
                                                                         htmlContent.IsPublished,
                                                                         UserController.Instance.GetCurrentUserInfo().UserID,
                                                                         MaximumVersionHistory);
            }
            else
            {
                // update content
                DataProvider.Instance().UpdateHtmlText(htmlContent.ItemID, htmlContent.Content, htmlContent.Summary, htmlContent.StateID, htmlContent.IsPublished, UserController.Instance.GetCurrentUserInfo().UserID);
            }

            // add log history
            var logInfo = new HtmlTextLogInfo();

            logInfo.ItemID   = htmlContent.ItemID;
            logInfo.StateID  = htmlContent.StateID;
            logInfo.Approved = htmlContent.Approved;
            logInfo.Comment  = htmlContent.Comment;
            var objLogs = new HtmlTextLogController();

            objLogs.AddHtmlTextLog(logInfo);

            // create user notifications
            CreateUserNotifications(htmlContent);

            // refresh output cache
            ModuleController.SynchronizeModule(htmlContent.ModuleID);
        }
Example #36
0
        public void PostModule_TestIfCommandReturnsCode400BadRequestIfCommandResponseIs400()
        {
            // Arrange
            Mock <ICsvLoader>     csvMock = new Mock <ICsvLoader>(MockBehavior.Loose);
            Mock <IModuleService> service = new Mock <IModuleService>(MockBehavior.Loose);

            service.Setup(s => s.SendCreeerModuleCommand(It.IsAny <Module>()))
            .Returns(new CreeerModuleCommandResponse()
            {
                StatusCode = 400, Message = "Combinatie van modulecode en cohort bestaat al"
            });
            ModuleController sut          = new ModuleController(service.Object, csvMock.Object);
            ModuleViewModel  correctModel = new ModuleViewModel()
            {
                Cohort       = "2017/2018",
                Competenties = new Matrix(),
                Eindeisen    = new List <string>()
                {
                    "Eindeis1", "Eindeis2"
                },
                Moduleleider = new Moduleleider()
                {
                    Email          = "*****@*****.**",
                    Naam           = "dirk-jan",
                    Telefoonnummer = "06742136491"
                },
                Studiefase = new Studiefase()
                {
                    Fase     = "Propedeuse",
                    Perioden = new List <int>()
                    {
                        1, 3
                    }
                },
                Studiejaar     = "Jaar 3",
                AanbevolenVoor = new List <Specialisatie>()
                {
                    new Specialisatie()
                    {
                        Code = "SE",
                        Naam = "Software Engineering"
                    }
                },
                AantalEc      = 3,
                ModuleCode    = "iad1",
                ModuleNaam    = "Algoritmen en Datastructuren 1",
                VerplichtVoor = new List <Specialisatie>()
                {
                    new Specialisatie()
                    {
                        Code = "SE", Naam = "Software Engineering"
                    }
                }
            };
            // Act
            var result = sut.PostModule(correctModel);


            // Assert
            Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));
            var objectResult = (BadRequestObjectResult)result;

            Assert.AreEqual("De combinatie van modulecode en cohort bestaat al.", objectResult.Value);
        }
Example #37
0
    private void UpdateCurrentObject(GameObject previousObject)
    {
        if (CurrentEventData == null)
        {
            return;
        }
        // Send enter events and update the highlight.
        GameObject currentObject = GetCurrentGameObject(); // Get the pointer target

        HandlePointerExitAndEnter(CurrentEventData, currentObject);

        // Update the current selection, or clear if it is no longer the current object.
        var selected = EventExecutor.GetEventHandler <ISelectHandler>(currentObject);

        if (selected == ModuleController.eventSystem.currentSelectedGameObject)
        {
            EventExecutor.Execute(ModuleController.eventSystem.currentSelectedGameObject, ModuleController.GetBaseEventData(),
                                  ExecuteEvents.updateSelectedHandler);
        }
        else
        {
            ModuleController.eventSystem.SetSelectedGameObject(null, CurrentEventData);
        }

        // Execute hover event.
        if (currentObject != null && currentObject == previousObject)
        {
            EventExecutor.ExecuteHierarchy(currentObject, CurrentEventData, GvrExecuteEventsExtension.pointerHoverHandler);
        }
    }
        public void InstallPackage(PaymentGateWayModuleInfo module, int update)
        {
            ModuleController moduleCtr          = new ModuleController();
            XmlDocument      doc                = new XmlDocument();
            ArrayList        dllFiles           = new ArrayList();
            string           unistallScriptFile = string.Empty;

            doc.Load(module.TempFolderPath + '\\' + module.ManifestFile);
            XmlElement root = doc.DocumentElement;

            if (!String.IsNullOrEmpty(root.ToString()))
            {
                XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder");
                foreach (XmlNode xn in xnList)
                {
                    #region Module Exist check
                    try
                    {
                        System.Nullable <Int32> newModuleID       = 0;
                        System.Nullable <Int32> newModuleDefID    = 0;
                        System.Nullable <Int32> newPortalmoduleID = 0;
                        //System.Nullable<Int32> _newPortalmoduleID = 0;
                        //System.Nullable<Int32> _newModuleDefPermissionID = 0;
                        //System.Nullable<Int32> _newPortalModulePermissionID = 0;
                        #region "Module Creation Logic"
                        SQLHandler    sqhl        = new SQLHandler();
                        SqlConnection sqlConn     = new SqlConnection(SystemSetting.SageFrameConnectionString);
                        SqlCommand    sqlCmd      = new SqlCommand();
                        int           ReturnValue = -1;
                        sqlCmd.Connection  = sqlConn;
                        sqlCmd.CommandText = "[dbo].[usp_Aspx_PaymentGatewayTypeAdd]";
                        sqlCmd.CommandType = CommandType.StoredProcedure;
                        sqlCmd.Parameters.Add(new SqlParameter("@PaymentGatewayTypeName", module.PaymentGatewayTypeName));
                        sqlCmd.Parameters.Add(new SqlParameter("@StoreID", module.StoreID));
                        sqlCmd.Parameters.Add(new SqlParameter("@PortalID", module.PortalID));
                        sqlCmd.Parameters.Add(new SqlParameter("@FolderName", module.FolderName));
                        sqlCmd.Parameters.Add(new SqlParameter("@FriendlyName", module.FriendlyName));
                        sqlCmd.Parameters.Add(new SqlParameter("@CultureName", module.CultureName));
                        sqlCmd.Parameters.Add(new SqlParameter("@Description", module.Description));
                        sqlCmd.Parameters.Add(new SqlParameter("@Version", module.Version));
                        sqlCmd.Parameters.Add(new SqlParameter("@AddedBy", GetUsername));
                        sqlCmd.Parameters.Add(new SqlParameter("@Update", update));
                        sqlCmd.Parameters.Add(new SqlParameter("@NewModuleId", SqlDbType.Int));
                        sqlCmd.Parameters["@NewModuleId"].Direction = ParameterDirection.Output;

                        sqlConn.Open();
                        sqlCmd.ExecuteNonQuery();
                        if (update == 0)
                        {
                            ReturnValue = (int)sqlCmd.Parameters["@NewModuleId"].Value;
                            module.PaymentGatewayTypeID = ReturnValue;
                        }
                        sqlConn.Close();

                        XmlNodeList xnList5      = doc.SelectNodes("sageframe/folders/folder/modules/module/controls/control");
                        int         displayOrder = 0;
                        foreach (XmlNode xn5 in xnList5)
                        {
                            displayOrder++;
                            string ctlKey       = xn5["key"].InnerXml.ToString();
                            string ctlSource    = xn5["src"].InnerXml.ToString();
                            string ctlTitle     = xn5["title"].InnerXml.ToString();
                            string _ctlType     = xn5["type"].InnerXml.ToString();
                            int    ctlType      = checkControlType(_ctlType);
                            string ctlHelpUrl   = xn5["helpurl"].InnerXml.ToString();
                            string ctlSupportPr = xn5["supportspartialrendering"].InnerXml.ToString();


                            List <KeyValuePair <string, object> > paramCol = new List <KeyValuePair <string, object> >();
                            paramCol.Add(new KeyValuePair <string, object>("@PaymentGatewayTypeID", module.PaymentGatewayTypeID));
                            paramCol.Add(new KeyValuePair <string, object>("@ControlName", ctlKey));
                            paramCol.Add(new KeyValuePair <string, object>("@ControlType", ctlType));
                            paramCol.Add(new KeyValuePair <string, object>("@ControlSource", ctlSource));
                            paramCol.Add(new KeyValuePair <string, object>("@DisplayOrder", displayOrder));
                            paramCol.Add(new KeyValuePair <string, object>("@StoreID", module.StoreID));
                            paramCol.Add(new KeyValuePair <string, object>("@PortalID", module.PortalID));
                            paramCol.Add(new KeyValuePair <string, object>("@CultureName", module.CultureName));
                            paramCol.Add(new KeyValuePair <string, object>("@AddedBy", GetUsername));
                            paramCol.Add(new KeyValuePair <string, object>("@Update", update));
                            paramCol.Add(new KeyValuePair <string, object>("@HelpUrl", ctlHelpUrl));
                            paramCol.Add(new KeyValuePair <string, object>("@SupportsPartialRendering", bool.Parse(ctlSupportPr.ToString())));
                            if (xn5.Attributes["type"] == null)
                            {
                                sqlH.ExecuteNonQuery("[dbo].[usp_Aspx_PaymentGateWayControlAdd]", paramCol);
                            }
                            else
                            {
                                if (xn5.Attributes["type"] != null && xn5.Attributes["type"].Value.ToString().ToLower() == "page")
                                {
                                    if (!IsPageExists(ctlKey))
                                    {
                                        //if (update == 0)
                                        // {
                                        try
                                        {
                                            #region "Module Creation Logic"

                                            // add into module table
                                            ModuleInfo moduleObj = new ModuleInfo();
                                            moduleObj.ModuleName              = "AspxCommerce." + module.FriendlyName;
                                            moduleObj.Name                    = module.Name;
                                            moduleObj.PackageType             = "Module";
                                            moduleObj.Owner                   = "AspxCommerce";
                                            moduleObj.Organization            = "";
                                            moduleObj.URL                     = "";
                                            moduleObj.Email                   = "";
                                            moduleObj.ReleaseNotes            = "";
                                            moduleObj.FriendlyName            = ctlKey;
                                            moduleObj.Description             = ctlKey;
                                            moduleObj.Version                 = module.Version;
                                            moduleObj.isPremium               = true;
                                            moduleObj.BusinessControllerClass = "";
                                            moduleObj.FolderName              = module.FolderName;
                                            moduleObj.supportedFeatures       = 0;
                                            moduleObj.CompatibleVersions      = "";
                                            moduleObj.dependencies            = "";
                                            moduleObj.permissions             = "";

                                            int[] outputValue;
                                            outputValue = moduleCtr.AddModules(moduleObj, false, 0, true,
                                                                               DateTime.Now, GetPortalID,
                                                                               GetUsername);
                                            moduleObj.ModuleID    = outputValue[0];
                                            moduleObj.ModuleDefID = outputValue[1];
                                            newModuleID           = moduleObj.ModuleID;
                                            newModuleDefID        = moduleObj.ModuleDefID;


                                            //insert into ProtalModule table

                                            newPortalmoduleID = moduleCtr.AddPortalModules(GetPortalID,
                                                                                           newModuleID, true,
                                                                                           DateTime.Now,
                                                                                           GetUsername);
                                            #endregion

                                            //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID
                                            int controlType = 0;
                                            controlType = ctlType;
                                            string IconFile = "";

                                            //add into module control table
                                            moduleCtr.AddModuleCoontrols(newModuleDefID, ctlKey + "View",
                                                                         ctlTitle + "View", ctlSource,
                                                                         IconFile, controlType, 0, ctlHelpUrl,
                                                                         bool.Parse(ctlSupportPr), true,
                                                                         DateTime.Now,
                                                                         GetPortalID, GetUsername);

                                            //sp_ModuleDefPermissionAdd
                                            string ModuleDefPermissionID;
                                            List <KeyValuePair <string, object> > paramDef =
                                                new List <KeyValuePair <string, object> >();
                                            paramDef.Add(new KeyValuePair <string, object>("@ModuleDefID",
                                                                                           newModuleDefID));
                                            paramDef.Add(new KeyValuePair <string, object>("@PortalModuleID",
                                                                                           newPortalmoduleID));
                                            paramDef.Add(new KeyValuePair <string, object>("@PermissionID", 1));
                                            paramDef.Add(new KeyValuePair <string, object>("@IsActive", true));
                                            paramDef.Add(new KeyValuePair <string, object>("@AddedOn", DateTime.Now));
                                            paramDef.Add(new KeyValuePair <string, object>("@PortalID", GetPortalID));
                                            paramDef.Add(new KeyValuePair <string, object>("@AddedBy", GetUsername));
                                            ModuleDefPermissionID =
                                                sqlH.ExecuteNonQueryAsGivenType <string>(
                                                    "[dbo].[sp_ModuleDefPermissionAdd]", paramDef,
                                                    "@ModuleDefPermissionID");

                                            //ModuleDefPermissionID
                                            List <KeyValuePair <string, object> > paramPage =
                                                new List <KeyValuePair <string, object> >();
                                            paramPage.Add(new KeyValuePair <string, object>("@ModuleDefID",
                                                                                            newModuleDefID));
                                            paramPage.Add(new KeyValuePair <string, object>("@PageName", ctlKey));
                                            paramPage.Add(new KeyValuePair <string, object>("@PortalID", GetPortalID));
                                            paramPage.Add(new KeyValuePair <string, object>(
                                                              "@ModuleDefPermissionID",
                                                              int.Parse(ModuleDefPermissionID)));
                                            ;
                                            sqlH.ExecuteNonQuery("[dbo].[usp_Aspx_CreatePaymentGatewayPage]",
                                                                 paramPage);
                                        }
                                        catch (Exception ex)
                                        {
                                            ProcessException(ex);
                                        }
                                        //   }
                                    }
                                }
                            }
                        }


                        XmlNodeList xnList2 = doc.SelectNodes("sageframe/folders/folder/settings/setting");
                        int         onetime = 0;
                        foreach (XmlNode xn2 in xnList2)
                        {
                            onetime++;
                            string settingkey   = xn2["key"].InnerXml.ToString();
                            string settingvalue = xn2["value"].InnerXml.ToString();
                            List <KeyValuePair <string, object> > paramCol = new List <KeyValuePair <string, object> >();
                            paramCol.Add(new KeyValuePair <string, object>("@PaymentGatewayTypeID", module.PaymentGatewayTypeID));
                            paramCol.Add(new KeyValuePair <string, object>("@StoreID", module.StoreID));
                            paramCol.Add(new KeyValuePair <string, object>("@PortalID", module.PortalID));
                            paramCol.Add(new KeyValuePair <string, object>("@SettingKey", settingkey));
                            paramCol.Add(new KeyValuePair <string, object>("@SettingValue", settingvalue));
                            paramCol.Add(new KeyValuePair <string, object>("@AddedBy", GetUsername));
                            paramCol.Add(new KeyValuePair <string, object>("@Update", update));
                            paramCol.Add(new KeyValuePair <string, object>("@onetime", onetime));
                            sqlH.ExecuteNonQuery("[dbo].[usp_Aspx_PaymentGateWaySettingByKeyAdd]", paramCol);
                        }

                        XmlNodeList xnList3 = doc.SelectNodes("sageframe/folders/folder/files/file");
                        if (xnList3.Count != 0)
                        {
                            foreach (XmlNode xn3 in xnList3)
                            {
                                string fileName = xn3["name"].InnerXml;
                                try
                                {
                                    #region CheckValidDataSqlProvider
                                    if (!String.IsNullOrEmpty(fileName) && fileName.Contains(module.Version + ".SqlDataProvider"))
                                    {
                                        _exceptions = ReadSQLFile(module.TempFolderPath, fileName);
                                    }
                                    #endregion

                                    #region CheckAlldllFiles
                                    if (!String.IsNullOrEmpty(fileName) && fileName.Contains(".dll"))
                                    {
                                        dllFiles.Add(fileName);
                                    }
                                    #endregion

                                    #region ReadUninstall SQL FileName
                                    if (!String.IsNullOrEmpty(fileName) && fileName.Contains("Uninstall.SqlDataProvider"))
                                    {
                                        unistallScriptFile = fileName;
                                    }
                                    #endregion
                                }
                                catch (Exception ex)
                                {
                                    _exceptions += ex.Message;
                                    break;
                                }
                            }
                        }

                        if (_exceptions != string.Empty)
                        {
                            if (module.PaymentGatewayTypeID.ToString() != null && module.PaymentGatewayTypeID > 0)
                            {
                                //Run unstallScript
                                if (unistallScriptFile != "")
                                {
                                    _exceptions = ReadSQLFile(module.TempFolderPath, unistallScriptFile);
                                }
                                //Delete Module info from data base
                                PaymentGatewayRollBack(module.PaymentGatewayTypeID, GetPortalID, module.StoreID);
                                module.PaymentGatewayTypeID = -1;
                            }
                        }
                        #endregion
                    }
                    catch
                    {
                        if (module.PaymentGatewayTypeID.ToString() != null && module.PaymentGatewayTypeID > 0)
                        {
                            //Run unstallScript
                            if (unistallScriptFile != "")
                            {
                                _exceptions = ReadSQLFile(module.TempFolderPath, unistallScriptFile);
                            }
                            //Delete Module info from data base
                            if (update == 0)
                            {
                                PaymentGatewayRollBack(module.PaymentGatewayTypeID, GetPortalID, module.StoreID);
                            }
                            module.PaymentGatewayTypeID = -1;
                        }
                    }
                    #endregion
                }
            }

            if (module.PaymentGatewayTypeID.ToString() != null && module.PaymentGatewayTypeID > 0 && _exceptions == string.Empty)
            {
                string path       = HttpContext.Current.Server.MapPath("~/");
                string flPath     = module.FolderName.ToString().Replace("/", "\\");
                string targetPath = path + SageFrame.Common.RegisterModule.Common.ModuleFolder + '\\' + flPath;
                CopyDirectory(module.TempFolderPath, targetPath);
                for (int i = 0; i < dllFiles.Count; i++)
                {
                    string sourcedllFile = module.TempFolderPath + '\\' + dllFiles[i].ToString();
                    string targetdllPath = path + SageFrame.Common.RegisterModule.Common.DLLTargetPath + '\\' + dllFiles[i].ToString();
                    File.Copy(sourcedllFile, targetdllPath, true);
                    //File.Move();
                }
            }
            DeleteTempDirectory(module.TempFolderPath);
        }
        public override void UpdateSettings()
        {
            var controller = new ModuleController();

            controller.UpdateModuleSetting(ModuleId, "View", ViewComboBox.SelectedValue);
        }
        private string ImportModule()
        {
            var strMessage = "";

            if (Module != null)
            {
                if (!String.IsNullOrEmpty(Module.DesktopModule.BusinessControllerClass) && Module.DesktopModule.IsPortable)
                {
                    try
                    {
                        var objObject = Reflection.CreateObject(Module.DesktopModule.BusinessControllerClass, Module.DesktopModule.BusinessControllerClass);
                        if (objObject is IPortable)
                        {
                            var xmlDoc = new XmlDocument();
                            try
                            {
                                xmlDoc.LoadXml(txtContent.Text);
                            }
                            catch
                            {
                                strMessage = Localization.GetString("NotValidXml", LocalResourceFile);
                            }
                            if (String.IsNullOrEmpty(strMessage))
                            {
                                var strType = xmlDoc.DocumentElement.GetAttribute("type");
                                if (strType == Globals.CleanName(Module.DesktopModule.ModuleName) || strType == Globals.CleanName(Module.DesktopModule.FriendlyName))
                                {
                                    var strVersion = xmlDoc.DocumentElement.GetAttribute("version");
                                    // DNN26810 if rootnode = "content", import only content(the old way)
                                    if (xmlDoc.DocumentElement.Name.ToLower() == "content")
                                    {
                                        ((IPortable)objObject).ImportModule(ModuleId, xmlDoc.DocumentElement.InnerXml, strVersion, UserInfo.UserID);
                                    }
                                    // otherwise (="module") import the new way
                                    else
                                    {
                                        ModuleController.DeserializeModule(xmlDoc.DocumentElement, Module, PortalId, TabId);
                                    }
                                    Response.Redirect(Globals.NavigateURL(), true);
                                }
                                else
                                {
                                    strMessage = Localization.GetString("NotCorrectType", LocalResourceFile);
                                }
                            }
                        }
                        else
                        {
                            strMessage = Localization.GetString("ImportNotSupported", LocalResourceFile);
                        }
                    }
                    catch
                    {
                        strMessage = Localization.GetString("Error", LocalResourceFile);
                    }
                }
                else
                {
                    strMessage = Localization.GetString("ImportNotSupported", LocalResourceFile);
                }
            }
            return(strMessage);
        }
 public void InitWithNullModuleThrowsArgumentNullException()
 {
     var testee = new ModuleController();
     testee.Invoking(t => t.Initialize(null))
         .ShouldThrow<ArgumentNullException>();
 }
        protected void gdvExtensions_RowCommand(object sender, GridViewCommandEventArgs e)
        {            
            HttpContext.Current.Session[SessionKeys.moduleid] = int.Parse(e.CommandArgument.ToString());
            switch (e.CommandName)
            {
                case "Edit":
                    string strURL = string.Empty;
                    string redmain = Request.RawUrl;
                    if (redmain.Contains("ExtensionMessage"))
                        redmain = redmain.Remove(redmain.IndexOf("ExtensionMessage") - 1);

                    //To direct to new page with query string
                    string ControlPath = "/Modules/Admin/Extensions/Editors/ModuleEditor.ascx";
                    SageFrameConfig pagebase = new SageFrameConfig();
                    bool IsUseFriendlyUrls = pagebase.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls);
                    if (!IsUseFriendlyUrls)
                    {
                        string[] arrUrl;
                        arrUrl = redmain.Split('&');
                        if (arrUrl.Length > 0)
                        {
                            for (int i = 0; i < 3; i++)
                            {
                                strURL += arrUrl[i] + "&";
                            }
                            //strURL = strURL.Remove(strURL.LastIndexOf('&'));
                            strURL = strURL + "extension=" + ControlPath + "&modulecode=" + HttpContext.Current.Session[SessionKeys.moduleid];
                        }
                    }
                    else
                    {
                        if (redmain.Contains("?"))
                        {
                            // Location of the letter ?.
                            int i = redmain.IndexOf('?');
                            // Remainder of string starting at '?'.
                            string d = redmain.Substring(i);
                            strURL = redmain + "?extension=" + ControlPath + "&modulecode=" + HttpContext.Current.Session[SessionKeys.moduleid];

                        }
                        else
                        {
                            strURL = redmain + "?extension=" + ControlPath + "&modulecode=" + HttpContext.Current.Session[SessionKeys.moduleid];
                        }
                    }
                    Response.Redirect(strURL);
                    break;
                case "Delete":
                    int moduleID = int.Parse(e.CommandArgument.ToString());
                    try
                    {

                        //Uninstall Module
                        ModuleController objController = new ModuleController();
                        ModuleInfo moduleInfo = objController.GetModuleInformationByModuleID(moduleID);
                      
                        UninstallModule(moduleInfo, true);
                        //Delete module from database
                        objController.DeletePackagesByModuleID(GetPortalID, moduleID);
                       

                        BindGrid(string.Empty);
                        ShowMessage(SageMessageTitle.Information.ToString(), GetSageMessage("Extensions", "ModuleIsDeletedSuccessfully"), "", SageMessageType.Success);
                    }
                    catch (Exception ex)
                    {
                        ProcessException(ex);
                    }
                    break;
            }
        }
 public void StartWithForgroundThreads()
 {
     ModuleController testee = new ModuleController();
     testee.Initialize(new TestModule());
     testee.Start();
 }
Example #44
0
        protected void AddNewModule(string title, int desktopModuleId, string paneName, int position, ViewPermissionType permissionType, string align)
        {
            TabPermissionCollection    objTabPermissions       = PortalSettings.ActiveTab.TabPermissions;
            PermissionController       objPermissionController = new PermissionController();
            ModuleController           objModules           = new ModuleController();
            ModuleDefinitionController objModuleDefinitions = new ModuleDefinitionController();

            Services.Log.EventLog.EventLogController objEventLog = new Services.Log.EventLog.EventLogController();
            int intIndex;

            try
            {
                DesktopModuleController objDesktopModules = new DesktopModuleController();
                ArrayList arrDM        = objDesktopModules.GetDesktopModulesByPortal(PortalSettings.PortalId);
                bool      isSelectable = false;
                for (int intloop = 0; intloop < arrDM.Count; intloop++)
                {
                    if (((DesktopModuleInfo)(arrDM[intloop])).DesktopModuleID == desktopModuleId)
                    {
                        isSelectable = true;
                        break;
                    }
                }
                if (isSelectable == false)
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            int UserId = -1;

            if (Request.IsAuthenticated)
            {
                UserInfo objUserInfo = UserController.GetCurrentUserInfo();
                UserId = objUserInfo.UserID;
            }

            ArrayList arrModuleDefinitions = objModuleDefinitions.GetModuleDefinitions(desktopModuleId);

            for (intIndex = 0; intIndex < arrModuleDefinitions.Count; intIndex++)
            {
                ModuleDefinitionInfo objModuleDefinition = (ModuleDefinitionInfo)(arrModuleDefinitions[intIndex]);



                ModuleInfo objModule = new ModuleInfo();
                objModule.Initialize(PortalSettings.PortalId);

                objModule.PortalID    = PortalSettings.PortalId;
                objModule.TabID       = PortalSettings.ActiveTab.TabID;
                objModule.ModuleOrder = position;
                if (String.IsNullOrEmpty(title))
                {
                    objModule.ModuleTitle = objModuleDefinition.FriendlyName;
                }
                else
                {
                    objModule.ModuleTitle = title;
                }

                objModule.ModuleTitle = title;
                objModule.PaneName    = paneName;
                objModule.ModuleDefID = objModuleDefinition.ModuleDefID;
                objModule.CacheTime   = objModuleDefinition.DefaultCacheTime;

                // initialize module permissions
                ModulePermissionCollection objModulePermissions = new ModulePermissionCollection();
                objModule.ModulePermissions      = objModulePermissions;
                objModule.InheritViewPermissions = false;

                // get the default module view permissions
                ArrayList arrSystemModuleViewPermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", "VIEW");

                // get the permissions from the page
                foreach (TabPermissionInfo objTabPermission in objTabPermissions)
                {
                    // get the system module permissions for the permissionkey
                    ArrayList arrSystemModulePermissions = objPermissionController.GetPermissionByCodeAndKey("SYSTEM_MODULE_DEFINITION", objTabPermission.PermissionKey);
                    // loop through the system module permissions
                    int j;
                    for (j = 0; j < arrSystemModulePermissions.Count; j++)
                    {
                        // create the module permission
                        PermissionInfo       objSystemModulePermission = (PermissionInfo)(arrSystemModulePermissions[j]);
                        ModulePermissionInfo objModulePermission       = AddModulePermission(objModule.ModuleID, objSystemModulePermission, objTabPermission.RoleID);

                        // add the permission to the collection
                        if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess)
                        {
                            objModulePermissions.Add(objModulePermission);
                        }

                        // ensure that every EDIT permission which allows access also provides VIEW permission
                        if (objModulePermission.PermissionKey == "EDIT" & objModulePermission.AllowAccess)
                        {
                            ModulePermissionInfo objModuleViewperm = new ModulePermissionInfo();
                            objModuleViewperm.ModuleID      = objModulePermission.ModuleID;
                            objModuleViewperm.PermissionID  = ((PermissionInfo)(arrSystemModuleViewPermissions[0])).PermissionID;
                            objModuleViewperm.RoleID        = objModulePermission.RoleID;
                            objModuleViewperm.PermissionKey = "VIEW";
                            objModuleViewperm.AllowAccess   = true;
                            if (!(objModulePermissions.Contains(objModuleViewperm)))
                            {
                                objModulePermissions.Add(objModuleViewperm);
                            }
                        }
                    }

                    //Get the custom Module Permissions,  Assume that roles with Edit Tab Permissions
                    //are automatically assigned to the Custom Module Permissions
                    if (objTabPermission.PermissionKey == "EDIT")
                    {
                        ArrayList arrCustomModulePermissions = objPermissionController.GetPermissionsByModuleDefID(objModule.ModuleDefID);

                        // loop through the custom module permissions
                        for (j = 0; j < arrCustomModulePermissions.Count; j++)
                        {
                            // create the module permission
                            PermissionInfo       objCustomModulePermission = (PermissionInfo)(arrCustomModulePermissions[j]);
                            ModulePermissionInfo objModulePermission       = AddModulePermission(objModule.ModuleID, objCustomModulePermission, objTabPermission.RoleID);

                            // add the permission to the collection
                            if (!(objModulePermissions.Contains(objModulePermission)) & objModulePermission.AllowAccess)
                            {
                                objModulePermissions.Add(objModulePermission);
                            }
                        }
                    }
                }

                switch (permissionType)
                {
                case ViewPermissionType.View:
                    objModule.InheritViewPermissions = true;
                    break;

                case ViewPermissionType.Edit:
                    objModule.ModulePermissions = objModulePermissions;
                    break;
                }

                objModule.AllTabs    = false;
                objModule.Visibility = VisibilityState.Maximized;
                objModule.Alignment  = align;

                objModules.AddModule(objModule);
                objEventLog.AddLog(objModule, PortalSettings, UserId, "", Services.Log.EventLog.EventLogController.EventLogType.MODULE_CREATED);
            }
        }
        protected void imbUpdateModlueControl_Click(object sender, EventArgs e)
        {
            string ExtensionMessage = string.Empty;
            if (Request.QueryString["moduledef"] != null)
            {
                try
                {
                    //add
                    int _moduledefid = int.Parse(Request.QueryString["moduledef"]);
                    string _moduleControlKey = txtKey.Text;
                    string _moduleControlTitle = txtTitle.Text;
                    string _moduleControlSrc = ddlSource.SelectedItem.ToString();
                    string _moduleControlHelpUrl = txtHelpURL.Text;
                    //bool _moduleSupportsPartialRendering = chkSupportsPartialRendering.Checked;
                    bool _moduleSupportsPartialRendering = false;
                    int _controlType = int.Parse(ddlType.SelectedItem.Value);

                    int isUnique = CheckUniqueControlType(0, _moduledefid, _controlType, GetPortalID, false);
                    if (isUnique == 0)
                    {
                        string _iconFile = "";
                        if (ddlIcon.SelectedIndex != -1)
                        {
                            _iconFile = ddlIcon.SelectedItem.Value;
                        }
                        int _displayOrder = int.Parse(txtDisplayOrder.Text);
                        //add into module control table
                        ModuleController objController = new ModuleController();
                        objController.AddModuleCoontrols(_moduledefid, _moduleControlKey, _moduleControlTitle, _moduleControlSrc,
                            _iconFile, _controlType, _displayOrder, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, DateTime.Now,
                            GetPortalID, GetUsername);
                        ExtensionMessage = GetSageMessage("Extensions", "ModuleControlIsAddedSuccessfully");
                        ClearSessions();
                        string ControlPath = "/Modules/Admin/Extensions/Editors/ModuleEditor.ascx&moduleid=" + HttpContext.Current.Session["moduleid"] + "&ExtensionMessage=" + ExtensionMessage;
                        ProcessSourceControlUrl(Request.RawUrl, ControlPath, "extension");
                    }
                    else
                    {
                        lblErrorControlType.Visible = true;
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ModuleControlAlreadyExists"), "", SageMessageType.Alert);
                    }
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }

            else if (Request.QueryString["modulecontrol"] != null)
            {
                //update
                try
                {
                    int _modulecontriolid = int.Parse(Request.QueryString["modulecontrol"]);
                    string _moduleControlKey = txtKey.Text;
                    string _moduleControlTitle = txtTitle.Text;
                    string _moduleControlSrc = ddlSource.SelectedItem.ToString();
                    string _moduleControlHelpUrl = txtHelpURL.Text;
                    //bool _moduleSupportsPartialRendering = chkSupportsPartialRendering.Checked;
                    bool _moduleSupportsPartialRendering = false;
                    int _controlType = int.Parse(ddlType.SelectedItem.Value);

                    int isUnique = CheckUniqueControlType(_modulecontriolid, 0, _controlType, GetPortalID, true);
                    if (isUnique == 0)
                    {
                        string _iconFile = "";
                        if (ddlIcon.SelectedIndex != -1)
                        {
                            _iconFile = ddlIcon.SelectedItem.Value;
                        }
                        int _displayOrder = int.Parse(txtDisplayOrder.Text);

                        //update into module control table
                        ModuleController objController = new ModuleController();
                        objController.UpdateModuleCoontrols(_modulecontriolid, _moduleControlKey, _moduleControlTitle, _moduleControlSrc,
                            _iconFile, _controlType, _displayOrder, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, true, DateTime.Now,
                            GetPortalID, GetUsername);
                        ExtensionMessage = GetSageMessage("Extensions", "ModuleControlIsUpdatedSuccessfully");
                        ClearSessions();
                        string ControlPath = "/Modules/Admin/Extensions/Editors/ModuleEditor.ascx&moduleid=" + HttpContext.Current.Session["moduleid"] + "&ExtensionMessage=" + ExtensionMessage;
                        ProcessSourceControlUrl(Request.RawUrl, ControlPath, "extension");
                    }
                    else
                    {
                        lblErrorControlType.Visible = true;
                        ShowMessage(SageMessageTitle.Notification.ToString(), GetSageMessage("Extensions", "ModuleControlAlreadyExists"), "", SageMessageType.Alert);
                    }
                }
                catch (Exception ex)
                {
                    ProcessException(ex);
                }
            }
        }
Example #46
0
        private bool ProcessSlaveModule()
        {
            ModuleController objModules  = new ModuleController();
            ModuleInfo       objModule   = null;
            ModuleInfo       slaveModule = null;
            int    moduleId = -1;
            string key      = "";
            bool   bSuccess = true;

            if (Request.QueryString["mid"] != null)
            {
                Int32.TryParse(Request.QueryString["mid"], out moduleId);
            }
            if (Request.QueryString["ctl"] != null)
            {
                key = Request.QueryString["ctl"];
            }
            if (Request.QueryString["moduleid"] != null && (key.ToLower() == "module" || key.ToLower() == "help"))
            {
                Int32.TryParse(Request.QueryString["moduleid"], out moduleId);
            }
            if (moduleId != -1)
            {
                objModule = objModules.GetModule(moduleId, PortalSettings.ActiveTab.TabID, false);
                if (objModule != null)
                {
                    slaveModule = objModule.Clone();
                }
            }
            if (slaveModule == null)
            {
                slaveModule             = new ModuleInfo();
                slaveModule.ModuleID    = moduleId;
                slaveModule.ModuleDefID = -1;
                slaveModule.TabID       = PortalSettings.ActiveTab.TabID;
            }
            if (Request.QueryString["moduleid"] != null && (key.ToLower() == "module" || key.ToLower() == "help"))
            {
                slaveModule.ModuleDefID = -1;
            }
            if (Request.QueryString["dnnprintmode"] != "true")
            {
                slaveModule.ModuleTitle = "";
            }
            slaveModule.Header           = "";
            slaveModule.Footer           = "";
            slaveModule.StartDate        = DateTime.MinValue;
            slaveModule.EndDate          = DateTime.MaxValue;
            slaveModule.PaneName         = Common.Globals.glbDefaultPane;
            slaveModule.Visibility       = VisibilityState.None;
            slaveModule.Color            = "";
            slaveModule.Border           = "";
            slaveModule.DisplayTitle     = true;
            slaveModule.DisplayPrint     = false;
            slaveModule.DisplaySyndicate = false;
            slaveModule.ContainerSrc     = PortalSettings.ActiveTab.ContainerSrc;
            if (string.IsNullOrEmpty(slaveModule.ContainerSrc))
            {
                slaveModule.ContainerSrc = PortalSettings.DefaultPortalContainer;
            }
            slaveModule.ContainerSrc  = SkinController.FormatSkinSrc(slaveModule.ContainerSrc, PortalSettings);
            slaveModule.ContainerPath = SkinController.FormatSkinPath(slaveModule.ContainerSrc);
            Pane pane   = null;
            bool bFound = Panes.TryGetValue(Common.Globals.glbDefaultPane.ToLowerInvariant(), out pane);
            ModuleControlInfo objModuleControl = ModuleControlController.GetModuleControlByControlKey(key, slaveModule.ModuleDefID);

            if (objModuleControl != null)
            {
                slaveModule.ModuleControlId = objModuleControl.ModuleControlID;
                slaveModule.IconFile        = objModuleControl.IconFile;
                if (ModulePermissionController.HasModuleAccess(slaveModule.ModuleControl.ControlType, Null.NullString, slaveModule))
                {
                    bSuccess = InjectModule(pane, slaveModule);
                }
                else
                {
                    Response.Redirect(Common.Globals.AccessDeniedURL(MODULEACCESS_ERROR), true);
                }
            }
            return(bSuccess);
        }
        private void BindControls()
        {
            try
            {
                rowSource.Visible = true;
                pUpdatePane.Visible = true;
                rowModuleEdit.Visible = true;
                rowDefinitionEdit.Visible = true;
                if (HttpContext.Current.Session["ModuleName"] != null)
                {
                    lblModuleD.Text = HttpContext.Current.Session["ModuleName"].ToString();
                }
                if (HttpContext.Current.Session["ModuleDefinitionName"] != null)
                {
                    lblDefinitionD.Text = HttpContext.Current.Session["ModuleDefinitionName"].ToString();
                }                
                LoadSources(Server.MapPath("~/Modules"));
                LoadIcons(SystemSetting.glbImageFileTypes);
                if (Request.QueryString["modulecontrol"] != null)
                {
                    ModuleController objController = new ModuleController();
                    ModuleEntities module = objController.ModuleControlsGetByModuleControlID(int.Parse(Request.QueryString["modulecontrol"]));
                    if (module.ControlSrc != null)
                    {
                        ddlSource.ClearSelection();
                        ddlSource.SelectedIndex = ddlSource.Items.IndexOf(ddlSource.Items.FindByText(module.ControlSrc.ToString()));
                    }

                    if (module.IconFile != null)
                    {
                        ddlIcon.SelectedIndex = ddlIcon.Items.IndexOf(ddlIcon.Items.FindByText(module.IconFile.ToString()));
                    }
                    ddlType.SelectedIndex = ddlType.Items.IndexOf(ddlType.Items.FindByValue(module.ControlType.ToString()));
                    txtKey.Text = module.ControlKey;
                    txtTitle.Text = module.ControlTitle;
                    txtDisplayOrder.Text = module.DisplayOrder.ToString();
                    txtHelpURL.Text = module.HelpUrl;
                    //chkSupportsPartialRendering.Checked = (bool)module.SupportsPartialRendering;
                }
            }
            catch (Exception ex)
            {
                ProcessException(ex);
            }
        }
        private void lstObjects_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
        {
            Table          objTable        = null;
            LinkButton     objDownloadLink = null;
            ImageButton    objImageButton  = null;
            Button         objButton       = null;
            Label          objLabel        = null;
            Label          lblDetails      = null;
            HyperLink      objHyperLink    = null;
            RepositoryInfo objRepository   = null;

            var       mc       = new ModuleController();
            var       mi       = mc.GetModule(ModuleId);
            Hashtable settings = mi.ModuleSettings;


            if (e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem)
            {
                objRepository = new RepositoryInfo();
                objRepository = e.Item.DataItem as RepositoryInfo;

                objTable = (Table)e.Item.Cells[0].FindControl("ItemButtonTable");

                objDownloadLink      = (LinkButton)objTable.Rows[0].Cells[0].FindControl("btnViewFile");
                objDownloadLink.Text = Localization.GetString("ViewFile", LocalResourceFile);
                if (objRepository.FileName.ToString().Length == 0)
                {
                    objDownloadLink.Visible = false;
                }

                objDownloadLink      = (LinkButton)objTable.Rows[0].Cells[0].FindControl("btnApprove");
                objDownloadLink.Text = Localization.GetString("ApproveFile", LocalResourceFile);

                objDownloadLink      = (LinkButton)objTable.Rows[0].Cells[0].FindControl("btnReject");
                objDownloadLink.Text = Localization.GetString("RejectFile", LocalResourceFile);

                objTable = (Table)e.Item.Cells[0].FindControl("ItemDetailsTable");

                objHyperLink             = (HyperLink)objTable.Rows[0].Cells[0].FindControl("hlImage");
                objHyperLink.Target      = "_blank";
                objHyperLink.NavigateUrl = oRepositoryBusinessController.FormatImageURL(objRepository.ItemId.ToString());
                objHyperLink.ImageUrl    = oRepositoryBusinessController.FormatPreviewImageURL(objRepository.ItemId, ModuleId, 150);

                objLabel      = (Label)objTable.Rows[0].Cells[0].FindControl("lbClickToView");
                objLabel.Text = Localization.GetString("ClickToView", LocalResourceFile);

                if (objRepository.Image.ToString().Length == 0)
                {
                    objLabel.Visible                = false;
                    objHyperLink.Visible            = false;
                    objTable.Rows[0].Cells[0].Width = System.Web.UI.WebControls.Unit.Pixel(0);
                }
                else
                {
                    objLabel.Visible                = true;
                    objHyperLink.Visible            = true;
                    objTable.Rows[0].Cells[0].Width = System.Web.UI.WebControls.Unit.Pixel(150);
                }

                lblDetails = (Label)objTable.Rows[0].Cells[0].FindControl("lblItemDetails");

                if (objRepository.Author.ToString().Length > 0)
                {
                    lblDetails.Text = "<span class='SubHead'>" + Localization.GetString("Author", LocalResourceFile) + " </span>" + objRepository.Author.ToString() + "<br>";
                }
                if (objRepository.AuthorEMail.ToString().Length > 0)
                {
                    lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("AuthorEMail", LocalResourceFile) + " </span><a href='mailto:" + objRepository.AuthorEMail.ToString() + "'>" + objRepository.AuthorEMail.ToString() + "</a><br><br>";
                }
                else
                {
                    if (objRepository.Author.ToString().Length > 0)
                    {
                        lblDetails.Text += "<br>";
                    }
                }

                if (objRepository.FileSize.ToString() != "0")
                {
                    lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("FileSize", LocalResourceFile) + " </span>" + objRepository.FileSize.ToString() + "<br>";
                }

                if (objRepository.Downloads.ToString() != "0")
                {
                    lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("Downloads", LocalResourceFile) + " </span>" + objRepository.Downloads.ToString() + "<br><br>";
                }
                lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("Created", LocalResourceFile) + " </span>" + objRepository.CreatedDate.ToString() + "<br>";
                lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("Updated", LocalResourceFile) + " </span>" + objRepository.UpdatedDate.ToString() + "<br><br>";

                if (objRepository.Description.ToString().Length > 0)
                {
                    lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("Description", LocalResourceFile) + " </span><br>" + objRepository.Description.ToString();
                }
                else
                {
                    lblDetails.Text += "<span class='SubHead'>" + Localization.GetString("Description", LocalResourceFile) + " </span><br>No description";
                }

                objTable = (Table)e.Item.Cells[0].FindControl("tblReject");

                objLabel      = (Label)objTable.Rows[0].Cells[0].FindControl("lbRejectionReason");
                objLabel.Text = Localization.GetString("RejectionReason", LocalResourceFile);

                objButton      = (Button)objTable.Rows[0].Cells[0].FindControl("btnSendRejection");
                objButton.Text = Localization.GetString("SendRejection", LocalResourceFile);
            }
        }
 private void SetValue(string theKey, string theValue) {
     ModuleController moduleController = new ModuleController();
     //int siteModuleId = moduleController.GetModuleByDefinition(_portalId, "PDPModule").ModuleID;
     moduleController.UpdateModuleSetting(_siteModuleId, theKey, theValue);
 }
Example #50
0
 public void TearDown()
 {
     PortalController.ClearInstance();
     ModuleController.ClearInstance();
     UserController.ClearInstance();
 }
        public override void RenderValuesToHtmlInsideDataSet(DataSet ds, int moduleId, bool noScript)
        {
            if (ds != null)
            {
                var fields       = new ArrayList();
                var tableData    = ds.Tables[DataSetTableName.Data];
                var tokenReplace = new TokenReplace {
                    ModuleId = moduleId
                };
                foreach (DataRow row in ds.Tables[DataSetTableName.Fields].Rows)
                {
                    if (row[FieldsTableColumn.Type].ToString() == Name)
                    {
                        var fieldId = (int)row[FieldsTableColumn.Id];
                        var field   = new FieldSetting
                        {
                            Title           = row[FieldsTableColumn.Title].ToString(),
                            TokenText       = GetFieldSetting("TokenText", fieldId, ds).AsString(),
                            ShowUserName    = GetFieldSetting("ShowUserName", fieldId, ds).AsBoolean(),
                            OpenInNewWindow = GetFieldSetting("OpenInNewWindow", fieldId, ds).AsBoolean()
                        };
                        fields.Add(field);
                        tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Url, typeof(string)));
                        tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Original, typeof(string)));
                        tableData.Columns.Add(new DataColumn(field.Title + DataTableColumn.Appendix_Caption, typeof(string)));
                    }
                }

                if (fields.Count > 0)
                {
                    PortalSettings portalSettings = null;
                    if (HttpContext.Current != null)
                    {
                        portalSettings = PortalController.Instance.GetCurrentPortalSettings();
                    }
                    var mc       = new ModuleController();
                    var settings = mc.GetModule(moduleId).ModuleSettings;

                    foreach (DataRow row in tableData.Rows)
                    {
                        foreach (FieldSetting field in fields)
                        {
                            var strFieldvalue = string.Empty;
                            //Link showed to the user
                            var link = row[field.Title].ToString();


                            //set caption:
                            var caption = field.TokenText;
                            var url     = string.Empty;
                            //Link readable by browsers

                            link = UrlUtil.StripURL(link);
                            if (link != string.Empty)     //valid link
                            {
                                //var isLink = true;
                                var intUser = Convert.ToInt32(-1);
                                if (link.Like("userid=*") && portalSettings != null)
                                {
                                    try
                                    {
                                        intUser           = int.Parse(link.Substring(7));
                                        tokenReplace.User = new UserController().GetUser(portalSettings.PortalId,
                                                                                         intUser);
                                    }
                                    catch
                                    {
                                    }
                                }
                                if (intUser == -1)
                                {
                                    tokenReplace.User = new UserInfo {
                                        Username = "******"
                                    };
                                }


                                if (caption == string.Empty)
                                {
                                    caption = field.ShowUserName ? "[User:DisplayName]" : "[User:UserName]";
                                }

                                caption = tokenReplace.ReplaceEnvironmentTokens(caption, row);
                                if (caption == string.Empty)     //DisplayName empty
                                {
                                    caption = tokenReplace.ReplaceEnvironmentTokens("[User:username]");
                                }

                                url =
                                    HttpUtility.HtmlEncode(Globals.LinkClick(link, portalSettings.ActiveTab.TabID,
                                                                             moduleId));

                                strFieldvalue = string.Format("<!--{1}--><a href=\"{0}\"{2}>{1}</a>",
                                                              url,
                                                              caption,
                                                              (field.OpenInNewWindow ? " target=\"_blank\"" : ""));
                            }
                            row[field.Title] = strFieldvalue;
                            row[field.Title + DataTableColumn.Appendix_Original] = link;
                            row[field.Title + DataTableColumn.Appendix_Url]      = url;
                            row[field.Title + DataTableColumn.Appendix_Caption]  = caption;
                        }
                    }
                }
            }
        }
 public void InitWithModuleWithModuleWithNoMessageConsumerMethod()
 {
     var testee = new ModuleController();
     testee.Invoking(t => t.Initialize(new ModuleWithNoMessageConsumerMethod()))
         .ShouldThrow<ArgumentException>();
 }