aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2018-04-25 09:44:13 +0300
committerAvi Levkovich <avi@twine-s.com>2018-04-25 09:44:13 +0300
commitd352d3b3bd785d9eb8a93347333de0b357f7ce0e (patch)
tree2488173ea7e4f9d5ddb6ef53de57998815732847 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS
parentc82908b6d5314bc2602ea10c373267b79fbdd810 (diff)
parenta89077bae848d010ae70da6be572dee3b824a895 (diff)
downloadTango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.tar.gz
Tango-d352d3b3bd785d9eb8a93347333de0b357f7ce0e.zip
Start SPI ADS1220
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs19
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml70
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs160
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs19
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs32
5 files changed, 300 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs
new file mode 100644
index 000000000..eb9ef8012
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL.Entities;
+
+namespace Tango.MachineStudio.UI.TFS
+{
+ public class SystemInformationModel
+ {
+ public String ApplicationVersion { get; set; }
+ public String EmbeddedVersion { get; set; }
+ public String UserName { get; set; }
+ public String HostName { get; set; }
+ public Machine Machine { get; set; }
+ public String ConfigurationString { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml
new file mode 100644
index 000000000..7b0c4a896
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml
@@ -0,0 +1,70 @@
+@{
+ Tango.MachineStudio.UI.TFS.SystemInformationModel vm = Model as Tango.MachineStudio.UI.TFS.SystemInformationModel;
+}
+
+<div>
+ <div style="font-size:20pt;text-decoration:underline">System Information</div>
+ <table style="margin-top:10px">
+ <tbody>
+
+ <tr>
+ <td><b>Application Version:</b></td>
+ <td>@vm.ApplicationVersion</td>
+ </tr>
+
+ <tr>
+ <td><b>Embedded Version:</b></td>
+ <td>@vm.EmbeddedVersion</td>
+ </tr>
+
+ <tr>
+ <td><b>Host Name:</b></td>
+ <td>@vm.HostName</td>
+ </tr>
+
+ <tr>
+ <td><b>User:</b></td>
+ <td>@vm.UserName</td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <div style="font-size:20pt;text-decoration:underline;margin-top:10px">Machine</div>
+
+ @if (vm.Machine != null)
+ {
+ <table style="margin-top:10px">
+ <tbody>
+
+ <tr>
+ <td><b>Organization:</b></td>
+ <td>@vm.Machine.Organization.Name</td>
+ </tr>
+
+ <tr>
+ <td><b>Name:</b></td>
+ <td>@vm.Machine.Name</td>
+ </tr>
+
+ <tr>
+ <td><b>S/N:</b></td>
+ <td>@vm.Machine.SerialNumber</td>
+ </tr>
+
+ <tr>
+ <td><b>Version:</b></td>
+ <td>@vm.Machine.MachineVersion.Version</td>
+ </tr>
+
+ </tbody>
+ </table>
+
+ <div style="font-size:20pt;text-decoration:underline;margin-top:10px">Configuration</div>
+ <div style="white-space:pre;margin-top:10px;font-size:8pt">@vm.ConfigurationString</div>
+ }
+ else
+ {
+ <div style="color:Red;margin-top:10px">Not Connected</div>
+ }
+</div> \ No newline at end of file
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs
new file mode 100644
index 000000000..27b257e61
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs
@@ -0,0 +1,160 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using Tango.BL.Entities;
+using Tango.Core.DI;
+using Tango.Core.Helpers;
+using Tango.Integration.Operation;
+using Tango.Logging;
+using Tango.MachineStudio.Common.Authentication;
+using Tango.MachineStudio.Common.StudioApplication;
+using Tango.SharedUI.Helpers;
+using Tango.TFS;
+
+namespace Tango.MachineStudio.UI.TFS
+{
+ public class TeamFoundationServiceExtendedClient : TeamFoundationServiceClient
+ {
+ public Project Project { get; private set; }
+
+ 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)
+ {
+
+ }
+
+ public Task<WorkItem> UploadWorkItem(WorkItem workItem)
+ {
+ return UploadWorkItem(Project, workItem);
+ }
+
+ public void Initialize()
+ {
+ Task.Factory.StartNew(() =>
+ {
+ if (!IsInitialized)
+ {
+ Project = GetProject("Tango").Result;
+ IsInitialized = true;
+ }
+ });
+ }
+
+ 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 = Project.Members.SingleOrDefault(x => x.UniqueName.ToLower().Contains(auth.CurrentUser.Email.ToLower()));
+ item.CreatedBy = currentUser;
+ item.ChangedBy = currentUser;
+ item.AuthorizedAs = currentUser;
+
+ item.FoundInBuild = app.Version;
+ item.Priority = Priority.Priority3;
+ item.Severity = Severity.Medium;
+ item.State = State.New;
+ item.Type = WorkItemType.Bug;
+
+ var bitmap = UIHelper.TakeSnapshot(MainWindow.Instance);
+ String filePath = PathHelper.GetTempFilePath();
+ bitmap.SaveJpeg(filePath, 30);
+
+ item.Attachments.Add(new Attachment()
+ {
+ Description = "Screen Capture",
+ FilePath = filePath,
+ Name = "Screen Capture.jpg",
+ });
+
+ 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 appLogFile = PathHelper.GetTempFilePath();
+ File.Copy(appFileLogger.LogFile, appLogFile);
+
+ item.Attachments.Add(new Attachment()
+ {
+ Description = "Application Log File",
+ FilePath = appLogFile,
+ Name = Path.GetFileName(appFileLogger.LogFile),
+ });
+ }
+
+ if (embeddedFileLogger != null && File.Exists(embeddedFileLogger.LogFile))
+ {
+ String embeddedLogFile = PathHelper.GetTempFilePath();
+ File.Copy(appFileLogger.LogFile, embeddedLogFile);
+
+ item.Attachments.Add(new Attachment()
+ {
+ Description = "Embedded Log File",
+ FilePath = embeddedLogFile,
+ Name = Path.GetFileName(embeddedFileLogger.LogFile),
+ });
+ }
+
+ SystemInformationModel sysModel = new SystemInformationModel();
+ sysModel.ApplicationVersion = app.Version;
+ sysModel.EmbeddedVersion = "Fake Version";
+ sysModel.HostName = Environment.MachineName;
+ sysModel.UserName = auth.CurrentUser.Contact.FullName;
+
+ if (app.ConnectedMachine != null)
+ {
+ Machine machine = app.ConnectedMachine.Machine;
+
+ sysModel.Machine = machine;
+
+ MachineDesigner.Views.MainView machineView = new MachineDesigner.Views.MainView();
+ machineView.Width = 1280;
+ machineView.Height = 1100;
+ machineView.PanelColumnDefinition.Width = new System.Windows.GridLength(0);
+ machineView.stackHeader.Visibility = Visibility.Collapsed;
+ machineView.Background = System.Windows.Media.Brushes.White;
+ machineView.DataContext = new MachineDesigner.ViewModels.MainViewVM() { SelectedMachine = machine, Configuration = machine.Configuration };
+
+ String configImageFile = PathHelper.GetTempFilePath();
+ machineView.RenderToFile(configImageFile, System.Drawing.Imaging.ImageFormat.Jpeg, new System.Windows.Size(machineView.Width, machineView.Height), 100);
+
+ item.Attachments.Add(new Attachment()
+ {
+ Description = "Machine Configuration",
+ FilePath = configImageFile,
+ Name = "Machine Configuration.jpg"
+ });
+
+ sysModel.ConfigurationString = machine.Configuration.CloneConfiguration().ToJsonString();
+ }
+
+ 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);
+
+ return item;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs
new file mode 100644
index 000000000..0691ca6bd
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamMembersProvider.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.AutoComplete.Editors;
+using Tango.Core.DI;
+
+namespace Tango.MachineStudio.UI.TFS
+{
+ public class TeamMembersProvider : ISuggestionProvider
+ {
+ public IEnumerable GetSuggestions(string filter)
+ {
+ return TangoIOC.Default.GetInstance<TeamFoundationServiceExtendedClient>().Project.Members.Where(x => x.AssignName.ToLower().Contains(filter.ToLower()));
+ }
+ }
+}
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs
new file mode 100644
index 000000000..1418d0576
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/WorkItemValidationAttribute.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.TFS;
+
+namespace Tango.MachineStudio.UI.TFS
+{
+ public class WorkItemValidationAttribute : ValidationAttribute
+ {
+ public override bool IsValid(object value)
+ {
+ WorkItem item = value as WorkItem;
+
+ if (String.IsNullOrWhiteSpace(item.Title))
+ {
+ ErrorMessage = "Title is empty";
+ return false;
+ }
+
+ if (item.AssignedTo == null)
+ {
+ ErrorMessage = "Assigned To is empty";
+ return false;
+ }
+
+ return true;
+ }
+ }
+}