Exemple #1
0
        /// <summary>
        /// Finds a document type that can handle a file
        /// with the given file extension eg ".txt" or "txt"
        /// when the original file name was "Readme.txt".
        ///
        /// Always returns the 1st document type handler that matches the extension.
        /// </summary>
        /// <param name="fileExtension"></param>
        /// <param name="trimPeriod">Determines if an additional '.' character is removed
        /// from the given extension string or not.</param>
        /// <returns></returns>
        public IDocumentType FindDocumentTypeByExtension(string fileExtension,
                                                         bool trimPeriod = false)
        {
            if (string.IsNullOrEmpty(fileExtension))
            {
                return(null);
            }

            if (trimPeriod)
            {
                int idx;

                if ((idx = fileExtension.LastIndexOf(".", StringComparison.Ordinal)) >= 0)
                {
                    fileExtension = fileExtension.Substring(idx + 1);
                }
            }

            if (string.IsNullOrEmpty(fileExtension))
            {
                return(null);
            }

            var ret = _DocumentTypes.FirstOrDefault(d => d.DefaultFilter == fileExtension);

            return(ret);
        }
		public MPTsSelectationViewModel(List<GKMPT> mpts, bool canCreateNew = false)
		{
			Title = "Выбор МПТ";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			MPTs = mpts;
			CanCreateNew = canCreateNew;
			TargetMPTs = new SortableObservableCollection<GKMPT>();
			SourceMPTs = new SortableObservableCollection<GKMPT>();

			foreach (var mpt in GKManager.DeviceConfiguration.MPTs)
			{
				if (MPTs.Contains(mpt))
					TargetMPTs.Add(mpt);
				else
					SourceMPTs.Add(mpt);
			}
			TargetMPTs.Sort(x => x.No);
			SourceMPTs.Sort(x => x.No);

			SelectedTargetMPT = TargetMPTs.FirstOrDefault();
			SelectedSourceMPT = SourceMPTs.FirstOrDefault();
		}
		public ZonesSelectationViewModel(List<GKZone> zones, bool canCreateNew = false)
		{
			Title = "Выбор зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Zones = zones;
			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<GKZone>();
			SourceZones = new SortableObservableCollection<GKZone>();

			foreach (var zone in GKManager.DeviceConfiguration.SortedZones)
			{
				if (Zones.Contains(zone))
					TargetZones.Add(zone);
				else
					SourceZones.Add(zone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
Exemple #4
0
		public void Initialize()
		{
			IsNowPlaying = false;
			Sounds = new SortableObservableCollection<SoundViewModel>();
			var stateClasses = new List<Tuple<XStateClass, SoundType>>();

			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Fire1));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire2, SoundType.Fire2));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Attention, SoundType.Attention));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Fire1, SoundType.Alarm));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Failure, SoundType.Failure));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.Off, SoundType.Off));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOn, SoundType.TurningOn));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.TurningOff, SoundType.StopStart));
			stateClasses.Add(new Tuple<XStateClass, SoundType>(XStateClass.AutoOff, SoundType.AutoOff));

			foreach (var stateClass in stateClasses)
			{
				var newSound = new Sound() { StateClass = stateClass.Item1, Type = stateClass.Item2 };

				var sound = ClientManager.SystemConfiguration.Sounds.FirstOrDefault(x => x.Type == stateClass.Item2);
				if (sound == null)
					ClientManager.SystemConfiguration.Sounds.Add(newSound);
				else
					newSound = sound;

				Sounds.Add(new SoundViewModel(newSound));
			}

			Sounds.Sort(x => EnumHelper.GetEnumDescription(x.SoundType));
			SelectedSound = Sounds.FirstOrDefault();

			if (ClientManager.SystemConfiguration.Sounds.RemoveAll(x => !Sounds.Any(y => y.SoundType == x.Type)) > 0)
				ServiceFactory.SaveService.SoundsChanged = true;
		}
		public DirectionsSelectationViewModel(List<GKDirection> directions)
		{
			Title = "Выбор направлений";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Directions = directions;
			TargetDirections = new SortableObservableCollection<GKDirection>();
			SourceDirections = new SortableObservableCollection<GKDirection>();

			foreach (var direction in GKManager.Directions)
			{
				if (Directions.Contains(direction))
					TargetDirections.Add(direction);
				else
					SourceDirections.Add(direction);
			}
			TargetDirections.Sort(x => x.No);
			SourceDirections.Sort(x => x.No);

			SelectedTargetDirection = TargetDirections.FirstOrDefault();
			SelectedSourceDirection = SourceDirections.FirstOrDefault();
		}
		public GuardZonesSelectationViewModel(List<GKGuardZone> guardZones)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			GuardZones = guardZones;
			TargetZones = new SortableObservableCollection<GKGuardZone>();
			SourceZones = new SortableObservableCollection<GKGuardZone>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				if (GuardZones.Contains(guardZone))
					TargetZones.Add(guardZone);
				else
					SourceZones.Add(guardZone);
			}
			TargetZones.Sort(x => x.No);
			SourceZones.Sort(x => x.No);

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
		public PumpStationsSelectationViewModel(List<GKPumpStation> pumpStations)
		{
			Title = "Выбор насосных станций";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			PumpStations = pumpStations;
			TargetPumpStations = new SortableObservableCollection<GKPumpStation>();
			SourcePumpStations = new SortableObservableCollection<GKPumpStation>();

			foreach (var pumpStation in GKManager.PumpStations)
			{
				if (PumpStations.Contains(pumpStation))
					TargetPumpStations.Add(pumpStation);
				else
					SourcePumpStations.Add(pumpStation);
			}
			TargetPumpStations.Sort(x => x.No);
			SourcePumpStations.Sort(x => x.No);

			SelectedTargetPumpStation = TargetPumpStations.FirstOrDefault();
			SelectedSourcePumpStation = SourcePumpStations.FirstOrDefault();
		}
		void UpdateDevices()
		{
			AvailableDevices = new SortableObservableCollection<GKDevice>();
			Devices = new SortableObservableCollection<GKDevice>();
			SelectedAvailableDevice = null;
			SelectedDevice = null;

			foreach (var device in SourceDevices)
			{
				if (!device.Driver.IsGroupDevice)
				{
					if (DevicesList.Contains(device))
						Devices.Add(device);
					else
						AvailableDevices.Add(device);
				}
			}
			Devices.Sort(x => x.IntDottedPresentationAddress);
			AvailableDevices.Sort(x => x.IntDottedPresentationAddress);

			SelectedDevice = Devices.FirstOrDefault();
			SelectedAvailableDevice = AvailableDevices.FirstOrDefault();

			OnPropertyChanged(() => Devices);
			OnPropertyChanged(() => AvailableDevices);
		}
		public DelaysSelectationViewModel(List<GKDelay> delays)
		{
			Title = "Выбор задержек";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Delays = delays;
			TargetDelays = new SortableObservableCollection<GKDelay>();
			SourceDelays = new SortableObservableCollection<GKDelay>();

			foreach (var delay in GKManager.DeviceConfiguration.Delays)
			{
				if (Delays.Contains(delay))
					TargetDelays.Add(delay);
				else
					SourceDelays.Add(delay);
			}
			TargetDelays.Sort(x => x.No);
			SourceDelays.Sort(x => x.No);

			SelectedTargetDelay = TargetDelays.FirstOrDefault();
			SelectedSourceDelay = SourceDelays.FirstOrDefault();
		}
Exemple #10
0
		public void Update()
		{
			Parts = new SortableObservableCollection<SchedulePartViewModel>();
			foreach (var schedulePart in Schedule.ScheduleParts.OrderBy(x => x.DayNo))
			{
				var schedulePartViewModel = new SchedulePartViewModel(Schedule, schedulePart);
				Parts.Add(schedulePartViewModel);
			}
			SelectedPart = Parts.FirstOrDefault();
		}
		public GuardZonesWithFuncSelectationViewModel(GKDevice device, bool canCreateNew = false)
		{
			Title = "Выбор охранных зон";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Device = device;
			DeviceGuardZones = new ObservableCollection<DeviceGuardZoneViewModel>();
			foreach (var zone in device.GuardZones)
			{
				var guardZoneDevice = zone.GuardZoneDevices.FirstOrDefault(x => x.Device == device);
				if (guardZoneDevice != null)
				{
					var deviceGuardZone = new GKDeviceGuardZone();
					deviceGuardZone.GuardZone = zone;
					deviceGuardZone.GuardZoneUID = zone.UID;
					deviceGuardZone.ActionType = guardZoneDevice.ActionType;
					deviceGuardZone.CodeReaderSettings = guardZoneDevice.CodeReaderSettings;
					DeviceGuardZones.Add(new DeviceGuardZoneViewModel(deviceGuardZone, device));
				}
			}

			CanCreateNew = canCreateNew;
			TargetZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();
			SourceZones = new SortableObservableCollection<DeviceGuardZoneViewModel>();

			foreach (var guardZone in GKManager.GuardZones)
			{
				var deviceGuardZone = DeviceGuardZones.FirstOrDefault(x => x.DeviceGuardZone.GuardZone == guardZone);
				if (deviceGuardZone != null)
					TargetZones.Add(deviceGuardZone);
				else
				{
					var gkDeviceGuardZone = new GKDeviceGuardZone();
					gkDeviceGuardZone.GuardZone = guardZone;
					gkDeviceGuardZone.GuardZoneUID = guardZone.UID;
					SourceZones.Add(new DeviceGuardZoneViewModel(gkDeviceGuardZone, device));
				}
			}

			SelectedTargetZone = TargetZones.FirstOrDefault();
			SelectedSourceZone = SourceZones.FirstOrDefault();
		}
		public DoorsSelectationViewModel(List<GKDoor> doors, List<GKDoorType> doorsTypes = null)
		{
			Title = "Выбор точек доступа";
			AddCommand = new RelayCommand<object>(OnAdd, CanAdd);
			RemoveCommand = new RelayCommand<object>(OnRemove, CanRemove);
			AddAllCommand = new RelayCommand(OnAddAll, CanAddAll);
			RemoveAllCommand = new RelayCommand(OnRemoveAll, CanRemoveAll);
			CreateNewCommand = new RelayCommand(OnCreateNew);

			Doors = doors;
			TargetDoors = new SortableObservableCollection<GKDoor>();
			SourceDoors = new SortableObservableCollection<GKDoor>();

			var allDoors = GKManager.DeviceConfiguration.Doors;
			if (doorsTypes != null)
			{
				var filteredDoors = new List<GKDoor>();
				foreach (var door in allDoors)
					foreach (var doorType in doorsTypes)
					{
						if (door.DoorType == doorType)
						{
							filteredDoors.Add(door);
							break;
						}
					}
				allDoors = filteredDoors;
			}
			foreach (var door in allDoors)
			{
				if (Doors.Contains(door))
					TargetDoors.Add(door);
				else
					SourceDoors.Add(door);
			}
			TargetDoors.Sort(x => x.No);
			SourceDoors.Sort(x => x.No);

			SelectedTargetDoor = TargetDoors.FirstOrDefault();
			SelectedSourceDoor = SourceDoors.FirstOrDefault();
		}
		void UpdateGrid()
		{
			using (new WaitWrapper())
			{
				var employeeUID = Guid.Empty;

				if (SelectedTimeTrack != null)
				{
					employeeUID = SelectedTimeTrack.ShortEmployee.UID;
				}

				TotalDays = (int)(TimeTrackFilter.EndDate - TimeTrackFilter.StartDate).TotalDays + 1;
				FirstDay = TimeTrackFilter.StartDate;

				TimeTracks = new SortableObservableCollection<TimeTrackViewModel>();
				var stream = ClientManager.RubezhService.GetTimeTracksStream(TimeTrackFilter.EmployeeFilter, TimeTrackFilter.StartDate, TimeTrackFilter.EndDate);
				var folderName = AppDataFolderHelper.GetFolder("TempServer");
				var resultFileName = Path.Combine(folderName, "ClientTimeTrackResult.xml");
				var resultFileStream = File.Create(resultFileName);
				CopyStream(stream, resultFileStream);
				var timeTrackResult = Deserialize(resultFileName);

				if (timeTrackResult != null)
				{
					TimeTrackEmployeeResults = timeTrackResult.TimeTrackEmployeeResults;
					foreach (var timeTrackEmployeeResult in TimeTrackEmployeeResults)
					{
						var timeTrackViewModel = new TimeTrackViewModel(TimeTrackFilter, timeTrackEmployeeResult);
						TimeTracks.Add(timeTrackViewModel);
					}

					TimeTracks.Sort(x => x.ShortEmployee.LastName);
					RowHeight = 60 + 20 * TimeTrackFilter.TotalTimeTrackTypeFilters.Count;
				}

				SelectedTimeTrack = TimeTracks.FirstOrDefault(x => x.ShortEmployee.UID == employeeUID) ??
									TimeTracks.FirstOrDefault();
			}
		}