Пример #1
0
        /// <summary>
        /// Class constructor
        /// </summary>
        public Base()
        {
            _UnitInfo = new UnitInfo();
            _UnitInfo.DownloadTime    = new DateTime(1900, 1, 1, 0, 0, 0);
            _UnitInfo.PercentComplete = 0;
            _UnitInfo.ProteinID       = 0;
            _UnitInfo.FramesComplete  = 0;
            _UnitInfo.TimeOfLastFrame = new DateTime(1900, 1, 1, 0, 0, 0);
            _UnitInfo.TimePerFrame    = new TimeSpan(0, 1, 0, 0);
            _UnitInfo.PPD             = 0.0;
            _UnitInfo.UPD             = 0.0;

            _CurrentProtein               = new Protein();
            _CurrentProtein.Contact       = "Unassigned Contact";
            _CurrentProtein.Core          = "Unassigned Core";
            _CurrentProtein.Credit        = 0;
            _CurrentProtein.Description   = "Unassigned Description";
            _CurrentProtein.Frames        = 100;
            _CurrentProtein.MaxDays       = 0;
            _CurrentProtein.NumAtoms      = 0;
            _CurrentProtein.PreferredDays = 0;
            _CurrentProtein.ProjectNumber = 0;
            _CurrentProtein.ServerIP      = "0.0.0.0";
            _CurrentProtein.WorkUnitName  = "Unassigned Protein";

            _Proteins = Proteins.ProteinCollection.Instance;
        }
Пример #2
0
        public ProteinService(ProteinDataContainer dataContainer, IProjectSummaryService projectSummaryService, ILogger logger)
        {
            _dataContainer         = dataContainer;
            _projectSummaryService = projectSummaryService;
            _logger     = logger ?? NullLogger.Instance;
            _collection = CreateProteinCollection(_dataContainer.Data);

            LastProjectRefresh = new Dictionary <int, DateTime>();
        }
Пример #3
0
        private static ProteinCollection CreateProteinCollection(IEnumerable <Protein> proteins)
        {
            var collection = new ProteinCollection();

            foreach (var p in proteins)
            {
                collection.Add(p);
            }
            return(collection);
        }
Пример #4
0
        public IReadOnlyCollection <ProteinChange> Refresh(IProgress <ProgressInfo> progress)
        {
            _logger.Info("Downloading new project data from Stanford...");
            var proteins = _projectSummaryService.GetProteins(progress);

            IReadOnlyCollection <ProteinChange> changes = null;

            if (proteins != null)
            {
                var collection = new ProteinCollection(_collection);
                changes = collection.Update(proteins);
                Interlocked.Exchange(ref _collection, collection);

                foreach (var info in changes.Where(info => info.Action != ProteinChangeAction.None))
                {
                    _logger.Info(info.ToString());
                }
            }

            var now = DateTime.UtcNow;

            foreach (var key in LastProjectRefresh.Keys.ToList())
            {
                if (_collection.Contains(key))
                {
                    LastProjectRefresh.Remove(key);
                }
                else
                {
                    LastProjectRefresh[key] = now;
                }
            }
            LastRefresh = now;

            Write();
            return(changes);
        }