Example #1
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;
        }
Example #2
0
 public void AppendMatrix(DataMatrix chunk)
 {
     chunk.Rows.ForEach(row => {
         var newrow = this.AddRow();
         for (int colIndex = 0; colIndex < Columns.Count; colIndex++) {
             newrow[colIndex] = row[colIndex];
         }
     });
 }
Example #3
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("");
     });
 }
Example #4
0
 public void AppendMatrix(DataMatrix chunk)
 {
     chunk.Rows.ForEach(row => {
         var newrow = this.AddRow();
         for (int colIndex = 0; colIndex < Columns.Count; colIndex++)
         {
             newrow[colIndex] = row[colIndex];
         }
     });
 }
Example #5
0
        public DataMatrix GetAsMatrix()
        {
            var results = new DataMatrix();

            results.Columns.Add(new MatrixColumn {
                Name = "RTF"
            });
            results.AddRow()[0] = _rtf.ToString();
            return(results);
        }
Example #6
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;
        }
Example #7
0
        public MatrixColumnChooser(DataMatrix matrix, string caption)
        {
            InitializeComponent();
            this.Matrix = matrix;
            lblCaption.Content = caption;

            var names = matrix.Columns.FindAll((col) => { return !col.IsHidden; }).Select((col) => {
                return col.Name;
            });

            cmbColumn.ItemsSource = names;

            if (names != null && names.Count() > 0) {
                cmbColumn.SelectedItem = names.ElementAt(0);
            }
        }
        public FormattedLatLongVirtualColumn(DataMatrix matrix)
        {
            var areaTypeCol = matrix.IndexOf("AreaType");
            var latCol = matrix.IndexOf("Lat");
            var longCol = matrix.IndexOf("Long");
            var latCol2 = matrix.IndexOf("Lat2");
            var longCol2 = matrix.IndexOf("Long2");

            this.Name = "FormattedLatLong";

            this.ValueGenerator = (row) => {

                object objLat = row[latCol];
                object objlong = row[longCol];
                object objAreaType = row[areaTypeCol];

                AreaType areaType = AreaType.Point;
                if (objAreaType != null) {
                    areaType = (AreaType) int.Parse(objAreaType.ToString());
                }

                if (objLat != null && objlong != null) {
                    double lat = (double)objLat;
                    double @long = (double)objlong;
                    switch (areaType) {
                        case AreaType.Point:
                            return string.Format("{0}, {1}", GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude));
                        case AreaType.Line:
                            double lat2 = (double)row[latCol2];
                            double long2 = (double)row[longCol2];
                            return string.Format("Line: {0}, {1} - {2}, {3}",
                                GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude),
                                GeoUtils.DecDegToDMS(lat2, CoordinateType.Latitude), GeoUtils.DecDegToDMS(long2, CoordinateType.Longitude));
                        case AreaType.Box:
                            lat2 = (double)row[latCol2];
                            long2 = (double)row[longCol2];
                            return string.Format("Box: {0}, {1} - {2}, {3}",
                                GeoUtils.DecDegToDMS(lat, CoordinateType.Latitude), GeoUtils.DecDegToDMS(@long, CoordinateType.Longitude),
                                GeoUtils.DecDegToDMS(lat2, CoordinateType.Latitude), GeoUtils.DecDegToDMS(long2, CoordinateType.Longitude));
                    }
                }

                return "";
            };
        }
        public FormattedDateVirtualColumn(DataMatrix matrix)
        {
            int dateTypeCol = matrix.IndexOf("DateType");
            int startDateCol = matrix.IndexOf("StartDate");
            int endDateCol = matrix.IndexOf("EndDate");
            int casualDateCol = matrix.IndexOf("CasualDate");

            Name = "Dates";
            ValueGenerator = (row) => {
                int dateType = 0;
                object objDateType = row[dateTypeCol];
                if (objDateType != null) {
                    int.TryParse(objDateType.ToString(), out dateType);
                    return DateUtils.FormatDates(dateType, row[startDateCol] as int?, row[endDateCol] as int?, row[casualDateCol] as string);

                }
                return "";
            };
        }
Example #10
0
 public override bool CanExport(DataMatrix matrix, String datasetName)
 {
     return true;
 }
Example #11
0
 public DataMatrix GetAsMatrix()
 {
     var results = new DataMatrix();
     results.Columns.Add(new MatrixColumn { Name = "RTF" });
     results.AddRow()[0] = _rtf.ToString();
     return results;
 }
Example #12
0
        private DataMatrix MergeItemMatrices(DataMatrix siteData, DataMatrix siteVisitData, DataMatrix materialData)
        {
            var result = new DataMatrix();

            // Create the final column set (based on the specified criteria)
            foreach (QueryCriteria c in Criteria) {
                result.Columns.Add(new MatrixColumn { Name = c.Field.DisplayName });
            }

            // Now add the identity columns (as hidden columns, unless they already exist)
            string[] cols = { "Site Identifier", "Visit Identifier", "Material Identifier"};
            foreach (string col in cols) {
                if (result.IndexOf(col) < 0) {
                    result.Columns.Add(new MatrixColumn { Name = col, IsHidden = true });
                }
            }

            int currentOrderNum = 1;
            LabelSetItem item = null;
            while ((item = Items.FirstOrDefault((candidate) => { return candidate.PrintOrder == currentOrderNum; })) != null) {

                if (item.NumCopies > 0) {

                    var row = result.AddRow();

                    if (item.SiteID > 0) {
                        AddFieldData(row, item.SiteID, "Site Identifier", siteData);
                    }

                    if (item.VisitID > 0) {
                        AddFieldData(row, item.VisitID, "Visit Identifier", siteVisitData);
                    }

                    if (item.MaterialID > 0) {
                        AddFieldData(row, item.MaterialID, "Material Identifier", materialData);
                    }

                    if (item.NumCopies > 1) {
                        CopyRow(result, row, item.NumCopies - 1);
                    }
                }

                currentOrderNum++;
            }

            return result;
        }
Example #13
0
 public void Dispose()
 {
     this.Data = null;
     lvw.ItemsSource = null;
 }
Example #14
0
 internal MatrixRow(DataMatrix matrix, object[] data)
 {
     _matrix = matrix;
     _data = data;
 }
Example #15
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;
        }
Example #16
0
        protected override object GetOptions(Window parentWindow, DataMatrix matrix, String datasetName)
        {
            var filename = PromptForFilename(".txt", "Excel 2007/2010 Workbook (.xlsx)|*.xlsx", datasetName);
            if (!String.IsNullOrEmpty(filename)) {
                ExcelExporterOptions options = new ExcelExporterOptions();
                options.Filename = filename;
                return options;
            }

            return null;
        }
        private void PreviewDataSet()
        {
            if (String.IsNullOrEmpty(Filename)) {
                return;
            }

            var builder = new BVPImportSourceBuilder(Filename);
            this.RowSource = builder.BuildRowSource();
            // make a matrix of the data - for now all of it, but if it becomes too much, we can limit it to top 100 or so...
            var matrix = new DataMatrix();
            var view = new GridView();
            for (int i = 0; i < RowSource.ColumnCount; ++i) {
                String name = RowSource.ColumnName(i);
                matrix.Columns.Add(new MatrixColumn { Name = name });
                var column = new GridViewColumn { Header = BuildColumnHeader(name), DisplayMemberBinding = new Binding(String.Format("[{0}]", i)) };
                view.Columns.Add(column);
            }

            while (RowSource.MoveNext()) {
                var row = matrix.AddRow();
                for (int i = 0; i < RowSource.ColumnCount; ++i) {
                    row[RowSource.ColumnName(i)] = RowSource[i];
                }
            }

            lvwPreview.ItemsSource = matrix.Rows;
            lvwPreview.View = view;
        }
Example #18
0
        private void ExportToCSV(DataMatrix matrix, Stream stream, DarwinCoreExporterOptions options, bool writeColumnHeaders)
        {
            // Now emit each row...
            int numCols = matrix.Columns.Count;
            var numRows = matrix.Rows.Count;
            var currentRow = 0;
            var _quote = '"';

            using (var writer = new StreamWriter(stream)) {
                if (writeColumnHeaders) {
                    for (int colIndex = 0; colIndex < numCols; ++colIndex) {
                        MatrixColumn col = matrix.Columns[colIndex];
                        if (!col.IsHidden) {
                            if (options.QuoteValues) {
                                writer.Write(_quote);
                            }
                            writer.Write(col.Name);
                            if (options.QuoteValues) {
                                writer.Write(_quote);
                            }
                            if (colIndex < numCols - 1) {
                                writer.Write(options.Delimiter);
                            }
                        }
                    }
                    writer.WriteLine();
                }

                for (int rowIndex = 0; rowIndex < matrix.Rows.Count; ++rowIndex) {
                    var row = matrix.Rows[rowIndex];
                    for (int colIndex = 0; colIndex < numCols; ++colIndex) {
                        if (!matrix.Columns[colIndex].IsHidden) {
                            var objValue = row[colIndex];
                            var value = objValue == null ? "" : objValue.ToString();

                            if (options.EscapeSpecial) {
                                value = value.Replace("\"", "\\\"");
                                value = value.Replace(options.Delimiter, "\\" + options.Delimiter);
                            }

                            var quoteValue = options.QuoteValues || value.Contains(options.Delimiter);

                            if (quoteValue) {
                                writer.Write(_quote);
                            }

                            writer.Write(value);

                            if (quoteValue) {
                                writer.Write(_quote);
                            }
                            if (colIndex < numCols - 1) {
                                writer.Write(options.Delimiter);
                            }
                        }
                    }
                    writer.WriteLine();
                    currentRow++;
                    if ((currentRow % 1000) == 0) {
                        double percent = (currentRow / ((double)numRows)) * 100.0;
                        ProgressMessage(String.Format("{0} rows exported to {1}", currentRow, options.Filename), percent);
                    }
                }
            }
        }
Example #19
0
        private void AddTaxonRow(DataMatrix results, Taxon taxa, MultimediaLink link, string multimediaSource = "Taxon", int? materialId= null)
        {
            // Filter the rows...
            bool addRow = true;
            if (!string.IsNullOrWhiteSpace(_extensionFilter)) {
                addRow = _extensionFilter.Equals(link.Extension, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow && !string.IsNullOrWhiteSpace(_typeFilter)) {
                addRow = _typeFilter.Equals(link.MultimediaType, StringComparison.CurrentCultureIgnoreCase);
            }

            if (addRow) {
                var row = results.AddRow();
                row[0] = link.MultimediaID;
                row[1] = taxa.TaxaID.Value;
                row[2] = link;
                row[3] = taxa.TaxaFullName;
                row[4] = taxa.Rank;
                row[5] = link.Name;
                row[6] = link.Extension;
                row[7] = link.MultimediaType;
                row[8] = link.SizeInBytes;
                row[9] = multimediaSource;
                row[10] = materialId;
            }
        }
Example #20
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;
        }
Example #21
0
 private void AddMaterialRowsForTaxon(DataMatrix results, Taxon taxon)
 {
     var ids = XMLIOService.GetMaterialForTaxon(taxon.TaxaID.Value);
     foreach (XMLIOMaterialID id in ids) {
         var links = SupportService.GetMultimediaItems(TraitCategoryType.Material.ToString(), id.MaterialID);
         foreach (MultimediaLink link in links) {
             AddTaxonRow(results, taxon, link, "Material", id.MaterialID);
         }
     }
 }
Example #22
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;
        }
Example #23
0
 internal MatrixRow(DataMatrix matrix, object[] data)
 {
     _matrix = matrix;
     _data   = data;
 }
Example #24
0
 protected abstract object GetOptions(Window parentWindow, DataMatrix matrix, String datasetName);
Example #25
0
 public abstract bool CanExport(DataMatrix matrix, String datasetName);
Example #26
0
 private void CopyRow(DataMatrix dest, MatrixRow srcRow, int numCopies)
 {
     for (int i = 0; i < numCopies; ++i) {
         var newRow = dest.AddRow();
         foreach (MatrixColumn col in dest.Columns) {
             int index = dest.IndexOf(col.Name);
             newRow[index] = srcRow[index];
         }
     }
 }
Example #27
0
        public DataMatrix StoredProcDataMatrix(string proc, Dictionary <string, ColumnDataFormatter> formatterMap, List <MatrixColumn> additionalColumns, params DbParameter[] @params)
        {
            DataMatrix[]          matrix     = { null };
            ColumnDataFormatter[] formatters = null;

            var defaultFormatter = new ColumnDataFormatter((value, rdr) => value);

            StoredProcReaderForEach(proc, (reader) => {
                if (matrix[0] == null)
                {
                    // Set up formatter array...
                    formatters = new ColumnDataFormatter[reader.FieldCount];

                    matrix[0] = new DataMatrix();
                    for (int i = 0; i < reader.FieldCount; ++i)
                    {
                        var columnName = reader.GetName(i);

                        bool hidden = false;
                        if (columnName.StartsWith(HIDDEN_COLUMN_PREFIX))
                        {
                            columnName = columnName.Substring(HIDDEN_COLUMN_PREFIX.Length);
                            hidden     = true;
                        }

                        matrix[0].Columns.Add(new MatrixColumn {
                            Name = columnName, IsHidden = hidden
                        });
                        if (formatterMap != null && formatterMap.ContainsKey(columnName))
                        {
                            formatters[i] = formatterMap[columnName];
                        }
                        else
                        {
                            formatters[i] = defaultFormatter;
                        }
                    }
                }

                if (additionalColumns != null && additionalColumns.Count > 0)
                {
                    foreach (MatrixColumn col in additionalColumns)
                    {
                        matrix[0].Columns.Add(col);
                    }
                }

                MatrixRow row = matrix[0].AddRow();
                for (int i = 0; i < reader.FieldCount; ++i)
                {
                    if (!reader.IsDBNull(i))
                    {
                        row[i] = formatters[i](reader[i], reader);
                    }
                }
            }, @params);

            if (matrix[0] == null)
            {
                matrix[0] = new DataMatrix();
            }

            return(matrix[0]);
        }
Example #28
0
 public abstract void ExportImpl(Window parentWindow, DataMatrix matrix, String datasetName, object options);
Example #29
0
        private void AddFieldData(MatrixRow targetRow, int objectId, string objectFieldName, DataMatrix srcData)
        {
            var srcRow = srcData.FindRow(objectFieldName, objectId);
            if (srcRow != null) {
                for (int srcIndex = 0; srcIndex < srcData.Columns.Count; srcIndex++) {
                    var col = srcData.Columns[srcIndex];
                    int targetIndex = targetRow.Matrix.IndexOf(col.Name);

                    if (targetIndex >= 0) {
                        targetRow[targetIndex] = srcRow[srcIndex];
                    }
                }
            }
        }
Example #30
0
        protected override object GetOptions(Window parentWindow, DataMatrix matrix, String datasetName)
        {
            string filename = PromptForFilename(".sqlite", "SQLite database (.sqlite)|*.sqlite", datasetName);
            if (!String.IsNullOrEmpty(filename)) {
                ExcelExporterOptions options = new ExcelExporterOptions();
                options.Filename = filename;
                return options;
            }

            return null;
        }
Example #31
0
 private List<DisplayColumnDefinition> GenerateDefaultColumns(DataMatrix data)
 {
     var list = new List<DisplayColumnDefinition>();
     foreach (MatrixColumn col in data.Columns) {
         if (!col.IsHidden) {
             var colDef = new DisplayColumnDefinition { ColumnName = col.Name, DisplayName = col.Name };
             list.Add(colDef);
         }
     }
     return list;
 }
Example #32
0
        public void CreateTable(string tableName, DataMatrix matrix)
        {
            StringBuilder columnDefs = new StringBuilder();
            int numCols = matrix.Columns.Count;
            foreach (MatrixColumn col in matrix.Columns) {
                if (!col.IsHidden) {
                    columnDefs.AppendFormat("[{0}]", col.Name).Append(" TEXT");
                    columnDefs.Append(", ");
                }
            }

            columnDefs.Remove(columnDefs.Length - 2, 2);

            Command((cmd) => {
                cmd.CommandText = String.Format("CREATE TABLE [{0}] ({1})", tableName, columnDefs.ToString());
                cmd.ExecuteNonQuery();
            });
        }
Example #33
0
 public FrameworkElement ConstructView(IBioLinkReport report, DataMatrix reportData, IProgressObserver progress)
 {
     TabularDataViewer viewer = new TabularDataViewer(report, reportData, progress);
     viewer.ContextMenuHandler = ContextMenuHandler;
     return viewer;
 }
Example #34
0
        internal void DisplayReportResults(DataMatrix data)
        {
            StatusMessage("Preparing view...");

            if (this.Report != null) {
                reportContent.Children.Clear();
                if (Report.Viewers.Count == 0 || Report.Viewers.Count == 1) {
                    IReportViewerSource viewerSource = null;
                    if (Report.Viewers.Count == 0) {
                        viewerSource = new TabularDataViewerSource();
                    } else {
                        viewerSource = Report.Viewers[0];
                    }
                    FrameworkElement control = viewerSource.ConstructView(Report, data, this);
                    reportContent.Children.Add(control);
                } else {
                    TabControl tab = new TabControl();
                    int count = 0;
                    foreach (IReportViewerSource tmpViewerSource in Report.Viewers) {
                        var viewerSource = tmpViewerSource; // need to capture a local because of the closure below
                        var tabItem = new TabItem { Header = viewerSource.Name };

                        // Create the first view straight away...
                        if (count == 0) {
                            var scroller = new ScrollViewer();
                            scroller.Content = viewerSource.ConstructView(Report, data, this);
                            tabItem.Content = scroller;
                        } else {
                            tabItem.RequestBringIntoView += new RequestBringIntoViewEventHandler((s, e) => {

                                if (tabItem.Content == null) {
                                    var scroller = new ScrollViewer();
                                    scroller.Content = viewerSource.ConstructView(Report, data, this);
                                    tabItem.Content = scroller;
                                }
                            });
                        }

                        tab.Items.Add(tabItem);
                        count++;
                    }
                    reportContent.Children.Add(tab);
                }
            }

            StatusMessage("{0} records retrieved.", data.Rows.Count);
        }