diff options
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules')
4 files changed, 52 insertions, 31 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/UserModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/UserModel.cs new file mode 100644 index 000000000..5fbda6f12 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Models/UserModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.ThreadExtensions.Models +{ + public class UserModel + { + public String Guid { get; set; } + + public string Name { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj index e7724a473..f8d6419f6 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Tango.MachineStudio.ThreadExtensions.csproj @@ -116,6 +116,7 @@ <Compile Include="Models\RmlExtensionModel.cs" /> <Compile Include="Excel\TestResultsExcelModel.cs" /> <Compile Include="Excel\ThreadCharacteristicsExelModel.cs" /> + <Compile Include="Models\UserModel.cs" /> <Compile Include="ViewModelLocator.cs" /> <Compile Include="ViewModels\AddItemDialogVM.cs" /> <Compile Include="ViewModels\CalibrationDataVM.cs" /> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs index 47965deb4..853a415a3 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs @@ -45,10 +45,9 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private IAuthenticationProvider _authentication; private IActionLogManager _actionLogManager; - private ObservablesContext _rmlExtentions_context; private ObservablesContext _active_context; - private List<User> _allUsers; + private List<UserModel> _allUsers; #region properties //private ObservableCollection<RmlsExtension> _rmlsExtension; @@ -228,14 +227,14 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels set { _industrySector = value; RaisePropertyChangedAuto(); } } - private String _Filter; + private String _RMLFilter; /// <summary> /// Gets or sets the search filter. /// </summary> - public String Filter + public String RMLFilter { - get { return _Filter; } - set { _Filter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } + get { return _RMLFilter; } + set { _RMLFilter = value; RaisePropertyChangedAuto(); OnFilterChanged(); } } private async void OnFilterChanged() @@ -337,7 +336,8 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private async void BackToThreadExtensionViews(object obj) { - if (_notification.ShowQuestion("Are you sure you want to exit the RML without saving changes?")) + + //if ( _notification.ShowQuestion("Are you sure you want to exit the RML without saving changes?")) { View.NavigateTo(RMLExtensionNavigationView.RMLExtensionsView); await LoadRmlExtentions(); @@ -796,10 +796,10 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels public bool CanEdit { get { return _canEdit; } - set { _canEdit = value; RaisePropertyChangedAuto(); } + set { _canEdit = value; + RaisePropertyChangedAuto(); } } - public MainViewVM(INotificationProvider notificationProvider, IAuthenticationProvider authentication, IActionLogManager actionLogManager) { _notification = notificationProvider; @@ -853,7 +853,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels AddGlossLevelItemCommand = new RelayCommand(AddGlossLevelItem); EditGlossLevelItemCommand = new RelayCommand(EditGlossLevelItem); - + } @@ -861,6 +861,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels { var env = SettingsManager.Default.GetOrCreate<MachineStudioSettings>().DeploymentSlot; CanEdit = env == Web.DeploymentSlot.DEV || env == Web.DeploymentSlot.TEST || env == Web.DeploymentSlot.PROCESS; + } @@ -868,22 +869,31 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels private async Task LoadRmlExtentions() { - var filter = Filter.ToStringOrEmpty().ToLower(); + var filter = RMLFilter.ToStringOrEmpty().ToLower(); try { IsFree = false; - - using (_notification.PushTaskItem("Loading RmlExtentions...")) + using (ObservablesContext db = ObservablesContext.CreateDefault()) { - if (_rmlExtentions_context != null) _rmlExtentions_context.Dispose(); - _rmlExtentions_context = ObservablesContext.CreateDefault(); - - Brands = _rmlExtentions_context.YarnBrands.ToObservableCollection(); - _allUsers = await _rmlExtentions_context.Users.Include(x => x.Contact).ToListAsync(); - var q = (from c in _rmlExtentions_context.Rmls.Where(x => x.Name.ToLower().Contains(filter)) - join p in _rmlExtentions_context.RmlsExtensions on c.Guid equals p.RmlsGuid into ps + if (Brands == null) + Brands = db.YarnBrands.ToObservableCollection(); + if (_allUsers == null) + { + _allUsers = new List<UserModel>(); + var users = await db.Users.Include(x => x.Contact).ToListAsync(); + foreach (var user in users) + { + UserModel model = new UserModel(); + model.Guid = user.Guid; + model.Name = user.Contact.FullName; + _allUsers.Add(model); + } + } + + var q = (from c in db.Rmls.Where(x => x.Name.ToLower().Contains(filter)) + join p in db.RmlsExtensions on c.Guid equals p.RmlsGuid into ps from p in ps.DefaultIfEmpty() select new { RML = c, RMLExtesion = p }).Distinct().ToList().DistinctBy(x => x.RML.Guid) .Select(x => new RmlExtensionModel() @@ -894,7 +904,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels Manufacturer = x.RML.Manufacturer, Brand = x.RMLExtesion == null ? "" : (Brands.Where(y => y.Guid == x.RMLExtesion.YarnBrandGuid).Select(z => z.Name).FirstOrDefault()), LinearDensity = (int)x.RML.FiberSize, - CreatedBy = x.RMLExtesion == null ? "" : _allUsers.SingleOrDefault(y => y.Guid == x.RMLExtesion.UsersGuid).Contact.FullName, + CreatedBy = x.RMLExtesion == null ? "" : _allUsers.SingleOrDefault(y => y.Guid == x.RMLExtesion.UsersGuid).Name, Created = x.RMLExtesion == null ? DateTime.Now : x.RMLExtesion.Created, LastUpdated = x.RMLExtesion == null ? DateTime.Now : x.RMLExtesion.LastUpdated, Status = x.RMLExtesion == null ? RMLExtensionStatus.New : x.RMLExtesion.RMLStatus, @@ -902,7 +912,6 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels }).ToList(); RmlExtensions = q; - } } catch (Exception ex) @@ -1011,7 +1020,7 @@ namespace Tango.MachineStudio.ThreadExtensions.ViewModels .BuildAsync(); ActiveRML = new RmlBuilder(_active_context).Set(SelectedRMLExtension.RMLGuid).WithLiquidFactors().Build(); - + if (!String.IsNullOrEmpty(ActiveRML.Manufacturer) && false == Manufacturers.Any(x => x == ActiveRML.Manufacturer)) { _active_context.YarnManufacturers.Add(new YarnManufacturer() { Name = ActiveRML.Manufacturer }); diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml index 3ab0d2d24..255fd80d1 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/Views/RMLExtensionsView.xaml @@ -22,19 +22,19 @@ </UserControl.Resources> <Grid IsEnabled="{Binding IsFree}"> - <DockPanel Margin="100 100 100 50" MaxWidth="1200"> + <DockPanel Margin="100 100 100 50" MaxWidth="1500"> <Grid DockPanel.Dock="Top"> <Image Source="../Images/threads.png" Width="300" Margin="10" /> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Bottom" Margin="0 0 10 30"> <materialDesign:PackIcon Kind="Magnify" Width="26" Height="26"/> - <TextBox Width="300" materialDesign:HintAssist.Hint="Search by name" Text="{Binding Filter,UpdateSourceTrigger=PropertyChanged,Delay=500}"></TextBox> + <TextBox x:Name="textBoxSearch" Width="300" materialDesign:HintAssist.Hint="Search by name" Text="{Binding RMLFilter, Mode=OneWayToSource, UpdateSourceTrigger=PropertyChanged,Delay=500}"></TextBox> </StackPanel> </Grid> <Grid DockPanel.Dock="Bottom"> <StackPanel> <Grid> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> - <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlExtensionCommand}"> + <Button Margin="50 0 0 0" MinWidth="200" Height="60" Command="{Binding ManageRmlExtensionCommand}" FocusVisualStyle="{x:Null}"> <StackPanel Orientation="Horizontal"> <materialDesign:PackIcon Kind="Pencil" Width="24" Height="24" /> <TextBlock Margin="10 0 0 0" FontSize="18">EDIT</TextBlock> @@ -42,14 +42,10 @@ </Button> </StackPanel> </Grid> - - <StackPanel Orientation="Horizontal" Margin="0 40 0 0"> - - </StackPanel> </StackPanel> </Grid> <Grid> - <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding RmlExtensions}" SelectedItem="{Binding SelectedRMLExtension}"> + <DataGrid Margin="0 0 0 10" BorderBrush="Silver" IsReadOnly="True" BorderThickness="1" SelectionUnit="FullRow" RowHeight="60" Background="{StaticResource TransparentBackgroundBrush}" AlternatingRowBackground="{StaticResource Transparent200}" AutoGenerateColumns="False" CanUserAddRows="False" CanUserDeleteRows="False" ItemsSource="{Binding RmlExtensions}" SelectedItem="{Binding SelectedRMLExtension}" HorizontalScrollBarVisibility="Disabled"> <DataGrid.CellStyle> <Style TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}"> <Setter Property="BorderThickness" Value="0"/> |
