Beispiel #1
0
		public ArchiveViewModel()
		{
			ShowFilterCommand = new RelayCommand(OnShowFilter);
			ShowSettingsCommand = new RelayCommand(OnShowSettings);
			ServiceFactory.Events.GetEvent<XJournalSettingsUpdatedEvent>().Unsubscribe(OnSettingsChanged);
			ServiceFactory.Events.GetEvent<XJournalSettingsUpdatedEvent>().Subscribe(OnSettingsChanged);
			ArchiveDefaultState = ClientSettings.ArchiveDefaultState;
			if (ArchiveDefaultState == null)
				ArchiveDefaultState = new ArchiveDefaultState();
		}
Beispiel #2
0
        public ArchiveViewModel()
        {
            ShowFilterCommand = new RelayCommand(OnShowFilter);
            ShowSettingsCommand = new RelayCommand(OnShowSettings);
            //ServiceFactory.Events.GetEvent<GetFilteredArchiveCompletedEvent>().Subscribe(OnGetFilteredArchiveCompleted);

            _archiveDefaultState = ClientSettings.ArchiveDefaultState;
            if (_archiveDefaultState == null)
                _archiveDefaultState = new ArchiveDefaultState();
        }
Beispiel #3
0
 public static void LoadArchiveDefaultState()
 {
     if (File.Exists(ArchiveDefaultStateFileName))
     {
         using (var fileStream = new FileStream(ArchiveDefaultStateFileName, FileMode.Open))
         {
             var dataContractSerializer = new DataContractSerializer(typeof(ArchiveDefaultState));
             ArchiveDefaultState = (ArchiveDefaultState)dataContractSerializer.ReadObject(fileStream);
         }
     }
     else
     {
         ArchiveDefaultState = new ArchiveDefaultState();
     }
 }
Beispiel #4
0
		public ArchiveViewModel()
		{
			ShowFilterCommand = new RelayCommand(OnShowFilter);
			ShowSettingsCommand = new RelayCommand(OnShowSettings);
			FirstPageCommand = new RelayCommand(OnFirstPage, CanFirstPage);
			PreviousPageCommand = new RelayCommand(OnPreviousPage, CanPreviousPage);
			NextPageCommand = new RelayCommand(OnNextPage, CanNextPage);
			LastPageCommand = new RelayCommand(OnLastPage, CanLastPage);
			Pages = new ObservableCollection<ArchivePageViewModel>();
			ServiceFactory.Events.GetEvent<GetFilteredArchiveCompletedEvent>().Subscribe(OnGetFilteredArchiveCompleted);
			//ServiceFactory.Events.GetEvent<GetFS2FilteredArchiveCompletedEvent>().Subscribe(OnGetFS2FilteredArchiveCompleted);

			ArchiveDefaultState = ClientSettings.ArchiveDefaultState;
			if (ArchiveDefaultState == null)
				ArchiveDefaultState = new ArchiveDefaultState();
		}
        public ArchiveSettingsViewModel(ArchiveDefaultState archiveDefaultState)
        {
            Title = "Настройки";

            ArchiveDefaultStates = new ObservableCollection<ArchiveDefaultStateViewModel>();
            foreach (ArchiveDefaultStateType item in Enum.GetValues(typeof(ArchiveDefaultStateType)))
            {
                ArchiveDefaultStates.Add(new ArchiveDefaultStateViewModel(item));
            }

            HoursCount = 1;
            DaysCount = 1;
            StartDate = ArchiveFirstDate;
            EndDate = NowDate;

            ServiceFactory.Events.GetEvent<ArchiveDefaultStateCheckedEvent>().Subscribe(OnArchiveDefaultStateCheckedEvent);

            ArchiveDefaultStates.First(x => x.ArchiveDefaultStateType == archiveDefaultState.ArchiveDefaultStateType).IsActive = true;
            switch (archiveDefaultState.ArchiveDefaultStateType)
            {
                case ArchiveDefaultStateType.LastHours:
                    if (archiveDefaultState.Count.HasValue)
                        HoursCount = archiveDefaultState.Count.Value;
                    break;

                case ArchiveDefaultStateType.LastDays:
                    if (archiveDefaultState.Count.HasValue)
                        DaysCount = archiveDefaultState.Count.Value;
                    break;

                case ArchiveDefaultStateType.FromDate:
                    if (archiveDefaultState.StartDate.HasValue)
                        StartDate = archiveDefaultState.StartDate.Value;
                    break;

                case ArchiveDefaultStateType.RangeDate:
                    if (archiveDefaultState.StartDate.HasValue)
                        StartDate = archiveDefaultState.StartDate.Value;
                    if (archiveDefaultState.EndDate.HasValue)
                        EndDate = archiveDefaultState.EndDate.Value;
                    break;

                case ArchiveDefaultStateType.All:
                default:
                    break;
            }
        }
Beispiel #6
0
		static void LoadArchiveDefaultState()
		{
			if (File.Exists(ArchiveDefaultStateFileName))
			{
				using (var fileStream = new FileStream(ArchiveDefaultStateFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					var dataContractSerializer = new DataContractSerializer(typeof(ArchiveDefaultState));
					ArchiveDefaultState = (ArchiveDefaultState)dataContractSerializer.ReadObject(fileStream);
					if (ArchiveDefaultState.AdditionalColumns == null)
						ArchiveDefaultState.AdditionalColumns = new List<JournalColumnType>();
				}
			}
			else
			{
				ArchiveDefaultState = new ArchiveDefaultState();
			}
		}
Beispiel #7
0
		ArchiveFilter GerFilterFromDefaultState(ArchiveDefaultState archiveDefaultState)
		{
			var archiveFilter = new ArchiveFilter()
			{
				StartDate = ArchiveFirstDate,
				EndDate = DateTime.Now
			};

			switch (archiveDefaultState.ArchiveDefaultStateType)
			{
				case ArchiveDefaultStateType.LastHours:
					if (archiveDefaultState.Count.HasValue)
						archiveFilter.StartDate = archiveFilter.EndDate.AddHours(-archiveDefaultState.Count.Value);
					break;

				case ArchiveDefaultStateType.LastDays:
					if (archiveDefaultState.Count.HasValue)
						archiveFilter.StartDate = archiveFilter.EndDate.AddDays(-archiveDefaultState.Count.Value);
					break;

				case ArchiveDefaultStateType.FromDate:
					if (archiveDefaultState.StartDate.HasValue)
						archiveFilter.StartDate = archiveDefaultState.StartDate.Value;
					break;

				case ArchiveDefaultStateType.RangeDate:
					if (archiveDefaultState.StartDate.HasValue)
						archiveFilter.StartDate = archiveDefaultState.StartDate.Value;
					if (archiveDefaultState.EndDate.HasValue)
						archiveFilter.EndDate = archiveDefaultState.EndDate.Value;
					break;
			}

			return archiveFilter;
		}
Beispiel #8
0
		void OnShowSettings()
		{
			try
			{
				var archiveSettingsViewModel = new ArchiveSettingsViewModel(ArchiveDefaultState);
				if (DialogService.ShowModalWindow(archiveSettingsViewModel))
				{
					ArchiveFilter = null;
					ArchiveDefaultState = archiveSettingsViewModel.GetModel();
					ClientSettings.ArchiveDefaultState = ArchiveDefaultState;
					IsFilterOn = false;
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "ArchiveViewModel.ShowSettingsCommand");
				MessageBoxService.ShowException(e);
			}
		}
Beispiel #9
0
		static void LoadArchiveDefaultState()
		{
			if (File.Exists(ArchiveDefaultStateFileName))
			{
				using (var fileStream = new FileStream(ArchiveDefaultStateFileName, FileMode.Open, FileAccess.Read, FileShare.Read))
				{
					var xmlSerializer = new XmlSerializer(typeof(ArchiveDefaultState));
					ArchiveDefaultState = (ArchiveDefaultState)xmlSerializer.Deserialize(fileStream);
					if (ArchiveDefaultState.XAdditionalColumns == null)
						ArchiveDefaultState.XAdditionalColumns = new List<XJournalColumnType>();
					if (ArchiveDefaultState.AdditionalJournalColumnTypes == null)
						ArchiveDefaultState.AdditionalJournalColumnTypes = new List<JournalColumnType>();
				}
			}
			else
			{
				ArchiveDefaultState = new ArchiveDefaultState();
			}
		}
        public ArchiveDefaultState GetModel()
        {
            var archiveDefaultState = new ArchiveDefaultState();
            archiveDefaultState.ArchiveDefaultStateType = ArchiveDefaultStates.First(x => x.IsActive).ArchiveDefaultStateType;
            switch (archiveDefaultState.ArchiveDefaultStateType)
            {
                case ArchiveDefaultStateType.LastHours:
                    archiveDefaultState.Count = HoursCount;
                    break;

                case ArchiveDefaultStateType.LastDays:
                    archiveDefaultState.Count = DaysCount;
                    break;

                case ArchiveDefaultStateType.FromDate:
                    archiveDefaultState.StartDate = StartDate;
                    break;

                case ArchiveDefaultStateType.RangeDate:
                    archiveDefaultState.StartDate = StartDate;
                    archiveDefaultState.EndDate = EndDate;
                    break;

                case ArchiveDefaultStateType.All:
                default:
                    break;
            }

            return archiveDefaultState;
        }
Beispiel #11
0
		void OnShowSettings()
		{
			try
			{
				var archiveSettingsViewModel = new ArchiveSettingsViewModel(ArchiveDefaultState);
				if (DialogService.ShowModalWindow(archiveSettingsViewModel))
				{
					ArchiveDefaultState = archiveSettingsViewModel.ArchiveDefaultState;
					ClientSettings.ArchiveDefaultState = ArchiveDefaultState;
					ServiceFactory.Events.GetEvent<XJournalSettingsUpdatedEvent>().Publish(null);
					if (IsFilterOn == false)
						Update(true);
				}
			}
			catch (Exception e)
			{
				Logger.Error(e, "Исключение при вызове ArchiveViewModel.ShowSettingsCommand");
				MessageBoxService.ShowException(e);
			}
		}
Beispiel #12
0
 void OnShowSettings()
 {
     try
     {
         var archiveSettingsViewModel = new ArchiveSettingsViewModel(_archiveDefaultState);
         if (DialogService.ShowModalWindow(archiveSettingsViewModel))
         {
             _archiveDefaultState = archiveSettingsViewModel.GetModel();
             ClientSettings.ArchiveDefaultState = _archiveDefaultState;
             if (IsFilterOn == false)
                 Update(true);
         }
     }
     catch (Exception e)
     {
         Logger.Error(e, "Исключение при вызове ArchiveViewModel.ShowSettingsCommand");
         MessageBoxService.ShowException(e);
     }
 }