Exemplo n.º 1
0
 public ITATDocument()
 {
     _ITATDocumentID = Guid.NewGuid();
     _documentName = string.Empty;
     _defaultDocument = false;
     _workflowEnabled = true;
     _clause = new ITATClause();
     _clause.Name = XMLNames._E_Document;
     _header = new ITATDocumentHeader();
     _footer = new ITATDocumentFooter();           
     
 }
        private bool FormChanged(ITATClause clause)
        {
            if (clause.Name != txtName.Text)
            {
                //TODO: rename the appropriate tree node that was changed
                return true;
            }
            if (clause.ChildNumberingScheme != (Business.ChildNumberingSchemeType)Enum.Parse(typeof(Business.ChildNumberingSchemeType), ddlChildNumberingScheme.SelectedValue))
                return true;
            if ((clause.IndentFirstParagraph ?? false) != chkIndentFirstParagraph.Checked)
                return true;
            if ((clause.IndentSubsequentParagraphs ?? false) != chkIndentSubsequentParagraphs.Checked)
                return true;
            if ((clause.HangingIndent ?? false) != chkHangingIndent.Checked)
                return true;
            if ((clause.BreakParagraphs ?? false) != chkBreakParagraphs.Checked)
                return true;
            if ((clause.PageBreakBefore ?? false) != chkPageBreakBefore.Checked)
                return true;

            //in the next 3 "if" blocks, ignore the case where one string is null and the other is empty			
            if (_template.MatchTerm(clause.DependsOnTermID, clause.DependsOnTermName, ddlConditionalTerm.SelectedValue))
                return true;
            if (clause.DependsOnOperator != ddlConditionalOperator.SelectedValue)
                if (!(string.IsNullOrEmpty(clause.DependsOnOperator) && string.IsNullOrEmpty(ddlConditionalOperator.SelectedValue)))   //ignore the case where one string is null and the other is empty
                    return true;
            if (clause.DependsOnValue != ddlConditionalValue.SelectedValue)
                if (!(string.IsNullOrEmpty(clause.DependsOnValue) && string.IsNullOrEmpty(ddlConditionalValue.SelectedValue)))   //ignore the case where one string is null and the other is empty
                    return true;

            return false;
        }
Exemplo n.º 3
0
        public ITATDocument(XmlDocument xmlTemplateDoc, XmlNode node, Template template, bool isNewDocStructure)
        {
            if (isNewDocStructure)
            {
                _ITATDocumentID = new Guid(Utility.XMLHelper.GetAttributeString(node, XMLNames._A_ID));
                _documentName = Utility.XMLHelper.GetAttributeString(node, XMLNames._A_Name);
                _defaultDocument = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Document_DefaultDocument);
                _workflowEnabled = Utility.XMLHelper.GetAttributeBool(node, XMLNames._A_Document_WorkflowEnabled);
                _generatedDocumentID = Utility.XMLHelper.GetAttributeString(node, XMLNames._A_GeneratedDocumentID);
            }
            else
            {
                _ITATDocumentID = Guid.NewGuid();
                _documentName = Utility.XMLHelper.GetAttributeString(node.SelectSingleNode(XMLNames._E_Body), XMLNames._A_Name);
                _defaultDocument = true;
                _workflowEnabled = true;
                _generatedDocumentID = Utility.XMLHelper.GetAttributeString(xmlTemplateDoc.DocumentElement, XMLNames._A_GeneratedDocument); ;
            }


            XmlNode nodeHeader = node.SelectSingleNode(XMLNames._E_Header);
            _header = new ITATDocumentHeader(nodeHeader);

            XmlNode nodeFooter = node.SelectSingleNode(XMLNames._E_Footer);
            _footer = new ITATDocumentFooter(nodeFooter);

            XmlNode nodeBody = node.SelectSingleNode(XMLNames._E_Body);
            _clause = new ITATClause();
            _clause.Name = Utility.XMLHelper.GetAttributeString(nodeBody, XMLNames._A_Name);
            _clause.ChildNumberingScheme = ChildNumberingSchemeHelper.GetSchemeType(Utility.XMLHelper.GetAttributeString(nodeBody, XMLNames._A_ChildNumberingScheme));
            _clause.Create(nodeBody);
        }
        private void LoadClauseProperties(ITATClause clause, bool rootNode)
        {
            txtName.Text = clause.Name;
            ddlChildNumberingScheme.SelectedValue = clause.ChildNumberingScheme.ToString("D");

            if (rootNode)
            {
                lblName.Visible = false;
                txtName.Visible = false;
                chkIndentFirstParagraph.Visible = false;
                chkIndentSubsequentParagraphs.Visible = false;
                chkHangingIndent.Visible = false;
                chkBreakParagraphs.Visible = false;
                chkPageBreakBefore.Visible = false;
                ddlConditionalTerm.Visible = false;
                spnDependsOn.Visible = false;
                fldDependsOn.Visible = false;


            }
            else
            {
                chkIndentFirstParagraph.Checked = (clause.IndentFirstParagraph ?? false);
                chkIndentSubsequentParagraphs.Checked = (clause.IndentSubsequentParagraphs ?? false);
                chkHangingIndent.Checked = (clause.HangingIndent ?? false);
                chkBreakParagraphs.Checked = (clause.BreakParagraphs ?? false);
                chkPageBreakBefore.Checked = (clause.PageBreakBefore ?? false);
                string dependsOnTermName = _template.FindTermName(clause.DependsOnTermID, clause.DependsOnTermName);
                FormatDependentClauseSection(dependsOnTermName, clause.DependsOnOperator, clause.DependsOnValue);

                txtName.Visible = true;
                lblName.Visible = true;
                chkIndentFirstParagraph.Visible = true;
                chkIndentSubsequentParagraphs.Visible = true;
                chkHangingIndent.Visible = true;
                chkBreakParagraphs.Visible = true;
                chkPageBreakBefore.Visible = true;
                ddlConditionalTerm.Visible = true;
                spnDependsOn.Visible = true;
                fldDependsOn.Visible = true;
            }

        }
 protected void btnAddClause_OnCommand(object sender, CommandEventArgs e)
 {
     ITATClause parent = _template.GetITATDocument(_ITATDocumentID).FindClause(_clausePath, treClauses.PathSeparator);
     ITATClause newClause = new ITATClause();
     newClause.Name = "New Clause";
     newClause.ChildNumberingScheme = ChildNumberingSchemeType.None;
     newClause.Text = Helper.DefaultEditorHtml(edt);
     parent.Children.Add(newClause);
     LoadClauseTree();   //refresh the clause tree to pick up the new clause
     SelectTreeNode(string.Format("{0}{2}{1}", _clausePath, newClause.Name, treClauses.PathSeparator));
     IsChanged = true;
 }
        private void AddTreeNode(TreeNode parent, ITATClause clause)
        {
            TreeNode newNode;
            if (parent == null)
            {
                newNode = new TreeNode(clause.Name, clause.Name);
                treClauses.Nodes.Add(newNode);
            }
            else
            {
                newNode = new TreeNode(clause.Name, clause.Name);
                parent.ChildNodes.Add(newNode);
            }
            //newNode.NavigateUrl = string.Format("javascript:OnTreeNodeClick('{0}')", clause.Name);

            foreach (ITATClause childClause in clause.Children)
                AddTreeNode(newNode, childClause);
        }
 private void LoadClauseText(ITATClause clause)
 {
     edt.Visible = true;
     edt.Html = Business.Term.SubstituteTermIDs(_template, clause.Text);
 }
Exemplo n.º 8
0
		public static void ReplaceEmbeddedTermNames(Template template, ITATClause child, List<string> sErrors)
		{
			if (!string.IsNullOrEmpty(child.DependsOnTermName))
			{
				try
				{
					child.DependsOnTermID = template.FindTerm(child.DependsOnTermName).ID;
				}
				catch (Exception)
				{
					sErrors.Add(string.Format("Unable to find Clause Dependent term '{0}'", child.DependsOnTermName));
				}
			}

			for (int i = 0; i < child._children.Count; i++)
			{
				if (!string.IsNullOrEmpty(child._children[i].DependsOnTermName))
				{
					try
					{
						child._children[i].DependsOnTermID = template.FindTerm(child._children[i].DependsOnTermName).ID;
					}
					catch (Exception)
					{
						sErrors.Add(string.Format("Unable to find Clause Dependent term '{0}'", child._children[i].DependsOnTermName));
					}
				}
			}
		}
Exemplo n.º 9
0
		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);
			}
		}
Exemplo n.º 10
0
		public static void SubstituteTermNames(Template template, ITATClause child)
		{
			child.Text = Term.SubstituteTermNames(template, child.Text);
			for (int i = 0; i < child._children.Count; i++)
			{
				child._children[i].Text = Term.SubstituteTermNames(template, child._children[i].Text);
			}
		}
Exemplo n.º 11
0
		public void Build(XmlDocument xmlDoc, XmlNode parentNode, ITATClause parentClause, bool bValidate)
		{
			foreach (ITATClause childClause in parentClause._children)
			{
				if (bValidate)
				{
					Utility.XMLHelper.ValidateString("ITATClause text", childClause._text);
				}

				XmlNode elementChildClause = xmlDoc.CreateNode(XmlNodeType.Element, XMLNames._E_Clause, XMLNames._M_NameSpaceURI);
				BuildNode(xmlDoc, elementChildClause, childClause, bValidate);
				Build(xmlDoc, elementChildClause, childClause, bValidate);
				parentNode.AppendChild(elementChildClause);
			}
		}
Exemplo n.º 12
0
		public void BuildNode(XmlDocument xmlDoc, XmlNode node, ITATClause clause, bool bValidate)
		{
			if (bValidate)
			{
				if (string.IsNullOrEmpty(clause._text))
					throw new XmlException("Required ITATClause text not supplied");
			}
			Utility.XMLHelper.AddAttributeString(xmlDoc, node, XMLNames._A_Name, clause._name);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_IndentFirstParagraph, clause._indentFirstParagraph);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_IndentSubsequentParagraphs, clause._indentSubsequentParagraphs);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_HangingIndent, clause._hangingIndent);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_BreakParagraphs, clause._breakParagraphs);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_PageBreakBefore, clause._pageBreakBefore);
			Utility.XMLHelper.AddAttributeBool(xmlDoc, node, XMLNames._A_SuppressSpacingBefore, clause._suppressSpacingBefore);
			Term.StoreID(xmlDoc, node, XMLNames._A_DependsOnTermName, clause._dependsOnTermName, XMLNames._A_DependsOnTermID, clause._dependsOnTermID);

			Utility.XMLHelper.AddAttributeString(xmlDoc, node, XMLNames._A_DependsOnOperator, clause._dependsOnOperator);
			Utility.XMLHelper.AddAttributeString(xmlDoc, node, XMLNames._A_DependsOnValue, clause._dependsOnValue);
			Utility.XMLHelper.AddAttributeString(xmlDoc, node, XMLNames._A_ChildNumberingScheme, ChildNumberingSchemeHelper.GetSchemeText(clause._childNumberingScheme));
			Utility.XMLHelper.AddText(xmlDoc, node, clause._text);
		}
Exemplo n.º 13
0
		private bool ParseDOM(XmlNode parentNode, ITATClause parentClause)
		{
			foreach (XmlNode childNode in parentNode.ChildNodes)
			{
				if (!Utility.XMLHelper.IsTextNode(childNode))
				{
					ITATClause childClause = new ITATClause();
					childClause.CreateNode(childNode, childClause);
					childClause._parent = parentClause;
					parentClause._children.Add(childClause);
				}
			}
			return true;
		}
Exemplo n.º 14
0
		private bool CreateNode(XmlNode clauseNode, ITATClause clause)
		{
			clause._name = Utility.XMLHelper.GetAttributeString(clauseNode, XMLNames._A_Name);
			clause._indentFirstParagraph = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_IndentFirstParagraph);
			clause._indentSubsequentParagraphs = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_IndentSubsequentParagraphs);
			clause._hangingIndent = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_HangingIndent);
			clause._breakParagraphs = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_BreakParagraphs);
			clause._pageBreakBefore = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_PageBreakBefore);
			clause._suppressSpacingBefore = Utility.XMLHelper.GetAttributeBool(clauseNode, XMLNames._A_SuppressSpacingBefore);

			clause._dependsOnTermName = Utility.XMLHelper.GetAttributeString(clauseNode, XMLNames._A_DependsOnTermName);
			clause._dependsOnTermID = Term.CreateID(clauseNode, XMLNames._A_DependsOnTermID);

			clause._dependsOnOperator = Utility.XMLHelper.GetAttributeString(clauseNode, XMLNames._A_DependsOnOperator);
			clause._dependsOnValue = Utility.XMLHelper.GetAttributeString(clauseNode, XMLNames._A_DependsOnValue);

			clause._childNumberingScheme = ChildNumberingSchemeHelper.GetSchemeType(Utility.XMLHelper.GetAttributeString(clauseNode, XMLNames._A_ChildNumberingScheme));
			clause._text = Utility.XMLHelper.GetText(clauseNode);

			return ParseDOM(clauseNode, clause);
		}