コード例 #1
0
        static void Main(string[] args)
        {
            var fileName         = string.Format("{0}\\MaintList.xlsx", "C:\\Import");
            var connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0; data source={0}; Extended Properties=Excel 8.0;", fileName);
            var db      = new ModulesDataContext();
            var adapter = new OleDbDataAdapter("SELECT * FROM [WCR$]", connectionString);
            var ds      = new DataSet();

            adapter.Fill(ds, "ExcelData");
            DataTable ExcelData = ds.Tables["ExcelData"];
            var       counter   = 0;

            foreach (DataRow row in ExcelData.Rows)
            {
                Module mod = new Module();

                mod.SystemID = Convert.ToInt32(ExcelData.Rows[counter]["SysID"]);
                mod.Module1  = ExcelData.Rows[counter]["Num"].ToString();
                mod.Title    = ExcelData.Rows[counter]["Title"].ToString();
                mod.Type     = "CAI";

                db.Modules.InsertOnSubmit(mod);
                db.SubmitChanges();
                counter++;
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }