Ejemplo n.º 1
0
        public void Load(Template template, string value, string pattern, char? delimiter)
        {
            if (!string.IsNullOrEmpty(value))
            {
                //TODO: May also need to account for List<DurationUnit> _initialDurationUnits and _renewalDurationUnits
                string[] values = value.Split(delimiter.Value);
                string[] sections = pattern.Split(delimiter.Value);
                if (values.Length != sections.Length)
                    return;
                Term term = null;
                for (int i = 0; i < sections.Length; i++)
                {
                    if (!string.IsNullOrEmpty(values[i]))
                    {
                        switch (sections[i])
                        {
                            //Expecting values[i] to be of the form 'Term Name^Effective Date' or 'Term Name^Expiration Date'
                            case _LABEL_BASE_DATE_TERM_NAME:
                                string termName = RenewalTerm.GetLoadBaseDateTermName(values[i]);
                                term = template.FindBasicTerm(termName);
                                if (term != null)
                                {
                                    switch (term.TermType)
                                    {
                                        case TermType.Date:
                                            BaseDateTermID = term.ID;
                                            break;

                                        case TermType.Renewal:
                                            switch (RenewalTerm.GetLoadBaseDateTermDisplayType(values[i]))
                                            {
                                                case DisplayedDate.EffectiveDate:
                                                    _baseDateTermPart = XMLNames._TPS_EffectiveDate;
                                                    break;

                                                case DisplayedDate.ExpirationDate:
                                                    _baseDateTermPart = XMLNames._TPS_ExpirationDate;
                                                    break;
                                            }
                                            BaseDateTermID = term.ID;
                                            break;
                                    }
                                }
                                break;

                            case _LABEL_OFFSET_TERM_NAME:
                                term = template.FindBasicTerm(values[i]);
                                if (term != null)
                                    OffsetTermID = term.ID;
                                break;

                            case _LABEL_OFFSET_DEFAULT_VALUE:
                                int offsetDefaultValue;
                                if (int.TryParse(values[i], out offsetDefaultValue))
                                    OffsetDefaultValue = offsetDefaultValue;
                                break;

                            case _LABEL_BASE_DATE_OFFSET:
                                BaseDateOffset = values[i];
                                break;
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
		public static ScheduledEvent Find(Template template, Guid scheduledEventID)
		{
			if (template == null)
				return null;

			ScheduledEvent scheduledEvent = null;

			foreach (Event eachEvent in template.Events)
			{
				scheduledEvent = Find(eachEvent.ScheduledEvents, scheduledEventID);
				if (scheduledEvent != null)
					return scheduledEvent;
			}

			foreach (Event eachEvent in template.Workflow.Events)
			{
				scheduledEvent = Find(eachEvent.ScheduledEvents, scheduledEventID);
				if (scheduledEvent != null)
					return scheduledEvent;
			}

			RenewalTerm renewalTerm = template.FindBasicTerm(TermType.Renewal) as RenewalTerm;
			if (renewalTerm != null)
				return Find(renewalTerm.RenewalEvent.ScheduledEvents, scheduledEventID);

			return null;
		}
Ejemplo n.º 3
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);
		}