public int GetLastestVersionNum(string strPath) { int iLatesetVersion = -1; SAWItemInfo itemInfo = GetFileInfo(strPath, -1); if (itemInfo != null) { iLatesetVersion = itemInfo.version; } return(iLatesetVersion); }
public bool GetFileModifiedDate(string path, out System.DateTime date) { date = System.DateTime.Today; SAWItemInfo itemInfo = GetFileInfo(path, -1); if (itemInfo != null) { date = itemInfo.date; } return(true); }
public Int64 GetFileSize(string path) { Int64 size = -1; SAWItemInfo itemInfo = GetFileInfo(path, -1); if (itemInfo != null) { size = itemInfo.size; } return(size); }
public string GetFileComment(string path) { SAWItemInfo itemInfo = GetFileInfo(path, -1); string strComment = ""; if (itemInfo != null) { strComment = itemInfo.comment; } return(strComment); }
public SAWItemInfo GetFileInfo(string file, int ver) { SAWItemInfo ItemInfo = new SAWItemInfo(); LongObject version = new LongObject(); DateTime time = new DateTime(); LongObject size = new LongObject(); StringObject comment = new StringObject(); StringObject error = new StringObject(); file = SAWCommon.ConvertPath(file); if (0 != sdkObject.GetFileGeneralInfo(strRepositoryName, file, version, ref time, size, comment, error)) { string errorIfFolder = "File \"" + file + "\" not found."; if (errorIfFolder == error.GetValue()) { IntObject iobjSubFoldersNotDeletedCount = new IntObject(); IntObject iobjSubFoldersDeletedCount = new IntObject(); IntObject iobjFileNotDeletedCount = new IntObject(); IntObject iobjFilesDeletedCount = new IntObject(); List <SDKDeletedItemGeneralInfo> listDeletedItemGeneralInfo = new List <SDKDeletedItemGeneralInfo>(); IntObject iobjRight = new IntObject(); if (0 == sdkObject.GetFolderGeneralInfo(strRepositoryName, file, iobjSubFoldersNotDeletedCount, iobjSubFoldersDeletedCount, iobjFileNotDeletedCount, iobjFilesDeletedCount, version, ref time, comment, ref listDeletedItemGeneralInfo, iobjRight, error)) { ItemInfo.comment = comment.GetValue(); ItemInfo.name = file; ItemInfo.size = 0; ItemInfo.version = (int)version.GetValue(); ItemInfo.date = time; ItemInfo.isdir = true; ItemInfo.type = EnumActionType.Enum_ActionTypeNull; ItemInfo.user = ""; return(ItemInfo); } } return(null); } else { ItemInfo.comment = comment.GetValue(); ItemInfo.name = file; ItemInfo.size = (int)size.GetValue(); ItemInfo.version = (int)version.GetValue(); ItemInfo.date = time; ItemInfo.isdir = false; ItemInfo.type = EnumActionType.Enum_ActionTypeNull; ItemInfo.user = ""; return(ItemInfo); } }
public List <SAWItemInfo> GetFileHistory(string path) { List <SDKHistory> history = new List <SDKHistory>(); StringObject error = new StringObject(); path = SAWCommon.ConvertPath(path); List <string> listUsers = new List <string>(); List <SHistorySortOrderBy> listFilterHistorySortOrderBy = new List <SHistorySortOrderBy>(); //SHistorySortOrderBy HistorySortOrderBy = new SHistorySortOrderBy(); //listFilterHistorySortOrderBy.Add(HistorySortOrderBy); if (0 != sdkObject.GetFileHistory(strRepositoryName, path, listUsers, int.MaxValue, false, "", listFilterHistorySortOrderBy, ref history, true, error)) { if (error.GetValue().Contains("The operation can not be performed on folder")) { List <string> listFileExtensions = new List <string>(); List <string> listFileSubStrings = new List <string>(); if (0 != sdkObject.GetFolderHistoryByItem(strRepositoryName, path, false, listUsers, listFileExtensions, listFileSubStrings, int.MaxValue, false, "", listFilterHistorySortOrderBy, new System.DateTime(), System.DateTime.Now, ref history, error)) { return(null); } } else { return(null); } } List <SAWItemInfo> ItemHistoryInfoset = new List <SAWItemInfo>(); foreach (SDKHistory ItemHistory in history) { SAWItemInfo ItemInfo = new SAWItemInfo(); ItemInfo.comment = ItemHistory.m_strComment; ItemInfo.name = ItemHistory.m_strItemFullName; ItemInfo.size = (int)ItemHistory.m_lFileSize; ItemInfo.version = (int)ItemHistory.m_lChangeSetID; //GetLastestVersionNum(ItemHistory.m_strItemFullName); ItemInfo.date = ItemHistory.m_dtCheckin; ItemInfo.isdir = IsItemAFolder(ItemHistory.m_enumItemType); ItemInfo.type = ConvertActionType(ItemHistory.m_enumActionType); ItemInfo.user = ItemHistory.m_strUserName; ItemHistoryInfoset.Add(ItemInfo); } return(ItemHistoryInfoset); }
public int GetVersionFromDate(string path, System.DateTime date) { List <SAWItemInfo> history = GetFileHistory(path); int version = -1; for (int i = 0; i < history.Count; i++) { SAWItemInfo item = history[i]; if (item.date <= date) { version = version > item.version ? version : item.version; } else { break; } } return(version); }
public List <SAWItemInfo> GetFileHistory(string path) { bool Cancelled; string ResultDescription; var FileHistoryParam = new SAWHFileHistoryParam(); bool IsPinned; var HistorySet = new SAWHHistorySet(); bool bDir = false; if (0 != sdkObject.GetFileHistory(SAWCommon.ConvertPath(path), FileHistoryParam, out IsPinned, out HistorySet, out Cancelled, out ResultDescription)) { var FolderHistoryParam = new SAWHProjectHistoryParam(); if (0 != sdkObject.GetProjectHistory(SAWCommon.ConvertPath(path), FolderHistoryParam, out HistorySet, out Cancelled, out ResultDescription)) { return(null); } bDir = true; } var set = new List <SAWItemInfo>(); for (int i = 0; i < HistorySet.Count; i++) { SAWHHistory w = HistorySet.Item(i) as SAWHHistory; var his = new SAWItemInfo(); his.comment = w.Comment == null ? "" : w.Comment; his.date = w.ActionDateTime; his.name = w.ItemName; his.size = w.FileSizeLow; his.user = w.UserName; his.version = w.VersionNumberLow; his.type = (EnumActionType)w.ActionType; his.isdir = bDir; set.Add(his); } return(set); }
public List <SAWItemInfo> EnumItems(string strFolder, int version) { if (version == -1) { version = GetLastestVersionNum(strFolder); } // Lookup cache. /*foreach(SAWItemCache v in this.itemCache) * { * if(strFolder == v.strPath && version == v.version) * { * return v.result; * } * }*/ List <SAWItemInfo> result = new List <SAWItemInfo>(); SAWHHistorySet subProject = new SAWHHistorySet(); SAWHHistorySet subFile = new SAWHHistorySet(); Boolean Cancelled; string ResultDescription; if (0 != sdkObject.GetProjectTreeByVersion(SAWCommon.ConvertPath(strFolder), version, out subProject, out subFile, out Cancelled, out ResultDescription)) { return(null); } foreach (SAWHHistory v in subProject) { SAWItemInfo his = new SAWItemInfo(); his.comment = v.Comment; his.name = v.ItemName; his.size = v.FileSizeLow; his.user = v.UserName; his.version = v.VersionNumberLow; his.date = v.ModificationDateTime; his.date = System.DateTime.Now; his.isdir = true; result.Add(his); } foreach (SAWHHistory v in subFile) { SAWItemInfo his = new SAWItemInfo(); his.comment = v.Comment; his.name = v.ItemName; his.size = v.FileSizeLow; his.user = v.UserName; his.version = v.VersionNumberLow; his.date = v.ModificationDateTime; his.isdir = false; result.Add(his); } /* * SAWItemCache c = new SAWItemCache(); * c.strPath = strFolder; * c.version = version; * c.result = result; * itemCache.Add(c);*/ return(result); }