/// <summary>
        /// Reades one row from the xml format.
        /// </summary>
        /// <param name='xmlDoc'>The xml document that the row node will be read from.</param>
        /// <param name="nsmgr">Namespacemanager containing all namespaces used by the excel compatible xml format</param>
        protected override void ReadXmlRows(XmlDocument xmlDoc, XmlNamespaceManager nsmgr)
        {
            XmlNodeList rowNodes = xmlDoc.SelectNodes("/ss:Workbook/ss:Worksheet/ss:Table/ss:Row", nsmgr);

            foreach (XmlNode rowNode in rowNodes)
            {
                XmlNode dataNode = rowNode.SelectSingleNode("ss:Cell/ss:Data", nsmgr);
                this.Add(PeriodManager.GetPeriod(Convert.ToInt32(dataNode.InnerText)));
            }
        }
        /// <summary>
        /// Convert an SpeciesFactCondition to a WebSpeciesFactCondition.
        /// </summary>
        /// <param name="speciesFactCondition">The species fact condition.</param>
        /// <returns>A WebSpeciesFactCondition.</returns>
        private static WebSpeciesFactCondition GetSpeciesFactCondition(SpeciesFactCondition speciesFactCondition)
        {
            WebSpeciesFactCondition webSpeciesFactCondition;

            webSpeciesFactCondition = new WebSpeciesFactCondition();

            // Add all factors.
            if (speciesFactCondition.Factors.IsNotEmpty())
            {
                webSpeciesFactCondition.Factors = new List <WebFactor>();
                foreach (Factor factor in speciesFactCondition.Factors)
                {
                    webSpeciesFactCondition.Factors.Add(FactorManager.GetFactor(factor));
                }
            }

            // Add all periods.
            if (speciesFactCondition.Periods.IsNotEmpty())
            {
                webSpeciesFactCondition.Periods = new List <WebPeriod>();
                foreach (Period period in speciesFactCondition.Periods)
                {
                    webSpeciesFactCondition.Periods.Add(PeriodManager.GetPeriod(period));
                }
            }

            // Add all individual categories.
            if (speciesFactCondition.IndividualCategories.IsNotEmpty())
            {
                webSpeciesFactCondition.IndividualCategories = new List <WebIndividualCategory>();
                foreach (IndividualCategory individualCategory in speciesFactCondition.IndividualCategories)
                {
                    webSpeciesFactCondition.IndividualCategories.Add(IndividualCategoryManager.GetIndividualCategory(individualCategory));
                }
            }

            // Add all species fact field conditions.
            if (speciesFactCondition.SpeciesFactFieldConditions.IsNotEmpty())
            {
                webSpeciesFactCondition.SpeciesFactFieldConditions = new List <WebSpeciesFactFieldCondition>();
                foreach (SpeciesFactFieldCondition speciesFactFieldCondition in speciesFactCondition.SpeciesFactFieldConditions)
                {
                    webSpeciesFactCondition.SpeciesFactFieldConditions.Add(GetSpeciesFactFieldCondition(speciesFactFieldCondition));
                }
            }

            return(webSpeciesFactCondition);
        }
        /// <summary>
        /// Creates a species fact instance with data from web service.
        /// </summary>
        /// <param name="id">Id of the species fact</param>
        /// <param name="sortOrder">Sort order of the species fact</param>
        /// <param name="taxon">Taxon of the species fact</param>
        /// <param name="individualCategoryId">Individual Category Id of the species fact</param>
        /// <param name="factorId">Foctor Id of the species fact</param>
        /// <param name="host">Host taxon associated with the species fact</param>
        /// <param name="hasHost">Indicates if this species fact has a host.</param>
        /// <param name="periodId">Period Id of the species fact</param>
        /// <param name="hasPeriod">Indicates if this species fact has a period.</param>
        /// <param name="fieldValue1">Field value of field 1 for the species fact</param>
        /// <param name="hasFieldValue1">Indicates if field 1 has a value.</param>
        /// <param name="fieldValue2">Field value of field 2 for the species fact</param>
        /// <param name="hasFieldValue2">Indicates if field 2 has a value.</param>
        /// <param name="fieldValue3">Field value of field 3 for the species fact</param>
        /// <param name="hasFieldValue3">Indicates if field 3 has a value.</param>
        /// <param name="fieldValue4">Field value of field 4 for the species fact</param>
        /// <param name="hasFieldValue4">Indicates if field 4 has a value.</param>
        /// <param name="fieldValue5">Field value of field 5 for the species fact</param>
        /// <param name="hasFieldValue5">Indicates if field 5 has a value.</param>
        /// <param name="qualityId">Quality Id of the species fact</param>
        /// <param name="referenceId">Reference id of the species fact</param>
        /// <param name="updateUserFullName">Full Name of the pdate user of the species fact</param>
        /// <param name="updateDate">Update date of the species fact</param>
        public SpeciesFact(
            Int32 id,
            Int32 sortOrder,
            Taxon taxon,
            Int32 individualCategoryId,
            Int32 factorId,
            Taxon host,
            Boolean hasHost,
            Int32 periodId,
            Boolean hasPeriod,
            Double fieldValue1,
            Boolean hasFieldValue1,
            Double fieldValue2,
            Boolean hasFieldValue2,
            Double fieldValue3,
            Boolean hasFieldValue3,
            String fieldValue4,
            Boolean hasFieldValue4,
            String fieldValue5,
            Boolean hasFieldValue5,
            Int32 qualityId,
            Int32 referenceId,
            String updateUserFullName,
            DateTime updateDate)
            : base(id, sortOrder)
        {
            Int32 hostId;
            Int32 fieldIndex;

            _fields            = null;
            _substantialFields = null;
            _mainField         = null;
            _hasId             = true;
            hostId             = 0;
            if (hasHost)
            {
                hostId = host.Id;
            }

            _identifier = SpeciesFactManager.GetSpeciesFactIdentifier(
                taxon.Id,
                individualCategoryId,
                factorId,
                hasHost,
                hostId,
                hasPeriod,
                periodId);

            _taxon = taxon;
            _individualCategory = IndividualCategoryManager.GetIndividualCategory(individualCategoryId);
            _factor             = FactorManager.GetFactor(factorId);

            if (hasHost)
            {
                _host    = host;
                _hasHost = hasHost;
            }
            else
            {
                if (_factor.IsTaxonomic)
                {
                    _host = TaxonManager.GetTaxon(0, TaxonInformationType.Basic);
                }
                else
                {
                    _host = null;
                }
                _hasHost = _host.IsNotNull();
            }



            if (hasPeriod)
            {
                _period = PeriodManager.GetPeriod(periodId);
            }
            else
            {
                _period = null;
            }
            _hasPeriod = hasPeriod;

            _quality            = SpeciesFactManager.GetSpeciesFactQuality(qualityId);
            _oldQuality         = _quality;
            _reference          = ReferenceManager.GetReference(referenceId);
            _oldReference       = _reference;
            _updateUserFullName = updateUserFullName;
            _updateDate         = updateDate;
            _hasUpdateDate      = true;

            if (!_factor.FactorUpdateMode.IsHeader)
            {
                _fields            = new SpeciesFactFieldList();
                _substantialFields = new SpeciesFactFieldList();
                _fieldArray        = new SpeciesFactField[FactorManager.GetFactorFieldMaxCount()];
                for (fieldIndex = 0; fieldIndex < FactorManager.GetFactorFieldMaxCount(); fieldIndex++)
                {
                    _fieldArray[fieldIndex] = null;
                }

                foreach (FactorField factorField in _factor.FactorDataType.Fields)
                {
                    Boolean          hasFieldValue;
                    SpeciesFactField field;
                    Object           fieldValue;

                    switch (factorField.Index)
                    {
                    case 0:
                        fieldValue    = fieldValue1;
                        hasFieldValue = hasFieldValue1;
                        break;

                    case 1:
                        fieldValue    = fieldValue2;
                        hasFieldValue = hasFieldValue2;
                        break;

                    case 2:
                        fieldValue    = fieldValue3;
                        hasFieldValue = hasFieldValue3;
                        break;

                    case 3:
                        fieldValue    = fieldValue4;
                        hasFieldValue = hasFieldValue4;
                        break;

                    case 4:
                        fieldValue    = fieldValue5;
                        hasFieldValue = hasFieldValue5;
                        break;

                    default:
                        throw new Exception("Unknown data field!");
                    }

                    field = new SpeciesFactField(this, factorField, hasFieldValue, fieldValue);
                    _fields.Add(field);
                    _fieldArray[field.Index] = field;

                    if (factorField.IsSubstantial)
                    {
                        _substantialFields.Add(field);
                    }

                    if (factorField.IsMain)
                    {
                        _mainField = field;
                    }
                }
            }
            _shouldBeSaved = AllowUpdate;
        }
示例#4
0
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on taxon.
 /// </summary>
 /// <param name="taxon">Taxon.</param>
 public SpeciesEncyclopediaArticle(Taxon taxon)
     : this(taxon, PeriodManager.GetCurrentPublicPeriod())
 {
 }
示例#5
0
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 public SpeciesEncyclopediaArticle(SpeciesFactList speciesFacts)
     : this(speciesFacts, PeriodManager.GetCurrentPublicPeriod())
 {
 }
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on taxon.
 /// </summary>
 /// <param name="taxon">Taxon.</param>
 public SpeciesInformationDocument(Taxon taxon)
     : this(taxon, PeriodManager.GetCurrentPublicPeriod())
 {
 }
 /// <summary>
 /// Creates a instance of a Species Information Document
 /// object based on a list of species facts.
 /// </summary>
 /// <param name="speciesFacts">The species facts related to species information document factors and a single taxon</param>
 public SpeciesInformationDocument(SpeciesFactList speciesFacts)
     : this(speciesFacts, PeriodManager.GetCurrentPublicPeriod())
 {
 }