Esempio n. 1
0
		/// <summary>
		///     Загрузка всех прямоугольных элементов плана, базирующихся на ElementBaseRectangle, кроме тех, которые реализуют
		///     IElementTextBlock
		/// </summary>
		/// <param name="plan">Объект плана.</param>
		/// <returns>Коллекция элементов плана.</returns>
		private IEnumerable<PlanElement> LoadRectangleElements(RubezhAPI.Models.Plan plan)
		{
			return
				plan.AllElements.Where(elem => elem is ElementBaseRectangle && !(elem is IElementTextBlock))
					.Select(elem => PlanElement.FromRectangle(elem as ElementBaseRectangle))
					.Where(elem => elem != null);
		}
Esempio n. 2
0
		public OperationResult<bool> Save(RubezhAPI.GK.GKDaySchedule item)
		{
			return DbServiceHelper.InTryCatch(() => 
			{
				bool isNew = false;
				var tableItem = Context.GKDaySchedules.Include(x => x.GKDayScheduleParts).FirstOrDefault(x => x.UID == item.UID);
				if (tableItem == null)
				{
					isNew = true;
					tableItem = new GKDaySchedule { UID = item.UID };
				}
				else
					Context.GKDayScheduleParts.RemoveRange(tableItem.GKDayScheduleParts);
				tableItem.No = item.No;
				tableItem.Name = item.Name;
				tableItem.Description = item.Description;
				tableItem.GKDayScheduleParts = item.DayScheduleParts.Select(x => new GKDaySchedulePart
				{
					UID = Guid.NewGuid(),
					StartMilliseconds = x.StartMilliseconds,
					EndMilliseconds = x.EndMilliseconds
				}).ToList();
				if (isNew)
					Context.GKDaySchedules.Add(tableItem);
				Context.SaveChanges();
				return true;
			});
		}
Esempio n. 3
0
		public void TranslateBack(RubezhAPI.SKD.CardDoor apiItem)
		{
			CardUID = apiItem.CardUID;
			DoorUID = apiItem.DoorUID;
			AccessTemplateUID = apiItem.AccessTemplateUID;
			EnterScheduleNo = apiItem.EnterScheduleNo;
			ExitScheduleNo = apiItem.ExitScheduleNo;
		}
		public MonitorLayoutShellViewModel(RubezhAPI.Models.Layouts.Layout layout)
			: base()
		{
			Layout = layout;
			LayoutContainer = new LayoutContainer(this, layout);
			LayoutContainer.LayoutChanging += LayoutChanging;
			ChangeUserCommand = new RelayCommand(OnChangeUser);
			ChangeLayoutCommand = new RelayCommand<LayoutModel>(OnChangeLayout);
			Icon = @"..\Monitor.Layout.ico";
			ListenAutomationEvents();
		}
Esempio n. 5
0
		public OperationResult<bool> Delete(RubezhAPI.GK.GKDaySchedule item)
		{
			return DbServiceHelper.InTryCatch(() =>
			{
				var tableItem = GetTableItems().FirstOrDefault(x => x.UID == item.UID);
				if (tableItem != null)
				{
					Context.GKDaySchedules.Remove(tableItem);
				}
				Context.SaveChanges();
				return true;
			});
		}
Esempio n. 6
0
		/// <summary>
		///     Загрузка всех элементов плана (помимо корневого).
		/// </summary>
		/// <param name="plan">Объект плана.</param>
		/// <returns>Коллекция элементов плана.</returns>
		private IEnumerable<PlanElement> LoadPlanSubElements(RubezhAPI.Models.Plan plan)
		{
			var rectangles = LoadRectangleElements(plan);
			var polygons = LoadPolygonElements(plan);
			var polylines = LoadPolyLineElements(plan);
			var ellipses = LoadEllipseElements(plan);
			var textBlocks = LoadStaticTextElements(plan);
			var doors = LoadDoorElements(plan);
			var devices = LoadDeviceElements(plan);
			//return textBlocks.Concat(rectangles).Concat(ellipses).Concat(doors).Concat(devices);


			return ellipses.Concat(polygons).Concat(polylines).Concat(rectangles).Concat(doors).Concat(textBlocks).Concat(devices);
		}
Esempio n. 7
0
		public OperationResult<bool> Save(RubezhAPI.GK.GKSchedule item)
		{
			return DbServiceHelper.InTryCatch(() =>
			{
				bool isNew = false;
				var tableItem = GetTableItems().FirstOrDefault(x => x.UID == item.UID);
				if (tableItem == null)
				{
					isNew = true;
					tableItem = new GKSchedule { UID = item.UID };
				}
				else
				{
					Context.GKScheduleDays.RemoveRange(tableItem.ScheduleDays);
					Context.ScheduleGKDaySchedules.RemoveRange(tableItem.ScheduleGKDaySchedules);
				}
				tableItem.No = item.No;
				tableItem.Name = item.Name;
				tableItem.Description = item.Description;
				tableItem.Year = item.Year;
				tableItem.Type = (int)item.ScheduleType;
				tableItem.PeriodType = (int)item.SchedulePeriodType;
				tableItem.StartDateTime = item.StartDateTime.CheckDate();
				tableItem.HoursPeriod = item.HoursPeriod;
				tableItem.HolidayScheduleNo = item.HolidayScheduleNo;
				tableItem.WorkingHolidayScheduleNo = item.WorkHolidayScheduleNo;
				tableItem.ScheduleDays = item.SelectedDays.Select(x => new GKScheduleDay
				{
					UID = Guid.NewGuid(),
					ScheduleUID = item.UID,
					DateTime = x.CheckDate()
				}).ToList();
				tableItem.ScheduleGKDaySchedules = item.ScheduleParts.Select(x => new ScheduleGKDaySchedule
				{
					UID = Guid.NewGuid(),
					ScheduleUID = item.UID,
					DayScheduleUID = x.DayScheduleUID.EmptyToNull(),
					DayNo = x.DayNo
				}).ToList();
				if (isNew)
					Context.GKSchedules.Add(tableItem);
				Context.SaveChanges();
				return true;
			});
		}
Esempio n. 8
0
		JsonResult GetJournalPage(RubezhAPI.Journal.JournalFilter journalFilter, int pageNo)
		{
			SafeRubezhService.CallbackOperationResultEvent += OnCallbackOperationResult;
			try
			{
				var result = ClientManager.RubezhService.BeginGetArchivePage(journalFilter, pageNo, User.Identity.Name);
				if (!result.HasError)
				{
					if (!_autoResetEvent.WaitOne(TimeSpan.FromSeconds(10)))
					{
						_journalItems = new List<JournalItem>();
					}
				}
			}
			finally
			{
				SafeRubezhService.CallbackOperationResultEvent -= OnCallbackOperationResult;
			}
			var list = _journalItems.Select(x => new JournalModel(x)).ToList();
			return Json(list, JsonRequestBehavior.AllowGet);
		}
Esempio n. 9
0
		/// <summary>
		///     Загрузка корневого элемента плана (фон).
		/// </summary>
		/// <param name="plan">Объект плана.</param>
		/// <returns>Корневой элемент плана.</returns>
		private PlanElement LoadPlanRoot(RubezhAPI.Models.Plan plan)
		{
			return new PlanElement
			{
				Border = InternalConverterOld.ConvertColor(System.Windows.Media.Colors.Black),
				BorderThickness = 0,
				Fill = InternalConverterOld.ConvertColor(plan.BackgroundColor.ToWindowsColor()),
				Id = "pe" + plan.UID,
				Name = plan.Caption,
				Path =
					"M 0 0 L " + plan.Width + " 0 L " + plan.Width +
					" " + plan.Height +
					" L 0 " + plan.Height + " L 0 0 z",
				Type = ShapeTypes.Plan.ToString(),
				Image = RenderPlanBackgound(
					plan.BackgroundImageSource, plan.ImageType,
					Convert.ToInt32(plan.Width),
					Convert.ToInt32(plan.Height)),
				Width = plan.Width,
				Height = plan.Height
			};
		}
Esempio n. 10
0
		/// <summary>
		///     Рекурсивно получить основную информацию о плане и вложенных планах.
		/// </summary>
		/// <param name="plan">Объект плана.</param>
		/// <returns>Основная информация о плане, включая вложенные планы.</returns>
		private PlanSimpl GetPlanInfo(RubezhAPI.Models.Plan plan)
		{
			return new PlanSimpl
			{
				Name = plan.Caption,
				Uid = plan.UID,
				Description = plan.Description,
				Width = plan.Width,
				Height = plan.Height,
				NestedPlans = plan.Children != null ? plan.Children.Select(GetPlanInfo) : null,
				ParentUid = plan.Parent != null ? plan.Parent.UID : (Guid?)null,
				IsFolder = plan is PlanFolder
			};
		}
Esempio n. 11
0
		private IEnumerable<PlanElement> LoadDoorElements(RubezhAPI.Models.Plan plan)
		{
			return plan.ElementGKDoors.ToList().Select(PlanElement.FromGkDoor);
		}
Esempio n. 12
0
		private IEnumerable<PlanElement> LoadDeviceElements(RubezhAPI.Models.Plan plan)
		{
			return plan.ElementGKDevices.Select(PlanElement.FromDevice);
		}
Esempio n. 13
0
		/// <summary>
		///     Преобразует статические текcтовые элементы
		///     (ElementTextBlock, ElementProcedure).
		/// </summary>
		/// <param name="plan">План</param>
		/// <returns>Элемент-группа, содержащий групповой элемент, внутри которого текст и прямоугольник.</returns>
		private IEnumerable<PlanElement> LoadStaticTextElements(RubezhAPI.Models.Plan plan)
		{
			var textBlockElements = plan.ElementTextBlocks;
			var procedureElements = plan.AllElements.OfType<ElementProcedure>();
			return textBlockElements.Where(t => !string.IsNullOrWhiteSpace(t.Text)).Select(
				PlanElement.FromTextBlock)
									.Where(elem => elem != null)
									.Union(procedureElements.Where(p => !string.IsNullOrWhiteSpace(p.Text)).Select(PlanElement.FromProcedure).Where(elem => elem != null));
		}
Esempio n. 14
0
		protected override ElementBaseShape CreateElement(RubezhAPI.PointCollection points)
		{
			return new ElementPolygon { Points = points };
		}
Esempio n. 15
0
		public static Photo Create(RubezhAPI.SKD.Photo photo) 
		{ 
			if (photo == null) 
				return null; 
			return new Photo { UID = Guid.NewGuid(), Data = photo.Data }; 
		}
Esempio n. 16
0
		private IEnumerable<PlanElement> LoadPolygonElements(RubezhAPI.Models.Plan plan)
		{
			return plan.AllElements.Where(elem => elem is ElementBasePolygon).Select(elem => PlanElement.FromPolygon(elem as ElementBasePolygon)).Where(elem => elem != null);
		}
Esempio n. 17
0
		protected override ElementBaseShape CreateElement(RubezhAPI.PointCollection points)
		{
			var element = new ElementPolygonSubPlan { Points = points };
			var propertiesViewModel = new SubPlanPropertiesViewModel(element, DesignerCanvas);
			return DialogService.ShowModalWindow(propertiesViewModel) ? element : null;
		}
Esempio n. 18
0
		public PlanLinkViewModel(RubezhAPI.Models.Plan plan, ElementBase elementBase)
		{
			PlanUID = plan.UID;
			ElementUID = elementBase.UID;
			Name = plan.Caption;
		}
Esempio n. 19
0
		public void AddClient(RubezhAPI.Models.ClientCredentials clientCredentials)
		{
			MainViewModel.Current.AddClient(clientCredentials);
		}
Esempio n. 20
0
		protected abstract ElementBaseShape CreateElement(RubezhAPI.PointCollection points);
Esempio n. 21
0
		private IEnumerable<PlanElement> LoadPolyLineElements(RubezhAPI.Models.Plan plan)
		{
			return plan.ElementPolylines.Select(PlanElement.FromPolyline).Where(elem => elem != null);
		}
Esempio n. 22
0
		public CardDoor(RubezhAPI.SKD.CardDoor apiItem)
		{
			UID = apiItem.UID;
			TranslateBack(apiItem);
		}
Esempio n. 23
0
		private IEnumerable<PlanElement> LoadEllipseElements(RubezhAPI.Models.Plan plan)
		{
			return plan.ElementEllipses.Select(PlanElement.FromEllipse).Where(elem => elem != null);
		}
Esempio n. 24
0
		public void AddClient(RubezhAPI.Models.ClientCredentials clientCredentials)
		{
			MainPresenter.Current.AddClient(clientCredentials);
		}