public void InsertCode(CodeDto dto) { var strSql = "INSERT INTO code(Id,oldcode,newcode) VALUES('" + dto.Id + "','" + dto.OldCode + "','" + dto.NewCode + "')"; MysqlDBUtil.ExecuteSql(strSql); }
/// <summary> /// 添加新的图纸编号 /// </summary> /// <param name="dto"></param> public static void InsertCode(CodeDto dto) { //MysqlOperate operate = new MysqlOperate(); operate.InsertCode(dto); }
private void UpdateCAD() { var showInfo = ""; var fileStaus = ""; if (string.IsNullOrEmpty(txtSavePath.Text)) { MessageBox.Show("请选择文件保存位置!", "提示信息"); return; } var FilePath = ""; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); for (int k = 0; k < lvwList.Items.Count; k++) { lblTips.Text = "当前共有: " + lvwList.Items.Count + " 张图纸需要处理,现在正在处理第 " + (k + 1) + " 张"; FilePath = lvwList.Items[k].ToString(); AcadDoc = acAppComObj.Documents.Open(FilePath, null, null); acAppComObj.Application.Visible = false; AcadBlocks blocks = AcadDoc.Blocks; HistoryDto dto = new HistoryDto(); CodeDto codeDto = new CodeDto(); dto.Id = Guid.NewGuid().ToString(); dto.FileName = AcadDoc.Name; dto.FilePath = FilePath; try { foreach (AcadBlock block in blocks) { foreach (AcadEntity entity in block) { list.Add(entity.ObjectName); ////1.替换基本属性 //Util.ReplaceProperty(entity); ////2.替换装配图的明细表编号 //Util.ReplaceDrawingCode(entity, acAppComObj); //entity.Update(); } } fileStaus = "图纸处理完成"; dto.FileStatus = fileStaus; //3.处理情况保存 //InsertHistory(dto); codeDto.Id = Guid.NewGuid().ToString(); codeDto.OldCode = Util.oldCode; codeDto.NewCode = Util.newCode; //InsertCode(codeDto); } catch (Exception ex) { fileStaus = "图纸处理异常,异常原因:" + ex.Message; dto.FileStatus = fileStaus; //3.处理情况保存 //InsertHistory(dto); continue; } dto.FileStatus = fileStaus; //判断是否需要保存,如需要则另存为 if (acAppComObj.ActiveDocument.Saved == false) { acAppComObj.ActiveDocument.SaveAs(txtSavePath.Text + "\\" + Util.newCode, AcSaveAsType.ac2013_dwg, null); GC.Collect(); } } stopwatch.Stop(); // 停止监视 TimeSpan timespan = stopwatch.Elapsed; // 获取当前实例测量得出的总时间 double hours = timespan.TotalHours; // 总小时 double minutes = timespan.TotalMinutes; // 总分钟 double seconds = timespan.TotalSeconds; // 总秒数 double milliseconds = timespan.TotalMilliseconds; // 总毫秒数 lvwList.DataSource = list; MessageBox.Show(fileStaus); //MessageBox.Show("图纸修改完成,修改所花时间为:" + seconds.ToString()); MessageBox.Show(showInfo); }
void InsertCode(CodeDto dto) { MysqlOperate operate = new MysqlOperate(); operate.InsertCode(dto); }