/// <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); }
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; }); }
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(); }
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; }); }
/// <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); }
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; }); }
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); }
/// <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 }; }
/// <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 }; }
private IEnumerable<PlanElement> LoadDoorElements(RubezhAPI.Models.Plan plan) { return plan.ElementGKDoors.ToList().Select(PlanElement.FromGkDoor); }
private IEnumerable<PlanElement> LoadDeviceElements(RubezhAPI.Models.Plan plan) { return plan.ElementGKDevices.Select(PlanElement.FromDevice); }
/// <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)); }
protected override ElementBaseShape CreateElement(RubezhAPI.PointCollection points) { return new ElementPolygon { Points = points }; }
public static Photo Create(RubezhAPI.SKD.Photo photo) { if (photo == null) return null; return new Photo { UID = Guid.NewGuid(), Data = photo.Data }; }
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); }
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; }
public PlanLinkViewModel(RubezhAPI.Models.Plan plan, ElementBase elementBase) { PlanUID = plan.UID; ElementUID = elementBase.UID; Name = plan.Caption; }
public void AddClient(RubezhAPI.Models.ClientCredentials clientCredentials) { MainViewModel.Current.AddClient(clientCredentials); }
protected abstract ElementBaseShape CreateElement(RubezhAPI.PointCollection points);
private IEnumerable<PlanElement> LoadPolyLineElements(RubezhAPI.Models.Plan plan) { return plan.ElementPolylines.Select(PlanElement.FromPolyline).Where(elem => elem != null); }
public CardDoor(RubezhAPI.SKD.CardDoor apiItem) { UID = apiItem.UID; TranslateBack(apiItem); }
private IEnumerable<PlanElement> LoadEllipseElements(RubezhAPI.Models.Plan plan) { return plan.ElementEllipses.Select(PlanElement.FromEllipse).Where(elem => elem != null); }
public void AddClient(RubezhAPI.Models.ClientCredentials clientCredentials) { MainPresenter.Current.AddClient(clientCredentials); }