示例#1
0
        private static bool SaveNewRTToDB(string RTNew)
        {
            int saveDetails = 0;

            try
            {
                using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
                {
                    context.Relations.Add(new Relation {
                        RelationName = RTNew
                    });
                    saveDetails = context.SaveChanges();
                }

                if (saveDetails >= 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#2
0
        public static bool SaveTopic(string topic)
        {
            int count = 0;

            try
            {
                using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
                {
                    context.Topics.Add(new Topic {
                        TopicsName = topic
                    });
                    count = context.SaveChanges();
                }

                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#3
0
        private static bool SaveNewC2ToDB(string c2NewVal)
        {
            int count = 0;

            try
            {
                using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
                {
                    context.ConceptTwoes.Add(new ConceptTwo {
                        ConceptTwoName = c2NewVal
                    });
                    count = context.SaveChanges();
                }

                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            catch (Exception ex) { return(false); }
        }
示例#4
0
        public static List <ConceptOneEOModel> GetNewConceptOne(string newVal, string newType, string newProperty)
        {
            using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
            {
                context.ConceptOnes.Add(new ConceptOne {
                    ConceptOneName = newVal
                });
            }


            //var client = new GraphClient(new Uri("http://localhost:11002/db/data"), "neo4j", "mohammed123805")
            //{
            //    JsonContractResolver = new CamelCasePropertyNamesContractResolver()
            //};

            //client.Connect();

            //var conceptOne = new ConceptOne1 { Name = newVal, description = newProperty };
            //client.Cypher
            //    .Create("(conceptone:ConceptOne {conceptB})")
            //    .WithParam("conceptB", conceptOne)
            //    .ExecuteWithoutResultsAsync()
            //    .Wait();



            if (SaveNewC1ToDB(newVal))
            {
                return(GetAllConceptOne(null));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        public static bool DeleteTopic(int topicId)
        {
            int count = 0;

            try
            {
                using (var context = new ConceptsRelationDBEntities())
                {
                    List <SaveAllCR> _allCRsForFilter = context.SaveAllCRs.Where(tp => tp.Id == topicId).ToList <SaveAllCR>();
                    foreach (SaveAllCR cr in _allCRsForFilter)
                    {
                        context.SaveAllCRs.Remove(cr);
                    }
                    count = context.SaveChanges();
                }

                if (count > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (var context = new ConceptsRelationDBEntities())
     {
         grdvTopics.DataSource = context.Topics.ToList <Topic>();
         grdvTopics.DataBind();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            List <SaveAllCR> saveAllCRList = new List <SaveAllCR>();
            SaveAllCR        saveAllCR     = new SaveAllCR();

            Relation   relation      = new Relation();
            ConceptOne c1Details     = new ConceptOne();
            ConceptTwo c2Details     = new ConceptTwo();
            Topic      topicDBEntity = new Topic();

            List <string> lstTopicName = new List <string>();

            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

            try
            {
                using (var context = new ConceptsRelationDBEntities())
                {
                    //saveAllCRList = context.SaveAllCRs.ToList<SaveAllCR>().Distinct();
                    lstTopicName = context.SaveAllCRs.Select(scr => scr.Topic.TopicsName).Distinct().ToList <string>();
                    //var result = EFContext.TestAddresses.Select(m => m.Name).Distinct();

                    //foreach (SaveAllCR cr in saveAllCRList)
                    foreach (string cr in lstTopicName)
                    {
                        topicDetailsEOList.Add(new TopicDetailsEOModel
                        {
                            //TopicDetailsId = cr.Id,
                            //ConceptOne = cr.ConceptOne.ConceptOneName,
                            //ConceptTwo = cr.ConceptTwo.ConceptTwoName,
                            //RelationType = cr.Relation.RelationName,
                            //TopicName = cr.Topic.TopicsName
                            TopicName = cr
                        });
                    }
                }

                //topicDetailsEOList.Select(x => x.TopicDetailsId).Distinct();
                //topicDetailsEOList.Select(x => x.TopicDetailsId=5);

                grdvTopics.DataSource = topicDetailsEOList;
                grdvTopics.DataBind();
                //  return topicDetailsEOList;
            }
            catch (Exception ex)
            {
                throw ex;
            }



            //using (var context = new ConceptsRelationDBEntities())
            //{

            //    grdvTopics.DataSource = context.MasterConceptRelations.ToList<MasterConceptRelation>();
            //    grdvTopics.DataBind();
            //}
        }
示例#8
0
        public static List <TopicDetailsEOModel> GetAllDetailsForTopic(string topic)
        {
            int count = 0;
            List <SaveAllCR> saveAllCRList = new List <SaveAllCR>();
            //SaveAllCR saveAllCR = new SaveAllCR();

            //Relation relation = new Relation();
            //ConceptOne c1Details = new ConceptOne();
            //ConceptTwo c2Details = new ConceptTwo();
            //Topic topicDBEntity = new Topic();

            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

            try
            {
                using (var context = new ConceptsRelationDBEntities())
                {
                    saveAllCRList = context.SaveAllCRs.Where(tp => tp.Topic.TopicsName == topic).ToList <SaveAllCR>();

                    foreach (SaveAllCR cr in saveAllCRList)
                    {
                        TopicDetailsEOModel tdEoModel = new TopicDetailsEOModel();
                        tdEoModel.TopicDetailsId = cr.Id;
                        tdEoModel.ConceptOne     = cr.ConceptOne.ConceptOneName;
                        tdEoModel.ConceptTwo     = cr.ConceptOne1.ConceptOneName;
                        tdEoModel.RelationType   = cr.Relation.RelationName;
                        tdEoModel.TopicName      = cr.Topic.TopicsName;

                        topicDetailsEOList.Add(tdEoModel);

                        //topicDetailsEOList.Add(new TopicDetailsEOModel
                        //{
                        //    TopicDetailsId = cr.Id,
                        //    ConceptOne = cr.ConceptOne.ConceptOneName,
                        //    //ConceptTwo = cr.ConceptTwo.ConceptTwoName,
                        //    ConceptTwo = cr.ConceptOne.ConceptOneName,
                        //    RelationType = cr.Relation.RelationName,
                        //    TopicName = cr.Topic.TopicsName
                        //});
                    }
                }

                return(topicDetailsEOList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
            //{
            //    //GetAllItems();
            //}

            string topicName = Request.QueryString["TopicName"];

            //topic = topicName;

            using (var context = new ConceptsRelationDBEntities())
            {
                //grdvConceptRelation.DataSource = context.MasterConceptRelations.Where(c => c.TopicID == id).ToList<MasterConceptRelation>();
                //grdvConceptRelation.DataBind();
            }
        }
示例#10
0
        public static List <RelationsEOModel> GetAllRelations(string rtVal)
        {
            List <RelationsEOModel> relEO = new List <RelationsEOModel>();

            using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
            {
                List <Relation> lstRelations = new List <Relation>();
                lstRelations = context.Relations.ToList();
                foreach (Relation r in lstRelations)
                {
                    relEO.Add(new RelationsEOModel {
                        id = r.RelID, text = r.RelationName
                    });
                }
            }

            return(relEO);
        }
示例#11
0
        //[WebMethod]
        //public static List<ConceptOneEOModel> GetNewConceptOne(string val)
        //{
        //    if (SaveNewC1ToDB(val))
        //    {
        //        return GetAllConceptOne(null);
        //    }

        //    else { return null; }

        //}

        private static bool SaveNewC1ToDB(string c1NewVal)
        {
            int count = 0;

            try
            {
                using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
                {
                    context.ConceptOnes.Add(new ConceptOne {
                        ConceptOneName = c1NewVal
                    });
                    count = context.SaveChanges();
                }

                if (count > 0)
                {
                    var client = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "ismail123")
                    {
                        JsonContractResolver = new CamelCasePropertyNamesContractResolver()
                    };

                    client.Connect();

                    var conceptOne = new ConceptOne1 {
                        Name = c1NewVal
                    };
                    client.Cypher
                    .Create("(conceptone:ConceptOne {conceptB})")
                    .WithParam("conceptB", conceptOne)
                    .ExecuteWithoutResultsAsync()
                    .Wait();



                    return(true);
                }
                else
                {
                    return(false);
                }
            }

            catch (Exception es) { return(false); }
        }
示例#12
0
        public static List <ConceptTwoEOModel> GetAllConceptTwo(string c2Val)
        {
            List <ConceptTwoEOModel> relEO = new List <ConceptTwoEOModel>();

            using (ConceptsRelationDBEntities context = new ConceptsRelationDBEntities())
            {
                List <ConceptTwo> lstRelations = new List <ConceptTwo>();
                lstRelations = context.ConceptTwoes.ToList();
                foreach (ConceptTwo r in lstRelations)
                {
                    relEO.Add(new ConceptTwoEOModel {
                        id = r.C2Id, text = r.ConceptTwoName
                    });
                }
            }



            return(relEO);
        }
示例#13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // int tipicId = Request.QueryString["TopicID"];
            string topicName = Request.QueryString["topicName"];
            string par       = Request.QueryString["param1"];

            if (par != null)
            {
                cypher.Value = par;
            }
            //string relationType = Request.QueryString["TopicName"];
            //string conceptOne = Request.QueryString["TopicName"];
            //string conceptTwo = Request.QueryString["TopicName"];

            if (topicName != null)
            {
                int tipicId = 1;
                List <SaveAllCR> saveAllCRList = new List <SaveAllCR>();
                SaveAllCR        saveAllCR     = new SaveAllCR();

                Relation   relation      = new Relation();
                ConceptOne c1Details     = new ConceptOne();
                ConceptTwo c2Details     = new ConceptTwo();
                Topic      topicDBEntity = new Topic();

                List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

                try
                {
                    using (var context = new ConceptsRelationDBEntities())
                    {
                        saveAllCRList = context.SaveAllCRs.Where(tp => tp.Topic.TopicsName == topicName).ToList <SaveAllCR>();

                        foreach (SaveAllCR cr in saveAllCRList)
                        {
                            topicDetailsEOList.Add(new TopicDetailsEOModel
                            {
                                TopicDetailsId = cr.Id,
                                ConceptOne     = cr.ConceptOne.ConceptOneName,
                                ConceptTwo     = cr.ConceptOne1.ConceptOneName,
                                RelationType   = cr.Relation.RelationName,
                                TopicName      = cr.Topic.TopicsName
                            });
                        }
                    }

                    //var topicIdConceptRelation= topicDetailsEOList.Select(x =>  x.TopicDetailsId= tipicId).ToList();
                    List <TopicDetailsEOModel> topicConceptRelation = new List <TopicDetailsEOModel>();

                    topicConceptRelation = topicDetailsEOList;

                    int    count        = topicConceptRelation.Count();
                    int    m            = 1;
                    string allrelations = "";
                    foreach (var item in topicConceptRelation)
                    {
                        allrelations = allrelations + "MATCH p = () -[r:" + item.RelationType + "]->() RETURN p ";

                        if (count != m)
                        {
                            allrelations = allrelations + " UNION ";
                        }

                        m++;
                    }

                    cypher.Value = allrelations;
                }



                catch (Exception ex)
                {
                    throw ex;
                }
            }
            // var concepOnetList= topicDetailsEOList.Select(x => x.ConceptOne).Distinct().ToList();
            // var concepTwotList = topicDetailsEOList.Select(x => x.ConceptTwo).Distinct().ToList();
            // //  return topicDetailsEOList;



            // List<string> concepOnetList_1 = new List<string>();
            // int j = 1;
            // for (int i = 0; i < concepOnetList.Count(); i++)
            // {

            //     // topicConceptRelation.Add(new TopicDetailsEOModel() {  ConceptOne = concept1 });
            //     string concept1 = "";
            //     concept1 = concepOnetList[i].Replace(" ", String.Empty);
            //     concept1 = concept1 + j.ToString();

            //     foreach (var item in topicConceptRelation)
            //     {

            //         if (concepOnetList[i]== item.ConceptOne)
            //         {

            //             int index = topicConceptRelation.FindIndex(obj => obj.ConceptOne == concepOnetList[i]);
            //             //int index = topicConceptRelation.FindIndex(ind => ind.Equals(concepOnetList[i])); //Finds the item index

            //             //topicConceptRelation[index].ConceptOne = concept1;
            //             topicConceptRelation[index].ConceptOne = concept1;

            //         }
            //     }



            //     Label myLabel = new Label();
            //     myLabel.ID = "myLabel_" + j;

            //     myLabel.Text = "CREATE(" + concept1 + ":Album { Name:" +'"' + concepOnetList[i] +'"' + "})";
            //     PlaceHolder1.Controls.Add(myLabel);
            //     PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
            //     j++;
            // }

            // int k = concepOnetList.Count()+1;
            // for (int i = 0; i <concepTwotList.Count(); i++)
            // {
            //     string concept2 = "";
            //     concept2 = concepTwotList[i].Replace(" ", String.Empty);
            //     concept2 = concept2 + k.ToString();
            //     foreach (var item in topicConceptRelation)
            //     {

            //         if (concepTwotList[i] == item.ConceptTwo)
            //         {


            //             int index = topicConceptRelation.FindIndex(obj => obj.ConceptTwo == concepTwotList[i]);
            //             //int index = topicConceptRelation.FindIndex(ind => ind.Equals(concepOnetList[i])); //Finds the item index

            //             //topicConceptRelation[index].ConceptOne = concept1;
            //             topicConceptRelation[index].ConceptTwo = concept2;
            //         }
            //     }



            //     List<Label> testlist = new List<Label>();
            //     Label myLabel = new Label();
            //     myLabel.ID = "myLabel_" + k;

            //     myLabel.Text = "CREATE(" + concept2 + ":Album { Name:" + '"' + concepTwotList[i] + '"' + "})";
            //     testlist.Add(myLabel);
            //     PlaceHolder1.Controls.Add(myLabel);
            //     PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
            //     k++;
            // }

            //// var totalConcepts = concepOnetList.Concat(concepTwotList).ToList();


            // int r = 1;
            // List<string> relationsList = new List<string>();
            // //for (int i = 0; i < topicConceptRelation.Count(); i++)
            // foreach (var item in topicConceptRelation)
            // {
            //     string relations = "";
            //     relations = item.RelationType.Replace(" ", String.Empty);
            //     relations = relations + r.ToString();

            //     Label myLabel = new Label();
            //     myLabel.ID = "myLabel_" + j;

            //     //if(item.TopicDetailsId == tipicId )
            //     //{

            //     //var concept1 = totalConcepts.Select(x => x = item.ConceptOne);
            //     ////CREATE(a) -[r: RELEASED]->(b)
            //     myLabel.Text = "CREATE(" + item.ConceptOne + ") -[" + relations + ":" + item.RelationType + "]->(" + item.ConceptTwo + ")";
            //     PlaceHolder1.Controls.Add(myLabel);
            //     PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
            //     relationsList.Add(relations);
            //     //}
            //     r++;
            // }


            // string retDtat = "";
            // string ret = "RETURN ";
            // var concepOnetList1 = topicConceptRelation.Select(x => x.ConceptOne).Distinct().ToList();
            // var concepTwoList1 = topicConceptRelation.Select(x => x.ConceptTwo).Distinct().ToList();
            // for (int i = 0; i < concepOnetList1.Count(); i++)
            // {
            //     //foreach (var item in topicConceptRelation)
            //     //{
            //     //    if (concepOnetList[i] == item.ConceptOne)
            //     //    {


            //             retDtat = retDtat+ concepOnetList1[i] + "," ;
            //     //    }


            //     //   // j++;
            //     //}
            // }

            // for (int i = 0; i < concepTwoList1.Count(); i++)
            // {
            //     //foreach (var item in topicConceptRelation)
            //     //{
            //     //    if (concepTwotList[i] == item.ConceptTwo)
            //     //    {

            //             retDtat = retDtat + concepTwoList1[i] + ",";
            //     //    }
            //     //}
            // }

            // for (int i = 0; i < relationsList.Count(); i++)
            // {
            //     retDtat = retDtat+relationsList[i] + ",";
            // }


            //         Label retLabel = new Label();
            // retLabel.ID = "myLabel_" + j;
            // retLabel.Text = ret + retDtat;
            // PlaceHolder1.Controls.Add(retLabel);



            // for (int i = 0; i < topicDetailsEOList.Count; i++)
        }
示例#14
0
        public static List <Label> GetNeo4JQuery(string topic, int c1, int c2, int rt)
        {
            int count = 0;
            List <SaveAllCR> saveAllCRList = new List <SaveAllCR>();
            SaveAllCR        saveAllCR     = new SaveAllCR();

            Relation   relation      = new Relation();
            ConceptOne c1Details     = new ConceptOne();
            ConceptTwo c2Details     = new ConceptTwo();
            Topic      topicDBEntity = new Topic();

            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

            try
            {
                var searchCriteria = new
                {
                    topicName    = topic,
                    concept1     = c1,
                    concept2     = c2,
                    relationType = rt
                };

                var predicate = PredicateBuilder.New <SaveAllCR>();

                if (!string.IsNullOrWhiteSpace(searchCriteria.topicName.ToString()))
                {
                    predicate = predicate.And(p => p.Topic.TopicsName.Contains(searchCriteria.topicName));
                }

                //if (!string.IsNullOrWhiteSpace(searchCriteria.concept1.ToString()))
                if (searchCriteria.concept1.ToString() != "0")
                {
                    //predicate = predicate.And(p => p.ConceptOne.ConceptOneName.Contains(searchCriteria.concept1.ToString()));
                    predicate = predicate.And(p => p.ConceptOne.C1Id.ToString().Contains(searchCriteria.concept1.ToString()));
                }
                //if (!string.IsNullOrWhiteSpace(searchCriteria.concept2.ToString()))
                if (searchCriteria.concept2.ToString() != "0")
                {
                    predicate = predicate.And(p => p.ConceptTwo.C2Id.ToString().Contains(searchCriteria.concept2.ToString()));
                }
                //if (!string.IsNullOrWhiteSpace(searchCriteria.relationType.ToString()))
                if (searchCriteria.relationType.ToString() != "0")
                {
                    predicate = predicate.And(p => p.Relation.RelID.ToString().Contains(searchCriteria.relationType.ToString()));
                }
                using (var context = new ConceptsRelationDBEntities())
                {
                    saveAllCRList = context.SaveAllCRs.
                                    Where(predicate.Compile())
                                    //Where(tp => tp.Topic.TopicsName == topic)
                                    .ToList <SaveAllCR>();

                    foreach (SaveAllCR cr in saveAllCRList)
                    {
                        topicDetailsEOList.Add(new TopicDetailsEOModel
                        {
                            TopicDetailsId = cr.Id,
                            ConceptOne     = cr.ConceptOne.ConceptOneName,
                            ConceptTwo     = cr.ConceptTwo.ConceptTwoName,
                            RelationType   = cr.Relation.RelationName,
                            TopicName      = cr.Topic.TopicsName
                        });
                    }
                }


                List <TopicDetailsEOModel> topicConceptRelation = new List <TopicDetailsEOModel>();
                List <Label> PlaceHolder1 = new List <Label>();



                var concepOnetList = topicDetailsEOList.Select(x => x.ConceptOne).Distinct().ToList();
                var concepTwotList = topicDetailsEOList.Select(x => x.ConceptTwo).Distinct().ToList();
                //  return topicDetailsEOList;


                topicConceptRelation = topicDetailsEOList;


                List <string> concepOnetList_1 = new List <string>();
                int           j = 1;
                for (int i = 0; i < concepOnetList.Count(); i++)
                {
                    // topicConceptRelation.Add(new TopicDetailsEOModel() {  ConceptOne = concept1 });
                    string concept1 = "";
                    concept1 = concepOnetList[i].Replace(" ", String.Empty);
                    concept1 = concept1 + j.ToString();

                    foreach (var item in topicConceptRelation)
                    {
                        if (concepOnetList[i] == item.ConceptOne)
                        {
                            int index = topicConceptRelation.FindIndex(obj => obj.ConceptOne == concepOnetList[i]);
                            //int index = topicConceptRelation.FindIndex(ind => ind.Equals(concepOnetList[i])); //Finds the item index

                            //topicConceptRelation[index].ConceptOne = concept1;
                            topicConceptRelation[index].ConceptOne = concept1;
                        }
                    }



                    Label myLabel = new Label();
                    myLabel.ID = "myLabel_" + j;

                    myLabel.Text = "CREATE(" + concept1 + ":Album { Name:" + '"' + concepOnetList[i] + '"' + "})";
                    PlaceHolder1.Add(myLabel);
                    //PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
                    j++;
                }

                int k = concepOnetList.Count() + 1;
                for (int i = 0; i < concepTwotList.Count(); i++)
                {
                    string concept2 = "";
                    concept2 = concepTwotList[i].Replace(" ", String.Empty);
                    concept2 = concept2 + k.ToString();
                    foreach (var item in topicConceptRelation)
                    {
                        if (concepTwotList[i] == item.ConceptTwo)
                        {
                            int index = topicConceptRelation.FindIndex(obj => obj.ConceptTwo == concepTwotList[i]);
                            //int index = topicConceptRelation.FindIndex(ind => ind.Equals(concepOnetList[i])); //Finds the item index

                            //topicConceptRelation[index].ConceptOne = concept1;
                            topicConceptRelation[index].ConceptTwo = concept2;
                        }
                    }



                    List <Label> testlist = new List <Label>();
                    Label        myLabel  = new Label();
                    myLabel.ID = "myLabel_" + k;

                    myLabel.Text = "CREATE(" + concept2 + ":Album { Name:" + '"' + concepTwotList[i] + '"' + "})";
                    testlist.Add(myLabel);
                    PlaceHolder1.Add(myLabel);
                    // PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
                    k++;
                }

                // var totalConcepts = concepOnetList.Concat(concepTwotList).ToList();


                int           r             = 1;
                List <string> relationsList = new List <string>();
                //for (int i = 0; i < topicConceptRelation.Count(); i++)
                foreach (var item in topicConceptRelation)
                {
                    string relations = "";
                    relations = item.RelationType.Replace(" ", String.Empty);
                    relations = relations + r.ToString();

                    Label myLabel = new Label();
                    myLabel.ID = "myLabel_" + j;

                    //if(item.TopicDetailsId == tipicId )
                    //{

                    //var concept1 = totalConcepts.Select(x => x = item.ConceptOne);
                    ////CREATE(a) -[r: RELEASED]->(b)
                    myLabel.Text = "CREATE(" + item.ConceptOne + ") -[" + relations + ":" + item.RelationType + "]->(" + item.ConceptTwo + ")";
                    PlaceHolder1.Add(myLabel);
                    // PlaceHolder1.Controls.Add(new LiteralControl("<br/>"));
                    relationsList.Add(relations);
                    //}
                    r++;
                }


                string retDtat         = "";
                string ret             = "RETURN ";
                var    concepOnetList1 = topicConceptRelation.Select(x => x.ConceptOne).Distinct().ToList();
                var    concepTwoList1  = topicConceptRelation.Select(x => x.ConceptTwo).Distinct().ToList();
                for (int i = 0; i < concepOnetList1.Count(); i++)
                {
                    //foreach (var item in topicConceptRelation)
                    //{
                    //    if (concepOnetList[i] == item.ConceptOne)
                    //    {


                    retDtat = retDtat + concepOnetList1[i] + ",";
                    //    }


                    //   // j++;
                    //}
                }

                for (int i = 0; i < concepTwoList1.Count(); i++)
                {
                    //foreach (var item in topicConceptRelation)
                    //{
                    //    if (concepTwotList[i] == item.ConceptTwo)
                    //    {

                    retDtat = retDtat + concepTwoList1[i] + ",";
                    //    }
                    //}
                }

                for (int i = 0; i < relationsList.Count(); i++)
                {
                    retDtat = retDtat + relationsList[i] + ",";
                }


                Label retLabel = new Label();
                retLabel.ID   = "myLabel_" + j;
                retLabel.Text = ret + retDtat;
                PlaceHolder1.Add(retLabel);



                return(PlaceHolder1);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#15
0
        public static bool SaveAllDetails(string topic, int rtVal, int c1Val, int c2Val, bool isEdit, int editTopicId)
        {
            int                        count              = 0;
            Topic                      topicDBEntity      = new Topic();
            List <SaveAllCR>           saveAllCRList      = new List <SaveAllCR>();
            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

            try
            {
                using (var context = new ConceptsRelationDBEntities())
                {
                    topicDBEntity = context.Topics.Where(tp => tp.TopicsName == topic).FirstOrDefault();

                    if (!isEdit && editTopicId == 0)
                    {
                        //Save new record
                        context.SaveAllCRs.Add(
                            new SaveAllCR
                        {
                            fTopicId = topicDBEntity.TopicID,
                            fRId     = rtVal,
                            fC1Id    = c1Val,
                            fC2Id    = c2Val
                        });
                    }
                    else
                    {
                        // Update Existing record
                        //var result = context.SaveAllCRs.SingleOrDefault(tp => tp.Topic.TopicsName == topic &&
                        //                                                    tp.fC1Id == c1Val &&
                        //                                                    tp.fC1Id == c2Val &&
                        //                                                    tp.fRId == rtVal
                        //                                                    );
                        var result = context.SaveAllCRs.SingleOrDefault(tp => tp.Id == editTopicId);
                        if (result != null)
                        {
                            result.fC1Id = c1Val;
                            result.fC2Id = c2Val;
                            result.fRId  = rtVal;
                        }
                    }
                    count = context.SaveChanges();
                }

                if (count > 0)
                {
                    using (var context = new ConceptsRelationDBEntities())
                    {
                        //Home1 hm1 = new Home1();
                        //hm1.grdvConceptRelation.DataSource = context.MasterConceptRelations.Where(c => c.TopicName == "Topic 2").ToList<MasterConceptRelation>();
                        //hm1.grdvConceptRelation.DataBind();
                    }



                    using (var context = new ConceptsRelationDBEntities())
                    {
                        saveAllCRList = context.SaveAllCRs.Where(tp => tp.Topic.TopicsName == topic && tp.Relation.RelID == rtVal && tp.ConceptOne.C1Id == c1Val && tp.ConceptTwo.C2Id == c2Val).ToList <SaveAllCR>();

                        foreach (SaveAllCR cr in saveAllCRList)
                        {
                            TopicDetailsEOModel tdEoModel = new TopicDetailsEOModel();
                            tdEoModel.TopicDetailsId = cr.Id;
                            tdEoModel.ConceptOne     = cr.ConceptOne.ConceptOneName;
                            tdEoModel.ConceptTwo     = cr.ConceptOne1.ConceptOneName;
                            tdEoModel.RelationType   = cr.Relation.RelationName;
                            tdEoModel.TopicName      = cr.Topic.TopicsName;

                            topicDetailsEOList.Add(tdEoModel);

                            //topicDetailsEOList.Add(new TopicDetailsEOModel
                            //{
                            //    TopicDetailsId = cr.Id,
                            //    ConceptOne = cr.ConceptOne.ConceptOneName,
                            //    ConceptTwo = cr.ConceptTwo.ConceptTwoName,
                            //    RelationType = cr.Relation.RelationName,
                            //    TopicName = cr.Topic.TopicsName
                            //});
                        }
                    }

                    var client = new GraphClient(new Uri("http://localhost:7474/db/data"), "neo4j", "ismail123")
                    {
                        JsonContractResolver = new CamelCasePropertyNamesContractResolver()
                    };

                    client.Connect();
                    List <string> con1list = topicDetailsEOList.Select(X => X.ConceptOne).Distinct().ToList();
                    string        concept1 = string.Join(",", con1list);
                    List <string> con2list = topicDetailsEOList.Select(X => X.ConceptTwo).Distinct().ToList();
                    string        concept2 = string.Join(",", con2list);
                    List <string> rellist  = topicDetailsEOList.Select(X => X.RelationType).Distinct().ToList();
                    string        relation = string.Join(",", rellist);
                    string        rel      = "(conceptone1)-[:" + relation + "]->(conceptone2)";

                    client.Cypher
                    .Match("(conceptone1:ConceptOne)", "(conceptone2:ConceptOne)")
                    .Where((ConceptOne1 conceptone1) => conceptone1.Name == concept1)
                    .AndWhere((ConceptOne1 conceptone2) => conceptone2.Name == concept2)
                    .Create(rel)
                    .ExecuteWithoutResultsAsync()
                    .Wait();

                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
示例#16
0
        public static List <TopicDetailsEOModel> Search(string topic, int c1, int c2, int rt)
        //public static List<TopicDetailsEOModel> Search(string topic, string c1, string c2, string rt)
        {
            int count = 0;
            List <SaveAllCR> saveAllCRList  = new List <SaveAllCR>();
            List <SaveAllCR> saveAllCRList1 = new List <SaveAllCR>();
            SaveAllCR        saveAllCR      = new SaveAllCR();

            Relation   relation      = new Relation();
            ConceptOne c1Details     = new ConceptOne();
            ConceptTwo c2Details     = new ConceptTwo();
            Topic      topicDBEntity = new Topic();


            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();



            try
            {
                // Commenting below line from 348 - 373, to check if Predicate logic, which is below 373 line works or not.

                using (var context = new ConceptsRelationDBEntities())
                {
                    saveAllCRList = context.SaveAllCRs.Where(tp => tp.Topic.TopicsName == topic).ToList <SaveAllCR>();


                    foreach (var item in saveAllCRList)
                    {
                        //
                        // The below logic is wrong, it has to be AND but if and only if the
                        // values are not 0, if any either c1, c2, rt is 0, then neglect that in the filter, for which item.fkId == 0 with OR condition
                        //if (item.fC1Id == c1 || item.fC1Id == c2 || item.fRId == rt)
                        if ((item.fC1Id == c1 || c1 == 0) &&
                            (item.fC2Id == c2 || c2 == 0) &&
                            (item.fRId == rt || rt == 0))
                        {
                            saveAllCRList1.Add(item);
                        }
                    }


                    foreach (SaveAllCR cr in saveAllCRList1)
                    {
                        topicDetailsEOList.Add(new TopicDetailsEOModel
                        {
                            TopicDetailsId = cr.Id,
                            ConceptOne     = cr.ConceptOne.ConceptOneName,
                            ConceptTwo     = cr.ConceptOne1.ConceptOneName,
                            RelationType   = cr.Relation.RelationName,
                            TopicName      = cr.Topic.TopicsName
                        });
                    }
                }



                //// 21 May 2019:  Predicate was not working thats why commented.
                //var searchCriteria = new
                //{
                //    topicName = topic,
                //    concept1 = c1,
                //    concept2 = c2,
                //    relationType = rt
                //};

                //var predicate = PredicateBuilder.New<SaveAllCR>();

                //if (!string.IsNullOrWhiteSpace(searchCriteria.topicName.ToString()))
                //{
                //    predicate = predicate.And(p => p.Topic.TopicsName.Contains(searchCriteria.topicName));
                //}

                ////if (!string.IsNullOrWhiteSpace(searchCriteria.concept1.ToString()))
                //if (searchCriteria.concept1.ToString() != "0")
                //{
                //    //predicate = predicate.And(p => p.ConceptOne.ConceptOneName.Contains(searchCriteria.concept1.ToString()));
                //    //predicate = predicate.And(p => p.ConceptOne.C1Id.ToString().Contains(searchCriteria.concept1.ToString()));
                //    predicate = predicate.And(p => p.ConceptOne.C1Id.ToString().Contains(searchCriteria.concept1.ToString()));
                //}
                ////if (!string.IsNullOrWhiteSpace(searchCriteria.concept2.ToString()))
                //if (searchCriteria.concept2.ToString() != "0")
                //{
                //    predicate = predicate.And(p => p.ConceptTwo.C2Id.ToString().Contains(searchCriteria.concept2.ToString()));
                //}
                ////if (!string.IsNullOrWhiteSpace(searchCriteria.relationType.ToString()))
                //if (searchCriteria.relationType.ToString() != "0")
                //{
                //    predicate = predicate.And(p => p.Relation.RelID.ToString().Contains(searchCriteria.relationType.ToString()));
                //}
                //using (var context = new ConceptsRelationDBEntities())
                //{
                //    saveAllCRList = context.SaveAllCRs.
                //        Where(predicate.Compile())
                //        //Where(tp => tp.Topic.TopicsName == topic)
                //        .ToList<SaveAllCR>();

                //    foreach (SaveAllCR cr in saveAllCRList)
                //    {

                //        topicDetailsEOList.Add(new TopicDetailsEOModel
                //        {
                //            TopicDetailsId = cr.Id,
                //            ConceptOne = cr.ConceptOne.ConceptOneName,
                //            ConceptTwo = cr.ConceptTwo.ConceptTwoName,
                //            RelationType = cr.Relation.RelationName,
                //            TopicName = cr.Topic.TopicsName
                //        });
                //    }
                //}



                return(topicDetailsEOList);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
示例#17
0
        public static List <Label> GetNeo4JQuery(string topic, int c1, int c2, int rt)
        {
            int count = 0;
            List <SaveAllCR> saveAllCRList  = new List <SaveAllCR>();
            List <SaveAllCR> saveAllCRList1 = new List <SaveAllCR>();
            SaveAllCR        saveAllCR      = new SaveAllCR();

            Relation   relation      = new Relation();
            ConceptOne c1Details     = new ConceptOne();
            ConceptTwo c2Details     = new ConceptTwo();
            Topic      topicDBEntity = new Topic();

            List <TopicDetailsEOModel> topicDetailsEOList = new List <TopicDetailsEOModel>();

            try
            {
                //var searchCriteria = new
                //{
                //    topicName = topic,
                //    concept1 = c1,
                //    concept2 = c2,
                //    relationType = rt
                //};

                //var predicate = PredicateBuilder.New<SaveAllCR>();

                //if (!string.IsNullOrWhiteSpace(searchCriteria.topicName.ToString()))
                //{
                //    predicate = predicate.And(p => p.Topic.TopicsName.Contains(searchCriteria.topicName));
                //}

                ////if (!string.IsNullOrWhiteSpace(searchCriteria.concept1.ToString()))
                //if (searchCriteria.concept1.ToString() != "0")
                //{
                //    //predicate = predicate.And(p => p.ConceptOne.ConceptOneName.Contains(searchCriteria.concept1.ToString()));
                //    predicate = predicate.And(p => p.ConceptOne.C1Id.ToString().Contains(searchCriteria.concept1.ToString()));
                //}
                ////if (!string.IsNullOrWhiteSpace(searchCriteria.concept2.ToString()))
                //if (searchCriteria.concept2.ToString() != "0")
                //{
                //    predicate = predicate.And(p => p.ConceptTwo.C2Id.ToString().Contains(searchCriteria.concept2.ToString()));
                //}
                ////if (!string.IsNullOrWhiteSpace(searchCriteria.relationType.ToString()))
                //if (searchCriteria.relationType.ToString() != "0")
                //{
                //    predicate = predicate.And(p => p.Relation.RelID.ToString().Contains(searchCriteria.relationType.ToString()));
                //}
                //using (var context = new ConceptsRelationDBEntities())
                //{
                //    saveAllCRList = context.SaveAllCRs.
                //        Where(predicate.Compile())
                //        //Where(tp => tp.Topic.TopicsName == topic)
                //        .ToList<SaveAllCR>();

                //    foreach (SaveAllCR cr in saveAllCRList)
                //    {

                //        topicDetailsEOList.Add(new TopicDetailsEOModel
                //        {
                //            TopicDetailsId = cr.Id,
                //            ConceptOne = cr.ConceptOne.ConceptOneName,
                //            ConceptTwo = cr.ConceptTwo.ConceptTwoName,
                //            RelationType = cr.Relation.RelationName,
                //            TopicName = cr.Topic.TopicsName
                //        });
                //    }
                //}


                using (var context = new ConceptsRelationDBEntities())
                {
                    saveAllCRList = context.SaveAllCRs.Where(tp => tp.Topic.TopicsName == topic).ToList <SaveAllCR>();


                    foreach (var item in saveAllCRList)
                    {
                        if (item.fC1Id == c1 || item.fC1Id == c2 || item.fRId == rt)
                        {
                            saveAllCRList1.Add(item);
                        }
                    }


                    foreach (SaveAllCR cr in saveAllCRList1)
                    {
                        topicDetailsEOList.Add(new TopicDetailsEOModel
                        {
                            TopicDetailsId = cr.Id,
                            ConceptOne     = cr.ConceptOne.ConceptOneName,
                            ConceptTwo     = cr.ConceptOne1.ConceptOneName,
                            RelationType   = cr.Relation.RelationName,
                            TopicName      = cr.Topic.TopicsName
                        });
                    }
                }



                List <TopicDetailsEOModel> topicConceptRelation = new List <TopicDetailsEOModel>();

                topicConceptRelation = topicDetailsEOList;

                int    count1       = topicConceptRelation.Count();
                int    n            = 1;
                string allrelations = "";
                foreach (var item in topicConceptRelation)
                {
                    allrelations = allrelations + " MATCH p = (a: ConceptOne) -[r:" + item.RelationType + "]->(b: ConceptTwo) WHERE a.name =" + '"' + item.ConceptOne + '"' + "AND b.name = " + '"' + item.ConceptTwo + '"' + "RETURN p ";

                    if (count1 != n)
                    {
                        allrelations = allrelations + " UNION ";
                    }

                    n++;
                }

                // cypher.Value = allrelations;

                List <Label> PlaceHolder1 = new List <Label>();
                Label        lbl          = new Label();
                lbl.Text = allrelations;
                PlaceHolder1.Add(lbl);

                return(PlaceHolder1);
            }

            catch (Exception ex)
            {
                return(null);
            }
        }