Пример #1
0
        public FilteredJournalViewModel(JournalFilter journalFilter)
        {
            ServiceFactory.Events.GetEvent<NewJournalRecordEvent>().Unsubscribe(OnNewJournalRecord);
            ServiceFactory.Events.GetEvent<NewJournalRecordEvent>().Subscribe(OnNewJournalRecord);

            if (journalFilter != null)
            {
                JournalFilter = journalFilter;
                Initialize();
            }
        }
Пример #2
0
        public FilterDetailsViewModel(JournalFilter journalFilter)
        {
            Title = "Редактировать фильтр";

            JournalFilter = new JournalFilter()
            {
                Name = journalFilter.Name,
                LastRecordsCount = journalFilter.LastRecordsCount,
                LastDaysCount = journalFilter.LastDaysCount,
                IsLastDaysCountActive = journalFilter.IsLastDaysCountActive
            };

            Initialize();

            StateTypes.Where(
                eventViewModel => journalFilter.StateTypes.Any(
                    x => x == eventViewModel.StateType)).All(x => x.IsChecked = true);

            Categories.Where(
                categoryViewModel => journalFilter.Categories.Any(
                    x => x == categoryViewModel.DeviceCategoryType)).All(x => x.IsChecked = true);
        }
Пример #3
0
		public OperationResult<List<JournalRecord>> GetFilteredJournal(JournalFilter journalFilter)
		{
			return FiresecDB.DatabaseHelper.GetFilteredJournal(journalFilter);
		}
Пример #4
0
		public static List<FS2JournalItem> GetFilteredJournal(JournalFilter journalFilter)
		{
			var result = new List<FS2JournalItem>();
			try
			{
				bool hasWhere = false;
				string query = "";
				if (journalFilter.IsLastDaysCountActive)
				{
					query = "SELECT * FROM Journal WHERE " +
					"\n SystemTime > '" + DateTime.Now.AddDays(-journalFilter.LastDaysCount).ToString("yyyy-MM-dd HH:mm:ss") + "'";
					hasWhere = true;
				}
				else
				{
					query = "SELECT TOP (" + journalFilter.LastRecordsCount + ") * FROM Journal ";
				}

				if (journalFilter.StateTypes.Count > 0)
				{
					if (hasWhere == false)
					{
						query += " WHERE ";
						hasWhere = true;
					}
					else
					{
						query += "\n AND ";
					}
					query += " (";
					for (int i = 0; i < journalFilter.StateTypes.Count; i++)
					{
						if (i > 0)
							query += "\n OR ";
						var stateType = journalFilter.StateTypes[i];
						query += " StateType = " + ((int)stateType).ToString();
					}
					query += ")";
				}

				if (journalFilter.Categories.Count > 0)
				{
					if (hasWhere == false)
					{
						query += " WHERE ";
						hasWhere = true;
					}
					else
					{
						query += "\n AND ";
					}
					query += " (";
					for (int i = 0; i < journalFilter.Categories.Count; i++)
					{
						if (i > 0)
							query += "\n OR ";
						var category = journalFilter.Categories[i];
						query += " DeviceCategory = " + ((int)category).ToString();
					}
					query += ")";
				}

				query += "\n ORDER BY SystemTime DESC";

				using (var sqlCeConnection = new SqlCeConnection(ConnectionString))
				{
					sqlCeConnection.ConnectionString = ConnectionString;
					var sqlCeCommand = new SqlCeCommand(query, sqlCeConnection);
					sqlCeConnection.Open();
					var reader = sqlCeCommand.ExecuteReader();
					while (reader.Read())
					{
						var journalItem = ReadOneJournalItem(reader);
						result.Add(journalItem);
					}
					sqlCeConnection.Close();
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "Исключение при вызове FiresecService.GetFilteredJournal");
				throw new FS2Exception(e.Message);
			}
			return result;
		}
Пример #5
0
 public FilterDetailsViewModel()
 {
     Title = "Добавить фильтр";
     JournalFilter = new JournalFilter();
     Initialize();
 }
		public OperationResult<List<FS2JournalItem>> GetFilteredJournal(JournalFilter journalFilter)
		{
			return SafeOperationCall(() => { return FS2Contract.GetFilteredJournal(journalFilter); }, "GetFilteredJournal");
		}
 public OperationResult<List<JournalRecord>> GetFilteredJournal(JournalFilter journalFilter)
 {
     return SafeOperationCall(() => { return FiresecService.GetFilteredJournal(journalFilter); });
 }
Пример #8
0
		public static List<FS2JournalItem> GetFilteredJournal(JournalFilter journalFilter)
		{
			return ServerFS2Database.GetFilteredJournal(journalFilter);
		}
Пример #9
0
 public FilterViewModel(JournalFilter journalFilter)
 {
     JournalFilter = journalFilter;
 }