Пример #1
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// The Commit method finalises the Install and commits any pending changes.
        /// </summary>
        /// <remarks>In the case of Modules this is not neccessary</remarks>
        /// -----------------------------------------------------------------------------
        public override void Commit()
        {
            //Add CodeSubDirectory
            if (!string.IsNullOrEmpty(_desktopModule.CodeSubDirectory))
            {
                Config.AddCodeSubDirectory(_desktopModule.CodeSubDirectory);
            }
            if (_desktopModule.SupportedFeatures == Null.NullInteger)
            {
                //Set an Event Message so the features are loaded by reflection on restart
                var oAppStartMessage = new EventMessage
                {
                    Priority         = MessagePriority.High,
                    ExpirationDate   = DateTime.Now.AddYears(-1),
                    SentDate         = DateTime.Now,
                    Body             = "",
                    ProcessorType    = "DotNetNuke.Entities.Modules.EventMessageProcessor, DotNetNuke",
                    ProcessorCommand = "UpdateSupportedFeatures"
                };

                //Add custom Attributes for this message
                oAppStartMessage.Attributes.Add("BusinessControllerClass", _desktopModule.BusinessControllerClass);
                oAppStartMessage.Attributes.Add("desktopModuleID", _desktopModule.DesktopModuleID.ToString());

                //send it to occur on next App_Start Event
                EventQueueController.SendMessage(oAppStartMessage, "Application_Start_FirstRequest");
            }

            //Add Event Message
            if (_eventMessage != null)
            {
                if (!String.IsNullOrEmpty(_eventMessage.Attributes["UpgradeVersionsList"]))
                {
                    _eventMessage.Attributes.Set("desktopModuleID", _desktopModule.DesktopModuleID.ToString());
                    EventQueueController.SendMessage(_eventMessage, "Application_Start");
                }
            }

            //Add DesktopModule to all portals
            if (!_desktopModule.IsPremium)
            {
                DesktopModuleController.AddDesktopModuleToPortals(_desktopModule.DesktopModuleID);
            }

            //Add DesktopModule to all portals
            if (!String.IsNullOrEmpty(_desktopModule.AdminPage))
            {
                foreach (PortalInfo portal in PortalController.Instance.GetPortals())
                {
                    bool createdNewPage = false, addedNewModule = false;
                    DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.AdminPage, portal.PortalID, ref createdNewPage, ref addedNewModule);

                    if (createdNewPage)
                    {
                        Log.AddInfo(string.Format(Util.MODULE_AdminPageAdded, _desktopModule.AdminPage, portal.PortalID));
                    }

                    if (addedNewModule)
                    {
                        Log.AddInfo(string.Format(Util.MODULE_AdminPagemoduleAdded, _desktopModule.AdminPage, portal.PortalID));
                    }
                }
            }

            //Add host items
            if (_desktopModule.Page != null && !String.IsNullOrEmpty(_desktopModule.HostPage))
            {
                bool createdNewPage = false, addedNewModule = false;
                DesktopModuleController.AddDesktopModulePageToPortal(_desktopModule, _desktopModule.HostPage, Null.NullInteger, ref createdNewPage, ref addedNewModule);

                if (createdNewPage)
                {
                    Log.AddInfo(string.Format(Util.MODULE_HostPageAdded, _desktopModule.HostPage));
                }

                if (addedNewModule)
                {
                    Log.AddInfo(string.Format(Util.MODULE_HostPagemoduleAdded, _desktopModule.HostPage));
                }
            }
        }