Esempio n. 1
0
		public JournalFilter GetModel()
		{
			var filter = new JournalFilter();
			foreach (var subsystem in RootObjects)
			{
				foreach (var objectType in subsystem.Children)
				{
					if (objectType.IsChecked)
					{
						filter.JournalObjectTypes.Add(objectType.JournalObjectType);
					}
					else
					{
						foreach (var objectViewModel in objectType.GetAllChildren())
						{
							if (objectViewModel.IsChecked && objectViewModel.UID != Guid.Empty)
							{
								filter.ObjectUIDs.Add(objectViewModel.UID);
							}
						}
					}
				}
			}

			return filter;
		}
Esempio n. 2
0
		public OperationResult<List<JournalItem>> GetFilteredJournalItems(Guid clientUID, JournalFilter filter)
		{
			using (var dbService = new RubezhDAL.DataClasses.DbService())
			{
				return dbService.JournalTranslator.GetFilteredJournalItems(filter);
			}
		}
Esempio n. 3
0
		void Initialize(JournalFilter filter)
		{
			AllObjects.ForEach(x => x.SetIsChecked(false));
			foreach (var journalObjectType in filter.JournalObjectTypes)
			{
				var objectTypeViewModel = AllObjects.FirstOrDefault(x => x.IsObjectGroup && x.JournalObjectType == journalObjectType);
				if (objectTypeViewModel != null)
				{
					objectTypeViewModel.IsChecked = true;
					objectTypeViewModel.IsRealChecked = true;
				}
			}
			foreach (var uid in filter.ObjectUIDs)
			{
				if (uid != Guid.Empty)
				{
					var objectUIDViewModel = AllObjects.FirstOrDefault(x => x.UID == uid);
					if (objectUIDViewModel != null)
					{
						objectUIDViewModel.IsChecked = true;
						objectUIDViewModel.IsRealChecked = true;
						objectUIDViewModel.ExpandToThis();
					}
				}
			}
		}
Esempio n. 4
0
		public void Initialize(JournalFilter filter)
		{
			AllFilters.ForEach(x => x.IsChecked = false);

			foreach (var journalObjectType in filter.JournalObjectTypes)
			{
				var filterNameViewModel = AllFilters.FirstOrDefault(x => x.FilterObjectType == FilterObjectType.ObjectType && x.JournalObjectType == journalObjectType);
				if (filterNameViewModel != null)
				{
					filterNameViewModel.IsChecked = true;
				}
			}
			foreach (var uid in filter.ObjectUIDs)
			{
				if (uid != Guid.Empty)
				{
					var filterNameViewModel = AllFilters.FirstOrDefault(x => x.UID == uid);
					if (filterNameViewModel != null)
					{
						filterNameViewModel.IsChecked = true;
						filterNameViewModel.ExpandToThis();
					}
				}
			}
		}
Esempio n. 5
0
        public FilterViewModel(JournalFilter filter)
		{
			Filter = filter;
            Names= new ObservableCollection<NameViewModel>();
            Objects= new ObservableCollection<ObjectViewModel>();
            SetFilterMenu();      
		}
Esempio n. 6
0
		public void Initialize(JournalFilter filter)
		{
			AllFilters.ForEach(x => x.IsChecked = false);
			foreach (var item in RootFilters)
			{
				item.IsChecked = false;
			}
			foreach (var eventName in filter.JournalEventNameTypes)
			{
				var filterNameViewModel = AllFilters.FirstOrDefault(x => x.JournalEventNameType == eventName);
				if (filterNameViewModel != null)
				{
					filterNameViewModel.SetIsChecked(true);
				}
			}
			foreach (var eventName in filter.JournalEventDescriptionTypes)
			{
				var filterNameViewModel = AllFilters.FirstOrDefault(x => x.JournalEventDescriptionType == eventName);
				if (filterNameViewModel != null)
				{
					filterNameViewModel.SetIsChecked(true);
					filterNameViewModel.Parent.IsExpanded = true;
				}
			}
			foreach (var journalSubsystemTypes in filter.JournalSubsystemTypes)
			{
				var filterNameViewModel = RootFilters.FirstOrDefault(x => x.JournalSubsystemType == journalSubsystemTypes);
				if (filterNameViewModel != null)
				{
					filterNameViewModel.IsChecked = true;

				}
			}
		}
Esempio n. 7
0
        public void Update(JournalFilter filter)
		{
			Filter = filter;
            OnPropertyChanged(() => Filter);
            Names.Clear();
            Objects.Clear();
            SetFilterMenu();
		}
Esempio n. 8
0
		public void Sort(List<Guid> objectUIDs)
		{
			Filter = new JournalFilter();
			Filter.PageSize = ClientSettings.ArchiveDefaultState.PageSize;
			Filter.StartDate = DateTime.Now.AddDays(-7);
			ClientSettings.ArchiveDefaultState.ArchiveDefaultStateType = ArchiveDefaultStateType.LastDays;
			ClientSettings.ArchiveDefaultState.Count = 7;

			Filter.ObjectUIDs.AddRange(objectUIDs);
			Update();
		}
Esempio n. 9
0
		public OperationResult<bool> BeginGetJournal(JournalFilter filter, Guid clientUid, Guid journalClientUid)
		{
			ServerTaskRunner.Add(null, "Чтение журнала событий", () =>
			{
				using (var dbService = new RubezhDAL.DataClasses.DbService())
				{
					var result = dbService.JournalTranslator.GetFilteredJournalItems(filter);
					RubezhService.NotifyOperationResult_GetJournal(result, clientUid, journalClientUid);
				}
			});
			return new OperationResult<bool>(true);
		}
Esempio n. 10
0
		public JournalViewModel(JournalFilter journalFilter = null)
		{
			_uid = Guid.NewGuid();
			_unreadCount = 0;
			Filter = journalFilter;
			if (Filter == null)
			{
				Filter = new JournalFilter();
				IsShowButtons = true;
			}
			JournalItems = new ObservableCollection<JournalItemViewModel>();
			ShowFilterCommand = new RelayCommand(OnShowFilter);
			IsVisibleBottomPanel = true;
		}
Esempio n. 11
0
		public ArchiveFilterViewModel(JournalFilter filter, bool isShowDateTime)
		{
			Title = "Настройки фильтра";
			ClearCommand = new RelayCommand(OnClear);
			SaveCommand = new RelayCommand(OnSave);
			CancelCommand = new RelayCommand(OnCancel);

			if (filter == null)
				filter = new JournalFilter();
			IsShowDateTime = isShowDateTime;
			if(IsShowDateTime)
				ArchiveDateTimeViewModel = new ArchiveDateTimeViewModel();
			FilterNamesViewModel = new FilterNamesViewModel(filter);
			FilterObjectsViewModel = new FilterObjectsViewModel(filter);
			
		}
Esempio n. 12
0
		public FilterDetailsViewModel(JournalFilter filter = null)
		{
			if (filter == null)
			{
				Title = "Добавить фильтр";
				Filter = new JournalFilter();
				Name = "Новый фильтр";
			}
			else
			{
				Title = "Свойства фильтра";
				Filter = filter;
			}
			NamesViewModel = new NamesViewModel(Filter);
			ObjectsViewModel = new ObjectsViewModel(Filter);
			CopyProperties();
		}
Esempio n. 13
0
		public JournalFilter GetModel()
		{
			var filter = new JournalFilter();
			foreach (var rootFilter in RootFilters)
			{
				if (rootFilter.IsChecked)
				{
					filter.JournalSubsystemTypes.Add(rootFilter.JournalSubsystemType);
				}
				foreach (var eventViewModel in rootFilter.Children)
				{
					if (eventViewModel.IsChecked)
						filter.JournalEventNameTypes.Add(eventViewModel.JournalEventNameType);
					var descriptions = eventViewModel.Children.Where(x => x.IsChecked).Select(x => x.JournalEventDescriptionType).ToList();
					filter.JournalEventDescriptionTypes.AddRange(descriptions);
				}
			}
			if (!RootFilters.SelectMany(x => x.GetAllChildren()).Any(x => !x.IsChecked))
				filter.JournalEventNameTypes.Add(JournalEventNameType.NULL);
			return filter;
		}
Esempio n. 14
0
		public JournalFilter GetModel()
		{
			var filter = new JournalFilter();
			foreach (var filterObject in RootFilters.SelectMany(x => x.GetAllChildren()).Where(x => x.IsChecked))
			{
				switch (filterObject.FilterObjectType)
				{
					case FilterObjectType.ObjectType:
						filter.JournalObjectTypes.Add(filterObject.JournalObjectType);
						break;
					case FilterObjectType.Object:
					case FilterObjectType.Camera:
					case FilterObjectType.HR:
						filter.ObjectUIDs.Add(filterObject.UID);
						break;
					case FilterObjectType.Subsystem:	
					default:
						break;
				}
			}
			return filter;
		}
Esempio n. 15
0
		public OperationResult<bool> BeginGetArchivePage(JournalFilter filter, int page, string userName = null)
		{
			return SafeOperationCall(() => 
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.BeginGetArchivePage(filter, page, RubezhServiceFactory.UID, userName);
			}, "BeginGetArchivePage");
		}
Esempio n. 16
0
		public FilterObjectsViewModel(JournalFilter filter)
		{
			BuildTree();
			Initialize(filter);
		}
Esempio n. 17
0
		void Initialize(JournalFilter filter)
		{
			AllNames.ForEach(x => x.IsChecked = false);
			foreach (var journalEventNameType in filter.JournalEventNameTypes)
			{
				var nameViewModel = AllNames.FirstOrDefault(x => x.JournalEventNameType == journalEventNameType);
				if (nameViewModel != null)
				{
					nameViewModel.SetIsChecked(true);
					nameViewModel.ExpandToThis();
				}
			}
			foreach (var description in filter.JournalEventDescriptionTypes)
			{
				var nameViewModel = AllNames.FirstOrDefault(x => x.JournalEventDescriptionType == description);
				if (nameViewModel != null)
				{
					nameViewModel.SetIsChecked(true);
					nameViewModel.ExpandToThis();
				}
			}
			foreach (var journalSubsystemTypes in filter.JournalSubsystemTypes)
			{
				var subsystemViewModel = RootNames.FirstOrDefault(x => x.JournalSubsystemType == journalSubsystemTypes);
				if (subsystemViewModel != null)
				{
					subsystemViewModel.IsChecked = true;

				}
			}
		}
Esempio n. 18
0
		public FilterViewModel(JournalFilter filter)
		{
			Filter = filter;
		}
Esempio n. 19
0
		public OperationResult<bool> BeginGetArchivePage(JournalFilter filter, int page, Guid clientUid, string userName)
		{
			ServerTaskRunner.Add(null, "Чтение архива", () =>
			{
				using (var dbService = new RubezhDAL.DataClasses.DbService())
				{
					var result = dbService.JournalTranslator.GetArchivePage(filter, page);
					RubezhService.NotifyOperationResult_GetArchivePage(result, clientUid, userName);
				}
			});
			return new OperationResult<bool>(true);
		}
Esempio n. 20
0
		public OperationResult<int> GetArchiveCount(Guid clientUID, JournalFilter filter)
		{
			using (var dbService = new RubezhDAL.DataClasses.DbService())
			{
				return dbService.JournalTranslator.GetArchiveCount(filter);
			}
		}
Esempio n. 21
0
		public void Update(JournalFilter filter)
		{
			Filter = filter;
			OnPropertyChanged(() => Name);
		}
Esempio n. 22
0
		void Initialize(JournalFilter filter)
		{
			FilterNamesViewModel.Initialize(filter);
			FilterObjectsViewModel.Initialize(filter);
		}
Esempio n. 23
0
		public IEnumerable<ILayoutPartPresenter> GetLayoutParts()
		{
			yield return new LayoutPartPresenter(LayoutPartIdentities.Journal, "Журнал событий", "BBook.png", (p) =>
			{
				var layoutPartJournalProperties = p as LayoutPartJournalProperties;
				var filter = ClientManager.SystemConfiguration.JournalFilters.FirstOrDefault(x => x.UID == layoutPartJournalProperties.FilterUID);
				if (filter == null)
					filter = new JournalFilter();

				var journalViewModel = new JournalViewModel(filter);
				journalViewModel.IsVisibleBottomPanel = layoutPartJournalProperties.IsVisibleBottomPanel;
				journalViewModel.Initialize();
				journalViewModel.SetJournalItems();
				
				return journalViewModel;
			});
			yield return new LayoutPartPresenter(LayoutPartIdentities.Archive, "Архив", "BArchive.png", (p) => _archiveViewModel);
		}
Esempio n. 24
0
		public void Update()
		{
			try
			{
				if (Filter == null)
					Filter = new JournalFilter();

				Filter.PageSize = ClientSettings.ArchiveDefaultState.PageSize;
				Filter.UseDeviceDateTime = ClientSettings.ArchiveDefaultState.UseDeviceDateTime;
				Filter.IsSortAsc = ClientSettings.ArchiveDefaultState.IsSortAsc;
				Filter.StartDate = ArchiveFirstDate;
				Filter.EndDate = DateTime.Now;

				switch (ClientSettings.ArchiveDefaultState.ArchiveDefaultStateType)
				{
					case ArchiveDefaultStateType.LastHours:
						Filter.StartDate = Filter.EndDate.AddHours(-ClientSettings.ArchiveDefaultState.Count);
						break;

					case ArchiveDefaultStateType.LastDays:
						Filter.StartDate = Filter.EndDate.AddDays(-ClientSettings.ArchiveDefaultState.Count);
						break;

					case ArchiveDefaultStateType.FromDate:
						Filter.StartDate = ClientSettings.ArchiveDefaultState.StartDate;
						break;

					case ArchiveDefaultStateType.RangeDate:
						Filter.StartDate = ClientSettings.ArchiveDefaultState.StartDate;
						Filter.EndDate = ClientSettings.ArchiveDefaultState.EndDate;
						break;
				}

				var countResult = ClientManager.RubezhService.GetArchiveCount(Filter);
				if (!countResult.HasError)
				{
					TotalPageNumber = countResult.Result / Filter.PageSize + 1;
					CurrentPageNumber = 1;
				}
			}
			catch (ThreadAbortException) { }
			catch (Exception e)
			{
				Logger.Error(e, "ArchiveViewModel.OnUpdate");
			}
		}
Esempio n. 25
0
		public static IEnumerable<JournalItem> Get(JournalFilter filter)
		{
			var result = ClientManager.RubezhService.GetFilteredJournalItems(filter);
			return Common.ThrowErrorIfExists(result);
		}
Esempio n. 26
0
		protected override DataSet CreateDataSet(DataProvider dataProvider)
		{
			var filter = GetFilter<EventsReportFilter>();
			var dataSet = new EventsDataSet();
			var archiveFilter = new JournalFilter();
			archiveFilter.StartDate = filter.DateTimeFrom;
			archiveFilter.EndDate = filter.DateTimeTo;
			if (filter.JournalEventNameTypes != null && filter.JournalEventNameTypes.Count > 0)
			{
				archiveFilter.JournalEventNameTypes = filter.JournalEventNameTypes;
			}
			if (filter.JournalObjectTypes != null && filter.JournalObjectTypes.Count > 0)
			{
				archiveFilter.JournalObjectTypes = filter.JournalObjectTypes;
			}
			if (filter.JournalEventSubsystemTypes != null && filter.JournalEventSubsystemTypes.Count > 0)
			{
				archiveFilter.JournalSubsystemTypes = filter.JournalEventSubsystemTypes;
			}
			if (filter.JournalObjectTypes != null && filter.JournalObjectTypes.Count > 0)
			{
				archiveFilter.JournalObjectTypes = filter.JournalObjectTypes;
			}
			if (filter.ObjectUIDs != null && filter.ObjectUIDs.Count > 0)
			{
				archiveFilter.ObjectUIDs = filter.ObjectUIDs;
			}
			if (filter.Employees != null && filter.Employees.Count > 0)
			{
				archiveFilter.EmployeeUIDs = filter.Employees;
			}
			if (!filter.Users.IsEmpty())
				archiveFilter.Users = filter.Users;
			var journalItemsResult = dataProvider.DbService.JournalTranslator.GetFilteredArchiveItems(archiveFilter);
			if (journalItemsResult.Result != null)
			{
				foreach (var journalItem in journalItemsResult.Result)
				{
					var dataRow = dataSet.Data.NewDataRow();
					dataRow.SystemDateTime = journalItem.SystemDateTime;
					if (journalItem.DeviceDateTime.HasValue)
					{
						dataRow.DeviceDateTime = journalItem.DeviceDateTime.Value;
					}

					if (journalItem.JournalEventNameType != JournalEventNameType.NULL)
					{
						dataRow.Name = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventNameType);
					}

					if (journalItem.JournalEventDescriptionType != JournalEventDescriptionType.NULL)
					{
						dataRow.Description = EventDescriptionAttributeHelper.ToName(journalItem.JournalEventDescriptionType);
						if (!string.IsNullOrEmpty(journalItem.DescriptionText))
							dataRow.Description += " " + journalItem.DescriptionText;
					}
					else
					{
						dataRow.Description = journalItem.DescriptionText;
					}

					switch (journalItem.JournalObjectType)
					{
						case JournalObjectType.GKDevice:
							var device = GKManager.Devices.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (device != null)
							{
								dataRow.Object = device.PresentationName;
							}
							break;

						case JournalObjectType.GKZone:
							var zone = GKManager.Zones.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (zone != null)
							{
								dataRow.Object = zone.PresentationName;
							}
							break;

						case JournalObjectType.GKSKDZone:
							var SKDzone = GKManager.Zones.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (SKDzone != null)
							{
								dataRow.Object = SKDzone.PresentationName;
							}
							break;

						case JournalObjectType.GKDirection:
							var direction = GKManager.Directions.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (direction != null)
							{
								dataRow.Object = direction.PresentationName;
							}
							break;

						case JournalObjectType.GKPumpStation:
							var pumpStation = GKManager.PumpStations.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (pumpStation != null)
							{
								var objectName = pumpStation.PresentationName;
							}
							break;

						case JournalObjectType.GKMPT:
							var mpt = GKManager.MPTs.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (mpt != null)
							{
								dataRow.Object = mpt.PresentationName;
							}
							break;

						case JournalObjectType.GKDelay:
							var delay = GKManager.Delays.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (delay != null)
							{
								dataRow.Object = delay.PresentationName;
							}
							break;

						case JournalObjectType.GKGuardZone:
							var guardZone = GKManager.GuardZones.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (guardZone != null)
							{
								dataRow.Object = guardZone.PresentationName;
							}
							break;

						case JournalObjectType.GKDoor:
							var gkDoor = GKManager.Doors.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							if (gkDoor != null)
							{
								dataRow.Object = gkDoor.PresentationName;
							}
							break;

						case JournalObjectType.Camera:
							//var camera = RubezhManager.SystemConfiguration.Cameras.FirstOrDefault(x => x.UID == journalItem.ObjectUID);
							//if (camera != null)
							//{
							//	dataRow.Object = camera.Name;
							//}
							break;

						case JournalObjectType.None:
						case JournalObjectType.GKUser:
							dataRow.Object = journalItem.ObjectName != null ? journalItem.ObjectName : "";
							break;
					}

					if (dataRow.IsObjectNull())
					{
						dataRow.Object = journalItem.ObjectName;
					}

					if (dataRow.IsObjectNull())
						dataRow.Object = "<Нет в конфигурации>";

					dataRow.System = journalItem.JournalSubsystemType.ToDescription();
					dataRow.User = journalItem.UserName;

					dataSet.Data.Rows.Add(dataRow);
				}
			}
			else
			{
				if (journalItemsResult.HasError)
					ThrowException(journalItemsResult.Error);
				else
					ThrowException("Exception was trown in EventsReport.CreateDataSet()");
			}
			return dataSet;
		}
Esempio n. 27
0
		string BuildQuery(JournalFilter archiveFilter)
		{
			string dateTimeTypeString;
			if (archiveFilter.UseDeviceDateTime)
				dateTimeTypeString = "DeviceDate";
			else
				dateTimeTypeString = "SystemDate";

			var query =
				"SELECT * FROM Journal WHERE " +
				"\n " + dateTimeTypeString + " > '" + archiveFilter.StartDate.ToString("yyyy-MM-dd HH:mm:ss") + "'" +
				"\n AND " + dateTimeTypeString + " < '" + archiveFilter.EndDate.ToString("yyyy-MM-dd HH:mm:ss") + "'";

			if (archiveFilter.JournalEventNameTypes.Count > 0)
			{
				query += "\n and (";
				int index = 0;
				foreach (var journalEventNameType in archiveFilter.JournalEventNameTypes)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					query += "Name = '" + (int)journalEventNameType + "'";
				}
				query += ")";
			}

			if (archiveFilter.JournalSubsystemTypes.Count > 0)
			{
				query += "\n AND (";
				int index = 0;
				foreach (var journalSubsystemType in archiveFilter.JournalSubsystemTypes)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					query += "Subsystem = '" + (int)journalSubsystemType + "'";
				}
				query += ")";
			}

			if (archiveFilter.JournalObjectTypes.Count > 0)
			{
				query += "\n AND (";
				int index = 0;
				foreach (var journalObjectType in archiveFilter.JournalObjectTypes)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					query += "ObjectType = '" + (int)journalObjectType + "'";
				}
				query += ")";
			}

			if (archiveFilter.ObjectUIDs.Count > 0)
			{
				query += "\n AND (";
				int index = 0;
				foreach (var objectUID in archiveFilter.ObjectUIDs)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					query += "ObjectUID = '" + objectUID + "'";
				}
				query += ")";
			}

			if (archiveFilter.EmployeeUIDs.Count > 0)
			{
				query += "\n AND (";
				int index = 0;
				foreach (var employeeUID in archiveFilter.EmployeeUIDs)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					//query += "EmployeeUID = '" + employeeUID + "'";
					query += "ObjectUID = '" + employeeUID + "'";
				}
				query += ")";
			}

			if (archiveFilter.Users.Count > 0)
			{
				query += "\n AND (";
				int index = 0;
				foreach (var user in archiveFilter.Users)
				{
					if (index > 0)
						query += "\n OR ";
					index++;
					query += "UserName = '******'";
				}
				query += ")";
			}
			return query;
		}
Esempio n. 28
0
		public OperationResult<int> GetArchiveCount(JournalFilter filter)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.GetArchiveCount(RubezhServiceFactory.UID, filter);
			}, "GetArchiveCount");
		}
Esempio n. 29
0
		public OperationResult<List<JournalItem>> GetFilteredJournalItems(JournalFilter filter)
		{
			return SafeOperationCall(() =>
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.GetFilteredJournalItems(RubezhServiceFactory.UID, filter);
			}, "GetFilteredJournalItems");
		}
Esempio n. 30
0
		public OperationResult<bool> BeginGetJournal(JournalFilter filter, Guid clientUid)
		{
			return SafeOperationCall(() => 
			{
				var rubezhService = RubezhServiceFactory.Create(TimeSpan.FromMinutes(10));
				using (rubezhService as IDisposable)
					return rubezhService.BeginGetJournal(filter, RubezhServiceFactory.UID, clientUid);
			}, "BeginGetJournal");
		}