Exemple #1
0
            private void RepopulateLiveReportList()
            {
                _liveReportDriver.List.Clear();
                var documentGridViewContext = DocumentGridViewContext.CreateDocumentGridViewContext(null, DataSchemaLocalizer.INVARIANT);

                _liveReportDriver.List.AddRange(documentGridViewContext.GetViewSpecList(PersistedViews.ExternalToolsGroup.Id).ViewSpecs.Select(view => new ReportOrViewSpec(view)));
            }
Exemple #2
0
        /// <summary>
        ///  A helper function that generates the report with reportTitle from the SrmDocument.
        ///  Throws an error if the reportSpec no longer exists in Settings.Default.
        /// </summary>
        /// <param name="doc">Document to create the report from.</param>
        /// <param name="reportTitle">Title of the reportSpec to make a report from.</param>
        /// <param name="toolTitle">Title of tool for exception error message.</param>
        /// <param name="progressMonitor">Progress monitor.</param>
        /// <param name="writer">TextWriter that the report should be written to.</param>
        /// <returns> Returns a string representation of the ReportTitle report, or throws an error that the reportSpec no longer exist. </returns>
        public static void GetReport(SrmDocument doc, string reportTitle, string toolTitle, IProgressMonitor progressMonitor, TextWriter writer)
        {
            var container = new MemoryDocumentContainer();

            container.SetDocument(doc, container.Document);
            var      dataSchema  = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
            var      viewContext = new DocumentGridViewContext(dataSchema);
            ViewInfo viewInfo    = viewContext.GetViewInfo(PersistedViews.ExternalToolsGroup.Id.ViewName(reportTitle));

            if (null == viewInfo)
            {
                throw new ToolExecutionException(
                          string.Format(
                              Resources.ToolDescriptionHelpers_GetReport_Error_0_requires_a_report_titled_1_which_no_longer_exists__Please_select_a_new_report_or_import_the_report_format,
                              toolTitle, reportTitle));
            }
            IProgressStatus status =
                new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
                                                 reportTitle));

            progressMonitor.UpdateProgress(status);
            if (!viewContext.Export(CancellationToken.None, progressMonitor, ref status, viewInfo, writer,
                                    viewContext.GetCsvWriter()))
            {
                throw new OperationCanceledException();
            }
        }
Exemple #3
0
        public void TestExportWithCurrentLanguage()
        {
            CultureInfo       cultureInfo       = CultureInfo.CurrentUICulture;
            SkylineDataSchema skylineDataSchema =
                new SkylineDataSchema(CreateMemoryDocumentContainer(LoadTestDocument()), SkylineDataSchema.GetLocalizedSchemaLocalizer());
            SkylineViewContext viewContext = new DocumentGridViewContext(skylineDataSchema);

            string testFile  = Path.Combine(TestContext.TestDir, "TestExportWithCurrentLanguage.csv");
            var    dsvWriter = viewContext.GetCsvWriter();

            viewContext.ExportToFile(null, GetTestReport(skylineDataSchema), testFile, dsvWriter);
            string strExported   = File.ReadAllText(testFile);
            var    actualLines   = strExported.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
            var    expectedLines = ExpectedInvariantReport.Split(new[] { Environment.NewLine }, StringSplitOptions.None);

            var invariantHeaders = expectedLines[0].Split(',');
            var expectedHeaders  =
                invariantHeaders.Select(header => ColumnCaptions.ResourceManager.GetString(header, cultureInfo) ?? header).ToArray();
            var actualHeaders = actualLines[0].Split(TextUtil.GetCsvSeparator(cultureInfo));

            CollectionAssert.AreEqual(expectedHeaders, actualHeaders);
            // If the language in English, then the exported report will be identical to the invariant report except for the headers
            if (cultureInfo.Name == "en-US")
            {
                CollectionAssert.AreEqual(expectedLines.Skip(1).ToArray(), actualLines.Skip(1).ToArray());
            }
        }
 protected override void OnHandleDestroyed(EventArgs e)
 {
     base.OnHandleDestroyed(e);
     if (null != _viewContext)
     {
         _viewContext.ViewsChanged -= OnViewsChanged;
         _viewContext = null;
     }
 }
        public void EditReportList()
        {
            var dataSchema  = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewContext = new DocumentGridViewContext(dataSchema)
            {
                EnablePreview = true
            };

            using (var manageViewsForm = new ManageViewsForm(viewContext))
            {
                manageViewsForm.ShowDialog(this);
            }
        }
 protected override void OnHandleCreated(EventArgs e)
 {
     base.OnHandleCreated(e);
     if (null != _documentUiContainer)
     {
         _viewContext = new DocumentGridViewContext(new SkylineDataSchema(_documentUiContainer,
                                                                          DataSchemaLocalizer.INVARIANT));
         _viewContext.ViewsChanged += OnViewsChanged;
         imageList1.Images.Clear();
         imageList1.Images.Add(Resources.Folder);
         imageList1.Images.Add(Resources.Blank);
         imageList1.Images.AddRange(_viewContext.GetImageList());
         Repopulate();
     }
 }
Exemple #7
0
        public static void ReportToCsv(ReportSpec reportSpec, SrmDocument doc, string fileName, CultureInfo cultureInfo)
        {
            var documentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(documentContainer.SetDocument(doc, documentContainer.Document));
            var skylineDataSchema = new SkylineDataSchema(documentContainer, new DataSchemaLocalizer(cultureInfo, cultureInfo));
            var viewSpec          = ReportSharing.ConvertAll(new[] { new ReportOrViewSpec(reportSpec) }, doc).First();
            var viewContext       = new DocumentGridViewContext(skylineDataSchema);

            using (var writer = new StreamWriter(fileName))
            {
                IProgressStatus status = new ProgressStatus();
                viewContext.Export(CancellationToken.None, new SilentProgressMonitor(), ref status,
                                   viewContext.GetViewInfo(ViewGroup.BUILT_IN, viewSpec), writer, viewContext.GetCsvWriter());
            }
        }
        public void NewReport()
        {
            var dataSchema  = new SkylineDataSchema(DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            var viewContext = new DocumentGridViewContext(dataSchema)
            {
                EnablePreview = true
            };
            var newView = viewContext.NewView(this, PersistedViews.MainGroup);

            if (newView != null)
            {
                chooseViewsControl.SelectView(newView.Name);
                chooseViewsControl.CheckedViews = chooseViewsControl.CheckedViews
                                                  .Append(PersistedViews.MainGroup.Id.ViewName(newView.Name));
            }
        }
Exemple #9
0
        public void TestInvariantExport()
        {
            SkylineDataSchema skylineDataSchema =
                new SkylineDataSchema(CreateMemoryDocumentContainer(LoadTestDocument()), DataSchemaLocalizer.INVARIANT);
            SkylineViewContext viewContext = new DocumentGridViewContext(skylineDataSchema);

            string testFile  = Path.Combine(TestContext.TestDir, "TestInvariantExport.csv");
            var    dsvWriter = new DsvWriter(CultureInfo.InvariantCulture, ',');

            viewContext.ExportToFile(null, GetTestReport(skylineDataSchema), testFile, dsvWriter);
            string strExported = File.ReadAllText(testFile);

            Assert.AreEqual(ExpectedInvariantReport, strExported);
            // Assert that the file written out was UTF8 encoding without any byte order mark
            byte[] bytesExported = File.ReadAllBytes(testFile);
            CollectionAssert.AreEqual(Encoding.UTF8.GetBytes(strExported), bytesExported);
        }
Exemple #10
0
        private string GetReportRows(SrmDocument document, ViewSpec viewSpec, IProgressMonitor progressMonitor)
        {
            var container = new MemoryDocumentContainer();

            container.SetDocument(document, container.Document);
            var             dataSchema  = new SkylineDataSchema(container, DataSchemaLocalizer.INVARIANT);
            var             viewContext = new DocumentGridViewContext(dataSchema);
            IProgressStatus status      = new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
                                                                           viewSpec.Name));
            var writer = new StringWriter();

            if (viewContext.Export(CancellationToken.None, progressMonitor, ref status, viewContext.GetViewInfo(null, viewSpec), writer,
                                   viewContext.GetCsvWriter()))
            {
                return(writer.ToString());
            }
            return(null);
        }
Exemple #11
0
        public void TestGenerateMsStatsInput()
        {
            SrmDocument testDocument            = OpenTestDocument();
            var         memoryDocumentContainer = new MemoryDocumentContainer();

            Assert.IsTrue(memoryDocumentContainer.SetDocument(testDocument, memoryDocumentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(memoryDocumentContainer, DataSchemaLocalizer.INVARIANT);
            var             view           = ReportSharing.DeserializeReportList(OpenTestFile("MSstats_report.skyr")).First().ViewSpec;
            var             viewContext    = new DocumentGridViewContext(skylineDataSchema);
            StringWriter    stringWriter   = new StringWriter();
            IProgressStatus progressStatus = new ProgressStatus();

            viewContext.Export(new SilentProgressMonitor(), ref progressStatus,
                               viewContext.GetViewInfo(ViewGroup.BUILT_IN, view), stringWriter,
                               viewContext.GetCsvWriter());
            string expectedReport = new StreamReader(OpenTestFile("BrudererSubset_MSstatsInput.csv")).ReadToEnd();

            AssertEx.NoDiff(expectedReport, stringWriter.ToString());
        }