public ComplexStringAccreator(LibraryManager lm, IDynamicContainer d)
 {
     _d = d;
     _lm = lm;
     if (d.value.homogeneous)
     {
         if (d.value.any)
         {
             _innerAccreator = new ComplexAnyHomogeneousComplexResult(lm, d);
         }
         else
         {
             _innerAccreator = new ComplexAllHomogeneousComplexResult(lm, d);
         }
     }
     else
     {
         if (d.value.any)
         {
             _innerAccreator = new ComplexAnyHetrogeneousComplexResult(lm, d);
         }
         else
         {
             _innerAccreator = new ComplexAllHetrogeneousComplexResult(lm, d);
         }
     }
 }
Exemplo n.º 2
0
        public Project()
        {
            Uid = Guid.NewGuid();
            _services = new ServiceContainer();

            Name = "Project";

            _levels = new NamedResourceCollection<Level>();
            _levels.Modified += (s, e) => OnModified(EventArgs.Empty);

            _libraryManager = new LibraryManager();
            _libraryManager.Libraries.Modified += (s, e) => OnModified(EventArgs.Empty);

            Library defaultLibrary = new Library();

            _libraryManager.Libraries.Add(defaultLibrary);

            Extra = new List<XmlElement>();

            _texturePool = new MetaTexturePool();
            _texturePool.AddPool(defaultLibrary.Uid, defaultLibrary.TexturePool);

            _tilePools = new MetaTilePoolManager(_texturePool);
            _tilePools.AddManager(defaultLibrary.Uid, defaultLibrary.TilePoolManager);
            _objectPools = new MetaObjectPoolManager(_texturePool);
            _objectPools.AddManager(defaultLibrary.Uid, defaultLibrary.ObjectPoolManager);
            _tileBrushes = new MetaTileBrushManager();
            _tileBrushes.AddManager(defaultLibrary.Uid, defaultLibrary.TileBrushManager);

            SetDefaultLibrary(defaultLibrary);

            _services.AddService(typeof(TilePoolManager), _tilePools);

            ResetModified();
        }
Exemplo n.º 3
0
        public ImportPeptideSearchDlg(SkylineWindow skylineWindow, LibraryManager libraryManager)
        {
            SkylineWindow = skylineWindow;
            ImportPeptideSearch = new ImportPeptideSearch();

            InitializeComponent();

            Icon = Resources.Skyline;

            CurrentPage = Pages.spectra_page;
            btnNext.Text = Resources.ImportPeptideSearchDlg_ImportPeptideSearchDlg_Next;
            AcceptButton = btnNext;
            btnNext.Enabled = HasUnmatchedLibraryRuns(SkylineWindow.DocumentUI);

            // Create and add wizard pages
            BuildPepSearchLibControl = new BuildPeptideSearchLibraryControl(SkylineWindow, ImportPeptideSearch, libraryManager)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 50)
            };
            BuildPepSearchLibControl.InputFilesChanged += BuildPepSearchLibForm_OnInputFilesChanged;
            buildSearchSpecLibPage.Controls.Add(BuildPepSearchLibControl);

            ImportFastaControl = new ImportFastaControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            importFastaPage.Controls.Add(ImportFastaControl);

            MatchModificationsControl = new MatchModificationsControl(SkylineWindow, ImportPeptideSearch)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            matchModificationsPage.Controls.Add(MatchModificationsControl);

            TransitionSettingsControl = new TransitionSettingsControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(18, 60)
            };
            transitionSettingsUiPage.Controls.Add(TransitionSettingsControl);

            FullScanSettingsControl = new FullScanSettingsControl(SkylineWindow)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(18, 50)
            };
            ms1FullScanSettingsPage.Controls.Add(FullScanSettingsControl);

            ImportResultsControl = new ImportResultsControl(ImportPeptideSearch, SkylineWindow.DocumentFilePath)
            {
                Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right),
                Location = new Point(2, 60)
            };
            getChromatogramsPage.Controls.Add((Control) ImportResultsControl);

            _pagesToSkip = new HashSet<Pages>();
        }
Exemplo n.º 4
0
        public Project(Stream stream, ProjectResolver resolver)
        {
            _services = new ServiceContainer();
            _levels = new NamedResourceCollection<Level>();
            _levels.Modified += (s, e) => OnModified(EventArgs.Empty);

            _libraryManager = new LibraryManager();
            _libraryManager.Libraries.Modified += (s, e) => OnModified(EventArgs.Empty);

            Extra = new List<XmlElement>();

            XmlReaderSettings settings = new XmlReaderSettings() {
                CloseInput = true,
                IgnoreComments = true,
                IgnoreWhitespace = true,
            };

            using (XmlReader reader = XmlTextReader.Create(stream, settings)) {
                XmlSerializer serializer = new XmlSerializer(typeof(ProjectX));
                ProjectX proxy = serializer.Deserialize(reader) as ProjectX;

                FromXProxy(proxy, resolver, this);
            }

            ResetModified();
        }
Exemplo n.º 5
0
 public RuntimeLoadContext(LibraryManager libraryManager,
                           ICompilationEngine compilationEngine,
                           IAssemblyLoadContext defaultContext)
 {
     _projectAssemblyLoader = new ProjectAssemblyLoader(loadContextAccessor: null, compilationEngine: compilationEngine, libraryManager: libraryManager);
     _packageAssemblyLoader = new PackageAssemblyLoader(loadContextAccessor: null, libraryManager: libraryManager);
     _defaultContext = defaultContext;
 }
Exemplo n.º 6
0
 public ProjectAssemblyLoader(IAssemblyLoadContextAccessor loadContextAccessor,
                              ICompilationEngine compilationEngine,
                              LibraryManager libraryManager)
 {
     _loadContextAccessor = loadContextAccessor;
     _compilationEngine = compilationEngine;
     _libraryManager = libraryManager;
 }
Exemplo n.º 7
0
        // ReSharper restore UnusedMember.Local
        // ReSharper restore InconsistentNaming
        public ManageResultsDlg(IDocumentUIContainer documentUIContainer, LibraryManager libraryManager)
        {
            InitializeComponent();

            Icon = Resources.Skyline;

            DocumentUIContainer = documentUIContainer;
            var settings = DocumentUIContainer.Document.Settings;
            if (settings.HasResults)
            {
                foreach (var chromatogramSet in settings.MeasuredResults.Chromatograms)
                {
                    listResults.Items.Add(new ManageResultsAction(chromatogramSet));
                }
                listResults.SelectedIndices.Add(0);
            }

            var libraries = settings.PeptideSettings.Libraries;
            if (libraries.HasLibraries && libraries.HasDocumentLibrary)
            {
                DocumentLibrarySpec = libraries.LibrarySpecs.FirstOrDefault(x => x.IsDocumentLibrary);
                if (null != DocumentLibrarySpec)
                {
                    DocumentLibrary = libraryManager.TryGetLibrary(DocumentLibrarySpec);
                    if (null != DocumentLibrary)
                    {
                        foreach (var dataFile in DocumentLibrary.LibraryDetails.DataFiles)
                        {
                            listLibraries.Items.Add(dataFile);
                        }
                        listLibraries.SelectedIndices.Add(0);
                    }
                }
            }
            if (listLibraries.Items.Count == 0)
            {
                checkBoxRemoveLibraryRuns.Visible = false;
                int heightTabPage = manageResultsTabControl.TabPages[(int) TABS.Replicates].Height;
                int changeHeight = heightTabPage - listResults.Bottom - btnRemove.Top;
                listResults.Height += changeHeight;
                Height -= changeHeight;
                manageResultsTabControl.TabPages.RemoveAt((int)TABS.Libraries);
            }
            else if (listResults.Items.Count == 0)
            {
                checkBoxRemoveReplicates.Visible = false;
                int heightTabPage = manageResultsTabControl.TabPages[(int)TABS.Libraries].Height;
                int changeHeight = heightTabPage - listLibraries.Bottom - btnRemoveLibRun.Top;
                listLibraries.Height += changeHeight;
                Height -= changeHeight;
                manageResultsTabControl.TabPages.RemoveAt((int)TABS.Replicates);
            }

            LibraryRunsRemovedList = new List<string>();
            ChromatogramsRemovedList = new List<ChromatogramSet>();
        }
Exemplo n.º 8
0
        public CompilationEngineContext(LibraryManager libraryManager, IProjectGraphProvider projectGraphProvider, IFileWatcher fileWatcher, IServiceProvider services, FrameworkName targetFramework, string configuration)
        {
            LibraryManager = libraryManager;
            ProjectGraphProvider = projectGraphProvider;
            FileWatcher = fileWatcher;
            TargetFramework = targetFramework;
            Configuration = configuration;

            _services = new ServiceProvider(services);
        }
        public BuildPeptideSearchLibraryControl(SkylineWindow skylineWindow, ImportPeptideSearch importPeptideSearch, LibraryManager libraryManager)
        {
            SkylineWindow = skylineWindow;
            ImportPeptideSearch = importPeptideSearch;
            LibraryManager = libraryManager;

            InitializeComponent();

            textCutoff.Text = ImportPeptideSearch.CutoffScore.ToString(LocalizationHelper.CurrentCulture);

            if (SkylineWindow.Document.PeptideCount == 0)
                cbFilterForDocumentPeptides.Hide();
        }
Exemplo n.º 10
0
        /// <summary>
        ///     Convert Xml-based files to binary.
        /// </summary>
        public static void ConvertXmlFiles(PlaylistManager playlistManager, LibraryManager libraryManager)
        {
            var playlistsDirectory = Path.Combine(TabsterEnvironment.GetEnvironmentDirectoryPath(TabsterEnvironmentDirectory.UserData), "Playlists");

            // playlists are no longer stored as files, but are now stored in database
            if (Directory.Exists(playlistsDirectory))
            {
            #pragma warning disable 612
                var playlistProcessor = new TabsterFileProcessor<TablaturePlaylistDocument>(TablaturePlaylistDocument.FileVersion);
            #pragma warning restore 612

                foreach (var file in Directory.GetFiles(playlistsDirectory, string.Format("*{0}", Constants.TablaturePlaylistFileExtension), SearchOption.AllDirectories))
                {
                    var playlistFile = playlistProcessor.Load(file);

                    if (playlistFile != null)
                    {
                        var playlist = new TablaturePlaylist(playlistFile.Name) {Created = playlistFile.FileAttributes.Created};

                        foreach (var item in playlistFile)
                        {
                            playlist.Add(item);
                        }

                        playlistManager.Update(playlist);

                        try
                        {
                            File.Delete(file);
                        }

                        catch(Exception ex)
                        {
                            Logging.GetLogger().Error(string.Format("Error occured during playlist conversion: {0}", file), ex);
                        }
                    }
                }
            }

            if (Directory.Exists(libraryManager.TablatureDirectory))
            {
                foreach (var file in Directory.GetFiles(libraryManager.TablatureDirectory, string.Format("*{0}", Constants.TablatureFileExtension), SearchOption.AllDirectories))
                {
                    var tablatureFile = TabsterXmlFileConverter.ConvertTablatureDocument(file);

                    if (tablatureFile != null)
                        tablatureFile.Save(file);
                }
            }
        }
Exemplo n.º 11
0
        public static SrmDocument CreateNISTLibraryDocument(string textFasta, bool peptideList, string textLib,
            out LibraryManager libraryManager, out TestDocumentContainer docContainer, out int startRev)
        {
            var streamManager = new MemoryStreamManager();
            streamManager.TextFiles.Add(LibraryLoadTest.PATH_NIST_LIB, textLib);
            var librarySpec = new NistLibSpec("Yeast (NIST)", LibraryLoadTest.PATH_NIST_LIB);

            // For serialization, add the library spec to the settings
            TestLibraryList = new SpectralLibraryList { librarySpec };

            libraryManager = new LibraryManager { StreamManager = streamManager };
            docContainer = new TestDocumentContainer();

            SrmSettings settings = SrmSettingsList.GetDefault0_6();
            settings = settings.ChangePeptideLibraries(l => l.ChangeLibrarySpecs(new[] { librarySpec }));

            return CreateLibraryDocument(settings, textFasta, peptideList, docContainer, libraryManager, out startRev);
        }
Exemplo n.º 12
0
        private BaseItem RetrieveChild(BaseItem child)
        {
            var item = LibraryManager.GetMemoryItemById(child.Id);

            if (item != null)
            {
                if (item is IByReferenceItem)
                {
                    return(LibraryManager.GetOrAddByReferenceItem(item));
                }

                item.Parent = this;
            }
            else
            {
                child.Parent = this;
                LibraryManager.RegisterItem(child);
                item = child;
            }

            return(item);
        }
Exemplo n.º 13
0
        public IEnumerable <Episode> GetSeasonEpisodes(Season parentSeason, User user, DtoOptions options)
        {
            var queryFromSeries = ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons;

            // add optimization when this setting is not enabled
            var seriesKey = queryFromSeries ?
                            GetUniqueSeriesKey(this) :
                            GetUniqueSeriesKey(parentSeason);

            var query = new InternalItemsQuery(user)
            {
                AncestorWithPresentationUniqueKey = queryFromSeries ? null : seriesKey,
                SeriesPresentationUniqueKey       = queryFromSeries ? seriesKey : null,
                IncludeItemTypes = new[] { typeof(Episode).Name },
                SortBy           = new[] { ItemSortBy.SortName },
                DtoOptions       = options
            };

            if (user != null)
            {
                var config = user.Configuration;
                if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes)
                {
                    query.IsVirtualItem = false;
                }
                else if (!config.DisplayMissingEpisodes)
                {
                    query.IsMissing = false;
                }
                else if (!config.DisplayUnairedEpisodes)
                {
                    query.IsVirtualUnaired = false;
                }
            }

            var allItems = LibraryManager.GetItemList(query).OfType <Episode>();

            return(GetSeasonEpisodes(parentSeason, user, allItems, options));
        }
Exemplo n.º 14
0
        public override int GetChildCount(User user)
        {
            var seriesKey = GetUniqueSeriesKey(this);

            var result = LibraryManager.GetCount(new InternalItemsQuery(user)
            {
                AncestorWithPresentationUniqueKey = null,
                SeriesPresentationUniqueKey       = seriesKey,
                IncludeItemTypes = new[] { typeof(Season).Name },
                IsVirtualItem    = false,
                Limit            = 0,
                DtoOptions       = new Dto.DtoOptions
                {
                    Fields = new List <ItemFields>
                    {
                    },
                    EnableImages = false
                }
            });

            return(result);
        }
Exemplo n.º 15
0
        private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken)
        {
            var all = AllArtists;

            foreach (var i in all)
            {
                // This should not be necessary but we're seeing some cases of it
                if (string.IsNullOrEmpty(i))
                {
                    continue;
                }

                var artist = LibraryManager.GetArtist(i);

                if (!artist.IsAccessedByName)
                {
                    continue;
                }

                await artist.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// This is called before any metadata refresh and returns true or false indicating if changes were made
        /// </summary>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public override bool BeforeMetadataRefresh()
        {
            var hasChanges = base.BeforeMetadataRefresh();

            var locationType = LocationType;

            if (locationType == LocationType.FileSystem || locationType == LocationType.Offline)
            {
                if (!IndexNumber.HasValue && !string.IsNullOrEmpty(Path))
                {
                    IndexNumber = IndexNumber ?? LibraryManager.GetSeasonNumberFromPath(Path);

                    // If a change was made record it
                    if (IndexNumber.HasValue)
                    {
                        hasChanges = true;
                    }
                }
            }

            return(hasChanges);
        }
        public void Read_Artifacts_Stream_Dune()
        {
            var listError           = new List <string>();
            var countInputArtifacts = 1000;

            _mockValidator.Setup(mock => mock.Validate(It.IsAny <LibraryArtifact>()))
            .Returns(() => (true, listError));

            var manager = new LibraryManager(_mockValidator.Object);

            using (var stream = File.Open(_path, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                manager.Write(ArtifactInitializer.Initializer(countInputArtifacts, 0), stream);
            }

            using (var stream = File.Open(_path, FileMode.Open, FileAccess.Read, FileShare.None))
            {
                var result = ArtifactCounter.CountArtifact(stream);

                Assert.AreEqual(countInputArtifacts, result);
            }
        }
Exemplo n.º 18
0
        public override void UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken)
        {
            base.UpdateToRepository(updateReason, cancellationToken);

            var localAlternates = GetLocalAlternateVersionIds()
                                  .Select(i => LibraryManager.GetItemById(i))
                                  .Where(i => i != null);

            foreach (var item in localAlternates)
            {
                item.ImageInfos      = ImageInfos;
                item.Overview        = Overview;
                item.ProductionYear  = ProductionYear;
                item.PremiereDate    = PremiereDate;
                item.CommunityRating = CommunityRating;
                item.OfficialRating  = OfficialRating;
                item.Genres          = Genres;
                item.ProviderIds     = ProviderIds;

                item.UpdateToRepository(ItemUpdateType.MetadataDownload, cancellationToken);
            }
        }
Exemplo n.º 19
0
        private ItemResolveArgs CreateResolveArgs(IDirectoryService directoryService)
        {
            var path = ContainingFolderPath;

            var args = new ItemResolveArgs(ConfigurationManager.ApplicationPaths, directoryService)
            {
                FileInfo       = new DirectoryInfo(path),
                Path           = path,
                Parent         = Parent,
                CollectionType = CollectionType
            };

            // Gather child folder and files
            if (args.IsDirectory)
            {
                var isPhysicalRoot = args.IsPhysicalRoot;

                // When resolving the root, we need it's grandchildren (children of user views)
                var flattenFolderDepth = isPhysicalRoot ? 2 : 0;

                var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf);

                // Need to remove subpaths that may have been resolved from shortcuts
                // Example: if \\server\movies exists, then strip out \\server\movies\action
                if (isPhysicalRoot)
                {
                    var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Keys);

                    fileSystemDictionary = paths.Select(i => (FileSystemInfo) new DirectoryInfo(i)).ToDictionary(i => i.FullName);
                }

                args.FileSystemDictionary = fileSystemDictionary;
            }

            PhysicalLocationsList = args.PhysicalLocations.ToList();

            return(args);
        }
Exemplo n.º 20
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var item = context.SelectedItems.FirstOrDefault() as LibraryTreeViewItem;

            if (item == null)
            {
                return;
            }

            var name = item.Library.Name;

            do
            {
                name = AppHost.Prompt("Enter the new name of the library:", "Quick Access", name);
                if (string.IsNullOrEmpty(name))
                {
                    return;
                }

                if (LibraryManager.Libraries.Any(w => w != item.Library && string.Compare(w.Name, name, StringComparison.InvariantCultureIgnoreCase) == 0))
                {
                    AppHost.MessageBox($"A library with the name '{name}' already exists.\n\nPlease choose another name.", "Information", MessageBoxButton.OK, MessageBoxImage.Information);
                }
                else
                {
                    break;
                }
            }while (true);

            LibraryManager.Rename(item.Library, name);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Gets the index by person.
        /// </summary>
        /// <param name="user">The user.</param>
        /// <param name="personTypes">The person types we should match on</param>
        /// <param name="indexName">Name of the index.</param>
        /// <returns>IEnumerable{BaseItem}.</returns>
        protected IEnumerable <BaseItem> GetIndexByPerson(User user, List <string> personTypes, string indexName)
        {
            // Even though this implementation means multiple iterations over the target list - it allows us to defer
            // the retrieval of the individual children for each index value until they are requested.
            using (new Profiler(indexName + " Index Build for " + Name, Logger))
            {
                // Put this in a local variable to avoid an implicitly captured closure
                var currentIndexName = indexName;

                var us         = this;
                var candidates = RecursiveChildren.Where(i => i.IncludeInIndex && i.AllPeople != null).ToList();

                return(candidates.AsParallel().SelectMany(i => i.AllPeople.Where(p => personTypes.Contains(p.Type))
                                                          .Select(a => a.Name))
                       .Distinct()
                       .Select(i =>
                {
                    try
                    {
                        return LibraryManager.GetPerson(i).Result;
                    }
                    catch (IOException ex)
                    {
                        Logger.ErrorException("Error getting person {0}", ex, i);
                        return null;
                    }
                    catch (AggregateException ex)
                    {
                        Logger.ErrorException("Error getting person {0}", ex, i);
                        return null;
                    }
                })
                       .Where(i => i != null)
                       .Select(a => new IndexFolder(us, a,
                                                    candidates.Where(i => i.AllPeople.Any(p => personTypes.Contains(p.Type) && p.Name.Equals(a.Name, StringComparison.OrdinalIgnoreCase))
                                                                     ), currentIndexName)));
            }
        }
Exemplo n.º 22
0
        internal IEnumerable <Episode> GetEpisodes(User user, int seasonNumber, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable <Episode> additionalEpisodes)
        {
            var episodes = GetRecursiveChildren(user, i => i is Episode)
                           .Cast <Episode>();

            episodes = FilterEpisodesBySeason(episodes, seasonNumber, DisplaySpecialsWithSeasons);

            episodes = episodes.Concat(additionalEpisodes).Distinct();

            if (!includeMissingEpisodes)
            {
                episodes = episodes.Where(i => !i.IsMissingEpisode);
            }
            if (!includeVirtualUnairedEpisodes)
            {
                episodes = episodes.Where(i => !i.IsVirtualUnaired);
            }

            var sortBy = seasonNumber == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder;

            return(LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending)
                   .Cast <Episode>());
        }
Exemplo n.º 23
0
        private void BindLibraryManager(LibraryManager manager)
        {
            if (_libraryManager == manager)
            {
                return;
            }

            if (_libraryManager != null)
            {
                _libraryManager.Libraries.ResourceAdded    -= _libraryEventBindings[EventBindings.LibraryAdded];
                _libraryManager.Libraries.ResourceRemoved  -= _libraryEventBindings[EventBindings.LibraryRemoved];
                _libraryManager.Libraries.ResourceModified -= _libraryEventBindings[EventBindings.LibraryModified];
            }

            _libraryManager = manager;

            if (_libraryManager != null)
            {
                _libraryManager.Libraries.ResourceAdded    += _libraryEventBindings[EventBindings.LibraryAdded];
                _libraryManager.Libraries.ResourceRemoved  += _libraryEventBindings[EventBindings.LibraryRemoved];
                _libraryManager.Libraries.ResourceModified += _libraryEventBindings[EventBindings.LibraryModified];
            }
        }
Exemplo n.º 24
0
        public override void Execute(object parameter)
        {
            var context = parameter as ContentTreeContext;

            if (context == null)
            {
                return;
            }

            var item = context.SelectedItems.FirstOrDefault() as LibraryTreeViewItem;

            if (item == null)
            {
                return;
            }

            if (AppHost.MessageBox(string.Format("Are you sure you want to delete '{0}'?", item.Library.Name), "Confirmation", MessageBoxButton.OKCancel, MessageBoxImage.Question) != MessageBoxResult.OK)
            {
                return;
            }

            LibraryManager.Delete(item.Library);
        }
Exemplo n.º 25
0
        public void InitializeDevice()
        {
            Form.ClientSize = new Size(Width, Height);

            _meshFactory = new MeshFactory(this);
            MeshFactory  = _meshFactory;

            effect = new BasicEffect(Device);

            // Set light
            //effect.LightingEnabled = true;
            //effect.AmbientLightColor = Color.Gray.ToVector3();
            //effect.DirectionalLight0.Enabled = true;
            //effect.DirectionalLight0.DiffuseColor = Color.LemonChiffon.ToVector3();
            effect.EnableDefaultLighting();

            Device.RasterizerState = RasterizerState.CullNone;

            UpdateView();
            LibraryManager.LibraryStarted();

            Info.SetDevice(Device);
        }
Exemplo n.º 26
0
        public IEnumerable <Episode> GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable <Episode> allSeriesEpisodes)
        {
            if (allSeriesEpisodes == null)
            {
                return(GetEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes));
            }

            var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons);

            if (!includeMissingEpisodes)
            {
                episodes = episodes.Where(i => !i.IsMissingEpisode);
            }
            if (!includeVirtualUnairedEpisodes)
            {
                episodes = episodes.Where(i => !i.IsVirtualUnaired);
            }

            var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder;

            return(LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending)
                   .Cast <Episode>());
        }
Exemplo n.º 27
0
        //3. Zakończ wypożyczenie

        /// <summary>
        /// Funkcja rysująca na ekranie opcję kończenia wypożyczeń.
        /// </summary>
        /// <param name="library">Biblioteka</param>
        static void MenuEndBorrowing(LibraryManager library)
        {
            Console.WriteLine("Zakończ wypożyczenie");
            Console.WriteLine();
            Console.Write("ID wypożyczenia: ");

            int borrowingID;

            int.TryParse(Console.ReadLine(), out borrowingID);

            Console.WriteLine();

            try
            {
                library.EndBorrowing(borrowingID);
            }
            catch (ArgumentException ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine("Wypożyczenie nie zostało zakończone, wciśnij dowolny klawisz aby kontynuować...");
                Console.ReadKey();
            }
        }
Exemplo n.º 28
0
 protected override void Dispose(bool disposing)
 {
     try
     {
         if (this._componentID != 0)
         {
             if (GetService(typeof(SOleComponentManager)) is IOleComponentManager mgr)
             {
                 mgr.FRevokeComponent(this._componentID);
             }
             this._componentID = 0;
         }
         if (null != this._libraryManager)
         {
             this._libraryManager.Dispose();
             this._libraryManager = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
        public async Task UpdateAuthor()
        {
            var options = getDatabase("UpdateAuthorDB");

            await using (var context = new LibraryContext(options))
            {
                var _manager = new LibraryManager(context);
                await _manager.AddAuthor(SingleAuthor());

                await context.SaveChangesAsync();
            }
            await using (var context = new LibraryContext(options))
            {
                var _manager    = new LibraryManager(context);
                var checkUpdate = await _manager.UpdateAuthor(
                    new Author { Name = "AuthorName" }, 1);

                await context.SaveChangesAsync();

                Assert.Equal(1, checkUpdate);
                Assert.Equal("AuthorName", context.Authors.Single().Name);
            }
        }
Exemplo n.º 30
0
        public void Dispose()
        {
            Logger.Log.Debug("Disposing");

            ActiveLibrary = null;
            Libraries.Clear();
            Libraries = null;

            ActiveProject = null;
            Projects.Clear();
            Projects = null;

            CommandManager.Dispose();
            CommandManager = null;

            LibraryManager.Dispose();
            LibraryManager = null;

            WindowManager.Dispose();
            WindowManager = null;

            Logger.Log.Debug("Disposed");
        }
Exemplo n.º 31
0
        /// <summary>
        /// Loads the additional parts.
        /// </summary>
        /// <returns>IEnumerable{Video}.</returns>
        private IEnumerable <Video> LoadAdditionalParts()
        {
            IEnumerable <FileSystemInfo> files;

            if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd)
            {
                files = new DirectoryInfo(System.IO.Path.GetDirectoryName(Path))
                        .EnumerateDirectories()
                        .Where(i => !string.Equals(i.FullName, Path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsMultiPartFile(i.Name));
            }
            else
            {
                files = ResolveArgs.FileSystemChildren.Where(i =>
                {
                    if ((i.Attributes & FileAttributes.Directory) == FileAttributes.Directory)
                    {
                        return(false);
                    }

                    return(!string.Equals(i.FullName, Path, StringComparison.OrdinalIgnoreCase) && EntityResolutionHelper.IsVideoFile(i.FullName) && EntityResolutionHelper.IsMultiPartFile(i.Name));
                });
            }

            return(LibraryManager.ResolvePaths <Video>(files, null).Select(video =>
            {
                // Try to retrieve it from the db. If we don't find it, use the resolved version
                var dbItem = LibraryManager.RetrieveItem(video.Id) as Video;

                if (dbItem != null)
                {
                    dbItem.ResolveArgs = video.ResolveArgs;
                    video = dbItem;
                }

                return video;
            }).ToList());
        }
Exemplo n.º 32
0
        private void RemoveObsoleteSeasons(Series series)
        {
            // TODO Legacy. It's not really "physical" seasons as any virtual seasons are always converted to non-virtual in FillInMissingSeasonsAsync.
            var physicalSeasonNumbers = new HashSet <int>();
            var virtualSeasons        = new List <Season>();

            foreach (var existingSeason in series.Children.OfType <Season>())
            {
                if (existingSeason.LocationType != LocationType.Virtual && existingSeason.IndexNumber.HasValue)
                {
                    physicalSeasonNumbers.Add(existingSeason.IndexNumber.Value);
                }
                else if (existingSeason.LocationType == LocationType.Virtual)
                {
                    virtualSeasons.Add(existingSeason);
                }
            }

            foreach (var virtualSeason in virtualSeasons)
            {
                var seasonNumber = virtualSeason.IndexNumber;
                // If there's a physical season with the same number or no episodes in the season, delete it
                if ((seasonNumber.HasValue && physicalSeasonNumbers.Contains(seasonNumber.Value)) ||
                    !virtualSeason.GetEpisodes().Any())
                {
                    Logger.LogInformation("Removing virtual season {SeasonNumber} in series {SeriesName}", virtualSeason.IndexNumber, series.Name);

                    LibraryManager.DeleteItem(
                        virtualSeason,
                        new DeleteOptions
                    {
                        DeleteFileLocation = true
                    },
                        false);
                }
            }
        }
Exemplo n.º 33
0
        /// <summary>
        /// Finds the parts.
        /// </summary>
        protected override void FindParts()
        {
            if (IsFirstRun)
            {
                RegisterServerWithAdministratorAccess();
            }

            base.FindParts();

            HttpServer.Init(GetExports <IRestfulService>(false));

            ServerManager.AddWebSocketListeners(GetExports <IWebSocketListener>(false));

            StartServer(true);

            LibraryManager.AddParts(GetExports <IResolverIgnoreRule>(),
                                    GetExports <IVirtualFolderCreator>(),
                                    GetExports <IItemResolver>(),
                                    GetExports <IIntroProvider>(),
                                    GetExports <IBaseItemComparer>(),
                                    GetExports <ILibraryPostScanTask>());

            ProviderManager.AddParts(GetExports <IImageProvider>(), GetExports <IMetadataService>(), GetExports <IMetadataProvider>(),
                                     GetExports <IMetadataSaver>(),
                                     GetExports <IImageSaver>(),
                                     GetExports <IExternalId>());

            SeriesOrderManager.AddParts(GetExports <ISeriesOrderProvider>());

            ImageProcessor.AddParts(GetExports <IImageEnhancer>());

            LiveTvManager.AddParts(GetExports <ILiveTvService>());

            SessionManager.AddParts(GetExports <ISessionControllerFactory>());

            ChannelManager.AddParts(GetExports <IChannel>());
        }
Exemplo n.º 34
0
        protected void OnInitializeDevice()
        {
            Form.ClientSize = new Size(Width, Height);

            DeviceSettings9 settings = new DeviceSettings9();

            settings.CreationFlags   = CreateFlags.HardwareVertexProcessing;
            settings.Windowed        = true;
            settings.MultisampleType = MultisampleType.FourSamples;
            try
            {
                InitializeDevice(settings);
            }
            catch
            {
                // Disable 4xAA if not supported
                settings.MultisampleType = MultisampleType.None;
                try
                {
                    InitializeDevice(settings);
                }
                catch
                {
                    settings.CreationFlags = CreateFlags.SoftwareVertexProcessing;
                    try
                    {
                        InitializeDevice(settings);
                    }
                    catch
                    {
                        MessageBox.Show("Could not initialize DirectX device!");
                        return;
                    }
                }
            }
            LibraryManager.LibraryStarted();
        }
Exemplo n.º 35
0
        public override int GetRecursiveChildCount(User user)
        {
            var seriesKey = GetUniqueSeriesKey(this);

            var query = new InternalItemsQuery(user)
            {
                AncestorWithPresentationUniqueKey = null,
                SeriesPresentationUniqueKey       = seriesKey,
                DtoOptions = new Dto.DtoOptions(false)
                {
                    EnableImages = false
                }
            };

            if (query.IncludeItemTypes.Length == 0)
            {
                query.IncludeItemTypes = new[] { typeof(Episode).Name };
            }
            query.IsVirtualItem = false;
            query.Limit         = 0;
            var totalRecordCount = LibraryManager.GetCount(query);

            return(totalRecordCount);
        }
Exemplo n.º 36
0
        public virtual object GetRootFolders(HttpContext context)
        {
            YZRequest        request     = new YZRequest(context);
            string           libType     = request.GetString("libType");
            string           uid         = YZAuthHelper.LoginUserAccount;
            FolderCollection rootFolders = new FolderCollection();

            using (IYZDbProvider provider = YZDbProviderManager.DefaultProvider)
            {
                using (IDbConnection cn = provider.OpenConnection())
                {
                    LibraryCollection libs = LibraryManager.GetLibraries(provider, cn, uid, libType, null, null);
                    foreach (Library.Library lib in libs)
                    {
                        Folder folder = DirectoryManager.GetFolderByID(provider, cn, lib.FolderID);
                        folder.Name = lib.Name;

                        rootFolders.Add(folder);
                    }
                }
            }

            return(rootFolders);
        }
Exemplo n.º 37
0
        public override bool BeforeMetadataRefresh(bool replaceAllMetdata)
        {
            var hasChanges = base.BeforeMetadataRefresh(replaceAllMetdata);

            if (!IsLocked)
            {
                if (SourceType == SourceType.Library)
                {
                    try
                    {
                        if (LibraryManager.FillMissingEpisodeNumbersFromPath(this, replaceAllMetdata))
                        {
                            hasChanges = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError(ex, "Error in FillMissingEpisodeNumbersFromPath. Episode: {Episode}", Path ?? Name ?? Id.ToString());
                    }
                }
            }

            return(hasChanges);
        }
Exemplo n.º 38
0
        public static async Task LoadOtherStuffAsync()
        {
            // Start off a list of tasks we need to run before we can continue startup
            await Task.Run(async() =>
            {
                await Task.WhenAll(
                    DrivesManager.EnumerateDrivesAsync(),
                    CloudDrivesManager.EnumerateDrivesAsync(),
                    LibraryManager.EnumerateLibrariesAsync(),
                    NetworkDrivesManager.EnumerateDrivesAsync(),
                    WSLDistroManager.EnumerateDrivesAsync(),
                    SidebarPinnedController.InitializeAsync()
                    );
                await Task.WhenAll(
                    AppSettings.DetectQuickLook(),
                    TerminalController.InitializeAsync(),
                    JumpList.InitializeAsync(),
                    ExternalResourcesHelper.LoadOtherThemesAsync()
                    );
            });

            // Check for required updates
            new AppUpdater().CheckForUpdatesAsync();
        }
Exemplo n.º 39
0
        public static SrmDocument CreateNISTLibraryDocument(string textFasta, bool peptideList, string textLib,
                                                            out LibraryManager libraryManager, out TestDocumentContainer docContainer, out int startRev)
        {
            var streamManager = new MemoryStreamManager();

            streamManager.TextFiles.Add(LibraryLoadTest.PATH_NIST_LIB, textLib);
            var librarySpec = new NistLibSpec("Yeast (NIST)", LibraryLoadTest.PATH_NIST_LIB);

            // For serialization, add the library spec to the settings
            TestLibraryList = new SpectralLibraryList {
                librarySpec
            };

            libraryManager = new LibraryManager {
                StreamManager = streamManager
            };
            docContainer = new TestDocumentContainer();

            SrmSettings settings = SrmSettingsList.GetDefault0_6();

            settings = settings.ChangePeptideLibraries(l => l.ChangeLibrarySpecs(new[] { librarySpec }));

            return(CreateLibraryDocument(settings, textFasta, peptideList, docContainer, libraryManager, out startRev));
        }
Exemplo n.º 40
0
 internal ProjectContext(
     GlobalSettings globalSettings,
     ProjectDescription rootProject,
     LibraryDescription platformLibrary,
     NuGetFramework targetFramework,
     bool isPortable,
     string runtimeIdentifier,
     string packagesDirectory,
     LibraryManager libraryManager,
     LockFile lockfile,
     List <DiagnosticMessage> diagnostics)
 {
     Identity          = new ProjectContextIdentity(rootProject?.Path, targetFramework);
     GlobalSettings    = globalSettings;
     RootProject       = rootProject;
     PlatformLibrary   = platformLibrary;
     TargetFramework   = targetFramework;
     RuntimeIdentifier = runtimeIdentifier;
     PackagesDirectory = packagesDirectory;
     LibraryManager    = libraryManager;
     LockFile          = lockfile;
     IsPortable        = isPortable;
     Diagnostics       = diagnostics;
 }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="useBundledLibrary">
        /// If <code>true</code>, a bundled copy of fastText binary is extracted to process' current directory.
        /// You can set this to <code>false</code>, but then you must ensure that a compatible binary for your
        /// platform is discoverable by system library loader.
        ///
        /// You can compile your own binary from this specific fork: https://github.com/olegtarasov/fastText.
        /// </param>
        /// <param name="loggerFactory">Optional logger factory.</param>
        public FastTextWrapper(bool useBundledLibrary = true, ILoggerFactory loggerFactory = null)
        {
            _logger = loggerFactory?.CreateLogger <FastTextWrapper>();

            if (useBundledLibrary)
            {
                var accessor = new ResourceAccessor(Assembly.GetExecutingAssembly());
                var manager  = new LibraryManager(
                    loggerFactory,
                    new LibraryItem(Platform.Windows, Bitness.x64,
                                    new LibraryFile("fasttext.dll", accessor.Binary("Resources.fasttext.dll"))),
                    new LibraryItem(Platform.MacOs, Bitness.x64,
                                    new LibraryFile("libfasttext.dylib", accessor.Binary("Resources.libfasttext.dylib"))),
                    new LibraryItem(Platform.Linux, Bitness.x64,
                                    new LibraryFile("libfasttext.so", accessor.Binary("Resources.libfasttext.so"))));

                manager.LoadNativeLibrary();
            }

            _mapper = new MapperConfiguration(config => config.CreateMap <FastTextArgs, FastTextArgsStruct>())
                      .CreateMapper();

            _fastText = CreateFastText();
        }
Exemplo n.º 42
0
        public List<DependencyPath> RetrieveAll()
        {
            string saveFile = Path.Combine(GetCurrentPath(), ".libdef");

            LibraryManager manager = new LibraryManager(saveFile);
            return manager.GetAll();
        }
Exemplo n.º 43
0
        public void LibraryNoIonsTest()
        {
            var streamManager = new MemoryStreamManager();
            var loader = new LibraryLoadTest.TestLibraryLoader { StreamManager = streamManager };

            // Create X! Hunter library with 20 lowest intensity peaks in NIST library
            LibraryLoadTest.CreateHunterFile(streamManager, loader, LibraryLoadTest.TEXT_LIB_YEAST_NIST, true);

            var hunterSpec = new XHunterLibSpec("Yeast (X!)", LibraryLoadTest.PATH_HUNTER_LIB);

            // For serialization, add the library spec to the settings
            TestLibraryList = new SpectralLibraryList { hunterSpec };

            var libraryManager = new LibraryManager { StreamManager = streamManager };
            var docContainer = new TestDocumentContainer();

            SrmSettings settings = SrmSettingsList.GetDefault();
            settings = settings.ChangePeptideLibraries(l => l.ChangeLibrarySpecs(new LibrarySpec[] { hunterSpec }));

            int startRev;
            SrmDocument docLoaded = CreateLibraryDocument(settings, ExampleText.TEXT_FASTA_YEAST_LIB, false,
                docContainer, libraryManager, out startRev);
            // Peptides should have been chosen, but no transitions, since the spectra are garbage
            AssertEx.IsDocumentState(docLoaded, startRev, 2, 4, 0);
        }
Exemplo n.º 44
0
        private bool ImportSearchInternal(CommandArgs commandArgs, ref SrmDocument doc)
        {
            var progressMonitor = new CommandProgressMonitor(_out, new ProgressStatus(String.Empty));
            var import = new ImportPeptideSearch
            {
                SearchFilenames = commandArgs.SearchResultsFiles.ToArray(),
                CutoffScore = commandArgs.CutoffScore.GetValueOrDefault()
            };

            // Build library
            var builder = import.GetLibBuilder(doc, commandArgs.Saving ? commandArgs.SaveFile : commandArgs.SkylineFile, commandArgs.IncludeAmbiguousMatches);
            ImportPeptideSearch.ClosePeptideSearchLibraryStreams(doc);
            _out.WriteLine(Resources.CommandLine_ImportSearch_Creating_spectral_library_from_files_);
            foreach (var file in commandArgs.SearchResultsFiles)
                _out.WriteLine(Path.GetFileName(file));
            if (!builder.BuildLibrary(progressMonitor))
                return false;

            if (!string.IsNullOrEmpty(builder.AmbiguousMatchesMessage))
                _out.WriteLine(builder.AmbiguousMatchesMessage);

            var docLibSpec = builder.LibrarySpec.ChangeDocumentLibrary(true);

            _out.WriteLine(Resources.CommandLine_ImportSearch_Loading_library);
            var libraryManager = new LibraryManager();
            if (!import.LoadPeptideSearchLibrary(libraryManager, docLibSpec, progressMonitor))
                return false;

            doc = import.AddDocumentSpectralLibrary(doc, docLibSpec);
            if (doc == null)
                return false;

            if (!import.VerifyRetentionTimes(import.GetFoundResultsFiles().Select(f => f.Path)))
            {
                _out.WriteLine(TextUtil.LineSeparate(
                    Resources.ImportPeptideSearchDlg_NextPage_The_document_specific_spectral_library_does_not_have_valid_retention_times_,
                    Resources.ImportPeptideSearchDlg_NextPage_Please_check_your_peptide_search_pipeline_or_contact_Skyline_support_to_ensure_retention_times_appear_in_your_spectral_libraries_));
                return false;
            }

            // Look for results files to import
            import.InitializeSpectrumSourceFiles(doc);
            import.UpdateSpectrumSourceFilesFromDirs(import.GetDirsToSearch(Path.GetDirectoryName(commandArgs.SkylineFile)), false, null);
            var missingResultsFiles = import.GetMissingResultsFiles().ToArray();
            if (missingResultsFiles.Any())
            {
                foreach (var file in missingResultsFiles)
                {
                    if (doc.Settings.HasResults && doc.Settings.MeasuredResults.FindMatchingMSDataFile(new MsDataFilePath(file)) != null)
                        continue;

                    _out.WriteLine(Resources.CommandLine_ImportSearch_Warning__Unable_to_locate_results_file___0__, Path.GetFileName(file));
                }
            }

            // Add all modifications, if requested
            if (commandArgs.AcceptAllModifications)
            {
                import.InitializeModifications(doc);
                var foundMods = import.GetMatchedMods().Count();
                var newModifications = new PeptideModifications(import.MatcherPepMods.StaticModifications,
                    new[] {new TypedModifications(IsotopeLabelType.heavy, import.MatcherHeavyMods)});
                var newSettings = import.AddModifications(doc, newModifications);
                if (!ReferenceEquals(doc.Settings, newSettings))
                {
                    if (foundMods != 1)
                        _out.WriteLine(Resources.CommandLine_ImportSearch_Adding__0__modifications_, foundMods);
                    else
                        _out.WriteLine(Resources.CommandLine_ImportSearch_Adding_1_modification_);
                    doc = doc.ChangeSettings(newSettings);
                    doc.Settings.UpdateDefaultModifications(false);
                }
            }

            // Import FASTA
            if (commandArgs.ImportingFasta)
            {
                _out.WriteLine(Resources.CommandLine_ImportFasta_Importing_FASTA_file__0____, Path.GetFileName(commandArgs.FastaPath));
                doc = ImportPeptideSearch.PrepareImportFasta(doc);
                int emptyProteins;
                try
                {
                    IdentityPath firstAdded, nextAdd;
                    doc = ImportPeptideSearch.ImportFasta(doc, commandArgs.FastaPath, progressMonitor, null,
                        out firstAdded, out nextAdd, out emptyProteins);
                }
                catch (Exception x)
                {
                    _out.WriteLine(Resources.CommandLine_Run_Error__Failed_importing_the_file__0____1_, commandArgs.FastaPath, x.Message);
                    _doc = doc;
                    return true;  // So that document will be saved with the new library
                }

                if (emptyProteins > 0 && !commandArgs.KeepEmptyProteins)
                {
                    doc = ImportPeptideSearch.RemoveEmptyProteins(doc);
                }
            }

            // Import results
            _doc = doc;
            ImportFoundResultsFiles(commandArgs, import);
            return true;
        }
Exemplo n.º 45
0
 private static SrmDocument CreateNISTLibraryDocument(out LibraryManager libraryManager,
     out TestDocumentContainer docContainer, out int startRev)
 {
     SrmDocument docLoaded = CreateNISTLibraryDocument(ExampleText.TEXT_FASTA_YEAST_LIB,
                                                       false,
                                                       LibraryLoadTest.TEXT_LIB_YEAST_NIST,
                                                       out libraryManager,
                                                       out docContainer,
                                                       out startRev);
     AssertEx.IsDocumentState(docLoaded, startRev, 2, 4, 12);
     return docLoaded;
 }
Exemplo n.º 46
0
 private static void ValidateLibraryDocs(SrmDocument docTarget, SrmDocument docActual, LibraryManager libraryManager)
 {
     var docContainer = new TestDocumentContainer();
     libraryManager.Register(docContainer);
     try
     {
         AssertEx.IsDocumentState(docActual, 0, docTarget.PeptideGroupCount, docTarget.PeptideCount,
             docTarget.PeptideTransitionGroupCount, docTarget.PeptideTransitionCount);
         docActual = docActual.ChangeSettings(docActual.Settings.ConnectLibrarySpecs(FindLibrarySpec));
         Assert.IsTrue(docContainer.SetDocument(docActual, null, true));
         SrmDocument docLoaded = docContainer.Document;
         AssertEx.DocumentCloned(docTarget, docLoaded);
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Transitions.ToArray(), docLoaded.Transitions.ToArray()));
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.TransitionGroups.ToArray(), docLoaded.TransitionGroups.ToArray()));
     //                Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Peptides.ToArray(), docLoaded.Peptides.ToArray()));
         Assert.IsTrue(ArrayUtil.ReferencesEqual(docActual.Children, docLoaded.Children));
     }
     finally
     {
         libraryManager.Unregister(docContainer);
     }
 }
Exemplo n.º 47
0
 public PackageAssemblyLoader(IAssemblyLoadContextAccessor loadContextAccessor,
                              LibraryManager libraryManager)
 {
     _loadContextAccessor = loadContextAccessor;
     _assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraryManager);
 }
Exemplo n.º 48
0
        public void SaveLocation(DependencyPath path)
        {
            string saveFile = Path.Combine(GetCurrentPath(), ".libdef");

            LibraryManager manager = new LibraryManager(saveFile);
            manager.Append(path);
        }
Exemplo n.º 49
0
        public void LibraryMultipleTest()
        {
            var streamManager = new MemoryStreamManager();
            var loader = new LibraryLoadTest.TestLibraryLoader { StreamManager = streamManager };

            // Create library files
            const string hunterText = LibraryLoadTest.TEXT_LIB_YEAST_NIST1 + "\n" + LibraryLoadTest.TEXT_LIB_YEAST_NIST2;
            LibraryLoadTest.CreateHunterFile(streamManager, loader, hunterText);
            const string biblioText = LibraryLoadTest.TEXT_LIB_YEAST_NIST2 + "\n" + LibraryLoadTest.TEXT_LIB_YEAST_NIST3;
            LibraryLoadTest.CreateBiblioFile(streamManager, loader, biblioText);
            const string nistText = LibraryLoadTest.TEXT_LIB_YEAST_NIST3 + "\n" + LibraryLoadTest.TEXT_LIB_YEAST_NIST4;
            streamManager.TextFiles.Add(LibraryLoadTest.PATH_NIST_LIB, nistText);

            var hunterSpec = new XHunterLibSpec("Yeast (X!)", LibraryLoadTest.PATH_HUNTER_LIB);
            var bilbioSpec = new BiblioSpecLibSpec("Yeast (BS)", LibraryLoadTest.PATH_BIBLIOSPEC_LIB);
            var nistSpec = new NistLibSpec("Yeast (NIST)", LibraryLoadTest.PATH_NIST_LIB);

            // For serialization, add the library spec to the settings
            TestLibraryList = new SpectralLibraryList { hunterSpec, bilbioSpec, nistSpec };

            var libraryManager = new LibraryManager { StreamManager = streamManager };
            var docContainer = new TestDocumentContainer();

            SrmSettings settings = SrmSettingsList.GetDefault();
            settings = settings.ChangePeptideLibraries(l => l.ChangeLibrarySpecs(new LibrarySpec[] { hunterSpec, bilbioSpec, nistSpec }));

            int startRev;
            SrmDocument docLoaded = CreateLibraryDocument(settings, ExampleText.TEXT_FASTA_YEAST_LIB, false,
                docContainer, libraryManager, out startRev);
            AssertEx.IsDocumentState(docLoaded, startRev, 2, 4, 12);
            Assert.IsTrue(HasLibraryInfo(docLoaded, typeof(XHunterSpectrumHeaderInfo)));
            Assert.IsTrue(HasLibraryInfo(docLoaded, typeof(BiblioSpecSpectrumHeaderInfo)));
            Assert.IsTrue(HasLibraryInfo(docLoaded, typeof(NistSpectrumHeaderInfo)));

            // Remove the rank 1 transition from each transition group
            TransitionDocNode[] transitionNodes = docLoaded.PeptideTransitions.ToArray();
            for (int i = 0; i < transitionNodes.Length; i++)
            {
                var nodeTran = transitionNodes[i];
                if (nodeTran.LibInfo.Rank != 1)
                    continue;
                var path = docLoaded.GetPathTo((int) SrmDocument.Level.TransitionGroups, i/3);
                docLoaded = (SrmDocument) docLoaded.RemoveChild(path, nodeTran);
                ++startRev;
            }
            AssertEx.IsDocumentState(docLoaded, startRev, 2, 4, 8);
            // Make sure this can be serialized and deserialized without causing
            // a recalculation of the nodes in the tree.
            AssertEx.Serializable(docLoaded, (doc1, doc2) => ValidateLibraryDocs(doc1, doc2, libraryManager));
        }
Exemplo n.º 50
0
        public PeptideSettingsUI(SkylineWindow parent, LibraryManager libraryManager)
        {
            InitializeComponent();

            btnUpdateIonMobilityLibraries.Visible = false; // TODO: ion mobility libraries are more complex than initially thought - put this off until after summer 2014 release

            _parent = parent;
            _libraryManager = libraryManager;
            _peptideSettings = parent.DocumentUI.Settings.PeptideSettings;

            // Initialize digestion settings
            _driverEnzyme = new SettingsListComboDriver<Enzyme>(comboEnzyme, Settings.Default.EnzymeList);
            _driverEnzyme.LoadList(_peptideSettings.Enzyme.GetKey());
            for (int i = DigestSettings.MIN_MISSED_CLEAVAGES; i <= DigestSettings.MAX_MISSED_CLEAVAGES; i++)
                comboMissedCleavages.Items.Add(i.ToString(CultureInfo.InvariantCulture));
            comboMissedCleavages.SelectedItem = Digest.MaxMissedCleavages.ToString(LocalizationHelper.CurrentCulture);
            if (comboMissedCleavages.SelectedIndex < 0)
                comboMissedCleavages.SelectedIndex = 0;
            cbRaggedEnds.Checked = Digest.ExcludeRaggedEnds;

            // Initialize prediction settings
            _driverRT = new SettingsListComboDriver<RetentionTimeRegression>(comboRetentionTime, Settings.Default.RetentionTimeList);
            string sel = (Prediction.RetentionTime == null ? null : Prediction.RetentionTime.Name);
            _driverRT.LoadList(sel);
            cbUseMeasuredRT.Checked = textMeasureRTWindow.Enabled = Prediction.UseMeasuredRTs;
            if (Prediction.MeasuredRTWindow.HasValue)
                textMeasureRTWindow.Text = Prediction.MeasuredRTWindow.Value.ToString(LocalizationHelper.CurrentCulture);

            _driverDT = new SettingsListComboDriver<DriftTimePredictor>(comboDriftTimePredictor, Settings.Default.DriftTimePredictorList);
            string selDT = (Prediction.DriftTimePredictor == null ? null : Prediction.DriftTimePredictor.Name);
            _driverDT.LoadList(selDT);
            cbUseSpectralLibraryDriftTimes.Checked = textSpectralLibraryDriftTimesResolvingPower.Enabled = Prediction.UseLibraryDriftTimes;
            if (Prediction.LibraryDriftTimesResolvingPower.HasValue)
                textSpectralLibraryDriftTimesResolvingPower.Text = Prediction.LibraryDriftTimesResolvingPower.Value.ToString(LocalizationHelper.CurrentCulture);

            // Initialize filter settings
            _driverExclusion = new SettingsListBoxDriver<PeptideExcludeRegex>(listboxExclusions, Settings.Default.PeptideExcludeList);
            _driverExclusion.LoadList(null, Filter.Exclusions);

            textExcludeAAs.Text = Filter.ExcludeNTermAAs.ToString(LocalizationHelper.CurrentCulture);
            textMaxLength.Text = Filter.MaxPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            textMinLength.Text = Filter.MinPeptideLength.ToString(LocalizationHelper.CurrentCulture);
            cbAutoSelect.Checked = Filter.AutoSelect;

            // Initialize spectral library settings
            _driverLibrary = new SettingsListBoxDriver<LibrarySpec>(listLibraries, Settings.Default.SpectralLibraryList);
            IList<LibrarySpec> listLibrarySpecs = Libraries.LibrarySpecs;

            _driverLibrary.LoadList(null, listLibrarySpecs);
            _driverBackgroundProteome = new SettingsListComboDriver<BackgroundProteomeSpec>(comboBackgroundProteome, Settings.Default.BackgroundProteomeList);
            _driverBackgroundProteome.LoadList(_peptideSettings.BackgroundProteome.Name);

            panelPick.Visible = listLibrarySpecs.Count > 0;
            btnExplore.Enabled = listLibraries.Items.Count > 0;

            comboMatching.SelectedIndex = (int) Libraries.Pick;

            _lastRankId = Libraries.RankId;
            _lastPeptideCount = Libraries.PeptideCount.HasValue
                                    ? Libraries.PeptideCount.Value.ToString(LocalizationHelper.CurrentCulture)
                                    : null;

            UpdateRanks(null);

            // Initialize modification settings
            _driverStaticMod = new SettingsListBoxDriver<StaticMod>(listStaticMods, Settings.Default.StaticModList);
            _driverStaticMod.LoadList(null, Modifications.StaticModifications);
            _driverHeavyMod = new SettingsListBoxDriver<StaticMod>(listHeavyMods, Settings.Default.HeavyModList);
            _driverLabelType = new LabelTypeComboDriver(comboLabelType, Modifications, _driverHeavyMod,
                labelStandardType, comboStandardType, listStandardTypes);
            textMaxVariableMods.Text = Modifications.MaxVariableMods.ToString(LocalizationHelper.CurrentCulture);
            textMaxNeutralLosses.Text = Modifications.MaxNeutralLosses.ToString(LocalizationHelper.CurrentCulture);

            // Initialize peak scoring settings.
            _driverPeakScoringModel = new SettingsListComboDriver<PeakScoringModelSpec>(comboPeakScoringModel, Settings.Default.PeakScoringModelList);
            var peakScoringModel = _peptideSettings.Integration.PeakScoringModel;
            _driverPeakScoringModel.LoadList(peakScoringModel != null ? peakScoringModel.Name : null);

            IsShowLibraryExplorer = false;
            tabControl1.TabPages.Remove(tabIntegration);
            comboNormalizationMethod.Items.AddRange(
                NormalizationMethod.ListNormalizationMethods(parent.DocumentUI).ToArray());
            comboNormalizationMethod.SelectedItem = _peptideSettings.Quantification.NormalizationMethod;
            comboWeighting.Items.AddRange(RegressionWeighting.All.Cast<object>().ToArray());
            comboWeighting.SelectedItem = _peptideSettings.Quantification.RegressionWeighting;
            comboRegressionFit.Items.AddRange(RegressionFit.All.Cast<object>().ToArray());
            comboRegressionFit.SelectedItem = _peptideSettings.Quantification.RegressionFit;
            comboQuantMsLevel.SelectedIndex = Math.Max(0, _quantMsLevels.IndexOf(_peptideSettings.Quantification.MsLevel));
            tbxQuantUnits.Text = _peptideSettings.Quantification.Units;
        }
Exemplo n.º 51
0
    protected void uploadFilesToEktron(FileUpload fiU)
    {
        // folder ID where I want the files to go

        long folderId = 103;

        // create the content item title in the form "YYYY T - CCCC" where Y is year, T is term and C is program code.

        string content_title = "aasdf" + DateTime.Now.ToString();

        // initialize framework.

        Ektron.Cms.API.Library libraryAPI = new Ektron.Cms.API.Library();

        LibraryManager lmgr = new LibraryManager();

        // determine if the item already exists.

        Ektron.Cms.Content.LibraryCriteria criteria = new Ektron.Cms.Content.LibraryCriteria();

        // upload the file to Ektron

        Ektron.Cms.LibraryConfigData lib_setting_data = libraryAPI.GetLibrarySettings(folderId);

        string filename = Server.MapPath(lib_setting_data.FileDirectory) + Path.GetFileName(fiU.FileName);

        Ektron.Cms.LibraryData item = new Ektron.Cms.LibraryData()

        {

            Title = content_title,

            ParentId = folderId,

            FileName = filename,

            File = File1.FileBytes

        };

        if (fiU.PostedFile.ContentType == "application/pdf")
        {

            lmgr.Add(item);

            ltlMessage.Text = "Library item added with ID = " + item.Id.ToString();

        }

        else

            ltlMessage.Text = "Not added. File must be a PDF.";
    }
Exemplo n.º 52
0
 public CompilerOptionsProvider(LibraryManager libraryManager)
 {
     _libraryManager = libraryManager;
 }
 public ComplexAllHomogeneousComplexResult(LibraryManager lm, IDynamicContainer d)
 {
     _lm = lm;
     _d = d;
 }
Exemplo n.º 54
0
        public DependencyPath RetrieveLocation(string name)
        {
            string saveFile = Path.Combine(GetCurrentPath(), ".libdef");

            LibraryManager manager = new LibraryManager(saveFile);
            return manager.Get(name);
        }
Exemplo n.º 55
0
        public ImportPeptideSearchDlg(SkylineWindow skylineWindow, LibraryManager libraryManager, Workflow workflowType)
            : this(skylineWindow, libraryManager)
        {
            BuildPepSearchLibControl.ForceWorkflow(workflowType);

            if (workflowType == Workflow.dda)
            {
                int shortHeight = MinimumSize.Height - 110;
                MinimumSize = new Size(MinimumSize.Width, shortHeight);
                Height = shortHeight;
            }
        }
Exemplo n.º 56
0
        public ResultsMemoryDocumentContainer(SrmDocument docInitial, string pathInitial, bool wait)
        {
            SetDocument(docInitial, null, wait);
            // Chromatogram loader needs file path to know how to place the .skyd file
            DocumentFilePath = pathInitial;

            ChromatogramManager = new ChromatogramManager();
            ChromatogramManager.Register(this);
            Register(ChromatogramManager);

            LibraryManager = new LibraryManager();
            LibraryManager.Register(this);
            Register(LibraryManager);

            RetentionTimeManager = new RetentionTimeManager();
            RetentionTimeManager.Register(this);
            Register(RetentionTimeManager);

            IonMobilityManager = new IonMobilityLibraryManager();
            IonMobilityManager.Register(this);
            Register(IonMobilityManager);

            IrtDbManager = new IrtDbManager();
            IrtDbManager.Register(this);
            Register(IrtDbManager);
        }
Exemplo n.º 57
0
        public bool LoadPeptideSearchLibrary(LibraryManager libraryManager, LibrarySpec libSpec, IProgressMonitor monitor)
        {
            if (libSpec == null)
            {
                return false;
            }

            DocLib = libraryManager.TryGetLibrary(libSpec) ??
                     libraryManager.LoadLibrary(libSpec, () => new DefaultFileLoadMonitor(monitor));

            return DocLib != null;
        }
        private void BindLibraryManager(LibraryManager manager)
        {
            if (_libraryManager == manager)
                return;

            if (_libraryManager != null) {
                _libraryManager.Libraries.ResourceAdded -= _libraryEventBindings[EventBindings.LibraryAdded];
                _libraryManager.Libraries.ResourceRemoved -= _libraryEventBindings[EventBindings.LibraryRemoved];
                _libraryManager.Libraries.ResourceModified -= _libraryEventBindings[EventBindings.LibraryModified];
            }

            _libraryManager = manager;

            if (_libraryManager != null) {
                _libraryManager.Libraries.ResourceAdded += _libraryEventBindings[EventBindings.LibraryAdded];
                _libraryManager.Libraries.ResourceRemoved += _libraryEventBindings[EventBindings.LibraryRemoved];
                _libraryManager.Libraries.ResourceModified += _libraryEventBindings[EventBindings.LibraryModified];
            }
        }