Example #1
0
		public static void AddJournal(JournalType journalType, string description = null)
		{
			var journalEvent = new Journal()
			{
				JournalType = journalType,
				Description = description
			};

			try
			{
				using (var context = DatabaseContext.Initialize())
				{
					context.Journal.Add(journalEvent);
					context.SaveChanges();
				}
			}

			catch (Exception e)
			{
				MessageBoxService.ShowException(e);
			}
		}
Example #2
0
		public static void AddJournalForUser(JournalType journalType, ModelBase modelBase = null, string Description = null)
		{
			var journalEvent = new Journal();
			if (modelBase != null)
			{
				if (modelBase is User)
					journalEvent.ClassType = ClassType.IsUser;
				if (modelBase is Consumer)
					journalEvent.ClassType = ClassType.IsConsumer;
				if (modelBase is Tariff)
					journalEvent.ClassType = ClassType.IsTariff;
				if (modelBase is Device)
					journalEvent.ClassType = ClassType.IsDevice;

				journalEvent.ObjectUID = modelBase.UID;
				journalEvent.ObjectName = modelBase.Name;
			}
			else
			{
				journalEvent.ClassType = ClassType.IsSystem;
			}
			journalEvent.UserName = CurrentUser.Name;
			journalEvent.UserUID = CurrentUser.UID;
			journalEvent.JournalType = journalType;
			journalEvent.Description = Description;

			try
			{
				using (var context = DatabaseContext.Initialize())
				{
					context.Journal.Add(journalEvent);
					context.SaveChanges();
				}
			}

			catch (Exception e)
			{
				MessageBoxService.ShowException(e);
			}
		}
Example #3
0
		public JournalEventViewModel(Journal journal)
		{
			ShowCommand = new RelayCommand(OnShow);
			Journal = journal;
		}