private void UninstallPaymentGateway(PaymentGateWayModuleInfo paymentGateWay, bool deleteModuleFolder, int gatewayID)
    {
        PaymentGatewayInstaller installerClass = new PaymentGatewayInstaller();
        string path = HttpContext.Current.Server.MapPath("~/");

        //checked if directory exist for current Payment Gateway foldername
        string paymentGatewayFolderPath = paymentGateWay.InstalledFolderPath;
        if (!string.IsNullOrEmpty(paymentGatewayFolderPath))
        {
            if (Directory.Exists(paymentGatewayFolderPath))
            {
                //check for valid .sfe file exist or not
                XmlDocument doc = new XmlDocument();
                doc.Load(paymentGatewayFolderPath + '\\' + paymentGateWay.ManifestFile);

                try
                {
                    if (paymentGateWay.PaymentGatewayTypeID > 0)
                    {
                        //Run script  
                        ReadUninstallScriptAndDLLFiles(doc, paymentGatewayFolderPath, installerClass);
                        //Rollback PaymentGatewayTypeID
                        //installerClass.PaymentGatewayRollBack(paymentGateWay.PaymentGatewayTypeID, GetPortalID, GetStoreID);
                        if (deleteModuleFolder == true)
                        {
                            //Delete Payment GateWay's Original Folder
                            installerClass.DeleteTempDirectory(paymentGateWay.InstalledFolderPath);
                        }
                        installhelp.InstallPackage(paymentModule, gatewayID);
                    }
                }
                catch (Exception ex)
                {
                    Exceptions = ex.Message;
                }
            }
            else
            {
                ShowMessage(SageMessageTitle.Exception.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "PaymentGatewayFolderDoesnotExist"), "", SageMessageType.Error);
            }
        }
    }
 protected void btnAddNew_Click(object sender, EventArgs e)
 {
     try
     {
         ArrayList arrColl = installhelp.Step0CheckLogic(fuPGModule);
         int ReturnValue;
         if (arrColl != null && arrColl.Count > 0)
         {
             ReturnValue = (int)arrColl[0];
             paymentModule = (PaymentGateWayModuleInfo)arrColl[1];
             ViewState["PaymentGateway"] = paymentModule.PaymentGatewayTypeID.ToString();
             if (ReturnValue == 0)
             {
                 // ViewState["PaymentGateway"] = null;
                 ShowMessage(SageMessageTitle.Notification.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "YouNeedToSelectAFileToUploadFirst"), "", SageMessageType.Alert);
                 lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "YouNeedToSelectAFileToUploadFirst");
                 lblLoadMessage.Visible = true;
                 errorCode = 1;
                 return;
             }
             else if (ReturnValue == -1)
             {
                 // ViewState["PaymentGateway"] = null;
                 ShowMessage(SageMessageTitle.Exception.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "InvalidFileExtension") + this.fuPGModule.FileName, "", SageMessageType.Alert);
                 lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "InvalidFileExtension") + this.fuPGModule.FileName;
                 lblLoadMessage.Visible = true;
                 errorCode = 1;
                 return;
             }
             else if (ReturnValue == 1)
             {
                 //paymentModule = (PaymentGateWayModuleInfo)ViewState["PaymentGateway"];
                 //if (paymentModule != null)
                 //{
                 installhelp.InstallPackage(paymentModule, 0);
                 ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "PaymentGatewayInstalledSuccessfully"), "", SageMessageType.Success);
                 errorCode = 0;
                 return;
                 //}
             }
             else if (ReturnValue == 2)
             {
                 if (chkRepairInstall.Checked == true)
                 {
                     //paymentModule = (PaymentGateWayModuleInfo)ViewState["PaymentGateway"];
                     int gatewayID = int.Parse(ViewState["PaymentGateway"].ToString());
                     if (paymentModule != null)
                     {
                         UninstallPaymentGateway(paymentModule, true, gatewayID);
                         ViewState["PaymentGateway"] = null;
                         ShowMessage(SageMessageTitle.Information.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "PaymentGatewayInstalledSuccessfully"), "", SageMessageType.Success);
                         errorCode = 0;
                         return;
                     }
                 }
                 else
                 {
                     //ViewState["PaymentGateway"] = null;                    
                     ShowMessage(SageMessageTitle.Notification.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "AlreadyExistPaymentGateway"), "", SageMessageType.Alert);
                     lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "AlreadyExistPaymentGateway");
                     lblLoadMessage.Visible = true;
                     errorCode = 1;
                     return;
                 }
             }
             else if (ReturnValue == 3)
             {
                 // ViewState["PaymentGateway"] = null;
                 ShowMessage(SageMessageTitle.Notification.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThisPackageIsNotValid"), "", SageMessageType.Alert);
                 lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThisPackageIsNotValid");
                 lblLoadMessage.Visible = true;
                 errorCode = 1;
                 return;
             }
             else if (ReturnValue == 4)
             {
                 // ViewState["PaymentGateway"] = null;
                 ShowMessage(SageMessageTitle.Notification.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThisPackageDoesNotAppearToBeValid"), "", SageMessageType.Alert);
                 lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThisPackageDoesNotAppearToBeValid");
                 lblLoadMessage.Visible = true;
                 errorCode = 1;
                 return;
             }
             else
             {
                 // ViewState["PaymentGateway"] = null;
                 ShowMessage(SageMessageTitle.Exception.ToString(), SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThereIsErrorWhileInstallingThisModule"), "", SageMessageType.Error);
                 lblLoadMessage.Text = SageMessage.GetSageModuleLocalMessageByVertualPath("Modules/ASPXCommerce/ASPXPaymentGateWayManagement/ModuleLocalText", "ThereIsErrorWhileInstallingThisModule");
                 lblLoadMessage.Visible = true;
                 errorCode = 1;
                 return;
             }
         }
     }
     catch (Exception ex)
     {
         ProcessException(ex);
     }
 }
Exemplo n.º 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
                    {
                        #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())));
                            sq.ExecuteNonQuery("[dbo].[usp_ASPX_PaymentGateWayControlAdd]", paramCol);
                        }

                        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));
                            sq.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);
        }
Exemplo n.º 4
0
 public string checkFormanifestFile(string TempUnzippedPath, PaymentGateWayModuleInfo module)
 {
     DirectoryInfo dir = new DirectoryInfo(TempUnzippedPath);
     foreach (FileInfo f in dir.GetFiles("*.*"))
     {
         if (f.Extension.ToLower() == ".sfe")
         {
             module.ManifestFile = f.Name;
             return module.ManifestFile;
         }
         else
         {
             module.ManifestFile = "";
         }
     }
     return module.ManifestFile;
 }
Exemplo n.º 5
0
        public int Step1CheckLogic(string TempUnzippedPath, PaymentGateWayModuleInfo module)
        {
            if (checkFormanifestFile(TempUnzippedPath, module) != "")
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(TempUnzippedPath + '\\' + module.ManifestFile);
                XmlElement root = doc.DocumentElement;
                if (checkValidManifestFile(root, module))
                {
                    XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder");
                    foreach (XmlNode xn in xnList)
                    {
                        module.PaymentGatewayTypeName = xn["paymentgatewayname"].InnerXml.ToString();
                        module.FolderName = xn["foldername"].InnerXml.ToString();
                        module.FriendlyName = xn["friendlyname"].InnerXml.ToString();   
                        module.Description = xn["description"].InnerXml.ToString();  
                        module.Version = xn["version"].InnerXml.ToString();  
                        module.Name = xn["name"].InnerXml.ToString();
                        module.StoreID = GetStoreID;//int.Parse(xn["storeid"].InnerXml.ToString());
                        module.PortalID = GetPortalID;//int.Parse(xn["portalid"].InnerXml.ToString());
                        module.CultureName = xn["culturename"].InnerXml.ToString();

                        if (!String.IsNullOrEmpty(module.PaymentGatewayTypeName) && IsModuleExist(module.PaymentGatewayTypeName.ToLower(), module.FolderName.ToString(), module.FriendlyName.ToString(),int.Parse(GetStoreID.ToString()),int.Parse(GetPortalID.ToString())))
                        {
                            string path = HttpContext.Current.Server.MapPath("~/");
                            string targetPath = path + SageFrame.Core.RegisterModule.Common.ModuleFolder + '\\' + module.FolderName;
                            module.InstalledFolderPath = targetPath;
                           // DeleteTempDirectory(TempUnzippedPath);
                            return 1;//Already exist
                        }
                        else
                        {
                            return 2;//Not Exists
                        }
                    }
                }
                else
                {
                    return -1;//Invalid Manifest file
                }
            }
            return 0;//No manifest file
        }
Exemplo n.º 6
0
 public bool checkValidManifestFile(XmlElement root, PaymentGateWayModuleInfo module)
 {
     if (root.Name == "sageframe")//need to change the root node for valid manifest file at root node  
     {
         string PackageType = root.GetAttribute("type"); //root.NodeType
         //module.PackageType = PackageType;
         switch (PackageType.ToLower())
         {
             //need to check for many cases for like skin /..
             case "paymentgateway":
                 return true;
         }
     }
     return false;
 }