Esempio n. 1
0
        /// <summary>
        /// Adds the scientific name of the taxon.
        /// </summary>
        /// <param name="worksheet">The worksheet.</param>
        /// <param name="taxonItem">The taxon item.</param>
        /// <param name="rowIndex">Index of the row.</param>
        /// <param name="columnIndex">Index of the column.</param>
        private void AddScientificName(
            ExcelWorksheet worksheet,
            ExportTaxonItem taxonItem,
            Int32 rowIndex,
            Int32 columnIndex)
        {
            if ((_options.OutputAuthorInAllNameCells || _options.OutputCommonNameInAllNameCells) &&
                (taxonItem.Taxon.Category.SortOrder >= _genusTaxonCategory.SortOrder))
            {
                using (ExcelRange range = worksheet.Cells[rowIndex, columnIndex])
                {
                    if (!_options.OutputAuthorInAllNameCells && !_options.OutputCommonNameInAllNameCells)
                    {
                        //Måste ändå kolla på synonymer _options.OutputExcludeAuthorForSynonyms
                        range.Value = taxonItem.Taxon.ScientificName;
                    }
                    else
                    {
                        range.IsRichText = true;
                        ExcelRichText ert = range.RichText.Add(taxonItem.Taxon.ScientificName);
                        ert.Italic = true;

                        //Kolla också på synonymer _options.OutputExcludeAuthorForSynonyms
                        if (_options.OutputAuthorInAllNameCells && !string.IsNullOrEmpty(taxonItem.Taxon.Author))
                        {
                            ert        = range.RichText.Add(string.Format(" {0}", taxonItem.Taxon.Author));
                            ert.Italic = false;
                        }

                        if (_options.OutputCommonNameInAllNameCells && !string.IsNullOrEmpty(taxonItem.Taxon.CommonName))
                        {
                            ert        = range.RichText.Add(string.Format(" {0}", taxonItem.Taxon.CommonName));
                            ert.Italic = false;
                        }
                    }
                }
            }
            else
            {
                worksheet.Cells[rowIndex, columnIndex].Value = taxonItem.GetScientificName(
                    _options.OutputAuthorInAllNameCells,
                    _options.OutputCommonNameInAllNameCells);
            }
        }
Esempio n. 2
0
        //private void AddMisappliedNames(ExcelWorksheet worksheet, ExportTaxonItem taxonItem, int rowIndex, int columnIndex)
        //{
        //    if (taxonItem.MisappliedNames.IsEmpty())
        //    {
        //        return;
        //    }

        //    using (ExcelRange range = worksheet.Cells[rowIndex, columnIndex])
        //    {
        //        range.IsRichText = true;
        //        ExcelRichText ert;

        //        for (int i = 0; i < taxonItem.MisappliedNames.Count; i++)
        //        {
        //            TaxonNameViewModel taxonName = taxonItem.MisappliedNames[i];
        //            if (i > 0)
        //            {
        //                ert = range.RichText.Add("; ");
        //                ert.Italic = false;
        //            }

        //            ert = range.RichText.Add(taxonName.Name);
        //            ert.Italic = taxonName.IsScientificName;
        //            if (!string.IsNullOrEmpty(taxonName.Author))
        //            {
        //                ert = range.RichText.Add(string.Format(" {0}", taxonName.Author));
        //                ert.Italic = false;
        //            }
        //        }
        //    }
        //}

        //private void AddProParteSynonyms(ExcelWorksheet worksheet, ExportTaxonItem taxonItem, int rowIndex, int columnIndex)
        //{

        //}

        private void AddNames(List <TaxonNameViewModel> names, ExcelWorksheet worksheet, ExportTaxonItem taxonItem, int rowIndex, int columnIndex)
        {
            if (names.IsEmpty())
            {
                return;
            }

            using (ExcelRange range = worksheet.Cells[rowIndex, columnIndex])
            {
                range.IsRichText = true;
                ExcelRichText ert;

                for (int i = 0; i < names.Count; i++)
                {
                    TaxonNameViewModel taxonName = names[i];
                    if (i > 0)
                    {
                        ert        = range.RichText.Add("; ");
                        ert.Italic = false;
                    }

                    ert        = range.RichText.Add(taxonName.Name);
                    ert.Italic = taxonName.IsScientificName;
                    if (!string.IsNullOrEmpty(taxonName.Author) && (!_options.OutputAuthorForSynonyms))
                    {
                        ert        = range.RichText.Add(string.Format(" {0}", taxonName.Author));
                        ert.Italic = false;
                    }
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Method that generate a list of taxon items with the most basic set of parameters.
        /// </summary>
        /// <returns>Export taxon items.</returns>
        private List <ExportTaxonItem> GetExportTaxonItems()
        {
            Boolean                hasOutputTaxonNames;
            ExportTaxonItem        exportTaxonItem;
            Int32                  index;
            ITaxon                 taxon;
            List <ExportTaxonItem> exportTaxonList;
            List <TaxonNameList>   allTaxonNames = null;

            ArtDatabanken.Data.SpeciesFact speciesFact;
            Stopwatch         stopwatch;
            TaxonCategoryList outputTaxonCategories;
            TaxonList         filteredTaxa;

            stopwatch = new Stopwatch();
            stopwatch.Start();

            exportTaxonList       = new List <ExportTaxonItem>();
            hasOutputTaxonNames   = HasOutputTaxonNames();
            filteredTaxa          = _options.GetFilteredTaxa(this._userContext);
            outputTaxonCategories = _options.GetOutputTaxonCategories();
            if (filteredTaxa.IsNotEmpty())
            {
                if (hasOutputTaxonNames)
                {
                    allTaxonNames = CoreData.TaxonManager.GetTaxonNames(_userContext, filteredTaxa);
                }

                for (index = 0; index < filteredTaxa.Count; index++)
                {
                    taxon           = filteredTaxa[index];
                    exportTaxonItem = new ExportTaxonItem(
                        taxon,
                        _options.GetTaxonTreeNode(taxon),
                        outputTaxonCategories);

                    // Add swedish history information.
                    if (_options.OutputSwedishHistory)
                    {
                        speciesFact = _options.GetSpeciesFact(this._userContext, ArtDatabanken.Data.FactorId.SwedishHistory, exportTaxonItem.Taxon);
                        if (speciesFact.IsNotNull() &&
                            speciesFact.MainField.IsNotNull() &&
                            speciesFact.MainField.EnumValue.IsNotNull())
                        {
                            exportTaxonItem.SwedishHistory = speciesFact.MainField.EnumValue.OriginalLabel;
                        }
                    }

                    // Add swedish occurrence information.
                    if (_options.OutputSwedishOccurrence)
                    {
                        speciesFact = _options.GetSpeciesFact(this._userContext, ArtDatabanken.Data.FactorId.SwedishOccurrence, exportTaxonItem.Taxon);
                        if (speciesFact.IsNotNull() &&
                            speciesFact.MainField.IsNotNull() &&
                            speciesFact.MainField.EnumValue.IsNotNull())
                        {
                            exportTaxonItem.SwedishOccurrence = speciesFact.MainField.EnumValue.OriginalLabel;
                        }
                    }

                    // Add taxon name information.
                    if (hasOutputTaxonNames)
                    {
                        exportTaxonItem.TaxonNames = allTaxonNames[index];
                    }

                    // Synonyms
                    if (_options.OutputSynonyms)
                    {
                        exportTaxonItem.Synonyms = GetSynonyms(taxon);
                    }

                    // Synonyms
                    if (_options.OutputProParteSynonyms)
                    {
                        exportTaxonItem.ProParteSynonyms = GetProParteSynonyms(taxon);
                    }

                    // Synonyms
                    if (_options.OutputMisappliedNames)
                    {
                        exportTaxonItem.MisappliedNames = GetMisappliedNames(taxon);
                    }

                    // Synonyms excl. auktor
                    //if (_options.OutputExcludeAuctor)
                    //{
                    //    //exportTaxonItem.MisappliedNames = GetMisappliedNames(taxon);
                    //}

                    exportTaxonList.Add(exportTaxonItem);
                }
            }

            stopwatch.Stop();
            DyntaxaLogger.WriteMessage("Export: Get all data to populate Excel file: {0:N0} milliseconds", stopwatch.ElapsedMilliseconds);

            return(exportTaxonList);
        }