public ActionResult EditABlog(BlogVM blogVM)
        {
            BlogManager manager = BlogManagerFactory.Create();

            if (blogVM.Blog.TagInputs != null)
            {
                string[] tags = blogVM.Blog.TagInputs.Split(',');

                foreach (var tag in tags)
                {
                    var searchTag = new SearchTag()
                    {
                        SearchTagBody = tag
                    };

                    blogVM.Blog.SearchTags.Add(searchTag);
                }

                blogVM.Blog.TagInputs = null;
            }

            manager.UpdateBlog(blogVM.Blog);

            return(RedirectToAction("MyBlogs"));
        }
        public ActionResult Review(BlogVM model)
        {
            BlogManager manager = BlogManagerFactory.Create();

            if (model.Blog.TagInputs != null)
            {
                string[] tags = model.Blog.TagInputs.Split(',');

                foreach (var tag in tags)
                {
                    var searchTag = new SearchTag()
                    {
                        SearchTagBody = tag
                    };

                    model.Blog.SearchTags.Add(searchTag);
                }

                model.Blog.TagInputs = null;
            }

            manager.UpdateBlog(model.Blog);

            return(RedirectToAction("ViewPending"));
        }
Beispiel #3
0
        public Hitomi()
        {
            Queries   = new QueryCollection();
            Galleries = new MetadataCollection(Queries);

            SearchResults = new ReactiveList <string>();

            SearchTag = ReactiveCommand.CreateFromTask <string, IEnumerable <Tag> >(async _ => {
                return(await DatabaseManager.Instance.GetTags($"Content LIKE '%{SearchQuery}%'"));
            }, this.WhenAny(x => x.SearchQuery, x => !string.IsNullOrWhiteSpace(x.Value)));
            SearchTag.Subscribe(x =>
            {
                SearchResults.Clear();
                x.ToObservable().Select(o => o.Content).Subscribe(SearchResults.Add);
            });
            this.WhenAnyValue(x => x.SearchQuery)
            .Throttle(TimeSpan.FromSeconds(1), RxApp.MainThreadScheduler)
            .InvokeCommand(SearchTag);
            InitializeSetting();

            UpdateCache = ReactiveCommand.CreateFromTask(UpdateGalleryCache);

            AddTag       = ReactiveCommand.Create <string>(Queries.AddQuery);
            RemoveTag    = ReactiveCommand.CreateFromTask <Query>(Queries.RemoveQuery);
            SaveSettings = ReactiveCommand.Create(SaveSetting);
        }
Beispiel #4
0
        public TagItem ValidateAndReturn(string tag)
        {
            var _tagItem = SearchTag.ValidateAndReturn(tag);

            UpdateWeekRecords(_tagItem);

            return(_tagItem);
        }
		public static void ApplyKeywords(this IEnumerable<BaseLibraryLink> links, SearchTag[] keywords)
		{
			foreach (var libraryLink in links)
			{
				libraryLink.Tags.Keywords.Clear();
				libraryLink.Tags.Keywords.AddRange(keywords.Select(tag => new SearchTag { Name = tag.Name }));
				libraryLink.MarkAsModified();
			}
		}
Beispiel #6
0
 private void btAdd_Click(object sender, EventArgs e)
 {
     if (SelectedSwitch != null)
     {
         var search = RenderingEngine.SearchService.FindSearchDescription(SelectedSwitch.UniqueName);
         var tag    = new SearchTag("Empty");
         search?.Tags.Add(tag);
         AddEntry(tag);
     }
 }
Beispiel #7
0
 public static void TagSave(SearchTag item)
 {
     if (item != null)
     {
         //only new
         using (IDbConnection con = new SQLiteConnection(GetConnectionString()))
         {
             con.Execute("insert into SearchTag (Name) values (@Name)", item);
         }
     }
 }
        public TagItem ValidateAndReturn(string tag)
        {
            var _tagItem = SearchTag.ValidateAndReturn(tag);

            if (_tagItem != null)
            {
                UpdateWeekRecord(_tagItem);
                SendMessage("addTag", _tagItem);
            }

            return(_tagItem);
        }
Beispiel #9
0
 // --- Click on search by tag ---
 public void ClickOnRechercher()
 {
     if (SearchTag != "" && SearchTag != null)
     {
         string[] searchedTag = SearchTag.Split(' ');
         _pomodoroTaskList.filter(searchedTag);
     }
     else
     {
         _pomodoroTaskList.resetFilter();
     }
 }
Beispiel #10
0
 private void AddEntry(SearchTag s)
 {
     listMetaData.Items.Add(new ListViewItem(new[]
     {
         new ListViewItem.ListViewSubItem {
             Text = s.Tag
         },
         new ListViewItem.ListViewSubItem {
             Text = s.Description
         },
     }, 0)
     {
         Tag = s
     });
 }
Beispiel #11
0
        private void Search(string tag)
        {
            if (TagItems.Count > 7)
            {
                MessageBoxService.ShowAlert(AppResources.QueryCountExceeded, AppResources.QueryCountExceededDetail);
                return;
            }

            var _tagItem = SearchTag.ValidateAndReturn(tag);

            UpdateWeekRecords(_tagItem);

            TagItems.Add(_tagItem);

            RecordsBySearch.Remove(_tagItem.Name);
        }
        public ActionResult AddBlogPost(BlogVM model)
        {
            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(model.Blog.Title))
                {
                    ModelState.AddModelError("Title", "You must enter a title.");
                }
                else if (string.IsNullOrEmpty(model.Blog.Content))
                {
                    ModelState.AddModelError("Content", "You must enter something in the blog body.");
                }
                else
                {
                    TheCodingVineDbContext db = new TheCodingVineDbContext();


                    BlogManager manager = BlogManagerFactory.Create();

                    if (model.Blog.TagInputs != null)
                    {
                        string[] tags = model.Blog.TagInputs.Split(',');

                        foreach (var tag in tags)
                        {
                            var searchTag = new SearchTag()
                            {
                                SearchTagBody = tag
                            };
                            model.Blog.SearchTags.Add(searchTag);
                        }

                        model.Blog.TagInputs = null;
                    }

                    UserManager <AppUser> userManager = new UserManager <AppUser>(new UserStore <AppUser>(db));

                    model.Blog.BlogWriter = userManager.FindByName(User.Identity.Name);

                    manager.AddBlog(model.Blog);

                    return(RedirectToAction("MyBlogs"));
                }
            }

            return(View(model));
        }
Beispiel #13
0
    void Update()
    {
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;


        if (slotUsed == SelectionSlotManager.currentSlotSelected && Physics.Raycast(ray, out hit))
        {
            //Thread.Sleep(10);

            if (lastSelection == null && latestMateral != null)
            {
                hit.transform.gameObject.GetComponent <Renderer>().material = latestMateral;
                Debug.Log("ho rilevato un vecchio cambiamento");
            }

            if (hit.transform != lastSelection && lastSelection != null)
            {
                lastSelection.gameObject.GetComponent <Renderer>().material = lastMaterial;
                change = true;
            }

            selection = hit.transform;
            var selectionRender = selection.GetComponent <Renderer>();

            if (change)
            {
                lastMaterial = selectionRender.material;
                change       = false;
            }

            if (selectionRender != null && SearchTag.search("slz", selection.gameObject))
            {
                selectionRender.material = selectionMaterial;
            }

            lastSelection = selection;
        }
        else if (slotUsed != SelectionSlotManager.currentSlotSelected && lastSelection != null)
        {
            lastSelection.gameObject.GetComponent <Renderer>().material = lastMaterial;
            latestMateral = lastMaterial;
            lastSelection = null;
            change        = true;
        }
    }
Beispiel #14
0
        private Control GetCbOrOInputontrolFromMembers(SearchTag stag)
        {
            loading = true;
            try
            {
                //input can be here any time, regardless of childs!
                var input = GetUserInputControl(stag);
                if (input != null)
                {
                    flpReflectionMembers.Controls.Add(input);
                    return(input);
                }

                var list = SearchTagExtractor.ExtractTagsFromAttributes(stag.MyRuntimePropertyValue, stag);
                if (list.Any())
                {
                    var      ordered = (from a in list orderby a.TagName select a).ToList();
                    ComboBox cb      = new ComboBox
                    {
                        DropDownStyle = ComboBoxStyle.DropDownList,
                        FlatStyle     = FlatStyle.Standard
                    };
                    flpReflectionMembers.Controls.Add(cb);
                    cb.DataSource            = ordered;
                    cb.DisplayMember         = "TagName";
                    cb.SelectedValueChanged += (sender, e) =>
                    {
                        var tag     = cb.SelectedItem as SearchTag;
                        var childcb = GetCbOrOInputontrolFromMembers(tag);
                    };
                    return(cb);
                }

                return(null);
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }
            finally
            {
                this.loading = false;
            }

            return(null);
        }
Beispiel #15
0
        private Control GetCbOrOInputontrolFromMembers(SearchTag stag)
        {
            _loading = true;
            try
            {
                //input can be here any time, regardless of childs!
                var input = GetUserInputControl(stag);
                if (input != null)
                {
                    flpReflectionMembers.Controls.Add(input);
                    return(input);
                }

                List <SearchTag> list = new List <SearchTag>(SearchTagExtractor.ExtractTagsFromAttributes(stag.MyRuntimePropertyValue).OrderBy(x => x.TagName));
                if (list.Count > 0)
                {
                    ComboBox cb = new ComboBox
                    {
                        DropDownStyle = ComboBoxStyle.DropDownList,
                        FlatStyle     = FlatStyle.Standard
                    };
                    flpReflectionMembers.Controls.Add(cb);
                    cb.DataSource            = list;
                    cb.DisplayMember         = "TagName";
                    cb.SelectedValueChanged += (sender, e) =>
                    {
                        var tag     = cb.SelectedItem as SearchTag;
                        var childcb = GetCbOrOInputontrolFromMembers(tag);
                    };
                    return(cb);
                }

                return(null);
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }
            finally
            {
                _loading = false;
            }

            return(null);
        }
Beispiel #16
0
        private void UpdateDialog()
        {
            flpReflectionMembers.Controls.Clear();
            MySearchCharacter.MySINnerFile.SiNnerMetaData.Tags.Clear();
            MyTagTreeView.Nodes.Clear();
            TreeNode root = null;

            MySearchCharacter.PopulateTree(ref root, null, MySetTags);
            MyTagTreeView.Nodes.Add(root);
            motherTag = new SearchTag
            {
                Tags                   = new List <Tag>(),
                MyPropertyInfo         = null,
                MyRuntimePropertyValue = MySearchCharacter.MyCharacter,
                TagName                = "Root",
                TagValue               = "Search"
            };
            Control cbChar = GetCbOrOInputontrolFromMembers(motherTag);
        }
        public void TagTest1()
        {
            ISearchTag andTag = new AndTag();

            andTag.Add("上衣");

            ISearchTag orTag = new OrTag();

            orTag.Add("蓝色");
            orTag.Add("休闲");

            andTag.Add(orTag);
            ITag searchTag = new SearchTag
            {
                Tag = andTag
            };

            Assert.AreEqual("{\"and\":[\"上衣\",{\"or\":[\"蓝色\",\"休闲\"]}]}", searchTag.ToString());
        }
Beispiel #18
0
        public void AddTag(SwitchBase sw, SearchTag tag)
        {
            var swResult = Engine.FindSwitch(sw.UniqueName);

            if (swResult != null)
            {
                var key = swResult.UniqueName;
                if (SearchDescriptionAvailable(key))
                {
                    var searchDescription = FindSearchDescription(key);
                    searchDescription.Add(tag);
                }
                else
                {
                    var desc = new SearchDescription(key);
                    desc.Add(tag);
                    AddSearchDescription(desc);
                }
            }
        }
Beispiel #19
0
        public void ResetFilters(bool reset_explorers = true)
        {
            library_filter_control_search.ResetFilters();

            SearchTag.Clear();

            if (reset_explorers)
            {
                ObjTagExplorerControl.Reset();
                ObjAITagExplorerControl.Reset();
                ObjAuthorExplorerControl.Reset();
                ObjPublicationExplorerControl.Reset();
                ObjReadingStageExplorerControl.Reset();
                ObjYearExplorerControl.Reset();
                ObjRatingExplorerControl.Reset();
                ObjThemeExplorerControl.Reset();
                ObjTypeExplorerControl.Reset();
            }

            ReviewParameters();
        }
        public SearchTag GetSINnerSearchExample()
        {
            Guid parentTagGuid = Guid.NewGuid();
            var sin = new SearchTag
            {
                TagName = "Reflection",
                TagValue = "",
                SearchOpterator = SearchTag.TagOperatorEnum.notnull,
                Tags = new List<Tag>()
                {
                    new SearchTag ()
                    {
                         Tags = new List<Tag>(),
                         TagName = "AttributeSection",
                         SearchOpterator = SearchTag.TagOperatorEnum.exists
                    }
                }

            };
            return sin;
        }
Beispiel #21
0
        // Search & Tag

        public void RemoveTag(TagItem tagItem)
        {
            SearchTag.RemoveTag(tagItem);

            if (tagItem == null)
            {
                return;
            }

            TagItems.Remove(tagItem);

            UpdateWeekRecords(null);

            RecordsBySearch.Add(tagItem.Name);

            var list = new List <string>(RecordsBySearch);

            list.Sort();

            SortRecordsBySearch(list);
        }
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'SINnerSearchExample.GetSINnerSearchExample()'
        public SearchTag GetSINnerSearchExample()
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'SINnerSearchExample.GetSINnerSearchExample()'
        {
            Guid parentTagGuid = Guid.NewGuid();
            var  sin           = new SearchTag
            {
                TagName         = "Reflection",
                TagValue        = "",
                SearchOpterator = SearchTag.TagOperatorEnum.notnull,
                Tags            = new List <Tag>()
                {
                    new SearchTag()
                    {
                        Tags            = new List <Tag>(),
                        TagName         = "AttributeSection",
                        SearchOpterator = SearchTag.TagOperatorEnum.exists
                    }
                }
            };

            return(sin);
        }
Beispiel #23
0
 public IEnumerable <SINner> Search(SearchTag searchTag)
 {
     try
     {
         _logger.LogTrace("Searching SINnerFile");
         var result = _context.SINners.OrderByDescending(a => a.UploadDateTime).Take(20);
         result = _context.SINners.Include(sinner => sinner.SINnerMetaData)
                  .ThenInclude(meta => meta.Tags)
                  .ThenInclude(tag => tag.Tags)
                  .ThenInclude(tag => tag.Tags)
                  .ThenInclude(tag => tag.Tags)
                  .ThenInclude(tag => tag.Tags)
                  .ThenInclude(tag => tag.Tags)
                  .OrderByDescending(a => a.UploadDateTime).Take(20);
         return(result);
     }
     catch (Exception e)
     {
         HubException hue = new HubException("Exception in SearchSINnerFile: " + e.Message, e);
         throw hue;
     }
 }
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member 'SINSearchController.Search(SearchTag)'
        public IEnumerable <SINner> Search(SearchTag searchTag)
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member 'SINSearchController.Search(SearchTag)'
        {
            try
            {
                _logger.LogTrace("Searching SINnerFile");
                var result = _context.SINners.Include(sinner => sinner.SINnerMetaData)
                             .ThenInclude(meta => meta.Tags)
                             .ThenInclude(tag => tag.Tags)
                             .ThenInclude(tag => tag.Tags)
                             .ThenInclude(tag => tag.Tags)
                             .ThenInclude(tag => tag.Tags)
                             .ThenInclude(tag => tag.Tags)
                             .OrderByDescending(a => a.UploadDateTime).Take(20);
                return(result);
            }
            catch (Exception e)
            {
                HubException hue = new HubException("Exception in SearchSINnerFile: " + e.Message, e);
                throw hue;
            }
        }
Beispiel #25
0
    // Update is called once per frame
    void Update()
    {
        var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, 1) && !SelectionSlotManager.isFull())
        {
            selection    = hit.transform;
            prefabParent = getPrefabsParent(selection.gameObject);
            if (prefabParent != null && SearchTag.search("spo", prefabParent))
            {
                keyIndicator.text = "PREMERE [E] PER RACCOGLIERE  2";

                if (Input.GetButtonDown("Fire1"))
                {
                    Debug.Log(((Tag)prefabParent.GetComponent <Tag>()).getTag());
                    Debug.Log("ha il tag");
                    ((SpawnableObject)prefabParent.GetComponent <SpawnableObject>()).setEnable(true);
                    keyIndicator.text = " ";
                }
            }
        }
    }
 private void AddTags(object sender, EventArgs e)
 {
     try
     {
         if (metroTextBox1.Text.Trim(' ').Length > 0)
         {
             string[] tags = metroTextBox1.Text.ToLower().Split(' ');
             foreach (string tag in tags)
             {
                 if (!searchTags.Contains(tag) && tag.Length > 0 && searchTags.Count < 45)
                 {
                     searchTags.Add(tag);
                     SearchTag st = new SearchTag(tag);
                     flowLayoutPanelTags.Controls.Add(st);
                     flowLayoutPanelTags.Controls.SetChildIndex(st, 0);
                     st.Disposed += new EventHandler(RemoveTag);
                     st.Tag       = tag;
                 }
             }
             metroTextBox1.Text = "";
         }
     }
     catch { }
 }
		private void SaveCategoriesDataSource()
		{
			var commonCategories = _searchGroups
				.Select(sg =>
					{
						var searchGroup = new SearchGroup { Name = sg.DataSource.Name };
						searchGroup.Tags.AddRange(sg.ListBox.Items
							.Where(item => item.CheckState == CheckState.Checked)
							.Select(item =>
							{
								var sourceTag = (SearchTag)item.Value;
								var searchTag = new SearchTag { Name = sourceTag.Name };
								return searchTag;
							}));
						return searchGroup;
					})
				.Where(searchGroup => searchGroup.Tags.Any())
				.ToArray();
			var partialCategories = _searchGroups
				.Select(sg =>
				{
					var searchGroup = new SearchGroup { Name = sg.DataSource.Name };
					searchGroup.Tags.AddRange(sg.ListBox.Items
						.Where(item => item.CheckState == CheckState.Indeterminate)
						.Select(item =>
						{
							var sourceTag = (SearchTag)item.Value;
							var searchTag = new SearchTag { Name = sourceTag.Name };
							return searchTag;
						}));
					return searchGroup;
				})
				.Where(searchGroup => searchGroup.Tags.Any())
				.ToArray();
			_links.ApplyCategories(commonCategories, partialCategories);
		}
Beispiel #28
0
        private Control GetUserInputControl(SearchTag stag)
        {
            string          switchname = stag.TagName;
            string          typename   = stag.MyRuntimePropertyValue.GetType().ToString();
            FlowLayoutPanel flp        = new FlowLayoutPanel();;
            TextBox         tb         = null;
            Button          b          = null;
            NumericUpDown   nud        = null;
            ComboBox        cb         = null;

            switch (typename)
            {
            case "System.Boolean":
            {
                RadioButtonListItem itrue = new RadioButtonListItem
                {
                    Text = "true"
                };
                RadioButtonListItem ifalse = new RadioButtonListItem
                {
                    Text = "false"
                };
                RadioButtonList rdb = new RadioButtonList
                {
                    Text = stag.TagName
                };
                rdb.Items.Add(itrue);
                rdb.Items.Add(ifalse);
                rdb.SelectedIndexChanged += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(((SearchTag)stag.MyParentTag).MyRuntimePropertyValue, itrue.Checked);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                return(rdb);
            }

            case "System.String":
            {
                tb = new TextBox();
                flp.Controls.Add(tb);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo as PropertyInfo;
                    info.SetValue(((SearchTag)stag.MyParentTag).MyRuntimePropertyValue, tb.Text);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "System.Int32":
            {
                nud = new NumericUpDown
                {
                    Minimum = int.MinValue,
                    Maximum = int.MaxValue
                };
                flp.Controls.Add(nud);
                b = new Button
                {
                    Text = "OK"
                };
                b.Click += (sender, e) =>
                {
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(((SearchTag)stag.MyParentTag).MyRuntimePropertyValue, (int)nud.Value);
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(b);
                return(flp);
            }

            case "Chummer.Backend.Uniques.Tradition":
            {
                var traditions = Chummer.Backend.Uniques.Tradition.GetTraditions(ucSINnersSearch.MySearchCharacter.MyCharacter);
                cb = new ComboBox
                {
                    DataSource    = traditions,
                    DropDownStyle = ComboBoxStyle.DropDownList,
                    FlatStyle     = FlatStyle.Standard,
                    DisplayMember = "Name"
                };
                cb.SelectedValueChanged += (sender, e) =>
                {
                    if (_loading)
                    {
                        return;
                    }
                    PropertyInfo info = stag.MyPropertyInfo;
                    info.SetValue(((SearchTag)stag.MyParentTag).MyRuntimePropertyValue, cb.SelectedValue);
                    stag.TagValue = (cb.SelectedValue as Chummer.Backend.Uniques.Tradition)?.Name ?? string.Empty;
                    MySetTags.Add(stag);
                    UpdateDialog();
                };
                flp.Controls.Add(cb);
                return(flp);
            }
            }
            object obj = stag.MyRuntimePropertyValue;

            if (!(obj is string))
            {
                if (obj is IList)
                {
                    Type listtype = StaticUtils.GetListType(obj);
                    if (listtype != null)
                    {
                        switchname = listtype.Name;
                    }
                }
            }

            switch (switchname)
            {
            ///these are sample implementations to get added one by one...
            case "Spell":
            {
                Button button = new Button
                {
                    Text = "select Spell"
                };
                button.Click += (sender, e) =>
                {
                    var frmPickSpell = new frmSelectSpell(MySearchCharacter.MyCharacter);
                    frmPickSpell.ShowDialog();
                    // Open the Spells XML file and locate the selected piece.
                    XmlDocument objXmlDocument = XmlManager.Load("spells.xml");
                    XmlNode     objXmlSpell    = objXmlDocument.SelectSingleNode("/chummer/spells/spell[id = \"" + frmPickSpell.SelectedSpell + "\"]");
                    Spell       objSpell       = new Spell(MySearchCharacter.MyCharacter);
                    if (string.IsNullOrEmpty(objSpell.Name))
                    {
                        return;
                    }
                    objSpell.Create(objXmlSpell, string.Empty, frmPickSpell.Limited, frmPickSpell.Extended, frmPickSpell.Alchemical);
                    MySearchCharacter.MyCharacter.Spells.Add(objSpell);
                    SearchTag spellsearch = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                    {
                        MyRuntimePropertyValue = objSpell,
                        MyParentTag            = stag,
                        TagName        = objSpell.Name,
                        TagValue       = string.Empty,
                        SearchOperator = "exists"
                    };
                    MySetTags.Add(spellsearch);
                    UpdateDialog();
                };
                return(button);
            }

            case "Quality":
            {
                Button button = new Button
                {
                    Text = "select Quality"
                };
                button.Click += ((sender, e) =>
                    {
                        var frmPick = new frmSelectQuality(MySearchCharacter.MyCharacter);
                        frmPick.ShowDialog();
                        // Open the Spells XML file and locate the selected piece.
                        XmlDocument objXmlDocument = XmlManager.Load("qualities.xml");
                        XmlNode objXmlNode = objXmlDocument.SelectSingleNode("/chummer/qualities/quality[id = \"" + frmPick.SelectedQuality + "\"]");
                        Quality objQuality = new Quality(MySearchCharacter.MyCharacter);
                        List <Weapon> lstWeapons = new List <Weapon>();
                        objQuality.Create(objXmlNode, QualitySource.Selected, lstWeapons);
                        MySearchCharacter.MyCharacter.Qualities.Add(objQuality);
                        SearchTag newtag = new SearchTag(stag.MyPropertyInfo, stag.MyRuntimeHubClassTag)
                        {
                            MyRuntimePropertyValue = objQuality,
                            MyParentTag = stag,
                            TagName = objQuality.Name,
                            TagValue = string.Empty,
                            SearchOperator = "exists"
                        };
                        MySetTags.Add(newtag);
                        UpdateDialog();
                    });
                return(button);
            }
            }
            return(null);
        }
        protected override void Seed(TheCodingVineDbContext context)
        {
            context.BlogPosts.RemoveRange(context.BlogPosts);
            context.SaveChanges();


            UserManager <AppUser> userMgr = new UserManager <AppUser>(new UserStore <AppUser>(context));
            RoleManager <Model.Identities.AppRole> roleMgr = new RoleManager <AppRole>(new RoleStore <AppRole>(context));

            if (!roleMgr.RoleExists("Admin"))
            {
                roleMgr.Create(new AppRole()
                {
                    Name = "Admin"
                });
                AppUser TestAdmin = new AppUser()
                {
                    UserName = "******"
                };
                var result = userMgr.Create(TestAdmin, "test123");
                if (!result.Succeeded)
                {
                    //something went wrong on adding a user
                }
                userMgr.AddToRole(TestAdmin.Id, "Admin");
            }


            if (!roleMgr.RoleExists("BlogWriter"))
            {
                roleMgr.Create(new AppRole()
                {
                    Name = "BlogWriter"
                });
                AppUser TestBlogWriter = new AppUser()
                {
                    UserName = "******"
                };
                var result = userMgr.Create(TestBlogWriter, "test123");
                if (!result.Succeeded)
                {
                    //something went wrong on adding a user
                }
                userMgr.AddToRole(TestBlogWriter.Id, "BlogWriter");
            }

            // blog 1
            context.BlogPosts.AddOrUpdate(
                b => b.Title,
                new BlogPost
            {
                Title   = "Test Blog",
                Content = "<h3>Section One</h3> <p><span style=\"font-family: 'Open Sans', Arial, sans-serif;" +
                          " text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in ipsum sagittis, bibendum nisl in," +
                          " convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, eu pharetra purus scelerisque euismod. Sed nec " +
                          "ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet mauris. Pellentesque pretium porttitor nunc vitae semper. " +
                          "Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus" +
                          " tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum mi et, sollicitudin eleifend purus.</span></p>" +
                          " <h3><span style=\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Section Two</span></h3> <p><span style=" +
                          "\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Morbi in ipsum sagittis, bibendum nisl in, convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, " +
                          "eu pharetra purus scelerisque euismod. Sed nec ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet " +
                          "mauris. Pellentesque pretium porttitor nunc vitae semper. Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus" +
                          " nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum" +
                          " mi et, sollicitudin eleifend purus.</span></p>",
                PostDate = new DateTime(2018, 9, 1),

                RemoveDate = new DateTime(2018, 11, 1),
                IsApproved = true,
                BlogNotes  = "These are sample notes that would be input from the admin",
                BlogWriter = userMgr.FindByName("*****@*****.**")
            }
                );
            // blog 2
            context.BlogPosts.AddOrUpdate(
                b => b.Title,
                new BlogPost
            {
                Title   = "A Fishy Writer's Blog",
                Content = "<h3>Section One</h3> <p><span style=\"font-family: 'Open Sans', Arial, sans-serif;" +
                          " text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in ipsum sagittis, bibendum nisl in," +
                          " convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, eu pharetra purus scelerisque euismod. Sed nec " +
                          "ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet mauris. Pellentesque pretium porttitor nunc vitae semper. " +
                          "Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus" +
                          " tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum mi et, sollicitudin eleifend purus.</span></p>" +
                          " <h3><span style=\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Section Two</span></h3> <p><span style=" +
                          "\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Morbi in ipsum sagittis, bibendum nisl in, convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, " +
                          "eu pharetra purus scelerisque euismod. Sed nec ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet " +
                          "mauris. Pellentesque pretium porttitor nunc vitae semper. Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus" +
                          " nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum" +
                          " mi et, sollicitudin eleifend purus.</span></p>",
                PostDate = DateTime.Now,

                RemoveDate = DateTime.Now.AddDays(60),
                IsApproved = false,
                BlogWriter = userMgr.FindByName("*****@*****.**")
            }
                );
            // blog 3
            context.BlogPosts.AddOrUpdate(
                b => b.Title,
                new BlogPost
            {
                Title   = "The Fishiest Writer's Blog",
                Content = "<h3>Section One</h3> <p><span style=\"font-family: 'Open Sans', Arial, sans-serif;" +
                          " text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in ipsum sagittis, bibendum nisl in," +
                          " convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, eu pharetra purus scelerisque euismod. Sed nec " +
                          "ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet mauris. Pellentesque pretium porttitor nunc vitae semper. " +
                          "Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus" +
                          " tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum mi et, sollicitudin eleifend purus.</span></p>" +
                          " <h3><span style=\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Section Two</span></h3> <p><span style=" +
                          "\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Morbi in ipsum sagittis, bibendum nisl in, convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, " +
                          "eu pharetra purus scelerisque euismod. Sed nec ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet " +
                          "mauris. Pellentesque pretium porttitor nunc vitae semper. Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus" +
                          " nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum" +
                          " mi et, sollicitudin eleifend purus.</span></p>",
                PostDate = DateTime.Now,

                RemoveDate = DateTime.Now.AddDays(15),
                IsApproved = true,
                BlogNotes  = "Some fishy admin notes",
                BlogWriter = userMgr.FindByName("*****@*****.**")
            }
                );
            // blog 4
            context.BlogPosts.AddOrUpdate(
                b => b.Title,
                new BlogPost
            {
                Title   = "Cod Based Admin Blog",
                Content = "<h3>Section One</h3> <p><span style=\"font-family: 'Open Sans', Arial, sans-serif;" +
                          " text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in ipsum sagittis, bibendum nisl in," +
                          " convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, eu pharetra purus scelerisque euismod. Sed nec " +
                          "ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet mauris. Pellentesque pretium porttitor nunc vitae semper. " +
                          "Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus" +
                          " tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum mi et, sollicitudin eleifend purus.</span></p>" +
                          " <h3><span style=\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Section Two</span></h3> <p><span style=" +
                          "\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Morbi in ipsum sagittis, bibendum nisl in, convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, " +
                          "eu pharetra purus scelerisque euismod. Sed nec ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet " +
                          "mauris. Pellentesque pretium porttitor nunc vitae semper. Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus" +
                          " nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum" +
                          " mi et, sollicitudin eleifend purus.</span></p>",
                PostDate = DateTime.Now,

                RemoveDate = DateTime.Now.AddDays(30),
                IsApproved = true,
                BlogNotes  = "I can note my own blog!",
                BlogWriter = userMgr.FindByName("*****@*****.**")
            }
                );
            // blog 5
            context.BlogPosts.AddOrUpdate(
                b => b.Title,
                new BlogPost
            {
                Title   = "Expired Cod Blog",
                Content = "<h3>Section One</h3> <p><span style=\"font-family: 'Open Sans', Arial, sans-serif;" +
                          " text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in ipsum sagittis, bibendum nisl in," +
                          " convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, eu pharetra purus scelerisque euismod. Sed nec " +
                          "ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet mauris. Pellentesque pretium porttitor nunc vitae semper. " +
                          "Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus" +
                          " tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum mi et, sollicitudin eleifend purus.</span></p>" +
                          " <h3><span style=\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Section Two</span></h3> <p><span style=" +
                          "\"font-family: 'Open Sans', Arial, sans-serif; text-align: justify;\">Lorem ipsum dolor sit amet, consectetur adipiscing elit. " +
                          "Morbi in ipsum sagittis, bibendum nisl in, convallis magna. Pellentesque varius gravida pharetra. Nam hendrerit sem orci, " +
                          "eu pharetra purus scelerisque euismod. Sed nec ipsum posuere, maximus risus eget, placerat sem. Pellentesque eget aliquet " +
                          "mauris. Pellentesque pretium porttitor nunc vitae semper. Mauris in tincidunt nulla, quis feugiat lorem. Pellentesque finibus" +
                          " nec nibh eu mattis. Nam id dui arcu. Morbi imperdiet lectus tincidunt erat ultrices facilisis. Quisque mi orci, volutpat vestibulum" +
                          " mi et, sollicitudin eleifend purus.</span></p>",
                PostDate = DateTime.Now,

                RemoveDate = DateTime.Now.AddDays(30),
                IsApproved = true,
                BlogWriter = userMgr.FindByName("*****@*****.**")
            }
                );

            context.SearchTags.AddOrUpdate(
                t => t.SearchTagBody,
                new SearchTag {
                SearchTagBody = "TestTag"
            }
                );

            context.SearchTags.AddOrUpdate(
                t => t.SearchTagBody,
                new SearchTag {
                SearchTagBody = "Fishing"
            }
                );

            context.SearchTags.AddOrUpdate(
                t => t.SearchTagBody,
                new SearchTag {
                SearchTagBody = "CodIsBest"
            }
                );

            context.SearchTags.AddOrUpdate(
                t => t.SearchTagBody,
                new SearchTag {
                SearchTagBody = "LoremIpsum"
            }
                );

            context.SearchTags.AddOrUpdate(
                t => t.SearchTagBody,
                new SearchTag {
                SearchTagBody = "OldCod"
            }
                );

            context.StaticPosts.AddOrUpdate(
                s => s.Title,
                new StaticPost
            {
                Title   = "Test Static Post",
                Content = " <h3>Bacon!</h3> <p><span style=\"color: #333333; font-family: Georgia, 'Bitstream Charter', serif;" +
                          " font-size: 16px;\">Spicy jalapeno bacon ipsum dolor amet filet mignon shankle ground round pig corned beef tail jowl." +
                          " Pastrami chuck kielbasa landjaeger beef venison sirloin biltong ham andouille. Leberkas tenderloin meatloaf landjaeger" +
                          " pork belly. Filet mignon salami ground round, ball tip shoulder kielbasa pancetta bacon biltong prosciutto turducken " +
                          "cupim leberkas jowl. Sirloin porchetta pastrami, pork loin cow ribeye tail burgdoggen flank frankfurter capicola tri-tip. " +
                          "Biltong jerky swine tongue andouille ham hock.</span></p>"
            }
                );


            context.SaveChanges();

            SearchTag testTag  = context.SearchTags.Single(t => t.SearchTagBody == "TestTag");
            BlogPost  testBlog = context.BlogPosts.Single(b => b.Title == "Test Blog");

            testBlog.SearchTags.Add(testTag);
            testTag.BlogPosts.Add(testBlog);

            SearchTag testTag2  = context.SearchTags.Single(t => t.SearchTagBody == "Fishing");
            BlogPost  testBlog2 = context.BlogPosts.Single(b => b.Title == "A Fishy Writer's Blog");

            testBlog2.SearchTags.Add(testTag2);
            testTag2.BlogPosts.Add(testBlog2);

            SearchTag testTag3  = context.SearchTags.Single(t => t.SearchTagBody == "CodIsBest");
            BlogPost  testBlog3 = context.BlogPosts.Single(b => b.Title == "The Fishiest Writer's Blog");

            testBlog3.SearchTags.Add(testTag3);
            testBlog3.SearchTags.Add(testTag2);
            testTag3.BlogPosts.Add(testBlog3);

            SearchTag testTag4  = context.SearchTags.Single(t => t.SearchTagBody == "LoremIpsum");
            BlogPost  testBlog4 = context.BlogPosts.Single(b => b.Title == "Cod Based Admin Blog");

            testBlog4.SearchTags.Add(testTag4);
            testTag4.BlogPosts.Add(testBlog4);

            SearchTag testTag5  = context.SearchTags.Single(t => t.SearchTagBody == "OldCod");
            BlogPost  testBlog5 = context.BlogPosts.Single(b => b.Title == "Expired Cod Blog");

            testBlog5.SearchTags.Add(testTag5);
            testTag5.BlogPosts.Add(testBlog5);

            context.Entry(testBlog).State = EntityState.Modified;
            context.Entry(testTag).State  = EntityState.Modified;

            context.SaveChanges();
        }
		private void ApplyData()
		{
			var sharedGroups = _rootNode.Nodes
				.Where(groupNode => groupNode.CheckState == CheckState.Checked)
				.Select(groupNode =>
				{
					var sourceGroup = (SearchGroup)groupNode.Tag;
					var newGroup = new SearchGroup
					{
						Name = sourceGroup.Name,
						Description = sourceGroup.Description
					};
					newGroup.Tags.AddRange(groupNode.Nodes
						.Where(tagNode => tagNode.CheckState == CheckState.Checked)
						.Select(tagNode =>
						{
							var sourceTag = (SearchTag)tagNode.Tag;
							var newTag = new SearchTag { Name = sourceTag.Name };
							return newTag;
						}));
					return newGroup;
				})
				.Where(g => g.Tags.Any())
				.ToArray();

			var partialGroups = _rootNode.Nodes
				.Where(groupNode => groupNode.CheckState != CheckState.Unchecked)
				.Select(groupNode =>
				{
					var sourceGroup = (SearchGroup)groupNode.Tag;
					var newGroup = new SearchGroup
					{
						Name = sourceGroup.Name,
						Description = sourceGroup.Description
					};
					newGroup.Tags.AddRange(groupNode.Nodes
						.Where(tagNode => tagNode.CheckState == CheckState.Indeterminate)
						.Select(tagNode =>
						{
							var sourceTag = (SearchTag)tagNode.Tag;
							var newTag = new SearchTag { Name = sourceTag.Name };
							return newTag;
						}));
					return newGroup;
				})
				.Where(g => g.Tags.Any())
				.ToArray();

			Selection.SelectedObjects.ApplyCategories(sharedGroups, partialGroups);
			EditorChanged?.Invoke(this, new EventArgs());
		}
        public void Run(IWebClient client)
        {
            Console.WriteLine("==>  Demo - 通过本地文件进行图像搜索  <==");
            Console.WriteLine("See https://api-doc.productai.cn/doc/pai.html#通用图像搜索 for details.\r\n");

            //复杂Tag查询示例
            ISearchTag andTag = new AndTag();

            andTag.Add("上衣");
            andTag.Add(new List <string> {
                "圆领", "无袖"
            });

            ISearchTag orTag = new OrTag();

            orTag.Add("蓝色");
            orTag.Add("休闲");
            andTag.Add(orTag);
            ITag searchTag = new SearchTag
            {
                Tag = andTag
            };

            var request = new ImageSearchByImageFileRequest("k7h9fail")
            {
                ImageFile = new System.IO.FileInfo(@".\classify\f10.jpg"),
                Language  = LanguageType.Chinese,
                SearchTag = searchTag
            };

            // you can pass the extra paras to the request
            // 如果不需要传递额外的参数,请注释掉如下3行
            request.Options.Add("para1", "1");
            request.Options.Add("para2", "中文");
            request.Options.Add("para3", "value3");

            try
            {
                var response = client.GetResponse(request);

                Console.WriteLine("==========================Result==========================");
                foreach (var r in response.Results)
                {
                    Console.WriteLine("{0}\t\t{1}", r.Url, r.Score);
                }
                Console.WriteLine("==========================Result==========================");
            }
            catch (ServerException ex)
            {
                Console.WriteLine("ServerException happened: \r\n\tErrorCode: {0}\r\n\tErrorMessage: {1}",
                                  ex.ErrorCode,
                                  ex.ErrorMessage);
            }
            catch (ClientException ex)
            {
                Console.WriteLine("ClientException happened: \r\n\tRequestId: {0}\r\n\tErrorCode: {1}\r\n\tErrorMessage: {2}",
                                  ex.RequestId,
                                  ex.ErrorCode,
                                  ex.ErrorMessage);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Unknown Exception happened: {0}\r\n{1}", ex.Message, ex.StackTrace);
            }
        }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='searchTag'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <IList <SINner> > SearchAsync(this ISINnersClient operations, SearchTag searchTag = default(SearchTag), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SearchWithHttpMessagesAsync(searchTag, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='searchTag'>
 /// </param>
 public static IList <SINner> Search(this ISINnersClient operations, SearchTag searchTag = default(SearchTag))
 {
     return(Task.Factory.StartNew(s => ((ISINnersClient)s).SearchAsync(searchTag), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }