Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ExportTaxonListExcelFile"/> class.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="exportTaxonItems">The export taxon items.</param>
        /// <param name="fileFormat">The file format.</param>
        public ExportTaxonListExcelFile(
            ExportViewModel options,
            List <ExportTaxonItem> exportTaxonItems,
            ExcelFileFormat fileFormat)
        {
            HttpRequest request;

            _options                 = options;
            _columnCount             = 0;
            _exportTaxonItems        = exportTaxonItems;
            _fileFormat              = fileFormat;
            _genusTaxonCategory      = options.TaxonCategories.Get((Int32)TaxonCategoryId.Genus);
            _parentTaxaCategoryNames = new List <String>();
            _rowCount                = exportTaxonItems.Count + 1;
            _taxonBaseUrl            = "";
            _utf7Encoding            = new UTF7Encoding();
            if (options.OutputTaxonUrl && HttpContext.Current.IsNotNull())
            {
                request       = HttpContext.Current.Request;
                _taxonBaseUrl = request.Url.GetLeftPart(UriPartial.Authority).ToLower() + request.ApplicationPath.ToLower();
                if (!_taxonBaseUrl.EndsWith("/"))
                {
                    _taxonBaseUrl += "/";
                }

                _taxonBaseUrl += @"taxon/info/";
            }
        }
        /// <summary>
        /// Create a new instance of ExportViewModel.
        /// </summary>
        /// <param name="userContext">User context.</param>
        /// <param name="taxon">Output is related to this taxon.</param>
        /// <param name="isHierarchical">
        /// Indicates if output should be a hierarchical or straight list.
        /// </param>
        public static ExportViewModel Create(
            IUserContext userContext,
            ITaxon taxon,
            Boolean isHierarchical)
        {
            ExportViewModel model;

            model = new ExportViewModel();
            model.FilterIsValidTaxon   = true;
            model.IsHierarchical       = isHierarchical;
            model.OutputAuthor         = true;
            model.OutputCommonName     = true;
            model.OutputScientificName = !isHierarchical;
            model.OutputTaxonId        = true;
            model.OutputTaxonUrl       = true;
            model.TaxonId = taxon.Id;
            model.InitSpeciesFacts(userContext);
            model.InitTaxonTree(userContext, taxon);
            model.InitTaxonCategories(userContext, taxon);
            model.InitTaxonNameCategories(userContext);

            if (isHierarchical)
            {
                model.Title      = model.Labels.HierarchicalTitleLabel;
                model.PostAction = "HierarchicalTaxonList";
            }
            else
            {
                model.Title      = model.Labels.TitleLabel;
                model.PostAction = "TaxonList";
            }

            return(model);
        }
Beispiel #3
0
 /// <summary>
 /// Constructor of ExportManager.
 /// </summary>
 public ExportManager(ExportViewModel options, IUserContext userContext)
 {
     _options     = options;
     _userContext = userContext;
 }