public void Save() { try { ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString); if (this.ID == -1) { tbl_RuleClassify item = new tbl_RuleClassify(); UpdateEntity(item); item.Status = true; context.tbl_RuleClassifies.InsertOnSubmit(item); context.SubmitChanges(); this.ID = item.record_id; } else { var query = from entity in context.tbl_RuleClassifies where entity.record_id == this.ID select entity; foreach (var item in query) { UpdateEntity(item); } context.SubmitChanges(); } } catch (Exception ex) { Utilities.SolrException.WriteError(ex); } }
public bool SaveInDB() { try { ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString); if (this.ID == -1) { tbl_Schema item = new tbl_Schema(); UpdateEntity(item); item.Status = "New"; context.tbl_Schemas.InsertOnSubmit(item); context.SubmitChanges(); this.ID = item.record_id; } else { var query = from entity in context.tbl_Schemas where entity.record_id == this.ID select entity; foreach (var item in query) { UpdateEntity(item); } context.SubmitChanges(); } return(true); } catch (Exception ex) { Solr.Utilities.SolrException.WriteError(ex); } return(false); }
public bool Delete() { try { ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString); var query = from entity in context.tbl_Rules where entity.record_id == this.ID select entity; foreach (var item in query) { item.Status = false; } context.SubmitChanges(); return(true); } catch (Exception ex) { Solr.Utilities.SolrException.WriteError(ex); } return(false); }
public bool UpdateDBLucene() { try { List <ItemIngested> itemIngesteds = new List <ItemIngested>(); string resultJSON = Search.Select(this.RuleToClassify.QueryString, this.RuleToClassify.Rows?.ToString(), this.RuleToClassify.Sort, this.RuleToClassify.Start?.ToString(), this.RuleToClassify.Fields); JObject jsonObject = JObject.Parse(resultJSON); var resultValues = jsonObject["response"]["docs"]; foreach (var resultValue in resultValues) { string id = resultValue["id"].Value <string>(); JObject dbValue = new JObject(); ItemIngested itemIngested = new ItemIngested(); itemIngested.ID = -1; itemIngested.FileID = id; itemIngested.Value = string.Empty; foreach (var classifyField in this.RuleToClassify.ClassifyFields) { if (classifyField.SchemaName.StartsWith("DB_")) { dbValue.Add(classifyField.SchemaName, classifyField.Value); } else if (classifyField.SchemaName.StartsWith("LU_")) { UpdateLuceneItem(id, classifyField.SchemaName, classifyField.Value); } else { UpdateLuceneItem(id, classifyField.SchemaName, classifyField.Value); dbValue.Add(classifyField.SchemaName, classifyField.Value); } } itemIngested.Value = dbValue.ToString(); itemIngesteds.Add(itemIngested); } CommitLucene(); ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString); // See if we need to update DB var query = from entity1 in itemIngesteds join entity2 in context.tbl_ItemIngesteds on entity1.FileID equals entity2.FileID into newTable from entity3 in newTable.DefaultIfEmpty() select new { entity1, entity3 }; foreach (var item in query) { if (item.entity3 == null) { tbl_ItemIngested newItem = new tbl_ItemIngested(); newItem.FileID = item.entity1.FileID; newItem.Value = item.entity1.Value; newItem.Status = true; newItem.ModifiedBy = "jllorin"; newItem.ModifiedDate = DateTime.Now; context.tbl_ItemIngesteds.InsertOnSubmit(newItem); } else { item.entity3.Value = item.entity1.Value; } } context.SubmitChanges(); return(true); } catch (Exception ex) { Utilities.SolrException.WriteError(ex); } return(false); }