public void InstallPackage(PaymentGateWayModuleInfo module, int update)
        {
            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> moduleControlID = 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 (update == 0)
                                    {
                                        try
                                        {
                                            ModulesDataContext db = new ModulesDataContext(SystemSetting.SageFrameConnectionString);
                                            //var LINQModuleInfo = db.sp_ModulesAdd(ref _newModuleID, ref _newModuleDefID, objModule.Name, objModule.PackageType, objModule.License,objModule.Owner, objModule.Organization, objModule.URL, objModule.Email, objModule.ReleaseNotes, objModule.FriendlyName,objModule.Description, objModule.Version, isPremium, false, objModule.BusinessControllerClass, objModule.FolderName,objModule.ModuleName, supportedFeatures, objModule.CompatibleVersions, dependencies, permissions, 0, true, DateTime.Now,GetPortalID, GetUsername);
                                            var LINQModuleInfo             = db.sp_ModulesAdd(ref newModuleID, ref newModuleDefID, "AspxCommerce." + "" + module.FriendlyName + "", "Module", "", "AspxCommerce", "", "", "", "", ctlKey, ctlKey, module.Version, true, false, "", module.FolderName, "AspxCommerce." + module.FriendlyName, 0, "", "", "", 0, true, DateTime.Now, GetPortalID, GetUsername);
                                            ModuleControlsDataContext dbMC = new ModuleControlsDataContext(SystemSetting.SageFrameConnectionString);

                                            //PermissionDataContext dbPermission = new PermissionDataContext(SystemSetting.SageFrameConnectionString);

                                            //db.sp_PortalModulesAdd(ref _newPortalmoduleID, GetPortalID, _newModuleID, true, DateTime.Now, GetUsername);

                                            //// get the default module VIEW permissions
                                            //var LINQModuleViewPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW").SingleOrDefault();
                                            //int _permissionIDView = LINQModuleViewPermission.PermissionID;
                                            ////insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                                            //dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDView, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);


                                            //// get the default module EDIT permissions
                                            //var LINQModuleEditPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT").SingleOrDefault();
                                            //int _permissionIDEdit = LINQModuleEditPermission.PermissionID;
                                            ////insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                                            //dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDEdit, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);

                                            //modules control add
                                            dbMC.sp_ModuleControlsAdd(ref moduleControlID, newModuleDefID, ctlKey + "View", ctlTitle + "View", ctlSource, null, ctlType, 0, ctlHelpUrl, false, 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>("@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.Core.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.Core.RegisterModule.Common.DLLTargetPath + '\\' + dllFiles[i].ToString();
                    File.Copy(sourcedllFile, targetdllPath, true);
                    //File.Move();
                }
            }
            DeleteTempDirectory(module.TempFolderPath);
        }
示例#2
0
        public void InstallPackage(ModuleInfo module)
        {
            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
                    {
                        #region "Module Creation Logic"
                        // add into module table
                        var LINQModuleInfo = db.sp_ModulesAdd(ref _newModuleID, ref _newModuleDefID, module.Name, module.PackageType, module.License, module.Owner, module.Organization, module.URL, module.Email, module.ReleaseNotes, module.FriendlyName, module.Description, module.Version, true, false, module.BusinessControllerClass, module.FolderName, module.ModuleName, 0, module.CompatibleVersions, "", "", 0, true, DateTime.Now, GetPortalID, GetUsername);
                        module.ModuleID = (Int32)_newModuleID;

                        //insert into ProtalModule table
                        db.sp_PortalModulesAdd(ref _newPortalmoduleID, GetPortalID, _newModuleID, true, DateTime.Now, GetUsername);

                        //install permission for the installed module in ModuleDefPermission table with ModuleDefID and PermissionID
                        try
                        {
                            // get the default module VIEW permissions
                            var LINQModuleViewPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW").SingleOrDefault();
                            int _permissionIDView        = LINQModuleViewPermission.PermissionID;
                            //insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                            dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDView, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);


                            // get the default module EDIT permissions
                            var LINQModuleEditPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT").SingleOrDefault();
                            int _permissionIDEdit        = LINQModuleEditPermission.PermissionID;
                            //insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                            dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDEdit, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);
                        }
                        catch (Exception ex)
                        {
                            Exceptions += ex.Message;
                            break;
                        }

                        XmlNodeList xnList2 = doc.SelectNodes("sageframe/folders/folder/modules/module/controls/control");
                        foreach (XmlNode xn2 in xnList2)
                        {
                            string _moduleControlKey = null;
                            if (xn2["key"] != null)
                            {
                                _moduleControlKey = xn2["key"].InnerXml;// exists
                            }
                            string _moduleControlTitle             = xn2["title"].InnerXml;
                            string _moduleControlSrc               = xn2["src"].InnerXml;
                            string _controlType                    = xn2["type"].InnerXml;
                            string _moduleControlHelpUrl           = xn2["helpurl"].InnerXml;
                            bool   _moduleSupportsPartialRendering = false;
                            if (xn2["supportspartialrendering"] != null)
                            {
                                string _moduleControlSupportsPartialRendering = xn2["supportspartialrendering"].InnerXml;

                                if (_moduleControlSupportsPartialRendering == "true")
                                {
                                    _moduleSupportsPartialRendering = true;
                                }
                            }
                            int controlType = 0;
                            controlType = checkControlType(_controlType);
                            //add into module control table
                            ModuleControlsDataContext dbMC = new ModuleControlsDataContext(SystemSetting.SageFrameConnectionString);
                            dbMC.sp_ModuleControlsAdd(ref _moduleControlID, _newModuleDefID, _moduleControlKey, _moduleControlTitle, _moduleControlSrc, null, controlType, 0, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, DateTime.Now, GetPortalID, GetUsername);
                        }
                        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.ModuleID.ToString() != null && module.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0)
                            {
                                //Run unstallScript
                                if (_unistallScriptFile != "")
                                {
                                    Exceptions = ReadSQLFile(module.TempFolderPath, _unistallScriptFile);
                                }
                                //Delete Module info from data base
                                ModulesRollBack(module.ModuleID, GetPortalID);
                                module.ModuleID = -1;
                            }
                        }
                        #endregion
                    }
                    catch
                    {
                        if (module.ModuleID.ToString() != null && module.ModuleID > 0 && _newModuleDefID != null && _newModuleDefID > 0)
                        {
                            //Run unstallScript
                            if (_unistallScriptFile != "")
                            {
                                Exceptions = ReadSQLFile(module.TempFolderPath, _unistallScriptFile);
                            }
                            //Delete Module info from data base
                            ModulesRollBack(module.ModuleID, GetPortalID);
                            module.ModuleID = -1;
                        }
                    }
                    #endregion
                }
            }

            if (module.ModuleID.ToString() != null && module.ModuleID > 0 && Exceptions == string.Empty)
            {
                string path       = HttpContext.Current.Server.MapPath("~/");
                string targetPath = path + SageFrame.Core.RegisterModule.Common.ModuleFolder + '\\' + module.FolderName;
                CopyDirectory(module.TempFolderPath, targetPath);
                for (int i = 0; i < dllFiles.Count; i++)
                {
                    string sourcedllFile = module.TempFolderPath + '\\' + dllFiles[i].ToString();
                    string targetdllPath = path + SageFrame.Core.RegisterModule.Common.DLLTargetPath + '\\' + dllFiles[i].ToString();
                    File.Copy(sourcedllFile, targetdllPath, true);
                    //File.Move();
                }
            }
            DeleteTempDirectory(module.TempFolderPath);
        }
        public void InstallPackage(PaymentGateWayModuleInfo module,int update)
        {
            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> moduleControlID = 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 (update == 0)
                                    {
                                        try
                                        {
                                            ModulesDataContext db = new ModulesDataContext(SystemSetting.SageFrameConnectionString);
                                            //var LINQModuleInfo = db.sp_ModulesAdd(ref _newModuleID, ref _newModuleDefID, objModule.Name, objModule.PackageType, objModule.License,objModule.Owner, objModule.Organization, objModule.URL, objModule.Email, objModule.ReleaseNotes, objModule.FriendlyName,objModule.Description, objModule.Version, isPremium, false, objModule.BusinessControllerClass, objModule.FolderName,objModule.ModuleName, supportedFeatures, objModule.CompatibleVersions, dependencies, permissions, 0, true, DateTime.Now,GetPortalID, GetUsername);
                                            var LINQModuleInfo = db.sp_ModulesAdd(ref newModuleID, ref newModuleDefID, "AspxCommerce." + "" + module.FriendlyName + "", "Module", "", "AspxCommerce", "", "", "", "", ctlKey, ctlKey, module.Version, true, false, "", module.FolderName, "AspxCommerce." + module.FriendlyName, 0, "", "", "", 0, true, DateTime.Now, GetPortalID, GetUsername);
                                            ModuleControlsDataContext dbMC = new ModuleControlsDataContext(SystemSetting.SageFrameConnectionString);
                                         
                                            //PermissionDataContext dbPermission = new PermissionDataContext(SystemSetting.SageFrameConnectionString);

                                            //db.sp_PortalModulesAdd(ref _newPortalmoduleID, GetPortalID, _newModuleID, true, DateTime.Now, GetUsername);

                                            //// get the default module VIEW permissions
                                            //var LINQModuleViewPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW").SingleOrDefault();
                                            //int _permissionIDView = LINQModuleViewPermission.PermissionID;
                                            ////insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                                            //dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDView, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);


                                            //// get the default module EDIT permissions
                                            //var LINQModuleEditPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT").SingleOrDefault();
                                            //int _permissionIDEdit = LINQModuleEditPermission.PermissionID;
                                            ////insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                                            //dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDEdit, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);

                                            //modules control add
                                            dbMC.sp_ModuleControlsAdd(ref moduleControlID, newModuleDefID, ctlKey + "View", ctlTitle + "View", ctlSource, null, ctlType, 0, ctlHelpUrl, false, 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>("@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.Core.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.Core.RegisterModule.Common.DLLTargetPath + '\\' + dllFiles[i].ToString();
                    File.Copy(sourcedllFile, targetdllPath, true);
                    //File.Move();
                }
            }
            DeleteTempDirectory(module.TempFolderPath);
        }
示例#4
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";
                    bool isPremium         = true;
                    int  supportedFeatures = 0;
                    objModule.BusinessControllerClass = "";
                    objModule.CompatibleVersions      = "";
                    string dependencies = "";
                    string permissions  = "";

                    try
                    {
                        //Insert into Module and Package tables
                        var LINQModuleInfo = db.sp_ModulesAdd(ref _newModuleID, ref _newModuleDefID, objModule.Name, objModule.PackageType, objModule.License,
                                                              objModule.Owner, objModule.Organization, objModule.URL, objModule.Email, objModule.ReleaseNotes, objModule.FriendlyName,
                                                              objModule.Description, objModule.Version, isPremium, false, objModule.BusinessControllerClass, objModule.FolderName,
                                                              objModule.ModuleName, supportedFeatures, objModule.CompatibleVersions, dependencies, permissions, 0, true, DateTime.Now,
                                                              GetPortalID, GetUsername);
                        objModule.ModuleID = (Int32)_newModuleID;
                    }
                    catch (Exception ex)
                    {
                        ProcessException(ex);
                    }

                    try
                    {
                        //insert into ProtalModule table
                        db.sp_PortalModulesAdd(ref _newPortalmoduleID, 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
                        var LINQModuleViewPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_VIEW", "VIEW").SingleOrDefault();
                        int _permissionIDView        = LINQModuleViewPermission.PermissionID;
                        //insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                        dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDView, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, true, DateTime.Now, GetUsername);


                        // get the default module EDIT permissions
                        var LINQModuleEditPermission = dbPermission.sp_GetPermissionByCodeAndKey("SYSTEM_EDIT", "EDIT").SingleOrDefault();
                        int _permissionIDEdit        = LINQModuleEditPermission.PermissionID;
                        //insert into module permissions i.e., ModuleDefPermission and PortalModulePermission
                        dbPermission.sp_ModulesPermissionAdd(ref _newModuleDefPermissionID, _newModuleDefID, _permissionIDEdit, GetPortalID, ref _newPortalModulePermissionID, _newPortalmoduleID, true, null, 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);
                        //add into module control table
                        dbMC.sp_ModuleControlsAdd(ref _moduleControlID, _newModuleDefID, _moduleControlKey, _moduleControlTitle, _moduleControlSrc,
                                                  _iconFile, _controlType, _displayOrder, _moduleControlHelpUrl, _moduleSupportsPartialRendering, true, DateTime.Now,
                                                  GetPortalID, GetUsername);
                        ExtensionMessage = GetSageMessage("Extensions_Editors", "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);
        }