public XmlDocument CreateRecordHistoryDesc( OAdEntity record, string historyValue, string versionStr, bool isLastRevOfThisSyncCycle) { CQHistory cqHistory = new CQHistory(historyValue); ClearQuestRecordDescription recordHistDesc = new ClearQuestRecordDescription(); recordHistDesc.CreateHeader(cqHistory.User, DateTime.Parse(cqHistory.Date, CultureInfo.CurrentCulture), MigrationRecordId, EntityDefName, versionStr, isLastRevOfThisSyncCycle); recordHistDesc.AddField(CQConstants.HistoryFieldName, string.Empty, historyValue); return(recordHistDesc.DescriptionDocument); }
internal static void FindLastRevDtls(OAdEntity record, out string lastAuthor, out DateTime lastChangeDate) { lastAuthor = string.Empty; lastChangeDate = DateTime.MinValue; OAdHistoryFields cqHistFields = CQWrapper.GetHistoryFields(record); int historyFldCount = CQWrapper.HistoryFieldsCount(cqHistFields); for (int histFldIndex = 0; histFldIndex < historyFldCount; histFldIndex++) { object ob = (object)histFldIndex; OAdHistoryField historyField = CQWrapper.HistoryFieldsItem(cqHistFields, ref ob); int historyCount = CQWrapper.HistoryFieldHistoriesCount(historyField); // pick the last history for each historyfield object obHistIndex = (object)(historyCount - 1); OAdHistory aHistory = CQWrapper.HistoryFieldHistoriesItem(historyField, ref obHistIndex); CQHistory cqHistory = new CQHistory(aHistory); // CQ API returns local time DateTime changedDate = DateTime.Parse(cqHistory.Date, CultureInfo.CurrentCulture); if (changedDate.CompareTo(lastChangeDate) > 0) { // found a later change lastChangeDate = changedDate; lastAuthor = cqHistory.User; } } if (lastChangeDate.CompareTo(DateTime.MinValue) == 0) { lastChangeDate = DateTime.Now; lastAuthor = Environment.UserDomainName + "\\" + Environment.UserName; } }