示例#1
0
        public void MinimizeToFile(string targetFile, CacheFormat cacheFormat)
        {
            var targetSkydFile = ChromatogramCache.FinalPathForName(targetFile, null);

            using (var skydSaver = new FileSaver(targetSkydFile, true))
                using (var scansSaver = new FileSaver(targetSkydFile + ChromatogramCache.SCANS_EXT, true))
                    using (var peaksSaver = new FileSaver(targetSkydFile + ChromatogramCache.PEAKS_EXT, true))
                        using (var scoreSaver = new FileSaver(targetSkydFile + ChromatogramCache.SCORES_EXT, true))
                        {
                            var minimizer  = Document.Settings.MeasuredResults.GetChromCacheMinimizer(Document);
                            var settings   = new ChromCacheMinimizer.Settings().ChangeCacheFormat(cacheFormat);
                            var lockObject = new object();
                            ProgressMonitor.UpdateProgress(_progressStatus = _progressStatus.ChangeMessage(Resources.SrmDocumentSharing_MinimizeToFile_Writing_chromatograms));
                            minimizer.Minimize(settings, stats =>
                            {
                                if (ProgressMonitor.IsCanceled)
                                {
                                    throw new OperationCanceledException();
                                }
                                lock (lockObject)
                                {
                                    ProgressMonitor.UpdateProgress(_progressStatus = _progressStatus.ChangePercentComplete(stats.PercentComplete));
                                }
                            }, skydSaver.FileStream, scansSaver.FileStream, peaksSaver.FileStream, scoreSaver.FileStream);
                            skydSaver.Commit();
                        }
        }
示例#2
0
        private TemporaryDirectory ShareSkydFile(ZipFileShare zip, TemporaryDirectory tempDir)
        {
            string pathCache = ChromatogramCache.FinalPathForName(DocumentPath, null);

            if (!File.Exists(pathCache))
            {
                return(tempDir);
            }
            if (ShareType.SkylineVersion != null && Document.Settings.HasResults)
            {
                var measuredResults = Document.Settings.MeasuredResults;
                if (measuredResults.CacheVersion.HasValue &&
                    !measuredResults.CacheVersion.Equals(ShareType.SkylineVersion.CacheFormatVersion))
                {
                    String cacheFileName = Path.GetFileName(pathCache);
                    if (cacheFileName != null)
                    {
                        if (tempDir == null)
                        {
                            tempDir = new TemporaryDirectory();
                        }
                        String newCachePath = Path.Combine(tempDir.DirPath, cacheFileName);
                        MinimizeToFile(newCachePath, CacheFormat.FromVersion(ShareType.SkylineVersion.CacheFormatVersion));
                        zip.AddFile(newCachePath);
                        return(tempDir);
                    }
                }
            }
            zip.AddFile(pathCache);
            return(tempDir);
        }
示例#3
0
        public CacheManager(CacheFormat cacheFormat)
        {
            // Create the cache file directory
            mDirectoryPath = CacheDirectory.CreateDefaultDirect();

            // Set preferred cache format
            mCacheFormat = cacheFormat;
        }
示例#4
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        public CacheManager()
        {
            // Create the cache file directory
            mDirectoryPath = CacheDirectory.CreateDefaultDirect();

            // Set default cache format
            mCacheFormat = CacheFormat.OneFile;
        }
示例#5
0
        /// <summary>
        /// Constructor to take in preferred directory path
        /// </summary>
        /// <param name="path">The directory path to store cache files</param>
        public CacheManager(string path)
        {
            // Set preferred directory path
            mDirectoryPath = path;

            // Set default cache format
            mCacheFormat = CacheFormat.OneFile;
        }
示例#6
0
        /// <summary>
        /// Constructor to take in preferred directory path and preferred cache format
        /// </summary>
        /// <param name="path">The directory to store cache files</param>
        /// <param name="cacheFormat">The format to store and write cache files</param>
        public CacheManager(string path, CacheFormat cacheFormat)
        {
            // Set preferred directory path
            mDirectoryPath = path;

            // Set preferred cache format
            mCacheFormat = cacheFormat;
        }
示例#7
0
        /// <summary>
        /// Default Constructor
        /// </summary>
        /// <param name="path">The path where the cache file will be stored, can be change at anytime</param>
        /// <param name="queue">The queue collection to be written to be cache files</param>
        /// <param name="cacheFormat">The format to write the cache in</param>
        public CacheWriter(string path, QueueCollection queue, CacheFormat cacheFormat)
        {
            // Set queue collection
            mQueue = queue;

            // Set the cache format
            mCacheFormat = cacheFormat;
        }
示例#8
0
        public CacheManager(string path, CacheFormat cacheFormat, int queueCapacity)
        {
            // Set preferred directory path
            mDirectoryPath = path;

            // Set preferred cache format
            mCacheFormat = cacheFormat;

            mQueueCollection = new QueueCollection(queueCapacity);
        }
示例#9
0
        public override bool Set <T>(string key, T t)
        {
            try
            {
                var value = CacheFormat.Serialize(t);

                return(RedisDatabase.StringSet(key, value));
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("设置缓存失败{0},{1}", key, ex.Message));
                _logger.Error(ex);

                return(false);
            }
        }
示例#10
0
        public override T Get <T>(string key)
        {
            try
            {
                string value = RedisDatabase.StringGet(key);

                if (string.IsNullOrEmpty(value))
                {
                    return(null);
                }

                return(CacheFormat.Deserialize <T>(value));
            }
            catch (Exception ex)
            {
                _logger.Error(string.Format("获取缓存失败{0},{1}", key, ex.Message));
                _logger.Error(ex);

                return(null);
            }
        }