Esempio n. 1
0
        public D3MindMapData()
        {
            Dictionary <string, int> Statistics = new Dictionary <string, int>();

            d3Root.name     = "";
            d3Root.children = new List <D3Model>();
            d3Root.id       = count;
            d3Root.depth    = 0;
            D3Model parent = d3Root;

            foreach (var category in Statistics)
            {
                D3Model d3ChildCat = new D3Model();
                d3ChildCat.name = category.Key;
                d3ChildCat.id   = count++;
                d3Root.depth    = 1;

                if (d3ChildCat.name.Contains("name"))
                {
                    d3ChildCat._children = new List <children>();
                    d3Root.depth++;
                    d3ChildCat._children.Add(new children("TESTING " + d3ChildCat.name, "aaddafd"));
                }
                d3Root.parent = parent;
                d3Root.children.Add(d3ChildCat);
            }
        }
Esempio n. 2
0
        public D3MindMapData(SearchResponse Resp, string SearchKey)
        {
            d3Root.name     = SearchKey;
            d3Root.children = new List <D3Model>();
            d3Root.id       = count++;
            d3Root.depth    = 0;
            int NoOfPost = 0;

            foreach (var category in Resp.Statistics)
            {
                D3Model d3ChildCat = new D3Model();
                d3ChildCat.name  = category.Key;
                d3ChildCat.id    = count++;
                d3ChildCat.depth = 1;
                string SentenceByWord = "";

                NoOfPost             = 0;
                d3ChildCat._children = new List <children>();

                foreach (var kvp in Resp.statisticsId)
                {
                    if (kvp.Value != null && kvp.Value.Category == category.Key)
                    {
                        string id = kvp.Key.Split(new string[] { "|" }, StringSplitOptions.None)[0];
                        var    v  = Resp.Contents
                                    .FirstOrDefault(x => x.Id == id);
                        if (v.Id != "")
                        {
                            children _child = new children();
                            _child.Desc    = v.Desc;
                            _child.Desc    = v.Desc.Replace(kvp.Value.Keyword, "<span class='post-tag'>" + kvp.Value.Keyword + "</span>");
                            SentenceByWord = GetSentencebyKeyword(v.Desc, kvp.Value.Keyword);
                            int maxlength = 500;
                            maxlength           = SentenceByWord.Length > 500 ? maxlength : SentenceByWord.Length;
                            _child.name         = SentenceByWord.Substring(0, maxlength);
                            _child.Title        = v.Title;
                            _child.ImagePath    = v.ImagePath;
                            _child.LocationArea = v.LocationArea;
                            _child.ViewCount    = v.ViewCount;
                            _child.DonorName    = v.DonorName;
                            _child.id           = count++;
                            _child.SMPID        = v.Id;
                            NoOfPost++;
                            d3ChildCat._children.Add(_child);
                        }
                    }
                }


                //IEnumerable<Content> contents = Resp.Contents.Where(x => x.Category == category.Key);
                //if (contents.Count() > 0)
                //{
                //    NoOfPost = 0;
                //    d3ChildCat._children = new List<children>();
                //    foreach (var v in contents)
                //    {
                //        if (NoOfPost > 30) continue;

                //        children _child = new children();
                //        _child.Desc = v.Desc;
                //        SentenceByWord = GetSentencebyKeyword(v.Desc,v.KeyWord);
                //        int maxlength = 500;
                //        maxlength = SentenceByWord.Length > 500 ? maxlength : SentenceByWord.Length;
                //        _child.name = SentenceByWord.Substring(0, maxlength);
                //        _child.Title = v.Title;
                //        _child.ImagePath = v.ImagePath;
                //        _child.LocationArea = v.LocationArea;
                //        _child.ViewCount = v.ViewCount;
                //        _child.DonorName = v.DonorName;
                //        _child.id = count++;
                //        _child.SMPID = v.Id;
                //        NoOfPost++;
                //        d3ChildCat._children.Add(_child);

                //    }
                //}
                d3Root.children.Add(d3ChildCat);
            }
        }