public void Migrate(ComplexListItemValue itemValue) { _fieldValue = itemValue._fieldValue; }
public ComplexListItem(XmlNode node, ComplexList complexList) { _selectable = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Selectable); _selected = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Selected); _editable = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Editable); _deletable = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Deletable); _default = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Default); _id = Guid.Empty; string id = Utility.XMLHelper.GetAttributeString(node, XMLNames._A_ID); if (!string.IsNullOrEmpty(id)) { try { _id = new Guid(id); } catch { } } //If an ID was not assigned before, assign it now.... if (_id == Guid.Empty) _id = Guid.NewGuid(); XmlNodeList nodeItemValues = node.SelectNodes(XMLNames._E_ItemValue); if (nodeItemValues != null) { _itemValues = new List<ComplexListItemValue>(nodeItemValues.Count); foreach (XmlNode nodeItemValue in nodeItemValues) { ComplexListItemValue itemValue = new ComplexListItemValue(nodeItemValue, complexList); _itemValues.Add(itemValue); } } }
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); }
protected string GetFieldValue(ComplexListItemValue itemValue) { string result = ""; switch (itemValue.TermType) { case TermType.Text: result = Request.Form[Helper.ControlID(itemValue.FieldName, itemValue.TermType)]; break; case TermType.PickList: result = Request.Form[Helper.ControlID(itemValue.FieldName, itemValue.TermType)]; break; case TermType.Date: result = Request.Form[Helper.ControlID(itemValue.FieldName, itemValue.TermType)]; break; } return result; }
internal static TextBox CreateTextComplexListFieldControl(ComplexListItemValue itemValue) { TextBox txt = new TextBox(); txt.ID = ControlID(itemValue.FieldName); txt.Width = Unit.Percentage(100); //switch (((TermType.Text)itemValue.TermType).Format) //{ // case TextTermFormat.Plain: // txt.Width = Unit.Percentage(100); // break; // case TextTermFormat.Number: // txt.Width = Unit.Pixel(120); // break; // case TextTermFormat.Currency: // txt.Width = Unit.Pixel(120); // break; // case TextTermFormat.SSN: // txt.Width = Unit.Pixel(120); // break; // case TextTermFormat.Phone: // txt.Width = Unit.Pixel(120); // break; // case TextTermFormat.PhonePlusExtension: // txt.Width = Unit.Pixel(200); // break; // default: // break; //} return txt; }
internal static Panel CreateDateComplexListFieldControl(ComplexListItemValue itemValue) { Panel pnl = new Panel(); pnl.ID = ControlID(itemValue.FieldName) + "_pnl"; //write textbox to contain date TextBox txtDate = new TextBox(); //pnl.Controls[0] txtDate.Style["width"] = "114px"; txtDate.Style["height"] = "18px"; txtDate.Style["padding-top"] = "0"; txtDate.MaxLength = 12; txtDate.ID = ControlID(itemValue.FieldName); txtDate.Attributes["onfocus"] = "javascript:this.select();"; pnl.Controls.Add(txtDate); //write "button" image and click event that will display calendar IFRAME Image imgDate = new Image(); //pnl.Controls[1] imgDate.Style["cursor"] = "hand"; imgDate.ID = ControlID(itemValue.FieldName) + "_img"; imgDate.ImageUrl = "/Global/bin/Calendar/calendar.gif"; imgDate.Height = Unit.Parse("19px"); imgDate.Width = Unit.Parse("34px"); imgDate.ImageAlign = ImageAlign.Top; imgDate.BorderWidth = Unit.Parse("0px"); imgDate.Attributes["onclick"] = string.Format("window.event.cancelBubble=true; ShowCalendar(document.all.CalFrame, window.frames.CalFrame, null, document.getElementById('{0}'), null, -600, 3600);", txtDate.ClientID); pnl.Controls.Add(imgDate); return pnl; }
private static void GetComplexListItemTermTypeErrors( Dictionary<string /* Term Name */, List<string> /* Error Messages */ > errorMessages, ComplexListItemValue itemValue, int? itemIndex, string complexListName) { Term term = itemValue.Term; string termName = itemValue.FieldName; term.ReportName = termName; term.Runtime.Clear(true, term.Required ?? false); itemValue.FieldFilterTerm.Runtime.Clear(true, term.Required ?? false); string tabMessage = null; if (itemIndex.HasValue) tabMessage = GetTabMessage(complexListName, itemIndex.Value); string testValueError = term.TestValue(termName, tabMessage, itemValue.FieldValue); if (string.IsNullOrEmpty(testValueError)) { term.SetValue(itemValue.FieldValue); List<string> sErrors = term.CheckType(!string.IsNullOrEmpty(tabMessage), tabMessage); if (sErrors != null && sErrors.Count > 0) { if (!errorMessages.ContainsKey(itemValue.FieldName)) { itemValue.FieldFilterTerm.Runtime.HasError = true; if (sErrors.Count > 1) itemValue.FieldFilterTerm.Runtime.ErrorMessage = string.Join("\\n", sErrors.ToArray()); else itemValue.FieldFilterTerm.Runtime.ErrorMessage = sErrors[0]; errorMessages.Add(itemValue.FieldName, sErrors); } } } else { if (!errorMessages.ContainsKey(itemValue.FieldName)) { itemValue.FieldFilterTerm.Runtime.HasError = true; itemValue.FieldFilterTerm.Runtime.ErrorMessage = testValueError; errorMessages.Add(itemValue.FieldName, new List<string>(new string[] { testValueError })); } } }
internal static Panel CreatePickListComplexListFieldControl(ComplexListItemValue itemValue) { Panel pnl = new Panel(); pnl.ID = ControlID(itemValue.FieldName); PickListTerm pickListTerm = (PickListTerm)itemValue.Term; if (pickListTerm.PickListItems.Count == 1) //1 picklist item: single check box { CheckBox chk = new CheckBox(); chk.BorderStyle = BorderStyle.None; chk.ID = pnl.ID + "_lst"; // ???? chk.CssClass = Common.Names._STYLE_CSSCLASS_EDIT; chk.Text = pickListTerm.PickListItems[0].Value; pnl.Controls.Add(chk); } else { if (pickListTerm.MultiSelect ?? false) // multi-select picklist: MultiSelectGrid control { pnl.Height = Unit.Pixel(4 + 20 * Math.Min(4, pickListTerm.PickListItems.Count)); pnl.Width = Unit.Percentage(100.0); MultiSelectGrid grd = new MultiSelectGrid(); grd.ID = pnl.ID + "_lst"; grd.CheckboxColumn = 0; grd.DataSource = pickListTerm.PickListItems; grd.BoundColumns = "Value"; //grd.DataKeyNames = new string[] { "Value" }; grd.Container = pnl.ID; grd.HeaderContainer = ""; grd.AutoGenerateColumns = false; grd.RowHighlighting = false; grd.EnableClickEvent = false; grd.EnableDoubleClickEvent = false; grd.EnableHeaderClick = false; grd.ShowHeader = false; grd.ColumnWidths = "100%"; grd.DataBind(); pnl.Controls.Add(grd); } else { if (pickListTerm.PickListItems.Count == 2) //2 item single-select picklist: RadioButtonList { RadioButtonList rdolst = new RadioButtonList(); rdolst.ID = pnl.ID + "_lst"; rdolst.CellPadding = 0; rdolst.CellSpacing = 0; rdolst.RepeatDirection = RepeatDirection.Vertical; AddListItems(rdolst, pickListTerm.PickListItems); pnl.Controls.Add(rdolst); } else // 3 or more item single-select list: DropDrownList { DropDownList ddl = new DropDownList(); ddl.ID = pnl.ID + "_lst"; ddl.Width = Unit.Percentage(100.0); ddl.Items.Add(new ListItem("(Select One)", "")); AddListItems(ddl, pickListTerm.PickListItems); pnl.Controls.Add(ddl); } } } return pnl; }
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); } }
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; }
public bool AddFieldToCurrentItems(Guid fieldID, bool bigText, Term fieldFilterTerm) { foreach (ComplexListItem item in _items) { if (item.ItemValues != null) { ComplexListItemValue itemValue = new ComplexListItemValue(this, fieldFilterTerm); itemValue.FieldID = fieldID; itemValue.BigText = bigText; item.ItemValues.Add(itemValue); } } return true; }