/// <summary> /// Import categories to elasatic search /// DEPRECATED. Do not use anymore. Use ImportDepartments instead. /// </summary> public void ImportCategories() { try { DateTime start = DateTime.Now; _eventLog.WriteInformationLog(String.Format("ETL: Import Process Starting: Import categories to CS {0}", start.ToString())); var parentCategories = _stagingRepository.ReadParentCategories(); var childCategories = _stagingRepository.ReadSubCategories(); var categories = new BlockingCollection <ElasticSearchCategoryUpdate>(); //Parent Categories //Parallel.ForEach(parentCategories.AsEnumerable(), row => foreach (DataRow row in parentCategories.Rows) { categories.Add(new ElasticSearchCategoryUpdate() { index = new ESCategoryRootData() { _id = row.GetString("CategoryId"), data = new ESCategoryData() { parentcategoryid = null, name = row.GetString("CategoryName"), ppicode = row.GetString("PPICode"), subcategories = PopulateSubCategories(row.GetString("CategoryId"), childCategories) } } }); } ; //Sub Categories //Parallel.ForEach(childCategories.AsEnumerable(), row => foreach (DataRow row in childCategories.Rows) { categories.Add(new ElasticSearchCategoryUpdate() { index = new ESCategoryRootData() { _id = row.GetString("CategoryId"), data = new ESCategoryData() { parentcategoryid = row.GetString("ParentCategoryId"), name = row.GetString("CategoryName"), ppicode = row.GetString("PPICode") } } }); } _elasticSearchRepository.Create(string.Concat(categories.Select(c => c.ToJson()))); TimeSpan took = DateTime.Now - start; _eventLog.WriteInformationLog(String.Format("ETL: Import Process Finished: Import categories to CS. Process took {0}", took.ToString())); } catch (Exception e) { _eventLog.WriteErrorLog(String.Format("ETL: Error importing categories to CS -- whole process failed. {0} -- {1}", e.Message, e.StackTrace)); } }
public void ImportHouseBrands() { try { DateTime start = DateTime.Now; _eventLog.WriteInformationLog(String.Format("ETL: Import Process Starting: Import house brands to ES {0}", start.ToString())); var brandsDataTable = _stagingRepository.ReadBrandControlLabels(); var brands = new BlockingCollection <Models.ElasticSearch.BrandControlLabels.BrandUpdate>(); //Parallel.ForEach(brandsDataTable.AsEnumerable(), row =>reach foreach (DataRow row in brandsDataTable.Rows) { brands.Add(new Models.ElasticSearch.BrandControlLabels.BrandUpdate() { index = new Models.ElasticSearch.BrandControlLabels.RootData() { _id = row.GetString("ControlLabel"), data = new Models.ElasticSearch.BrandControlLabels.BrandData() { BrandControlLabel = row.GetString("ControlLabel"), ExtendedDescription = row.GetString("ExtendedDescription") } } }); } _elasticSearchRepository.Create(string.Concat(brands.Select(c => c.ToJson()))); TimeSpan took = DateTime.Now - start; _eventLog.WriteInformationLog(String.Format("ETL: Import Process Finished: house brands to ES. Process took {0}", took.ToString())); } catch (Exception e) { _eventLog.WriteErrorLog(String.Format("ETL: Error importing house brands -- whole process failed. {0} -- {1}", e.Message, e.StackTrace)); KeithLink.Common.Impl.Email.ExceptionEmail.Send(e, "ETL: Error importing house brands -- whole process failed."); } }