//0711TODO KO 需增加ElementIds的关联表加载处理 public static void FetchDepthNodeElements(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); var nodeElement = new TDepthNodeElement(); List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(nameof(entity.Segregation), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(UniqueIdHelper.UniqueIdStr))); command.CommandText = SQLiteHelper.GetSQLiteQuery_Select(null, $"{nodeElement.TableName}", wheres); //var command = connection.CreateCommand(); //var node = new TDepthNode(); //var nodeElement = new TDepthNodeElement(); //string tableSuffix = "n."; //List<KeyOperatorValue> wheres = new List<KeyOperatorValue>(); //wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.Segregation), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(UniqueIdHelper.UniqueIdStr))); //wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime))); //wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString<EIssueType>(entity.IssueType))); //command.CommandText = SQLiteHelper.GetSQLiteQuery_SelectWithJoin("ne.*", $"{node.TableName} n left join {nodeElement.TableName} ne on n.{nameof(node.Segregation)}=ne.{nameof(nodeElement.Segregation)} and n.{nameof(node.NodeCode)}=ne.{nameof(nodeElement.NodeCode)} and n.{nameof(node.Depth)}=ne.{nameof(nodeElement.Depth)}", wheres); var reader = command.ExecuteReader(); while (reader.Read()) { nodeElement = new TDepthNodeElement(reader); var node = entity.DepthNodes.FirstOrDefault(c => c.NodeCode == nodeElement.NodeCode && c.Depth == nodeElement.Depth); if (node != null) { node.ElementIds = nodeElement.ElementIds; } } }
public static List <DateTimeValue> GetDateTimeValues(EIssueType issueType, DateTime startTime, int daySpan) { List <DateTimeValue> result; using (var connection = SQLiteHelper.Connect()) { connection.Open(); switch (issueType) { case EIssueType.侧斜监测: result = new TDetail().GetDateTimeValue(issueType, startTime, daySpan, connection); break; case EIssueType.建筑物沉降: case EIssueType.地表沉降: case EIssueType.管线沉降_有压: case EIssueType.管线沉降_无压: case EIssueType.钢支撑轴力监测: default: throw new NotImplementedException("该方法暂不支持该类型"); } connection.Close(); } return(result); }
public static bool DbUpdate(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); Dictionary <string, string> sets = new Dictionary <string, string>(); sets.Add(nameof(entity.ReportName), SQLiteHelper.ToSQLiteString(entity.ReportName)); sets.Add(nameof(entity.IssueTimeRange), SQLiteHelper.ToSQLiteString(entity.IssueTimeRange)); sets.Add(nameof(entity.Contractor), SQLiteHelper.ToSQLiteString(entity.Contractor)); sets.Add(nameof(entity.Supervisor), SQLiteHelper.ToSQLiteString(entity.Supervisor)); sets.Add(nameof(entity.Monitor), SQLiteHelper.ToSQLiteString(entity.Monitor)); sets.Add(nameof(entity.InstrumentName), SQLiteHelper.ToSQLiteString(entity.InstrumentName)); sets.Add(nameof(entity.InstrumentCode), SQLiteHelper.ToSQLiteString(entity.InstrumentCode)); sets.Add(nameof(entity.CloseCTSettings), SQLiteHelper.ToSQLiteString(entity.CloseCTSettings)); sets.Add(nameof(entity.OverCTSettings), SQLiteHelper.ToSQLiteString(entity.OverCTSettings)); if (entity.ExtraValue1.HasValue) { sets.Add(nameof(entity.ExtraValue1), SQLiteHelper.ToSQLiteString(entity.ExtraValue1.Value)); } if (entity.ExtraValue2.HasValue) { sets.Add(nameof(entity.ExtraValue2), SQLiteHelper.ToSQLiteString(entity.ExtraValue2.Value)); } if (entity.ExtraValue3.HasValue) { sets.Add(nameof(entity.ExtraValue3), SQLiteHelper.ToSQLiteString(entity.ExtraValue3.Value)); } List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(nameof(entity.Segregation), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(UniqueIdHelper.UniqueIdStr))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType))); command.CommandText = SQLiteHelper.GetSQLiteQuery_Update(new TDetail().TableName, sets, wheres); return(command.ExecuteNonQuery() == 1); }
public static bool DbInsert(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); Dictionary <string, string> NameValues = new Dictionary <string, string>(); NameValues.Add(nameof(entity.ReportName), SQLiteHelper.ToSQLiteString(entity.ReportName)); NameValues.Add(nameof(entity.IssueType), SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType)); NameValues.Add(nameof(entity.IssueDateTime), SQLiteHelper.ToSQLiteString(entity.IssueDateTime)); NameValues.Add(nameof(entity.IssueTimeRange), SQLiteHelper.ToSQLiteString(entity.IssueTimeRange)); NameValues.Add(nameof(entity.Contractor), SQLiteHelper.ToSQLiteString(entity.Contractor)); NameValues.Add(nameof(entity.Supervisor), SQLiteHelper.ToSQLiteString(entity.Supervisor)); NameValues.Add(nameof(entity.Monitor), SQLiteHelper.ToSQLiteString(entity.Monitor)); NameValues.Add(nameof(entity.InstrumentName), SQLiteHelper.ToSQLiteString(entity.InstrumentName)); NameValues.Add(nameof(entity.InstrumentCode), SQLiteHelper.ToSQLiteString(entity.InstrumentCode)); NameValues.Add(nameof(entity.CloseCTSettings), SQLiteHelper.ToSQLiteString(entity.CloseCTSettings)); NameValues.Add(nameof(entity.OverCTSettings), SQLiteHelper.ToSQLiteString(entity.OverCTSettings)); if (entity.ExtraValue1.HasValue) { NameValues.Add(nameof(entity.ExtraValue1), SQLiteHelper.ToSQLiteString(entity.ExtraValue1.Value)); } if (entity.ExtraValue2.HasValue) { NameValues.Add(nameof(entity.ExtraValue2), SQLiteHelper.ToSQLiteString(entity.ExtraValue2.Value)); } if (entity.ExtraValue3.HasValue) { NameValues.Add(nameof(entity.ExtraValue3), SQLiteHelper.ToSQLiteString(entity.ExtraValue3.Value)); } command.CommandText = SQLiteHelper.GetSQLiteQuery_Insert(new TDetail().TableName, NameValues); return(command.ExecuteNonQuery() == 1); }
public static BLLResult UpdateDetail(TDetail detail, List <TNode> nodes) { var result = new BLLResult(); using (var connection = SQLiteHelper.Connect()) { connection.Open(); var transaction = connection.BeginTransaction(); try { if (!detail.DbUpdate(connection)) { throw new NotImplementedException("Detail数据未按预期存储"); } if (!nodes.DbUpdate(connection)) { throw new NotImplementedException("Nodes数据未按预期存储"); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); result.IsSuccess = false; result.Message = ex.ToString(); } connection.Close(); } return(result); }
public static void FetchDepthNodes(TDetail detail) { using (var connection = SQLiteHelper.Connect()) { connection.Open(); detail.FetchDepthNodes(connection); connection.Close(); } }
public static bool DbDelete(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType))); command.CommandText = SQLiteHelper.GetSQLiteQuery_Delete(new TDetail().TableName, wheres); return(command.ExecuteNonQuery() == 1); }
private void Model_OnDataChanged(TDetail detail) { tb_ReportName.Text = detail.ReportName; //报告名称 tb_IssueType.Text = detail.IssueType.ToString(); //沉降类型 tb_Contractor.Text = detail.Contractor; //承包单位 tb_Supervisor.Text = detail.Supervisor; //监理单位 tb_Monitor.Text = detail.Monitor; //监测单位 tb_Date.Text = detail.IssueDateTime.ToString("yyyy.MM.dd"); //监测日期 var endTime = detail.IssueDateTime.AddMinutes(detail.IssueTimeRange); var timeFormat = "HH:mm"; tb_Time.Text = $"{detail.IssueDateTime.ToString(timeFormat)}-{endTime.ToString(timeFormat)}"; //监测时间 tb_InstrumentName.Text = detail.InstrumentName; //仪器名称 tb_InstrumentCode.Text = detail.InstrumentCode; //仪器编号 //DGV var normalHeight = 20; ITNodeDataCollection <ITNodeData> leftNodes = IssueTypeEntity.GetNodeDataCollection(); ITNodeDataCollection <ITNodeData> rightNodes = IssueTypeEntity.GetNodeDataCollection(); if (detail.Nodes.Count <= normalHeight) { foreach (var node in detail.Nodes) { leftNodes.Add(node.NodeCode, node.Data); } } else { var height = normalHeight; if (detail.Nodes.Count > normalHeight * 2) { height = detail.Nodes.Count / 2; } for (int i = 0; i < detail.Nodes.Count; i++) { var node = detail.Nodes[i]; if (i < height) { leftNodes.Add(node.NodeCode, node.Data); } else { rightNodes.Add(node.NodeCode, node.Data); } } } dgv_right.DataSource = null; dgv_right.DataSource = rightNodes.Datas; dgv_left.DataSource = null; dgv_left.DataSource = leftNodes.Datas; }
//GET: TamcTymc/Edit/{id} public ActionResult Edit(int id) { TDetail detail = service.GetTById(id); TEdit model = new TEdit { TId = detail.TId, IsComplete = detail.IsComplete, DueOnDate = detail.DueOnDate, //CompletedOnDate = detail.CompletedOnDate //Should I add employee here? }; return(View(model)); }
public static BLLResult CreateDetail(TList list, TDetail detail, List <TNode> nodes) { var result = new BLLResult(); using (var connection = SQLiteHelper.Connect()) { connection.Open(); var transaction = connection.BeginTransaction(); try { list.DataCount = (short)list.Datas.Count; if (!list.DbInsertOrReplace(connection)) { throw new NotImplementedException("List数据未按预期存储"); } if (!detail.DbInsert(connection)) { throw new NotImplementedException("Detail数据未按预期存储"); } //nodes.DbDeleteByDetailKey(connection);//由于提交时,Nodes数量发生了变更,这里省略对原有Nodes数量删除的监测 if (!nodes.DbInsert(connection)) { throw new NotImplementedException("Nodes数据未按预期存储"); } //0711TODO KO 更新TNodeElement if (!nodes.Select(c => new TNodeElement(c.Segregation, c.NodeCode) { ElementIds = c.GetElementIds() }).DbInsertOrReplace(connection)) { throw new NotImplementedException("NodeElements数据未按预期存储"); } transaction.Commit(); } catch (Exception ex) { list.DataCount--; transaction.Rollback(); result.IsSuccess = false; result.Message = ex.ToString(); if (result.Message.Contains("constraint failed") && result.Message.Contains("TNode")) { result.Message = "导入的内容存在冲突,存在重复的测点"; } } connection.Close(); } return(result); }
public static void FetchNodes(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType))); command.CommandText = SQLiteHelper.GetSQLiteQuery_Select(null, new TNode().TableName, wheres); var reader = command.ExecuteReader(); while (reader.Read()) { entity.Nodes.Add(new TNode(reader)); } }
public TDetail Click <TDetail>() where TDetail : BaseComponent, new() { Retry.Do(Tile.Click); Wait.WaitForAjaxReady(By.CssSelector(".locking-mask")); var detail = default(TDetail); Retry.Do(() => { detail = new TDetail(); }); //Thread.Sleep(2000); detail.Refresh(); return(detail); }
public static void FetchDetails(this TList list, SQLiteConnection connection) { var command = connection.CreateCommand(); var detail = new TDetail(); List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue($"datetime({nameof(detail.IssueDateTime)},'start of day')", SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(list.IssueDate))); wheres.Add(new KeyOperatorValue(nameof(detail.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(list.IssueType))); command.CommandText = SQLiteHelper.GetSQLiteQuery_Select(null, detail.TableName, wheres); var reader = command.ExecuteReader(); while (reader.Read()) { list.Datas.Add(new TDetail(reader) { List = list }); } }
public TDetail Search <TDetail>() where TDetail : BaseComponent, new() { Retry.Do(_searchButton.Click); Wait.WaitUntilEnabled(By.CssSelector("[data-automation-id='search_criteria_submit']")); var detail = default(TDetail); Retry.Do(() => { detail = new TDetail(); }); Wait.WaitForAjaxReady(By.CssSelector(".locking-mask")); Wait.WaitForAjaxReady(By.CssSelector("[data-automation-id='search_criteria_submit'][disabled='disabled']")); detail.Refresh(); return(detail); }
public static void FetchDepthNodes(this TDetail entity, SQLiteConnection connection) { var command = connection.CreateCommand(); var node = new TDepthNode(); var nodeElement = new TDepthNodeElement(); string tableSuffix = "n."; List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.Segregation), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(UniqueIdHelper.UniqueIdStr))); wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.IssueDateTime), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(entity.IssueDateTime))); wheres.Add(new KeyOperatorValue(tableSuffix + nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(entity.IssueType))); //0711TODO KO 需增加ElementIds的关联表加载处理 command.CommandText = SQLiteHelper.GetSQLiteQuery_SelectWithJoin($"n.*,ne.{nameof(nodeElement.ElementIds)}", $"{node.TableName} n left join {nodeElement.TableName} ne on n.{nameof(node.Segregation)}=ne.{nameof(nodeElement.Segregation)} and n.{nameof(node.NodeCode)}=ne.{nameof(nodeElement.NodeCode)} and n.{nameof(node.Depth)}=ne.{nameof(nodeElement.Depth)}", wheres); var reader = command.ExecuteReader(); while (reader.Read()) { entity.DepthNodes.Add(new TDepthNode(reader)); } }
public static List <DateTimeValue> GetDateTimeValue(this TDetail entity, EIssueType issueType, DateTime startTime, int daySpan, SQLiteConnection connection) { var command = connection.CreateCommand(); List <string> selects = new List <string>(); selects.Add(nameof(entity.IssueDateTime)); selects.Add(nameof(entity.ExtraValue3)); List <KeyOperatorValue> wheres = new List <KeyOperatorValue>(); wheres.Add(new KeyOperatorValue(nameof(entity.Segregation), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString(UniqueIdHelper.UniqueIdStr))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueType), SQLiteOperater.Eq, SQLiteHelper.ToSQLiteString <EIssueType>(issueType))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.GTorEq, SQLiteHelper.ToSQLiteString(startTime))); wheres.Add(new KeyOperatorValue(nameof(entity.IssueDateTime), SQLiteOperater.LT, SQLiteHelper.ToSQLiteString(startTime.AddDays(daySpan + 10))));//+10作预留区间允许其中有个10天的空档 command.CommandText = SQLiteHelper.GetSQLiteQuery_Select(selects, entity.TableName, wheres); var reader = command.ExecuteReader(); List <DateTimeValue> results = new List <DateTimeValue>(); switch (issueType) { case EIssueType.钢支撑轴力监测: while (reader.Read()) { DateTimeValue data = new DateTimeValue(); var time = DateTime.Parse(reader[nameof(entity.IssueDateTime)].ToString()); data.DateTime = time; double value; if (double.TryParse(reader[nameof(entity.ExtraValue3)].ToString(), out value)) { data.Value = value; } results.Add(data); } break; default: break; } return(results); }
public static BLLResult UpdateDetail(TDetail detail, List <TDepthNode> depthNodes) { var result = new BLLResult(); using (var connection = SQLiteHelper.Connect()) { connection.Open(); var transaction = connection.BeginTransaction(); try { if (!detail.DbUpdate(connection)) { throw new NotImplementedException("Detail数据未按预期存储"); } if (!depthNodes.DbUpdate(connection)) { throw new NotImplementedException("Nodes数据未按预期存储"); } //0711TODO KO 更新TNodeElement if (!depthNodes.Select(c => new TDepthNodeElement(c.Segregation, c.NodeCode, c.Depth) { ElementIds = c.GetElementIds() }).DbInsertOrReplace(connection)) { throw new NotImplementedException("NodeElements数据未按预期存储"); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); result.IsSuccess = false; result.Message = ex.ToString(); } connection.Close(); } return(result); }
public static BLLResult CreateDetail(TList list, TDetail detail, List <TDepthNode> nodes) { var result = new BLLResult(); using (var connection = SQLiteHelper.Connect()) { connection.Open(); var transaction = connection.BeginTransaction(); try { list.DataCount = (short)list.Datas.Count; if (!list.DbInsertOrReplace(connection)) { throw new NotImplementedException("List数据未按预期存储"); } if (!detail.DbInsert(connection)) { throw new NotImplementedException("Detail数据未按预期存储"); } //nodes.DbDeleteByDetailKey(connection);//由于提交时,Nodes数量发生了变更,这里省略对原有Nodes数量删除的监测 if (!nodes.DbInsert(connection)) { throw new NotImplementedException("Nodes数据未按预期存储"); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); result.IsSuccess = false; result.Message = ex.ToString(); } connection.Close(); } return(result); }
public static BLLResult DeleteDetail(TList list, TDetail detail, List <TDepthNode> nodes) { var result = new BLLResult(); using (var connection = SQLiteHelper.Connect()) { connection.Open(); var transaction = connection.BeginTransaction(); try { if (!detail.DbDelete(connection)) { throw new NotImplementedException("Detail数据未成功删除"); } if (!nodes.DbDeleteByDetailKey(connection)) { throw new NotImplementedException("Nodes数据未成功删除"); } list.Datas.Remove(detail); list.DataCount = (short)list.Datas.Count(); if (!list.DbUpdate(connection)) { throw new NotImplementedException("List数据未成功更新"); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); result.IsSuccess = false; result.Message = ex.ToString(); } connection.Close(); } return(result); }
//GET: TamcTymc/Details/{id} public ActionResult Details(int id) { TDetail model = service.GetTById(id); return(View(model)); }