public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service = new TaxaService(User);

            progress.ProgressStart(String.Format("Preparing Darwin Core records for {0} specimens...", _idSet.Count));

            DataMatrix result = null;
            var idSet = new LinkedList<int>(_idSet);
            int chunkSize = 2000;
            var helper = new DarwinCoreReportHelper();
            var chunk = new List<int>();
            var count = 0;
            while (idSet.Count > 0) {
                chunk.Add(idSet.First.Value);
                idSet.RemoveFirst();
                count++;
                if (chunk.Count >= chunkSize || idSet.Count == 0) {

                    var percentComplete = ((double) count / (double) _idSet.Count) * 100;

                    progress.ProgressMessage(String.Format("Preparing Darwin Core records {0} of {1}", count, _idSet.Count), percentComplete);
                    var where = "tblMaterial.intMaterialID in (" + chunk.Join(",") + ")";
                    var dataChunk = helper.RunDwcQuery(service, where);
                    if (result == null) {
                        result = dataChunk;
                    } else {
                        result.AppendMatrix(dataChunk);
                    }
                    chunk = new List<int>();
                }
            }
            progress.ProgressEnd(String.Format("{0} Darwin Core records retrieved.", count));

            return result;
        }
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service    = new MaterialService(User);
            var filterText = string.Format("Taxon: {0},  {1}: {2}", TaxonID.HasValue && TaxonID.Value > 0 ? TaxonName : "All taxon", ElemType, SiteRegionName);

            return(service.GetTaxaForSites(true, ElemType, SiteRegionID.Value, TaxonID.GetValueOrDefault(-1), filterText));
        }
        public override Data.DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service = new MaterialService(User);

            if (progress != null) {
                progress.ProgressStart(string.Format("Retrieving Material records for Trap {0}", Trap.DisplayLabel), true);
            }

            var serviceMessage = new ServiceMessageDelegate((message) => {
                progress.ProgressMessage(message, 0);
            });

            service.ServiceMessage += serviceMessage;
            DataMatrix matrix = service.GetMaterialForTrap(Trap.ElemID);
            service.ServiceMessage -= serviceMessage;

            if (progress != null) {
                progress.ProgressEnd(string.Format("{0} rows retreived", matrix.Rows.Count));
            }

            matrix.Columns.Add(new FormattedLatLongVirtualColumn(matrix));
            matrix.Columns.Add(new FormattedDateVirtualColumn(matrix));

            return matrix;
        }
Exemple #4
0
        private void LoadPluginsAsync(IProgressObserver monitor, Action finished)
        {
            Debug.Assert(User != null, "User is null!");


            PluginManager.Initialize(this.User, MainWindow.Instance);

            _pluginManager = PluginManager.Instance;

            _pluginManager.RequestShowContent    += new PluginManager.ShowDockableContributionDelegate(_pluginManager_RequestShowContent);
            _pluginManager.DocumentContentAdded  += new PluginManager.AddDockableContentDelegate(_pluginManager_DocumentContentAdded);
            _pluginManager.DockableContentClosed += new PluginManager.CloseDockableContentDelegate(_pluginManager_DockableContentClosed);
            _pluginManager.ProgressEvent         += ProgressObserverAdapter.Adapt(monitor);
            // Debug logging...
            _pluginManager.ProgressEvent += (message, percent, eventType) => { Logger.Debug("<<{2}>> {0} {1}", message, (percent >= 0 ? "(" + percent + "%)" : ""), eventType); return(true); };
            Thread t = new Thread(new ThreadStart(() => {
                this.InvokeIfRequired(() => {
                    this.explorersPane.Width = 0;
                    _pluginManager.LoadPlugins(AddPluginContributions);
                    if (finished != null)
                    {
                        finished();
                    }
                    explorersPane.Width = 180;
                });
            }));

            t.Name = "Plugin Bootstrapper Thread";
            t.TrySetApartmentState(ApartmentState.STA);
            t.Start();
        }
        public TabularDataViewer(IBioLinkReport report, DataMatrix data, IProgressObserver progress)
        {
            InitializeComponent();
            this.Data = data;
            _progress = progress;
            _report = report;
            var view = new GridView();

            var columns = report.DisplayColumns;
            if (columns == null || columns.Count == 0) {
                columns = GenerateDefaultColumns(data);
            }

            var hcs = viewerGrid.Resources["hcs"] as Style;

            foreach (DisplayColumnDefinition c in columns) {
                DisplayColumnDefinition coldef = c;
                var column = new GridViewColumn { Header = BuildColumnHeader(coldef), DisplayMemberBinding = new Binding(String.Format("[{0}]", data.IndexOf(coldef.ColumnName))), HeaderContainerStyle = hcs };
                view.Columns.Add(column);
            }

            lvw.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lvw.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(lvw_MouseRightButtonUp);

            lvw.ItemsSource = Data.Rows;
            this.lvw.View = view;
        }
Exemple #6
0
        public TabularDataViewer(IBioLinkReport report, DataMatrix data, IProgressObserver progress)
        {
            InitializeComponent();
            this.Data = data;
            _progress = progress;
            _report   = report;
            var view = new GridView();

            var columns = report.DisplayColumns;

            if (columns == null || columns.Count == 0)
            {
                columns = GenerateDefaultColumns(data);
            }

            var hcs = viewerGrid.Resources["hcs"] as Style;

            foreach (DisplayColumnDefinition c in columns)
            {
                DisplayColumnDefinition coldef = c;
                var column = new GridViewColumn {
                    Header = BuildColumnHeader(coldef), DisplayMemberBinding = new Binding(String.Format("[{0}]", data.IndexOf(coldef.ColumnName))), HeaderContainerStyle = hcs
                };
                view.Columns.Add(column);
            }

            lvw.AddHandler(ButtonBase.ClickEvent, new RoutedEventHandler(GridViewColumnHeaderClickedHandler));

            lvw.MouseRightButtonUp += new System.Windows.Input.MouseButtonEventHandler(lvw_MouseRightButtonUp);

            lvw.ItemsSource = Data.Rows;
            this.lvw.View   = view;
        }
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            if (progress != null)
            {
                progress.ProgressStart(string.Format("Retrieving Material records for {0}", Taxon.DisplayLabel), true);
            }

            var serviceMessage = new ServiceMessageDelegate((message) => {
                progress.ProgressMessage(message, 0);
            });

            Service.ServiceMessage += serviceMessage;
            DataMatrix matrix = Service.GetMaterialForTaxon(Taxon.TaxaID.Value);

            Service.ServiceMessage -= serviceMessage;

            if (progress != null)
            {
                progress.ProgressEnd(string.Format("{0} rows retreived", matrix.Rows.Count));
            }

            matrix.Columns.Add(new FormattedLatLongVirtualColumn(matrix));
            matrix.Columns.Add(new FormattedDateVirtualColumn(matrix));

            return(matrix);
        }
Exemple #8
0
 public void Export(Window parentWindow, DataMatrix matrix, String datasetName, IProgressObserver progress)
 {
     this.ProgressObserver = progress;
     object options = GetOptions(parentWindow, matrix, datasetName);
     JobExecutor.QueueJob(() => {
         this.ExportImpl(parentWindow, matrix, datasetName, options);
         ProgressEnd("");
     });
 }
Exemple #9
0
        public AssociateReportsViewer(IBioLinkReport report, DataMatrix data, IProgressObserver progress)
        {
            InitializeComponent();
            this.Report     = report;
            this.DataMatrix = data;
            this.Progress   = progress;

            Loaded += new RoutedEventHandler(AssociateReportsViewer_Loaded);
        }
Exemple #10
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null)
            {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;

            using (var parser = new GenericParserAdapter(_options.Filename)) {
                parser.ColumnDelimiter   = _options.Delimiter[0];
                parser.FirstRowHasHeader = _options.FirstRowContainsNames;
                parser.TextQualifier     = '\"';
                parser.FirstRowSetsExpectedColumnCount = true;

                var service     = new ImportStagingService();
                var columnNames = new List <String>();

                int rowCount = 0;
                service.BeginTransaction();
                var values = new List <string>();
                while (parser.Read())
                {
                    if (rowCount == 0)
                    {
                        for (int i = 0; i < parser.ColumnCount; ++i)
                        {
                            if (_options.FirstRowContainsNames)
                            {
                                columnNames.Add(parser.GetColumnName(i));
                            }
                            else
                            {
                                columnNames.Add("Column" + i);
                            }
                        }
                        service.CreateImportTable(columnNames);
                    }

                    values.Clear();
                    for (int i = 0; i < parser.ColumnCount; ++i)
                    {
                        values.Add(parser[i]);
                    }

                    service.InsertImportRow(values);

                    rowCount++;
                }

                service.CommitTransaction();

                rowsource = new ImportRowSource(service, rowCount);
            }

            return(rowsource);
        }
Exemple #11
0
        public void Export(Window parentWindow, DataMatrix matrix, String datasetName, IProgressObserver progress)
        {
            this.ProgressObserver = progress;
            object options = GetOptions(parentWindow, matrix, datasetName);

            JobExecutor.QueueJob(() => {
                this.ExportImpl(parentWindow, matrix, datasetName, options);
                ProgressEnd("");
            });
        }
Exemple #12
0
 public override ImportRowSource CreateRowSource(IProgressObserver progress)
 {
     if (_options != null) {
         if (_options.RowSource == null) {
             var builder = new BVPImportSourceBuilder(_options.Filename);
             _options.RowSource = builder.BuildRowSource();
         }
         return _options.RowSource;
     }
     return null;
 }
 public void Subscribe(IProgressObserver progressObserver)
 {
     if (MainScope == null)
     {
         _mainProgressObservers.Add(progressObserver);
     }
     else
     {
         MainScope.Subscribe(progressObserver);
     }
 }
 public override ImportRowSource CreateRowSource(IProgressObserver progress)
 {
     if (_options != null)
     {
         if (_options.RowSource == null)
         {
             var builder = new BVPImportSourceBuilder(_options.Filename);
             _options.RowSource = builder.BuildRowSource();
         }
         return(_options.RowSource);
     }
     return(null);
 }
Exemple #15
0
        public ExportData(DataMatrix data, string dataSetName, IProgressObserver progress)
        {
            InitializeComponent();
            _data = data;
            _dataSetName = dataSetName;
            _progress = progress;
            var candidates = PluginManager.Instance.GetExtensionsOfType<TabularDataExporter>();
            var exporters = candidates.FindAll((exporter) => {
                return exporter.CanExport(data, dataSetName);
            });

            listBox.ItemsSource = exporters;
        }
        public ExportData(DataMatrix data, string dataSetName, IProgressObserver progress)
        {
            InitializeComponent();
            _data        = data;
            _dataSetName = dataSetName;
            _progress    = progress;
            var candidates = PluginManager.Instance.GetExtensionsOfType <TabularDataExporter>();
            var exporters  = candidates.FindAll((exporter) => {
                return(exporter.CanExport(data, dataSetName));
            });

            listBox.ItemsSource = exporters;
        }
        public override Data.DataMatrix ExtractReportData(IProgressObserver progress)
        {
            DataMatrix results = null;

            switch (ObjectType)
            {
            case TraitCategoryType.Taxon:
                results = AddMediaForTaxon(Target.ObjectID.Value, progress);
                break;
            }

            return(results);
        }
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null)
            {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;
            var             service   = new ImportStagingService();
            int             rowCount  = 0;
            var             values    = new List <string>();

            if (progress != null)
            {
                progress.ProgressMessage(String.Format("Importing data - Stage 1 Connecting to input source...", rowCount));
            }

            WithExcelWorksheetRows(_options.Filename, _options.Worksheet, 0, row => {
                if (rowCount == 0)
                {
                    var columnNames = new List <String>();
                    foreach (DataColumn column in row.Table.Columns)
                    {
                        columnNames.Add(column.ColumnName);
                    }
                    service.CreateImportTable(columnNames);
                    service.BeginTransaction();
                }
                values.Clear();
                foreach (DataColumn col in row.Table.Columns)
                {
                    var value = row[col];
                    values.Add((value == null ? "" : value.ToString()));
                }
                service.InsertImportRow(values);
                if (++rowCount % 1000 == 0)
                {
                    if (progress != null)
                    {
                        progress.ProgressMessage(String.Format("Importing data - Stage 1 {0} rows copied to staging database...", rowCount));
                    }
                }
                ;
            });

            service.CommitTransaction();
            rowsource = new ImportRowSource(service, rowCount);
            return(rowsource);
        }
Exemple #19
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null) {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;

            using (var parser = new GenericParserAdapter(_options.Filename)) {
                parser.ColumnDelimiter = _options.Delimiter[0];
                parser.FirstRowHasHeader = _options.FirstRowContainsNames;
                parser.TextQualifier = '\"';
                parser.FirstRowSetsExpectedColumnCount = true;

                var service = new ImportStagingService();
                var columnNames = new List<String>();

                int rowCount = 0;
                service.BeginTransaction();
                var values = new List<string>();
                while (parser.Read()) {
                    if (rowCount == 0) {
                        for (int i = 0; i < parser.ColumnCount; ++i) {
                            if (_options.FirstRowContainsNames) {
                                columnNames.Add(parser.GetColumnName(i));
                            } else {
                                columnNames.Add("Column" + i);
                            }
                        }
                        service.CreateImportTable(columnNames);
                    }

                    values.Clear();
                    for (int i = 0; i < parser.ColumnCount; ++i) {
                        values.Add(parser[i]);
                    }

                    service.InsertImportRow(values);

                    rowCount++;
                }

                service.CommitTransaction();

                rowsource = new ImportRowSource(service, rowCount);
            }

            return rowsource;
        }
        protected override List <RefLink> SelectReferences(IProgressObserver progress)
        {
            var service     = new SupportService(User);
            var taxaService = new TaxaService(User);

            if (progress != null)
            {
                progress.ProgressMessage("Retrieving Reference links...");
            }
            var reflinks = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), Taxon.TaxaID.Value);

            if (Options.IncludeChildReferences == true)
            {
                var children = taxaService.GetExpandFullTree(Taxon.TaxaID.Value);

                var elementCount = 0;
                int total        = children.Count;

                if (progress != null)
                {
                    progress.ProgressStart("Extracting references for children...");
                }

                foreach (Taxon child in children)
                {
                    if (progress != null)
                    {
                        double percent = (((double)elementCount) / ((double)total)) * 100.0;
                        progress.ProgressMessage(string.Format("Processing {0}", child.TaxaFullName), percent);
                    }
                    elementCount++;

                    var links = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), child.TaxaID.Value);
                    foreach (RefLink link in links)
                    {
                        reflinks.Add(link);
                    }
                }

                if (progress != null)
                {
                    progress.ProgressEnd("");
                }
            }

            return(reflinks);
        }
Exemple #21
0
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var types = new string[] { "Site", "SiteVisit", "Material" };

            progress.ProgressMessage("Extracting site data...");
            var siteData = ExecuteLabelSetQuery(Items, Criteria, "Site");

            progress.ProgressMessage("Extracting site visit data...");
            var visitData = ExecuteLabelSetQuery(Items, Criteria, "SiteVisit");

            progress.ProgressMessage("Extracting material data...");
            var materialData = ExecuteLabelSetQuery(Items, Criteria, "Material");

            progress.ProgressMessage("Merging results...");

            return MergeItemMatrices(siteData, visitData, materialData);
        }
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var types = new string[] { "Site", "SiteVisit", "Material" };

            progress.ProgressMessage("Extracting site data...");
            var siteData = ExecuteLabelSetQuery(Items, Criteria, "Site");

            progress.ProgressMessage("Extracting site visit data...");
            var visitData = ExecuteLabelSetQuery(Items, Criteria, "SiteVisit");

            progress.ProgressMessage("Extracting material data...");
            var materialData = ExecuteLabelSetQuery(Items, Criteria, "Material");

            progress.ProgressMessage("Merging results...");

            return(MergeItemMatrices(siteData, visitData, materialData));
        }
        public void ExportXML(List <int> taxonIds, XMLIOExportOptions options, IProgressObserver progress, Func <bool> isCancelledCallback)
        {
            try {
                if (progress != null)
                {
                    progress.ProgressStart("Counting total taxa to export...");
                }

                var exporter = new XMLIOExporter(User, taxonIds, options, progress, isCancelledCallback);

                exporter.Export();
            } finally {
                if (progress != null)
                {
                    progress.ProgressEnd("Export complete.");
                }
            }
        }
Exemple #24
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            var errorSource = new ImportStagingService(_options.Filename);

            var service = new ImportStagingService();
            service.CreateImportTable(_columnNames);
            int rowcount = 0;
            var reader = errorSource.GetErrorReader();

            while (reader.Read()) {
                var values = new List<String>();
                for (int i = 0; i < reader.FieldCount - 1; ++i) {
                    var val = reader[i];
                    values.Add(val == null ? null : val.ToString());
                }
                service.InsertImportRow(values);
                rowcount++;
            }

            return new ImportRowSource(service, rowcount);
        }
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service = new TaxaService(User);

            progress.ProgressStart(String.Format("Preparing Darwin Core records for {0} specimens...", _idSet.Count));

            DataMatrix result    = null;
            var        idSet     = new LinkedList <int>(_idSet);
            int        chunkSize = 2000;
            var        helper    = new DarwinCoreReportHelper();
            var        chunk     = new List <int>();
            var        count     = 0;

            while (idSet.Count > 0)
            {
                chunk.Add(idSet.First.Value);
                idSet.RemoveFirst();
                count++;
                if (chunk.Count >= chunkSize || idSet.Count == 0)
                {
                    var percentComplete = ((double)count / (double)_idSet.Count) * 100;

                    progress.ProgressMessage(String.Format("Preparing Darwin Core records {0} of {1}", count, _idSet.Count), percentComplete);
                    var where = "tblMaterial.intMaterialID in (" + chunk.Join(",") + ")";
                    var dataChunk = helper.RunDwcQuery(service, where);
                    if (result == null)
                    {
                        result = dataChunk;
                    }
                    else
                    {
                        result.AppendMatrix(dataChunk);
                    }
                    chunk = new List <int>();
                }
            }
            progress.ProgressEnd(String.Format("{0} Darwin Core records retrieved.", count));

            return(result);
        }
Exemple #26
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null)
            {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;

            var columnNames = GetColumnNames();
            var service     = new ImportStagingService();

            service.CreateImportTable(columnNames);

            if (WithWorksheetDataTable(_options.Filename, string.Format("SELECT * FROM [{0}]", _options.Worksheet), (dt) => {
                service.BeginTransaction();
                var values = new List <string>();
                int rowcount = 0;
                foreach (DataRow row in dt.Rows)
                {
                    values.Clear();
                    foreach (DataColumn col in dt.Columns)
                    {
                        var value = row[col];
                        values.Add((value == null ? "" : value.ToString()));
                    }
                    service.InsertImportRow(values);
                    rowcount++;
                }

                service.CommitTransaction();

                rowsource = new ImportRowSource(service, rowcount);
            }))
            {
                return(rowsource);
            }

            return(null);
        }
Exemple #27
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            var errorSource = new ImportStagingService(_options.Filename);

            var service = new ImportStagingService();

            service.CreateImportTable(_columnNames);
            int rowcount = 0;
            var reader   = errorSource.GetErrorReader();

            while (reader.Read())
            {
                var values = new List <String>();
                for (int i = 0; i < reader.FieldCount - 1; ++i)
                {
                    var val = reader[i];
                    values.Add(val == null ? null : val.ToString());
                }
                service.InsertImportRow(values);
                rowcount++;
            }

            return(new ImportRowSource(service, rowcount));
        }
Exemple #28
0
        public override Data.DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var service = new TaxaService(User);

            return(service.TaxaForDistributionRegionReport(DistributionRegion.DistRegionID, TaxonID));
        }
Exemple #29
0
 protected abstract List<RefLink> SelectReferences(IProgressObserver progress);
Exemple #30
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     var service = new SupportService(User);
     return service.GetUserStatisticsReport(Username, StartDate, EndDate);
 }
 public override Data.DataMatrix ExtractReportData(IProgressObserver progress)
 {
     var service = new TaxaService(User);
     return service.TaxaForDistributionRegionReport(DistributionRegion.DistRegionID, TaxonID);
 }
Exemple #32
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null) {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;
            var service = new ImportStagingService();
            int rowCount = 0;
            var values = new List<string>();

            if (progress != null) {
                progress.ProgressMessage(String.Format("Importing data - Stage 1 Connecting to input source...", rowCount));
            }

            WithExcelWorksheetRows(_options.Filename, _options.Worksheet, 0, row => {
                if (rowCount == 0) {
                    var columnNames = new List<String>();
                    foreach (DataColumn column in row.Table.Columns) {
                        columnNames.Add(column.ColumnName);
                    }
                    service.CreateImportTable(columnNames);
                    service.BeginTransaction();
                }
                values.Clear();
                foreach (DataColumn col in row.Table.Columns) {
                    var value = row[col];
                    values.Add((value == null ? "" : value.ToString()));
                }
                service.InsertImportRow(values);
                if (++rowCount % 1000 == 0) {
                    if (progress != null) {
                        progress.ProgressMessage(String.Format("Importing data - Stage 1 {0} rows copied to staging database...", rowCount));
                    }
                };
            });

            service.CommitTransaction();
            rowsource = new ImportRowSource(service, rowCount);
            return rowsource;
        }
Exemple #33
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     var service = new MaterialService(User);
     var filterText = string.Format("Taxon: {0},  {1}: {2}", TaxonID.HasValue && TaxonID.Value > 0 ? TaxonName : "All taxon", ElemType, SiteRegionName);
     return service.GetTaxaForSites(true, ElemType, SiteRegionID.Value, TaxonID.GetValueOrDefault(-1), filterText);
 }
        private DataMatrix AddMediaForTaxon(int taxonId, IProgressObserver progress)
        {
            var results = new DataMatrix();

            results.Columns.Add(new MatrixColumn {
                Name = "MultimediaID", IsHidden = true
            });
            results.Columns.Add(new MatrixColumn {
                Name = "TaxonID", IsHidden = true
            });
            results.Columns.Add(new MatrixColumn {
                Name = "MultimediaLink", IsHidden = true
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Taxon name"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Rank"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Multimedia Name"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Extension"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Multimedia Type"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Size"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "Attached To"
            });
            results.Columns.Add(new MatrixColumn {
                Name = "MaterialID", IsHidden = true
            });

            if (progress != null)
            {
                progress.ProgressMessage("Extracting multimedia details for item...");
            }

            // First add the multimedia for this item
            var links = SupportService.GetMultimediaItems(TraitCategoryType.Taxon.ToString(), taxonId);
            var taxon = TaxaService.GetTaxon(taxonId);

            foreach (MultimediaLink link in links)
            {
                AddTaxonRow(results, taxon, link);
            }

            if (_includeMaterial)
            {
                AddMaterialRowsForTaxon(results, taxon);
            }

            if (_recurse)
            {
                // Now find all the children of this item
                if (progress != null)
                {
                    progress.ProgressMessage("Retrieving child items...");
                }

                var children = TaxaService.GetExpandFullTree(taxonId);

                var elementCount = 0;
                int total        = children.Count;

                if (progress != null)
                {
                    progress.ProgressStart("Extracting multimedia for children...");
                }

                foreach (Taxon child in children)
                {
                    if (progress != null)
                    {
                        double percent = (((double)elementCount) / ((double)total)) * 100.0;
                        progress.ProgressMessage(string.Format("Processing {0}", child.TaxaFullName), percent);
                    }
                    elementCount++;

                    links = SupportService.GetMultimediaItems(TraitCategoryType.Taxon.ToString(), child.TaxaID.Value);
                    foreach (MultimediaLink link in links)
                    {
                        AddTaxonRow(results, child, link);
                    }

                    if (_includeMaterial)
                    {
                        AddMaterialRowsForTaxon(results, child);
                    }
                }
            }

            if (progress != null)
            {
                progress.ProgressEnd(string.Format("{0} multimedia items found.", results.Rows.Count));
            }


            return(results);
        }
Exemple #35
0
 public abstract ImportRowSource CreateRowSource(IProgressObserver progress);
Exemple #36
0
        public System.Windows.FrameworkElement ConstructView(IBioLinkReport report, DataMatrix reportData, IProgressObserver progress)
        {
            var options = (report as ReferenceLinksReport).Options;

            var viewer = new RTFReportViewer {ReportName = report.Name};
            var rtf = new RTFReportBuilder();
            rtf.AppendFullHeader();
            rtf.ReportHeading(options.BibliographyTitle);

            var idx = 1;
            var colIndex = reportData.IndexOf("RefID");

            var refIds = new List<Int32>();
            for (var i = 0; i < reportData.Rows.Count; ++i ) {
                refIds.Add(i);
            }

            int sortColumnIdx = reportData.IndexOf(options.SortColumn);
            int refTypeIndex = reportData.IndexOf("RefType");
            refIds.Sort((idx1, idx2) => {
                            // If grouping, first check the ref type
                            if (options.GroupByReferenceType) {
                                var refType1 = reportData.Rows[idx1][refTypeIndex] as String;
                                var refType2 = reportData.Rows[idx2][refTypeIndex] as String;
                                if (!refType1.Equals(refType2)) {
                                    return String.Compare(refType1, refType2, true);
                                }
                            }

                            // then by the nominated sort column
                            var objVal1 = reportData.Rows[idx1][sortColumnIdx];
                            var objVal2 = reportData.Rows[idx2][sortColumnIdx];
                            var val1 = RTFUtils.StripMarkup(objVal1 == null ? "" : objVal1.ToString());
                            var val2 = RTFUtils.StripMarkup(objVal2 == null ? "" : objVal2.ToString());

                            if (options.SortAscending) {
                                return String.Compare((String)val1, (String)val2, true);
                            } else {
                                return String.Compare((String)val2, (String)val1, true);
                            }
                        });

            var lastRefType = "";
            String[] allowedKeywords = { "b", "i", "sub", "super", "strike", "ul", "ulnone", "nosupersub" };
            foreach (var rowIdx in refIds) {
                var row = reportData.Rows[rowIdx];

                if (options.GroupByReferenceType) {
                    var refType = row["RefType"] as String;
                    if (!String.Equals(refType, lastRefType, StringComparison.CurrentCultureIgnoreCase)) {
                        rtf.Par();
                        rtf.Append(@" \pard\fs24\b\f1 ");
                        rtf.Append(refType);
                        rtf.Append(@" \b0");
                        rtf.Par();
                        lastRefType = refType;
                    }
                }

                rtf.Par();
                rtf.Append(@" \pard\fs20\f1 ");
                if (options.BibliographyIndexStyle != BibliographyIndexStyle.None) {
                    rtf.Append("[");
                    switch (options.BibliographyIndexStyle) {
                        case BibliographyIndexStyle.Number:
                            rtf.Append(idx);
                            break;
                        case BibliographyIndexStyle.RefCode:
                            rtf.Append(row["RefCode"]);
                            break;
                    }
                    rtf.Append("] ");
                }
                idx++;

                var fullRTF = RTFUtils.filter(row["FullRTF"] as string, true, false, allowedKeywords);
                rtf.Append(fullRTF);

                var bits = new List<String>();
                if (!String.IsNullOrWhiteSpace(row["LinkPage"] as String)) {
                    bits.Add(String.Format("page {0}", row["LinkPage"] as String));
                }

                if (options.IncludeQualification) {
                    var qual = row["LinkQualificationRTF"] as string;
                    if (!String.IsNullOrEmpty(qual)  ) {
                        bits.Add(RTFUtils.filter(qual, true, true, allowedKeywords).Trim());
                    }
                }

                if (bits.Count > 0) {
                    rtf.Append(" (").Append(bits.Join("; ").Trim()).Append(")");
                }

                rtf.Par();
            }

            Console.WriteLine(rtf.RTF);

            viewer.rtf.Rtf = rtf.RTF;

            return viewer;
        }
Exemple #37
0
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            String caption = String.Format("Taxon: {0}, {1}", Taxon.TaxaFullName, RegionID < 0 ? "All regions." : RegionName);

            return(Service.TaxaForSites(RegionID, Taxon.TaxaID.Value, "Region", caption, true));
        }
Exemple #38
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     String caption = String.Format("Taxon: {0}, {1}", Taxon.TaxaFullName, RegionID < 0 ? "All regions." : RegionName);
     return Service.TaxaForSites(RegionID, Taxon.TaxaID.Value, "Region", caption, true);
 }
Exemple #39
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     return Service.GetTaxonTypes(Taxon.TaxaID.Value);
 }
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            DataMatrix table = Service.GetStatistics(Taxon.TaxaID.Value);

            return(table);
        }
Exemple #41
0
        protected override List<RefLink> SelectReferences(IProgressObserver progress)
        {
            var service = new SupportService(User);
            var taxaService = new TaxaService(User);
            if (progress != null) {
                progress.ProgressMessage("Retrieving Reference links...");
            }
            var reflinks = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), Taxon.TaxaID.Value);
            if (Options.IncludeChildReferences == true) {
                var children = taxaService.GetExpandFullTree(Taxon.TaxaID.Value);

                var elementCount = 0;
                int total = children.Count;

                if (progress != null) {
                    progress.ProgressStart("Extracting references for children...");
                }

                foreach (Taxon child in children) {

                    if (progress != null) {
                        double percent = (((double)elementCount) / ((double)total)) * 100.0;
                        progress.ProgressMessage(string.Format("Processing {0}", child.TaxaFullName), percent);
                    }
                    elementCount++;

                    var links = service.GetReferenceLinks(TraitCategoryType.Taxon.ToString(), child.TaxaID.Value);
                    foreach (RefLink link in links) {
                        reflinks.Add(link);
                    }
                }

                if (progress != null) {
                    progress.ProgressEnd("");
                }

            }

            return reflinks;
        }
Exemple #42
0
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var matrix = new DataMatrix();

            var service = new SupportService(User);

            matrix.Columns.Add(new MatrixColumn {
                Name = IntraCategoryIdColumnName, IsHidden = true
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "RefID", IsHidden = true
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "RefCode"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "RefType"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "LinkPage"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "LinkQualification"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "LinkQualificationRTF", IsHidden = true
            });

            matrix.Columns.Add(new MatrixColumn {
                Name = "Title"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Author"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "BookTitle"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Edition"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Editor"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "StartPage"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "EndPage"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "ActualDate"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "ISBN"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "ISSN"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalID", IsHidden = true
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "PartNo"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Place"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Possess"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Publisher"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "RefType"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Series"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "Source"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "FullText"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "FullRTF", IsHidden = true
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalAbbrevName"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalAbbrevName2"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalAlias"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalFullName"
            });
            matrix.Columns.Add(new MatrixColumn {
                Name = "JournalNotes"
            });

            var reflinks = SelectReferences(progress);

            progress.ProgressMessage("Preparing view model...");
            foreach (RefLink link in reflinks)
            {
                if (Options.HonourIncludeInReportsFlag)
                {
                    if (!link.UseInReport.HasValue || !link.UseInReport.Value)
                    {
                        // skip this one as it hasn't got the use in reports flag set.
                        continue;
                    }
                }

                var reference = service.GetReference(link.RefID);
                if (reference != null)
                {
                    int i   = 0;
                    var row = matrix.AddRow();
                    row[i++] = link.IntraCatID.Value;
                    row[i++] = link.RefID;
                    row[i++] = reference.RefCode;
                    row[i++] = link.RefLinkType;
                    row[i++] = link.RefPage;
                    row[i++] = RTFUtils.StripMarkup(link.RefQual);
                    row[i++] = link.RefQual;


                    row[i++] = RTFUtils.StripMarkup(reference.Title);
                    row[i++] = reference.Author;
                    row[i++] = RTFUtils.StripMarkup(reference.BookTitle);
                    row[i++] = reference.Edition;
                    row[i++] = reference.Editor;
                    row[i++] = reference.StartPage;
                    row[i++] = reference.EndPage;
                    row[i++] = SupportService.FormatDate(reference.ActualDate, "yyyy-MM-dd");
                    row[i++] = reference.ISBN;
                    row[i++] = reference.ISSN;
                    row[i++] = reference.JournalID;
                    row[i++] = reference.PartNo;
                    row[i++] = reference.Place;
                    row[i++] = reference.Possess;
                    row[i++] = reference.Publisher;
                    row[i++] = reference.RefType;
                    row[i++] = reference.Series;
                    row[i++] = reference.Source;
                    row[i++] = reference.FullText;
                    row[i++] = reference.FullRTF;

                    if (reference.JournalID.HasValue && reference.JournalID.Value > 0)
                    {
                        var journal = service.GetJournal(reference.JournalID.Value);
                        row[i++] = journal.AbbrevName;
                        row[i++] = journal.AbbrevName2;
                        row[i++] = journal.Alias;
                        row[i++] = journal.FullName;
                        row[i++] = journal.Notes;
                    }
                }
            }

            progress.ProgressMessage("");

            return(matrix);
        }
Exemple #43
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     DataMatrix table = Service.GetStatistics(Taxon.TaxaID.Value);
     return table;
 }
Exemple #44
0
        public override DataMatrix ExtractReportData(IProgressObserver progress)
        {
            var matrix = new DataMatrix();

            var service = new SupportService(User);

            matrix.Columns.Add(new MatrixColumn { Name = IntraCategoryIdColumnName, IsHidden = true });
            matrix.Columns.Add(new MatrixColumn { Name = "RefID", IsHidden = true });
            matrix.Columns.Add(new MatrixColumn { Name = "RefCode" });
            matrix.Columns.Add(new MatrixColumn { Name = "RefType" });
            matrix.Columns.Add(new MatrixColumn { Name = "LinkPage" });
            matrix.Columns.Add(new MatrixColumn { Name = "LinkQualification" });
            matrix.Columns.Add(new MatrixColumn { Name = "LinkQualificationRTF", IsHidden = true });

            matrix.Columns.Add(new MatrixColumn { Name = "Title" });
            matrix.Columns.Add(new MatrixColumn { Name = "Author" });
            matrix.Columns.Add(new MatrixColumn { Name = "BookTitle" });
            matrix.Columns.Add(new MatrixColumn { Name = "Edition" });
            matrix.Columns.Add(new MatrixColumn { Name = "Editor" });
            matrix.Columns.Add(new MatrixColumn { Name = "StartPage" });
            matrix.Columns.Add(new MatrixColumn { Name = "EndPage" });
            matrix.Columns.Add(new MatrixColumn { Name = "ActualDate" });
            matrix.Columns.Add(new MatrixColumn { Name = "ISBN" });
            matrix.Columns.Add(new MatrixColumn { Name = "ISSN" });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalID", IsHidden = true });
            matrix.Columns.Add(new MatrixColumn { Name = "PartNo" });
            matrix.Columns.Add(new MatrixColumn { Name = "Place" });
            matrix.Columns.Add(new MatrixColumn { Name = "Possess" });
            matrix.Columns.Add(new MatrixColumn { Name = "Publisher" });
            matrix.Columns.Add(new MatrixColumn { Name = "RefType" });
            matrix.Columns.Add(new MatrixColumn { Name = "Series" });
            matrix.Columns.Add(new MatrixColumn { Name = "Source" });
            matrix.Columns.Add(new MatrixColumn { Name = "FullText" });
            matrix.Columns.Add(new MatrixColumn { Name = "FullRTF", IsHidden = true });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalAbbrevName" });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalAbbrevName2" });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalAlias" });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalFullName" });
            matrix.Columns.Add(new MatrixColumn { Name = "JournalNotes" });

            var reflinks = SelectReferences(progress);

            progress.ProgressMessage("Preparing view model...");
            foreach (RefLink link in reflinks) {

                if (Options.HonourIncludeInReportsFlag) {
                    if (!link.UseInReport.HasValue || !link.UseInReport.Value) {
                        // skip this one as it hasn't got the use in reports flag set.
                        continue;
                    }
                }

                var reference = service.GetReference(link.RefID);
                if (reference != null) {
                    int i = 0;
                    var row = matrix.AddRow();
                    row[i++] = link.IntraCatID.Value;
                    row[i++] = link.RefID;
                    row[i++] = reference.RefCode;
                    row[i++] = link.RefLinkType;
                    row[i++] = link.RefPage;
                    row[i++] = RTFUtils.StripMarkup(link.RefQual);
                    row[i++] = link.RefQual;

                    row[i++] = RTFUtils.StripMarkup(reference.Title);
                    row[i++] = reference.Author;
                    row[i++] = RTFUtils.StripMarkup(reference.BookTitle);
                    row[i++] = reference.Edition;
                    row[i++] = reference.Editor;
                    row[i++] = reference.StartPage;
                    row[i++] = reference.EndPage;
                    row[i++] = SupportService.FormatDate(reference.ActualDate, "yyyy-MM-dd");
                    row[i++] = reference.ISBN;
                    row[i++] = reference.ISSN;
                    row[i++] = reference.JournalID;
                    row[i++] = reference.PartNo;
                    row[i++] = reference.Place;
                    row[i++] = reference.Possess;
                    row[i++] = reference.Publisher;
                    row[i++] = reference.RefType;
                    row[i++] = reference.Series;
                    row[i++] = reference.Source;
                    row[i++] = reference.FullText;
                    row[i++] = reference.FullRTF;

                    if (reference.JournalID.HasValue && reference.JournalID.Value > 0) {
                        var journal = service.GetJournal(reference.JournalID.Value);
                        row[i++] = journal.AbbrevName;
                        row[i++] = journal.AbbrevName2;
                        row[i++] = journal.Alias;
                        row[i++] = journal.FullName;
                        row[i++] = journal.Notes;
                    }
                }
            }

            progress.ProgressMessage("");

            return matrix;
        }
Exemple #45
0
        public void Import(Window parentWindow, ImportWizardContext context, IProgressObserver progress, Action <ImportStatusLevel, string> logFunc)
        {
            this.ParentWindow = parentWindow;
            this.Importer     = context.Importer;
            this.Mappings     = context.FieldMappings;
            this.Progress     = progress;
            this.LogFunc      = logFunc;


            if (Progress != null)
            {
                Progress.ProgressStart("Initialising...");
            }

            if (!InitImport())
            {
                return;
            }

            ProgressMsg("Importing data - Stage 1", 0);
            if (!DoStage1())
            {
                return;
            }

            CreateColumnIndexes();


            Cancelled = false;

            var connection = User.GetConnection();

            LogMsg("Importing data - Stage 2", 10);
            int rowCount    = 0;
            int lastPercent = 0;

            DateTime timeStarted = DateTime.Now;
            DateTime lastCheck   = timeStarted;

            RowSource.Reset();

            while (RowSource.MoveNext() && !Cancelled)
            {
                ImportCurrentRow(rowCount++, connection);

                var dblPercent = (double)((double)rowCount / (double)RowSource.RowCount) * 90;
                int percent    = ((int)dblPercent) + 10;

                var timeSinceLastUpdate = DateTime.Now - lastCheck;

                if (percent != lastPercent || timeSinceLastUpdate.Seconds > 5)
                {
                    var timeSinceStart = DateTime.Now - timeStarted;

                    var avgMillisPerRow = (double)(timeSinceStart.TotalMilliseconds == 0 ? 1 : timeSinceStart.TotalMilliseconds) / (double)(rowCount == 0 ? 1 : rowCount);
                    var rowsLeft        = RowSource.RowCount - rowCount;
                    var secondsLeft     = (int)((double)(rowsLeft * avgMillisPerRow) / 1000.0);

                    lastCheck = DateTime.Now;

                    TimeSpan ts = new TimeSpan(0, 0, secondsLeft);

                    var message = string.Format("Importing rows - Stage 2 ({0} of {1}). {2} remaining.", rowCount, RowSource.RowCount, ts.ToString());
                    ProgressMsg(message, percent);
                    lastPercent = percent;
                }
            }

            ProgressMsg("Importing rows - Stage 2 Complete", 100);

            LogMsg("{0} Rows successfully imported, {1} rows failed with errors", _successCount, _errorCount);

            LogMsg("Cleaning up staging database...");

            if (RowSource.Service.GetErrorCount() > 0)
            {
                if (ParentWindow.Question("Errors were encountered during the import. Rejected rows can be corrected and re-imported by re-running the import wizard and selecting the 'Import Error Database' option. Would you like to save the rejected rows so that they can be corrected and re-imported?", "Save rejected rows?", System.Windows.MessageBoxImage.Exclamation))
                {
                    // Clean out just the imported records, leaving just the error rows...
                    LogMsg("Purging successfully imported rows from staging database...");
                    RowSource.Service.PurgeImportedRecords();
                    LogMsg("Saving mapping information to staging database...");
                    RowSource.Service.SaveMappingInfo(Importer, Mappings);
                    LogMsg("Disconnecting from staging database...");
                    RowSource.Service.Disconnect();

                    var dlg = new Microsoft.Win32.SaveFileDialog();
                    dlg.Filter = "SQLite database files|*.sqlite|All files (*.*)|*.*";
                    dlg.Title  = "Save error database file";
                    if (dlg.ShowDialog().ValueOrFalse())
                    {
                        LogMsg("Copying staging database from {0} to {1}", RowSource.Service.FileName, dlg.FileName);
                        System.IO.File.Copy(RowSource.Service.FileName, dlg.FileName, true);
                    }
                }
            }

            connection.Close();
        }
Exemple #46
0
        public override ImportRowSource CreateRowSource(IProgressObserver progress)
        {
            if (_options == null) {
                throw new Exception("Null or incorrect options type received!");
            }

            ImportRowSource rowsource = null;

            var columnNames = GetColumnNames();
            var service = new ImportStagingService();
            service.CreateImportTable(columnNames);

            if (WithWorksheetDataTable(_options.Filename, string.Format("SELECT * FROM [{0}]", _options.Worksheet), (dt) => {

                service.BeginTransaction();
                var values = new List<string>();
                int rowcount = 0;
                foreach (DataRow row in dt.Rows) {
                    values.Clear();
                    foreach (DataColumn col in dt.Columns) {
                        var value = row[col];
                        values.Add((value == null ? "" : value.ToString()));
                    }
                    service.InsertImportRow(values);
                    rowcount++;
                }

                service.CommitTransaction();

                rowsource = new ImportRowSource(service, rowcount);

            })) {
                return rowsource;
            }

            return null;
        }
Exemple #47
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     return(Service.GetTaxonTypes(Taxon.TaxaID.Value));
 }
Exemple #48
0
 public ProgressObservableStream(IProgressObserver <long> observer,
                                 Stream decoratedStream) : base(decoratedStream)
 {
     _observer = observer;
 }
 public FrameworkElement ConstructView(IBioLinkReport report, DataMatrix reportData, IProgressObserver progress)
 {
     TabularDataViewer viewer = new TabularDataViewer(report, reportData, progress);
     viewer.ContextMenuHandler = ContextMenuHandler;
     return viewer;
 }
Exemple #50
0
 public abstract DataMatrix ExtractReportData(IProgressObserver progress);
Exemple #51
0
        public UpdateCheckResults CheckForUpdates(IProgressObserver progress)
        {
            // Get the running apps version to compare...
            // We need to use the parent window because its the main application assembly version we want, not this plugin.
            var v = PluginManager.Instance.ParentWindow.GetType().Assembly.GetName().Version;

            var results = new UpdateCheckResults {
                CurrentMajor = v.Major, CurrentMinor = v.Minor, CurrentBuild = v.Revision, UpdateExists = false, UpdateLink = ""
            };

            if (progress != null)
            {
                progress.ProgressStart("Checking for updates...");
            }
            Config.SetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            var updateURL = Config.GetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            try {
                if (progress != null)
                {
                    progress.ProgressMessage("Contacting update site...");
                }
                var reader = XmlReader.Create(updateURL);
                var feed   = SyndicationFeed.Load(reader);

                if (progress != null)
                {
                    progress.ProgressMessage("Checking update site data...");
                }

                var pattern = new Regex(@"BioLinkInstaller-(\d+)[.](\d+)[.](\d+)[.]exe");
                foreach (SyndicationItem item in feed.Items)
                {
                    foreach (var link in item.Links)
                    {
                        var m = pattern.Match(link.Uri.AbsoluteUri);
                        if (m.Success)
                        {
                            bool updateExists = false;
                            var  major        = Int32.Parse(m.Groups[1].Value);
                            var  minor        = Int32.Parse(m.Groups[2].Value);
                            var  build        = Int32.Parse(m.Groups[3].Value);

                            if (major > results.CurrentMajor)
                            {
                                updateExists = true;
                            }
                            else if (major == results.CurrentMajor)
                            {
                                if (minor > results.CurrentMinor)
                                {
                                    updateExists = true;
                                }
                                else if (minor == results.CurrentMinor)
                                {
                                    updateExists = build > results.CurrentBuild;
                                }
                            }

                            if (updateExists)
                            {
                                results.UpdateMajor  = major;
                                results.UpdateMinor  = minor;
                                results.UpdateBuild  = build;
                                results.UpdateExists = true;
                                results.UpdateLink   = link.Uri.AbsoluteUri;

                                return(results);
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            } finally {
                if (progress != null)
                {
                    progress.ProgressEnd("Update check complete.");
                }
            }

            return(results);
        }
Exemple #52
0
        public override Data.DataMatrix ExtractReportData(IProgressObserver progress)
        {
            DataMatrix results = null;

            switch (ObjectType) {
                case TraitCategoryType.Taxon:
                    results = AddMediaForTaxon(Target.ObjectID.Value, progress);
                    break;
            }

            return results;
        }
Exemple #53
0
        public UpdateCheckResults CheckForUpdates(IProgressObserver progress)
        {
            // Get the running apps version to compare...
            // We need to use the parent window because its the main application assembly version we want, not this plugin.
            var v = PluginManager.Instance.ParentWindow.GetType().Assembly.GetName().Version;

            var results = new UpdateCheckResults { CurrentMajor = v.Major, CurrentMinor = v.Minor, CurrentBuild = v.Revision, UpdateExists = false, UpdateLink = "" };
            if (progress != null) {
                progress.ProgressStart("Checking for updates...");
            }
            Config.SetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            var updateURL = Config.GetGlobal("BioLink.UpdateURL", "http://downloads.ala.org.au/feed/p/biolink");

            try {
                if (progress != null) {
                    progress.ProgressMessage("Contacting update site...");
                }
                var reader = XmlReader.Create(updateURL);
                var feed = SyndicationFeed.Load(reader);

                if (progress != null) {
                    progress.ProgressMessage("Checking update site data...");
                }

                var pattern = new Regex(@"BioLinkInstaller-(\d+)[.](\d+)[.](\d+)[.]exe");
                foreach (SyndicationItem item in feed.Items) {
                    foreach (var link in item.Links) {
                        var m = pattern.Match(link.Uri.AbsoluteUri);
                        if (m.Success) {
                            bool updateExists = false;
                            var major = Int32.Parse(m.Groups[1].Value);
                            var minor = Int32.Parse(m.Groups[2].Value);
                            var build = Int32.Parse(m.Groups[3].Value);

                            if (major > results.CurrentMajor) {
                                updateExists = true;
                            } else if (major == results.CurrentMajor) {
                                if (minor > results.CurrentMinor) {
                                    updateExists = true;
                                } else if (minor == results.CurrentMinor) {
                                    updateExists = build > results.CurrentBuild;
                                }
                            }

                            if (updateExists) {
                                results.UpdateMajor = major;
                                results.UpdateMinor = minor;
                                results.UpdateBuild = build;
                                results.UpdateExists = true;
                                results.UpdateLink = link.Uri.AbsoluteUri;

                                return results;
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                GlobalExceptionHandler.Handle(ex);
            } finally {
                if (progress != null) {
                    progress.ProgressEnd("Update check complete.");
                }
            }

            return results;
        }
Exemple #54
0
 public static void Subscribe(IProgressObserver progressObserver)
 {
     _threadProgressReporter.Value.Subscribe(progressObserver);
 }
Exemple #55
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     var service = new SupportService(User);
     return service.ExecuteQuery(Criteria, Distinct);
 }
Exemple #56
0
 public abstract DataMatrix ExtractReportData(IProgressObserver progress);
 public static IGeneratorParams CreateParams(int numbersToGenerate, int rangeStart, int rangeEnd, List <int> usedNumbers, IProgressObserver progressObserver)
 {
     return(new GeneratorParams()
     {
         NumbersToGenerate = numbersToGenerate,
         RangeStart = rangeStart,
         RangeEnd = rangeEnd,
         GeneratedNumbers = usedNumbers,
         ProgressObserver = progressObserver
     });
 }
Exemple #58
0
        private DataMatrix AddMediaForTaxon(int taxonId, IProgressObserver progress)
        {
            var results = new DataMatrix();

            results.Columns.Add(new MatrixColumn { Name = "MultimediaID", IsHidden = true });
            results.Columns.Add(new MatrixColumn { Name = "TaxonID", IsHidden = true });
            results.Columns.Add(new MatrixColumn { Name = "MultimediaLink", IsHidden = true });
            results.Columns.Add(new MatrixColumn { Name = "Taxon name" });
            results.Columns.Add(new MatrixColumn { Name = "Rank" });
            results.Columns.Add(new MatrixColumn { Name = "Multimedia Name" });
            results.Columns.Add(new MatrixColumn { Name = "Extension" });
            results.Columns.Add(new MatrixColumn { Name = "Multimedia Type" });
            results.Columns.Add(new MatrixColumn { Name = "Size" });
            results.Columns.Add(new MatrixColumn { Name = "Attached To" });
            results.Columns.Add(new MatrixColumn { Name = "MaterialID", IsHidden= true });

            if (progress != null) {
                progress.ProgressMessage("Extracting multimedia details for item...");
            }

            // First add the multimedia for this item
            var links = SupportService.GetMultimediaItems(TraitCategoryType.Taxon.ToString(), taxonId);
            var taxon = TaxaService.GetTaxon(taxonId);

            foreach (MultimediaLink link in links) {
                AddTaxonRow(results, taxon, link);
            }

            if (_includeMaterial) {
                AddMaterialRowsForTaxon(results, taxon);
            }

            if (_recurse) {
                // Now find all the children of this item
                if (progress != null) {
                    progress.ProgressMessage("Retrieving child items...");
                }

                var children = TaxaService.GetExpandFullTree(taxonId);

                var elementCount = 0;
                int total = children.Count;

                if (progress != null) {
                    progress.ProgressStart("Extracting multimedia for children...");
                }

                foreach (Taxon child in children) {

                    if (progress != null) {
                        double percent = (((double)elementCount) / ((double)total)) * 100.0;
                        progress.ProgressMessage(string.Format("Processing {0}", child.TaxaFullName), percent);
                    }
                    elementCount++;

                    links = SupportService.GetMultimediaItems(TraitCategoryType.Taxon.ToString(), child.TaxaID.Value);
                    foreach (MultimediaLink link in links) {
                        AddTaxonRow(results, child, link);
                    }

                    if (_includeMaterial) {
                        AddMaterialRowsForTaxon(results, child);
                    }

                }
            }

            if (progress != null) {
                progress.ProgressEnd(string.Format("{0} multimedia items found.", results.Rows.Count ));
            }

            return results;
        }
Exemple #59
0
 public StuckingProgressObserver(IProgressObserver wrapee)
 {
     this.wrapee = wrapee;
 }
Exemple #60
0
 public override DataMatrix ExtractReportData(IProgressObserver progress)
 {
     string caption = String.Format("Taxon: {0}", Taxon.TaxaFullName);
     return Service.ChecklistReport(Taxon.TaxaID.Value, caption, Extent, IncludeAvailableNames, IncludeLiteratureNames, Depth, UserDefinedOrder, VerifiedOnly, SelectedRanks);
 }