public static void InsertProductPropertiesToCache(string productConnectionString) { var startTime = DateTime.Now; var allProductProperties = WebProductPropertyBAL.GetAllProductProperties(productConnectionString); var getAllProductPropertiesDuration = (DateTime.Now - startTime).TotalSeconds; startTime = DateTime.Now; var productPropertiesParts = CollectionUtilities.Partition <KeyValuePair <long, List <ProductPropertyEntry> > >(allProductProperties, 1000); foreach (var part in productPropertiesParts) { WebProductPropertyBAL.InsertProductPropertiesToCache(part); } var insertProductPropertiesDuration = (DateTime.Now - startTime).TotalSeconds; startTime = DateTime.Now; var allProductFilterProperties = WebProductPropertyBAL.GetAllProductFilterProperties(productConnectionString, allProductProperties); var getAllProductFilterPropertiesDuration = (DateTime.Now - startTime).TotalSeconds; startTime = DateTime.Now; var productFilterPropertiesParts = CollectionUtilities.Partition <KeyValuePair <long, List <ProductPropertyEntry> > >(allProductFilterProperties, 1000); foreach (var part in productFilterPropertiesParts) { WebProductPropertyBAL.InsertProductFilterPropertiesToCache(part); } var insertProductFilterPropertiesDuration = (DateTime.Now - startTime).TotalSeconds; Logger.InfoFormat("InsertProductPropertiesToCache: {0} products. GetAllProductProperties Time: {1} s. InsertProductProperties Time: {2} s", allProductProperties.Count, getAllProductPropertiesDuration, insertProductPropertiesDuration); Logger.InfoFormat("InsertProductFilterPropertiesToCache: {0} products. GetAllProductFilterProperties Time: {1} s. InsertProductFilterProperties Time: {2} s", allProductFilterProperties.Count, getAllProductPropertiesDuration, insertProductPropertiesDuration); }
private void UpdateProperties() { while (_isRunning) { if ((DateTime.Now - LastUpdatePropertiesTime) > TimeSpan.FromHours(12)) { try { var propertyValueDictionary = WebProductPropertyBAL.GetAllPropertyValues(_productConnectionString); var propertyUnitDictionary = WebProductPropertyBAL.GetPropertyUnitDictionary(_productConnectionString); solrIndexer.PropertyUnitDictionary = propertyUnitDictionary; solrIndexer.PropertyValueDictionary = propertyValueDictionary; LastUpdatePropertiesTime = DateTime.Now; Logger.Info("Update Properties Success!"); } catch (Exception exception) { Logger.Error("Update Properties Error.", exception); Thread.Sleep(30000); } } else { Thread.Sleep(10000); } } }
private void InitData() { this.Invoke((MethodInvoker) delegate { panelMainControl.Enabled = false; }); var listMerchantUseDatafeedID = IndexProductTools.GetListMerchantUseDatafeedID(_productConnectionString);; var listSpecialMerchantID = IndexProductTools.GetListSpecialMerchantID(_productConnectionString); var listPriorMerchants = IndexProductTools.GetAllPriorMerchants(_productConnectionString); var listBadMerchant = IndexProductTools.GetAllBadMerchantId(_productConnectionString, 35); solrIndexer.ListMerchantUseDatafeedID = listMerchantUseDatafeedID; solrIndexer.ListSpecialMerchantID = listSpecialMerchantID; solrIndexer.ListPriorMerchants = listPriorMerchants; solrIndexer.ListBadMerchantID = listBadMerchant; var regionTree = RegionBAL.GetRegionTree(_productConnectionString); var categoryTree = ProductCategoryBAL.GetProductCategoryTree(_productConnectionString); var categoryTags = IndexProductTools.GetAllCategoryTags(_productConnectionString); var listPrefixCategory = IndexProductTools.GetAllPrefixCategory(_productConnectionString); solrIndexer.RegionTree = regionTree; solrIndexer.CategoryTree = categoryTree; solrIndexer.CategoryTags = categoryTags; solrIndexer.ListPrefixCategory = listPrefixCategory; var propertyValueDictionary = WebProductPropertyBAL.GetAllPropertyValues(_productConnectionString); var propertyUnitDictionary = WebProductPropertyBAL.GetPropertyUnitDictionary(_productConnectionString); solrIndexer.PropertyUnitDictionary = propertyUnitDictionary; solrIndexer.PropertyValueDictionary = propertyValueDictionary; this.Invoke((MethodInvoker) delegate { panelMainControl.Enabled = true; }); }