コード例 #1
0
        private void LoadIcons(string strExtensions, string strFolder)
        {
            DropDownList ddlIcon = ((DropDownList)ModuleControlsDetails1.FindControl("ddlIcon"));

            ddlIcon.Items.Clear();
            ddlIcon.Items.Insert(0, new ListItem("<Not Specified>", ""));

            //if (!string.IsNullOrEmpty(ddlFiles.SelectedItem.Value))
            //{
            if (string.IsNullOrEmpty(strFolder))
            {
                strFolder = Server.MapPath("~/Modules/" + GetSourceFolder());
            }
            string[] arrFiles = Directory.GetFiles(strFolder);
            foreach (string strFile in arrFiles)
            {
                string strExtension = Path.GetExtension(strFile).Replace(".", "");
                if (strExtensions.Contains(strExtension))
                {
                    ddlIcon.Items.Add(new ListItem(Path.GetFileName(strFile), Path.GetFileName(strFile).ToLower()));
                }
            }
            // }
        }
コード例 #2
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);
        }