private static void SaveDynamicMethods(ShippingProvider provider, int providerId, AspxCommonInfo commonInfo)
 {
     foreach (var dynamicMethod in provider.DynamicMethods)
     {
         try
         {
             List <KeyValuePair <string, object> > paraMeter = new List <KeyValuePair <string, object> >();
             paraMeter.Add(new KeyValuePair <string, object>("ShippingProviderId", providerId));
             paraMeter.Add(new KeyValuePair <string, object>("AssemblyName", provider.AssemblyName));
             paraMeter.Add(new KeyValuePair <string, object>("ClassName", provider.ShippingProviderClass));
             paraMeter.Add(new KeyValuePair <string, object>("NameSpace", provider.ShippingProviderNamespace));
             paraMeter.Add(new KeyValuePair <string, object>("MethodName", dynamicMethod.MethodName));
             paraMeter.Add(new KeyValuePair <string, object>("MethodType", dynamicMethod.MethodType));
             paraMeter.Add(new KeyValuePair <string, object>("ParameterCount",
                                                             dynamicMethod.DynamicParams.Count()));
             paraMeter.Add(new KeyValuePair <string, object>("StoreId", commonInfo.StoreID));
             paraMeter.Add(new KeyValuePair <string, object>("PortalId", commonInfo.PortalID));
             paraMeter.Add(new KeyValuePair <string, object>("UserName", commonInfo.UserName));
             OracleHandler sqLh       = new OracleHandler();
             int           dynamicmId = sqLh.ExecuteAsScalar <int>("usp_aspx_AddDynamicMethod", paraMeter);
             SaveDynamicMethodParams(dynamicMethod.DynamicParams, dynamicmId, commonInfo);
         }
         catch (Exception ex)
         {
             throw ex;
         }
     }
 }
 public static void ShippingProviderAddUpdate(List <ShippingMethod> methods,
                                              ShippingProvider provider, bool isAddedZip, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         AspxShipProviderMgntProvider.ShippingProviderAddUpdate(methods, provider, isAddedZip, aspxCommonObj);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public int SaveUpdateProviderSetting(ShippingProvider provider, string settingKey, string settingValue, AspxCommonInfo commonInfo)
 {
     try
     {
         int providerID = AspxShipProviderMgntProvider.SaveUpdateProviderSetting(provider, settingKey, settingValue, commonInfo);
         return(providerID);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public static int SaveUpdateProviderSetting(ShippingProvider provider, string settingKey, string settingValue, AspxCommonInfo commonInfo)
        {
            try
            {
                if (!provider.IsUnique)
                {
                    DeleteShippingProvider(provider.ShippingProviderID, commonInfo);
                }

                List <KeyValuePair <string, object> > parameter = new List <KeyValuePair <string, object> >();

                parameter.Add(new KeyValuePair <string, object>("ShippingProviderID", 0));
                parameter.Add(new KeyValuePair <string, object>("StoreID", commonInfo.StoreID));
                parameter.Add(new KeyValuePair <string, object>("PortalID", commonInfo.PortalID));
                parameter.Add(new KeyValuePair <string, object>("CultureName", commonInfo.CultureName));
                parameter.Add(new KeyValuePair <string, object>("UserName", commonInfo.UserName));

                parameter.Add(new KeyValuePair <string, object>("ShippingProviderServiceCode",
                                                                provider.ShippingProviderServiceCode));
                parameter.Add(new KeyValuePair <string, object>("ShippingProviderName", provider.ShippingProviderName));
                parameter.Add(new KeyValuePair <string, object>("ShippingProviderAliasHelp",
                                                                provider.ShippingProviderAliasHelp));
                parameter.Add(new KeyValuePair <string, object>("AssemblyName", provider.AssemblyName));
                parameter.Add(new KeyValuePair <string, object>("Namespace", provider.ShippingProviderNamespace));
                parameter.Add(new KeyValuePair <string, object>("Class", provider.ShippingProviderClass));
                parameter.Add(new KeyValuePair <string, object>("SettingControlSrc", provider.SettingControlPath));
                parameter.Add(new KeyValuePair <string, object>("LabelControlSrc", provider.LabelControlPath));
                parameter.Add(new KeyValuePair <string, object>("TrackControlSrc", provider.TrackControlPath));
                parameter.Add(new KeyValuePair <string, object>("IsActive", provider.IsActive));
                parameter.Add(new KeyValuePair <string, object>("IsAddedZipFlag", true));

                OracleHandler sqlH       = new OracleHandler();
                int           providerId = sqlH.ExecuteAsScalar <int>("usp_Aspx_ShippingProviderAddUpdate", parameter);

                SaveSetting(providerId, settingKey, settingValue, commonInfo);
                SaveDynamicMethods(provider, providerId, commonInfo);
                ExtractFile(provider);

                return(providerId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static List <ProviderShippingMethod> GetProviderRemainingMethod(int shippingProviderId, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                List <KeyValuePair <string, object> > paramCol = new List <KeyValuePair <string, object> >();
                paramCol.Add(new KeyValuePair <string, object>("ShippingProviderId", shippingProviderId));
                paramCol.Add(new KeyValuePair <string, object>("StoreId", aspxCommonObj.StoreID));
                paramCol.Add(new KeyValuePair <string, object>("PortalId", aspxCommonObj.PortalID));
                OracleHandler    sqlHl        = new OracleHandler();
                ShippingProvider providerInfo = sqlHl.ExecuteAsObject <ShippingProvider>("usp_Aspx_GetProviderAssemblyInfo",
                                                                                         paramCol);

                var obj1 =
                    (Dictionary <string, string>)
                    DynamicUtility.InvokeMethodAsObject(providerInfo.AssemblyName, providerInfo.ShippingProviderNamespace,
                                                        providerInfo.ShippingProviderClass, "GetAvailableServiceMethod");
                List <ShippingMethodInfo> storeMethod = AspxShipMethodMgntController.GetStoreProvidersAvailableMethod(shippingProviderId, aspxCommonObj);
                var services = obj1.Select(method => new ProviderShippingMethod()
                {
                    ShippingMethodCode = method.Key,
                    ShippingMethodName = method.Value
                }).ToList();

                var filterdmethods = new List <ProviderShippingMethod>();

                foreach (ShippingMethodInfo shippingMethod in storeMethod)
                {
                    foreach (var providerShippingMethod in services)
                    {
                        if (providerShippingMethod.ShippingMethodName == shippingMethod.ShippingMethodName)
                        {
                            services.Remove(providerShippingMethod);
                            break;
                        }
                    }
                }

                return(services);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        private static void ExtractFile(ShippingProvider provider)
        {
            //  TempFileName
            string extractedPath = "";

            ZipUtil.UnZipFiles(provider.TempFolderPath + "\\" + provider.TempFileName,
                               HttpContext.Current.Server.MapPath("~/" + provider.ModuleFolder),
                               ref extractedPath, SageFrame.Common.RegisterModule.Common.Password, false);

            FileHelperController fileHelper = new FileHelperController();
            string temp = "";

            temp = provider.TempFolderPath.Substring(provider.TempFolderPath.LastIndexOf("Module"));

            //var thread = new Thread(() => fileHelper.DeleteTempDirectory(temp));
            //thread.Start();

            fileHelper.DeleteTempDirectory(temp);
        }
        public static void ShippingProviderAddUpdate(List<ShippingMethod> methods,
            ShippingProvider provider, bool isAddedZip, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                if (!isAddedZip)
                {
                    List<KeyValuePair<string, object>> parameter = CommonParmBuilder.GetParamSPUC(aspxCommonObj);
                    parameter.Add(new KeyValuePair<string, object>("@ShippingProviderID", provider.ShippingProviderID));
                    parameter.Add(new KeyValuePair<string, object>("@ShippingProviderServiceCode",
                                                                   provider.ShippingProviderServiceCode));
                    parameter.Add(new KeyValuePair<string, object>("@ShippingProviderName", provider.ShippingProviderName));
                    parameter.Add(new KeyValuePair<string, object>("@ShippingProviderAliasHelp",
                                                                   provider.ShippingProviderAliasHelp));
                    parameter.Add(new KeyValuePair<string, object>("@AssemblyName", null));
                    parameter.Add(new KeyValuePair<string, object>("@Namespace", null));
                    parameter.Add(new KeyValuePair<string, object>("@Class", null));
                    parameter.Add(new KeyValuePair<string, object>("@SettingControlSrc", null));
                    parameter.Add(new KeyValuePair<string, object>("@IsActive", provider.IsActive));
                    parameter.Add(new KeyValuePair<string, object>("@IsAddedZipFlag", false));

                    SQLHandler sqlH = new SQLHandler();
                    int id = sqlH.ExecuteAsScalar<int>("[dbo].[usp_Aspx_ShippingProviderAddUpdate]", parameter);

                    //add providers provided shipping methods/services
                    List<KeyValuePair<string, object>> param = new List<KeyValuePair<string, object>>();
                    param.Add(new KeyValuePair<string, object>("@StoreId", aspxCommonObj.StoreID));
                    param.Add(new KeyValuePair<string, object>("@PortalId", aspxCommonObj.PortalID));
                    int displayorder = sqlH.ExecuteAsScalar<int>("[dbo].[usp_Aspx_GetDisplayOrderForShippingMethod]", param);

                    if (methods != null)
                    {
                        if (provider.ShippingProviderID != 0)
                        {
                            foreach (ShippingMethod method in methods)
                            {
                                displayorder++;
                                List<KeyValuePair<string, object>> parameterz = new List<KeyValuePair<string, object>>();
                                parameterz.Add(new KeyValuePair<string, object>("@ShippingMethodName",
                                                                       method.ShippingMethodName));
                                parameterz.Add(new KeyValuePair<string, object>("@ShippingMethodCode",
                                                                    method.ShippingMethodCode));
                                parameterz.Add(new KeyValuePair<string, object>("@ImagePath", ""));
                                parameterz.Add(new KeyValuePair<string, object>("@AlternateText",
                                                                 method.AlternateText));
                                parameterz.Add(new KeyValuePair<string, object>("@DisplayOrder", displayorder));
                                parameterz.Add(new KeyValuePair<string, object>("@DeliveryTime",
                                                                 method.DeliveryTime));
                                parameterz.Add(new KeyValuePair<string, object>("@WeightLimitFrom",
                                                                 method.WeightLimitFrom));
                                parameterz.Add(new KeyValuePair<string, object>("@WeightLimitTo",
                                                                   method.WeightLimitTo));
                                parameterz.Add(new KeyValuePair<string, object>("@ShippingProviderID",
                                                                 provider.ShippingProviderID));
                                parameterz.Add(new KeyValuePair<string, object>("@StoreID", aspxCommonObj.StoreID));
                                parameterz.Add(new KeyValuePair<string, object>("@PortalID", aspxCommonObj.PortalID));
                                parameterz.Add(new KeyValuePair<string, object>("@IsActive", method.IsActive));
                                parameterz.Add(new KeyValuePair<string, object>("@UserName", aspxCommonObj.UserName));
                                parameterz.Add(new KeyValuePair<string, object>("@CultureName", aspxCommonObj.CultureName));

                                sqlH.ExecuteNonQuery("usp_Aspx_AddProvidersShippingMethod", parameterz);
                            }
                        }
                    }
                }
                else
                {
                    //add providers provided shipping methods/services
                    int displayorder = 0;
                    if (provider.ShippingProviderID != 0)
                    {
                        foreach (ShippingMethod method in methods)
                        {
                            displayorder++;
                            List<KeyValuePair<string, object>> parameterz = CommonParmBuilder.GetParamSPUC(aspxCommonObj);

                            parameterz.Add(new KeyValuePair<string, object>("@ShippingMethodName",
                                                                  method.ShippingMethodName));
                            parameterz.Add(new KeyValuePair<string, object>("@ShippingMethodCode",
                                                             method.ShippingMethodCode));
                            parameterz.Add(new KeyValuePair<string, object>("@ImagePath", ""));
                            parameterz.Add(new KeyValuePair<string, object>("@AlternateText", method.AlternateText));
                            parameterz.Add(new KeyValuePair<string, object>("@DisplayOrder", displayorder));
                            parameterz.Add(new KeyValuePair<string, object>("@DeliveryTime", method.DeliveryTime));
                            parameterz.Add(new KeyValuePair<string, object>("@WeightLimitFrom", provider.MinWeight));
                            parameterz.Add(new KeyValuePair<string, object>("@WeightLimitTo", provider.MaxWeight));
                            parameterz.Add(new KeyValuePair<string, object>("@ShippingProviderID",
                                                            provider.ShippingProviderID));
                            parameterz.Add(new KeyValuePair<string, object>("@IsActive", method.IsActive));
                            SQLHandler sqlH = new SQLHandler();
                            sqlH.ExecuteNonQuery("usp_Aspx_AddProvidersShippingMethod", parameterz);
                        }
                    }

                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        private static void SaveDynamicMethods(ShippingProvider provider, int providerId, AspxCommonInfo commonInfo)
        {
            foreach (var dynamicMethod in provider.DynamicMethods)
            {
                try
                {


                    List<KeyValuePair<string, object>> paraMeter = new List<KeyValuePair<string, object>>();
                    paraMeter.Add(new KeyValuePair<string, object>("@ShippingProviderId", providerId));
                    paraMeter.Add(new KeyValuePair<string, object>("@AssemblyName", provider.AssemblyName));
                    paraMeter.Add(new KeyValuePair<string, object>("@ClassName", provider.ShippingProviderClass));
                    paraMeter.Add(new KeyValuePair<string, object>("@NameSpace", provider.ShippingProviderNamespace));
                    paraMeter.Add(new KeyValuePair<string, object>("@MethodName", dynamicMethod.MethodName));
                    paraMeter.Add(new KeyValuePair<string, object>("@MethodType", dynamicMethod.MethodType));
                    paraMeter.Add(new KeyValuePair<string, object>("@ParameterCount",
                                                                   dynamicMethod.DynamicParams.Count()));
                    paraMeter.Add(new KeyValuePair<string, object>("@StoreId", commonInfo.StoreID));
                    paraMeter.Add(new KeyValuePair<string, object>("@PortalId", commonInfo.PortalID));
                    paraMeter.Add(new KeyValuePair<string, object>("@UserName", commonInfo.UserName));
                    SQLHandler sqLh = new SQLHandler();
                    int dynamicmId = sqLh.ExecuteAsScalar<int>("usp_aspx_AddDynamicMethod", paraMeter);
                    SaveDynamicMethodParams(dynamicMethod.DynamicParams, dynamicmId,commonInfo);
                }
                catch (Exception ex)
                {

                    throw ex;
                }
            }

        }
        private static void ExtractFile(ShippingProvider provider)
        {
            //  TempFileName
            string extractedPath = "";
            ZipUtil.UnZipFiles(provider.TempFolderPath + "\\" + provider.TempFileName,
                               HttpContext.Current.Server.MapPath("~/" + provider.ModuleFolder),
                               ref extractedPath, SageFrame.Common.RegisterModule.Common.Password, false);

            FileHelperController fileHelper = new FileHelperController();
            string temp = "";
            temp = provider.TempFolderPath.Substring(provider.TempFolderPath.LastIndexOf("Module"));

            //var thread = new Thread(() => fileHelper.DeleteTempDirectory(temp));
            //thread.Start();

            fileHelper.DeleteTempDirectory(temp);
        }
        public static int SaveUpdateProviderSetting(ShippingProvider provider, string settingKey, string settingValue, AspxCommonInfo commonInfo)
        {
            try
            {
                if (!provider.IsUnique)
                {
                    DeleteShippingProvider(provider.ShippingProviderID, commonInfo);
                }

                List<KeyValuePair<string, object>> parameter = new List<KeyValuePair<string, object>>();

                parameter.Add(new KeyValuePair<string, object>("@ShippingProviderID", 0));
                parameter.Add(new KeyValuePair<string, object>("@StoreID", commonInfo.StoreID));
                parameter.Add(new KeyValuePair<string, object>("@PortalID", commonInfo.PortalID));
                parameter.Add(new KeyValuePair<string, object>("@CultureName", commonInfo.CultureName));
                parameter.Add(new KeyValuePair<string, object>("@UserName", commonInfo.UserName));

                parameter.Add(new KeyValuePair<string, object>("@ShippingProviderServiceCode",
                                                               provider.ShippingProviderServiceCode));
                parameter.Add(new KeyValuePair<string, object>("@ShippingProviderName", provider.ShippingProviderName));
                parameter.Add(new KeyValuePair<string, object>("@ShippingProviderAliasHelp",
                                                               provider.ShippingProviderAliasHelp));
                parameter.Add(new KeyValuePair<string, object>("@AssemblyName", provider.AssemblyName));
                parameter.Add(new KeyValuePair<string, object>("@Namespace", provider.ShippingProviderNamespace));
                parameter.Add(new KeyValuePair<string, object>("@Class", provider.ShippingProviderClass));
                parameter.Add(new KeyValuePair<string, object>("@SettingControlSrc", provider.SettingControlPath));
                parameter.Add(new KeyValuePair<string, object>("@LabelControlSrc", provider.LabelControlPath));
                parameter.Add(new KeyValuePair<string, object>("@TrackControlSrc", provider.TrackControlPath));
                parameter.Add(new KeyValuePair<string, object>("@IsActive", provider.IsActive));
                parameter.Add(new KeyValuePair<string, object>("@IsAddedZipFlag", true));

                SQLHandler sqlH = new SQLHandler();
                int providerId = sqlH.ExecuteAsScalar<int>("[dbo].[usp_Aspx_ShippingProviderAddUpdate]", parameter);

                SaveSetting(providerId, settingKey, settingValue, commonInfo);
                SaveDynamicMethods(provider, providerId, commonInfo);
                ExtractFile(provider);

                return providerId;

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
 public void ShippingProviderAddUpdate(List<ShippingMethod> methods,
     ShippingProvider provider, bool isAddedZip, AspxCommonInfo aspxCommonObj)
 {
     try
     {
         AspxShipProviderMgntController.ShippingProviderAddUpdate(methods, provider, isAddedZip, aspxCommonObj);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 private void UninstallShippingProvider(ShippingProvider provider)
 {
     string path = HttpContext.Current.Server.MapPath("~/");
     DeleteAllDllsFromBin(provider.DllFiles);
   
 }
    private int Step1CheckLogic(string tempUnzippedPath, ShippingProvider provider)
    {
        if (CheckFormanifestFile(tempUnzippedPath, provider) != "")
        {
            var doc = new XmlDocument();
            doc.Load(tempUnzippedPath + '\\' + provider.ManifestFile);
            XmlElement root = doc.DocumentElement;
            if (CheckValidManifestFile(root))
            {

                XmlNodeList xnList3 = doc.SelectNodes("sageframe/folders/folder/files/file");
                if (xnList3.Count != 0)
                {var dlls=new ArrayList();
                    foreach (XmlNode xn3 in xnList3)
                    {
                        string fileName = xn3["name"].InnerXml;
                        try
                        {
                            #region CheckValidDataSqlProvider

                            if (!String.IsNullOrEmpty(fileName) &&
                                fileName.Contains("1.00.00.SqlDataProvider"))
                            {
                                provider.InstallScript = fileName;
                            }

                            #endregion

                            #region CheckAlldllFiles

                            if (!String.IsNullOrEmpty(fileName) && fileName.Contains(".dll"))
                            {
                                dlls.Add(fileName);
                                _provider.DllFiles = dlls;
                            }

                            #endregion

                            #region ReadUninstall SQL FileName

                            if (!String.IsNullOrEmpty(fileName) && fileName.Contains("Uninstall.SqlDataProvider"))
                            {
                                provider.UninstallScript = fileName;
                            }

                            #endregion



                        }
                        catch
                        {
                           break;
                        }
                    }
                }
                XmlNodeList xnList = doc.SelectNodes("sageframe/folders/folder");
                foreach (XmlNode xn in xnList)
                {
                    provider.ShippingProviderName = xn["providername"].InnerXml;
                    provider.ShippingProviderAliasHelp = xn["provideraliashelp"].InnerXml;
                    provider.ShippingProviderServiceCode = xn["servicecode"].InnerXml;
                    provider.AssemblyName = xn["assemblyname"].InnerXml;
                    provider.ShippingProviderNamespace = xn["namespace"].InnerXml;
                    provider.ShippingProviderClass = xn["class"].InnerXml;
                    provider.ModuleFolder = "Modules/" + xn["foldername"].InnerXml;
                                                                         provider.IsActive = true;
                    
                                                                          
                    if (IsProviderExist(provider.ShippingProviderName,_storeId,_portalId))
                    {
                        XmlNodeList settingCtl = doc.SelectNodes("sageframe/folders/folder/modules/module/controls/control");
                        foreach (XmlNode xn5 in settingCtl)
                        {
                            if (xn5["name"].InnerXml.ToLower().Trim() == "setting")
                                provider.SettingControlPath = xn5["src"].InnerXml;
                            if (xn5["name"].InnerXml.ToLower().Trim() == "label")
                                provider.LabelControlPath = xn5["src"].InnerXml;
                            if (xn5["name"].InnerXml.ToLower().Trim() == "track")
                                provider.TrackControlPath = xn5["src"].InnerXml;
                            
                        }
                        XmlNodeList xnList2 = doc.SelectNodes("sageframe/folders/folder/settings/setting");
                       
                        foreach (XmlNode xn2 in xnList2)
                        {
                            string settingkey = xn2["key"].InnerXml;
                            string settingvalue = xn2["value"].InnerXml;
                            _providerSetting.Add(new KeyValuePair<string, string>(settingkey, settingvalue));
                        }
                        provider.Settings = _providerSetting;

                        XmlNodeList methods = doc.SelectNodes("sageframe/folders/folder/dynamicmethods/method");
                        foreach (XmlNode method in methods)
                        {
                            var dymethod = new DynamicMethod();
                            dymethod.MethodName = method["name"].InnerXml;
                            dymethod.MethodType = method.Attributes["type"].Value;
                            var parlist = new List<DynamicParam>();
                           XmlNodeList parameters= method.SelectNodes("params/param");
                           if (parameters != null)
                           {
                              
                               int parCount = 0;
                               foreach (XmlNode param in parameters)
                               {
                                   var pars = new DynamicParam();
                                   parCount++;
                                   pars.ParameterName = param.Attributes["type"].Value;
                                   pars.ParameterType = param.Attributes["objectType"].Value;
                                   pars.ParameterOrder =int.Parse(param.Attributes["order"].Value);
                                   parlist.Add(pars);
                               }
                               dymethod.DynamicParams = parlist;
                           }
                            _dynamicMethods.Add(dymethod);
                        }
                        provider.DynamicMethods = _dynamicMethods;
                        _provider.SettingControlTempPath = ResolveUrl(this.AppRelativeTemplateSourceDirectory) +
                                         "temp\\extracted\\" +
                                         _provider.SettingControlPath.Split('/').Last();
                        _provider.SettingControlTempPath = Regex.Replace(_provider.SettingControlTempPath, @"(\\)", @"//");
                        return 1;//Already exist
                    }
                    else
                    {
                        XmlNodeList settingCtl = doc.SelectNodes("sageframe/folders/folder/modules/module/controls/control");
                        foreach (XmlNode xn5 in settingCtl)
                        {
                            if (xn5["name"].InnerXml.ToLower().Trim()=="setting")
                            provider.SettingControlPath = xn5["src"].InnerXml;
                            if (xn5["name"].InnerXml.ToLower().Trim() == "label")
                                provider.LabelControlPath = xn5["src"].InnerXml;
                            if (xn5["name"].InnerXml.ToLower().Trim() == "track")
                                provider.TrackControlPath = xn5["src"].InnerXml;
                        }
                        XmlNodeList xnList2 = doc.SelectNodes("sageframe/folders/folder/settings/setting");

                        foreach (XmlNode xn2 in xnList2)
                        {
                            string settingkey = xn2["key"].InnerXml;
                            string settingvalue = xn2["value"].InnerXml;
                            _providerSetting.Add(new KeyValuePair<string, string>(settingkey, settingvalue));
                        }
                        provider.Settings = _providerSetting;
                        XmlNodeList methods = doc.SelectNodes("sageframe/folders/folder/dynamicmethods/method");
                        foreach (XmlNode method in methods)
                        {
                            var dymethod = new DynamicMethod();
                            dymethod.MethodName = method["name"].InnerXml;

                            XmlNodeList parameters = method.SelectNodes("params/param");
                            if (parameters != null)
                            {
                                var listParam = new List<DynamicParam>();
                                int parCount = 0;
                                foreach (XmlNode param in parameters)
                                {
                                    var pars = new DynamicParam();
                                    parCount++;
                                    pars.ParameterName = param.Attributes["type"].Value;
                                    pars.ParameterType = param.Attributes["objectType"].Value;
                                    pars.ParameterOrder = int.Parse(param.Attributes["order"].Value);
                                    listParam.Add(pars);

                                }
                                dymethod.DynamicParams = listParam;
                            }
                            _dynamicMethods.Add(dymethod);
                        }
                        provider.DynamicMethods = _dynamicMethods;
                        _provider.SettingControlTempPath = ResolveUrl(this.AppRelativeTemplateSourceDirectory) +
                                         "temp\\extracted\\" +
                                         _provider.SettingControlPath.Split('/').Last();
                        _provider.SettingControlTempPath = Regex.Replace(_provider.SettingControlTempPath, @"(\\)", @"//");

                        return 2;//Not Exists
                    }
                }
            }
            else
            {
                return -1;//Invalid Manifest file
            }
        }
        return 0;//No manifest file
    }
 private string CheckFormanifestFile(string tempUnzippedPath, ShippingProvider provider)
 {
     DirectoryInfo dir = new DirectoryInfo(tempUnzippedPath);
     foreach (FileInfo f in dir.GetFiles("*.*"))
     {
         if (f.Extension.ToLower() == ".sfe")
         {
             provider.ManifestFile = f.Name;
             return provider.ManifestFile;
         }
         else
         {
             provider.ManifestFile = "";
         }
     }
     return provider.ManifestFile;
 }
        public static void ShippingProviderAddUpdate(List <ShippingMethod> methods,
                                                     ShippingProvider provider, bool isAddedZip, AspxCommonInfo aspxCommonObj)
        {
            try
            {
                if (!isAddedZip)
                {
                    List <KeyValuePair <string, object> > parameter = CommonParmBuilder.GetParamSPUC(aspxCommonObj);
                    parameter.Add(new KeyValuePair <string, object>("ShippingProviderID", provider.ShippingProviderID));
                    parameter.Add(new KeyValuePair <string, object>("ShippingProviderServiceCode",
                                                                    provider.ShippingProviderServiceCode));
                    parameter.Add(new KeyValuePair <string, object>("ShippingProviderName", provider.ShippingProviderName));
                    parameter.Add(new KeyValuePair <string, object>("ShippingProviderAliasHelp",
                                                                    provider.ShippingProviderAliasHelp));
                    parameter.Add(new KeyValuePair <string, object>("AssemblyName", null));
                    parameter.Add(new KeyValuePair <string, object>("Namespace", null));
                    parameter.Add(new KeyValuePair <string, object>("Class", null));
                    parameter.Add(new KeyValuePair <string, object>("SettingControlSrc", null));
                    parameter.Add(new KeyValuePair <string, object>("IsActive", provider.IsActive));
                    parameter.Add(new KeyValuePair <string, object>("IsAddedZipFlag", false));

                    OracleHandler sqlH = new OracleHandler();
                    int           id   = sqlH.ExecuteAsScalar <int>("usp_Aspx_ShippingProviderAddUpdate", parameter);

                    //add providers provided shipping methods/services
                    List <KeyValuePair <string, object> > param = new List <KeyValuePair <string, object> >();
                    param.Add(new KeyValuePair <string, object>("StoreId", aspxCommonObj.StoreID));
                    param.Add(new KeyValuePair <string, object>("PortalId", aspxCommonObj.PortalID));
                    int displayorder = sqlH.ExecuteAsScalar <int>("usp_Aspx_GetDisplayOrderForShippingMethod", param);

                    if (methods != null)
                    {
                        if (provider.ShippingProviderID != 0)
                        {
                            foreach (ShippingMethod method in methods)
                            {
                                displayorder++;
                                List <KeyValuePair <string, object> > parameterz = new List <KeyValuePair <string, object> >();
                                parameterz.Add(new KeyValuePair <string, object>("ShippingMethodName",
                                                                                 method.ShippingMethodName));
                                parameterz.Add(new KeyValuePair <string, object>("ShippingMethodCode",
                                                                                 method.ShippingMethodCode));
                                parameterz.Add(new KeyValuePair <string, object>("ImagePath", ""));
                                parameterz.Add(new KeyValuePair <string, object>("AlternateText",
                                                                                 method.AlternateText));
                                parameterz.Add(new KeyValuePair <string, object>("DisplayOrder", displayorder));
                                parameterz.Add(new KeyValuePair <string, object>("DeliveryTime",
                                                                                 method.DeliveryTime));
                                parameterz.Add(new KeyValuePair <string, object>("WeightLimitFrom",
                                                                                 method.WeightLimitFrom));
                                parameterz.Add(new KeyValuePair <string, object>("WeightLimitTo",
                                                                                 method.WeightLimitTo));
                                parameterz.Add(new KeyValuePair <string, object>("ShippingProviderID",
                                                                                 provider.ShippingProviderID));
                                parameterz.Add(new KeyValuePair <string, object>("StoreID", aspxCommonObj.StoreID));
                                parameterz.Add(new KeyValuePair <string, object>("PortalID", aspxCommonObj.PortalID));
                                parameterz.Add(new KeyValuePair <string, object>("IsActive", method.IsActive));
                                parameterz.Add(new KeyValuePair <string, object>("UserName", aspxCommonObj.UserName));
                                parameterz.Add(new KeyValuePair <string, object>("CultureName", aspxCommonObj.CultureName));

                                sqlH.ExecuteNonQuery("usp_Aspx_AddProvidersShippingMethod", parameterz);
                            }
                        }
                    }
                }
                else
                {
                    //add providers provided shipping methods/services
                    int displayorder = 0;
                    if (provider.ShippingProviderID != 0)
                    {
                        foreach (ShippingMethod method in methods)
                        {
                            displayorder++;
                            List <KeyValuePair <string, object> > parameterz = CommonParmBuilder.GetParamSPUC(aspxCommonObj);

                            parameterz.Add(new KeyValuePair <string, object>("ShippingMethodName",
                                                                             method.ShippingMethodName));
                            parameterz.Add(new KeyValuePair <string, object>("ShippingMethodCode",
                                                                             method.ShippingMethodCode));
                            parameterz.Add(new KeyValuePair <string, object>("ImagePath", ""));
                            parameterz.Add(new KeyValuePair <string, object>("AlternateText", method.AlternateText));
                            parameterz.Add(new KeyValuePair <string, object>("DisplayOrder", displayorder));
                            parameterz.Add(new KeyValuePair <string, object>("DeliveryTime", method.DeliveryTime));
                            parameterz.Add(new KeyValuePair <string, object>("WeightLimitFrom", provider.MinWeight));
                            parameterz.Add(new KeyValuePair <string, object>("WeightLimitTo", provider.MaxWeight));
                            parameterz.Add(new KeyValuePair <string, object>("ShippingProviderID",
                                                                             provider.ShippingProviderID));
                            parameterz.Add(new KeyValuePair <string, object>("IsActive", method.IsActive));
                            OracleHandler sqlH = new OracleHandler();
                            sqlH.ExecuteNonQuery("usp_Aspx_AddProvidersShippingMethod", parameterz);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }