public void RefreshSplitView() { BoxModelData homeData = new BoxModelData(); var ListBox = homeData.GetListBox(); var group = from c in ListBox group c by c.NameParentBox; this.cvs.Source = group; }
public bool SetDefaultBox(string idBox) { BoxModelData homeModelData = new BoxModelData(); var ListBoxID = homeModelData.GetListBox().Select(n => n.Id).ToList(); if (!ListBoxID.Contains(idBox)) { return(false); } appSetting.BoxStart = int.Parse(idBox); return(true); }
public string RequestAddNamebox(string idBox) { // Check IdBox. BoxModelData homeModelData = new BoxModelData(); var ListBox = homeModelData.GetListBox(); foreach (var Box in ListBox) { if (Box.Id == idBox) { return(Resource.DIALOG_IDBOX_EXIST); } } // Send request string content = Resource.STR_EMPTY; string url = Resource.URL_LIST_THREAD .Replace("{rpIDBox}", idBox) .Replace("{rpIDPage}", "0"); try { Server.Get(url, ref content); if (content != Resource.DIALOG_ERROR) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(content); // Get Title Box HtmlNode TitleBoxNode = (from td in doc.DocumentNode.Descendants("td") where td.GetAttributeValue("class", Resource.STR_EMPTY) == "navbar" select td).FirstOrDefault(); // Get parent of Box List <HtmlNode> ParentBoxNodeList = doc .DocumentNode .Descendants("span") .Where(n => n.GetAttributeValue("class", Resource.STR_EMPTY) == "navbar") .ToList(); if (TitleBoxNode == null || HtmlEntity.DeEntitize(TitleBoxNode.InnerText) == Resource.STR_VB_MSG || ParentBoxNodeList == null || ParentBoxNodeList.Count < 2) { return(Resource.DIALOG_ERROR); } var TitleNode = HtmlEntity.DeEntitize(TitleBoxNode.InnerText.Trim()); var TitleParent = HtmlEntity.DeEntitize(ParentBoxNodeList[1].InnerText).Replace(">", Resource.STR_EMPTY).Trim(); homeModelData.Add(new BoxModel() { Id = idBox, NameParentBox = TitleParent, NameBox = TitleNode }); //await Task.Delay(TimeSpan.FromSeconds(0.3)); MainView.GetInstance().RefreshSplitView(); return(Resource.DIALOG_DONE); } else { return(Resource.DIALOG_ERROR); } } catch (Exception ex) { return(Resource.DIALOG_ERROR); } }