/// <summary> /// 未查询到数据时返回 null /// </summary> public static TEarthworkBlock DbSelect(this TEarthworkBlock entity, DbSession session, params PDMDbProperty[] fields) { var query = session.GetDbQueryBuilder(); SelectBuilder builder = new SelectBuilder(); if (fields.Count() == 0) { builder.ComponentSelect.Add(TEarthworkBlockProperties.IssueDateTime); builder.ComponentSelect.Add(TEarthworkBlockProperties.Id); builder.ComponentSelect.Add(TEarthworkBlockProperties.Indexer); builder.ComponentSelect.Add(TEarthworkBlockProperties.Name); builder.ComponentSelect.Add(TEarthworkBlockProperties.Description); builder.ComponentSelect.Add(TEarthworkBlockProperties.CPSettings); builder.ComponentSelect.Add(TEarthworkBlockProperties.EarthworkBlockImplementationInfo); } else { builder.ComponentSelect.Add(TEarthworkBlockProperties.IssueDateTime); builder.ComponentSelect.Add(TEarthworkBlockProperties.Id); foreach (var field in fields) { builder.ComponentSelect.Add(field); } } builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal)); builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.Id, entity.Id, LocateType.Equal)); query.SelectBuilders.Add(builder); return(session.GetQueryOperator().Select <TEarthworkBlock>(query)); }
/// <summary> /// 未查询到数据时返回 null /// </summary> public static TEarthworkBlock DbSelect(this TEarthworkBlock entity, DbSession session, SelectBuilder select) { var query = session.GetDbQueryBuilder(); query.SelectBuilder = select; return(session.GetQueryOperator().Select <TEarthworkBlock>(query)); }
public static bool DbDelete(this TEarthworkBlock entity, DbSession session) { var query = session.GetDbQueryBuilder(); query.DeleteBuilder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal)); query.DeleteBuilder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.Id, entity.Id, LocateType.Equal)); return(session.GetQueryOperator().Delete <TEarthworkBlock>(query)); }
public static void DeleteEarthworkBlockElements(this TEarthworkBlock earthworkBlock, DbSession session) { var query = session.GetDbQueryBuilder().DeleteBuilder; query.ComponentWhere.Add(TEarthworkBlockElementProperties.IssueDateTime, earthworkBlock.IssueDateTime, LocateType.Equal); query.ComponentWhere.Add(TEarthworkBlockElementProperties.Id, earthworkBlock.Id, LocateType.Equal); var @operator = session.GetQueryOperator(); @operator.Delete <TEarthworkBlockElement>(query); }
public static bool FetchEarthworkBlockElements(this TEarthworkBlock tEarthworkBlock, DbSession session) { var query = session.GetDbQueryBuilder(); SelectBuilder builder = new SelectBuilder(); builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockElementProperties.IssueDateTime, tEarthworkBlock.IssueDateTime, LocateType.Equal)); builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockElementProperties.Id, tEarthworkBlock.Id, LocateType.Equal)); query.SelectBuilders.Add(builder); tEarthworkBlock.EarthworkBlockElements = session.GetQueryOperator().SelectAll <TEarthworkBlockElement>(query); return(tEarthworkBlock.EarthworkBlockElements.Count > 0); }
public static bool DbInsert(this TEarthworkBlock entity, DbSession session) { var query = session.GetDbQueryBuilder(); InsertBuilder builder = new InsertBuilder(); builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.IssueDateTime, entity.IssueDateTime)); builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Id, entity.Id)); builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Indexer, entity.Indexer)); if (entity.Name == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Name)); } if (entity.Name.Length > 100) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Name), entity.Name.Length, 100)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Name, entity.Name)); if (entity.Description == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.Description)); } if (entity.Description.Length > 1000) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.Description), entity.Description.Length, 1000)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.Description, entity.Description)); if (entity.CPSettings == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.CPSettings)); } if (entity.CPSettings.Length > 1000) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.CPSettings), entity.CPSettings.Length, 1000)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.CPSettings, entity.CPSettings)); if (entity.EarthworkBlockImplementationInfo == null) { throw new NotImplementedException("缺少必填的参数项值, 参数项: " + nameof(entity.EarthworkBlockImplementationInfo)); } if (entity.EarthworkBlockImplementationInfo.Length > 1000) { throw new NotImplementedException(string.Format("参数项:{0}长度:{1}超过额定限制:{2}", nameof(entity.EarthworkBlockImplementationInfo), entity.EarthworkBlockImplementationInfo.Length, 1000)); } builder.ComponentInsert.Add(new ComponentValueOfInsert(TEarthworkBlockProperties.EarthworkBlockImplementationInfo, entity.EarthworkBlockImplementationInfo)); query.InsertBuilders.Add(builder); return(session.GetQueryOperator().Insert <TEarthworkBlock>(query)); }
/// <summary> /// 存在相应对象时返回true,缺少对象时返回false /// </summary> public static bool DbLoad(this TEarthworkBlock entity, DbSession session, params PDMDbProperty[] fields) { var result = entity.DbSelect(session, fields); if (result == null) { return(false); } if (fields.Count() == 0) { entity.Indexer = result.Indexer; entity.Name = result.Name; entity.Description = result.Description; entity.CPSettings = result.CPSettings; entity.EarthworkBlockImplementationInfo = result.EarthworkBlockImplementationInfo; } else { if (fields.Contains(TEarthworkBlockProperties.Indexer)) { entity.Indexer = result.Indexer; } if (fields.Contains(TEarthworkBlockProperties.Name)) { entity.Name = result.Name; } if (fields.Contains(TEarthworkBlockProperties.Description)) { entity.Description = result.Description; } if (fields.Contains(TEarthworkBlockProperties.CPSettings)) { entity.CPSettings = result.CPSettings; } if (fields.Contains(TEarthworkBlockProperties.EarthworkBlockImplementationInfo)) { entity.EarthworkBlockImplementationInfo = result.EarthworkBlockImplementationInfo; } } return(true); }
public static bool DbUpdate(this TEarthworkBlock entity, DbSession session, params PDMDbProperty[] fields) { var query = session.GetDbQueryBuilder(); UpdateBuilder builder = new UpdateBuilder(); builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.IssueDateTime, entity.IssueDateTime, LocateType.Equal)); builder.ComponentWhere.Add(new ComponentValueOfWhere(TEarthworkBlockProperties.Id, entity.Id, LocateType.Equal)); if (fields == null || fields.Length == 0) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Indexer, entity.Indexer)); builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Name, entity.Name)); builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Description, entity.Description)); builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.CPSettings, entity.CPSettings)); builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.EarthworkBlockImplementationInfo, entity.EarthworkBlockImplementationInfo)); } else { if (fields.Contains(TEarthworkBlockProperties.Indexer)) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Indexer, entity.Indexer)); } if (fields.Contains(TEarthworkBlockProperties.Name)) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Name, entity.Name)); } if (fields.Contains(TEarthworkBlockProperties.Description)) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.Description, entity.Description)); } if (fields.Contains(TEarthworkBlockProperties.CPSettings)) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.CPSettings, entity.CPSettings)); } if (fields.Contains(TEarthworkBlockProperties.EarthworkBlockImplementationInfo)) { builder.ComponentSet.Add(new ComponentValueOfSet(TEarthworkBlockProperties.EarthworkBlockImplementationInfo, entity.EarthworkBlockImplementationInfo)); } } query.UpdateBuilders.Add(builder); return(session.GetQueryOperator().Update <TEarthworkBlock>(query)); }
public EarthworkBlockCPSettingsForm(EarthworkBlockingForm form, TEarthworkBlock block) { InitializeComponent(); //传值存储 Mainform = form; Block = block; //CPSettings = block.CPSettings_Obj; CPSettings.Start(); btn_Apply.Enabled = false;//应用只在内容更改时可用 //控件参数初始化 traceBar_Transparency.Minimum = 0; traceBar_Transparency.Maximum = 100; //解除变更事件 cb_IsVisible.CheckedChanged -= ValueChanged; cb_IsSurfaceVisible.CheckedChanged -= ValueChanged; cb_IsHalftone.CheckedChanged -= ValueChanged; tb_Transparency.TextChanged -= tb_Transparency_TextChanged; traceBar_Transparency.Scroll -= traceBar_Transparency_Scroll; cb_FillPattern.SelectedIndexChanged -= ValueChanged; //赋值 cb_FillPattern.DisplayMember = "Name"; cb_FillPattern.ValueMember = "Id"; cb_FillPattern.DataSource = GetFillPatterns(form.m_Doc); cb_IsVisible.Checked = CPSettings.IsVisible; cb_IsSurfaceVisible.Checked = CPSettings.IsSurfaceVisible; cb_IsHalftone.Checked = CPSettings.IsHalftone; traceBar_Transparency.Value = CPSettings.SurfaceTransparency; tb_Transparency.Text = CPSettings.SurfaceTransparency.ToString(); btn_Color.ImageAlign = ContentAlignment.MiddleLeft; btn_Color.TextAlign = ContentAlignment.MiddleLeft; RenderColorButton(CPSettings.Color); //绑定变更事件 cb_IsVisible.CheckedChanged += ValueChanged; cb_IsSurfaceVisible.CheckedChanged += ValueChanged; cb_IsHalftone.CheckedChanged += ValueChanged; tb_Transparency.TextChanged += tb_Transparency_TextChanged; traceBar_Transparency.Scroll += traceBar_Transparency_Scroll; cb_FillPattern.SelectedIndexChanged += ValueChanged; }
public static void InsertEarthworkBlockElements(this TEarthworkBlock earthworkBlock, DbSession session) { List <int> elementIds = null; short groupId = 1; for (int i = 0; i < earthworkBlock.ElementIds.Count; i++) { if (i % 100 == 0) { elementIds = new List <int>(); } elementIds.Add(earthworkBlock.ElementIds[i]); if (i % 100 == 99 || i == earthworkBlock.ElementIds.Count - 1) { new TEarthworkBlockElement(earthworkBlock.IssueDateTime, earthworkBlock.Id, groupId) { ElementIds = string.Join(",", elementIds) }.DbInsert(session); groupId++; } } }
public override TEarthworkBlocking Import(Workbook workbook) { var sheet = ExcelHelper.GetWorksheet(workbook, EIssueType.GetSheetName()); if (!WorksheetCheck(sheet)) { return(null); } int rowIndex = 2; bool isEndTimeEarlier = false; bool isStartTimeError = false; bool isEndTimeError = false; bool isTimeSpanError = false; TEarthworkBlocking blocking; blocking = new TEarthworkBlocking(); while (!string.IsNullOrEmpty(sheet.GetCellValueAsString(rowIndex, 1))) { var name = sheet.GetCellValueAsString(rowIndex, 1); var startTimeStr = sheet.GetCellValueAsString(rowIndex, 2); var timeSpanStr = sheet.GetCellValueAsString(rowIndex, 3); var endTimeStr = sheet.GetCellValueAsString(rowIndex, 4); var description = sheet.GetCellValueAsString(rowIndex, 5); rowIndex++; DateTime startTime, endTime; double timeSpan; if (!DateTime.TryParse(startTimeStr, out startTime)) { isStartTimeError = true; continue; } if (!DateTime.TryParse(endTimeStr, out endTime)) { isEndTimeError = true; continue; } if (startTime > endTime) { isEndTimeEarlier = true; continue; } if (!double.TryParse(timeSpanStr, out timeSpan)) { isTimeSpanError = true; continue; } var block = new TEarthworkBlock(DateTime.MinValue, blocking.GetEarthworkBlockMaxId()) { Name = name, Description = description, EarthworkBlockImplementationInfo_Obj = new EarthworkBlockImplementationInfo() { StartTime = startTime, EndTime = endTime, ExposureTime = timeSpan, } }; blocking.Add(block); } if (isEndTimeEarlier || isStartTimeError || isEndTimeError || isTimeSpanError) { ShowMessage("部分导入的数据格式存在异常,或者不符合数据的规范"); } }