/// <summary> /// ImplantPlanning專案排序(依創建日期) /// </summary> /// <param name="array">專案陣列</param> /// <param name="left">輸入0</param> /// <param name="right">輸入array.count()-1</param> /// <param name="FirstIn">輸入true</param> public void Sort_Implant(List <ImplantOuterInformation> array, int left, int right, bool FirstIn) { if (FirstIn == true) { Filter_Implant(array, ref right); } if (left < right) { int i = left - 1; //left margin int j = right + 1; //right margin ImplantOuterInformation axle = array[(left + right) / 2]; //axle while (true) { while (array[++i].CreateDate > axle.CreateDate) { ; } while (array[--j].CreateDate < axle.CreateDate) { ; } if (i >= j) { break; } Swap_ImplantCase(array, i, j); } Sort_Implant(array, left, (i - 1), false); Sort_Implant(array, (j + 1), right, false); } }
private void Swap_ImplantCase(List <ImplantOuterInformation> array, int left, int right) { ImplantOuterInformation tmpCase = array[left]; array[left] = array[right]; array[right] = tmpCase; }
/// <summary> /// 設定Detail顯示資訊 /// </summary> /// <param name="importOuter">要匯入的ImplantOuterInformation</param> /// <param name="Import">要匯入的ImplantSmallInformation</param> public void SetDetailInfo(ImplantOuterInformation importOuter, ImplantSmallCaseInformation Import) { implantOuterInfo = importOuter; implantInfo = Import; textbox_Order.Text = implantOuterInfo.OrderNumber; textbox_Patient.Text = implantOuterInfo.PatientName; textbox_Gender.Text = implantOuterInfo.Gender ? TranslationSource.Instance["Male"] : TranslationSource.Instance["Female"]; if (implantOuterInfo.PatientBirth != new DateTime()) { int patientAge = DateTime.Today.Year - implantOuterInfo.PatientBirth.Year; textbox_Age.Text = patientAge.ToString(); } textbox_Clinic.Text = implantOuterInfo.Clinic; textbox_SurgicalGT.Text = implantOuterInfo.SurgicalGuide; textbox_SurgicalKit.Text = implantOuterInfo.Surgicalkit; string JpgPath = importOuter.XmlfilePath.Remove(importOuter.XmlfilePath.Length - 4) + ".jpg"; if (File.Exists(implantInfo.GuideModelPath) != true) { button_openDir.IsEnabled = false; } else { button_openDir.IsEnabled = true; } if (File.Exists(implantInfo.PDFpath) != true) { button_openPDF.IsEnabled = false; } else { button_openPDF.IsEnabled = true; } if (Properties.Settings.Default.guide_exePath == "") { button_loadGuide.IsEnabled = false; } textbox_toothProductInfo.Text = ""; if (implantInfo.List_ImplantToothInfo != null && implantInfo.List_ImplantToothInfo.Count > 0) { //有植體資料 foreach (var item in implantInfo.List_ImplantToothInfo) { string ToothNumber = item.ToothID.ToString(); string ToothProduct = item.Implant_Company + "(" + item.Implant_System + ")"; textbox_toothProductInfo.Text += "Tooth_" + ToothNumber + ":" + ToothProduct + '\n'; } } }
/// <summary> /// 讀各專案Xml檔內的資料 /// </summary> /// <param name="SoftwareID">軟體ID 參考_SoftwareID</param> /// <param name="XmlPath">Xml路徑</param> /// <returns></returns> private bool LoadXml(int SoftwareID, string XmlPath) { XDocument xmlDoc; FileInfo fInfo = new FileInfo(XmlPath);//要取得檔案創建日期和修改日期 try { xmlDoc = XDocument.Load(XmlPath); } catch { return(false); } switch (SoftwareID) { case (int)_softwareID.EZCAD: { //判斷是否為Material的XML if (xmlDoc.Element("OrderExport") == null) { return(false); } try { XElement xml = xmlDoc.Element("OrderExport"); string xOrderID = xml.Element("OrderInfo").Element("OrderID").Value; //ordernumer-custom string xClient = xml.Element("OrderInfo").Element("Client").Value; //Client string xTechnician = xml.Element("OrderInfo").Element("Technician").Value; //Technicain string xPatient = xml.Element("OrderInfo").Element("Patient").Value; //patient string xOrderNote = xml.Element("OrderInfo").Element("Note").Value; //Note string xDesignStep = xml.Element("DesignInfo").Element("DesignStep").Value; //DesignStep string xVersion = xml.Element("DesignInfo").Element("Version").Value; //Version CadInformation cadInfo = new CadInformation { OrderID = xOrderID, PatientName = xPatient, CreateDate = fInfo.CreationTime, ModifyDate = fInfo.LastWriteTime, DesignStep = Convert.ToInt32(xDesignStep), CaseDirectoryPath = Path.GetDirectoryName(XmlPath), CaseXmlPath = XmlPath, Client = xClient, Technician = xTechnician, Note = xOrderNote, CADversion = new Version(xVersion) }; Caselist_EZCAD.Add(cadInfo); return(true); } catch (Exception ex) { log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "ProjectHandle.cs LoadXml(EZCAD) Exception", ex.Message); return(false); } } case (int)_softwareID.Implant: { if (xmlDoc.Element("ImplantOrderExport") == null) { return(false); } try { XElement xml = xmlDoc.Element("ImplantOrderExport"); ImplantOuterInformation tmpImpOuterInfo = new ImplantOuterInformation { OrderNumber = xml.Element("OrderInfo").Element("OrderNo").Value, PatientName = xml.Element("OrderInfo").Element("PatientName").Value, CaseDirectoryPath = Path.GetDirectoryName(XmlPath) + @"\", CreateDate = fInfo.CreationTime, ModifyDate = fInfo.LastWriteTime }; try { if (xml.Element("OrderInfo").Element("PatientGender").Value.ToLower() == "male") { tmpImpOuterInfo.Gender = true; } else { tmpImpOuterInfo.Gender = false; } } catch { tmpImpOuterInfo.Gender = false; } try { string pbirthday = xml.Element("OrderInfo").Element("PatientBirthday").Value + "T00:00:00"; tmpImpOuterInfo.PatientBirth = Convert.ToDateTime(pbirthday); } catch { tmpImpOuterInfo.PatientBirth = new DateTime(); } try { tmpImpOuterInfo.Clinic = xml.Element("OrderInfo").Element("Clinic").Value; } catch { tmpImpOuterInfo.Clinic = ""; } try { tmpImpOuterInfo.Note = xml.Element("OrderInfo").Element("Note").Value; } catch { tmpImpOuterInfo.Note = ""; } try { tmpImpOuterInfo.SurgicalGoal = xml.Element("CaseInfo").Element("SurgicalGoal").Value; } catch { tmpImpOuterInfo.SurgicalGoal = ""; } try { tmpImpOuterInfo.SurgicalGuide = xml.Element("CaseInfo").Element("SurgicalGuide").Value; } catch { tmpImpOuterInfo.SurgicalGuide = ""; } try { tmpImpOuterInfo.SurgicalOption = xml.Element("CaseInfo").Element("SurgicalOption").Value; } catch { tmpImpOuterInfo.SurgicalOption = ""; } try { tmpImpOuterInfo.Surgicalkit = xml.Element("CaseInfo").Element("Surgicalkit").Value; } catch { tmpImpOuterInfo.Surgicalkit = ""; } try { tmpImpOuterInfo.CBCTPath = xml.Element("ImageData").Element("CBCTPath").Value; } catch { tmpImpOuterInfo.CBCTPath = ""; } try { tmpImpOuterInfo.JawPath = xml.Element("ImageData").Element("JawPath").Value; } catch { tmpImpOuterInfo.JawPath = ""; } try { tmpImpOuterInfo.JawTrayPath = xml.Element("ImageData").Element("JawTrayPath").Value; } catch { tmpImpOuterInfo.JawTrayPath = ""; } try { tmpImpOuterInfo.DenturePath = xml.Element("ImageData").Element("DenturePath").Value; } catch { tmpImpOuterInfo.DenturePath = ""; } tmpImpOuterInfo.XmlfilePath = XmlPath; Caselist_ImplantOuterCase.Add(tmpImpOuterInfo); return(true); } catch (Exception ex) { log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "ProjectHandle.cs LoadXml(Implant) Exception", ex.Message); return(false); } } case (int)_softwareID.Ortho: { if (xmlDoc.Element("CreateProjectInfo") == null) { return(false); } try { XElement xml = xmlDoc.Element("CreateProjectInfo"); bool Gender = false; try { if (xml.Element("PatientSex").Value.ToLower() == "true" || xml.Element("PatientSex").Value.ToLower() == "1") { Gender = true; } else { Gender = false; } } catch { } OrthoOuterInformation orthoInfo = new OrthoOuterInformation { CaseDirectoryPath = Path.GetDirectoryName(XmlPath) + @"\", PatientID = xml.Element("PatientID").Value, PatientName = xml.Element("PatientName").Value, PatientSex = Gender }; try { orthoInfo.PatientBirth = Convert.ToDateTime(xml.Element("PatientBday").Value); } catch { orthoInfo.PatientBirth = new DateTime(); } try { orthoInfo.PatientAddress = xml.Element("PatientAddress").Value; } catch { orthoInfo.PatientAddress = ""; } try { orthoInfo.DentistName = xml.Element("DentistName").Value; } catch { orthoInfo.DentistName = ""; } try { orthoInfo.ClinicName = xml.Element("ClinicName").Value; } catch { orthoInfo.ClinicName = ""; } try { orthoInfo.CreateDate = Convert.ToDateTime(xml.Element("CreateTime")?.Value); } catch { orthoInfo.CreateDate = fInfo.CreationTime; } Caselist_OrthoOuterCase.Add(orthoInfo); return(true); } catch (Exception ex) { log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "ProjectHandle.cs LoadouterXml(Ortho) Exception", ex.Message); return(false); } } case (int)_softwareID.Tray: { if (xmlDoc.Element("GuideExport") == null) { return(false); } try { XElement xml = xmlDoc.Element("GuideExport"); string xGuideType = xml.Element("OrderInfo").Element("GuideType").Value; string xDesignStep = xml.Element("OrderInfo").Element("DesignStep").Value; //DesignStep string xOrderID = xml.Element("ProjectName").Value; //ordernumer-custom TrayInformation trayInfo = new TrayInformation { OrderID = xOrderID, Brand = xml.Element("OrderInfo").Element("Brand").Value, CreateDate = fInfo.CreationTime, ModifyDate = fInfo.LastWriteTime, GuideType = Convert.ToInt16(xGuideType), DesignStep = Convert.ToInt32(xDesignStep), CaseDirectoryPath = Path.GetDirectoryName(XmlPath), CaseXmlPath = XmlPath }; Caselist_Tray.Add(trayInfo); return(true); } catch (Exception ex) { log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "ProjectHandle.cs LoadXml(Tray) Exception", ex.Message); return(false); } } case (int)_softwareID.Splint: { if (xmlDoc.Element("GuideExport") == null) { return(false); } try { XElement xml = xmlDoc.Element("GuideExport"); string xGuideType = xml.Element("OrderInfo").Element("GuideType").Value; string xDesignStep = xml.Element("OrderInfo").Element("DesignStep").Value; //DesignStep string xOrderID = xml.Element("ProjectName").Value; //ordernumer-custom SplintInformation splintInfo = new SplintInformation { OrderID = xOrderID, Brand = xml.Element("OrderInfo").Element("Brand").Value, CreateDate = fInfo.CreationTime, ModifyDate = fInfo.LastWriteTime, GuideType = Convert.ToInt16(xGuideType), DesignStep = Convert.ToInt32(xDesignStep), CaseDirectoryPath = Path.GetDirectoryName(XmlPath), CaseXmlPath = XmlPath }; Caselist_Splint.Add(splintInfo); return(true); } catch (Exception ex) { log.RecordLog(new StackTrace(true).GetFrame(0).GetFileLineNumber().ToString(), "ProjectHandle.cs LoadXml(Splint) Exception", ex.Message); return(false); } } } return(true); }