/// <summary> /// Add parent information. /// </summary> /// <param name="parentTaxonTreeNode">Parent taxon tree node.</param> /// <param name="parentTaxonRelation">Parent taxon tree relation.</param> public void AddParent(TaxonTreeNode parentTaxonTreeNode, WebTaxonRelation parentTaxonRelation) { Int32 parentIndex; if (Parents.IsEmpty() || Parents[Parents.Count - 1].SortOrder <= parentTaxonTreeNode.SortOrder) { // Insert at the end of the lists. if (Parents.IsNull()) { ParentRelations = new List <WebTaxonRelation>(); Parents = new List <TaxonTreeNode>(); } ParentRelations.Add(parentTaxonRelation); Parents.Add(parentTaxonTreeNode); } else { // Insert into the list. for (parentIndex = 0; parentIndex < Parents.Count; parentIndex++) { if (parentTaxonTreeNode.SortOrder < Parents[parentIndex].SortOrder) { ParentRelations.Insert(parentIndex, parentTaxonRelation); Parents.Insert(parentIndex, parentTaxonTreeNode); break; } } } }
/// <summary> /// Add child information. /// </summary> /// <param name="childTaxonTreeNode">Child taxon tree node.</param> /// <param name="childTaxonRelation">Child taxon relation.</param> public void AddChild(TaxonTreeNode childTaxonTreeNode, WebTaxonRelation childTaxonRelation) { Int32 childIndex; if (Children.IsEmpty() || Children[Children.Count - 1].SortOrder <= childTaxonTreeNode.SortOrder) { // Insert at the end of the lists. if (Children.IsNull()) { ChildRelations = new List <WebTaxonRelation>(); Children = new List <TaxonTreeNode>(); } ChildRelations.Add(childTaxonRelation); Children.Add(childTaxonTreeNode); } else { // Insert into the list. for (childIndex = 0; childIndex < Children.Count; childIndex++) { if (childTaxonTreeNode.SortOrder < Children[childIndex].SortOrder) { ChildRelations.Insert(childIndex, childTaxonRelation); Children.Insert(childIndex, childTaxonTreeNode); break; } } } }
/// <summary> /// Load data into the WebTaxon instance. /// </summary> /// <param name='taxonRelation'>TaxonRelation.</param> /// <param name='dataReader'>An open data reader.</param> public static void LoadData(this WebTaxonRelation taxonRelation, DataReader dataReader) { taxonRelation.ChildTaxonId = dataReader.GetInt32(TaxonRelationData.TAXONIDCHILD); taxonRelation.CreatedBy = dataReader.GetInt32(TaxonRelationData.CREATEDBY); taxonRelation.CreatedDate = dataReader.GetDateTime(TaxonRelationData.CREATEDDATE); taxonRelation.Guid = dataReader.GetString(TaxonRelationData.GUID); taxonRelation.Id = dataReader.GetInt32(TaxonRelationData.ID); taxonRelation.IsMainRelation = dataReader.GetBoolean(TaxonRelationData.IS_MAIN_RELATION); taxonRelation.IsPublished = dataReader.GetBoolean(TaxonRelationData.ISPUBLISHED); taxonRelation.ModifiedBy = dataReader.GetInt32(TaxonRelationData.MODIFIEDBY); taxonRelation.SetModifiedByPerson(dataReader.GetString(TaxonRelationData.PERSONNAME)); taxonRelation.ModifiedDate = dataReader.GetDateTime(TaxonRelationData.MODIFIEDDATE); taxonRelation.ParentTaxonId = dataReader.GetInt32(TaxonRelationData.TAXONIDPARENT); taxonRelation.SortOrder = dataReader.GetInt32(TaxonRelationData.SORTORDER); taxonRelation.ValidFromDate = dataReader.GetDateTime(TaxonRelationData.VALIDFROMDATE); taxonRelation.ValidToDate = dataReader.GetDateTime(TaxonRelationData.VALIDTODATE); taxonRelation.IsChangedInTaxonRevisionEventIdSpecified = dataReader.IsNotDbNull(TaxonRelationData.REVISIONEVENTID); if (taxonRelation.IsChangedInTaxonRevisionEventIdSpecified) { taxonRelation.ChangedInTaxonRevisionEventId = dataReader.GetInt32(TaxonRelationData.REVISIONEVENTID); } taxonRelation.IsReplacedInTaxonRevisionEventIdSpecified = dataReader.IsNotDbNull(TaxonRelationData.CHANGEDINREVISIONEVENTID); if (taxonRelation.IsReplacedInTaxonRevisionEventIdSpecified) { taxonRelation.ReplacedInTaxonRevisionEventId = dataReader.GetInt32(TaxonRelationData.CHANGEDINREVISIONEVENTID); } }
/// <summary> /// Set modified by person in WebTaxonRelation. /// </summary> /// <param name='taxonRelation'>Taxon relation.</param> /// <param name='modifiedByPerson'>Modified by person.</param> public static void SetModifiedByPerson(this WebTaxonRelation taxonRelation, String modifiedByPerson) { WebDataField dataField; // Add modified by person as dynamic property. dataField = new WebDataField(); dataField.Name = Settings.Default.WebDataModifiedByPerson; dataField.Type = WebDataType.String; dataField.Value = modifiedByPerson; if (taxonRelation.DataFields.IsNull()) { taxonRelation.DataFields = new List <WebDataField>(); } taxonRelation.DataFields.Add(dataField); }
/// <summary> /// Check the data in current object /// </summary> /// <param name='taxonRelation'>The taxonproperty object.</param> public static void CheckData(this WebTaxonRelation taxonRelation) { if (!taxonRelation.IsDataChecked) { taxonRelation.CheckStrings(); taxonRelation.IsDataChecked = true; if (taxonRelation.ValidFromDate.Equals(DateTime.MinValue)) { taxonRelation.ValidFromDate = DateTime.Now; } if (taxonRelation.ValidToDate.Equals(DateTime.MinValue)) { taxonRelation.ValidToDate = Settings.Default.DefaultValidToDate; } } }
/// <summary> /// Get name of the person that made the last /// modification of this taxon relation. /// </summary> /// <param name='taxonRelation'>Taxon relation.</param> /// <returns>Name of the person that made the last modification of this taxon relation.</returns> public static String GetModifiedByPerson(this WebTaxonRelation taxonRelation) { return(taxonRelation.DataFields.GetString(Settings.Default.WebDataModifiedByPerson)); }