private UnitInfoModel BuildUnitInfoLogic(SlotModel slotModel, UnitInfo unitInfo) { Debug.Assert(slotModel != null); Debug.Assert(unitInfo != null); Protein protein = ProteinService.Get(unitInfo.ProjectID, true) ?? new Protein(); // update the data unitInfo.UnitRetrievalTime = LastRetrievalTime; unitInfo.OwningClientName = Settings.Name; unitInfo.OwningClientPath = Settings.DataPath(); unitInfo.OwningSlotId = slotModel.SlotId; if (unitInfo.SlotType == SlotType.Unknown) { unitInfo.SlotType = protein.Core.ToSlotType(); if (unitInfo.SlotType == SlotType.Unknown) { unitInfo.SlotType = unitInfo.CoreID.ToSlotType(); } } // build unit info logic var unitInfoLogic = new UnitInfoModel(BenchmarkService); unitInfoLogic.CurrentProtein = protein; unitInfoLogic.UnitInfoData = unitInfo; return(unitInfoLogic); }
private void RefreshSlots() { _slotsLock.EnterWriteLock(); try { _slots.Clear(); if (_messages.SlotCollection != null) { // iterate through slot collection foreach (var slot in _messages.SlotCollection) { // add slot model to the collection var slotModel = new SlotModel { Settings = _settings, Prefs = Prefs, Status = (SlotStatus)slot.StatusEnum, SlotId = slot.Id, SlotOptions = slot.SlotOptions }; _slots.Add(slotModel); } } } finally { _slotsLock.ExitWriteLock(); } OnSlotsChanged(EventArgs.Empty); }
public void DuplicateTestNoDuplicates() { var instance1 = new SlotModel { UserId = "1" }; var unitInfo1 = new UnitInfo { ProjectID = 1 }; var logic1 = CreateUnitInfoLogic(unitInfo1); instance1.UnitInfoModel = logic1; var instance2 = new SlotModel { UserId = "2" }; var unitInfo2 = new UnitInfo { ProjectID = 2 }; var logic2 = CreateUnitInfoLogic(unitInfo2); instance2.UnitInfoModel = logic2; (new[] { instance1, instance2 }).FindDuplicates(); Assert.IsFalse(instance1.UserIdIsDuplicate); Assert.IsFalse(instance1.ProjectIsDuplicate); Assert.IsFalse(instance2.UserIdIsDuplicate); Assert.IsFalse(instance2.ProjectIsDuplicate); }
private static void SetSlotStatus(SlotModel slotModel) { if (slotModel.Status == SlotStatus.Running || slotModel.Status == SlotStatus.RunningNoFrameTimes) { slotModel.Status = slotModel.IsUsingBenchmarkFrameTime ? SlotStatus.RunningNoFrameTimes : SlotStatus.Running; } }
private static void PopulateRunLevelData(QueueUnitItem queueUnitItem, SlotModel slotModel) { if (slotModel.UserId == Constants.DefaultUserID) { slotModel.UserId = queueUnitItem.UserID; } if (slotModel.MachineId == Constants.DefaultMachineID) { slotModel.MachineId = queueUnitItem.MachineID; } }
/// <summary> /// Handles the Client Status Returned by Log Parsing and then determines what values to feed the DetermineStatus routine. /// </summary> private void HandleReturnedStatus(SlotStatus returnedStatus, SlotModel slot) { var statusData = new LegacyClientStatusData { ClientName = Settings.Name, SlotType = slot.UnitInfoModel.UnitInfoData.SlotType, UnitRetrievalTime = slot.UnitInfoModel.UnitInfoData.UnitRetrievalTime, UtcOffsetIsZero = Settings.UtcOffsetIsZero, UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now), ClientTimeOffset = Settings.ClientTimeOffset, TimeOfLastUnitStart = slot.TimeOfLastUnitStart, TimeOfLastFrameProgress = slot.TimeOfLastFrameProgress, CurrentStatus = slot.Status, ReturnedStatus = returnedStatus, FrameTime = slot.UnitInfoModel.GetRawTime(Prefs.Get <PpdCalculationType>(Preference.PpdCalculation)), BenchmarkAverageFrameTime = GetBenchmarkAverageFrameTimeOrDefault(slot.UnitInfo), TimeOfLastFrame = slot.UnitInfoModel.UnitInfoData.CurrentFrame == null ? TimeSpan.Zero : slot.UnitInfoModel.UnitInfoData.CurrentFrame.TimeOfFrame, UnitStartTimeStamp = slot.UnitInfoModel.UnitInfoData.UnitStartTimeStamp, AllowRunningAsync = Prefs.Get <bool>(Preference.AllowRunningAsync) }; SlotStatus computedStatus = LegacyClientStatus.GetSlotStatus(statusData, Logger); // If the returned status is EuePause and current status is not if (computedStatus.Equals(SlotStatus.EuePause) && statusData.CurrentStatus.Equals(SlotStatus.EuePause) == false) { if (Prefs.Get <bool>(Preference.EmailReportingEnabled) && Prefs.Get <bool>(Preference.ReportEuePause)) { SendEuePauseEmail(statusData.ClientName); } } // If the returned status is Hung and current status is not if (computedStatus.Equals(SlotStatus.Hung) && statusData.CurrentStatus.Equals(SlotStatus.Hung) == false) { if (Prefs.Get <bool>(Preference.EmailReportingEnabled) && Prefs.Get <bool>(Preference.ReportHung)) { SendHungEmail(statusData.ClientName); } } slot.Status = computedStatus; }
private SlotDetail CreateSlotDetail(SlotModel slot, DateTime updateDateTime) { var slotDetail = new SlotDetail(); slotDetail.HfmVersion = Application.VersionWithRevision; slotDetail.NumberFormat = _prefs.GetPpdFormatString(); slotDetail.UpdateDateTime = updateDateTime; slotDetail.LogFileAvailable = _prefs.Get <bool>(Preference.WebGenCopyFAHlog); slotDetail.LogFileName = slot.Settings.CachedFahLogFileName(); slotDetail.TotalRunCompletedUnits = slot.TotalRunCompletedUnits; slotDetail.TotalCompletedUnits = slot.TotalCompletedUnits; slotDetail.TotalRunFailedUnits = slot.TotalRunFailedUnits; slotDetail.TotalFailedUnits = slot.TotalFailedUnits; slotDetail.GridData = AutoMapper.Mapper.Map <SlotModel, GridData>(slot); slotDetail.CurrentLogLines = slot.CurrentLogLines; slotDetail.Protein = slot.UnitInfoModel.CurrentProtein; return(slotDetail); }
private void PopulateRunLevelData(DataAggregatorResult result, SlotModel slotModel) { slotModel.Arguments = result.Arguments; slotModel.ClientVersion = result.ClientVersion; slotModel.UserId = result.UserID; slotModel.MachineId = result.MachineID; //slotModel.TotalRunCompletedUnits = run.CompletedUnits; //slotModel.TotalRunFailedUnits = run.FailedUnits; //slotModel.TotalCompletedUnits = run.TotalCompletedUnits; if (UnitInfoDatabase.Connected) { slotModel.TotalRunCompletedUnits = (int)UnitInfoDatabase.Count(slotModel.Name, CountType.Completed, result.StartTime); slotModel.TotalCompletedUnits = (int)UnitInfoDatabase.Count(slotModel.Name, CountType.Completed); slotModel.TotalRunFailedUnits = (int)UnitInfoDatabase.Count(slotModel.Name, CountType.Failed, result.StartTime); slotModel.TotalFailedUnits = (int)UnitInfoDatabase.Count(slotModel.Name, CountType.Failed); } }
private void PopulateRunLevelData(DataAggregatorResult result, Info info, SlotModel slotModel) { Debug.Assert(slotModel != null); if (info != null) { slotModel.ClientVersion = info.Build.Version; } //if (run != null) //{ // slotModel.TotalRunCompletedUnits = run.CompletedUnits; // slotModel.TotalRunFailedUnits = run.FailedUnits; //} if (UnitInfoDatabase.Connected) { slotModel.TotalRunCompletedUnits = (int)UnitInfoDatabase.CountCompleted(slotModel.Name, result.StartTime); slotModel.TotalCompletedUnits = (int)UnitInfoDatabase.CountCompleted(slotModel.Name, null); slotModel.TotalRunFailedUnits = (int)UnitInfoDatabase.CountFailed(slotModel.Name, result.StartTime); slotModel.TotalFailedUnits = (int)UnitInfoDatabase.CountFailed(slotModel.Name, null); } }
private static void PopulateRunLevelData(ClientRun run, SlotModel slotModel) { slotModel.Arguments = run.Arguments; slotModel.ClientVersion = run.ClientVersion; slotModel.UserId = run.UserID; slotModel.MachineId = run.MachineID; slotModel.TotalRunCompletedUnits = run.CompletedUnits; slotModel.TotalRunFailedUnits = run.FailedUnits; slotModel.TotalCompletedUnits = run.TotalCompletedUnits; }
/// <summary> /// Handles the Client Status Returned by Log Parsing and then determines what values to feed the DetermineStatus routine. /// </summary> private void HandleReturnedStatus(SlotStatus returnedStatus, SlotModel slot) { var statusData = new StatusData { ClientName = Settings.Name, SlotType = slot.UnitInfoLogic.UnitInfoData.SlotType, UnitRetrievalTime = slot.UnitInfoLogic.UnitInfoData.UnitRetrievalTime, UtcOffsetIsZero = Settings.UtcOffsetIsZero, UtcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now), ClientTimeOffset = Settings.ClientTimeOffset, TimeOfLastUnitStart = slot.TimeOfLastUnitStart, TimeOfLastFrameProgress = slot.TimeOfLastFrameProgress, CurrentStatus = slot.Status, ReturnedStatus = returnedStatus, FrameTime = slot.UnitInfoLogic.GetRawTime(Prefs.Get<PpdCalculationType>(Preference.PpdCalculation)), BenchmarkAverageFrameTime = GetBenchmarkAverageFrameTimeOrDefault(slot.UnitInfo), TimeOfLastFrame = slot.UnitInfoLogic.UnitInfoData.CurrentFrame == null ? TimeSpan.Zero : slot.UnitInfoLogic.UnitInfoData.CurrentFrame.TimeOfFrame, UnitStartTimeStamp = slot.UnitInfoLogic.UnitInfoData.UnitStartTimeStamp, AllowRunningAsync = Prefs.Get<bool>(Preference.AllowRunningAsync) }; SlotStatus computedStatus = StatusLogic.HandleStatusData(statusData); // If the returned status is EuePause and current status is not if (computedStatus.Equals(SlotStatus.EuePause) && statusData.CurrentStatus.Equals(SlotStatus.EuePause) == false) { if (Prefs.Get<bool>(Preference.EmailReportingEnabled) && Prefs.Get<bool>(Preference.ReportEuePause)) { SendEuePauseEmail(statusData.ClientName); } } // If the returned status is Hung and current status is not if (computedStatus.Equals(SlotStatus.Hung) && statusData.CurrentStatus.Equals(SlotStatus.Hung) == false) { if (Prefs.Get<bool>(Preference.EmailReportingEnabled) && Prefs.Get<bool>(Preference.ReportHung)) { SendHungEmail(statusData.ClientName); } } slot.Status = computedStatus; }
private void RefreshSlots() { _slotsLock.EnterWriteLock(); try { _slots.Clear(); if (_messages.SlotCollection != null) { // itterate through slot collection); foreach (var slot in _messages.SlotCollection) { // add slot model to the collection var slotModel = new SlotModel { Settings = _settings, Prefs = Prefs, Status = (SlotStatus)slot.StatusEnum, SlotId = slot.Id, SlotOptions = slot.SlotOptions }; _slots.Add(slotModel); } } } finally { _slotsLock.ExitWriteLock(); } OnSlotsChanged(EventArgs.Empty); }
private UnitInfoLogic BuildUnitInfoLogic(SlotModel slotModel, UnitInfo unitInfo) { Debug.Assert(slotModel != null); Debug.Assert(unitInfo != null); Protein protein = ProteinDictionary.GetProteinOrDownload(unitInfo.ProjectID); // update the data unitInfo.UnitRetrievalTime = LastRetrievalTime; unitInfo.OwningClientName = Settings.Name; unitInfo.OwningClientPath = Settings.DataPath(); unitInfo.OwningSlotId = slotModel.SlotId; //unitInfo.SlotType = UnitInfo.DetermineSlotType(protein.Core, unitInfo.CoreID); // build unit info logic var unitInfoLogic = ServiceLocator.Resolve<UnitInfoLogic>(); unitInfoLogic.CurrentProtein = protein; unitInfoLogic.UnitInfoData = unitInfo; return unitInfoLogic; }
private static void SetSlotStatus(SlotModel slotModel) { if (slotModel.Status.Equals(SlotStatus.Running) || slotModel.Status.Equals(SlotStatus.RunningNoFrameTimes)) { slotModel.Status = slotModel.IsUsingBenchmarkFrameTime ? SlotStatus.RunningNoFrameTimes : SlotStatus.Running; } }
private static void PopulateRunLevelData(ClientRun run, Info info, SlotModel slotModel) { Debug.Assert(slotModel != null); if (info != null) { slotModel.ClientVersion = info.Build.Version; } if (run != null) { slotModel.TotalRunCompletedUnits = run.CompletedUnits; slotModel.TotalRunFailedUnits = run.FailedUnits; } }
private void SetLogLines(SlotModel instance, IList<LogLine> logLines) { /*** Checked LogLine Count ***/ if (logLines != null && logLines.Count > 0) { // Different Client... Load LogLines if (_view.LogFileViewer.LogOwnedByInstanceName.Equals(instance.Name) == false) { _view.LogFileViewer.SetLogLines(logLines, instance.Name, _prefs.Get<bool>(Preference.ColorLogFile)); //HfmTrace.WriteToHfmConsole(TraceLevel.Verbose, String.Format("Set Log Lines (Changed Client - {0})", instance.Name)); } // Textbox has text lines else if (_view.LogFileViewer.Lines.Length > 0) { string lastLogLine = String.Empty; try // to get the last LogLine from the instance { lastLogLine = logLines[logLines.Count - 1].ToString(); } catch (ArgumentOutOfRangeException ex) { // even though i've checked the count above, it could have changed in between then // and now... and if the count is 0 it will yield this exception. Log It!!! _logger.WarnFormat(ex, Constants.ClientNameFormat, instance.Name, ex.Message); } // If the last text line in the textbox DOES NOT equal the last LogLine Text... Load LogLines. // Otherwise, the log has not changed, don't update and perform the log "flicker". if (_view.LogFileViewer.Lines[_view.LogFileViewer.Lines.Length - 1].Equals(lastLogLine) == false) { _view.LogFileViewer.SetLogLines(logLines, instance.Name, _prefs.Get<bool>(Preference.ColorLogFile)); //HfmTrace.WriteToHfmConsole(TraceLevel.Verbose, "Set Log Lines (log lines different)"); } } // Nothing in the Textbox... Load LogLines else { _view.LogFileViewer.SetLogLines(logLines, instance.Name, _prefs.Get<bool>(Preference.ColorLogFile)); } } else { _view.LogFileViewer.SetNoLogLines(); } if (_prefs.Get<bool>(Preference.FollowLogFile)) { _view.LogFileViewer.ScrollToBottom(); } }
private SlotDetail CreateSlotDetail(SlotModel slot, DateTime updateDateTime) { var slotDetail = new SlotDetail(); slotDetail.HfmVersion = Application.VersionWithRevision; slotDetail.NumberFormat = _prefs.PpdFormatString; slotDetail.UpdateDateTime = updateDateTime; slotDetail.LogFileAvailable = _prefs.Get<bool>(Preference.WebGenCopyFAHlog); slotDetail.LogFileName = slot.Settings.CachedFahLogFileName(); slotDetail.TotalRunCompletedUnits = slot.TotalRunCompletedUnits; slotDetail.TotalCompletedUnits = slot.TotalCompletedUnits; slotDetail.TotalRunFailedUnits = slot.TotalRunFailedUnits; slotDetail.GridData = AutoMapper.Mapper.Map<SlotModel, GridData>(slot); slotDetail.CurrentLogLines = slot.CurrentLogLines; slotDetail.Protein = slot.UnitInfoLogic.CurrentProtein; return slotDetail; }
private static void PopulateRunLevelData(ClientQueueEntry queueEntry, SlotModel slotModel) { if (slotModel.UserId == Constants.DefaultUserID) { slotModel.UserId = queueEntry.UserID; } if (slotModel.MachineId == Constants.DefaultMachineID) { slotModel.MachineId = queueEntry.MachineID; } }
private IEnumerable <string> GenerateHtmlInternal(string folderPath, ICollection <SlotModel> slots) { Debug.Assert(String.IsNullOrEmpty(folderPath) == false); Debug.Assert(slots != null); // Generate XML Files var xmlFiles = GenerateXmlInternal(folderPath, slots); var fileList = new List <string>(slots.Count + 4); var cssFileName = _prefs.Get <string>(Preference.CssFile); // Load the Overview XML var overviewXml = new XmlDocument(); overviewXml.Load(xmlFiles.First()); StreamWriter sw; // Generate the index page string filePath = Path.Combine(folderPath, "index.html"); using (sw = new StreamWriter(filePath, false)) { sw.Write(Transform(overviewXml, GetXsltFileName(Preference.WebOverview), cssFileName)); } // Success, add it to the list fileList.Add(filePath); // Generate the mobile index page filePath = Path.Combine(folderPath, "mobile.html"); using (sw = new StreamWriter(filePath, false)) { sw.Write(Transform(overviewXml, GetXsltFileName(Preference.WebMobileOverview), cssFileName)); } // Success, add it to the list fileList.Add(filePath); // Generate the summary page filePath = Path.Combine(folderPath, "summary.html"); using (sw = new StreamWriter(filePath, false)) { sw.Write(Transform(overviewXml, GetXsltFileName(Preference.WebSummary), cssFileName)); } // Success, add it to the list fileList.Add(filePath); // Generate the mobile summary page filePath = Path.Combine(folderPath, "mobilesummary.html"); using (sw = new StreamWriter(filePath, false)) { sw.Write(Transform(overviewXml, GetXsltFileName(Preference.WebMobileSummary), cssFileName)); } // Success, add it to the list fileList.Add(filePath); string slotXslt = GetXsltFileName(Preference.WebSlot); // Generate a page per slot foreach (var slot in slots) { // Load the Instances XML var slotXml = new XmlDocument(); SlotModel slot1 = slot; string xmlFile = xmlFiles.FirstOrDefault(x => Path.GetFileName(x).StartsWith(slot1.Name)); if (xmlFile != null) { slotXml.Load(xmlFile); filePath = Path.Combine(folderPath, String.Concat(slot.Name, ".html")); using (sw = new StreamWriter(filePath, false)) { sw.Write(Transform(slotXml, slotXslt, cssFileName)); } // Success, add it to the list fileList.Add(filePath); } } XmlFilePaths = xmlFiles; return(fileList.AsReadOnly()); }