// Updates the Perforce status of the file public static void UpdatePerforceStatus(List <UserFile> fileList) { string[] fileStatusList = fileList.Select(x => x.ItemPath).ToArray(); if (fileStatusList.Any()) { List <FileMetaData> p4Info = Perforce.FileStatus(fileStatusList); if (p4Info != null) { foreach (FileMetaData metaData in p4Info) { UserFile updateFile = fileList.Where(x => x.ItemPath == metaData.LocalPath.Path).FirstOrDefault(); try { if (metaData == null) { updateFile.P4Status = P4Status.Unknown; } else if (metaData.OtherUsers != null) { updateFile.P4Status = P4Status.CheckedOutOther; } else if (metaData.Action == FileAction.None) { updateFile.P4Status = P4Status.CheckedIn; } else if (metaData.Action == FileAction.Edit) { updateFile.P4Status = P4Status.CheckedOut; } else if (metaData.Action == FileAction.Add) { updateFile.P4Status = P4Status.Add; } else if (metaData.Action == FileAction.Delete) { updateFile.P4Status = P4Status.Delete; } updateFile.P4Success = true; } catch (Exception e) { updateFile.P4Status = P4Status.Unknown; updateFile.P4Success = false; updateFile.FileError = e; System.Windows.Clipboard.SetText(updateFile.FileError.ToString()); } } } } }
// Update the Perforce status of the file, and whether or not Perforce successfully checked the file public virtual void UpdatePerforceStatus() { // If Perforce is Down or errors on getting file status fail gracefully and set P4 status to unknown try { List <FileMetaData> p4Info = Perforce.FileStatus(ItemPath); if (p4Info == null) { P4Status = P4Status.Unknown; } else if (p4Info.FirstOrDefault().OtherUsers != null) { P4Status = P4Status.CheckedOutOther; } else if (p4Info.FirstOrDefault().Action == FileAction.None) { P4Status = P4Status.CheckedIn; } else if (p4Info.FirstOrDefault().Action == FileAction.Edit) { P4Status = P4Status.CheckedOut; } else if (p4Info.FirstOrDefault().Action == FileAction.Add) { P4Status = P4Status.Add; } else if (p4Info.FirstOrDefault().Action == FileAction.Delete) { P4Status = P4Status.Delete; } P4Success = true; } catch (Exception e) { P4Status = P4Status.Unknown; P4Success = false; FileError = e; } }