コード例 #1
0
        public void CreateMultiplePagesModulePackage(List <ModuleSinglePageInfo> multiPageObj)
        {
            ModuleController moduleCtr         = new ModuleController();
            ModuleInfo       module            = new ModuleInfo();
            SQLHandler       sqlH              = new SQLHandler();
            Int32?           newModuleID       = 0;
            Int32?           newModuleDefID    = 0;
            Int32?           newPortalmoduleID = 0;

            foreach (ModuleSinglePageInfo pageObj in multiPageObj)
            {
                if (!IsPageExists(pageObj.PageName))
                {
                    try
                    {
                        #region "Module Creation Logic"

                        // add into module table
                        ModuleInfo moduleObj = new ModuleInfo();
                        moduleObj.ModuleName              = "AspxCommerce." + pageObj.FriendlyName;
                        moduleObj.Name                    = pageObj.FriendlyName;
                        moduleObj.PackageType             = "Module";
                        moduleObj.Owner                   = "AspxCommerce";
                        moduleObj.Organization            = "";
                        moduleObj.URL                     = "";
                        moduleObj.Email                   = "";
                        moduleObj.ReleaseNotes            = "";
                        moduleObj.FriendlyName            = pageObj.FriendlyName;
                        moduleObj.Description             = pageObj.Description;
                        moduleObj.Version                 = pageObj.Version;
                        moduleObj.isPremium               = true;
                        moduleObj.BusinessControllerClass = "";
                        moduleObj.FolderName              = pageObj.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

                        string IconFile = "";
                        //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID
                        foreach (var item in pageObj.PageControls)
                        {
                            int controlType = 0;
                            controlType = checkControlType(item.ControlType);
                            //add into module control table
                            moduleCtr.AddModuleCoontrols(newModuleDefID, pageObj.PageName + "View",
                                                         pageObj.PageTitle + "View", item.ControlSource,
                                                         IconFile, controlType, 0, pageObj.HelpURL,
                                                         pageObj.SupportPartialRendering, 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", pageObj.PageName));
                        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);
                    }
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        private string ImportControl(string controlSrc)
        {
            string ExtensionMessage = string.Empty;

            if (!string.IsNullOrEmpty(controlSrc))
            {
                DropDownList ddlFirst  = ((DropDownList)PackageDetails1.FindControl("ddlFirst"));
                DropDownList ddlSecond = ((DropDownList)PackageDetails1.FindControl("ddlSecond"));
                DropDownList ddlLast   = ((DropDownList)PackageDetails1.FindControl("ddlLast"));
                DropDownList ddlIcon   = ((DropDownList)ModuleControlsDetails1.FindControl("ddlIcon"));

                TextBox      txtKey                      = ((TextBox)ModuleControlsDetails1.FindControl("txtKey"));
                TextBox      txtTitle                    = ((TextBox)ModuleControlsDetails1.FindControl("txtTitle"));
                TextBox      txtHelpURL                  = ((TextBox)ModuleControlsDetails1.FindControl("txtHelpURL"));
                TextBox      txtDisplayOrder             = ((TextBox)ModuleControlsDetails1.FindControl("txtDisplayOrder"));
                CheckBox     chkSupportsPartialRendering = ((CheckBox)ModuleControlsDetails1.FindControl("chkSupportsPartialRendering"));
                DropDownList ddlType                     = ((DropDownList)ModuleControlsDetails1.FindControl("ddlType"));

                ModuleInfo objModule = new ModuleInfo();
                Installers install   = new Installers();
                try
                {
                    string folder        = RemoveTrailingSlash(GetSourceFolder());
                    string friendlyName  = PackageDetails1.PackageName;
                    string name          = GetClassName();
                    string moduleControl = "Modules/" + folder + "/" + controlSrc;

                    //add module and package tables
                    objModule.ModuleName              = name;
                    objModule.Name                    = name;
                    objModule.FriendlyName            = friendlyName;
                    objModule.Description             = PackageDetails1.Description;
                    objModule.FolderName              = folder;
                    objModule.Version                 = ddlFirst.SelectedValue + "." + ddlSecond.SelectedValue + "." + ddlLast.SelectedValue;//"01.00.00"; //new Version(1, 0, 0);
                    objModule.Owner                   = PackageDetails1.Owner;
                    objModule.Organization            = PackageDetails1.Organization;
                    objModule.URL                     = PackageDetails1.Url;
                    objModule.Email                   = PackageDetails1.Email;
                    objModule.ReleaseNotes            = PackageDetails1.ReleaseNotes;
                    objModule.License                 = PackageDetails1.License;
                    objModule.PackageType             = "Module";
                    objModule.isPremium               = true;
                    objModule.supportedFeatures       = 0;
                    objModule.BusinessControllerClass = "";
                    objModule.CompatibleVersions      = "";
                    objModule.dependencies            = "";
                    objModule.permissions             = "";
                    ModuleController objController = new ModuleController();
                    try
                    {
                        int[] outputValue;
                        outputValue           = objController.AddModules(objModule, false, 0, true, DateTime.Now, GetPortalID, GetUsername);
                        objModule.ModuleID    = outputValue[0];
                        objModule.ModuleDefID = outputValue[1];
                        _newModuleID          = objModule.ModuleID;
                        _newModuleDefID       = objModule.ModuleDefID;
                    }
                    catch (Exception ex)
                    {
                        ProcessException(ex);
                    }

                    try
                    {
                        //insert into ProtalModule table
                        _newPortalmoduleID = objController.AddPortalModules(GetPortalID, _newModuleID, true, DateTime.Now, GetUsername);
                    }
                    catch (Exception ex)
                    {
                        ProcessException(ex);
                    }
                    //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID
                    try
                    {
                        // get the default module VIEW permissions
                        int _permissionIDView = objController.GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW");
                        objController.AddModulePermission(_newModuleDefID, _permissionIDView, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTime.Now, GetUsername);
                        int _permissionIDEdit = objController.GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT");
                        objController.AddModulePermission(_newModuleDefID, _permissionIDEdit, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTime.Now, GetUsername);
                    }
                    catch (Exception ex)
                    {
                        Exceptions += ex.Message;
                    }

                    try
                    {
                        //Logic for modulecontrol installation
                        string _moduleControlKey               = txtKey.Text;
                        string _moduleControlTitle             = txtTitle.Text;
                        string _moduleControlSrc               = moduleControl;
                        string _moduleControlHelpUrl           = txtHelpURL.Text;
                        bool   _moduleSupportsPartialRendering = chkSupportsPartialRendering.Checked;
                        int    _controlType = int.Parse(ddlType.SelectedItem.Value);
                        string _iconFile    = "";
                        if (ddlIcon.SelectedIndex != -1)
                        {
                            _iconFile = ddlIcon.SelectedItem.Value;
                        }
                        int _displayOrder = int.Parse(txtDisplayOrder.Text);

                        _moduleControlID = objController.AddModuleCoontrols(_newModuleDefID, _moduleControlKey, _moduleControlTitle, _moduleControlSrc,
                                                                            _iconFile, _controlType, _displayOrder, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, DateTime.Now,
                                                                            GetPortalID, GetUsername);
                        ExtensionMessage = GetSageMessage("Extensions", "ModuleExtensionIsAddedSuccessfully");
                    }
                    catch (Exception ex)
                    {
                        Exceptions = ex.Message;
                    }

                    if (Exceptions != string.Empty)
                    {
                        if (objModule.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0)
                        {
                            //Delete Module info from data base
                            install.ModulesRollBack(objModule.ModuleID, GetPortalID);
                        }
                    }
                }
                catch
                {
                    if (objModule.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0)
                    {
                        //Delete Module info from data base
                        install.ModulesRollBack(objModule.ModuleID, GetPortalID);
                    }
                }
            }
            return(ExtensionMessage);
        }
コード例 #4
0
    public void RegisterModule(string moduleName, string moduleFolderPath, string procedure)
    {
        ModuleInfo objModule          = new ModuleInfo();
        int        _newModuleID       = 0;
        int        _newModuleDefID    = 0;
        int        _newPortalmoduleID = 0;
        string     Exceptions         = string.Empty;
        string     ExtensionMessage   = string.Empty;

        try
        {
            //add module and package tables
            objModule.ModuleName              = moduleName;
            objModule.Name                    = moduleName;
            objModule.FriendlyName            = moduleName;
            objModule.Description             = txtModuleDescription.Text;
            objModule.FolderName              = moduleName;
            objModule.Version                 = "01.00.00";//ddlFirst.SelectedValue + "." + ddlSecond.SelectedValue + "." + ddlLast.SelectedValue;//"01.00.00"; //new Version(1, 0, 0);
            objModule.Owner                   = "";
            objModule.Organization            = "";
            objModule.URL                     = "";
            objModule.Email                   = "";
            objModule.ReleaseNotes            = "";
            objModule.License                 = "";
            objModule.PackageType             = "Module";
            objModule.isPremium               = true;
            objModule.supportedFeatures       = 0;
            objModule.BusinessControllerClass = "";
            objModule.CompatibleVersions      = "";
            objModule.dependencies            = "";
            objModule.permissions             = "";
            ModuleController objController = new ModuleController();

            int[] outputValue;
            outputValue           = objController.AddModules(objModule, false, 0, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetPortalID, GetUsername);
            objModule.ModuleID    = outputValue[0];
            objModule.ModuleDefID = outputValue[1];
            _newModuleID          = objModule.ModuleID;
            _newModuleDefID       = objModule.ModuleDefID;

            //insert into ProtalModule table
            _newPortalmoduleID = objController.AddPortalModules(GetPortalID, _newModuleID, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername);

            //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID

            // get the default module VIEW permissions
            int _permissionIDView = objController.GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW");
            objController.AddModulePermission(_newModuleDefID, _permissionIDView, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername);
            int _permissionIDEdit = objController.GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT");
            objController.AddModulePermission(_newModuleDefID, _permissionIDEdit, GetPortalID, _newPortalmoduleID, true, GetUsername, true, DateTimeHelper.GetUtcTime(DateTime.Now), GetUsername);

            RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + ".ascx", 1, _newModuleDefID);
            if (chkEdit.Checked)
            {
                RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + "Edit" + ".ascx", 2, _newModuleDefID);
            }
            if (chkSetting.Checked)
            {
                RegisterControl(moduleName, moduleFolderPath + moduleName + "/" + moduleName + "Setting" + ".ascx", 3, _newModuleDefID);
            }
            if (Exceptions != string.Empty)
            {
                if (objModule.ModuleID > 0 && _newModuleDefID > 0)
                {
                    Installers install = new Installers();
                    //Delete Module info from data base
                    install.ModulesRollBack(objModule.ModuleID, GetPortalID);
                }
            }
            else
            {
                SQLHandler sageSQLHandler = new SQLHandler();
                sageSQLHandler.ExecuteScript(procedure, true);
            }
        }
        catch (Exception ex)
        {
            ShowMessage("", ex.ToString(), "", SageMessageType.Error);
            ProcessException(ex);
        }
        Response.Redirect(Request.Url.AbsoluteUri);
    }