public TermDependencyCondition(Template template, string sourceTerm, string oper, string value1, string value2)
		{
			_template = template;
			_sourceTermID = _template.FindTerm(sourceTerm).ID;
			_oper = oper;
			_value1 = value1;
			_value2 = value2;
		}
Esempio n. 2
0
		public static List<string> ReplaceEmbeddedTermNames(Template template, List<Event> notifications)
		{
			List<string> sErrors = new List<string>();
			foreach (Event notification in notifications)
			{
				if (!Term.ValidID(notification.BaseDateTermID))
					if (!string.IsNullOrEmpty((notification as Event).BaseDateTermName))
					{
						try
						{
							(notification as Event).BaseDateTermID = template.FindTerm((notification as Event).BaseDateTermName).ID;
						}
						catch (Exception)
						{
							sErrors.Add(string.Format("Unable to find Event term '{0}'", (notification as Event).BaseDateTermName));
						}
					}

				if (!Term.ValidID(notification.OffsetTermID))
					if (!string.IsNullOrEmpty((notification as Event).OffsetTermName))
					{
						try
						{
							(notification as Event).OffsetTermID = template.FindTerm((notification as Event).OffsetTermName).ID;
						}
						catch (Exception)
						{
							sErrors.Add(string.Format("Unable to find Event term '{0}'", (notification as Event).BaseDateTermName));
						}
					}

				foreach (Message message in notification.Messages)
				{
					message.Text = Term.SubstituteTermNames(template, message.Text);
				}
			}
			return sErrors;
		}
		public TermDependencyCondition(Template template, XmlNode conditionNode)
		{
			_template = template;
			string sourceTerm = Utility.XMLHelper.GetAttributeString(conditionNode, XMLNames._A_SourceTerm);
			if (!string.IsNullOrEmpty(sourceTerm))
			{
				_sourceTermID = _template.FindTerm(sourceTerm).ID;
			}
			else
			{
				_sourceTermID = Term.CreateID(conditionNode, XMLNames._A_SourceTermID);
			}
			_oper = Utility.XMLHelper.GetAttributeString(conditionNode, XMLNames._A_Oper);
			_value1 = Utility.XMLHelper.GetAttributeString(conditionNode, XMLNames._A_Value1);
			_value2 = Utility.XMLHelper.GetAttributeString(conditionNode, XMLNames._A_Value2);
		}
Esempio n. 4
0
		public static List<string> ReplaceEmbeddedTermNames(Template template, List<Term> terms)
		{
			List<string> sErrors = new List<string>();
			if (terms != null)
				foreach (Term term in terms)
				{
					switch (term.TermType)
					{
						//Does not apply to these term types:
						case TermType.Text:
						case TermType.Date:
						case TermType.MSO:
						case TermType.PickList:
						case TermType.Facility:
						case TermType.External:  // ???
							break;

						case TermType.Link:
							//TODO - The assumption here is that the Link term will be up to date, since the
							//change requiring its inclusion will not go out until the TermID change goes out.
							//Otherwise, the Link term would first require the ComplexLists to be loaded.
							break;

						case TermType.Renewal:
							if (!Term.ValidID((term as RenewalTerm).RenewalEvent.OffsetTermID))
								if (!string.IsNullOrEmpty((term as RenewalTerm).RenewalEvent.OffsetTermName))
								{
									try
									{
										(term as RenewalTerm).RenewalEvent.OffsetTermID = template.FindTerm((term as RenewalTerm).RenewalEvent.OffsetTermName).ID;
									}
									catch (Exception)
									{
										sErrors.Add(string.Format("Unable to find Renewal term '{0}'", (term as RenewalTerm).RenewalEvent.OffsetTermName));
									}
								}

							break;
						default:
							break;
					}
				}
			return sErrors;
		}
		public static List<string> ReplaceEmbeddedTermNames(Template template, List<TermDependency> termDependencies)
		{
			List<string> sErrors = new List<string>();
			foreach (TermDependency termDependency in termDependencies)
			{
				foreach (TermDependencyCondition termDependencyCondition in termDependency.Conditions)
				{
					if (!Term.ValidID(termDependencyCondition.SourceTermID))
						if (!string.IsNullOrEmpty(termDependencyCondition.SourceTerm))
						{
							try
							{
								termDependencyCondition.SourceTermID = template.FindTerm(termDependencyCondition.SourceTerm).ID;
							}
							catch (Exception)
							{
								sErrors.Add(string.Format("Unable to find TermDependency SourceTerm '{0}'", termDependencyCondition.SourceTerm));
							}
						}
				}
			}
			return sErrors;
		}
		public TermDependency(Template template, XmlNode termDependencyNode)
		{
			_template = template;

			string dependentTerm = Utility.XMLHelper.GetAttributeString(termDependencyNode, XMLNames._A_DependentTerm);
            Guid dependentTermID;
			if (!string.IsNullOrEmpty(dependentTerm))
			{
                dependentTermID = _template.FindTerm(dependentTerm).ID;
			}
			else
			{
                dependentTermID = Term.CreateID(termDependencyNode, XMLNames._A_DependentTermID);
			}

			string idString = Utility.XMLHelper.GetAttributeString(termDependencyNode, XMLNames._A_ID);
			_id = new Guid(idString);
			_quantifier = (DependencyQuantifier)Enum.Parse(typeof(DependencyQuantifier), Utility.XMLHelper.GetAttributeString(termDependencyNode, XMLNames._A_Quantity));
			string sTarget = Utility.XMLHelper.GetAttributeString(termDependencyNode, XMLNames._A_Target);
			if (string.IsNullOrEmpty(sTarget))
				_target = DependencyTarget.Term;
			else
				_target = (DependencyTarget)Enum.Parse(typeof(DependencyTarget), sTarget);

            if (_target == DependencyTarget.Term)
            {
                //Add dependent terms.  If this is the 'old' structure, then the dependentTermID is defined.  If not, then the DependentTerms collection is defined.
                _dependentTermIDs = new List<Guid>();
                XmlNode nodeDependentTerms = termDependencyNode.SelectSingleNode(Utility.XMLHelper.GetXPath(false, XMLNames._E_DependentTerms));
                if (nodeDependentTerms != null)
                {
                    XmlNodeList nodelistDependentTerms = termDependencyNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_DependentTerms, XMLNames._E_DependentTerm));
                    foreach (XmlNode nodeDependentTerm in nodelistDependentTerms)
                    {
                        _dependentTermIDs.Add(Term.CreateID(nodeDependentTerm, XMLNames._A_ID));
                    }
                }
                else
                {
                    if (!Term.ValidID(dependentTermID))
                    {
                        throw new Exception(string.Format("Dependent term not defined for Term Dependency {0}", _id.ToString()));
                    }
                    else
                    {
                        _dependentTermIDs.Add(dependentTermID);
                    }
                }
            }

			//Add Conditions
			XmlNodeList nodelistConditions = termDependencyNode.SelectNodes(Utility.XMLHelper.GetXPath(false, XMLNames._E_TermDependencyConditions, XMLNames._E_TermDependencyCondition));
			if (nodelistConditions != null && nodelistConditions.Count > 0)
			{
				_conditions = new List<TermDependencyCondition>(nodelistConditions.Count);
				foreach (XmlNode nodeCondition in nodelistConditions)
					_conditions.Add(new TermDependencyCondition(_template, nodeCondition));
			}
			else
			{
				_conditions = new List<TermDependencyCondition>();
			}

			//Add Action
			XmlNode nodeAction = termDependencyNode.SelectSingleNode(Utility.XMLHelper.GetXPath(false, XMLNames._E_TermDependencyAction));
			if (nodeAction != null)
				_action = new TermDependencyAction(nodeAction);
			else
				_action = new TermDependencyAction(TermDependencyActionValue.Default, TermDependencyActionValue.Default);


            //Is Active
            try
            {
                _isActive = Utility.XMLHelper.GetAttributeBool(termDependencyNode, XMLNames._A_IsActive);
                if (!_isActive.HasValue)
                    _isActive = true;
            }
            catch
            {
            }
		}
Esempio n. 7
0
 public List<string> TermReferences(Template template, string termName)
 {
     List<string> rtn = new List<string>();
     if (!string.IsNullOrEmpty(termName))
     {
         Guid termID = template.FindTerm(termName).ID;
         rtn.AddRange(Business.ITATDocuments.TermReferences(template, termName));
         rtn.AddRange(Business.Events.TermReferences(template, termName, termID, Events));
         rtn.AddRange(Business.BasicTerms.TermReferences(template, termName, termID));
         rtn.AddRange(Business.TermDependency.TermReferences(template, termName, termID));
         rtn.AddRange(Business.Workflows.TermReferences(template, termName, termID));
         rtn.AddRange(Business.ComplexLists.TermReferences(template, termName, ComplexLists));
     }
     return rtn;
 }
Esempio n. 8
0
		//If a clause is a conditional clause (i.e. it DependsOn a term, then check to see if the term has the required value for the clause to appear.
		internal bool ShouldShow(Template template)
		{
			//If we are previewing in the template editor (i.e., template is NOT a ManagedItem), then always show clauses (even conditional ones)
			if (!(template is ManagedItem))
				return true;

			Term term = null;
			if (Term.ValidID(_dependsOnTermID))
				term = template.FindTerm(_dependsOnTermID);
			else
				if (!string.IsNullOrEmpty(_dependsOnTermName))
					term = template.FindBasicTerm(_dependsOnTermName);

			if (term == null)
				return true;
			else
				if (_dependsOnOperator == "=")
					return (term.DisplayValue(XMLNames._TPS_None) == _dependsOnValue);
				else
					return (term.DisplayValue(XMLNames._TPS_None) != _dependsOnValue);
		}
Esempio n. 9
0
		internal List<ComplexList> FindComplexLists(Template template, string text)
		{
			List<string> complexListNames = new List<string>();
			List<ComplexList> rtn = new List<ComplexList>();
			string[] delimiter = new string[] { " | " };
			//match anything of the form <img...src="TextImage.ashx?text="...".../> in _text
			if (!string.IsNullOrEmpty(text))
			{
				MatchCollection matches = Regex.Matches(text, XMLNames._M_TermImageTemplate);
				foreach (Match match in matches)
				{
					//first search for a matching Term
					string[] termNameParts = match.Groups[1].Value.Split(delimiter, StringSplitOptions.RemoveEmptyEntries);
					string termIdentifier = termNameParts[0];
					Term term = null;
					if (termIdentifier.StartsWith(XMLNames._M_TermID))
					{
						Guid g = new Guid(termIdentifier.Substring(XMLNames._M_TermID.Length));
						term = template.FindTerm(g);
					}
					else
						term = template.FindTerm(termIdentifier);
					//if a term is found, and it is a complex list, add the term name to the list being returned
					if (term != null)
						if (term.TermType == TermType.ComplexList)
							if (!complexListNames.Contains(term.Name))
							{
								complexListNames.Add(term.Name);
								rtn.Add((ComplexList)term);
							}
				}
			}
			return rtn;
		}
Esempio n. 10
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));
					}
				}
			}
		}