Beispiel #1
0
 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 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);
     }
 }
Beispiel #3
0
 public static Rule Get(int id)
 {
     try
     {
         if (id == -1)
         {
             return(new Rule(-1, "[New Rule]", false, true, false, "*.*", string.Empty, string.Empty, null, null));
         }
         else
         {
             ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
             var query = from entity in context.tbl_Rules
                         where entity.record_id == id
                         select entity;
             foreach (var item in query)
             {
                 return(new Rule(item.record_id, item.RuleName, item.IsQueryShow, item.IsClassifyShow, item.IsSimilarityShow, item.QueryString, item.Sort, item.Fields,
                                 item.Start, item.Rows));
             }
         }
     }
     catch (Exception ex)
     {
         Utilities.SolrException.WriteError(ex);
     }
     return(null);
 }
Beispiel #4
0
 public static Schema Get(int id)
 {
     try
     {
         ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
         var query = from entity in context.tbl_Schemas
                     where entity.record_id == id
                     select entity;
         foreach (var item in query)
         {
             return(new Schema(item.record_id, item.Name, item.Description, item.Type, item.Stored, item.Indexed, item.DefaultValue));
         }
     }
     catch (Exception ex)
     {
         Solr.Utilities.SolrException.WriteError(ex);
     }
     return(null);
 }
        public static List <ItemIngested> Get()
        {
            List <ItemIngested> items = new List <ItemIngested>();

            try
            {
                ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
                var query = from entity in context.tbl_ItemIngesteds
                            where entity.Status == true
                            select entity;
                foreach (var item in query)
                {
                    items.Add(new ItemIngested(item.record_id, item.FileID, item.Value));
                }
            }
            catch (Exception ex)
            {
                Utilities.SolrException.WriteError(ex);
            }
            return(items);
        }
Beispiel #6
0
 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 static List <RuleClassify> Get()
        {
            List <RuleClassify> attributes = new List <RuleClassify>();

            try
            {
                ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
                var query = from entity1 in context.tbl_RuleClassifies
                            join entity2 in context.tbl_Schemas
                            on entity1.SchemaID_fk equals entity2.record_id
                            where entity1.Status == true && string.Compare(entity2.Status, "Deleted", true) != 0
                            select new { entity1.record_id, entity1.RuleID_fk, entity1.SchemaID_fk, entity1.Value, entity2.Name };
                foreach (var item in query)
                {
                    attributes.Add(new RuleClassify(item.record_id, item.RuleID_fk, item.SchemaID_fk, item.Name, item.Value, false));
                }
            }
            catch (Exception ex)
            {
                Utilities.SolrException.WriteError(ex);
            }
            return(attributes);
        }
Beispiel #8
0
        public static List <Schema> Get()
        {
            List <Schema> schemaFields = new List <Schema>();

            try
            {
                ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
                var query = from entity in context.tbl_Schemas
                            where string.Compare(entity.Status, "Deleted", true) != 0
                            orderby entity.Name
                            select entity;
                foreach (var item in query)
                {
                    var schema = new Schema(item.record_id, item.Name, item.Description, item.Type, item.Stored, item.Indexed, item.DefaultValue);
                    schemaFields.Add(schema);
                }
            }
            catch (Exception ex)
            {
                Solr.Utilities.SolrException.WriteError(ex);
            }
            return(schemaFields);
        }
Beispiel #9
0
        public static List <Rule> Get()
        {
            List <Rule> rules = new List <Rule>();

            try
            {
                ClassificationDataContext context = new ClassificationDataContext(System.Configuration.ConfigurationManager.ConnectionStrings["ClassificationConnectionStringProd"].ConnectionString);
                var query = from entity in context.tbl_Rules
                            where entity.Status == true
                            orderby entity.RuleName
                            select entity;
                foreach (var item in query)
                {
                    rules.Add(new Rule(item.record_id, item.RuleName, item.IsQueryShow, item.IsClassifyShow, item.IsSimilarityShow, item.QueryString, item.Sort, item.Fields,
                                       item.Start, item.Rows));
                }

                var ruleClassifyList = RuleClassify.Get()
                                       .GroupBy(u => u.RuleIDFk)
                                       .Select(grp => new { RuleIDFk = grp.Key, classifyList = grp.ToList() })
                                       .ToList();

                var joinQuery = from entity1 in rules
                                join entity2 in ruleClassifyList
                                on entity1.ID equals entity2.RuleIDFk
                                select new { entity1, entity2 };
                foreach (var item in joinQuery)
                {
                    item.entity1.ClassifyFields = item.entity2.classifyList;
                }
            }
            catch (Exception ex)
            {
                Utilities.SolrException.WriteError(ex);
            }
            return(rules);
        }
Beispiel #10
0
        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);
        }