aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.ThreadExtensions/ViewModels/MainViewVM.cs55
1 files changed, 32 insertions, 23 deletions
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 });