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); }
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; }
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); }
protected void ProgressMessage(string message, double?percent = null) { if (ProgressObserver != null) { ProgressObserver.ProgressMessage(message, percent); } }
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; }
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); }
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)); }
private void SetFilter(string text) { if (String.IsNullOrEmpty(text)) { return; } var dataView = CollectionViewSource.GetDefaultView(lvw.ItemsSource) as ListCollectionView; if (dataView != null) { text = text.ToLower(); dataView.Filter = (obj) => { var row = obj as MatrixRow; if (row != null) { object match = row.First((colval) => { if (colval != null) { return(colval.ToString().ToLower().Contains(text)); } return(false); }); if (match != null) { return(true); } } return(false); }; dataView.Refresh(); } if (_progress != null) { _progress.ProgressMessage(String.Format("Showing {0} of {1} rows", dataView.Count, Data.Rows.Count)); } }
public bool OnProgress(string message, double percentComplete, ProgressEventType progressEventType) { if (_observer != null) { switch (progressEventType) { case ProgressEventType.Start: _observer.ProgressStart(message); break; case ProgressEventType.Update: _observer.ProgressMessage(message, percentComplete); break; case ProgressEventType.End: _observer.ProgressEnd(message); break; } } return(true); }
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 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); }
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; }
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); }
public override DataMatrix ExtractReportData(IProgressObserver progress) { var matrix = new DataMatrix(); if (IsGroupedByTaxon) { matrix.Columns.Add(new MatrixColumn { Name = "TaxonName" }); matrix.Columns.Add(new MatrixColumn { Name = "BiotaID", IsHidden = true }); } matrix.Columns.Add(new MatrixColumn { Name = "Count" }); foreach (string colname in SelectedColumns) { matrix.Columns.Add(new MatrixColumn { Name = colname }); } // Open the feature layer data SelectedFeatureLayer.DataSource.Open(); var map = new Dictionary <string, FeatureCountPair>(); if (progress != null) { progress.ProgressMessage("Counting points...", 0); } int pointCount = 0; foreach (VectorLayer pointLayer in SelectedPointLayers) { var ds = pointLayer.DataSource; ds.Open(); pointCount += ds.GetFeatureCount(); } if (progress != null) { progress.ProgressStart(String.Format("Processing {0} points...", pointCount)); } int processed = 0; int notFoundCount = 0; var materialService = new MaterialService(User); var taxaService = new TaxaService(User); foreach (VectorLayer pointLayer in SelectedPointLayers) { var pointProvider = pointLayer.DataSource; pointProvider.Open(); for (uint i = 0; i < pointProvider.GetFeatureCount(); ++i) { var row = pointProvider.GetFeature(i); Taxon taxon = null; if (IsGroupedByTaxon) { int?materialId = (int?)row["MaterialID"]; if (materialId.HasValue) { var m = materialService.GetMaterial(materialId.Value); if (m.BiotaID > 0) { if (_taxonCache.ContainsKey(m.BiotaID)) { taxon = _taxonCache[m.BiotaID]; } else { taxon = taxaService.GetTaxon(m.BiotaID); _taxonCache[m.BiotaID] = taxon; } } } } SharpMap.Geometries.Point p = row.Geometry as Point; if (!ProcessPoint(SelectedFeatureLayer.DataSource, pointLayer, p, map, taxon)) { notFoundCount++; } processed++; if (progress != null) { double percent = ((double)processed) / ((double)pointCount) * 100; progress.ProgressMessage(String.Format("Processing {0} points...", pointCount), percent); } } } if (progress != null) { progress.ProgressMessage("Constructing result set...", 100); } int countIndex = matrix.IndexOf("Count"); int taxaIndex = matrix.IndexOf("TaxonName"); int biotaIDIndex = matrix.IndexOf("BiotaID"); foreach (FeatureCountPair pair in map.Values) { var matrixRow = matrix.AddRow(); foreach (DataColumn col in pair.First.Table.Columns) { if (SelectedColumns.Contains(col.ColumnName)) { var index = matrix.IndexOf(col.ColumnName); matrixRow[index] = pair.First[col]; } } matrixRow[countIndex] = pair.Second; if (IsGroupedByTaxon) { matrixRow[taxaIndex] = pair.Taxon == null ? "Unidentified" : pair.Taxon.TaxaFullName; matrixRow[biotaIDIndex] = pair.Taxon == null ? -1 : pair.Taxon.TaxaID.Value; } } if (IncludeUnmatchedPointRow && notFoundCount > 0) { var unmatched = matrix.AddRow(); unmatched[countIndex] = notFoundCount; } if (progress != null) { progress.ProgressEnd(String.Format("{0} points processed.", pointCount)); } return(matrix); }
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; }
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); }
public override DataMatrix ExtractReportData(IProgressObserver progress) { if (progress != null) { progress.ProgressMessage("Phase 1: Finding associate relationships..."); } int[] ids = new int[Taxa.Count]; int i = 0; foreach (TaxonViewModel vm in Taxa) { ids[i++] = vm.TaxaID.Value; } var matrix = Service.GetAssociatesForTaxa(RegionID, this.StripRTF, ids); var index = matrix.IndexOf("AssociateID"); if (index >= 0) { if (progress != null) { progress.ProgressMessage("Phase 2: Retrieving associates..."); } var idList = new List <int>(); foreach (MatrixRow row in matrix) { var associateId = (int)row[index]; if (!idList.Contains(associateId)) { idList.Add(associateId); } } if (progress != null) { progress.ProgressStart("Phase 3: Building view models..."); } var viewModels = new List <AssociateReportViewModel>(); if (idList.Count > 0) { var service = new SupportService(PluginManager.Instance.User); var associates = service.GetAssociatesById(idList); int count = 0; foreach (Associate m in associates) { count++; if (progress != null) { var percentComplete = ((double)count / (double)associates.Count) * 100.0; progress.ProgressMessage("Phase 3: Building view models...", percentComplete); } var vm = new AssociateReportViewModel(m); if (m.FromCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material)) { vm.FromViewModel = GetViewModel(LookupType.Material, m.FromIntraCatID); } else if (m.FromCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon)) { vm.FromViewModel = GetViewModel(LookupType.Taxon, m.FromIntraCatID); } else { vm.FromViewModel = new ViewModelPlaceholder(m.AssocDescription, "images/Description.png"); } if (m.ToCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Material)) { vm.ToViewModel = GetViewModel(LookupType.Material, m.ToIntraCatID); } else if (m.ToCatID == TraitCategoryTypeHelper.GetTraitCategoryTypeID(TraitCategoryType.Taxon)) { vm.ToViewModel = GetViewModel(LookupType.Taxon, m.ToIntraCatID); } else { vm.ToViewModel = new ViewModelPlaceholder(m.AssocDescription, "images/Description.png"); } viewModels.Add(vm); } progress.ProgressEnd("Complete."); } matrix.Tag = viewModels; } return(matrix); }
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; }
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; }
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; }