| ofs | hex dump | ascii |
|---|
| 0000 | 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 04 3d 00 00 02 c8 08 06 00 00 00 7c 7b 8b | .PNG........IHDR...=.........|{. |
| 0020 | e8 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 67 41 4d 41 00 00 b1 8f 0b fc 61 05 00 00 | .....sRGB.........gAMA......a... |
| 0040 | 00 09 70 48 59 73 00 00 0e c3 00 00 0e c3 01 c7 6f a8 64 00 00 00 18 74 45 58 74 53 6f 66 74 77 | ..pHYs..........o.d....tEXtSoftw |
| 0060 | 61 72 65 00 70 61 69 6e 74 2e 6e 65 74 20 34 2e 30 2e 39 6c 33 7e 4e 00 00 ff 81 49 44 41 54 78 | are.paint.net.4.0.9l3~N....IDATx |
| 0080 | 5e ec fd 0b f0 25 67 7a de 87 8d 13 72 99 58 66 a4 98 5c 4a 32 43 5a 52 64 89 92 48 8a 97 dd e5 | ^....%gz....r.Xf..\J2CZRd..H.... |
| 00a0 | 6d 49 49 94 44 49 36 53 b2 ab 52 2a 59 b2 75 49 4a b2 14 59 72 54 ba c5 0b 2c 15 45 76 ec c4 2e | mII.DI6S..R*Y.uIJ..YrT...,.Ev... |
| 00c0 | 57 e2 c8 72 25 b6 93 2a 9b 8c 68 96 a8 24 8a 2a fe f3 a2 5d 2c b0 58 dc 2f 33 c0 dc 07 0b 2c 30 | W..r%..*..h..$.*...],.X./3....,0 |
| 00e0 | 00 66 31 18 ec 0d c0 2e 06 18 4c be a7 f7 3c ff 79 fe ef bc 5f 77 9f 3e 7d ce e9 ee f3 4c d5 af | .f1.......L...<.y..._w.>}....L.. |
| 0100 | fa fd de f7 fd be af cf f9 f7 39 a7 df 67 be ee 3e 75 74 74 64 fa f3 cf 18 63 8c 31 c6 18 63 8c | ..........9..g..>uttd....c.1..c. |
| 0120 | 31 7b 24 ab 55 4d 85 d4 69 d2 03 6b 5d fe 7b c6 18 63 8c 31 c6 18 63 cc 1a 64 b5 e5 3a 64 f5 ed | 1{$.UM..i..k].{..c.1..c..d..:d.. |
| 0140 | 41 93 3a 0f 90 ec 60 e9 43 76 90 fe f7 8d 31 c6 18 63 8c 31 c6 98 81 64 75 26 c8 6a d2 36 b2 da | A.:...`.Cv....1..c.1...du&.j.6.. |
| 0160 | f7 e0 48 9d 07 40 3c 10 b4 ad f0 e0 ca 0e 44 f0 0d c2 37 1a 63 8c 31 c6 18 63 8c 31 23 a1 f5 26 | ..H..@<.......D...7.c.1..c.1#..& |
| 0180 | 88 f5 68 97 18 92 d5 ba 5a 17 1f 04 a9 f3 00 88 7f 78 50 13 38 32 41 e3 9b 02 ff 83 15 ff 43 63 | ..h.....Z........xP.82A.......Cc |
| 01a0 | 8c 31 c6 18 63 8c 31 66 43 58 63 c6 da f3 03 05 d6 a5 6d 62 48 56 f3 82 ac 3e 5e 34 a9 73 a1 64 | .1..c.1fCXc.......mbHV...>^4.s.d |
| 01c0 | 7f 70 10 85 0e 8a 1c 38 98 00 45 0d 1e 7c ff 6c e1 d7 ac f8 e7 56 7c f3 8a ff 91 31 c6 18 63 8c | .p.....8..E..|.l.....V|....1..c. |
| 01e0 | 31 c6 18 b3 21 ac 31 59 73 b2 06 45 3d aa c2 08 ea 55 8a 20 14 42 b4 be e5 7f ee 67 42 48 56 37 | 1...!.1Ys..E=....U...B.....gBHV7 |
| 0200 | 2f 8e d4 b9 10 e2 1f 94 f0 0f ce 83 80 07 47 14 38 70 30 51 e0 c0 41 86 03 ef d7 16 7e 9d f0 3f | /.............G.8p0Q..A.....~..? |
| 0220 | 2e fc f3 2b be a5 f0 ad c6 18 63 8c 31 c6 18 63 cc 86 a0 be 64 ad 89 ba 93 35 28 6a 52 8a 22 14 | ...+......c.1..c....d....5(jR.". |
| 0240 | 43 28 82 64 42 88 8a 20 99 f0 41 b2 9a 7a 11 a4 ce 99 93 fd 01 41 26 74 c4 55 1c 99 c0 41 61 03 | C(.dB.....A..z.......A&t.U...Aa. |
| 0260 | 07 de b7 ad f8 0d 2b 7e 63 e1 5f 58 f1 ed 85 ff 49 e0 3b 8c 31 c6 18 63 8c 31 c6 98 1e 68 2d 89 | ......+~c._X....I.;.1..c.1...h-. |
| 0280 | fa 92 b5 26 ea 4e d4 9f bf be 80 7a f4 83 05 8a 22 14 44 b8 42 04 f5 2c 57 83 64 2b 41 28 7e d4 | ...&.N.....z....".D.B..,W.d+A(~. |
| 02a0 | 04 90 ac c6 9e 35 a9 73 a6 c4 3f 16 ff 90 14 3b a0 70 65 ab 39 28 72 00 15 38 70 20 e1 a0 c2 c1 | .....5.s..?....;.pe.9(r..8p..... |
| 02c0 | 85 03 8d 22 c6 77 16 fe c5 c2 6f 5e f1 5b 0a ff d3 c2 6f 2d fc 4b c2 6f 2b fc f6 0a df 65 8c 31 | ...".w....o^.[....o-.K.o+....e.1 |
| 02e0 | c6 18 63 8c 31 e6 e0 c8 ea 43 d4 8e 04 b5 24 6a 4b 80 3a 13 f5 26 ea ce df 54 40 1d 8a 7a 14 b5 | ..c.1....C....$jK.:..&...T@..z.. |
| 0300 | a9 8a 21 14 42 50 c7 a2 9e d5 d5 20 5c 09 42 01 84 f7 04 e9 5a 01 92 d5 dc b3 24 75 ce 10 fd e3 | ..!.BP......\.B.....Z.....$u.... |
| 0320 | 50 e4 a0 d0 41 45 0b 7f e0 28 74 70 25 07 57 71 70 f5 06 54 35 08 1c 38 a8 28 6a e0 e0 c3 01 f9 | P...AE...(tp%.Wqp..T5..8.(j..... |
| 0340 | 3b 56 fc ae c2 77 17 be 67 c5 ef 5e f1 7d 2b be bf f0 03 c6 18 63 8c 31 c6 18 63 4c 0b a8 1d 09 | ;V...w..g..^.}+......c.1..cL.... |
| 0360 | eb 4a c0 5a 13 75 27 ea 4f d6 a2 a8 4b 51 9f a2 4e 85 18 42 21 04 75 2c ea 59 5d 0d 82 7a 17 22 | .J.Z.u'.O...KQ..N..B!.u,.Y]..z." |
| 0380 | 88 5e 0a a3 2b 40 54 fc d0 ba 5a c9 6a f0 d9 90 3a 67 42 f6 c7 50 c1 83 42 47 b6 aa 23 0a 1d 50 | .^..+@T...Z.j...:gB..P..BG..#..P |
| 03a0 | c9 20 72 e0 80 89 02 07 0e 2e 8a 1a 14 32 3e 54 f8 70 e1 23 85 1f 5e f1 23 85 1f 15 7e 4c f8 a8 | ..r..........2>T.p.#..^.#...~L.. |
| 03c0 | 31 c6 18 63 8c 31 c6 18 13 d0 7a 11 36 eb 49 d4 97 a8 33 51 73 02 d4 9f 3f 58 40 3d 8a ff 64 ff | 1..c.1....z.6.I...3Qs...?X@=..d. |
| 03e0 | de 02 c4 90 df 59 e0 0a 12 d4 b1 f8 4f 7b fc e7 3d 44 10 08 20 b8 7a 01 02 08 56 80 f0 32 18 5e | .....Y......O{..=D....z...V..2.^ |
| 0400 | 02 13 2f 7f 81 00 92 ad fa 20 59 5d 3e 79 52 e7 c4 e1 9b 1d ff 00 14 3c f0 c7 c2 92 1d 8a 1d ba | ../.......Y]>yR........<........ |
| 0420 | aa 83 97 ae e0 0f 0f a1 03 8a 18 96 0a 61 e9 10 45 0e 1c 38 14 38 70 50 51 d8 a0 90 81 83 f1 27 | .............a..E..8.8pPQ......' |
| 0440 | 0a bf a7 f0 7b 0b bf af f0 93 85 3f 50 f8 83 81 9f 32 c6 18 63 8c 31 c6 18 63 5a 88 75 24 6a cb | ....{......?P....2..c.1..cZ.u$j. |
| 0460 | df 5f 40 9d 89 7a 13 75 27 ea cf 1f 2f a0 1e 45 6d 4a 41 04 ff 21 4f 21 04 ff 59 8f ff b4 87 08 | ._@..z.u'.../..EmJA..!O!..Y..... |
| 0480 | 12 05 10 d4 bf f8 4f 7f bd 04 06 97 bf f0 fe 1f 7a e9 0b ea ea 9a f8 11 eb f3 c9 93 3a 37 e1 ab | ......O.........z...........:7.. |
| 04a0 | 5f fd ea 46 bc fd f6 db a7 de 78 e3 8d 53 af bf fe fa 31 5f f8 c2 17 1a 3f e2 65 0e 7d c3 e3 a5 | _..F......x..S....1_....?.e.}... |
| 04c0 | 2c 35 b1 03 cb 7a f0 07 e6 bd 39 b8 a2 03 42 07 94 31 1c 1c 38 48 54 e4 f8 b1 27 9f 7c f2 5f 3f | ,5...z....9...B..1..8HT...'.|._? |
| 04e0 | 7d fa f4 df 78 e2 89 27 fe 0f 8f 3e fa e8 7f 74 ee dc b9 ff d3 f3 cf 3f ff f3 85 4f 7d ee 73 9f | }...x..'...>...t.......?...O}.s. |
| 0500 | 3b fd e2 8b 2f 5e 7d e9 a5 97 6e 5e bd 7a f5 36 29 ed 13 94 9c e3 6d 1b 9a df e6 d3 58 6c ab af | ;.../^}...n^.z.6).....m.....Xl.. |
| 0520 | ab 5d cb 51 7f 16 db 16 6d 73 d7 88 39 b5 7e f4 6b 4c db 31 96 e5 44 7f f4 d1 5f 8b b5 11 fb 75 | .].Q....ms..9.~.kL.1..D..._....u |
| 0540 | 8d d1 16 5f 67 fe 5a 2e fc 31 d6 67 dc be 73 33 8f f3 68 bf da 18 99 bf 96 db 45 9c 8f 6d b5 db | ..._g.Z..1.g..s3..h.......E..m.. |
| 0560 | 88 39 b5 7e 5d e3 b5 c5 94 ae 71 da d8 b4 6f e6 df 17 d9 fe 6c ba 8f bb 7c 8d 98 8b f3 0d 9d 57 | .9.~].....q...o.....l...|......W |
| 0580 | fb 45 7b e8 98 64 d3 fe eb 30 c6 5c bb dc df 6d b2 c9 eb 40 df ae fe 31 27 e6 77 f5 9f 3b 4b 7f | .E{..d...0.\...m...@...1'.w..;K. |
| 05a0 | 7d 73 81 7f 87 72 ee 7c 57 6c 0c b6 35 ee 36 f0 31 39 0c bc 6f 87 f4 de e1 b5 4a 6d 79 ab f0 46 | }s...r.|Wl..5.6.19..o.....Jmy..F |
| 05c0 | 39 ce 2f be f0 c2 0b 8f 14 fe 49 a9 49 ff af 0f 3f fc f0 7f 8c fa f4 e9 a7 9f fe bb a5 5e fd 8b | 9./.......I.I...?............^.. |
| 05e0 | a5 fd 2f 97 fa 15 42 c8 0f ad ea 59 88 20 f8 8f 7c fc 87 3e fe 63 9f 97 c2 50 00 c1 d5 0e ba fa | ../...B....Y....|..>.c...P...... |
| 0600 | a3 b7 f8 51 f6 eb d4 cb 2f bf 7c 0a 5b d4 ed 5f fa d2 97 1a be fc e5 2f 37 b5 fb a5 4b 97 4e 5d | ...Q..../.|.[.._....using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Security.Authentication;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using Tango.BL.Entities;
using Tango.Core.DI;
using Tango.Core.ExtensionMethods;
using Tango.Core.Helpers;
using Tango.Core.IO;
using Tango.Integration.Operation;
using Tango.Logging;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Authentication;
using Tango.MachineStudio.Common.StudioApplication;
using Tango.Settings;
using Tango.SharedUI.Helpers;
using Tango.TFS;
namespace Tango.MachineStudio.UI.TFS
{
public class TeamFoundationServiceExtendedClient : TeamFoundationServiceClient
{
private TemporaryFolder _tempFolder;
private String user_email;
public Project Project { get; private set; }
private ObservableCollection<WorkItem> _resolvedWorkItems;
public ObservableCollection<WorkItem> ResolvedWorkItems
{
get { return _resolvedWorkItems; }
set { _resolvedWorkItems = value; RaisePropertyChangedAuto(); }
}
private bool _isInitialized;
public bool IsInitialized
{
get { return _isInitialized; }
private set { _isInitialized = value; RaisePropertyChangedAuto(); }
}
public TeamFoundationServiceExtendedClient(string collectionURL, string userName, string personalToken) : base(collectionURL, userName, personalToken)
{
_tempFolder = TemporaryManager.CreateFolder();
ResolvedWorkItems = new ObservableCollection<WorkItem>();
TangoIOC.Default.GetInstance<IAuthenticationProvider>().CurrentUserChanged += TeamFoundationServiceExtendedClient_CurrentUserChanged;
}
private void TeamFoundationServiceExtendedClient_CurrentUserChanged(object sender, User user)
{
if (user != null)
{
user_email = user.Email;
Task.Factory.StartNew(async () =>
{
Thread.Sleep(5000);
await UpdateCurrentUserResolvedWorkItems();
});
}
}
public Task<WorkItem> UploadWorkItem(WorkItem workItem)
{
return UploadWorkItem(Project, workItem);
}
public async Task UpdateCurrentUserResolvedWorkItems()
{
try
{
if (Project != null)
{
IStudioApplicationManager app = TangoIOC.Default.GetInstance<IStudioApplicationManager>();
var member = GetUserTeamMember();
if (member != null)
{
var items = await GetWorkItemsCreatedBy(Project, member);
items.Where(x => x.StepsToReproduce != null).ToList().ForEach(x => x.StepsToReproduce = x.StepsToReproduce.Replace("<div style=\"white-space:pre;\">", "").Replace("</div>", ""));
ResolvedWorkItems = items.Where(x => x.State == State.Resolved && x.ResolvedReason == ResolvedReason.Fixed && x.IsBuildVersionValid && x.FoundInBuildVersion < app.Version).ToObservableCollection();
}
else
{
LogManager.Default.Log($"User '{user_email}' is not part of the VSTS team.", LogCategory.Warning);
}
}
}
catch (Exception ex)
{
LogManager.Log(ex, "Error getting the current user resolved work items.");
}
}
public async Task<WorkItem> CloseWorkItem(WorkItem workItem)
{
await SetWorkItemState(Project, workItem, State.Closed);
var updated = await AddWorkItemComment(Project, workItem, GetUserTeamMember(), "Bug has been verified and closed by " + GetUserTeamMember().DisplayName + " (via Machine Studio).");
ResolvedWorkItems.Remove(workItem);
return updated;
}
public async Task<WorkItem> ReactivateWorkItem(WorkItem workItem)
{
await SetWorkItemState(Project, workItem, State.New);
var updated = await AddWorkItemComment(Project, workItem, GetUserTeamMember(), "Bug has been reactivated by " + GetUserTeamMember().DisplayName + " (via Machine Studio).");
updated = await SetWorkItemAssignment(Project, updated, workItem.ResolvedBy);
ResolvedWorkItems.Remove(workItem);
return updated;
}
public void Initialize()
{
Task.Factory.StartNew(() =>
{
if (!IsInitialized)
{
try
{
Project = GetProject("Tango").Result;
IsInitialized = true;
}
catch (Exception ex)
{
LogManager.Log(ex, "Error initializing the Team Foundation Service client.");
}
}
});
}
public WorkItem CreateBug()
{
WorkItem item = new WorkItem();
IAuthenticationProvider auth = TangoIOC.Default.GetInstance<IAuthenticationProvider>();
IStudioApplicationManager app = TangoIOC.Default.GetInstance<IStudioApplicationManager>();
item.Area = Project.Areas.FirstOrDefault();
item.Iteration = Project.Iterations.FirstOrDefault();
TeamMember currentUser = GetUserTeamMember();
if (currentUser == null)
{
throw LogManager.Default.Log(new AuthenticationException($"User '{user_email}' is not part of the Tango VSTS team. Please contact your administrator."));
}
item.CreatedBy = currentUser;
item.ChangedBy = currentUser;
item.AuthorizedAs = currentUser;
item.FoundInBuild = app.Version.ToString();
item.Priority = Priority.Priority3;
item.Severity = Severity.Medium;
item.State = State.New;
item.Type = WorkItemType.Bug;
item.Environment = SettingsManager.Default.GetOrCreate<MachineStudioSettings>().DeploymentSlot.ToDescription();
foreach (var window in Application.Current.Windows.OfType<Window>().Where(x => !String.IsNullOrWhiteSpace(x.Title)))
{
var bitmap = UIHelper.TakeSnapshot(window);
if (!_tempFolder.Exists())
{
_tempFolder = TemporaryManager.CreateFolder();
}
var tempFile = _tempFolder.CreateFile();
bitmap.SaveJpeg(tempFile.Path, 30);
String title = window.Title;
item.Attachments.Add(new Attachment()
{
Description = title + " Screen Capture",
FilePath = tempFile.Path,
Name = $"{title}.jpg",
});
}
return item;
}
private string[] GetLogFiles(FileLogger logger)
{
string[] fileEntries = new string[1];
fileEntries[0] = logger.LogFile;
string fileName = Path.GetFileNameWithoutExtension(logger.LogFile);
int indexPos = fileName.IndexOf(FileLogger.FILE_SET_EXTENSION);
if (indexPos > 0)
{
string extension = Path.GetExtension(logger.LogFile);
fileName = fileName.Substring(0, indexPos);
fileEntries = Directory.GetFiles(logger.Folder, $"{fileName}*{extension}").Where(x => Path.GetFileName(x).StartsWith(logger.Tag)).OrderBy(x => x.Length).ThenBy(x => x).ToArray();
}
return fileEntries;
}
public void FinalizeBug(WorkItem item)
{
IAuthenticationProvider auth = TangoIOC.Default.GetInstance<IAuthenticationProvider>();
IStudioApplicationManager app = TangoIOC.Default.GetInstance<IStudioApplicationManager>();
FileLogger appFileLogger = LogManager.Default.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger;
FileLogger embeddedFileLogger = MachineOperator.EmbeddedLogManager.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(FileLogger)) as FileLogger;
if (appFileLogger != null)
{
string[] logFiles = GetLogFiles(appFileLogger);
foreach( string file in logFiles)
{
var appLogFile = _tempFolder.CreateImaginaryFile();
File.Copy(file, appLogFile.Path);
item.Attachments.Add(new Attachment()
{
Description = "Application Log File",
FilePath = appLogFile.Path,
Name = Path.GetFileName(file),
});
}
}
if (embeddedFileLogger != null && File.Exists(embeddedFileLogger.LogFile))
{
string[] logFiles = GetLogFiles(embeddedFileLogger);
foreach (string file in logFiles)
{
var embeddedLogFile = _tempFolder.CreateImaginaryFile();
File.Copy(file, embeddedLogFile.Path);
item.Attachments.Add(new Attachment()
{
Description = "Embedded Log File",
FilePath = embeddedLogFile.Path,
Name = Path.GetFileName(file),
});
}
}
//Add session log file..
if (MachineOperator.EnableSessionLogFile)
{
var file = MachineOperator.SessionLogger.LogFile;
if (file != null && File.Exists(file))
{
var sessionLogFile = _tempFolder.CreateImaginaryFile();
File.Copy(file, sessionLogFile.Path);
item.Attachments.Add(new Attachment()
{
Description = "Session Log File",
FilePath = sessionLogFile.Path,
Name = Path.GetFileName(file),
});
}
}
SystemInformationModel sysModel = new SystemInformationModel();
sysModel.ApplicationVersion = app.Version.ToString();
sysModel.EmbeddedVersion = "N/A";
sysModel.HostName = Environment.MachineName;
sysModel.UserName = auth.CurrentUser.Contact.FullName;
if (app.ConnectedMachine != null)
{
Machine machine = app.Machine;
sysModel.Machine = machine;
sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version;
sysModel.ConfigurationString = machine.Configuration.Clone().ToJsonString();
if (app.ConnectedMachine.CurrentProcessParameters != null)
{
sysModel.LoadedProcessParametersString = app.ConnectedMachine.CurrentProcessParameters.ToJsonString(nameof(ProcessParametersTable.ProcessParametersTablesGroup));
}
if (app.ConnectedMachine.CurrentHardwareConfiguration != null)
{
sysModel.LoadedHardwareConfigurationString = app.ConnectedMachine.CurrentHardwareConfiguration.ToJsonString();
}
}
if (app.Machine != null && app.ConnectedMachine != null && app.ConnectedMachine.DeviceInformation != null)
{
item.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version;
item.MachineSerialNumber = app.Machine.SerialNumber;
}
String html = String.Empty;
using (var stream = EmbeddedResourceHelper.GetEmbeddedResourceStream("Tango.MachineStudio.UI.TFS.SystemInformationTemplate.cshtml"))
{
StreamReader reader = new StreamReader(stream);
html = reader.ReadToEnd();
}
item.SystemInformation = CodeGeneration.Helper.Parse(html, sysModel);
item.StepsToReproduce = String.Format("<div style=\"white-space:pre\">{0}</div>", item.StepsToReproduce);
}
private TeamMember GetUserTeamMember()
{
IAuthenticationProvider auth = TangoIOC.Default.GetInstance<IAuthenticationProvider>();
TeamMember currentUser = Project.Members.SingleOrDefault(x => x.UniqueName.ToLower().Contains(auth.CurrentUser.Email.ToLower()));
return currentUser;
}
}
}
|