aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs
diff options
context:
space:
mode:
authorRoy <roy.mail.net@gmail.com>2017-12-26 23:55:41 +0200
committerRoy <roy.mail.net@gmail.com>2017-12-26 23:55:41 +0200
commit9d12fd0ba222619dd5b42816ed004c7b762809dd (patch)
treebf8c2dd95f70484f9f8474ab44d4918ef2b30f44 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs
parent03caa4c6a2807e461edd98fc377498674e83c15c (diff)
downloadTango-9d12fd0ba222619dd5b42816ed004c7b762809dd.tar.gz
Tango-9d12fd0ba222619dd5b42816ed004c7b762809dd.zip
Added CCT & CAT to DB Module !
Implemented "deep filtering" on db module search.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs50
1 files changed, 38 insertions, 12 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs
index e472e312a..bc8d54ce9 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs
@@ -20,7 +20,7 @@ namespace Tango.MachineStudio.DB.ViewModels
{
public abstract class DbTableViewModel<T> : ViewModel, IShutdownRequestBlocker where T : class, IObservableEntity
{
- private INotificationProvider _notification;
+ protected INotificationProvider _notification;
/// <summary>
/// Initializes a new instance of the <see cref="DbTableViewModel"/> class.
@@ -156,11 +156,11 @@ namespace Tango.MachineStudio.DB.ViewModels
{
using (_notification.PushTaskItem("Saving changes to database..."))
{
- var dependenctEntities = SelectedEntity.GetDependentEntitiesNameAndGuid();
+ var dependenctEntities = SelectedEntity.GetDependentEntitiesNameAndGuid();
if (dependenctEntities.Count > 0)
{
- _notification.ShowError("The selected entity is being used by " + dependenctEntities.Count + " other entities." + Environment.NewLine + "Please delete any dependencies and try again." + Environment.NewLine + Environment.NewLine + String.Join(Environment.NewLine,dependenctEntities.Select(x => x.Key + ", ID: " + x.Value)));
+ _notification.ShowError("The selected entity is being used by " + dependenctEntities.Count + " other entities." + Environment.NewLine + "Please delete any dependencies and try again." + Environment.NewLine + Environment.NewLine + String.Join(Environment.NewLine, dependenctEntities.Select(x => x.Key + ", ID: " + x.Value)));
return;
}
@@ -293,18 +293,44 @@ namespace Tango.MachineStudio.DB.ViewModels
collectionView.Filter = (entity) =>
{
- return
- entity.
- GetType().
- GetProperties(BindingFlags.Public | BindingFlags.Instance).
- Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated").
- Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))).
- Select(prop => prop.GetValue(entity).ToString()).
- ToList().
- Any(x => x.ToLower().Contains(filter.ToLower()));
+ return FilterEntity((T)entity, filter);
};
}
+ private bool FilterEntity(T entity, String filter)
+ {
+ foreach (var prop in entity.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsClass && x.PropertyType != typeof(String) && x.PropertyType != typeof(byte[]) && !x.PropertyType.IsGenericType))
+ {
+ object obj = prop.GetValue(entity);
+
+ if (obj != null)
+ {
+ foreach (var innerProp in obj.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated").Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))))
+ {
+ object value = innerProp.GetValue(obj);
+
+ if (value != null)
+ {
+ if (value.ToString().ToLower().Contains(filter.ToLower()))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ }
+
+ return
+ entity.
+ GetType().
+ GetProperties(BindingFlags.Public | BindingFlags.Instance).
+ Where(x => x.Name != "Deleted" && x.Name != "ID" && x.Name != "LastUpdated").
+ Where(x => !x.PropertyType.IsGenericType && (x.PropertyType.IsClass || x.PropertyType == typeof(String))).
+ Select(prop => prop.GetValue(entity).ToString()).
+ ToList().
+ Any(x => x.ToLower().Contains(filter.ToLower()));
+ }
+
protected virtual void InitializeEntity(T entity)
{