Ejemplo n.º 1
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");
            char separator = TextUtil.GetCsvSeparator(cultureInfo);
            var dsvWriter = new DsvWriter(cultureInfo, separator);
            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(separator);
            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());
            }
        }
 public CheckReportCompatibility(SrmDocument document)
 {
     IDocumentContainer documentContainer = new MemoryDocumentContainer();
     Assert.IsTrue(documentContainer.SetDocument(document, null));
     _database = new Database(document.Settings);
     _database.AddSrmDocument(document);
     _dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
 }
Ejemplo n.º 3
0
 protected AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef,
                                        Attribute[] attributes)
     : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, attributes)
 {
     SkylineDataSchema = dataSchema;
     _annotationDef    = CachedValue.Create(dataSchema, () => FindAnnotationDef(annotationDef));
     _isValid          = true;
 }
Ejemplo n.º 4
0
 protected AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef,
                                        Attribute[] attributes)
     : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, attributes)
 {
     SkylineDataSchema = dataSchema;
     AnnotationDef     = annotationDef;
     _isValid          = true;
 }
Ejemplo n.º 5
0
 public ListColumnPropertyDescriptor(SkylineDataSchema dataSchema, string listName, AnnotationDef annotationDef)
     : base(AnnotationDef.ANNOTATION_PREFIX + annotationDef.Name, AnnotationPropertyDescriptor.GetAttributes(annotationDef))
 {
     SkylineDataSchema = dataSchema;
     ListName          = listName;
     AnnotationDef     = annotationDef;
     _listInfo         = CachedValue.Create(dataSchema, () => GetListInfo(SkylineDataSchema.Document));
     _listItemType     = ListItemTypes.INSTANCE.GetListItemType(listName);
 }
Ejemplo n.º 6
0
 public LiveReportForm(IDocumentContainer documentContainer)
 {
     InitializeComponent();
     Icon = Resources.Skyline;
     _dataSchema = new SkylineDataSchema(documentContainer);
     var parentColumn = new ColumnDescriptor(_dataSchema, typeof (Protein));
     var viewContext = new SkylineViewContext(parentColumn);
     bindingListSource.SetViewContext(viewContext);
     bindingListSource.RowSource = new Proteins(_dataSchema);
     navBar.BindingNavigator.Items.Insert(0, toolStripDropDownRowSource);
 }
Ejemplo n.º 7
0
 public ListLookupPropertyDescriptor(SkylineDataSchema dataSchema, string listName, PropertyDescriptor innerPropertyDescriptor)
     : base(innerPropertyDescriptor.Name, GetAttributes(innerPropertyDescriptor))
 {
     SkylineDataSchema        = dataSchema;
     ListName                 = listName;
     _listItemType            = ListItemTypes.INSTANCE.GetListItemType(listName);
     _innerPropertyDescriptor = innerPropertyDescriptor;
     _listData                = CachedValue.Create(dataSchema, () =>
     {
         return(SkylineDataSchema.Document.Settings.DataSettings.Lists.FirstOrDefault(list =>
                                                                                      list.ListDef.Name == ListName));
     });
 }
Ejemplo n.º 8
0
 public LiveResultsGrid(SkylineWindow skylineWindow)
 {
     InitializeComponent();
     SkylineWindow = skylineWindow;
     _dataSchema = new SkylineDataSchema(skylineWindow, SkylineDataSchema.GetLocalizedSchemaLocalizer());
     DataGridViewPasteHandler.Attach(skylineWindow, DataGridView);
     BindingListSource.ListChanged += bindingListSource_ListChanged;
     BindingListSource.CurrentChanged += bindingListSource_CurrentChanged;
     DataGridView.DataBindingComplete += boundDataGridView_DataBindingComplete;
     var contextMenuStrip = databoundGridControl.contextMenuStrip;
     contextMenuStrip.Items.Insert(0, new ToolStripSeparator());
     for (int i = contextMenuResultsGrid.Items.Count - 1; i >= 0; i--)
     {
         contextMenuStrip.Items.Insert(0, contextMenuResultsGrid.Items[i]);
     }
     contextMenuStrip.Opening += contextMenu_Opening;
 }
Ejemplo n.º 9
0
 public void AddRef()
 {
     if (Interlocked.Increment(ref _referenceCount) == 1)
     {
         _skylineDataSchema = new SkylineDataSchema(GroupComparisonModel.DocumentContainer,
             SkylineDataSchema.GetLocalizedSchemaLocalizer());
         var viewInfo = new ViewInfo(_skylineDataSchema, typeof(FoldChangeRow), GetDefaultViewSpec(new FoldChangeRow[0]))
             .ChangeViewGroup(ViewGroup.BUILT_IN);
         var rowSourceInfo = new RowSourceInfo(typeof(FoldChangeRow), new FoldChangeRow[0], new[] { viewInfo });
         ViewContext = new GroupComparisonViewContext(_skylineDataSchema, new[]{rowSourceInfo});
         _container = new Container();
         _bindingListSource = new BindingListSource(_container);
         _bindingListSource.SetViewContext(ViewContext, viewInfo);
         GroupComparisonModel.ModelChanged += GroupComparisonModelOnModelChanged;
         GroupComparisonModelOnModelChanged(GroupComparisonModel, new EventArgs());
     }
 }
Ejemplo n.º 10
0
        public override void SetValue(object component, object value)
        {
            var listItem  = (ListItem)component;
            var newRecord = listItem.GetRecord() as ListItem.NewRecordData;

            if (newRecord != null)
            {
                newRecord.UncommittedValues[AnnotationDef.Name] = value;
                return;
            }
            var existingRecord = listItem.GetRecord() as ListItem.ExistingRecordData;

            if (existingRecord == null)
            {
                throw new InvalidOperationException(@"Invalid row " + listItem.GetRecord()); // Cannot happen
            }
            var editDescription = EditDescription.SetAnnotation(AnnotationDef, value)
                                  .ChangeElementRef(((ListRef)ListRef.PROTOTYPE.ChangeName(ListName)).GetListItemRef(listItem));

            SkylineDataSchema.ModifyDocument(editDescription, doc =>
            {
                var listInfo = GetListInfo(doc);
                if (listInfo == null)
                {
                    throw new InvalidOperationException(Resources.ListColumnPropertyDescriptor_SetValue_List_has_been_deleted);
                }
                if (listInfo.ColumnIndex < 0)
                {
                    throw CommonException.Create(ListExceptionDetail.ColumnNotFound(ListName, AnnotationDef.Name));
                }
                int rowIndex = listInfo.ListData.RowIndexOf(existingRecord.ListItemId);
                if (rowIndex < 0)
                {
                    throw new ArgumentException(Resources.ListColumnPropertyDescriptor_SetValue_List_item_has_been_deleted_);
                }
                var listData = listInfo.ListData;
                listData     = listData.ChangeColumn(listInfo.ColumnIndex, listData.Columns[listInfo.ColumnIndex].SetValue(rowIndex, value));
                return(doc.ChangeSettings(
                           doc.Settings.ChangeDataSettings(

                               ChangeListData(doc.Settings.DataSettings, listData))));
            }, AuditLogEntry.SettingsLogFunction);
        }
Ejemplo n.º 11
0
        public static IEnumerable <RowSourceInfo> GetDocumentGridRowSources(SkylineDataSchema dataSchema)
        {
            yield return(MakeRowSource(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Proteins,
                                       () => new Proteins(dataSchema)));

            yield return(MakeRowSource(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Peptides,
                                       () => new Peptides(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors,
                                       () => new Precursors(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Transitions,
                                       () => new Transitions(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates,
                                       () => new ReplicateList(dataSchema)));

            yield return(new RowSourceInfo(typeof(SkylineDocument), new SkylineDocument[0], new ViewInfo[0]));
        }
Ejemplo n.º 12
0
 public DocumentSettingsDlg(IDocumentContainer documentContainer)
 {
     InitializeComponent();
     Icon = Resources.Skyline;
     DocumentContainer = documentContainer;
     _annotationsListBoxDriver = new SettingsListBoxDriver<AnnotationDef>(
         checkedListBoxAnnotations, Settings.Default.AnnotationDefList);
     _annotationsListBoxDriver.LoadList(
         DocumentContainer.Document.Settings.DataSettings.AnnotationDefs);
     _groupComparisonsListBoxDriver = new SettingsListBoxDriver<GroupComparisonDef>(
         checkedListBoxGroupComparisons, Settings.Default.GroupComparisonDefList);
     _groupComparisonsListBoxDriver.LoadList(
         DocumentContainer.Document.Settings.DataSettings.GroupComparisonDefs);
     var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
     chooseViewsControl.ViewContext = new SkylineViewContext(dataSchema, new RowSourceInfo[0]);
     chooseViewsControl.ShowCheckboxes = true;
     chooseViewsControl.CheckedViews =
         documentContainer.Document.Settings.DataSettings.ViewSpecList.ViewSpecs.Select(
             viewSpec => PersistedViews.MainGroup.Id.ViewName(viewSpec.Name));
 }
Ejemplo n.º 13
0
        public static IEnumerable <RowSourceInfo> GetDocumentGridRowSources(SkylineDataSchema dataSchema)
        {
            bool proteomic = dataSchema.DefaultUiMode == UiModes.PROTEOMIC;

            yield return(MakeRowSource <Protein>(dataSchema,
                                                 proteomic ? Resources.SkylineViewContext_GetDocumentGridRowSources_Proteins : Resources.SkylineViewContext_GetDocumentGridRowSources_Molecule_Lists,
                                                 () => new Proteins(dataSchema)));

            yield return(MakeRowSource <Entities.Peptide>(dataSchema,
                                                          proteomic ? Resources.SkylineViewContext_GetDocumentGridRowSources_Peptides : Resources.SkylineViewContext_GetDocumentGridRowSources_Molecules,
                                                          () => new Peptides(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource <Precursor>(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Precursors,
                                                   () => new Precursors(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource <Entities.Transition>(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Transitions,
                                                             () => new Transitions(dataSchema, new[] { IdentityPath.ROOT })));

            yield return(MakeRowSource <Replicate>(dataSchema, Resources.SkylineViewContext_GetDocumentGridRowSources_Replicates,
                                                   () => new ReplicateList(dataSchema)));

            yield return(new RowSourceInfo(typeof(SkylineDocument), new StaticRowSource(new SkylineDocument[0]), new ViewInfo[0]));
        }
Ejemplo n.º 14
0
 public void TestMapping()
 {
     var settings = SrmSettingsList.GetDefault();
     var document = new SrmDocument(settings);
     var documentContainer = new MemoryDocumentContainer();
     documentContainer.SetDocument(document, null);
     using (var database = new Database(settings))
     {
         var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
         var sessionFactory = database.SessionFactory;
         foreach (var classMetaData in sessionFactory.GetAllClassMetadata().Values)
         {
             var tableType = classMetaData.GetMappedClass(EntityMode.Poco);
             foreach (var propertyName in classMetaData.PropertyNames)
             {
                 if (propertyName == "Protein" && tableType == typeof (DbProteinResult))
                 {
                     continue;
                 }
                 var queryDef = new QueryDef
                     {
                         Select = new[] {new ReportColumn(tableType, propertyName),}
                     };
                 var reportSpec = new ReportSpec("test", queryDef);
                 var newTableType = ReportSpecConverter.GetNewTableType(reportSpec);
                 Assert.IsNotNull(newTableType, "No table for type {0}", tableType);
                 var converter = new ReportSpecConverter(dataSchema);
                 var viewInfo = converter.Convert(reportSpec);
                 Assert.IsNotNull(viewInfo, "Unable to convert property {0} in table {1}", propertyName, tableType);
                 Assert.AreEqual(1, viewInfo.DisplayColumns.Count, "No conversion for property {0} in table {1}", propertyName, tableType);
                 Assert.IsNotNull(viewInfo.DisplayColumns[0].ColumnDescriptor, "Column not found for property {0} in table {1}", propertyName, tableType);
                 var report = Report.Load(reportSpec);
                 var resultSet = report.Execute(database);
                 var bindingListSource = new BindingListSource();
                 bindingListSource.SetViewContext(new SkylineViewContext(viewInfo.ParentColumn, Array.CreateInstance(viewInfo.ParentColumn.PropertyType, 0)), viewInfo);
                 var properties = bindingListSource.GetItemProperties(null);
                 var oldCaptions = resultSet.ColumnInfos.Select(columnInfo => columnInfo.Caption).ToArray();
                 var newCaptions = properties.Cast<PropertyDescriptor>().Select(pd=>pd.DisplayName).ToArray();
                 if (oldCaptions.Length != newCaptions.Length)
                 {
                     Console.Out.WriteLine(oldCaptions);
                 }
                 CollectionAssert.AreEqual(oldCaptions, newCaptions, "Caption mismatch on {0} in {1}", propertyName, tableType);
                 for (int i = 0; i < resultSet.ColumnInfos.Count; i++)
                 {
                     var columnInfo = resultSet.ColumnInfos[i];
                     var formatAttribute = (FormatAttribute)properties[i].Attributes[typeof(FormatAttribute)];
                     string message = string.Format("Format problem on column converted from {0} in {1}",
                         columnInfo.ReportColumn.Column, columnInfo.ReportColumn.Table);
                     if (null == columnInfo.Format)
                     {
                         Assert.IsTrue(null == formatAttribute || null == formatAttribute.Format, message);
                     }
                     else
                     {
                         Assert.IsNotNull(formatAttribute, message);
                         Assert.AreEqual(columnInfo.Format, formatAttribute.Format, message);
                     }
                     if (columnInfo.IsNumeric)
                     {
                         Assert.IsNotNull(formatAttribute, message);
                         Assert.AreEqual(TextUtil.EXCEL_NA, formatAttribute.NullValue, message);
                     }
                     else
                     {
                         Assert.IsTrue(null == formatAttribute || null == formatAttribute.NullValue, message);
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 15
0
 public AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef, bool isValid)
     : this(dataSchema, annotationDef, GetAttributes(annotationDef))
 {
     _isValid = isValid;
 }
Ejemplo n.º 16
0
 public ViewChangeListener(PersistedViews persistedViews, SkylineDataSchema skylineDataSchema)
 {
     _persistedViews    = persistedViews;
     _skylineDataSchema = skylineDataSchema;
 }
Ejemplo n.º 17
0
 private SkylineViewContext GetViewContext(bool clone)
 {
     var dataSchema = new SkylineDataSchema(_documentUiContainer, GetDataSchemaLocalizer());
     if (clone)
     {
         dataSchema = dataSchema.Clone();
     }
     return new DocumentGridViewContext(dataSchema) {EnablePreview = true};
 }
Ejemplo n.º 18
0
 public SkylineViewContext(SkylineDataSchema dataSchema, IEnumerable <RowSourceInfo> rowSources) : base(dataSchema, rowSources)
 {
     ApplicationIcon = Resources.Skyline;
 }
Ejemplo n.º 19
0
 public CachedValue(SkylineDataSchema dataSchema, Func <T> getterFunc)
 {
     _dataSchema = dataSchema;
     _getterFunc = getterFunc;
 }
 public void TestCheckForUnusedColumnCaptions()
 {
     var documentContainer = new MemoryDocumentContainer();
     Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
     SkylineDataSchema dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
     var columnCaptions = new HashSet<string>();
     foreach (
         var resourceManager in SkylineDataSchema.GetLocalizedSchemaLocalizer().ColumnCaptionResourceManagers)
     {
         var resourceSet = resourceManager.GetResourceSet(CultureInfo.InvariantCulture, true, true);
         var enumerator = resourceSet.GetEnumerator();
         while (enumerator.MoveNext())
         {
             string key = enumerator.Key as string;
             if (null != key)
             {
                 columnCaptions.Add(key);
             }
         }
     }
     foreach (var columnDescriptor in EnumerateAllColumnDescriptors(dataSchema, STARTING_TYPES)
         )
     {
         var invariantCaption = dataSchema.GetColumnCaption(columnDescriptor);
         columnCaptions.Remove(invariantCaption.InvariantCaption);
     }
     var unusedCaptions = columnCaptions.ToArray();
     Assert.AreEqual(0, unusedCaptions.Length, "Unused entries found in ColumnCaptions.resx: {0}", string.Join(",", unusedCaptions));
 }
Ejemplo n.º 21
0
 public void TestPivotResultsThenIsotopeLabel()
 {
     var assembly = typeof (LiveReportPivotTest).Assembly;
     XmlSerializer documentSerializer = new XmlSerializer(typeof(SrmDocument));
     // ReSharper disable once AssignNullToNotNullAttribute
     var document = (SrmDocument)documentSerializer.Deserialize(
         assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "silac_1_to_4.sky"));
     XmlSerializer reportSerializer = new XmlSerializer(typeof(ReportOrViewSpecList));
     // ReSharper disable once AssignNullToNotNullAttribute
     var views = (ReportOrViewSpecList) reportSerializer.Deserialize(
         assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "LiveReportPivots.skyr"));
     var view = views.First(reportSpec => reportSpec.Name == "ResultSummaryPivotResultsThenLabelType").ViewSpec;
     var bindingListSource = new BindingListSource();
     var documentContainer = new MemoryDocumentContainer();
     Assert.IsTrue(documentContainer.SetDocument(document, null));
     var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT);
     bindingListSource.SetViewContext(new DocumentGridViewContext(dataSchema), new ViewInfo(dataSchema, typeof(Precursor), view));
     var expectedColumnNames = new[] {
             "PeptideSequence",
             "Chromatograms Replicate",
             "Chromatograms PeptideRetentionTime",
             "light IsotopeLabelType",
             "light MeanTotalArea",
             "light Chromatograms TotalArea",
             "heavy IsotopeLabelType",
             "heavy MeanTotalArea",
             "heavy Chromatograms TotalArea",
         };
     var actualColumnNames =
         bindingListSource.GetItemProperties(null)
             .Cast<PropertyDescriptor>()
             .Select(pd => pd.DisplayName)
             .ToArray();
     CollectionAssert.AreEqual(expectedColumnNames, actualColumnNames);
 }
Ejemplo n.º 22
0
 public ResultsGridViewContext(SkylineDataSchema dataSchema, IEnumerable <RowSourceInfo> rowSources) : base(dataSchema, rowSources)
 {
 }
Ejemplo n.º 23
0
 public AnnotationPropertyDescriptor(SkylineDataSchema dataSchema, AnnotationDef annotationDef, bool isValid)
     : this(dataSchema, annotationDef, GetAttributes(annotationDef))
 {
     _isValid       = isValid;
     _annotationDef = CachedValue.Create(dataSchema, () => FindAnnotationDef(annotationDef));
 }
Ejemplo n.º 24
0
 private ViewInfo GetTestReport(SkylineDataSchema dataSchema)
 {
     var serializer = new XmlSerializer(typeof(ViewSpecList));
     ViewSpec viewSpec = ((ViewSpecList) serializer.Deserialize(new StringReader(TestReport))).ViewSpecs.First();
     return new ViewInfo(dataSchema, typeof (Skyline.Model.Databinding.Entities.Transition), viewSpec);
 }
Ejemplo n.º 25
0
        public void ConsoleReportExportTest()
        {
            var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE);
            string docPath = testFilesDir.GetTestPath("BSA_Protea_label_free_20100323_meth3_multi.sky");
            string outPath = testFilesDir.GetTestPath("Exported_test_report.csv");

            // Import the first RAW file (or mzML for international)
            string rawPath = testFilesDir.GetTestPath("ah_20101011y_BSA_MS-MS_only_5-2" +
                ExtensionTestContext.ExtThermoRaw);
            const string replicate = "Single";

            //Before generating this report, check that it exists
            string reportName = Resources.ReportSpecList_GetDefaults_Peptide_Ratio_Results;
            Settings.Default.PersistedViews.ResetDefaults();
            Assert.IsNotNull(Settings.Default.PersistedViews.GetViewSpecList(PersistedViews.MainGroup.Id)
                .GetView(Resources.ReportSpecList_GetDefaults_Peptide_Ratio_Results));

            //First, programmatically generate the report
            SrmDocument doc = ResultsUtil.DeserializeDocument(docPath);

            //Attach replicate
            ProgressStatus status;
            doc = CommandLine.ImportResults(doc, docPath, replicate, MsDataFileUri.Parse(rawPath), null, null, out status);
            Assert.IsNull(status);

            string programmaticReport;
            MemoryDocumentContainer memoryDocumentContainer = new MemoryDocumentContainer();
            Assert.IsTrue(memoryDocumentContainer.SetDocument(doc, memoryDocumentContainer.Document));
            SkylineDataSchema skylineDataSchema = new SkylineDataSchema(memoryDocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
            DocumentGridViewContext viewContext = new DocumentGridViewContext(skylineDataSchema);
            ViewInfo viewInfo = viewContext.GetViewInfo(PersistedViews.MainGroup.Id.ViewName(reportName));
            StringWriter writer = new StringWriter();
            status = new ProgressStatus("Exporting report");
            viewContext.Export(null, ref status, viewInfo, writer,
                new DsvWriter(CultureInfo.CurrentCulture, TextUtil.GetCsvSeparator(LocalizationHelper.CurrentCulture)));
            programmaticReport = writer.ToString();

            RunCommand("--in=" + docPath,
                       "--import-file=" + rawPath,
                       "--import-replicate-name=" + replicate,
                       "--report-name=" + reportName,
                       "--report-format=CSV",
                       "--report-file=" + outPath);

            string reportLines = File.ReadAllText(outPath);
            AssertEx.NoDiff(reportLines, programmaticReport);
        }
Ejemplo n.º 26
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);
        }
Ejemplo n.º 27
0
 public DocumentGridViewContext(SkylineDataSchema dataSchema)
     : base(dataSchema, GetDocumentGridRowSources(dataSchema))
 {
 }
Ejemplo n.º 28
0
 public ReportSpecConverter(SkylineDataSchema dataSchema)
 {
     DataSchema = dataSchema;
 }
Ejemplo n.º 29
0
 public DocumentGridViewContext(SkylineDataSchema dataSchema)
     : base(dataSchema, GetDocumentGridRowSources(dataSchema))
 {
 }
Ejemplo n.º 30
0
 public ReportSpecConverter(SkylineDataSchema dataSchema)
 {
     DataSchema = dataSchema;
 }
Ejemplo n.º 31
0
 public abstract IBindingList GetList(SkylineDataSchema dataSchema);
Ejemplo n.º 32
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);
     var status = new ProgressStatus(string.Format(Resources.ReportSpec_ReportToCsvString_Exporting__0__report,
         viewSpec.Name));
     var writer = new StringWriter();
     if (viewContext.Export(progressMonitor, ref status, viewContext.GetViewInfo(null, viewSpec), writer,
         new DsvWriter(CultureInfo.InvariantCulture, TextUtil.SEPARATOR_CSV)))
     {
         return writer.ToString();
     }
     return null;
 }
 public void TestAllColumnCaptionsAreLocalized()
 {
     var documentContainer = new MemoryDocumentContainer();
     Assert.IsTrue(documentContainer.SetDocument(new SrmDocument(SrmSettingsList.GetDefault()), documentContainer.Document));
     SkylineDataSchema skylineDataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer());
     var missingCaptions = new HashSet<ColumnCaption>();
     foreach (var columnDescriptor in
             EnumerateAllColumnDescriptors(skylineDataSchema, STARTING_TYPES))
     {
         var invariantCaption = skylineDataSchema.GetColumnCaption(columnDescriptor);
         if (!skylineDataSchema.DataSchemaLocalizer.HasEntry(invariantCaption))
         {
             missingCaptions.Add(invariantCaption);
         }
     }
     if (missingCaptions.Count == 0)
     {
         return;
     }
     StringWriter message = new StringWriter();
     WriteResXFile(message, missingCaptions);
     Assert.Fail("Missing localized column captions {0}", message);
 }