/// <summary> /// Load the Layout Information to an Existing Template Instance. /// </summary> /// <param name="layout">The Layout Information to apply.</param> /// <param name="template">The Template Instance to apply the layout to.</param> /// <param name="dataEntryContract">Local Metadata for the Template.</param> private void LoadLayout(TemplateLayout layout, Template template, DataEntryContract dataEntryContract) { // Load the Template Information template.Description = layout.Description; template.IsSupplement = layout.IsSupplement; template.ValidationEnabled = layout.ValidationEnabled; // Apply the Section Layouts foreach (var sectionLayout in layout.Sections) { // Lookup the Section Information var sectionMetadata = dataEntryContract.GetSection(sectionLayout.DataEntrySectionName); var section = template.GetSection(sectionMetadata.Id); // If the Section does not exist in the Template, create a new section // using the layout information and add it to the Template. if (section == null) { // Create a new section using the layout section = template.CreateSection(sectionMetadata.Id, sectionLayout.Label); template.Sections.Add(section); } // Apply the Layout to the Section ApplySectionLayout(sectionLayout, section, sectionMetadata); } }
public IActionResult Update([FromBody] TemplateLayout templateLayout) { if (templateLayout == null) { return(BadRequest("TemplateLayout object can not null!")); } if (ExistsName(templateLayout.TemplateLayoutName, templateLayout.TemplateLayoutId)) { return(BadRequest("TemplateLayout name has been used!")); } using (var db = new AllInOneContext.AllInOneContext()) { try { db.TemplateLayout.Update(templateLayout); db.SaveChanges(); return(NoContent()); } catch (DbUpdateException dbEx) { _logger.LogError("更新模板异常:Message:{0}\r\n,StackTrace:{1}", dbEx.Message, dbEx.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "DBUpdate", ErrorMessage = "数据保存异常:" + dbEx.Message })); } catch (Exception ex) { _logger.LogError("更新模板异常:Message:{0}\r\n,StackTrace:{1}", ex.Message, ex.StackTrace); return(BadRequest(new ApplicationException { ErrorCode = "Unknown", ErrorMessage = ex.Message })); } } }
/// <summary> /// Get the Layout information for a supplied Template and Metadata. /// The Metadata is used to lookup identifier information. /// </summary> private TemplateLayout GetTemplateLayout(Template template, DataEntryContract dataEntryContract, string implementation) { // Create the Template Layout // This information can be used to create a new Template in a Different System that structurally matches the original. var templateLayout = new TemplateLayout() { ApiVersion = template.ApiVersion, Description = template.Description, Implementation = implementation, IsSupplement = template.IsSupplement, ModuleType = template.ModuleType, Name = template.Name, Sections = new List <SectionLayout>(), ValidationEnabled = template.ValidationEnabled, IsDefault = false // This Value is not part of the actual Layout. This is a placeholder for data that is managed elsewhere. }; // Create Scaffolding for Each Section foreach (var section in template.Sections) { // Get the Section Metadata var dataEntrySection = dataEntryContract.GetSection(section.DataEntrySectionId); templateLayout.Sections.Add(GetSectionLayout(section, dataEntrySection)); } return(templateLayout); }
/// <summary> /// Load layout Information into an Existing Template Instance. /// </summary> /// <param name="layout">Template Layout to Apply.</param> /// <param name="templateId">Id of a specific template to apply layout information to.</param> public void LoadLayout(TemplateLayout layout, Guid templateId) { // Load the Template var template = _admin.GetTemplate(templateId); if (template == null) { throw new Exception("The specified template[" + templateId + "] could not be found in the system."); } LoadLayout(layout, template); }
static void Add5and1TemplateLayout(Guid TemplateTypeGuid) { using (var db = new AllInOneContext()) { List <TemplateCell> tcList = new List <TemplateCell>(); for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { TemplateCell tcl = new TemplateCell(); if (i == 0 && j == 0) { tcl.TemplateCellId = Guid.NewGuid(); tcl.Column = j; tcl.Row = i; tcl.RowSpan = 2; tcl.ColumnSpan = 2; } else if (i <= 1 && j <= 1) { continue; } else { tcl = new TemplateCell() { TemplateCellId = Guid.NewGuid(), Column = j, Row = i, RowSpan = 1, ColumnSpan = 1, }; } tcList.Add(tcl); } } TemplateLayout tll = new TemplateLayout() { Columns = 3, Rows = 3, TemplateLayoutId = Guid.NewGuid(), LayoutType = db.SystemOption.First(t => t.SystemOptionCode.Equals("11400002")), TemplateType = db.SystemOption.First(t => t.SystemOptionId.Equals(TemplateTypeGuid)), Cells = tcList }; tll.TemplateLayoutName = "1+5"; db.TemplateLayout.Add(tll); db.SaveChanges(); } }
/// <summary> /// Load layout Information into an Existing Template Instance. /// </summary> /// <param name="layout">Template Layout to Apply.</param> /// <param name="template">Template to apply layout information to.</param> public void LoadLayout(TemplateLayout layout, Template template) { // Load the Metadata var dataEntryContract = _meta.GetDataEntryContract(template.DataEntryContractId); if (dataEntryContract == null) { throw new Exception("The metadata[" + template.DataEntryContractId + "] for template[" + template.Name + "] could not be found in the system."); } // Apply the layout information to the Template. LoadLayout(layout, template, dataEntryContract); }
public IActionResult GetById(Guid id) { using (var db = new AllInOneContext.AllInOneContext()) { TemplateLayout tl = GetDbQuery(db).FirstOrDefault(t => t.TemplateLayoutId.Equals(id)); if (tl == null) { return(NotFound()); } tl.Cells = (from c in (tl.Cells ?? new List <TemplateCell>()) orderby c.Row, c.Column select c).ToList(); return(new ObjectResult(tl)); } }
public IActionResult Remove(Guid id) { using (var db = new AllInOneContext.AllInOneContext()) { TemplateLayout deleteObj = db.TemplateLayout.FirstOrDefault(t => t.TemplateLayoutId.Equals(id)); if (deleteObj == null) { return(NotFound()); } db.TemplateLayout.Remove(deleteObj); db.SaveChanges(); return(NoContent()); } }
/// <summary> /// 适用于普通视频轮巡 /// </summary> /// <param name="cameras">轮巡监控点</param> /// <param name="template">视频模板</param> /// <param name="roundInterval">轮巡间隔</param> public VideoRoundTask(IEnumerable <CameraView> cameras, TemplateLayout template, int roundInterval) { if (cameras == null) { throw new ArgumentNullException("参数monitorysites未设置为对象引用实例"); } if (cameras.Count() == 0) { throw new Exception("参数monitorysitesl元素数量不能少于0"); } if (template == null) { throw new ArgumentNullException("参数template未设置为对象引用实例"); } if (roundInterval < 0) { throw new Exception("参数roundInterval不能少于0"); } int stepLength = template.Cells.Count(); int monitorysiteCount = cameras.Count(); int sectionCount = monitorysiteCount % stepLength == 0 ? monitorysiteCount / stepLength : monitorysiteCount / stepLength + 1; m_videoRoundScene = new VideoRoundSceneView(); m_videoRoundScene.VideoRoundSections = new List <VideoRoundSectionView>(); for (int i = 0; i < sectionCount; ++i) { VideoRoundSectionView section = new VideoRoundSectionView(); section.RoundInterval = roundInterval; section.TemplateLayout = template; List <RealPlayParam> playInfoList = new List <RealPlayParam>(); cameras.Skip(i * stepLength).Take(stepLength).ToList().ForEach(t => { playInfoList.Add(new RealPlayParam() { CameraView = t }); }); section.PlayInfoList = playInfoList; m_videoRoundScene.VideoRoundSections.Add(section); } }
static void AddStandarTemplateLayout(int row, int column, Guid TemplateTypeGuid) { using (var db = new AllInOneContext()) { List <TemplateCell> tcList = new List <TemplateCell>(); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { TemplateCell tcl = new TemplateCell() { TemplateCellId = Guid.NewGuid(), Column = j, Row = i, RowSpan = 1, ColumnSpan = 1, }; tcList.Add(tcl); } } TemplateLayout tll = new TemplateLayout() { Columns = column, Rows = row, TemplateLayoutId = Guid.NewGuid(), LayoutType = db.SystemOption.First(t => t.SystemOptionCode.Equals("11400001")), TemplateType = db.SystemOption.First(t => t.SystemOptionId.Equals(TemplateTypeGuid)), Cells = tcList }; tll.TemplateLayoutName = string.Format("{0}", row * column); db.TemplateLayout.Add(tll); db.SaveChanges(); } }