public static dynamic GetTSObject(Seam dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
private static PdfPTable CreateBeamParamsTable(Seam seam) { var paramsTable = new PdfPTable(1); paramsTable.AddCell(new PdfPCell(new Phrase("电子束焊工艺参数", ChFont)) { BorderWidth = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER }); var paramsTable1 = new PdfPTable(8); var paramList = seam.RevisedParams.Select(x => (SeamParam)x).ToList(); if (!paramList.Any()) { paramList = seam.InitialParams.Select(x => (SeamParam)x).ToList(); } var paramDict = paramList.ToDictionary(x => x.Enum); paramsTable1.AddCell(Crtc("加速电压(kV)", 2, 1)); paramsTable1.AddCell(Crtc("电子束流(mA)", 2, 1)); paramsTable1.AddCell(Crtc("焊接速度(cm/min)", 2, 1)); paramsTable1.AddCell(Crtc("聚焦电流(mA)", 2, 1)); paramsTable1.AddCell(Crtc("工作距离(mm)", 2, 1)); paramsTable1.AddCell(Crtc("束流斜率控制(S)", 1, 2)); paramsTable1.AddCell(Crtc("焊接真空度(Pa)", 2, 1)); paramsTable1.AddCell(Crtc("上升")); paramsTable1.AddCell(Crtc("下降")); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.加速电压))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.电子束流))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接速度))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.聚焦电流))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.工作距离))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.升))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.降))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接真空度))); paramsTable1.AddCell(Crtc("电子束扫描及偏转", 1, 6)); paramsTable1.AddCell(Crtc("", 3, 2)); paramsTable1.AddCell(Crtc("波形", 1, 2)); paramsTable1.AddCell(Crtc("幅值", 1, 2)); paramsTable1.AddCell(Crtc("频率", 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.波形), 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.幅值), 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.频率), 1, 2)); paramsTable.AddCell(new PdfPCell(paramsTable1) { BorderWidthRight = 0, BorderWidthBottom = 0 }); return(paramsTable); }
private void createSeamOfMultipleParts(string name, int number) { Seam seam = new Seam(); seam.Name = name; seam.Number = number; Picker picker = new Picker(); try { seam.SetPrimaryObject(picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART, "Wybierz element główny")); ModelObjectEnumerator partsEnumerator = picker.PickObjects(Picker.PickObjectsEnum.PICK_N_OBJECTS, "Wybierz elementy podrzędne"); ArrayList secondaryParts = new ArrayList(); foreach (ModelObject modelObject in partsEnumerator) { secondaryParts.Add(modelObject); } seam.SetSecondaryObjects(secondaryParts); seam.SetInputPositions(picker.PickPoint(), picker.PickPoint()); } catch (ApplicationException ex) { Operation.DisplayPrompt("Przerwano operację"); return; } if (number != BaseComponent.CUSTOM_OBJECT_NUMBER) { seam.Insert(); } else { try { if (isExisting(seam)) { seam.Insert(); } else { importCustomComponent(seam); seam.Insert(); } } catch (Exception ex) { MessageBox.Show("Nie udało się wstawić komponentu", "Error"); } } MyModel.CommitChanges(); }
private static PdfPTable CreateBrazeParamsTable(Seam seam) { var paramsTable = new PdfPTable(1); paramsTable.AddCell(new PdfPCell(new Phrase("高频钎焊工艺参数", ChFont)) { BorderWidth = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER }); var paramsTable1 = new PdfPTable(6); var paramList = seam.RevisedParams.Select(x => (SeamParam)x).ToList(); if (!paramList.Any()) { paramList = seam.InitialParams.Select(x => (SeamParam)x).ToList(); } var paramDict = paramList.ToDictionary(x => x.Enum); paramsTable1.AddCell(Crtc("钎料牌号")); paramsTable1.AddCell(Crtc("填料规格")); paramsTable1.AddCell(Crtc("焊接电压")); paramsTable1.AddCell(Crtc("氩气流量")); paramsTable1.AddCell(Crtc("感应圈编号")); paramsTable1.AddCell(Crtc("管子规格")); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.填充材料牌号))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.填充材料规格))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接电压))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.氩气流量))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.感应圈编号))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.管子规格))); paramsTable.AddCell(new PdfPCell(paramsTable1) { BorderWidthRight = 0, BorderWidthBottom = 0 }); return(paramsTable); }
private static PdfPTable CreateParamsTable(WeldMethod method, Seam seam) { switch (method) { case WeldMethod.氩弧焊: return(CreateTigParamsTable(seam)); case WeldMethod.电子束焊: return(CreateBeamParamsTable(seam)); case WeldMethod.电阻焊: return(CreateResistParamsTable(seam)); case WeldMethod.高频钎焊: return(CreateBrazeParamsTable(seam)); //case WeldMethod.等离子焊: // break; default: throw new ArgumentOutOfRangeException(nameof(method), method, null); } return(new PdfPTable(1)); }
public ActionResult AddSeam(AddSeamModel model, int prid) { var db = new Context(); var userId = Session.GetSessionUser().Id; var procedure = db.Procedures.Include(x => x.Seams).SingleOrDefault(x => x.Id == prid); if (procedure == null) { return(Json(new { succeed = false, error = "指定工序不存在" })); } if (model.JointForm != JointForm.堆焊) { if (!ModelState.IsValid) { if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } if (procedure.WeldMethod == WeldMethod.电子束焊) { return(AddSeam(false, false)); } if (procedure.WeldMethod == WeldMethod.高频钎焊) { return(AddSeam(false, false)); } } if (model.Material3 != null && model.Material3.Trim() != "" && model.Thick3 == null) { ModelState.AddModelError("Thick3", "Thick3 Required"); if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } } if (model.Thick3 != null && (model.Material3 == null || model.Material3.Trim() == "")) { ModelState.AddModelError("Material3", "Material3 Required"); if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } } if (model.Material4 != null && model.Material4.Trim() != "" && model.Thick4 == null) { ModelState.AddModelError("Thick4", "Thick4 Required"); if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } } if (model.Thick4 != null && (model.Material4 == null || model.Material4.Trim() == "")) { ModelState.AddModelError("Material4", "Material4 Required"); if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } } } if (procedure.Seams.Exists(x => x.No == model.No)) { ModelState.AddModelError("Error", "相同编号的焊缝已经存在"); if (procedure.WeldMethod == WeldMethod.氩弧焊) { if (procedure.AutoLevel == AutoLevel.手工) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.手工)); } if (procedure.AutoLevel == AutoLevel.自动) { return(AddSeams(procedure.WeldMethod == WeldMethod.氩弧焊, procedure.AutoLevel == AutoLevel.自动)); } } if (procedure.WeldMethod == WeldMethod.电阻焊) { return(AddSeam(procedure.WeldMethod == WeldMethod.电阻焊, procedure.ResistType == ResistType.点焊)); } if (procedure.WeldMethod == WeldMethod.电子束焊) { return(AddSeam(false, false)); } if (procedure.WeldMethod == WeldMethod.高频钎焊) { return(AddSeam(false, false)); } } var seam = new Seam { No = model.No, TestState = TestState.尚未进行, JointForm = model.JointForm, SeamLevel = model.SeamLevel, CheckStandard = model.CheckStandard, Material1 = model.Material1, Material2 = model.Material2, Material3 = model.Material3, Material4 = model.Material4, Thick1 = model.Thick1, Thick2 = model.Thick2, Thick3 = model.Thick3, Thick4 = model.Thick4, Gap = model.Gap, WeldMachineClass = model.WeldMachineClass, ElectrodeDiameter = model.ElectrodeDiameter }; procedure.Seams.Add(seam); db.SaveChanges(); return(Json(new { succeed = true })); }
public static IEnumerable <Process> Import(string path) { OdbcConnection conn = null; var db = new Context(); try { string strConn; if (GlobalData.Excel32) { strConn = "Driver={Microsoft Excel Driver (*.xls)};Dbq=" + path + ";"; } else { strConn = "Driver={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};Dbq=" + path + ";"; } conn = new OdbcConnection(strConn); conn.Open(); var processDict = new Dictionary <string, Process>(); foreach (WeldMethod m in Enum.GetValues(typeof(WeldMethod))) { var ds = new DataSet(); try { var cmd = new OdbcDataAdapter("select * from [" + m + "$]", strConn); cmd.Fill(ds); } catch (Exception) { continue; } foreach (DataColumn col in ds.Tables[0].Columns) { var idx1 = col.ColumnName.IndexOf('('); var idx2 = col.ColumnName.IndexOf('('); var idx = idx1; if (idx < 0) { idx = idx2; } else if (idx2 > 0 && idx2 < idx1) { idx = idx2; } if (idx > 0) { col.ColumnName = col.ColumnName.Substring(0, idx); } } var line = 2; try { foreach (DataRow dr in ds.Tables[0].Rows) { Process process; var processNo = dr["工艺规程编号"].GetDbString(); var userId = dr["编制者"].GetDbString(); var user = db.Users.SingleOrDefault(x => x.Id == userId || x.Name == userId); //if (user==null) //{ // user=new User // { // Id = DateTime.Now.ToString(), // Name = "none person", // Position = WorkPosition.焊接工程师, // Password = "******".Md532(), // Department = "燃烧部件制造分厂", // AuthorityRs = new[] { Authority.编制 }.ToAuthorityRs() // }; //} if (!processDict.TryGetValue(processNo, out process)) { process = new Process { No = processNo, // PartNo = PartNo, //PartName=PartName, PartNo = dr["零件号"].GetDbString(), PartName = dr["零件名称"].GetDbString(), TestState = ProgramTestState.未完成, ApprovalState = ApprovalState.未提交审核, Version = 1, Author = user, Procedures = new List <Procedure>() }; processDict.Add(processNo, process); } var procedureNo = dr["工序号"].GetDbString(); var procedureName = dr["工序名称"].GetDbString(); var procedure = process.Procedures.Find(x => x.No == procedureNo); if (processNo.Trim() == "" || procedureNo.Trim() == "") { continue; //throw new Exception(m + ",第" + line + "行," + "工艺规程编号为空!"); } if (procedure == null) { procedure = new Procedure { No = procedureNo, Name = procedureName, WeldMethod = m, WeldType = dr["焊接类型"].GetDbEnum <WeldType>(), Seams = new List <Seam>() }; process.Procedures.Add(procedure); } if (m == WeldMethod.电阻焊) { string sa = dr["焊接方式"].GetDbString(); string s = dr["焊接方式"].GetDbEnum <ResistType>().ToString(); procedure.ResistType = dr["焊接方式"].GetDbEnum <ResistType>(); } if (m == WeldMethod.氩弧焊) { procedure.AutoLevel = dr["自动化程度"].GetDbEnum <AutoLevel>(); } var seam = new Seam { No = (procedure.Seams.Count + 1).ToString(), TestState = TestState.尚未进行, CheckStandard = dr["验收标准"].GetDbString(), SeamLevel = dr["焊缝等级"].GetDbEnum <SeamLevel>(), JointForm = dr["接头形式"].GetDbEnum <JointForm>(), FillWire = dr["是否填丝"].GetDbString() == "是", Material1 = dr["材料牌号1"].GetDbString(), Material2 = dr["材料牌号2"].GetDbString() }; double thick1, thick2; if (!dr["材料规格1"].GetDbDouble(out thick1)) { throw new Exception("\"材料规格1\"必须为数字"); } if (!dr["材料规格2"].GetDbDouble(out thick2)) { throw new Exception("\"材料规格2\"必须为数字"); } seam.Thick1 = thick1; seam.Thick2 = thick2; if (m == WeldMethod.电阻焊 || m == WeldMethod.氩弧焊) { seam.Material3 = dr["材料牌号3"].GetDbString(); if (seam.Material3 != "") { double thick3; if (!dr["材料规格3"].GetDbDouble(out thick3)) { throw new Exception("\"材料规格3\"必须为数字"); } seam.Thick3 = thick3; } seam.Material4 = dr["材料牌号4"].GetDbString(); if (seam.Material4 != "") { double thick4; if (!dr["材料规格4"].GetDbDouble(out thick4)) { throw new Exception("\"材料规格4\"必须为数字"); } seam.Thick4 = thick4; } seam.ElectrodeDiameter = dr["电极直径/滚轮宽度"].GetDbString(); seam.WeldMachineClass = dr["焊机型别"].GetDbString(); } seam.SpecialReportFileNo = dr["特殊过程确认报告编号"].GetDbString(); procedure.Seams.Add(seam); switch (m) { case WeldMethod.氩弧焊: seam.CoverReportFileNo = dr["涵盖报告编号"].GetDbString(); seam.InitialParams = FillTigParam(dr); break; case WeldMethod.电阻焊: seam.InitialParams = FillResistParam(dr); break; case WeldMethod.电子束焊: seam.InitialParams = FillBeamParam(dr); break; case WeldMethod.高频钎焊: seam.InitialParams = FillBrazeParam(dr); break; default: throw new ArgumentOutOfRangeException(); } line++; } } catch (Exception e) { Log.Error(e.StackTrace); throw new Exception(m + ",第" + line + "行," + e.Message); } } return(processDict.Values); } finally { if (conn != null) { conn.Close(); } } }
private static PdfPTable CreateTigParamsTable(Seam seam) { var paramsTable = new PdfPTable(1); paramsTable.AddCell(new PdfPCell(new Phrase("熔焊工艺参数", ChFont)) { BorderWidth = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER }); var paramsTable1 = new PdfPTable(6); var paramList = seam.RevisedParams.Select(x => (SeamParam)x).ToList(); if (!paramList.Any()) { paramList = seam.InitialParams.Select(x => (SeamParam)x).ToList(); } var paramDict = paramList.ToDictionary(x => x.Enum); paramsTable1.AddCell(Crtc("焊接电流(A)", 2, 1)); paramsTable1.AddCell(Crtc("焊接速度(m/min)", 2, 1)); paramsTable1.AddCell(Crtc("氩气流量", 1, 2)); paramsTable1.AddCell(Crtc("电流衰减(s)", 2, 1)); paramsTable1.AddCell(Crtc("保护气滞后(m/s)", 2, 1)); paramsTable1.AddCell(Crtc("正面(L/min)")); paramsTable1.AddCell(Crtc("反面(L/min)")); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接电流))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接速度))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.氩气流量正面))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.氩气流量反面))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.电流衰减))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.保护气滞后))); paramsTable.AddCell(new PdfPCell(paramsTable1) { BorderWidthRight = 0, BorderWidthBottom = 0 }); var paramsTable2 = new PdfPTable(5); paramsTable2.SetWidths(new[] { 0.32f, 0.2f, 0.16f, 0.16f, 0.16f }); paramsTable2.AddCell(Crtc("填充材料牌号")); paramsTable2.AddCell(Crtc("填充材料规格")); paramsTable2.AddCell(Crtc("送丝速度(m/s)")); paramsTable2.AddCell(Crtc("钨极直径(mm)")); paramsTable2.AddCell(Crtc("喷嘴直径(mm)")); paramsTable2.AddCell(Crtc(GetValue(paramDict, WeldParam.填充材料牌号))); paramsTable2.AddCell(Crtc(GetValue(paramDict, WeldParam.填充材料规格))); paramsTable2.AddCell(Crtc(GetValue(paramDict, WeldParam.送丝速度))); paramsTable2.AddCell(Crtc(GetValue(paramDict, WeldParam.钨极直径))); paramsTable2.AddCell(Crtc(GetValue(paramDict, WeldParam.喷嘴直径))); paramsTable.AddCell(new PdfPCell(paramsTable2) { BorderWidthRight = 0, BorderWidthBottom = 0, BorderWidthTop = 0 }); return(paramsTable); }
private static PdfPTable CreateResistParamsTable(Seam seam) { var paramsTable = new PdfPTable(1); paramsTable.AddCell(new PdfPCell(new Phrase("电阻焊工艺参数", ChFont)) { BorderWidth = 0, PaddingBottom = 10, HorizontalAlignment = Element.ALIGN_CENTER }); var paramsTable1 = new PdfPTable(7); var paramList = seam.RevisedParams.Select(x => (SeamParam)x).ToList(); if (!paramList.Any()) { paramList = seam.InitialParams.Select(x => (SeamParam)x).ToList(); } var paramDict = paramList.ToDictionary(x => x.Enum); paramsTable1.AddCell(Crtc("焊机型别", 2, 2)); paramsTable1.AddCell(Crtc("电极直径/滚轮宽度(mm)", 2, 1)); paramsTable1.AddCell(Crtc("功率级数", 2, 1)); paramsTable1.AddCell(Crtc("预压(ms)", 2, 1)); paramsTable1.AddCell(Crtc("电极压力(Kpa)", 1, 2)); paramsTable1.AddCell(Crtc("抬起")); paramsTable1.AddCell(Crtc("压下")); //paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.焊机型别), 1, 2)); //paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.电极直径滚轮宽度))); paramsTable1.AddCell(Crtc(seam.WeldMachineClass, 1, 2)); paramsTable1.AddCell(Crtc(seam.ElectrodeDiameter)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.功率级数))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.预压))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.抬起))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.压下))); paramsTable1.AddCell(Crtc("脉冲1(ms)")); paramsTable1.AddCell(Crtc("焊接电流1(A)")); paramsTable1.AddCell(Crtc("冷却(ms)")); paramsTable1.AddCell(Crtc("脉冲2(ms)")); paramsTable1.AddCell(Crtc("焊接电流2(A)")); paramsTable1.AddCell(Crtc("维持(ms)")); paramsTable1.AddCell(Crtc("休止(ms)")); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.冲1))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接电流1))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.冷却))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.冲2))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接电流2))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.维持))); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.休止))); paramsTable1.AddCell(Crtc("气压(Kpa)", 1, 4)); paramsTable1.AddCell(Crtc("焊接速度(m/min)", 2, 2)); paramsTable1.AddCell(Crtc("焊点直径", 2, 1)); paramsTable1.AddCell(Crtc("下气室", 1, 2)); paramsTable1.AddCell(Crtc("中气室", 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.气室气压), 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.中气室气压), 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.接速度), 1, 2)); paramsTable1.AddCell(Crtc(GetValue(paramDict, WeldParam.熔核直径))); paramsTable.AddCell(new PdfPCell(paramsTable1) { BorderWidthRight = 0, BorderWidthBottom = 0 }); return(paramsTable); }
public ActionResult ImportWcapp(HttpPostedFileBase file) { try { var processes = new WcappFile(file.InputStream).ToProcesses(); var db = new Context(); List <string> existProcesses = new List <string>(); // TODO 将processes更新到数据库 //IsDeviceNet为true设备网 if (GlobalData.IsDeviceNet) { foreach (var proce in processes) { var process = db.Processes.SingleOrDefault(x => x.No == proce.No && x.Version == proce.Version); if (process != null) { //相同编号工艺规程编号的同一版本不能重复导入 existProcesses.Add($"{process.No}({process.VersionString})"); continue; } if (proce.Author == null) { return(Json(new { succeed = false, error = "请指定导入的Wcapp文件编制者" }, "text/html")); } var author = db.Users.Find(proce.Author.Id); process = new Process { PdmId = proce.No, No = proce.No, PartNo = proce.PartNo, PartName = proce.PartName, Author = author, ApprovalState = proce.ApprovalState, TestState = proce.TestState, Version = proce.Version, Procedures = new List <Procedure>() }; foreach (var procedure in proce.Procedures) { var proc = new Procedure { PdmId = procedure.No, No = procedure.No, Name = procedure.Name, WeldMethod = procedure.WeldMethod, WeldType = procedure.WeldType, ResistType = procedure.ResistType, AutoLevel = procedure.AutoLevel, TestState = procedure.TestState, Seams = new List <Seam>() }; foreach (var seam in procedure.Seams) { var ns = new Seam { No = seam.No, TestState = seam.TestState, JointForm = seam.JointForm, SeamLevel = seam.SeamLevel, CheckStandard = seam.CheckStandard, Material1 = seam.Material1, Material2 = seam.Material2, Material3 = seam.Material3, Thick1 = seam.Thick1, Thick2 = seam.Thick2, Thick3 = seam.Thick3, Gap = seam.Gap, InitialParams = new List <SeamParam1>(), RevisedParams = new List <SeamParam2>() }; foreach (var param in seam.InitialParams) { var npm = new SeamParam1 { Enum = param.Enum, Value = param.Value }; ns.InitialParams.Add(npm); } foreach (var param in seam.RevisedParams) { var npm = new SeamParam2 { Enum = param.Enum, Value = param.Value }; ns.RevisedParams.Add(npm); } proc.Seams.Add(ns); } process.Procedures.Add(proc); } db.Processes.Add(process); db.SaveChanges(); } } else // 导入到内网 { foreach (var proce in processes) { var processDb = db.Processes.Include("Procedures.Seams.RevisedParams").SingleOrDefault(x => x.No == proce.No && x.Version == proce.Version); //var processDbs = db.Processes.SingleOrDefault(x => x.No == proce.No && x.Version == proce.Version); if (processDb == null) { return(Json(new { succeed = false, error = "零件编号的工艺规程不存在" }, "text/html")); } if (!proce.Published) { return(Json(new { succeed = false, error = "状态未发布" }, "text/html")); } processDb.Published = proce.Published; if (proce.TestState != ProgramTestState.已完成) { return(Json(new { succeed = false, error = "试焊状态未完成" }, "text/html")); } processDb.TestState = proce.TestState; foreach (var procedure in proce.Procedures) { var prodedureDb = processDb.Procedures.SingleOrDefault(x => x.No == procedure.No); if (prodedureDb.TestState != ProgramTestState.已完成) { return(Json(new { succeed = false, error = "试焊状态未完成" }, "text/html")); } prodedureDb.TestState = procedure.TestState; foreach (var seam in procedure.Seams) { var seamDb = prodedureDb.Seams.SingleOrDefault(x => x.No == procedure.No); if (seamDb.TestState != TestState.已完成) { return(Json(new { succeed = false, error = "试焊状态未完成" }, "text/html")); } seamDb.TestState = seam.TestState; if (seamDb.RevisedParams.Any()) { return(Json(new { succeed = false, error = "试焊状态未完成" }, "text/html")); } foreach (var param in seam.RevisedParams) { seamDb.RevisedParams.Add(new Models.Database.SeamParam2 { Enum = param.Enum, Value = param.Value }); } } } db.SaveChanges(); } } if (existProcesses.Any()) { return(Json(new { succeed = true, existProcesses }, "text/html")); } else { return(Json(new { succeed = true }, "text/html")); } } catch (Exception e) { Log.Error(e.StackTrace); return(Json(new { succeed = false, error = e.Message }, "text/html")); } }