//Generate the Terms collection (of Term) based on an existing Template
        //2090429 - This will be called with a param for the XPath, depending...
        //This is called from ManagedItem.Create and from BasicTerms prop-get
		public static List<Term> Create(string templateDef, ManagedItem managedItem, Template template)
		{
			if (templateDef == null)
				return null;
            //Convert the xml into an xmldocument
            XmlDocument xmlTemplateDoc = new XmlDocument();
			xmlTemplateDoc.PreserveWhitespace = false;
			xmlTemplateDoc.LoadXml(templateDef);

            return Create(xmlTemplateDoc.SelectSingleNode(Utility.XMLHelper.GetXPath(true, XMLNames._E_TemplateDef, XMLNames._E_Terms)), managedItem, template);
		}
 public ExternalTerm(bool systemTerm, Business.ExternalInterfaceConfig eic, ManagedItem managedItem, Template template, bool isFilter)
     : base(systemTerm, template, isFilter)
 {
     TermType = TermType.External;
     NameRequired = true;
     Name = eic.Name;
     _interfaceConfig = eic;
     //NOTE - This operation is valid only the FIRST time this is set...
     if (TermTransforms == null && _interfaceConfig.TransformTermType.HasValue)
     {
         TransformTermType = _interfaceConfig.TransformTermType;
         TermTransforms = _interfaceConfig.TermTransforms;
     }
     _managedItem = managedItem;
     _valuesLoaded = false;
     _value = null;
 }
		/// <summary>
		/// Creates a new instance of a ManagedItem using the specified template where the system uses the OwningFacility concept
		/// </summary>
		/// <param name="template">The template that this ManagedItem is based on</param>
		/// <param name="facilityIds">One or more facilities that this ManagedItem is associated with</param>
		public static ManagedItem Create(bool updateDatabase, Guid templateID, int? primaryFacilityID)
		{
			ManagedItem managedItem = new ManagedItem(templateID, Guid.NewGuid());
			managedItem.LoadWorkflow();

			//Load BasicTerms since we will need to update the TemplateDef based on the selected PrimaryID's
			managedItem.LoadBasicTerms();

			managedItem.SetDefaultValues();
			managedItem.LoadAttachments();
			managedItem.State = managedItem.Workflow.FindBaseState();

			if (primaryFacilityID.HasValue)
			{
				List<int> facilityIDs = new List<int>(1);
				facilityIDs.Add(primaryFacilityID.Value);
				managedItem.PrimaryFacility.SelectedFacilityIDs = new List<int>(facilityIDs);
				managedItem.PrimaryFacility.OwningFacilityIDs = new List<int>(facilityIDs);
			}

			ITATSystem system = ITATSystem.Get(managedItem.SystemID);
			string sFirstPart = GetFirstPart(system, managedItem);
			string sPrefix = string.Format("{0}{1}", sFirstPart, system.ManagedItemNumberSystemId);
			if (sPrefix.Length > 13)
				throw new Exception("The ManagedItem Number length will exceed 20 characters");
            int nSequenceNumber = 0;
            if (updateDatabase)
                nSequenceNumber = Data.ManagedItem.GetSequenceNumber(managedItem.SystemID, sPrefix);
            else
                nSequenceNumber = 1;
			if (nSequenceNumber <= 0)
			{
				if (primaryFacilityID.HasValue)
					throw new Exception(string.Format("SequenceNumber not found for SystemID {0}, FacilityID {1}", managedItem.SystemID.ToString(), primaryFacilityID.Value.ToString()));
				else
					throw new Exception(string.Format("SequenceNumber not found for SystemID {0}", managedItem.SystemID.ToString()));
			}

			managedItem.ItemNumber = string.Format("{0}{1}", sPrefix, nSequenceNumber.ToString("D7"));
			return managedItem;
		}
		/// <summary>
		/// Retrieves a ManagedItem instance from the database.  Only retrieves the minimum data.
		/// </summary>
		/// <param name="id"></param>
		public static ManagedItem GetBasic(Guid managedItemID)
		{
			string status = "";
			string templateDef = "";
			string itemNumber = "";
			string templateID = "";
            Guid stateID = Guid.Empty;
			using (DataSet ds = Data.ManagedItem.GetManagedItem(managedItemID))
			{
				DataRow row = ds.Tables[0].Rows[0];
				status = (string)row[Data.DataNames._C_Status];
                templateDef = (string)row[Data.DataNames._C_TemplateDef];
				templateID = row[Data.DataNames._C_TemplateID].ToString();
				itemNumber = row[Data.DataNames._C_ManagedItemNumber].ToString();
                try
                {
                    stateID = (Guid)row[Data.DataNames._C_StateID];
                }
                catch
                {
                    throw new Exception(string.Format("StateID not defined for ManagedItem {0}", itemNumber));
                }
			}

			ManagedItem managedItem = new ManagedItem(new Guid(templateID), managedItemID);

            XmlDocument xmlTemplateDoc = new XmlDocument();
            xmlTemplateDoc.PreserveWhitespace = false;
            xmlTemplateDoc.LoadXml(templateDef);

            managedItem.LoadWorkflow(xmlTemplateDoc);
            managedItem.LoadBasicTerms(xmlTemplateDoc);

            //populate external terms
            foreach (Term term in managedItem.FindAllBasicTerms(TermType.External))
            {
                ExternalTerm extTerm = term as ExternalTerm;
                if (extTerm == null)
                    throw new Exception(string.Format("The term '{0}' is not an external term.", term.Name));
                if (!extTerm.ValuesLoaded)
                    extTerm.LoadValues();
            }

            managedItem.State = managedItem.Workflow.FindState(stateID);
            managedItem.ItemNumber = itemNumber;
            return managedItem;
		}
        public static ManagedItem Get(Guid managedItemId, bool loadComplexLists, string state, Guid stateID, string status, string templateDef, string itemNumber, Guid templateID, bool orphaned)
		{
			ManagedItem managedItem = new ManagedItem(templateID, managedItemId);
			XmlDocument xmlTemplateDoc = new XmlDocument();
			xmlTemplateDoc.PreserveWhitespace = false;
			xmlTemplateDoc.LoadXml(templateDef);

			if (loadComplexLists)
			{
				//Need Workflow in order to access the states
				//Need BasicTerms in order to be able to modify the Primary FacilityID's
				managedItem.LoadWorkflow(xmlTemplateDoc);
				managedItem.LoadBasicTerms(xmlTemplateDoc);
				managedItem.LoadComplexLists(xmlTemplateDoc);
			}
			else
			{
				managedItem.LoadWithoutComplexLists(xmlTemplateDoc);
			}
			managedItem.LoadComments(xmlTemplateDoc);
			managedItem.LoadAttachments();
            if (!managedItem.TermGroupsLoaded)
                managedItem.LoadTermGroups(xmlTemplateDoc);
            managedItem.LoadDocuments(xmlTemplateDoc);
            if (stateID.Equals(Guid.Empty))
			    managedItem.State = managedItem.Workflow.FindState(state);
            else
                managedItem.State = managedItem.Workflow.FindState(stateID);
            managedItem.ItemNumber = itemNumber;
            managedItem.IsOrphaned = orphaned;
            
			return managedItem;
		}
        public void Rollback(Guid managedItemAuditId, string sEnvironment, bool? orphanTheItem)
        {
			bool retroRollback;
            Retro.RetroData retroData = GetRetroData(_itemNumber, _managedItemID, managedItemAuditId);
			if (retroData.TemplateRetroDate.HasValue && retroData.AuditDate < retroData.TemplateRetroDate.Value)
            {
                //May require retro
                switch (RetroModel)
                {
                    case Retro.RetroModel.Off:
                        retroRollback = false;
                        break;

                    case Retro.RetroModel.OnWithEditLanguage:
                        if (_isOrphaned)
                        {
                            retroRollback = false;
                        }
                        else
                        {
                            if (!orphanTheItem.HasValue)
                                throw new Exception(string.Format("The 'orphan' value was required but not supplied for the rollback of ManagedItem '{0}'", ManagedItemID.ToString()));
                            retroRollback = !(orphanTheItem.Value);
                            _isOrphaned = orphanTheItem.Value;
                            if (_isOrphaned)
                            {
								retroData.AuditType = Retro.AuditType.Orphaned;
                                ILog log = LogManager.GetLogger(this.GetType());
                                log.Debug(string.Format("ManagedItem {0} ({1}) (System {2}) Orphaned due to Rollback", ItemNumber, ManagedItemID.ToString(), SystemID.ToString()));
                            }
                        }
                        break;

                    case Retro.RetroModel.OnWithoutEditLanguage:
                        retroRollback = true;
                        break;

                    default:
                        throw new Exception(string.Format("RetroModel case '{0}' not handled for ManagedItem '{1}'", RetroModel.ToString(),ManagedItemID.ToString()));
                }
            }
            else
                retroRollback = false;

            ITATSystem itatSystem = null;
            Business.ManagedItem newManagedItem = null;
            if (retroRollback)
            {
                Template currentTemplate = new Template(TemplateID, Business.DefType.Final);
                itatSystem = ITATSystem.Get(SystemID);
                bool returnToDraft;
                newManagedItem = Business.ManagedItem.CreateRetro(currentTemplate, false, ManagedItemID, itatSystem.HasOwningFacility.Value, itatSystem.DocumentStorageType, out returnToDraft);
                newManagedItem.Update(false, retroData.AuditType);    //Update also calls UpdateManagedItemStateRole
                if (returnToDraft)
                {
                    //No action required here as of last spec update
                }
                newManagedItem.UpdateScheduledEvents(ScheduledEvent.ExecutedCalculationType.UseGracePeriod);
            }
            else
            {
                newManagedItem = new ManagedItem(TemplateID, ManagedItemID, ItemNumber, IsOrphaned, retroData.StateID, retroData.TemplateDef);
                //Ensure that the database is updated with the older External term values
                foreach (Term t in newManagedItem.BasicTerms)
                    if (t.TermType == TermType.External)
                    {
                        (t as ExternalTerm).SaveValues(false);
                    }
				newManagedItem.Update(false, retroData.AuditType);    //Update also calls UpdateManagedItemStateRole
            }
            
           
            //Changed for Multiple Documents
            foreach (ITATDocument doc in Documents)
            {
                if (!string.IsNullOrEmpty(doc.GeneratedDocumentID) && newManagedItem.GetITATDocument(doc.ITATDocumentID).GeneratedDocumentID != doc.GeneratedDocumentID)
                {
                    if (itatSystem == null)
                        itatSystem = ITATSystem.Get(SystemID);
                    //Changed for Multiple Documents
                    RemoveGeneratedDocument(newManagedItem, doc.GeneratedDocumentID, itatSystem.DocumentStorageType);
                }

            }



        }
        private bool Migrate(ManagedItem sourceManagedItem)
        {
            _itemNumber = sourceManagedItem._itemNumber;
            _isOrphaned = sourceManagedItem._isOrphaned;
            //Changed for Multiple Documents
             this.Documents = sourceManagedItem.Documents;
            CopyExtensions(sourceManagedItem.Extensions);
            _attachments = new List<Attachment>(sourceManagedItem.Attachments);

            foreach (Term term in BasicTerms) 
            {
                term.MigrateReset();
                Term sourceTerm = sourceManagedItem.FindTerm(term.ID, term.Name);
                if (sourceTerm != null && !(sourceTerm is ComplexList) && term.TermType == sourceTerm.TermType)
                    term.Migrate(sourceTerm);
                else
                {
                    term.Migrate(null);
                }
            }

            foreach (Term term in sourceManagedItem.BasicTerms)
            {
                if (!term.Runtime.Migrated)
                    term.Delete();
            }

            for (int index = 0;index < ComplexLists.Count;index++)
            {
                ComplexList term = (ComplexList)ComplexLists[index];
                Term sourceTerm = sourceManagedItem.FindTerm(term.ID, term.Name);
                if (sourceTerm != null && (sourceTerm is ComplexList))
                {
                    if (ComplexList.ModifyItems(sourceTerm as ComplexList, term))
                        term = (ComplexList)term.RetroCopy(false, this);
                    term.Migrate(sourceTerm);
                    ComplexLists[index] = term;
                }
                else
                    term.Migrate(null);
            }

            foreach (Term term in sourceManagedItem.ComplexLists)
            {
                if (!term.Runtime.Migrated)
                    term.Delete();
            }

            int count = Comments.Count; //Cause the setting of _commentsLoaded
            Comments = new List<Comment>(sourceManagedItem.Comments);

            Event.Migrate(sourceManagedItem.Events, Events);
            Event.Migrate(sourceManagedItem.Workflow.Events, Workflow.Events);

            //The ActiveWorkflow is determined by the source template (that was used to create 'this').
            //The ActiveWorkflow will not change.
            //If the sourceManagedItem happens to have the same ActiveWorkflow as the source template, and a match
            //can be made on the state, then keep the state.  Otherwise, set the state to the base state.

            State currentState = null;
            if (ActiveWorkflowID.Equals(sourceManagedItem.ActiveWorkflowID) || Workflow.Name.Equals(sourceManagedItem.Workflow.Name))
            {
                currentState = Workflow.FindState(sourceManagedItem.State.ID);
                if (currentState == null)
                    currentState = Workflow.FindState(sourceManagedItem.State.Name);
            }

            State = currentState == null ? Workflow.FindBaseState() : currentState;
            return currentState == null;
        }
		//TODO:  Allow for non-numeric hard-coded value (including empty string)
		private static string GetFirstPart(ITATSystem system, ManagedItem managedItem)
		{
			//If ManagedItemNumberSystemType is an empty string, then return an empty string
			if (string.IsNullOrEmpty(system.ManagedItemNumberSystemType))
				return string.Empty;

			//If ManagedItemNumberSystemType is a special value meaning SAP Alias, return the Owning Facility's SAP Alias
			if (system.ManagedItemNumberSystemType == XMLNames._SYSTEM_MINST_Fac_SAP4)
			{
				if (managedItem.PrimaryFacility.OwningFacilityIDs == null)
					throw new Exception(string.Format("Tried to create a sequence number for a ManagedItem which does not have any OwningFacilites defined, ManagedItem {0}", managedItem._managedItemID.ToString()));
				if (managedItem.PrimaryFacility.OwningFacilityIDs.Count == 0)
					throw new Exception(string.Format("Tried to create a sequence number for a ManagedItem which does not have any OwningFacilites defined, ManagedItem {0}", managedItem._managedItemID.ToString()));

				string sSAPID = "";
				using (DataSet ds = Data.ManagedItem.GetFacilityInfo(FacilityTerm.GetXml(managedItem.PrimaryFacility.OwningFacilityIDs)))
				{
					if (ds.Tables.Count > 0)
						if (ds.Tables[0].Rows.Count > 0)
							//This approach assumes that we are only interested in the first facilityID
							sSAPID = ds.Tables[0].Rows[0][Data.DataNames._SP_FacilitySAPID].ToString();
					if (string.IsNullOrEmpty(sSAPID))
						throw new Exception(string.Format("SAPID not found for managedItem {0}", managedItem._managedItemID.ToString()));
				}
				return sSAPID.Substring(0, 4);
			}

			//Otherwise, return the hard-coded ManagedItemNumberSystemType 
			return system.ManagedItemNumberSystemType;
		}
		//Generate the Terms collection (of Term) based on an existing Template
        //Called by ManagedItem.GetBasic and by ManagedItem.Get
        public static List<Term> Create(XmlDocument xmlTemplateDoc, ManagedItem managedItem, Template template)
		{
            return Create(xmlTemplateDoc.SelectSingleNode(Utility.XMLHelper.GetXPath(true, XMLNames._E_TemplateDef, XMLNames._E_Terms)), managedItem, template);
		}
		private bool AnyConditionMet(ManagedItem managedItem)
		{
			foreach (TermDependencyCondition condition in _conditions)
			{
				if (condition.ConditionMet(managedItem.FindBasicTerm(condition.SourceTerm)))
					return true;
			}
			return false;
		}
		public bool ShouldApplyAction(ManagedItem managedItem)
		{
			if (_quantifier == DependencyQuantifier.Any)
				return AnyConditionMet(managedItem);
			else
				return AllConditionsMet(managedItem);
		}
		public ManagedItemSummary(ManagedItem managedItem)
		{
			_managedItem = managedItem;
		}
        public ExternalTerm(XmlNode termNode, ManagedItem managedItem, Template template, bool isFilter)
            : base(termNode, template, isFilter)
        {
            TermType = TermType.External;
            NameRequired = true;

            XmlNode nodeInterfaceConfig = termNode.SelectSingleNode(XMLNames._E_Config);
            if (nodeInterfaceConfig == null)
                throw new Exception("Config node not found for External Term");
            _interfaceConfig = new ExternalInterfaceConfig(nodeInterfaceConfig);
            _managedItem = managedItem;
            _valuesLoaded = false;
            XmlNode nodeValue = termNode.SelectSingleNode(XMLNames._E_Value);
            if (nodeValue != null)
                _value = Utility.XMLHelper.GetXMLText(Utility.XMLHelper.GetText(nodeValue));
            else
                _value = MakeNameValueXml();
        }
 public static void RemoveGeneratedDocument(ManagedItem sourceManagedItem, string documentID, Utility.DocumentStorageType documentStorageType)
 {
     ILog log = LogManager.GetLogger(sourceManagedItem.GetType());
     try
     {
         Utility.DocumentStorage documentStorageObject = Utility.DocumentStorage.GetDocumentStorageObject(documentStorageType);
         documentStorageObject.DeleteDocument(documentID);
         log.Debug(string.Format("Deleted Generated document {0} from ManagedItem {1} during CreateRetro call", documentID, sourceManagedItem.ItemNumber));
     }
     catch
     {
         //Create a record in the Document table - for later clean up
         Data.Document.DeleteDocument(sourceManagedItem.ManagedItemID, "Generated Document", "Generated Document", documentID, "Generated Document", false, false);
         log.Error(string.Format("Failed to fully delete Generated document {0} from ManagedItem {1} during CreateRetro call", documentID, sourceManagedItem.ItemNumber));
     }
 }
Example #15
0
		//Generate the Terms collection (of Term) based on an xml document
        //Called by BasicTerms.Create, once from ITATSystem.LoadFromDatabase
 		public static List<Term> Create(XmlNode termsNode, ManagedItem managedItem, Template template)
		{
			List<Term> rtn = new List<Term>(termsNode.ChildNodes.Count);
            int order = 0;
			foreach (XmlNode termNode in termsNode)
			{
				Term t = null;
				switch (termNode.Name.ToString())
				{
					case XMLNames._E_Text:
                        t = new TextTerm(termNode, template, false);
						break;
					case XMLNames._E_Date:
                        t = new DateTerm(termNode, template, false);
						break;
					case XMLNames._E_MSO:
                        t = new MSOTerm(termNode, template, false);
						break;
					case XMLNames._E_Link:
                        t = new LinkTerm(termNode, template, false);
						break;
					case XMLNames._E_Facility:
                        t = new FacilityTerm(termNode, template, false);
						break;
					case XMLNames._E_Renewal:
                        t = new RenewalTerm(termNode, managedItem != null, template, false);
						break;
					case XMLNames._E_PickList:
                        t = new PickListTerm(termNode, template, false);
						break;
					case XMLNames._E_External:
                        t = new ExternalTerm(termNode, managedItem, template, false);
						break;
                    case XMLNames._E_PlaceHolderAttachments:
                        t = new PlaceHolderAttachments(termNode, template, false);
                        break;
                    case XMLNames._E_PlaceHolderComments:
                        t = new PlaceHolderComments(termNode, template, false);
                        break;
                    default:
						throw new XmlException(string.Format("Tried to create undefined term type {0}", termNode.Name.ToString()));
				}
                t.Order = order++;
                rtn.Add(t);
			}
            //If this is not a load of the ITATSystem terms, then ensure that the collection includes the Attachments and Comments terms.
            if (template != null)
            {
                List<Term> placeholderTerms = FindTermsOfType(rtn, (TermType.PlaceHolderAttachments | TermType.PlaceHolderComments));
                if (placeholderTerms == null || (placeholderTerms != null && placeholderTerms.Count == 0))
                {
                    //If this is the first time these are being added, then this should be under Basic Security.
                    Term t = new PlaceHolderAttachments(false, template, false);
                    t.TermGroupID = template.BasicSecurityTermGroupID;
                    t.Order = order++;
                    rtn.Add(t);

                    t = new PlaceHolderComments(false, template, false);
                    t.TermGroupID = template.BasicSecurityTermGroupID;
                    t.Order = order++;
                    rtn.Add(t);
                }
                else if (placeholderTerms.Count != 2)
                {
                    throw new Exception(string.Format("Encountered a PlaceHolder term count of {0:D} when 2 were expected", placeholderTerms.Count));
                }
            }
			return rtn;
		}
 /// <summary>
 /// Creates a new instance of a ManagedItem using the specified template where the system uses the OwningFacility concept
 /// </summary>
 /// <param name="template">The template that this ManagedItem is based on</param>
 /// <param name="facilityIds">One or more facilities that this ManagedItem is associated with</param>
 public static ManagedItem CreateRetro(Template template, bool useAlternateTemplate, Guid sourceManagedItemID, bool hasOwningFacility, Utility.DocumentStorageType documentStorageType, out bool returnToDraft)
 {
     ManagedItem sourceManagedItem = Business.ManagedItem.Get(sourceManagedItemID, true);
     ManagedItem newManagedItem = new ManagedItem(template.ID, sourceManagedItem.ManagedItemID);
     newManagedItem.RetroCopy(template, useAlternateTemplate);
     returnToDraft = newManagedItem.Migrate(sourceManagedItem);
     if (returnToDraft)
     {
         //Changed for Multiple Documents
         foreach (ITATDocument doc in sourceManagedItem.Documents)
         {
             if (!string.IsNullOrEmpty(doc.GeneratedDocumentID))
             {
                 RemoveGeneratedDocument(sourceManagedItem, doc.GeneratedDocumentID, documentStorageType);
                 newManagedItem.GetITATDocument(doc.ITATDocumentID).GeneratedDocumentID = null;
             }
         }
     }
     return newManagedItem;
 }
Example #17
0
		public string Send(ManagedItem managedItem, ITATSystem system, string sEnvironment, List<int> owningFacilityIDs)
		{
			//If the subject or body or recipients are empty, then do not send anything
			if ((string.IsNullOrEmpty(Subject)) || (string.IsNullOrEmpty(this.Text)) || (this.Recipients == null) || (this.Recipients.Count == 0))
				return string.Empty;

			string sError = string.Empty;

			string from = null;
			string subject = null;
			string text = null;
			Kindred.Common.Security.NameEmailPair[] emailRecipients = null;

			try
			{
				Kindred.Common.Email.Email email = new Kindred.Common.Email.Email();
				from = XMLNames._M_EmailFrom;
				subject = string.IsNullOrEmpty(Subject) ? "Subject Missing" : Subject;
				text = string.IsNullOrEmpty(Text) ? "Text Missing" : Text;

				Term.SubstituteBasicTerms(managedItem, ref text);
				Term.SubstituteSpecialTerms(ref text, managedItem);

				//Now complete the 'ManagedItemReference' email links - fill in the dynamically supplied info
				if (!string.IsNullOrEmpty(system.Name))
					text = text.Replace(XMLNames._M_SystemNameHolder, system.Name);
				if (!string.IsNullOrEmpty(sEnvironment))
					text = text.Replace(XMLNames._M_EnvironmentHolder, sEnvironment);
				text = text.Replace(XMLNames._M_ManagedItemIdHolder, managedItem.ManagedItemID.ToString());

				List<int> facilityIDs = null;
				if (owningFacilityIDs != null)
					facilityIDs = new List<int>(owningFacilityIDs);
				else
					facilityIDs = new List<int>();
				bool overrideFacilities = false;
				//Note - HasOwningFacility trumps use of filterFacilityTerm
				if (!(system.HasOwningFacility ?? false))
				{
					if (FilterFacilityTermID.HasValue)
					{
						Term filterFacilityTerm = managedItem.FindTerm(FilterFacilityTermID.Value);
						if (filterFacilityTerm != null)
						{
							FacilityTerm facilityTerm = null;
							if (filterFacilityTerm.TermType == TermType.Facility)
								facilityTerm = filterFacilityTerm as FacilityTerm;
							else
								facilityTerm = new FacilityTerm(false, managedItem, filterFacilityTerm);
							if (facilityTerm != null)
							{
								facilityIDs = facilityTerm.SelectedFacilityIDs;
								overrideFacilities = true;
							}
						}
					}
				}

				List<int> allRecipientFacilityIDs = new List<int>();
				
				if ((system.HasOwningFacility ?? false) || overrideFacilities)
				{
					foreach (string recipient in Recipients)
					{
						List<int> absoluteLevels = null;
						List<int> relativeLevels = null;
						system.GetFacilityLevels(recipient, ref absoluteLevels, ref relativeLevels);
						List<int> recipientFacilityIDs = FacilityCollection.FacilityAncestry(facilityIDs, absoluteLevels, relativeLevels);
						foreach (int facilityID in recipientFacilityIDs)
							if (!allRecipientFacilityIDs.Contains(facilityID))
								allRecipientFacilityIDs.Add(facilityID);
					}
					emailRecipients = SecurityHelper.GetEmailRecipients(system, Recipients, allRecipientFacilityIDs);
				}
				else
				{
					emailRecipients = SecurityHelper.GetEmailRecipients(system, Recipients);
				}

				EmailHelper.SendEmail(from, subject, text, emailRecipients, system, Recipients, allRecipientFacilityIDs);
			}
			catch (Exception e)
			{
				sError = string.Format("Email={0} Exception={1}", EmailInfo(from, emailRecipients, subject, text), e.ToString());
			}
			return sError;
		}
 public static void SendNotificationToOwner(ITATSystem system, ManagedItem managedItem, string message, string errorMessage)
 {
     string[] ownerRecipients = system.OwnerEmail.Split(new char[] { ',', '|' }, StringSplitOptions.RemoveEmptyEntries);
     if (ownerRecipients.Length > 0)
     {
         Kindred.Common.Email.Email email = new Kindred.Common.Email.Email();
         foreach (string recipient in ownerRecipients)
             email.AddRecipient(Kindred.Common.Email.EmailRecipientType.To, recipient);
         email.Subject = string.Format("ITAT-{0} -- Unable to send notification for {1} {2}", system.Name, system.ManagedItemName, managedItem.ItemNumber);
         email.From = XMLNames._M_EmailFrom;
         email.Format = Kindred.Common.Email.EmailFormat.Html;
         email.Body = string.Format("<b>ITAT-{0} was unable to send a notification for {1} {2}.<br /><br />{3}</b><br /><br /><br />{4}", system.Name, system.ManagedItemName, managedItem.ItemNumber, errorMessage, message);
         email.ApplicationName = EmailName(system.Name);
         email.Send();
     }
 }
 public override void Migrate(Term term)
 {
     if (term == null)
         base.Migrate(term);
     if (!(term is ExternalTerm))
         return;
     else
     {
         ExternalTerm sourceTerm = term as ExternalTerm;
         _managedItem = sourceTerm._managedItem; //This is okay since we only need the ManagedItemID
         _value = sourceTerm._value;
         _interfaceConfig = sourceTerm._interfaceConfig.Copy();
         SaveValues(false);
         LoadValues();
         term.Runtime.Migrated = true;
     }
     Runtime.Migrated = true;
 }