public ComplexListItem(ComplexListItem sourceCLItem) { _itemValues = new List<ComplexListItemValue>(); _id = Guid.NewGuid(); _selectable = sourceCLItem._selectable; _selected = sourceCLItem._selected; _editable = sourceCLItem._editable; _deletable = sourceCLItem._deletable; _default = sourceCLItem._default; }
public ComplexListItem Migrate(Dictionary<Guid /*destTermField*/, Guid /*sourceTermField*/> fieldMapping, ComplexListItem sourceItem) { return null; }
private void SubstituteComplexLists(Template template) { int sampleListItemsOnPreview = 2; //First, substitute a child clause for each item in each DISTINCT complex list in this clause string text = Term.SubstituteTermIDs(template, HttpUtility.HtmlDecode(_text)); //NOTE: (RR 2-11-2010) -- added filter to only select complex lists where Runtime.Enabled==true. List<ComplexList> complexLists = FindComplexLists(template, text).FindAll(cl => cl.Runtime.Enabled == true); foreach (ComplexList complexList in complexLists) { string pattern = string.Format(XMLNames._M_TermImageFindPattern, complexList.Name); bool inTable = IsInTable(text, complexList.Name); if (!string.IsNullOrEmpty(complexList.Header)) { string headerText = (template.IsManagedItem ? complexList.Header : complexList.StandardHeader); Term.SubstituteBasicTerms(template, ref headerText); Term.SubstituteSpecialTerms(ref headerText, template); if (ContainsPrintableCharacters()) { text = string.Concat(text, HttpUtility.HtmlDecode(headerText)); } else { text = HttpUtility.HtmlDecode(headerText); } } //when doing the preview (i.e. template is NOT a managed item), add sample listitems to the complex list if (template.IsManagedItem) { int index = 0; for (int i = 0; i < complexList.Items.Count; i++) { if (complexList.Items[i].Selected ?? false) { if (inTable) { string itemDisplayValue = complexList.ItemDisplayValue(complexList.Items[i]); text = text.Replace(pattern, string.Format("{0}{1}", itemDisplayValue, pattern)); } else { ITATClause childClause = new ITATClause(); childClause.HangingIndent = this.HangingIndent; childClause.IndentFirstParagraph = this.IndentFirstParagraph; childClause.IndentSubsequentParagraphs = this.IndentSubsequentParagraphs; childClause.BreakParagraphs = this.BreakParagraphs; childClause.PageBreakBefore = false; childClause.Text = complexList.ItemDisplayValue(complexList.Items[i]); if (this.ChildNumberingScheme == ChildNumberingSchemeType.None) childClause.SuppressSpacingBefore = true; _children.Insert(index, childClause); index++; } } } } else { int index = 0; for (int i = 0; i < sampleListItemsOnPreview; i++) { ComplexListItem newItem = new ComplexListItem(); for (int j = 0; j < complexList.Fields.Count; j++) { ComplexListField field = complexList.Fields[j]; ComplexListItemValue complexListItemValue = new ComplexListItemValue(field.ID, string.Format(@"<span style=""font-weight:bold; text-decoration:underline;"">{3}{0} #{1} | {2}{4}</span>", complexList.Name, i + 1, field.Name, (char)0xab, (char)0xbb), complexList, field.FilterTerm, true); newItem.ItemValues.Add(complexListItemValue); } if (inTable) { text = text.Replace(pattern, string.Format("{0}{1}", complexList.ItemDisplayValue(newItem), pattern)); } else { ITATClause childClause = new ITATClause(); childClause.HangingIndent = this.HangingIndent; childClause.IndentFirstParagraph = this.IndentFirstParagraph; childClause.IndentSubsequentParagraphs = this.IndentSubsequentParagraphs; childClause.BreakParagraphs = this.BreakParagraphs; childClause.PageBreakBefore = false; childClause.Text = complexList.ItemDisplayValue(newItem); _children.Insert(index, childClause); index++; } } } //Delete the Complex List Term placeholder from _text string sOutput = text.Replace(pattern, string.Empty); _text = HttpUtility.HtmlEncode(sOutput); } }
protected void btnOK_Click(object sender, EventArgs e) { Business.ComplexList complexList = (Business.ComplexList)_template.ComplexLists[TermIndex]; List<ComplexListItemValue> complexListItemValues = new List<ComplexListItemValue>(); foreach (Business.ComplexListField field in complexList.Fields) { ComplexListItemValue cliv = new ComplexListItemValue(complexList, field.FilterTerm); cliv.FieldID = field.ID; cliv.FieldValue = GetFieldValue(field); cliv.BigText = cliv.FieldValue.Length > 150; complexListItemValues.Add(cliv); } ComplexListItem complexListItem = new ComplexListItem(); complexListItem.Default = true; complexListItem.ItemValues = complexListItemValues; complexListItem.Selectable = chkbxSelectable.Checked; complexListItem.Selected = chkbxSelected.Checked; complexListItem.Editable = chkbxEditable.Checked; complexListItem.Deletable = chkbxDeletable.Checked; if (EditMode == EditMode.Add) complexList.Items.Add(complexListItem); else complexList.Items[termEdit.ComplexListItemIndex] = complexListItem; BaseTransfer(null, TermHandler.ComplexListItem, "TermEditComplexListItems.aspx", true); }
public override void Migrate(Term term) { if (term == null) base.Migrate(term); if (!(term is ComplexList)) return; else { ComplexList sourceTerm = term as ComplexList; //Any Items found within the destination term ComplexList are considered Default Items. If there are no Default Items, then //migrate the sourceTerm ComplexList Items. If there are Default Items, then do not migrate the source term ComplexList Items. if (ModifyItems(sourceTerm, this)) { //Migrate the sourceTerm Items. First, create a mapping of FieldID's. Match source to destination based on ID, then by name. Dictionary<Guid /*destCLFieldID*/, ComplexListField /*sourceCLField*/> fieldMapping = new Dictionary<Guid, ComplexListField>(); foreach (ComplexListField destCLField in Fields) { ComplexListField sourceCLField = sourceTerm.FindField(destCLField.ID); if (sourceCLField == null) sourceCLField = sourceTerm.FindField(destCLField.Name); if (sourceCLField != null) fieldMapping.Add(destCLField.ID, sourceCLField); else fieldMapping.Add(destCLField.ID, destCLField); } foreach (ComplexListItem sourceCLItem in sourceTerm.Items) { ComplexListItem destCLItem = new ComplexListItem(sourceCLItem); foreach (ComplexListField destCLField in Fields) { ComplexListItemValue destCLItemValue = new ComplexListItemValue(null, destCLField.FilterTerm); destCLItemValue.BigText = fieldMapping[destCLField.ID].BigText ?? false; destCLItemValue.RemoveBlank = fieldMapping[destCLField.ID].RemoveBlank ?? false; destCLItemValue.FieldID = destCLField.ID; ComplexListItemValue sourceCLItemValue = sourceCLItem.FindItemValue(fieldMapping[destCLField.ID].ID); if (sourceCLItemValue != null) destCLItemValue.Migrate(sourceCLItemValue); else destCLItemValue.Clear(); destCLItem.ItemValues.Add(destCLItemValue); } Items.Add(destCLItem); } } sourceTerm.Runtime.Migrated = true; } Runtime.Migrated = true; }
private string SubstituteItemValue(ComplexListItem item, string fieldName) { try { for (int i = 0; i < item.ItemValues.Count; i++) if (this.Fields[i].Name == fieldName) if (item.ItemValues[i].RemoveBlank) if (string.IsNullOrEmpty(item.ItemValues[i].DisplayValue)) return string.Empty; else return item.ItemValues[i].DisplayValue; else return item.ItemValues[i].DisplayValue; return string.Empty; } catch { return string.Empty; } }
private string SubstituteTerms(ComplexListItem item) { //match anything of the form <img...src="TextImage.ashx?text="...".../> in _text string text = HttpUtility.HtmlDecode(this.Rendering); if (!string.IsNullOrEmpty(text)) { MatchCollection matches = Regex.Matches(text, XMLNames._M_TermImageTemplate); foreach (Match match in matches) { string matchedText = match.Result("$0"); string fieldName = match.Groups[1].Value; string replacementText = SubstituteItemValue(item, fieldName); text = HttpUtility.HtmlDecode(text).Replace(matchedText, replacementText); } } return text; }
public string ItemDisplayValue(ComplexListItem item) { string rtn = SubstituteTerms(item); return rtn; }
public ComplexList(XmlNode node, Template template, bool isFilter) : base(node, template, isFilter) { TermType = TermType.ComplexList; NameRequired = true; _columnCount = Utility.XMLHelper.GetAttributeInt(node, XMLNames._A_ColumnCount); _showOnItemSummary = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_ShowOnItemSummary); _fields = new List<ComplexListField>(); XmlNodeList nodeFields = node.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Fields, XMLNames._E_Field)); if (nodeFields != null) { foreach (XmlNode nodeField in nodeFields) { ComplexListField field = new ComplexListField(nodeField, this); _fields.Add(field); } } _items = new List<ComplexListItem>(); XmlNodeList nodeItems = node.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_Items, XMLNames._E_Item)); if (nodeItems != null) { foreach (XmlNode nodeItem in nodeItems) { ComplexListItem item = new ComplexListItem(nodeItem, this); //Set the BigText value stored within each itemValue - for use by the interface foreach (ComplexListItemValue itemValue in item.ItemValues) { if (!itemValue.FieldIDDefined) { itemValue.BigText = FindField(itemValue.FieldName).BigText ?? false; itemValue.RemoveBlank = FindField(itemValue.FieldName).RemoveBlank ?? false; } else { itemValue.BigText = FindField(itemValue.FieldID).BigText ?? false; itemValue.RemoveBlank = FindField(itemValue.FieldID).RemoveBlank ?? false; } } _items.Add(item); } } foreach (ComplexListItem item in _items) { foreach (ComplexListItemValue itemValue in item.ItemValues) { if (!itemValue.FieldIDDefined) { itemValue.FieldID = FindField(itemValue.FieldName).ID; } } } XmlNode nodeRendering = node.SelectSingleNode(XMLNames._E_Rendering); if (nodeRendering != null) { _rendering = Utility.XMLHelper.GetText(nodeRendering); _rendering = ComplexListField.EmbedFieldNames(this, _rendering); } XmlNode nodeStandardHeader = node.SelectSingleNode(XMLNames._E_StandardHeader); if (nodeStandardHeader != null) { _standardHeader = Utility.XMLHelper.GetText(nodeStandardHeader); _standardHeader = ComplexListField.EmbedFieldNames(this, _standardHeader); } XmlNode nodeAlternateHeader = node.SelectSingleNode(XMLNames._E_AlternateHeader); if (nodeAlternateHeader != null) { _alternateHeader = Utility.XMLHelper.GetText(nodeAlternateHeader); _alternateHeader = ComplexListField.EmbedFieldNames(this, _alternateHeader); } }