From 00a491d93733d4625ad329b2ba8237f445364b3f Mon Sep 17 00:00:00 2001 From: Mirta Date: Wed, 30 Dec 2020 16:39:52 +0200 Subject: merge --- .../Modules/Tango.MachineStudio.Sites/App.xaml | 12 -- .../Contracts/IMainView.cs | 20 -- .../Images/machine_site.png | Bin 207547 -> 0 bytes .../Tango.MachineStudio.Sites/Images/site.png | Bin 22073 -> 0 bytes .../Tango.MachineStudio.Sites/Models/SiteModel.cs | 18 -- .../Properties/AssemblyInfo.cs | 19 -- .../Properties/Resources.Designer.cs | 62 ------ .../Properties/Resources.resx | 117 ----------- .../Properties/Settings.Designer.cs | 30 --- .../Properties/Settings.settings | 7 - .../Tango.MachineStudio.Sites/SitesModule.cs | 62 ------ .../Tango.MachineStudio.Sites.csproj | 177 ----------------- .../Tango.MachineStudio.Sites/ViewModelLocator.cs | 29 --- .../ViewModels/MainViewVM.cs | 220 --------------------- .../ViewModels/SiteDetailsViewVM.cs | 175 ---------------- .../Tango.MachineStudio.Sites/Views/MainView.xaml | 19 -- .../Views/MainView.xaml.cs | 36 ---- .../Views/SiteDetailsView.xaml | 170 ---------------- .../Views/SiteDetailsView.xaml.cs | 28 --- .../Tango.MachineStudio.Sites/Views/SitesView.xaml | 76 ------- .../Views/SitesView.xaml.cs | 28 --- .../Modules/Tango.MachineStudio.Sites/app.config | 85 -------- .../Tango.MachineStudio.Sites/packages.config | 9 - 23 files changed, 1399 deletions(-) delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/site.png delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/AssemblyInfo.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.Designer.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.resx delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.Designer.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.settings delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/SitesModule.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModelLocator.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config delete mode 100644 Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites') diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml deleted file mode 100644 index 01a064b05..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/App.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs deleted file mode 100644 index 67f57b28c..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Contracts/IMainView.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.SharedUI; - -namespace Tango.MachineStudio.Sites.Contracts -{ - public enum SitesNavigationView - { - SitesView, - SiteDetailsView, - } - - public interface IMainView : IView - { - void NavigateTo(SitesNavigationView view); - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png deleted file mode 100644 index 9b22e53b0..000000000 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/machine_site.png and /dev/null differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/site.png b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/site.png deleted file mode 100644 index 2fee5fafa..000000000 Binary files a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Images/site.png and /dev/null differ diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs deleted file mode 100644 index 007f8a3ad..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Models/SiteModel.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL.Entities; -using Tango.SharedUI.Components; - -namespace Tango.MachineStudio.Sites.Models -{ - public class SiteModel : Site - { - public String Organization { get; set; } - public int MachineCount { get; set; } - public int CatalogCount { get; set; } - public int ThreadCount { get; set; } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/AssemblyInfo.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/AssemblyInfo.cs deleted file mode 100644 index a6eebb5a8..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; -using System.Windows; - -[assembly: AssemblyTitle("Tango - Machine Studio Sites Module")] -[assembly: AssemblyVersion("1.0.0.1737")] - -[assembly: ComVisible(false)] - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.Designer.cs deleted file mode 100644 index ecefa25e7..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.Designer.cs +++ /dev/null @@ -1,62 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.MachineStudio.Sites.Properties { - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if ((resourceMan == null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Tango.MachineStudio.Sites.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.resx b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.resx deleted file mode 100644 index af7dbebba..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Resources.resx +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.Designer.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.Designer.cs deleted file mode 100644 index 5fa894ceb..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace Tango.MachineStudio.Sites.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] - internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase - { - - private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); - - public static Settings Default - { - get - { - return defaultInstance; - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.settings b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.settings deleted file mode 100644 index 033d7a5e9..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/SitesModule.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/SitesModule.cs deleted file mode 100644 index 96d3aed49..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/SitesModule.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media.Imaging; -using Tango.BL.Enumerations; -using Tango.MachineStudio.Common; -using Tango.MachineStudio.Sites.Views; -using Tango.SharedUI.Helpers; - -namespace Tango.MachineStudio.Sites -{ - [StudioModule(20)] - public class SitesModule : StudioModuleBase - { - public override string Name - { - get - { - return "Sites"; - } - } - - public override string Description - { - get - { - return "Manage organizations sites and their common machine properties."; - } - } - - public override BitmapSource Image - { - get - { - return ResourceHelper.GetImageFromResources("Images/site.png"); - } - } - - public override Type MainViewType - { - get - { - return typeof(MainView); - } - } - - public override Permissions Permission - { - get - { - return Permissions.RunRMLModule; - } - } - - public override void Dispose() - { - - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj deleted file mode 100644 index ea9162ce2..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Tango.MachineStudio.Sites.csproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - AnyCPU - {18A27902-9881-4556-8163-F6DF2236A14D} - library - Tango.MachineStudio.Sites - Tango.MachineStudio.Sites - v4.6.1 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - true - full - false - ..\..\..\Build\Machine Studio\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - ..\..\..\Build\Machine Studio\Release\ - TRACE - prompt - 4 - - - - ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll - - - ..\..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - - ..\..\..\packages\Google.Protobuf.3.4.1\lib\net45\Google.Protobuf.dll - - - ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\MahApps.Metro.dll - - - ..\..\..\packages\MaterialDesignColors.1.1.2\lib\net45\MaterialDesignColors.dll - - - ..\..\..\packages\MaterialDesignThemes.2.3.1.953\lib\net45\MaterialDesignThemes.Wpf.dll - - - ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - - - - ..\..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll - - - - - - - - - 4.0 - - - - - - - - - - - - - MainView.xaml - - - GlobalVersionInfo.cs - - - - SiteDetailsView.xaml - - - SitesView.xaml - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - - - - - - {f441feee-322a-4943-b566-110e12fd3b72} - Tango.BL - - - {a34ee0f0-649d-41c8-8489-b6f1cc6924ee} - Tango.Core - - - {4206ac58-3b57-4699-8835-90bf6db01a61} - Tango.Integration - - - {bc932dbd-7cdb-488c-99e4-f02cf441f55e} - Tango.Logging - - - {d8f1ad85-526a-4f50-b6dc-d437af63d8d8} - Tango.Settings - - - {8491D07B-C1F6-4B62-A412-41B9FD2D6538} - Tango.SharedUI - - - {74e700b0-1156-4126-be40-ee450d3c3026} - Tango.Transport - - - {cb0b0aa2-bb24-4bca-a720-45e397684e12} - Tango.MachineStudio.Common - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModelLocator.cs deleted file mode 100644 index c06ae05e7..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModelLocator.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.Core.DI; -using Tango.MachineStudio.Sites.ViewModels; - -namespace Tango.MachineStudio.Sites -{ - public static class ViewModelLocator - { - /// - /// Initializes a new instance of the ViewModelLocator class. - /// - static ViewModelLocator() - { - TangoIOC.Default.Register(); - } - - public static MainViewVM MainViewVM - { - get - { - return TangoIOC.Default.GetInstance(); - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs deleted file mode 100644 index 5db5e004d..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/MainViewVM.cs +++ /dev/null @@ -1,220 +0,0 @@ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.ActionLogs; -using Tango.BL.Builders; -using Tango.BL.Entities; -using Tango.Core.Commands; -using Tango.Core.Threading; -using Tango.MachineStudio.Common; -using Tango.MachineStudio.Common.Authentication; -using Tango.MachineStudio.Common.Notifications; -using Tango.MachineStudio.Sites.Contracts; -using Tango.MachineStudio.Sites.Models; - -namespace Tango.MachineStudio.Sites.ViewModels -{ - public class MainViewVM : StudioViewModel - { - private ObservablesContext _db; - private INotificationProvider _notification; - private IAuthenticationProvider _authentication; - private IActionLogManager _actionLogManager; - private ActionTimer _filter_timer; - - private List _sites; - public List Sites - { - get { return _sites; } - set { _sites = value; RaisePropertyChangedAuto(); } - } - - private SiteModel _selectedSite; - public SiteModel SelectedSite - { - get { return _selectedSite; } - set { _selectedSite = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); } - } - - private String _filter; - public String Filter - { - get { return _filter; } - set { _filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } - } - - private SiteDetailsViewVM _siteDetailsViewVM; - public SiteDetailsViewVM SiteDetailsViewVM - { - get { return _siteDetailsViewVM; } - set { _siteDetailsViewVM = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand AddSiteCommand { get; set; } - - public RelayCommand RemoveSiteCommand { get; set; } - - public RelayCommand ManageSiteCommand { get; set; } - - public RelayCommand BackToSitesCommand { get; set; } - - public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) - { - _notification = notificationProvider; - _authentication = authentication; - _actionLogManager = actionLogManager; - _filter_timer = new ActionTimer(TimeSpan.FromMilliseconds(500)); - - ManageSiteCommand = new RelayCommand(() => LoadSelectedSite(), () => SelectedSite != null); - BackToSitesCommand = new RelayCommand(() => { View.NavigateTo(SitesNavigationView.SitesView); }); - AddSiteCommand = new RelayCommand(AddNewSite); - RemoveSiteCommand = new RelayCommand(RemoveSelectedSite, () => SelectedSite != null); - } - - private async void RemoveSelectedSite() - { - if (!_notification.ShowQuestion("Are you sure you wish to remove the selected site?")) return; - - try - { - using (_notification.PushTaskItem("Removing site...")) - { - IsFree = false; - await Task.Factory.StartNew(() => - { - var site = _db.Sites.SingleOrDefault(x => x.Guid == SelectedSite.Guid); - site.Delete(_db); - _db.SaveChanges(); - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteDeleted, _authentication.CurrentUser, site.Name, site, "Site deleted using Machine Studio."); - Sites.Remove(SelectedSite); - LoadSites(); - }); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error removing site."); - _notification.ShowError($"Error removing site.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } - } - - private async void AddNewSite() - { - try - { - String name = _notification.ShowTextInput("Enter site name", "name"); - if (String.IsNullOrWhiteSpace(name)) return; - - using (_notification.PushTaskItem("Creating site...")) - { - IsFree = false; - SiteDetailsViewVM = new SiteDetailsViewVM(); - SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; - await SiteDetailsViewVM.Init(SelectedSite?.Guid, _notification, _authentication, _actionLogManager, true, name); - View.NavigateTo(SitesNavigationView.SiteDetailsView); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error creating site."); - _notification.ShowError($"Error creating site.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } - } - - private async void LoadSelectedSite() - { - try - { - using (_notification.PushTaskItem("Loading site details...")) - { - IsFree = false; - SiteDetailsViewVM = new SiteDetailsViewVM(); - SiteDetailsViewVM.Saved += SiteDetailsViewVM_Saved; - await SiteDetailsViewVM.Init(SelectedSite.Guid, _notification, _authentication, _actionLogManager, false); - View.NavigateTo(SitesNavigationView.SiteDetailsView); - } - } - catch (Exception ex) - { - LogManager.Log(ex, "Error loading site details."); - _notification.ShowError($"Error loading site details.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } - } - - private void SiteDetailsViewVM_Saved(object sender, EventArgs e) - { - OnFilterChanged(); - View.NavigateTo(SitesNavigationView.SitesView); - } - - private void OnFilterChanged() - { - if (Filter != null) - { - _filter_timer.ResetReplace(() => - { - try - { - LoadSites(); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error loading sites list."); - } - }); - } - } - - private void LoadSites() - { - using (_notification.PushTaskItem("Loading sites...")) - { - Sites = (from site in _db.Sites - join organization in _db.Organizations on site.OrganizationGuid equals organization.Guid - join sites_rmls in _db.SitesRmls on site.Guid equals sites_rmls.SiteGuid into rmls - join sites_catalogs in _db.SitesCatalogs on site.Guid equals sites_catalogs.SiteGuid into catalogs - join sites_machines in _db.Machines on site.Guid equals sites_machines.SiteGuid into machines - where Filter == null || Filter == "" || site.Name.ToLower().StartsWith(Filter.ToLower()) || organization.Name.ToLower().StartsWith(Filter.ToLower()) - select new - { - Site = site, - OrganizationName = organization.Name, - ThreadCount = rmls.Count(x => x.SiteGuid == site.Guid), - CatalogCount = catalogs.Count(x => x.SiteGuid == site.Guid), - MachineCount = machines.Count(x => x.SiteGuid == site.Guid) - }).Distinct().ToList().DistinctBy(x => x.Site.Guid).Select(x => new SiteModel() - { - Guid = x.Site.Guid, - ID = x.Site.ID, - Name = x.Site.Name, - Description = x.Site.Description, - ThreadCount = x.ThreadCount, - CatalogCount = x.CatalogCount, - MachineCount = x.MachineCount, - Organization = x.OrganizationName, - }).ToList(); - } - } - - public override void OnApplicationReady() - { - _db = ObservablesContext.CreateDefault(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs deleted file mode 100644 index cacda1e8d..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/ViewModels/SiteDetailsViewVM.cs +++ /dev/null @@ -1,175 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Tango.BL; -using Tango.BL.Entities; -using Tango.Core.Commands; -using Tango.SharedUI; -using Tango.SharedUI.Components; -using System.Data.Entity; -using Tango.MachineStudio.Common.Notifications; -using Tango.MachineStudio.Common.Authentication; -using Tango.BL.ActionLogs; -using Tango.BL.DTO; -using Tango.BL.Builders; - -namespace Tango.MachineStudio.Sites.ViewModels -{ - public class SiteDetailsViewVM : ViewModel - { - private ObservablesContext _db; - private INotificationProvider _notification; - private IAuthenticationProvider _authentication; - private IActionLogManager _actionLogManager; - private bool _isNew; - private SiteDTO _siteBeforeSave; - - public event EventHandler Saved; - - private Site _site; - public Site Site - { - get { return _site; } - set { _site = value; RaisePropertyChangedAuto(); } - } - - private List _organizations; - public List Organizations - { - get { return _organizations; } - set { _organizations = value; RaisePropertyChangedAuto(); } - } - - private SelectedObjectCollection _rmls; - public SelectedObjectCollection Rmls - { - get { return _rmls; } - set { _rmls = value; RaisePropertyChangedAuto(); } - } - - private SelectedObjectCollection _catalogs; - public SelectedObjectCollection Catalogs - { - get { return _catalogs; } - set { _catalogs = value; RaisePropertyChangedAuto(); } - } - - private List _machines; - public List Machines - { - get { return _machines; } - set { _machines = value; RaisePropertyChangedAuto(); } - } - - public RelayCommand SaveCommand { get; set; } - - public SiteDetailsViewVM() - { - SaveCommand = new RelayCommand(Save, () => IsFree); - } - - public async Task Init(String siteGuid, INotificationProvider notification, IAuthenticationProvider authentication, IActionLogManager actionLogManager, bool isNew, string newSiteName = null) - { - _notification = notification; - _authentication = authentication; - _actionLogManager = actionLogManager; - - _db = ObservablesContext.CreateDefault(); - Organizations = await _db.Organizations.ToListAsync(); - - if (isNew) - { - Site = new Site(); - Site.Name = newSiteName; - Site.Description = "My site description"; - _db.Sites.Add(Site); - - _isNew = true; - } - else - { - _isNew = false; - Site = await new SiteBuilder(_db).Set(siteGuid) - .WithSiteCatalogs() - .WithCatalogs() - .WithSiteRmls() - .WithRmls() - .WithOrganization() - .BuildAsync(); - } - - Machines = await _db.Machines.Where(x => x.SiteGuid == Site.Guid).Include(x => x.Organization).ToListAsync(); - - var rmls = await _db.Rmls.OrderBy(x => x.Name).ToListAsync(); - var catalogs = await _db.ColorCatalogs.OrderBy(x => x.Name).ToListAsync(); - - Rmls = new SelectedObjectCollection(rmls.ToObservableCollection(), Site.SitesRmls.Select(x => x.Rml).ToObservableCollection()); - Catalogs = new SelectedObjectCollection(catalogs.ToObservableCollection(), Site.SitesCatalogs.Select(x => x.ColorCatalog).ToObservableCollection()); - - _siteBeforeSave = SiteDTO.FromObservable(Site); - } - - private async void Save() - { - try - { - if (!Site.Validate(_db)) - { - _notification.ShowError(String.Join("\n", Site.ValidationErrors)); - return; - } - - IsFree = false; - - using (_notification.PushTaskItem("Saving site details...")) - { - //Check if site organization has changed and there are no machines that belongs to this site but different organization. - if (_db.Machines.Any(x => x.SiteGuid == Site.Guid && x.OrganizationGuid != Site.OrganizationGuid)) - { - throw new InvalidOperationException($"One or more machines belongs to this site but not to '{Site.Organization.Name}' organization."); - } - - //Remove site rmls. - Site.SitesRmls.ToList().Where(x => !Rmls.SynchedSource.ToList().Exists(y => y.Guid == x.RmlGuid)).ToList().ForEach(x => _db.SitesRmls.Remove(x)); - Site.SitesCatalogs.ToList().Where(x => !Catalogs.SynchedSource.ToList().Exists(y => y.Guid == x.ColorCatalogGuid)).ToList().ForEach(x => _db.SitesCatalogs.Remove(x)); - - foreach (var selectedRml in Rmls.SynchedSource.Where(x => !Site.SitesRmls.ToList().Exists(y => y.RmlGuid == x.Guid))) - { - _db.SitesRmls.Add(new SitesRml() { SiteGuid = Site.Guid, RmlGuid = selectedRml.Guid }); - } - - foreach (var selectedCatalog in Catalogs.SynchedSource.Where(x => !Site.SitesCatalogs.ToList().Exists(y => y.ColorCatalogGuid == x.Guid))) - { - _db.SitesCatalogs.Add(new SitesCatalog() { SiteGuid = Site.Guid, ColorCatalogGuid = selectedCatalog.Guid }); - } - - await _db.SaveChangesAsync(); - - if (_isNew) - { - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteCreated, _authentication.CurrentUser, Site.Name, Site, "Site created using Machine Studio."); - } - else - { - SiteDTO siteAfter = SiteDTO.FromObservable(Site); - _actionLogManager.InsertLog(BL.Enumerations.ActionLogType.SiteSaved, _authentication.CurrentUser, _siteBeforeSave.Name, _siteBeforeSave, siteAfter, "Site saved using Machine Studio."); - _siteBeforeSave = siteAfter; - } - } - _db.Dispose(); - Saved?.Invoke(this, new EventArgs()); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error saving site details."); - _notification.ShowError($"Error saving site details.\n{ex.FlattenMessage()}"); - } - finally - { - IsFree = true; - } - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml deleted file mode 100644 index 4ca82c4f7..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs deleted file mode 100644 index c4f9995ce..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/MainView.xaml.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; -using Tango.Core.DI; -using Tango.MachineStudio.Sites.Contracts; - -namespace Tango.MachineStudio.Sites.Views -{ - /// - /// Interaction logic for MainView.xaml - /// - public partial class MainView : UserControl, IMainView - { - public MainView() - { - InitializeComponent(); - TangoIOC.Default.Register(this); - } - - public void NavigateTo(SitesNavigationView view) - { - navigationControl.NavigateTo(view.ToString()); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml deleted file mode 100644 index 182f05be0..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PROPERTIES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SITE RML - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs deleted file mode 100644 index 03e9a2f75..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SiteDetailsView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Sites.Views -{ - /// - /// Interaction logic for SiteDetailsView.xaml - /// - public partial class SiteDetailsView : UserControl - { - public SiteDetailsView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml deleted file mode 100644 index 437003a8a..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs deleted file mode 100644 index e6a4a6fe6..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/Views/SitesView.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Navigation; -using System.Windows.Shapes; - -namespace Tango.MachineStudio.Sites.Views -{ - /// - /// Interaction logic for SitesView.xaml - /// - public partial class SitesView : UserControl - { - public SitesView() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config deleted file mode 100644 index 7b82e5f7c..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/app.config +++ /dev/null @@ -1,85 +0,0 @@ - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config deleted file mode 100644 index e57143046..000000000 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Sites/packages.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file -- cgit v1.3.1