public static void ConfigureTrackers(AbstractScheduledItem <ScheduleSettings> data, DateRange dateRange, MtObservableCollection <ITracker> trackers) { var start = dateRange.StartDate.Date; var finish = dateRange.FinishDate.Date; if (start > finish) { return; } trackers.Clear(); do { var tracker = data.Schedule.Trackers.FirstOrDefault(t => t.ScheduledDate.Date == start); if (tracker == null) { trackers.Add(new TrackerCap() { ScheduledDate = start }); } else { trackers.Add(tracker); } start = start.AddDays(1); } while (finish >= start); }
/// <summary> /// 开始入板 /// </summary> /// <param name="currentRoller"></param> /// <param name="product"></param> private void start(RollerDesignerItemViewModel currentRoller, ProductBase product) { if (product == null) { return; } RunningProductVo runningProduct = new RunningProductVo { Product = product }; lock (_lockRunningProducts) _runningProducts.Add(runningProduct); var beginRoller = _runningRollers.FirstOrDefault(a => a.RollerKey == currentRoller.Key); if (beginRoller == null) { throw new Exception($"起点({currentRoller.Key})不在运行时中"); } beginRoller.BandProduct = runningProduct; // 获取默认路径 runningProduct.TargetNode = getAutoTargetNode(currentRoller.Key); if (string.IsNullOrWhiteSpace(runningProduct.TargetNode)) { throw new Exception($"{currentRoller.Key}目标路径路由信息为空!"); } runningProduct.TargetPath = findPath(runningProduct.CurrentRollerKey, runningProduct.TargetNode); }
/// <summary>Adds an entity at the end of the collection.</summary> /// <param name="item">The entity.</param> public void Add(TEntity item) { var c = Get(item.Id); if (c != null) { _collection.Remove(c); } _collection.Add(item); }
private void Initialize() { Gpus = new MtObservableCollection <Gpu>(); for (var i = 0; i < GetTotalNumberOfGpus(); i++) { var id = i; id++; Gpus.Add(new Gpu { Identifier = id }); } var gpuVisibility = new[] { UserSettings.GlobalSettings.VisibilitySystemGpuTemp, UserSettings.GlobalSettings.VisibilitySystemGpuLoad }; _computer = new Computer { CPUEnabled = UserSettings.GlobalSettings.VisibilitySystemCpuTemp, GPUEnabled = BooleanExtensions.ExceedsThreshold(0, gpuVisibility) }; _computer.Open(); // Cpu timer var timerCpu = new Timer { Interval = UserSettings.GlobalSettings.PollingRateCpu }; timerCpu.Elapsed += timerCpu_Elapsed; timerCpu.Start(); // Ram timer var timerRam = new Timer { Interval = UserSettings.GlobalSettings.PollingRateRam }; timerRam.Elapsed += timerRam_Elapsed; timerRam.Start(); // Temp timer var timerTemp = new Timer { Interval = UserSettings.GlobalSettings.PollingRateTemps }; timerTemp.Elapsed += timerTemp_Elapsed; timerTemp.Start(); // Get the value at init EventExtensions.FireEvent(timerCpu, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerRam, "onIntervalElapsed", this, null); EventExtensions.FireEvent(timerTemp, "onIntervalElapsed", this, null); }
/// <summary> /// Reloading collection and calling subscribers - changing collection items /// </summary> /// <param name="collection"></param> /// <param name="data"></param> /// <typeparam name="T"></typeparam> public static void ReUpload <T>(this MtObservableCollection <T> collection, IEnumerable <T> data) where T : AbstractListItem { foreach (var item in collection.ToArray()) { collection.Remove(item); } foreach (var item in data) { collection.Add(item); } }
// Private Methods (2) private void DoLog(LogModel logData) { logs.Add(logData); }