aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs
Commit message (Expand)AuthorAgeFilesLines
* MS. RML Extensions. Add RMLExtension object with import/export RML.Victoria Plitt2023-01-191-3/+3
* MS. Performance when open RML extensions. Bug during delete tab - remove obje...Victoria Plitt2022-09-151-10/+11
* MS. RML Extension. Save White point.Victoria Plitt2022-09-011-3/+3
* MS. RML Extension. Added Application Type,Victoria Plitt2022-08-311-6/+7
* MS . RML ExtensionVictoria Plitt2022-08-071-2/+4
* RML Extension. New filter to show machines where test were added.Victoria Plitt2022-07-041-11/+75
* RML extension. Removing warning message " Please, select machine".Victoria Plitt2022-05-261-1/+1
* MS - bug: lost focus on 'Search' field on 'RML Extensions'.Victoria Plitt2022-05-021-23/+32
* #5831 RML extension- Color shade windowVictoria Plitt2022-01-191-1/+21
* #5821 Save all changes in DB and loading data.Victoria Plitt2022-01-131-4/+1
* #5821 RML extension - Color calibration windowVictoria Plitt2022-01-091-25/+48
* Save RML Extensions parameters in excel file.Victoria Plitt2021-11-251-4/+4
* #5818 -Export to Excel fileVictoria Plitt2021-11-251-11/+26
* 5818 RML EXTANSION- EXPORT EXCEL FILEVictoria Plitt2021-11-181-0/+120
* RML EXTANSION- item 5745, 5909, 5823. DataBase changes:Victoria Plitt2021-11-171-2/+2
* 1). Save results om selected machine. 2). Notification about save RML on back...Victoria Plitt2021-10-121-2/+55
* Added new tables in General_Env_Upgrade. Inserted new flag for enable/disable...Victoria Plitt2021-08-161-75/+95
* Added column "Level" to RML Extension. Changes in DB and GUI.Victoria Plitt2021-07-271-1/+4
* Save Manufacturer in YarnManufactors table on first open RML/RMLExtentionVictoria Plitt2021-07-201-10/+9
* Added Commands SaveFactors in ColorParameters View, and ApplayToProcessParame...Victoria Plitt2021-07-191-1/+6
* Editable Combobox item in ColorParametersView.Victoria Plitt2021-07-181-93/+352
* RML Extension changesVictoria Plitt2021-07-131-54/+285
* After VirusVictoria Plitt2021-07-041-226/+319
* Created a new project Tango.MachineStudio.ThreadExtentions. Changes in Database.Victoria Plitt2021-05-241-2/+526
* New Thread Extensions ModuleVictoria Plitt2021-04-121-0/+18
"p">; using Microsoft.WindowsAPICodePack.Dialogs; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Data.Entity; using System.Diagnostics; using System.Text; using System.Threading.Tasks; using Tango.BL; using Tango.BL.ActionLogs; using Tango.BL.DTO; using Tango.BL.Entities; using Tango.BL.Enumerations; using Tango.BL.ValueObjects; using Tango.Core.Commands; using Tango.MachineStudio.Common.Notifications; using Tango.MachineStudio.ThreadExtensions.Models; using Tango.SharedUI; using System.Collections.ObjectModel; namespace Tango.MachineStudio.ThreadExtensions.ViewModels { public class TestResultViewVM : ViewModel { private INotificationProvider _notification; private IActionLogManager _actionLogManager; #region Properties private string _threadName; /// <summary> /// Gets or sets the name of the thread. Using in print /// </summary> /// <value> /// The name of the thread. /// </value> public string ThreadName { get { return _threadName; } set { _threadName = value; RaisePropertyChangedAuto(); } } private bool _isSelected; /// <summary> /// Gets or sets a value indicating whether this instance is selected. /// </summary> public bool IsSelected { get { return _isSelected; } set { _isSelected = value; RaisePropertyChangedAuto(); } } private RmlExtensionTestResult _testResult; public RmlExtensionTestResult TestResult { get { return _testResult; } set { _testResult = value; RaisePropertyChangedAuto(); RaisePropertyChanged(nameof(TestResultsFiles)); } } private ObservableCollection<WashingMaterialColorModel> _colorsToMaterialCollection; public ObservableCollection<WashingMaterialColorModel> ColorsToMaterialCollection { get { return _colorsToMaterialCollection; } set { _colorsToMaterialCollection = value; RaisePropertyChangedAuto(); } } public List<RmlExtensionTestResultsFile> TestResultsFiles { get { return TestResult.RmlExtensionTestResultsFiles.ToList(); } } public RelayCommand<RmlExtensionTestResultsFile> DeleteCommand { get; set; } public RelayCommand<RmlExtensionTestResultsFile> DownLoadFileCommand { get; set; } public RelayCommand UploadCommand { get; set; } public RelayCommand DownLoadAllCommand { get; set; } #endregion public TestResultViewVM(INotificationProvider notification, IActionLogManager actionLogManager) { _notification = notification; _actionLogManager = actionLogManager; UploadCommand = new RelayCommand(UploadFiles); DownLoadFileCommand = new RelayCommand<RmlExtensionTestResultsFile>(DownLoadFile); DeleteCommand = new RelayCommand<RmlExtensionTestResultsFile>(DeleteFile); DownLoadAllCommand = new RelayCommand(DownLoadAllFiles); } #region TestResultsFiles private async void UploadFiles(object obj) { OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Select data file"; dlg.Filter = "CSV Files|*.csv"; dlg.Multiselect = true; if (dlg.ShowDialog().Value) { try { var files = dlg.FileNames.ToList(); using (ObservablesContext db = ObservablesContext.CreateDefault()) { var testResult = await db.RmlExtensionTestResults.Where(x => x.Guid == TestResult.Guid).Include(t1 => t1.RmlExtensionTestResultsFiles).FirstOrDefaultAsync(); foreach (var strpath in files) { var testResultfile = new RmlExtensionTestResultsFile(); testResultfile.FileName = Path.GetFileName(strpath); //temporary!!! testResultfile.FilePath = strpath; // TestResult.RmlExtensionTestResultsFiles.Add(testResultfile); testResult.RmlExtensionTestResultsFiles.Add(testResultfile); } if (testResult != null) { await db.SaveChangesAsync(); } TestResult.RmlExtensionTestResultsFiles = testResult.RmlExtensionTestResultsFiles;///????? RaisePropertyChanged(nameof(TestResultsFiles)); } _notification.ShowInfo("File successfully loaded."); } catch (Exception ex) { _notification.ShowError($"An error occurred while trying to import the file.\n{ex.FlattenMessage()}"); } } } private void DownLoadFile(RmlExtensionTestResultsFile file) { SaveFileDialog dlg = new SaveFileDialog(); dlg.Title = "Save the csv file"; dlg.Filter = "CSV Files|*.csv"; dlg.DefaultExt = ".csv"; dlg.FileName = file.FileName; if (dlg.ShowDialog().Value) { /// } } private void DownLoadAllFiles() { CommonOpenFileDialog dlg = new CommonOpenFileDialog(); dlg.Title = "Select folder."; dlg.IsFolderPicker = true; if (dlg.ShowDialog() == CommonFileDialogResult.Ok) { var filesPath = TestResult.RmlExtensionTestResultsFiles.Select( x=>x.FilePath).ToList(); ///// } } private async void DeleteFile(RmlExtensionTestResultsFile file) { if (_notification.ShowQuestion("Are you sure you want to delete the selected file?")) { using (ObservablesContext db = ObservablesContext.CreateDefault()) { var deletefile = db.RmlExtensionTestResultsFiles.FirstOrDefault(x => x.Guid == file.Guid); if(deletefile != null) { db.RmlExtensionTestResultsFiles.Remove(deletefile); await db.SaveChangesAsync(); } } TestResult.RmlExtensionTestResultsFiles.Remove(file); RaisePropertyChanged(nameof(TestResultsFiles)); } } #endregion } }