private void DoUpdateFromHistory(Task task) { if (debug) { Console.WriteLine("+" + task.Name); } HPMSDKInternalData hid = GetCustomColumn(task); if ((hid.m_Data != null) && hid.m_Data.Length > 1 && BitConverter.ToInt32(hid.m_Data, 0) < task.LastUpdated.ToLocalTime().Ticks) { HPMDataHistoryGetHistoryParameters pars = new HPMDataHistoryGetHistoryParameters(); pars.m_DataID = task.UniqueTaskID; pars.m_FieldID = EHPMStatisticsField.NoStatistics; pars.m_FieldData = 0; pars.m_DataIdent0 = EHPMStatisticsScope.NoStatisticsScope; pars.m_DataIdent1 = 0; HPMDataHistory history = SessionManager.Session.DataHistoryGetHistory(pars); if (history != null) { DoUpdateFromHistory(task, history); } writeHIDStatus(task); } else if (hid.m_Data == null) { writeHIDStatus(task); } else if (hid.m_Data.Length <= 1) { writeHIDStatus(task); } }
private RawBurndownHistory GetRawHistory(HistoryKind historyKind) { HPMDataHistoryGetHistoryParameters getHistoryParameters = new HPMDataHistoryGetHistoryParameters(); if (historyKind == HistoryKind.Points) { getHistoryParameters.m_FieldID = EHPMStatisticsField.ComplexityPoints; } else if (historyKind == HistoryKind.EstimatedDays) { getHistoryParameters.m_FieldID = EHPMStatisticsField.EstimatedIdealDays; } getHistoryParameters.m_DataIdent0 = EHPMStatisticsScope.Milestone; getHistoryParameters.m_DataIdent1 = (uint)UniqueID.m_ID; int nTries = 0; HPMDataHistory history = null; while (nTries < 25) { // TODO: Consider to move the reponsibility to the client to register a callback instead. It really isn't kosher to do polling here. history = Session.DataHistoryGetHistory(getHistoryParameters); if (history == null) { ++nTries; System.Threading.Thread.Sleep(100); } else { break; } } if (history != null && (cache.rawHistoryCached[(int)historyKind] == null || history.m_Latests.m_Time > cache.rawHistoryCached[(int)historyKind].LastTimeEntry)) { cache.rawHistoryCached[(int)historyKind] = new RawBurndownHistory(history.m_HistoryEntries.Length, history.m_Latests.m_Time); for (uint j = 0; j < history.m_HistoryEntries.Length; j += 1) { HPMDataHistoryEntry historyEntry = history.m_HistoryEntries[j]; ulong time = historyEntry.m_Time; DateTime date = HPMUtilities.FromHPMDateTime(time); if (historyEntry.m_bHasDataRecorded && historyEntry.m_EntryType == EHPMDataHistoryEntryType.Statistics_AbsoluteValue) { HPMVariantData data = Session.DataHistoryGetEntryData(history, j); HPMStatisticsMultiFrequency value = Session.VariantDecode_HPMStatisticsMultiFrequency(data); cache.rawHistoryCached[(int)historyKind].InsertAt(j, date, value.m_FrequencyEntries[1].m_FrequencyFP); } } cache.normalizedHistoryCached[(int)historyKind] = null; } return(cache.rawHistoryCached[(int)historyKind]); }
private void DoUpdateFromHistory(Task task, HPMDataHistory history) { // Ensure that we get the custom column of the right project HPMProjectCustomColumnsColumn actualCustomColumn = task.ProjectView.GetCustomColumn(trackingColumn.m_Name); DateTimeValue storedValue = (DateTimeValue)task.GetCustomColumnValue(actualCustomColumn); // ToInt64 will return the value as microseconds since 1970 Jan 1 ulong storedHpmTime = storedValue.ToHpmDateTime(); if (history.m_Latests.m_Time > storedHpmTime) { foreach (HPMDataHistoryEntry entry in history.m_HistoryEntries) { // Check if it is the status field if (entry.m_FieldID == 15) { if (entry.m_Time > storedHpmTime) { storedHpmTime = entry.m_Time; task.SetCustomColumnValue(trackingColumn, DateTimeValue.FromHpmDateTime(task, actualCustomColumn, storedHpmTime)); } } } } }