protected void BindDictionaryBranch(JsonTreeNode branch, Guid parentDict) { using (DictionaryProvider provider = new DictionaryProvider()) { List<DictionaryTree> dicts = provider.GetDictionaryTreeList(parentDict, this.Roles); foreach (DictionaryTree dict in dicts) { JsonTreeNode tempNode = new JsonTreeNode(dict.Name); branch.children.Add(tempNode); BindDictionaryBranch(tempNode, dict.ID); } if (!parentDict.Equals(Guid.Empty)) { DictionaryTree entity = provider.DictionaryTrees.SingleOrDefault(d => d.ID == parentDict); List<DictionaryProperty> source = provider.GetAvailableDictionaryProperties(this.Roles, entity.DictionaryID); foreach (DictionaryProperty prop in source) { JsonTreeNode tempNode = new JsonTreeNode(prop.Name); tempNode.uid = String.Format("{0}_{1}", prop.Dictionary.TableName, prop.ColumnName); tempNode.leaf = true; branch.children.Add(tempNode); } } } }
private void BindDictionaryList() { using (DictionaryProvider provider = new DictionaryProvider()) { List<DictionaryTree> list = provider.GetDictionaryTreeList(this.DictionaryTreeID, this.Roles); List<DictionaryDDLSource> source = new List<DictionaryDDLSource>(); foreach (DictionaryTree item in list) { DictionaryDDLSource entity = new DictionaryDDLSource(); entity.DictionaryTreeID = item.ID; //set dictionary property title entity.Title = item.Name; //string.Format("{0} ({1})", item.First.Name, item.Second); //get product dicitonary value object value = provider.GetDictionaryItemValue(this.DictionaryTreeID, this.RequestDictionaryEntityID, item.FK); if (value != null && !string.IsNullOrEmpty(value.ToString())) { entity.ID = new Guid(value.ToString());//entity.SelectedValue = value.ToString(); string valueText = provider.GetProductDictionaryText(entity.ID, item).ToString(); if (!string.IsNullOrEmpty(valueText) && valueText.Trim().Length > 0) entity.ValueText = valueText; } source.Add(entity); } DictionaryPropertyRepeater.DataSource = source; DictionaryPropertyRepeater.DataBind(); } }
public void BindDictionaryTreeView(Guid parentID, TreeNode parentNode, ContentDomain domain, List<ITreeNode> parents) { using (DictionaryProvider provider = new DictionaryProvider()) { //bind child dictionaries List<ITreeNode> list = new List<ITreeNode>(); if (parentID.Equals(Guid.Empty)) { List<DictionaryTree> list1 = provider.GetDictionaryTreeList(parentID, this.Roles); var q = from l in list1.Where(f => f.ClassificationID.HasValue) join m in parents on l.ClassificationID.Value equals m.ID select new DictionaryTree { ID = l.ID, ParentID = l.ParentID, Name = string.Format("{0} ({1})", l.Name, m.Name) } as ITreeNode; //l as ITreeNode; list = q.ToList(); } else { list = provider.GetList(parentID, User.ID, Roles); } foreach (ITreeNode item in list) { TreeNode node = new TreeNode(item.Name, item.ID.ToString()); node.SelectAction = TreeNodeSelectAction.Expand; if (parentNode != null) parentNode.ChildNodes.Add(node); else DictionaryTreeView.Nodes.Add(node); this.BindDictionaryTreeView(item.ID, node, domain, parents); } //bind fields if (parentNode != null && !parentID.Equals(Guid.Empty)) { DictionaryTree entity = provider.DictionaryTrees.SingleOrDefault(d => d.ID == parentID); List<IUserField> fields = domain.GetUserFields(this.User.ID, RequestClassificationTreeID, this.FieldPlaceHolderID).Where(uf => uf.DictionaryTreeID == parentID).ToList(); List<Guid> previous = this.PreviouseDictionaries; previous.AddRange(fields.Select(f => f.DictionaryProperty.ID)); this.PreviouseDictionaries = previous; //List<DictionaryProperty> source = entity.Dictionary.DictionaryProperties.ToList(); List<DictionaryProperty> source = provider.GetAvailableDictionaryProperties(this.Roles, entity.DictionaryID); foreach (DictionaryProperty prop in source) { TreeNode node = new TreeNode(prop.Name, prop.ID.ToString()); node.SelectAction = TreeNodeSelectAction.None; IUserField field = fields.Find(f => f.DictionaryProperty.ID == prop.ID); if (field != null) { node.Checked = true; node.Value = string.Format("{0},{1}", node.Value, field.Sequence); } else node.Checked = false; parentNode.ChildNodes.AddAt(0, node); } } //-- } }
private void BindDictionaryList(List<ITreeNode> parents, bool isEmpty) { using (DictionaryProvider provider = new DictionaryProvider()) { //--- dictionary property ----- Product product = provider.Products.SingleOrDefault(p => p.ID == this.RequestProductID); if (product == null) this.RedirectToErrorPage(); List<DictionaryTree> list = provider.GetDictionaryTreeList(Guid.Empty, this.Roles); var q = from l in list.Where(f => f.ClassificationID.HasValue) join m in parents on l.ClassificationID.Value equals m.ID select new Pair<DictionaryTree, string>(l, m.Name); List<DictionaryDDLSource> source = new List<DictionaryDDLSource>(); foreach (Pair<DictionaryTree, string> item in q.ToList()) { DictionaryDDLSource entity = new DictionaryDDLSource(); entity.DictionaryTreeID = item.First.ID; //set dictionary property title entity.Title = string.Format("{0} ({1})", item.First.Name, item.Second); //get product dicitonary value object value = provider.GetProductDicitonaryValue(this.RequestProductID, item.First.FK); if (value != null && !string.IsNullOrEmpty(value.ToString()) && !isEmpty) { entity.ID = new Guid(value.ToString());//entity.SelectedValue = value.ToString(); string valueText = provider.GetProductDictionaryText(entity.ID, item.First).ToString(); if (!string.IsNullOrEmpty(valueText) && valueText.Trim().Length > 0) entity.ValueText = valueText; } source.Add(entity); } DictionaryPropertyRepeater.DataSource = source; DictionaryPropertyRepeater.DataBind(); } }