/// <summary> /// Adds a new document to the given phase. /// </summary> /// <param name="container">The container holding the document.</param> /// <param name="stream">The stream for the document.</param> /// <param name="name">The name for the document.</param> /// <param name="creator">The creator of the document.</param> public Document AddDocument(IDocumentContainer container, Stream stream, string name, User creator) { Condition.Requires(container) .IsNotNull(); Condition.Requires(stream) .IsNotNull() .Evaluate(f => f.Length > 0); Condition.Requires(name) .IsNotNullOrWhiteSpace(); Condition.Requires(creator) .IsNotNull(); string attachementId = this.CreateNewAttachementId(); this._documentSession.Advanced.DocumentStore.DatabaseCommands.PutAttachment(attachementId, null, stream, null); var document = new Document { CreatedByUserId = creator.Id, Name = name, AttachementId = attachementId }; container.Documents.Add(document); return document; }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var lib = GetOptimizationLibrary(docCurrent); if (lib != null && !lib.IsNone && !lib.IsUsable) lib = LoadLibrary(container, lib); if (lib == null || !ReferenceEquals(document.Id, container.Document.Id)) { // Loading was cancelled or document changed EndProcessing(document); return false; } SrmDocument docNew; do { // Change the document to use the new library docCurrent = container.Document; if (!ReferenceEquals(GetOptimizationLibrary(docCurrent), GetOptimizationLibrary(container.Document))) return false; docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangeTransitionPrediction(predict => predict.ChangeOptimizationLibrary(lib))); } while (!CompleteProcessing(container, docNew, docCurrent)); return true; }
protected override bool IsCanceled(IDocumentContainer container, object tag) { SrmSettings settings = container.Document.Settings; // If the document no longer contains any measured results, or the // measured results for the document are completely loaded. // TODO: Allow a single file loading to be canceled by removing it return !settings.HasResults || settings.MeasuredResults.IsLoaded; }
public DocumentGridForm(IDocumentContainer documentContainer) : this(new DocumentGridViewContext(new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()))) { var skylineWindow = documentContainer as SkylineWindow; if (null != skylineWindow) { DataGridViewPasteHandler.Attach(skylineWindow, DataGridView); } }
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); }
protected override bool IsCanceled(IDocumentContainer container, object tag) { // For our purposes, a better name for this would be "IsInterrupted": if the // doc changes out from under us, we just preserve the searches done so far // then get out, and use them in the OnDocumentChange which must be coming. if (ReferenceEquals(container.Document, tag)) // "tag" is the doc we started working on return false; // We are still working on the same doc // If the doc changed, then our work so far may be useless now CleanupProcessedNodesDict(container.Document); // Does any of our completed search work apply to the current document? return true; }
public LongWaitDlg(IDocumentContainer documentContainer = null, bool allowCancel = true) { InitializeComponent(); Icon = Resources.Skyline; _documentContainer = documentContainer; btnCancel.Visible = btnCancel.Enabled = IsCancellable = allowCancel; if (!IsCancellable) Height -= Height - btnCancel.Bottom; }
public static FoldChangeGrid ShowFoldChangeGrid(DockPanel dockPanel, Rectangle rcFloating, IDocumentContainer documentContainer, string groupComparisonName) { var grid = FindForm<FoldChangeGrid>(documentContainer, groupComparisonName); if (grid != null) { grid.Activate(); return grid; } grid = new FoldChangeGrid(); grid.SetBindingSource(FindOrCreateBindingSource(documentContainer, groupComparisonName)); grid.Show(dockPanel, rcFloating); return grid; }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { SrmDocument docNew, docOrig; do { docOrig = container.Document; var loadMonitor = new LoadMonitor(this, container, docOrig); docNew = DocumentRetentionTimes.RecalculateAlignments(docOrig, loadMonitor); if (null == docNew) { EndProcessing(docOrig); return(false); } }while (!CompleteProcessing(container, docNew, docOrig)); return(true); }
private void Add(IDocumentContainer document) { if (document == null) { return; } document.PropertyChanged += ObserveDocument; if (document.Pages != null) { foreach (var container in document.Pages) { Add(container); } } }
private IonMobilityLibrary LoadIonMobilityLibrary(IDocumentContainer container, IonMobilityLibrary dtLib) { // TODO: Something better than locking for the entire load lock (_loadedIonMobilityeLibraries) { IonMobilityLibrary libResult; if (!_loadedIonMobilityeLibraries.TryGetValue(dtLib.Name, out libResult)) { libResult = dtLib.Initialize(new LoadMonitor(this, container, dtLib)); if (libResult != null) { _loadedIonMobilityeLibraries.Add(libResult.Name, libResult); } } return(libResult); } }
public override IAsyncEnumerator <TryCatch <OrderByQueryPage> > CreateEnumerator( IDocumentContainer documentContainer, QueryState state = null, CancellationToken cancellationToken = default) { List <FeedRangeEpk> ranges = documentContainer.GetFeedRangesAsync( trace: NoOpTrace.Singleton, cancellationToken: cancellationToken).Result; Assert.AreEqual(1, ranges.Count); return(new OrderByQueryPartitionRangePageAsyncEnumerator( queryDataSource: documentContainer, sqlQuerySpec: new Cosmos.Query.Core.SqlQuerySpec("SELECT * FROM c"), feedRangeState: new FeedRangeState <QueryState>(ranges[0], state), partitionKey: null, queryPaginationOptions: new QueryPaginationOptions(pageSizeHint: 10), filter: "filter", cancellationToken: cancellationToken)); }
public LongWaitDlg(IDocumentContainer documentContainer = null, bool allowCancel = true) { InitializeComponent(); Icon = Resources.Skyline; _documentContainer = documentContainer; btnCancel.Visible = btnCancel.Enabled = IsCancellable = allowCancel; if (!IsCancellable) { Height -= Height - btnCancel.Bottom; } _cancellationTokenSource = new CancellationTokenSource(); _completionEvent = new ManualResetEvent(false); }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { SrmDocument docNew, docOrig; do { docOrig = container.Document; var loadMonitor = new LoadMonitor(this, container, docOrig); docNew = DocumentRetentionTimes.RecalculateAlignments(docOrig, loadMonitor); if (null == docNew) { EndProcessing(docOrig); return false; } } while (!CompleteProcessing(container, docNew, docOrig)); return true; }
private OptimizationLibrary LoadLibrary(IDocumentContainer container, OptimizationLibrary lib) { // TODO: Something better than locking for the entire load lock (_loadedLibraries) { OptimizationLibrary libResult; if (!_loadedLibraries.TryGetValue(lib.Name, out libResult)) { libResult = lib.Initialize(container.Document, new LoadMonitor(this, container, lib)); if (libResult != null) { _loadedLibraries.Add(libResult.Name, libResult); } } return(libResult); } }
public MetadataRuleEditor(IDocumentContainer documentContainer) { InitializeComponent(); _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var rootColumn = ColumnDescriptor.RootColumn(_dataSchema, typeof(ResultFile)); var viewContext = new SkylineViewContext(rootColumn, new StaticRowSource(new ExtractedMetadataResultRow[0])); _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile)); bindingListSource1.SetViewContext(viewContext); var sources = _metadataExtractor.GetSourceColumns().ToArray(); comboSourceText.Items.AddRange(sources); comboMetadataTarget.Items.AddRange(_metadataExtractor.GetTargetColumns().ToArray()); SelectItem(comboSourceText, PropertyPath.Root.Property(nameof(ResultFile.FileName))); FormatCultureInfo = CultureInfo.InvariantCulture; }
public static TryCatch <IQueryPipelineStage> MonadicCreate( IDocumentContainer documentContainer, SqlQuerySpec sqlQuerySpec, IReadOnlyList <FeedRangeEpk> targetRanges, Cosmos.PartitionKey?partitionKey, int pageSize, int maxConcurrency, CosmosElement continuationToken, CancellationToken cancellationToken) { if (targetRanges == null) { throw new ArgumentNullException(nameof(targetRanges)); } if (targetRanges.Count == 0) { throw new ArgumentException($"{nameof(targetRanges)} must have some elements"); } if (pageSize <= 0) { throw new ArgumentOutOfRangeException(nameof(pageSize)); } TryCatch <CrossPartitionState <QueryState> > monadicExtractState = MonadicExtractState(continuationToken, targetRanges); if (monadicExtractState.Failed) { return(TryCatch <IQueryPipelineStage> .FromException(monadicExtractState.Exception)); } CrossPartitionState <QueryState> state = monadicExtractState.Result; CrossPartitionRangePageAsyncEnumerator <QueryPage, QueryState> crossPartitionPageEnumerator = new CrossPartitionRangePageAsyncEnumerator <QueryPage, QueryState>( documentContainer, ParallelCrossPartitionQueryPipelineStage.MakeCreateFunction(documentContainer, sqlQuerySpec, pageSize, partitionKey, cancellationToken), comparer: Comparer.Singleton, maxConcurrency, state: state, cancellationToken: cancellationToken); ParallelCrossPartitionQueryPipelineStage stage = new ParallelCrossPartitionQueryPipelineStage(crossPartitionPageEnumerator, cancellationToken); return(TryCatch <IQueryPipelineStage> .FromResult(stage)); }
private RCalcIrt LoadCalculator(IDocumentContainer container, RCalcIrt calc) { // TODO: Something better than locking for the entire load lock (_loadedCalculators) { RCalcIrt calcResult; if (!_loadedCalculators.TryGetValue(calc.Name, out calcResult)) { calcResult = (RCalcIrt)calc.Initialize(new LoadMonitor(this, container, calc)); if (calcResult != null) { _loadedCalculators.Add(calcResult.Name, calcResult); } } return(calcResult); } }
public static TryCatch <CrossPartitionReadFeedAsyncEnumerator> MonadicCreate( IDocumentContainer documentContainer, QueryRequestOptions queryRequestOptions, string continuationToken, int pageSize, CancellationToken cancellationToken) { if (documentContainer == null) { throw new ArgumentNullException(nameof(documentContainer)); } TryCatch <CrossPartitionState <ReadFeedState> > monadicCrossPartitionState = MonadicParseCrossPartitionState(continuationToken); if (monadicCrossPartitionState.Failed) { return(TryCatch <CrossPartitionReadFeedAsyncEnumerator> .FromException(monadicCrossPartitionState.Exception)); } RntbdConstants.RntdbEnumerationDirection rntdbEnumerationDirection = RntbdConstants.RntdbEnumerationDirection.Forward; if ((queryRequestOptions?.Properties != null) && queryRequestOptions.Properties.TryGetValue(HttpConstants.HttpHeaders.EnumerationDirection, out object direction)) { rntdbEnumerationDirection = (byte)direction == (byte)RntbdConstants.RntdbEnumerationDirection.Reverse ? RntbdConstants.RntdbEnumerationDirection.Reverse : RntbdConstants.RntdbEnumerationDirection.Forward; } IComparer <PartitionRangePageAsyncEnumerator <ReadFeedPage, ReadFeedState> > comparer; if (rntdbEnumerationDirection == RntbdConstants.RntdbEnumerationDirection.Forward) { comparer = PartitionRangePageAsyncEnumeratorComparerForward.Singleton; } else { comparer = PartitionRangePageAsyncEnumeratorComparerReverse.Singleton; } CrossPartitionRangePageAsyncEnumerator <ReadFeedPage, ReadFeedState> crossPartitionEnumerator = new CrossPartitionRangePageAsyncEnumerator <ReadFeedPage, ReadFeedState>( documentContainer, CrossPartitionReadFeedAsyncEnumerator.MakeCreateFunction( documentContainer, queryRequestOptions, pageSize, cancellationToken), comparer: comparer, maxConcurrency: default,
public async Task NoChangesAsync() { IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems : 0); TryCatch <CrossPartitionChangeFeedAsyncEnumerator> monadicEnumerator = CrossPartitionChangeFeedAsyncEnumerator.MonadicCreate( documentContainer, new ChangeFeedRequestOptions(), ChangeFeedStartFrom.Beginning(), cancellationToken: default); Assert.IsTrue(monadicEnumerator.Succeeded); CrossPartitionChangeFeedAsyncEnumerator enumerator = monadicEnumerator.Result; Assert.IsTrue(await enumerator.MoveNextAsync()); Assert.IsTrue(enumerator.Current.Succeeded); Assert.IsTrue(enumerator.Current.Result is ChangeFeedNotModifiedPage); Assert.IsNotNull(enumerator.Current.Result.State); }
public LongWaitDlg(IDocumentContainer documentContainer = null, bool allowCancel = true) { InitializeComponent(); Icon = Resources.Skyline; _documentContainer = documentContainer; btnCancel.Visible = btnCancel.Enabled = IsCancellable = allowCancel; if (!IsCancellable) { Height -= Height - btnCancel.Bottom; } _originalFormHeight = Height; _originalMessageHeight = labelMessage.Height; _cancellationTokenSource = new CancellationTokenSource(); }
public MetadataRuleSetEditor(IDocumentContainer documentContainer, MetadataRuleSet metadataRuleSet, IEnumerable <MetadataRuleSet> existing) { InitializeComponent(); DocumentContainer = documentContainer; metadataRuleSet = metadataRuleSet ?? new MetadataRuleSet(typeof(ResultFile)); _originalName = metadataRuleSet.Name; _dataSchema = new SkylineDataSchema(documentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var rootColumn = ColumnDescriptor.RootColumn(_dataSchema, typeof(ExtractedMetadataResultRow)); var viewInfo = new ViewInfo(rootColumn, GetDefaultViewSpec()); var skylineViewContext = new MetadataResultViewContext(rootColumn, new StaticRowSource(new MetadataStepResult[0])); bindingListSourceResults.SetViewContext(skylineViewContext, viewInfo); _metadataExtractor = new MetadataExtractor(_dataSchema, typeof(ResultFile)); _ruleRowList = new List <RuleRow>(); bindingSourceRules.DataSource = new BindingList <RuleRow>(_ruleRowList); MetadataRuleSet = metadataRuleSet; _existing = ImmutableList.ValueOfOrEmpty(existing); }
public async Task NoChangesAsync() { IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems: 0); CrossPartitionChangeFeedAsyncEnumerator enumerator = CrossPartitionChangeFeedAsyncEnumerator.Create( documentContainer, new CrossFeedRangeState<ChangeFeedState>( new FeedRangeState<ChangeFeedState>[] { new FeedRangeState<ChangeFeedState>(FeedRangeEpk.FullRange, ChangeFeedState.Beginning()) }), ChangeFeedPaginationOptions.Default, cancellationToken: default); Assert.IsTrue(await enumerator.MoveNextAsync()); Assert.IsTrue(enumerator.Current.Succeeded); Assert.IsTrue(enumerator.Current.Result.Page is ChangeFeedNotModifiedPage); Assert.IsNotNull(enumerator.Current.Result.State); }
public async Task EmptyContainerTestAsync() { IDocumentContainer documentContainer = await this.CreateDocumentContainerAsync(numItems : 0); List <FeedRangeEpk> ranges = await documentContainer.GetFeedRangesAsync(NoOpTrace.Singleton, cancellationToken : default); TryCatch <ChangeFeedPage> monadicChangeFeedPage = await documentContainer.MonadicChangeFeedAsync( ChangeFeedState.Beginning(), ranges[0], pageSize : 10, changeFeedMode : ChangeFeedMode.Incremental, jsonSerializationFormat : null, trace : NoOpTrace.Singleton, cancellationToken : default); Assert.IsTrue(monadicChangeFeedPage.Succeeded); Assert.IsTrue(monadicChangeFeedPage.Result is ChangeFeedNotModifiedPage); }
public DocumentContainerPartitionRangeEnumerator( IDocumentContainer documentContainer, int partitionKeyRangeId, int pageSize, DocumentContainerState state = null) : base( new PartitionKeyRange() { Id = partitionKeyRangeId.ToString(), MinInclusive = partitionKeyRangeId.ToString(), MaxExclusive = partitionKeyRangeId.ToString() }, state ?? new DocumentContainerState(resourceIdentifier: 0)) { this.documentContainer = documentContainer ?? throw new ArgumentNullException(nameof(documentContainer)); this.partitionKeyRangeId = partitionKeyRangeId; this.pageSize = pageSize; }
public static T FindForm <T>(IDocumentContainer documentContainer, string groupComparisonName) where T : FoldChangeForm { foreach (var form in Application.OpenForms.OfType <T>()) { var foldChangeBindingSource = form.FoldChangeBindingSource; if (null == foldChangeBindingSource) { continue; } if (groupComparisonName == foldChangeBindingSource.GroupComparisonModel.GroupComparisonName && ReferenceEquals(documentContainer, foldChangeBindingSource.GroupComparisonModel.DocumentContainer)) { return(form); } } return(null); }
public static void CloseInapplicableForms(IDocumentContainer documentContainer) { var groupComparisonNames = new HashSet <string>( documentContainer.Document.Settings.DataSettings.GroupComparisonDefs.Select(def => def.Name)); foreach (var form in Application.OpenForms.OfType <FoldChangeForm>()) { if (!ReferenceEquals(documentContainer, form._documentContainer)) { continue; } if (!string.IsNullOrEmpty(form._groupComparisonName) && !groupComparisonNames.Contains(form._groupComparisonName)) { form.BeginInvoke(new Action(form.Close)); } } }
/// <inheritdoc/> public void Save(Stream stream, IDocumentContainer document) { if (stream is FileStream fileStream) { _outputPath = System.IO.Path.GetDirectoryName(fileStream.Name); } else { _outputPath = string.Empty; } var dxf = new DXF.DxfDocument(DXFH.DxfVersion.AutoCad2010); Add(dxf, document); dxf.Save(stream); ClearCache(isZooming: false); }
public async Task ChangeFeedIteratorCore_DoesNotUpdateContinuation_OnError() { int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync( numItems, failureConfigs : new FlakyDocumentContainer.FailureConfigs(inject429s: true, injectEmptyPages: true)); ChangeFeedIteratorCore changeFeedIteratorCore = new ChangeFeedIteratorCore( documentContainer, ChangeFeedMode.Incremental, new ChangeFeedRequestOptions(), ChangeFeedStartFrom.Beginning(), this.MockClientContext()); int count = 0; int numIterations = 500; while (numIterations-- > 0) { ResponseMessage responseMessage = await changeFeedIteratorCore.ReadNextAsync(); if (!(responseMessage.IsSuccessStatusCode || responseMessage.StatusCode == HttpStatusCode.NotModified)) { if (responseMessage.Headers.ContinuationToken != null) { Assert.Fail(); } } else { if (responseMessage.StatusCode != HttpStatusCode.NotModified) { count += GetChanges(responseMessage.Content).Count; } } if (count > numItems) { Assert.Fail(); } } Assert.AreEqual(numItems, count); }
private static async Task <List <CosmosElement> > ExecuteQueryAsync( string query, IReadOnlyList <CosmosObject> documents, IDocumentContainer documentContainer = null, int pageSize = 10) { if (documentContainer == null) { documentContainer = await CreateDocumentContainerAsync(documents); } List <CosmosElement> resultsFromDrainWithoutState = await DrainWithoutStateAsync(query, documentContainer, pageSize); List <CosmosElement> resultsFromDrainWithState = await DrainWithStateAsync(query, documentContainer, pageSize); Assert.IsTrue(resultsFromDrainWithoutState.SequenceEqual(resultsFromDrainWithState)); return(resultsFromDrainWithoutState); }
public async Task StartFromBeginningAsync(bool useContinuations) { int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); CrossPartitionChangeFeedAsyncEnumerator enumerator = CrossPartitionChangeFeedAsyncEnumerator.Create( documentContainer, new CrossFeedRangeState<ChangeFeedState>( new FeedRangeState<ChangeFeedState>[] { new FeedRangeState<ChangeFeedState>(FeedRangeEpk.FullRange, ChangeFeedState.Beginning()) }), ChangeFeedPaginationOptions.Default, cancellationToken: default); (int globalCount, double _) = await (useContinuations ? DrainWithUntilNotModifiedWithContinuationTokens(documentContainer, enumerator) : DrainUntilNotModifedAsync(enumerator)); Assert.AreEqual(numItems, globalCount); }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var ionMobilityLibrary = GetIonMobilityLibrary(docCurrent); if (ionMobilityLibrary != null && !ionMobilityLibrary.IsUsable) { ionMobilityLibrary = LoadIonMobilityLibrary(container, ionMobilityLibrary); } if (ionMobilityLibrary == null || !ReferenceEquals(document.Id, container.Document.Id)) { // Loading was cancelled or document changed EndProcessing(document); return(false); } var dtPredictor = docCurrent.Settings.PeptideSettings.Prediction.IonMobilityPredictor; var dtPredictorNew = !ReferenceEquals(ionMobilityLibrary, dtPredictor.IonMobilityLibrary) ? dtPredictor.ChangeLibrary(ionMobilityLibrary) : dtPredictor; if (dtPredictorNew == null || !ReferenceEquals(document.Id, container.Document.Id) || (Equals(dtPredictor, dtPredictorNew))) { // Loading was cancelled or document changed EndProcessing(document); return(false); } SrmDocument docNew; do { // Change the document to use the new predictor. docCurrent = container.Document; if (!ReferenceEquals(dtPredictor, docCurrent.Settings.PeptideSettings.Prediction.IonMobilityPredictor)) { return(false); } docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangePeptidePrediction(predictor => predictor.ChangeDriftTimePredictor(dtPredictorNew))); }while (!CompleteProcessing(container, docNew, docCurrent)); return(true); }
public async Task StartFromBeginningAsync(bool useContinuations) { int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); TryCatch <CrossPartitionChangeFeedAsyncEnumerator> monadicEnumerator = CrossPartitionChangeFeedAsyncEnumerator.MonadicCreate( documentContainer, new ChangeFeedRequestOptions(), ChangeFeedStartFrom.Beginning(), cancellationToken: default); Assert.IsTrue(monadicEnumerator.Succeeded); CrossPartitionChangeFeedAsyncEnumerator enumerator = monadicEnumerator.Result; int globalCount = await(useContinuations ? DrainWithUntilNotModifiedWithContinuationTokens(documentContainer, enumerator) : DrainUntilNotModifedAsync(enumerator)); Assert.AreEqual(numItems, globalCount); }
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)); }
public void Register(IDocumentContainer container) { // Only one document container at a time if (_documentContainer != null) { _documentContainer.Unlisten(OnDocumentChanged); } _documentContainer = container; // A null container can be used to clear if (container == null) { _document = null; } else { _document = container.Document; container.Listen(OnDocumentChanged); } RefreshCache(_document); }
public static CrossPartitionChangeFeedAsyncEnumerator Create( IDocumentContainer documentContainer, CrossFeedRangeState <ChangeFeedState> state, ChangeFeedPaginationOptions changeFeedPaginationOptions, CancellationToken cancellationToken) { changeFeedPaginationOptions ??= ChangeFeedPaginationOptions.Default; if (documentContainer == null) { throw new ArgumentNullException(nameof(documentContainer)); } CrossPartitionRangePageAsyncEnumerator <ChangeFeedPage, ChangeFeedState> crossPartitionEnumerator = new CrossPartitionRangePageAsyncEnumerator <ChangeFeedPage, ChangeFeedState>( documentContainer, CrossPartitionChangeFeedAsyncEnumerator.MakeCreateFunction( documentContainer, changeFeedPaginationOptions, cancellationToken), comparer: default /* this uses a regular queue instead of prioirty queue */,
public void Compose(IDocumentContainer container) { container.Page(page => { page.Margin(20); page.ContinuousSize(150); page.Header().Text("Header"); page.Content().PaddingVertical(10).Border(1).Padding(10).Column(column => { foreach (var index in Enumerable.Range(1, 100)) { column.Item().Text($"Line {index}").FontColor(Placeholders.Color()); } }); page.Footer().Text("Footer"); }); }
public async Task StartFromNowAsync(bool useContinuations) { int numItems = 100; IDocumentContainer documentContainer = await CreateDocumentContainerAsync(numItems); CrossPartitionChangeFeedAsyncEnumerator enumerator = CrossPartitionChangeFeedAsyncEnumerator.Create( documentContainer, new CrossFeedRangeState <ChangeFeedState>( new FeedRangeState <ChangeFeedState>[] { new FeedRangeState <ChangeFeedState>(FeedRangeEpk.FullRange, ChangeFeedState.Now()) }), ChangeFeedPaginationOptions.Default, cancellationToken: default); (int globalCount, double _) = await(useContinuations ? DrainWithUntilNotModifiedWithContinuationTokens(documentContainer, enumerator) : DrainUntilNotModifedAsync(enumerator)); Assert.AreEqual(0, globalCount); for (int i = 0; i < numItems; i++) { // Insert an item CosmosObject item = CosmosObject.Parse($"{{\"pk\" : {i} }}"); while (true) { TryCatch <Record> monadicCreateRecord = await documentContainer.MonadicCreateItemAsync(item, cancellationToken : default); if (monadicCreateRecord.Succeeded) { break; } } } (int globalCountAfter, double _) = await(useContinuations ? DrainWithUntilNotModifiedWithContinuationTokens(documentContainer, enumerator) : DrainUntilNotModifedAsync(enumerator)); Assert.AreEqual(numItems, globalCountAfter); }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var ionMobilityLibrary = GetIonMobilityLibrary(docCurrent); if (ionMobilityLibrary != null && !ionMobilityLibrary.IsUsable) { ionMobilityLibrary = LoadIonMobilityLibrary(container, ionMobilityLibrary); } if (ionMobilityLibrary == null || !ReferenceEquals(document.Id, container.Document.Id)) { // Loading was cancelled or document changed EndProcessing(document); return(false); } var ionMobilityFiltering = docCurrent.Settings.TransitionSettings.IonMobilityFiltering; var ionMobilityFilteringNew = !ReferenceEquals(ionMobilityLibrary, ionMobilityFiltering.IonMobilityLibrary) ? ionMobilityFiltering.ChangeLibrary(ionMobilityLibrary) : ionMobilityFiltering; if (ionMobilityFilteringNew == null || !ReferenceEquals(document.Id, container.Document.Id) || (Equals(ionMobilityFiltering, ionMobilityFilteringNew))) { // Loading was cancelled or document changed EndProcessing(document); return(false); } SrmDocument docNew; do { // Change the document to use the new ion mobility filter. docCurrent = container.Document; if (!ReferenceEquals(ionMobilityFiltering, docCurrent.Settings.TransitionSettings.IonMobilityFiltering)) { return(false); // Loading was cancelled or document changed } docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangeTransitionSettings(t => t.ChangeIonMobilityFiltering(ionMobilityFilteringNew))); }while (!CompleteProcessing(container, docNew, docCurrent)); return(true); }
private static async Task RunTest(AggressivePrefetchTestCase testCase) { CancellationTokenSource cts = new CancellationTokenSource(Timeout); int maxConcurrency = Convert.ToInt32(Math.Pow(2, testCase.PartitionCount)); using MockDocumentContainer monadicDocumentContainer = new MockDocumentContainer( partitionKeyDefinition: FullPipelineTests.partitionKeyDefinition, continuationCount: testCase.ContinuationCount, maxConcurrency: maxConcurrency, cancellationToken: cts.Token); IDocumentContainer documentContainer = await FullPipelineTests.CreateDocumentContainerAsync( Documents, monadicDocumentContainer, testCase.PartitionCount); IReadOnlyList <FeedRangeEpk> feedRanges = await documentContainer.GetFeedRangesAsync(NoOpTrace.Singleton, cts.Token); Assert.AreEqual(maxConcurrency, feedRanges.Count); Task <List <CosmosElement> > resultTask = FullPipelineTests.DrainWithoutStateAsync( testCase.Query, documentContainer, pageSize: 10); for (int i = 0; i < testCase.ContinuationCount; i++) { while (monadicDocumentContainer.CountWaiters < maxConcurrency && !cts.IsCancellationRequested) { await Task.Delay(PollingInterval); } monadicDocumentContainer.Release(maxConcurrency); } IReadOnlyList <CosmosElement> actualDocuments = await resultTask; actualDocuments.Should().HaveCount(1); actualDocuments.First().Should().Be(testCase.ExpectedDocument); }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var calc = GetIrtCalculator(docCurrent); if (calc != null && !calc.IsUsable) calc = LoadCalculator(container, calc); if (calc == null || !ReferenceEquals(document.Id, container.Document.Id)) { // Loading was cancelled or document changed EndProcessing(document); return false; } var rtRegression = docCurrent.Settings.PeptideSettings.Prediction.RetentionTime; var rtRegressionNew = !ReferenceEquals(calc, rtRegression.Calculator) ? rtRegression.ChangeCalculator(calc) : rtRegression; if (rtRegressionNew.IsAutoCalcRequired(docCurrent, null)) rtRegressionNew = AutoCalcRegressions(container, rtRegressionNew); if (rtRegressionNew == null || !ReferenceEquals(document.Id, container.Document.Id) || // No change in the regression, including reference equal standard peptides (Equals(rtRegression, rtRegressionNew) && rtRegression.SamePeptides(rtRegressionNew))) { // Loading was cancelled or document changed EndProcessing(document); return false; } SrmDocument docNew; do { // Change the document to use the new calculator and regression information. docCurrent = container.Document; if (!ReferenceEquals(rtRegression, docCurrent.Settings.PeptideSettings.Prediction.RetentionTime)) return false; docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangePeptidePrediction(predict => predict.ChangeRetentionTime(rtRegressionNew))); } while (!CompleteProcessing(container, docNew, docCurrent)); return true; }
public EditGroupComparisonDlg(IDocumentContainer documentContainer, GroupComparisonDef groupComparisonDef, IEnumerable<GroupComparisonDef> existingGroupComparisons) : base(new GroupComparisonModel(documentContainer, null) { GroupComparisonDef = groupComparisonDef}) { InitializeComponent(); Icon = Resources.Skyline; _originalGroupComparisonDef = groupComparisonDef; _existingGroupComparisons = existingGroupComparisons; if (documentContainer == null) { btnPreview.Visible = false; } tbxName.Text = groupComparisonDef.Name ?? string.Empty; tbxConfidenceLevel.TextChanged += tbxConfidenceLevel_TextChanged; comboControlAnnotation.SelectedIndexChanged += comboControlAnnotation_SelectedIndexChanged; comboCaseValue.SelectedIndexChanged += comboCaseValue_SelectedIndexChanged; comboControlValue.SelectedIndexChanged += comboControlValue_SelectedIndexChanged; comboIdentityAnnotation.SelectedIndexChanged += comboIdentityAnnotation_SelectedIndexChanged; comboNormalizationMethod.SelectedIndexChanged += comboNormalizationMethod_SelectedIndexChanged; radioScopeProtein.CheckedChanged += radioScope_CheckedChanged; radioScopePeptide.CheckedChanged += radioScope_CheckedChanged; }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var ionMobilityLibrary = GetIonMobilityLibrary(docCurrent); if (ionMobilityLibrary != null && !ionMobilityLibrary.IsUsable) ionMobilityLibrary = LoadIonMobilityLibrary(container, ionMobilityLibrary); if (ionMobilityLibrary == null || !ReferenceEquals(document.Id, container.Document.Id)) { // Loading was cancelled or document changed EndProcessing(document); return false; } var dtPredictor = docCurrent.Settings.PeptideSettings.Prediction.DriftTimePredictor; var dtPredictorNew = !ReferenceEquals(ionMobilityLibrary, dtPredictor.IonMobilityLibrary) ? dtPredictor.ChangeLibrary(ionMobilityLibrary) : dtPredictor; if (dtPredictorNew == null || !ReferenceEquals(document.Id, container.Document.Id) || (Equals(dtPredictor, dtPredictorNew))) { // Loading was cancelled or document changed EndProcessing(document); return false; } SrmDocument docNew; do { // Change the document to use the new predictor. docCurrent = container.Document; if (!ReferenceEquals(dtPredictor, docCurrent.Settings.PeptideSettings.Prediction.DriftTimePredictor)) return false; docNew = docCurrent.ChangeSettings(docCurrent.Settings.ChangePeptidePrediction(predictor => predictor.ChangeDriftTimePredictor(dtPredictorNew))); } while (!CompleteProcessing(container, docNew, docCurrent)); return true; }
protected override bool IsCanceled(IDocumentContainer container, object tag) { return false; }
private void CompleteProcessing(IDocumentContainer container, BackgroundProteome backgroundProteomeWithDigestions) { SrmDocument docCurrent; SrmDocument docNew; do { docCurrent = container.Document; docNew = ChangeBackgroundProteome(docCurrent, backgroundProteomeWithDigestions); } while (!CompleteProcessing(container, docNew, docCurrent)); }
public DigestHelper(BackgroundProteomeManager manager, IDocumentContainer container, SrmDocument document, string nameProteome, string pathProteome, bool isTemporary) { _manager = manager; _container = container; _document = document; _nameProteome = nameProteome; _pathProteome = pathProteome; _isTemporary = isTemporary; }
private OptimizationLibrary LoadLibrary(IDocumentContainer container, OptimizationLibrary lib) { // TODO: Something better than locking for the entire load lock (_loadedLibraries) { OptimizationLibrary libResult; if (!_loadedLibraries.TryGetValue(lib.Name, out libResult)) { libResult = lib.Initialize(container.Document, new LoadMonitor(this, container, lib)); if (libResult != null) _loadedLibraries.Add(libResult.Name, libResult); } return libResult; } }
protected bool CompleteProcessing(IDocumentContainer container, SrmDocument docNew, SrmDocument docOriginal) { lock (_processing) { if (!container.SetDocument(docNew, docOriginal)) return false; EndProcessing(docOriginal); } return true; }
public void Unregister(IDocumentContainer container) { container.Unlisten(OnDocumentChanged); }
public SrmSettingsChangeMonitor(IProgressMonitor progressMonitor, string formatString, IDocumentContainer documentContainer = null, SrmDocument startDocument = null) { _progressMonitor = progressMonitor; _documentContainer = documentContainer; _startDocument = startDocument; if (_startDocument == null && documentContainer != null) _startDocument = documentContainer.Document; if (!formatString.Contains('{')) _status = new ProgressStatus(formatString); else { _formatString = formatString; // Set status string to empty, since it should be reset very quickly _status = new ProgressStatus(string.Empty); } }
private RCalcIrt LoadCalculator(IDocumentContainer container, RCalcIrt calc) { // TODO: Something better than locking for the entire load lock (_loadedCalculators) { RCalcIrt calcResult; if (!_loadedCalculators.TryGetValue(calc.Name, out calcResult)) { calcResult = (RCalcIrt) calc.Initialize(new LoadMonitor(this, container, calc)); if (calcResult != null) _loadedCalculators.Add(calcResult.Name, calcResult); } return calcResult; } }
public GroupComparisonModel(IDocumentContainer documentContainer, string groupComparisonName) { _documentContainer = documentContainer; GroupComparisonName = groupComparisonName; Document = documentContainer.Document; }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { if (!FastaImporter.HasWebAccess()) // Do we even have web access? return false; // Return silently rather than flashing the progress bar SrmDocument docNew, docOrig; do { docOrig = container.Document; var loadMonitor = new LoadMonitor(this, container, docOrig); docNew = LookupProteinMetadata(docOrig, loadMonitor); if (null == docNew) { EndProcessing(docOrig); return false; } } while (!CompleteProcessing(container, docNew, docOrig)); CleanupProcessedNodesDict(docNew); // Drop any completed work, we're done with it return true; }
private IonMobilityLibrary LoadIonMobilityLibrary(IDocumentContainer container, IonMobilityLibrary dtLib) { // TODO: Something better than locking for the entire load lock (_loadedIonMobilityeLibraries) { IonMobilityLibrary libResult; if (!_loadedIonMobilityeLibraries.TryGetValue(dtLib.Name, out libResult)) { libResult = (IonMobilityLibrary) dtLib.Initialize(new LoadMonitor(this, container, dtLib)); if (libResult != null) _loadedIonMobilityeLibraries.Add(libResult.Name, libResult); } return libResult; } }
private static RetentionTimeRegression AutoCalcRegressions(IDocumentContainer container, RetentionTimeRegression rtRegression) { var document = container.Document; var dictSeqToPeptide = new Dictionary<string, PeptideDocNode>(); foreach (var nodePep in document.Peptides) { if (nodePep.IsDecoy) continue; string seqMod = document.Settings.GetSourceTextId(nodePep); if (!dictSeqToPeptide.ContainsKey(seqMod)) dictSeqToPeptide.Add(seqMod, nodePep); } int minCount = 0; try { var regressionPeps = rtRegression.Calculator.ChooseRegressionPeptides(dictSeqToPeptide.Keys, out minCount); var setRegression = new HashSet<string>(regressionPeps); dictSeqToPeptide = dictSeqToPeptide.Where(p => setRegression.Contains(p.Key)) .ToDictionary(p => p.Key, p => p.Value); } catch (IncompleteStandardException) { // Without a full set of regression peptides, no auto-calculation is possible dictSeqToPeptide.Clear(); } var dictStandardPeptides = dictSeqToPeptide.ToDictionary(p => p.Value.Peptide.GlobalIndex, p => p.Value); // Must have standard peptides, all with results if (dictSeqToPeptide.Count == 0) return rtRegression.ClearEquations(); else if (dictSeqToPeptide.Values.Any(nodePep => !nodePep.HasResults)) return rtRegression.ClearEquations(dictStandardPeptides); var calculator = rtRegression.Calculator; var dictSeqToScore = dictSeqToPeptide.ToDictionary(p => p.Key, p => calculator.ScoreSequence(p.Key) ?? calculator.UnknownScore); var dictFileIdToCorr = new Dictionary<int, IList<TimeScorePair>>(); var listPepCorr = new List<TimeScorePair>(); foreach (var seqToPeptide in dictSeqToPeptide) { var nodePep = seqToPeptide.Value; double? time = nodePep.SchedulingTime; if (!time.HasValue) continue; double score = dictSeqToScore[seqToPeptide.Key]; listPepCorr.Add(new TimeScorePair(time.Value, score)); foreach (var fileId in nodePep.Results.Where(r => r != null) .SelectMany(r => r) .Select(chromInfo => chromInfo.FileId)) { IList<TimeScorePair> listTimeScores; if (!dictFileIdToCorr.TryGetValue(fileId.GlobalIndex, out listTimeScores)) listTimeScores = dictFileIdToCorr[fileId.GlobalIndex] = new List<TimeScorePair>(); time = nodePep.GetSchedulingTime(fileId); if (!time.HasValue) continue; listTimeScores.Add(new TimeScorePair(time.Value, score)); } } // If not all standard peptides have at least some retention time value, fail prediction if (listPepCorr.Count != dictSeqToPeptide.Count) return rtRegression.ClearEquations(dictStandardPeptides); // Only calculate regressions for files with retention times for all of the standards var fileIdToConversions = from p in dictFileIdToCorr where p.Value.Count == dictSeqToPeptide.Count select new KeyValuePair<int, RegressionLine>(p.Key, CalcConversion(p.Value, minCount)); return rtRegression.ChangeEquations(new RegressionLineElement(CalcConversion(listPepCorr, minCount)), fileIdToConversions, dictStandardPeptides); }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { var loader = new Loader(this, container, document, docCurrent); loader.Load(); return false; }
protected override bool LoadBackground(IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { // Only allow one background proteome to load at a time. This can // get tricky, if the user performs an undo and then a redo across // a change in background proteome. // Our first priority is doing the digestions, the second is accessing web // services to add missing protein metadata. lock (_lockLoadBackgroundProteome) { BackgroundProteome originalBackgroundProteome = GetBackgroundProteome(docCurrent); // Check to see whether the Digestion already exists but has not been queried yet. BackgroundProteome backgroundProteomeWithDigestions = new BackgroundProteome(originalBackgroundProteome, true); if (IsNotLoadedExplained(docCurrent, backgroundProteomeWithDigestions, true) == null) { // digest is ready, and protein metdata is resolved CompleteProcessing(container, backgroundProteomeWithDigestions); return true; } // are we here to do the digest, or to resolve the protein metadata? bool getMetadata = (IsNotLoadedExplained(docCurrent, backgroundProteomeWithDigestions, false) == null) && backgroundProteomeWithDigestions.NeedsProteinMetadataSearch; string name = originalBackgroundProteome.Name; ProgressStatus progressStatus = new ProgressStatus(string.Format(getMetadata?Resources.BackgroundProteomeManager_LoadBackground_Resolving_protein_details_for__0__proteome:Resources.BackgroundProteomeManager_LoadBackground_Digesting__0__proteome, name)); try { using (FileSaver fs = new FileSaver(originalBackgroundProteome.DatabasePath, StreamManager)) { File.Copy(originalBackgroundProteome.DatabasePath, fs.SafeName, true); var digestHelper = new DigestHelper(this, container, docCurrent, name, fs.SafeName, true); bool success; if (getMetadata) success = digestHelper.LookupProteinMetadata(ref progressStatus); else success = (digestHelper.Digest(ref progressStatus) != null); if (!success) { // Processing was canceled EndProcessing(docCurrent); UpdateProgress(progressStatus.Cancel()); return false; } using (var proteomeDb = ProteomeDb.OpenProteomeDb(originalBackgroundProteome.DatabasePath)) { proteomeDb.DatabaseLock.AcquireWriterLock(int.MaxValue); try { if (!fs.Commit()) { EndProcessing(docCurrent); throw new IOException( string.Format( Resources .BackgroundProteomeManager_LoadBackground_Unable_to_rename_temporary_file_to__0__, fs.RealName)); } } finally { proteomeDb.DatabaseLock.ReleaseWriterLock(); } } CompleteProcessing(container, new BackgroundProteome(originalBackgroundProteome, true)); UpdateProgress(progressStatus.Complete()); return true; } } catch (Exception x) { var message = new StringBuilder(); message.AppendLine( string.Format(Resources.BackgroundProteomeManager_LoadBackground_Failed_updating_background_proteome__0__, name)); message.Append(x.Message); UpdateProgress(progressStatus.ChangeErrorException(new IOException(message.ToString(), x))); return false; } } }
protected override bool IsCanceled(IDocumentContainer container, object tag) { return !ReferenceEquals(container.Document, tag); }
public void Register(IDocumentContainer container) { // Only one document container at a time if (_documentContainer != null) _documentContainer.Unlisten(OnDocumentChanged); _documentContainer = container; // A null container can be used to clear if (container == null) { _document = null; } else { _document = container.Document; container.Listen(OnDocumentChanged); } RefreshCache(_document); }
public Loader(ChromatogramManager manager, IDocumentContainer container, SrmDocument document, SrmDocument docCurrent) { _manager = manager; _container = container; _document = document; _docCurrent = docCurrent; }