public static int InsertAllBranchesAndRegionsOfMerchant(long merchantID, string productConnectionString) { var merchantBranches = MerchantBranchBAL.GetAllBranchesOfMerchant(merchantID, productConnectionString); if (merchantBranches != null && merchantBranches.Count != 0) { MerchantBranchBAL.InsertAllBranchesOfMerchantToCache(merchantID, merchantBranches); MerchantBranchBAL.InsertAllBranchShortInfoOfMerchantToCache(merchantID, merchantBranches.Select(x => new MerchantBranchShortInfo(x)).ToList()); if (_regionParentDictionary == null) { _regionParentDictionary = RegionBAL.GetRegionParentDictionary(productConnectionString); } var merchantRegions = new MerchantRegions(); merchantRegions.AllMerchantDistrict = merchantBranches.Select(x => x.RegionID).Distinct().ToList(); merchantRegions.AllMerchantProvins = merchantRegions.AllMerchantDistrict.Select(x => _regionParentDictionary[x]).Distinct().ToList(); MerchantRegionBAL.InsertMerchantRegions(merchantID, merchantRegions); return(merchantBranches.Count); } return(0); }
public static void InsertAllBranchesAndRegionsOfAllMerchant(string productConnectionString) { var startTime = DateTime.Now; var allMerchantBranches = MerchantBranchBAL.GetAllBranchesOfAllMerchants(productConnectionString); var getSqlDuration = DateTime.Now - startTime; startTime = DateTime.Now; MerchantBranchBAL.InsertAllBranchesOfAllMerchantsToCache(allMerchantBranches); MerchantBranchBAL.InsertAllBranchShortInfoOfAllMerchantsToCache(allMerchantBranches); if (_regionParentDictionary == null) { _regionParentDictionary = RegionBAL.GetRegionParentDictionary(productConnectionString); } var provinViewOrders = RegionBAL.GetAllRegionOrder(productConnectionString); MerchantRegionBAL.InsertMerchantRegionsOfAllMerchant(allMerchantBranches, provinViewOrders, _regionParentDictionary); var insertDuration = DateTime.Now - startTime; Logger.InfoFormat("InsertAllBranchesAndRegionsOfAllMerchant: {0} merchantBranches, GetSQLTime: {1} second, InsertTime: {2} second", allMerchantBranches.Count, getSqlDuration.TotalSeconds, insertDuration.TotalSeconds); }