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; } }
public static List <CommonRateList> GetRate(ItemListDetails itemsDetail) { try { System.Net.ServicePointManager.Expect100Continue = false; var rateInfo = new List <CommonRateList>(); //to get Dynamic Fuctions info List <MethodList> rateMethods = GetAllMethodsFromProvider(itemsDetail.CommonInfo.StoreID, itemsDetail.CommonInfo.PortalID); WareHouseAddress originAddress = GetWareHouseAddress(itemsDetail.CommonInfo.StoreID, itemsDetail.CommonInfo.PortalID); itemsDetail.WareHouseAddress = originAddress; if (itemsDetail.BasketItems.Count > 0) { foreach (var method in rateMethods) { List <ParamList> paramList = GetParamsOfMethod(method.DynamicMethodId, itemsDetail.CommonInfo.StoreID, itemsDetail.CommonInfo.PortalID); foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies()) { Type type = ass.GetType(method.NameSpace + "." + method.ClassName, false); var paramCollection = new List <object>(); if (type != null) { for (int i = 0; i < paramList.Count; i++) { var param = ass.GetType(method.NameSpace + "." + paramList[i].ParameterName, false); // Type listType = typeof (List<>).MakeGenericType(new Type[] {param}); Type t = itemsDetail.GetType(); if (param != null) { switch (paramList[i].ParameterType) { case "list": //itemslist var itemsList = DynamicUtility.TransferDataToList(itemsDetail.BasketItems, itemsDetail, param, method.AssemblyName); paramCollection.Add(itemsList); break; default: var pa = DynamicUtility.PassMembersValue(itemsDetail, param, method.AssemblyName); paramCollection.Add(pa); break; } } if (param == null && paramList[i].ParameterName != "") { switch (paramList[i].ParameterName) { case "storeId": paramCollection.Add(itemsDetail.CommonInfo.StoreID); break; case "portalId": paramCollection.Add(itemsDetail.CommonInfo.PortalID); break; case "providerId": paramCollection.Add(method.ShippingProviderId); break; } } // Type listType1 = param1.MakeGenericType(new Type[] { param1 }); // ((method.ClassName) Activator.CreateInstance(Type.GetType(method.ClassName))); // DynamicUtility.Cast<listType>(originAddress); } //var obj = new Object[] {originAddress, da, packagedimension}; object instance = Activator.CreateInstance(type); MethodInfo fn = type.GetMethod(method.MethodName); var obj = paramCollection.ToArray(); System.Net.ServicePointManager.Expect100Continue = false; var rateResponse = fn.Invoke(instance, BindingFlags.InvokeMethod | BindingFlags.Public | BindingFlags.Static, null, obj, null); List <CommonRateList> cl = DynamicUtility.CastToList <CommonRateList>(rateResponse); //list of available shipping method of store rateInfo.AddRange(cl); break; } } } } //GetProvidersAvailableMethod var allowedshippingMethods = GetProvidersAvailableMethod(itemsDetail.CommonInfo.StoreID, itemsDetail.CommonInfo.PortalID, itemsDetail.CommonInfo.CultureName); //filtering allowed shipping methods only var filterdmethods = new List <CommonRateList>(); // filterdmethods = rateInfo.Where(x => allowedshippingMethods.Any(y => x.ShippingMethodName == y.ShippingMethodName)). // ToList(); AspxCommerceWebService coreService = new AspxCommerceWebService(); List <ShippingMethodInfo> flatRates = coreService.GetShippingMethodByWeight(itemsDetail.CommonInfo.StoreID, itemsDetail.CommonInfo.PortalID, itemsDetail.CommonInfo. CustomerID, itemsDetail.CommonInfo.UserName, itemsDetail.CommonInfo. CultureName, itemsDetail.CommonInfo. SessionCode); foreach (var item in flatRates) { var cr = new CommonRateList { CurrencyCode = "", ImagePath = item.ImagePath, ShippingMethodId = item.ShippingMethodID, DeliveryTime = item.DeliveryTime, ShippingMethodName = item.ShippingMethodName, TotalCharges = decimal.Parse(item.ShippingCost) }; //filterdmethods.Insert(0, cr); filterdmethods.Add(cr); } foreach (var commonRateList in allowedshippingMethods) { foreach (var info in rateInfo) { if (info.ShippingMethodName == commonRateList.ShippingMethodName) { var filterdmethod = info; filterdmethod.ShippingMethodId = commonRateList.ShippingMethodID; filterdmethods.Add(filterdmethod); break; } } } return(filterdmethods); } catch (Exception e) { throw e; } }