public ExaminationReportPage(object data): this() { mouseHook.MouseUp += new System.Windows.Forms.MouseEventHandler(mouseHook_MouseUp); //mouseHook.MouseMove += new System.Windows.Forms.MouseEventHandler(mouseHook_MouseMove); try { this.person = data as Person; if (this.person == null) { MessageBox.Show(this, "Please select a patient."); this.Close(); } else { string dataFile = FindUserReportData(person.ArchiveFolder); if (string.IsNullOrEmpty(dataFile)) { dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; } //string dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; if (File.Exists(dataFile)) { try { this.shortFormReportModel = SerializeUtilities.Desrialize<ShortFormReport>(dataFile); } catch (Exception exec1) { } if (shortFormReportModel.DataSignImg != null) { this.dataSignImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataSignImg); } } else { shortFormReportModel.DataUserCode = person.Code; bool defaultSign = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Use Default Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); if (defaultSign) { string imgFile = AppDomain.CurrentDomain.BaseDirectory + "/Signature/temp.jpg"; if (File.Exists(imgFile)) { this.dataSignImg.Source = ImageTools.GetBitmapImage(imgFile); //dataScreenShotImg.Source = GetBitmapImage(AppDomain.CurrentDomain.BaseDirectory + "/Images/BigIcon.png"); } } } if ("en-US".Equals(App.local)) { shortFormReportModel.DataScreenDate = DateTime.ParseExact("20" + person.Code.Substring(0, 6), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("MM/dd/yyyy"); } else { shortFormReportModel.DataScreenDate = DateTime.ParseExact("20" + person.Code.Substring(0, 6), "yyyyMMdd", System.Globalization.CultureInfo.CurrentCulture).ToString("yyyy年MM月dd日"); } shortFormReportModel.DataClientNum = person.ClientNumber; shortFormReportModel.DataName = person.SurName; shortFormReportModel.DataAge = person.Age + ""; shortFormReportModel.DataAddress = person.Address; shortFormReportModel.DataHeight = person.Height; shortFormReportModel.DataWeight = person.Weight; shortFormReportModel.DataMobile = person.Mobile; shortFormReportModel.DataEmail = person.Email; shortFormReportModel.DataScreenLocation = person.ScreenVenue; this.reportDataGrid.DataContext = this.shortFormReportModel; //以下是添加处理操作员和医生的名字的选择项 User doctorUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataDoctor)) { doctorUser.Name = shortFormReportModel.DataDoctor; doctorUser.License = shortFormReportModel.DataDoctorLicense; } else { if(!string.IsNullOrEmpty(this.person.DoctorName)){ doctorUser.Name = this.person.DoctorName; doctorUser.License = this.person.DoctorLicense; shortFormReportModel.DataDoctor = this.person.DoctorName; shortFormReportModel.DataDoctorLicense = this.person.DoctorLicense; } } this.dataDoctor.ItemsSource = App.reportSettingModel.DoctorNames; if(!string.IsNullOrEmpty(doctorUser.Name)){ for (int i = 0; i < App.reportSettingModel.DoctorNames.Count; i++) { var item=App.reportSettingModel.DoctorNames[i]; if (doctorUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(doctorUser.License)==string.IsNullOrEmpty(item.License)||doctorUser.License==item.License)) { this.dataDoctor.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataDoctor.SelectedIndex == -1) { App.reportSettingModel.DoctorNames.Add(doctorUser); this.dataDoctor.SelectedIndex = App.reportSettingModel.DoctorNames.Count - 1; } } User techUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataMeikTech)) { techUser.Name = shortFormReportModel.DataMeikTech; techUser.License = shortFormReportModel.DataTechLicense; } else { if (!string.IsNullOrEmpty(this.person.TechName)) { techUser.Name = this.person.TechName; techUser.License = this.person.TechLicense; shortFormReportModel.DataMeikTech = this.person.TechName; shortFormReportModel.DataTechLicense = this.person.TechLicense; } } //this.dataMeikTech.ItemsSource = App.reportSettingModel.TechNames; //if (!string.IsNullOrEmpty(techUser.Name)) //{ // for (int i = 0; i < App.reportSettingModel.TechNames.Count; i++) // { // var item = App.reportSettingModel.TechNames[i]; // if (techUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(techUser.License) == string.IsNullOrEmpty(item.License) || techUser.License == item.License)) // { // this.dataMeikTech.SelectedIndex = i; // break; // } // } // //如果没有找到匹配的用户 // if (this.dataMeikTech.SelectedIndex == -1) // { // App.reportSettingModel.TechNames.Add(techUser); // this.dataMeikTech.SelectedIndex = App.reportSettingModel.TechNames.Count - 1; // } //} } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
private void LoadDataForFlowDocument(FlowDocument page, ShortFormReport reportModel) { if (reportModel != null) { var textBlock1 = page.FindName("dataClientNum") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataClientNum; } textBlock1 = page.FindName("dataUserCode") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataUserCode; } textBlock1 = page.FindName("dataScreenDate") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataScreenDate; } textBlock1 = page.FindName("dataName") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataName; } textBlock1 = page.FindName("dataAge") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataAge; } textBlock1 = page.FindName("dataHeight") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataHeight; } textBlock1 = page.FindName("dataWeight") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataWeight; } textBlock1 = page.FindName("dataScreenLocation") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataScreenLocation; } textBlock1 = page.FindName("dataMobile") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataMobile; } textBlock1 = page.FindName("dataEmail") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataEmail; } textBlock1 = page.FindName("dataLeftBreast") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftBreast; } textBlock1 = page.FindName("dataRightBreast") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightBreast; } textBlock1 = page.FindName("dataLeftPalpableMass") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftPalpableMass; } textBlock1 = page.FindName("dataRightPalpableMass") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightPalpableMass; } textBlock1 = page.FindName("dataLeftChangesOfElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftChangesOfElectricalConductivity; } textBlock1 = page.FindName("dataRightChangesOfElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightChangesOfElectricalConductivity; } textBlock1 = page.FindName("dataLeftMammaryStruct") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMammaryStruct; } textBlock1 = page.FindName("dataRightMammaryStruct") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMammaryStruct; } textBlock1 = page.FindName("dataLeftLactiferousSinusZone") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftLactiferousSinusZone; } textBlock1 = page.FindName("dataRightLactiferousSinusZone") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightLactiferousSinusZone; } textBlock1 = page.FindName("dataLeftMammaryContour") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMammaryContour; } textBlock1 = page.FindName("dataRightMammaryContour") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMammaryContour; } textBlock1 = page.FindName("dataLeftNumber") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftNumber; } textBlock1 = page.FindName("dataRightNumber") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightNumber; } textBlock1 = page.FindName("dataLeftLocation") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftLocation) ? "Nil" : reportModel.DataLeftLocation; } textBlock1 = page.FindName("dataRightLocation") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightLocation) ? "Nil" : reportModel.DataRightLocation; } textBlock1 = page.FindName("dataLeftSize") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSize) ? "Nil" : reportModel.DataLeftSize; } textBlock1 = page.FindName("dataRightSize") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSize) ? "Nil" : reportModel.DataRightSize; } textBlock1 = page.FindName("dataLeftShape") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftShape) ? "Nil" : reportModel.DataLeftShape; } textBlock1 = page.FindName("dataRightShape") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightShape) ? "Nil" : reportModel.DataRightShape; } textBlock1 = page.FindName("dataLeftContourAroundFocus") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftContourAroundFocus) ? "Nil" : reportModel.DataLeftContourAroundFocus; } textBlock1 = page.FindName("dataRightContourAroundFocus") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightContourAroundFocus) ? "Nil" : reportModel.DataRightContourAroundFocus; } textBlock1 = page.FindName("dataLeftInternalElectricalStructure") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftInternalElectricalStructure) ? "Nil" : reportModel.DataLeftInternalElectricalStructure; } textBlock1 = page.FindName("dataRightInternalElectricalStructure") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightInternalElectricalStructure) ? "Nil" : reportModel.DataRightInternalElectricalStructure; } textBlock1 = page.FindName("dataLeftSurroundingTissues") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSurroundingTissues) ? "Nil" : reportModel.DataLeftSurroundingTissues; } textBlock1 = page.FindName("dataRightSurroundingTissues") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSurroundingTissues) ? "Nil" : reportModel.DataRightSurroundingTissues; } textBlock1 = page.FindName("dataLeftLocation2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftLocation2) ? "Nil" : reportModel.DataLeftLocation2; } textBlock1 = page.FindName("dataRightLocation2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightLocation2) ? "Nil" : reportModel.DataRightLocation2; } textBlock1 = page.FindName("dataLeftSize2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSize2) ? "Nil" : reportModel.DataLeftSize2; } textBlock1 = page.FindName("dataRightSize2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSize2) ? "Nil" : reportModel.DataRightSize2; } textBlock1 = page.FindName("dataLeftShape2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftShape2) ? "Nil" : reportModel.DataLeftShape2; } textBlock1 = page.FindName("dataRightShape2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightShape2) ? "Nil" : reportModel.DataRightShape2; } textBlock1 = page.FindName("dataLeftContourAroundFocus2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftContourAroundFocus2) ? "Nil" : reportModel.DataLeftContourAroundFocus2; } textBlock1 = page.FindName("dataRightContourAroundFocus2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightContourAroundFocus2) ? "Nil" : reportModel.DataRightContourAroundFocus2; } textBlock1 = page.FindName("dataLeftInternalElectricalStructure2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftInternalElectricalStructure2) ? "Nil" : reportModel.DataLeftInternalElectricalStructure2; } textBlock1 = page.FindName("dataRightInternalElectricalStructure2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightInternalElectricalStructure2) ? "Nil" : reportModel.DataRightInternalElectricalStructure2; } textBlock1 = page.FindName("dataLeftSurroundingTissues2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSurroundingTissues2) ? "Nil" : reportModel.DataLeftSurroundingTissues2; } textBlock1 = page.FindName("dataRightSurroundingTissues2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSurroundingTissues2) ? "Nil" : reportModel.DataRightSurroundingTissues2; } textBlock1 = page.FindName("dataLeftLocation3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftLocation3) ? "Nil" : reportModel.DataLeftLocation3; } textBlock1 = page.FindName("dataRightLocation3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightLocation3) ? "Nil" : reportModel.DataRightLocation3; } textBlock1 = page.FindName("dataLeftSize3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSize3) ? "Nil" : reportModel.DataLeftSize3; } textBlock1 = page.FindName("dataRightSize3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSize3) ? "Nil" : reportModel.DataRightSize3; } textBlock1 = page.FindName("dataLeftShape3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftShape3) ? "Nil" : reportModel.DataLeftShape3; } textBlock1 = page.FindName("dataRightShape3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightShape3) ? "Nil" : reportModel.DataRightShape3; } textBlock1 = page.FindName("dataLeftContourAroundFocus3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftContourAroundFocus3) ? "Nil" : reportModel.DataLeftContourAroundFocus3; } textBlock1 = page.FindName("dataRightContourAroundFocus3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightContourAroundFocus3) ? "Nil" : reportModel.DataRightContourAroundFocus3; } textBlock1 = page.FindName("dataLeftInternalElectricalStructure3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftInternalElectricalStructure3) ? "Nil" : reportModel.DataLeftInternalElectricalStructure3; } textBlock1 = page.FindName("dataRightInternalElectricalStructure3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightInternalElectricalStructure3) ? "Nil" : reportModel.DataRightInternalElectricalStructure3; } textBlock1 = page.FindName("dataLeftSurroundingTissues3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataLeftSurroundingTissues3) ? "Nil" : reportModel.DataLeftSurroundingTissues3; } textBlock1 = page.FindName("dataRightSurroundingTissues3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataRightSurroundingTissues3) ? "Nil" : reportModel.DataRightSurroundingTissues3; } textBlock1 = page.FindName("dataLeftOncomarkerHighlightBenignChanges") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftOncomarkerHighlightBenignChanges; } textBlock1 = page.FindName("dataRightOncomarkerHighlightBenignChanges") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightOncomarkerHighlightBenignChanges; } textBlock1 = page.FindName("dataLeftOncomarkerHighlightSuspiciousChanges") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftOncomarkerHighlightSuspiciousChanges; } textBlock1 = page.FindName("dataRightOncomarkerHighlightSuspiciousChanges") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightOncomarkerHighlightSuspiciousChanges; } textBlock1 = page.FindName("dataLeftMeanElectricalConductivity1") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMeanElectricalConductivity1; } textBlock1 = page.FindName("dataRightMeanElectricalConductivity1") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMeanElectricalConductivity1; } textBlock1 = page.FindName("dataLeftMeanElectricalConductivity2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMeanElectricalConductivity2; } textBlock1 = page.FindName("dataRightMeanElectricalConductivity2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMeanElectricalConductivity2; } textBlock1 = page.FindName("dataMeanElectricalConductivity3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataMeanElectricalConductivity3; } textBlock1 = page.FindName("dataLeftMeanElectricalConductivity3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMeanElectricalConductivity3; } textBlock1 = page.FindName("dataRightMeanElectricalConductivity3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMeanElectricalConductivity3; } textBlock1 = page.FindName("dataLeftComparativeElectricalConductivity1") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftComparativeElectricalConductivity1; } textBlock1 = page.FindName("dataLeftComparativeElectricalConductivity2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftComparativeElectricalConductivity2; } textBlock1 = page.FindName("dataComparativeElectricalConductivity3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataComparativeElectricalConductivity3; } textBlock1 = page.FindName("dataLeftComparativeElectricalConductivity3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftComparativeElectricalConductivity3; } textBlock1 = page.FindName("dataLeftDivergenceBetweenHistograms1") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftDivergenceBetweenHistograms1; } textBlock1 = page.FindName("dataLeftDivergenceBetweenHistograms2") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftDivergenceBetweenHistograms2; } textBlock1 = page.FindName("dataDivergenceBetweenHistograms3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataDivergenceBetweenHistograms3; } textBlock1 = page.FindName("dataLeftDivergenceBetweenHistograms3") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftDivergenceBetweenHistograms3; } textBlock1 = page.FindName("dataLeftComparisonWithNorm") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftComparisonWithNorm; } textBlock1 = page.FindName("dataRightComparisonWithNorm") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightComparisonWithNorm; } textBlock1 = page.FindName("dataLeftPhaseElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftPhaseElectricalConductivity; } textBlock1 = page.FindName("dataRightPhaseElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightPhaseElectricalConductivity; } textBlock1 = page.FindName("dataAgeElectricalConductivityReference") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataAgeElectricalConductivityReference; } textBlock1 = page.FindName("dataLeftAgeElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftAgeElectricalConductivity; } textBlock1 = page.FindName("dataRightAgeElectricalConductivity") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightAgeElectricalConductivity; } textBlock1 = page.FindName("dataExamConclusion") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataExamConclusion; } textBlock1 = page.FindName("dataLeftMammaryGland") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMammaryGland; } textBlock1 = page.FindName("dataLeftMeanECOfLesion") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMeanECOfLesion; } textBlock1 = page.FindName("dataLeftAgeRelated") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftAgeRelated; } textBlock1 = page.FindName("dataLeftMammaryGlandResult") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftMammaryGlandResult; } textBlock1 = page.FindName("dataRightMammaryGland") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMammaryGland; } textBlock1 = page.FindName("dataRightMeanECOfLesion") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMeanECOfLesion; } textBlock1 = page.FindName("dataRightAgeRelated") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightAgeRelated; } textBlock1 = page.FindName("dataRightMammaryGlandResult") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightMammaryGlandResult; } textBlock1 = page.FindName("dataTotalPts") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataTotalPts; } textBlock1 = page.FindName("dataLeftTotalPts") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftTotalPts; } textBlock1 = page.FindName("dataRightTotalPts") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightTotalPts; } textBlock1 = page.FindName("dataPoint") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataPoint; } textBlock1 = page.FindName("dataBiRadsCategory") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataBiRadsCategory; } textBlock1 = page.FindName("dataLeftBiRadsCategory") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataLeftBiRadsCategory; } textBlock1 = page.FindName("dataRightBiRadsCategory") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRightBiRadsCategory; } textBlock1 = page.FindName("dataRecommendation") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataRecommendation; } textBlock1 = page.FindName("dataFurtherExam") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataFurtherExam) ? "N/A" : reportModel.DataFurtherExam; } textBlock1 = page.FindName("dataConclusion") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataConclusion; } textBlock1 = page.FindName("dataComments") as TextBlock; if (textBlock1 != null) { textBlock1.Text = string.IsNullOrEmpty(reportModel.DataComments) ? "N/A" : reportModel.DataComments; } textBlock1 = page.FindName("dataMeikTech") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataMeikTech; } textBlock1 = page.FindName("dataDoctor") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataDoctor; } textBlock1 = page.FindName("dataSignDate") as TextBlock; if (textBlock1 != null) { textBlock1.Text = reportModel.DataSignDate; } if(!string.IsNullOrEmpty(reportModel.DataLeftLocation)&&page.FindName("L1_Canvas")!=null){ if (reportModel.DataLeftLocation.StartsWith("12")) { textBlock1 = page.FindName("L1_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("11")) { textBlock1 = page.FindName("L1_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("10")) { textBlock1 = page.FindName("L1_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("9")) { textBlock1 = page.FindName("L1_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("8")) { textBlock1 = page.FindName("L1_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("7")) { textBlock1 = page.FindName("L1_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("6")) { textBlock1 = page.FindName("L1_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("5")) { textBlock1 = page.FindName("L1_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("4")) { textBlock1 = page.FindName("L1_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("3")) { textBlock1 = page.FindName("L1_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("2")) { textBlock1 = page.FindName("L1_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation.StartsWith("1")) { textBlock1 = page.FindName("L1_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("L1".Equals(reportModel.DataLeftMaxFlag)) { textBlock1.Text = "●"; } } if (!string.IsNullOrEmpty(reportModel.DataRightLocation) && page.FindName("L1_Canvas") != null) { if (reportModel.DataRightLocation.StartsWith("12")) { textBlock1 = page.FindName("R1_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("11")) { textBlock1 = page.FindName("R1_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("10")) { textBlock1 = page.FindName("R1_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("9")) { textBlock1 = page.FindName("R1_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("8")) { textBlock1 = page.FindName("R1_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("7")) { textBlock1 = page.FindName("R1_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("6")) { textBlock1 = page.FindName("R1_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("5")) { textBlock1 = page.FindName("R1_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("4")) { textBlock1 = page.FindName("R1_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("3")) { textBlock1 = page.FindName("R1_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("2")) { textBlock1 = page.FindName("R1_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation.StartsWith("1")) { textBlock1 = page.FindName("R1_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("R1".Equals(reportModel.DataRightMaxFlag)) { textBlock1.Text = "●"; } } if (!string.IsNullOrEmpty(reportModel.DataLeftLocation2) && page.FindName("L1_Canvas") != null) { if (reportModel.DataLeftLocation2.StartsWith("12")) { textBlock1 = page.FindName("L2_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("11")) { textBlock1 = page.FindName("L2_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("10")) { textBlock1 = page.FindName("L2_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("9")) { textBlock1 = page.FindName("L2_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("8")) { textBlock1 = page.FindName("L2_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("7")) { textBlock1 = page.FindName("L2_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("6")) { textBlock1 = page.FindName("L2_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("5")) { textBlock1 = page.FindName("L2_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("4")) { textBlock1 = page.FindName("L2_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("3")) { textBlock1 = page.FindName("L2_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("2")) { textBlock1 = page.FindName("L2_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation2.StartsWith("1")) { textBlock1 = page.FindName("L2_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("L2".Equals(reportModel.DataLeftMaxFlag)) { textBlock1.Text = "●"; } } if (!string.IsNullOrEmpty(reportModel.DataRightLocation2) && page.FindName("L1_Canvas") != null) { if (reportModel.DataRightLocation2.StartsWith("12")) { textBlock1 = page.FindName("R2_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("11")) { textBlock1 = page.FindName("R2_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("10")) { textBlock1 = page.FindName("R2_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("9")) { textBlock1 = page.FindName("R2_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("8")) { textBlock1 = page.FindName("R2_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("7")) { textBlock1 = page.FindName("R2_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("6")) { textBlock1 = page.FindName("R2_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("5")) { textBlock1 = page.FindName("R2_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("4")) { textBlock1 = page.FindName("R2_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("3")) { textBlock1 = page.FindName("R2_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("2")) { textBlock1 = page.FindName("R2_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation2.StartsWith("1")) { textBlock1 = page.FindName("R2_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("R2".Equals(reportModel.DataRightMaxFlag)) { textBlock1.Text = "●"; } } if (!string.IsNullOrEmpty(reportModel.DataLeftLocation3) && page.FindName("L1_Canvas") != null) { if (reportModel.DataLeftLocation3.StartsWith("12")) { textBlock1 = page.FindName("L3_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("11")) { textBlock1 = page.FindName("L3_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("10")) { textBlock1 = page.FindName("L3_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("9")) { textBlock1 = page.FindName("L3_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("8")) { textBlock1 = page.FindName("L3_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("7")) { textBlock1 = page.FindName("L3_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("6")) { textBlock1 = page.FindName("L3_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("5")) { textBlock1 = page.FindName("L3_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("4")) { textBlock1 = page.FindName("L3_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("3")) { textBlock1 = page.FindName("L3_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("2")) { textBlock1 = page.FindName("L3_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataLeftLocation3.StartsWith("1")) { textBlock1 = page.FindName("L3_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("L3".Equals(reportModel.DataLeftMaxFlag)) { textBlock1.Text = "●"; } } if (!string.IsNullOrEmpty(reportModel.DataRightLocation3) &&page.FindName("L1_Canvas") != null) { if (reportModel.DataRightLocation3.StartsWith("12")) { textBlock1 = page.FindName("R3_12") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("11")) { textBlock1 = page.FindName("R3_11") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("10")) { textBlock1 = page.FindName("R3_10") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("9")) { textBlock1 = page.FindName("R3_9") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("8")) { textBlock1 = page.FindName("R3_8") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("7")) { textBlock1 = page.FindName("R3_7") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("6")) { textBlock1 = page.FindName("R3_6") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("5")) { textBlock1 = page.FindName("R3_5") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("4")) { textBlock1 = page.FindName("R3_4") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("3")) { textBlock1 = page.FindName("R3_3") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("2")) { textBlock1 = page.FindName("R3_2") as TextBlock; textBlock1.Visibility = Visibility.Visible; } else if (reportModel.DataRightLocation3.StartsWith("1")) { textBlock1 = page.FindName("R3_1") as TextBlock; textBlock1.Visibility = Visibility.Visible; } if ("R3".Equals(reportModel.DataRightMaxFlag)) { textBlock1.Text = "●"; } } } }
/// <summary> /// 针对FLowDocument对象生成PDF文件 /// </summary> /// <param name="reportTempl"></param> /// <param name="pdfFile"></param> /// <param name="reportModel"></param> private void ExportFlowDocumentPDF(string reportTempl, string pdfFile, ShortFormReport reportModel,string pagesize=null) { string xpsFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".xps"; if (File.Exists(xpsFile)) { File.Delete(xpsFile); } FlowDocument page = (FlowDocument)PrintPreviewWindow.LoadFlowDocumentAndRender(reportTempl, reportModel,pagesize); try { LoadDataForFlowDocument(page, reportModel); } catch { } XpsDocument xpsDocument = new XpsDocument(xpsFile, FileAccess.ReadWrite); //将flow document写入基于内存的xps document中去 XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument); writer.Write(((IDocumentPaginatorSource)page).DocumentPaginator); xpsDocument.Close(); if (File.Exists(pdfFile)) { File.Delete(pdfFile); } PDFTools.SavePDFFile(xpsFile, pdfFile); }
/// <summary> ///针对FixedPage对象生成PDF /// </summary> /// <param name="reportTempl"></param> /// <param name="pdfFile"></param> /// <param name="reportModel"></param> private void ExportPDF(string reportTempl,string pdfFile,ShortFormReport reportModel) { string xpsFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".xps"; //string userTempPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); //string xpsFile = userTempPath + System.IO.Path.DirectorySeparatorChar + person.Code + ".xps"; if (File.Exists(xpsFile)) { File.Delete(xpsFile); } FixedPage page = (FixedPage)PrintPreviewWindow.LoadFixedDocumentAndRender(reportTempl, reportModel); XpsDocument xpsDocument = new XpsDocument(xpsFile, FileAccess.ReadWrite); //将flow document写入基于内存的xps document中去 XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(xpsDocument); writer.Write(page); xpsDocument.Close(); if (File.Exists(pdfFile)) { File.Delete(pdfFile); } PDFTools.SavePDFFile(xpsFile, pdfFile); }
public SummaryReportPage(object data): this() { try { this.person = data as Person; if (this.person == null) { MessageBox.Show(this, App.Current.FindResource("Message_8").ToString()); this.Close(); } else { string dataFile = FindUserReportData(person.ArchiveFolder); if (string.IsNullOrEmpty(dataFile)) { dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; } if ("en-US".Equals(App.local)) { dataScreenDate.FormatString = "MMMM d, yyyy"; dataSignDate.FormatString = "MMMM d, yyyy"; } else { dataScreenDate.FormatString = "yyyy年MM月dd日"; dataSignDate.FormatString = "yyyy年MM月dd日"; } //string dataFile = dataFolder + System.IO.Path.DirectorySeparatorChar + person.Code + ".dat"; if(File.Exists(dataFile)){ ////序列化xaml //using (FileStream fs = new FileStream(dataFolder+"/"+person.Code+".dat", FileMode.Open)) //{ // var scrollViewer = XamlReader.Load(fs) as ScrollViewer; // this.reportPage = scrollViewer; //} this.shortFormReportModel=SerializeUtilities.Desrialize<ShortFormReport>(dataFile); if (shortFormReportModel.DataScreenShotImg != null) { this.dataScreenShotImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataScreenShotImg); } if (shortFormReportModel.DataSignImg != null) { this.dataSignImg.Source = ImageTools.GetBitmapImage(shortFormReportModel.DataSignImg); } } else { shortFormReportModel.DataUserCode = person.Code; shortFormReportModel.DataName = person.SurName; shortFormReportModel.DataAge = person.Age + ""; shortFormReportModel.DataScreenDate = DateTime.Parse(person.RegMonth + "/" + person.RegDate + "/" + person.RegYear).ToLongDateString(); shortFormReportModel.DataSignDate = DateTime.Today.ToLongDateString(); bool defaultSign = Convert.ToBoolean(OperateIniFile.ReadIniData("Report", "Use Default Signature", "false", System.AppDomain.CurrentDomain.BaseDirectory + "Config.ini")); if (defaultSign) { string imgFile = AppDomain.CurrentDomain.BaseDirectory + "/Signature/temp.jpg"; if (File.Exists(imgFile)) { dataSignImg.Source = ImageTools.GetBitmapImage(imgFile); //dataScreenShotImg.Source = GetBitmapImage(AppDomain.CurrentDomain.BaseDirectory + "/Images/BigIcon.png"); } } } this.reportDataGrid.DataContext = this.shortFormReportModel; //以下是添加处理操作员和医生的名字的选择项 User doctorUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataDoctor)) { doctorUser.Name = shortFormReportModel.DataDoctor; doctorUser.License = shortFormReportModel.DataDoctorLicense; } else { if (!string.IsNullOrEmpty(this.person.DoctorName)) { doctorUser.Name = this.person.DoctorName; doctorUser.License = this.person.DoctorLicense; shortFormReportModel.DataDoctor = this.person.DoctorName; shortFormReportModel.DataDoctorLicense = this.person.DoctorLicense; } } this.dataDoctor.ItemsSource = App.reportSettingModel.DoctorNames; if (!string.IsNullOrEmpty(doctorUser.Name)) { for (int i = 0; i < App.reportSettingModel.DoctorNames.Count; i++) { var item = App.reportSettingModel.DoctorNames[i]; if (doctorUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(doctorUser.License) == string.IsNullOrEmpty(item.License) || doctorUser.License == item.License)) { this.dataDoctor.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataDoctor.SelectedIndex == -1) { App.reportSettingModel.DoctorNames.Add(doctorUser); this.dataDoctor.SelectedIndex = App.reportSettingModel.DoctorNames.Count - 1; } } User techUser = new User(); if (!string.IsNullOrEmpty(shortFormReportModel.DataMeikTech)) { techUser.Name = shortFormReportModel.DataMeikTech; techUser.License = shortFormReportModel.DataTechLicense; } else { if (!string.IsNullOrEmpty(this.person.TechName)) { techUser.Name = this.person.TechName; techUser.License = this.person.TechLicense; shortFormReportModel.DataMeikTech = this.person.TechName; shortFormReportModel.DataTechLicense = this.person.TechLicense; } } this.dataMeikTech.ItemsSource = App.reportSettingModel.TechNames; if (!string.IsNullOrEmpty(techUser.Name)) { for (int i = 0; i < App.reportSettingModel.TechNames.Count; i++) { var item = App.reportSettingModel.TechNames[i]; if (techUser.Name.Equals(item.Name) && (string.IsNullOrEmpty(techUser.License) == string.IsNullOrEmpty(item.License) || techUser.License == item.License)) { this.dataMeikTech.SelectedIndex = i; break; } } //如果没有找到匹配的用户 if (this.dataMeikTech.SelectedIndex == -1) { App.reportSettingModel.TechNames.Add(techUser); this.dataMeikTech.SelectedIndex = App.reportSettingModel.TechNames.Count - 1; } } } } catch (Exception ex) { MessageBox.Show(this, ex.Message); } }
public static ShortFormReport ReadWordFile(string wordFilePath) { if (FileHelper.FileInUsed(wordFilePath)) { return null; } ShortFormReport shortFormReport = new ShortFormReport(); Word.Application wordApp = new Word.Application(); object unknow = Type.Missing; wordApp.Visible = false; wordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone; Object file = wordFilePath; Word.Document doc = null; try { doc = wordApp.Documents.Open(ref file); string dataMenstrualCycle = doc.FormFields[11].Result; if (string.IsNullOrEmpty(dataMenstrualCycle)) { shortFormReport.DataMenstrualCycle = "0"; } else if (dataMenstrualCycle.StartsWith("1 phase") || dataMenstrualCycle.StartsWith("phase 1") || dataMenstrualCycle.StartsWith("第一阶段") || dataMenstrualCycle.StartsWith("一期")) { shortFormReport.DataMenstrualCycle = "1";// App.Current.FindResource("ReportContext_15").ToString(); } else if (dataMenstrualCycle.StartsWith("2 phase") || dataMenstrualCycle.StartsWith("phase 2") || dataMenstrualCycle.StartsWith("第二阶段") || dataMenstrualCycle.StartsWith("二期")) { shortFormReport.DataMenstrualCycle = "2";//App.Current.FindResource("ReportContext_16").ToString(); } else if (dataMenstrualCycle.StartsWith("1 and 2 phase") || dataMenstrualCycle.StartsWith("第一和第二阶段") || dataMenstrualCycle.StartsWith("一期和二期")) { shortFormReport.DataMenstrualCycle = "3";//App.Current.FindResource("ReportContext_17").ToString(); } else if (dataMenstrualCycle.StartsWith("dysmenorrhea") || dataMenstrualCycle.StartsWith("痛经")) { shortFormReport.DataMenstrualCycle = "4";// App.Current.FindResource("ReportContext_18").ToString(); } else if (dataMenstrualCycle.StartsWith("missing") || dataMenstrualCycle.StartsWith("postmenopausal") || dataMenstrualCycle.StartsWith("postmenopause") || dataMenstrualCycle.StartsWith("绝经期")) { shortFormReport.DataMenstrualCycle = "5";// App.Current.FindResource("ReportContext_19").ToString(); shortFormReport.DataMeanElectricalConductivity3 = "1"; shortFormReport.DataComparativeElectricalConductivity3 = "1"; shortFormReport.DataDivergenceBetweenHistograms3 = "1"; } else if (dataMenstrualCycle.StartsWith("pregnancy") || dataMenstrualCycle.StartsWith("孕期")) { shortFormReport.DataMenstrualCycle = "6";// App.Current.FindResource("ReportContext_20").ToString(); shortFormReport.DataMeanElectricalConductivity3 = "2"; shortFormReport.DataComparativeElectricalConductivity3 = "2"; shortFormReport.DataDivergenceBetweenHistograms3 = "2"; } else if (dataMenstrualCycle.StartsWith("lactation") || dataMenstrualCycle.StartsWith("哺乳期")) { shortFormReport.DataMenstrualCycle = "7";// App.Current.FindResource("ReportContext_21").ToString(); shortFormReport.DataMeanElectricalConductivity3 = "3"; shortFormReport.DataComparativeElectricalConductivity3 = "3"; shortFormReport.DataDivergenceBetweenHistograms3 = "3"; } //shortFormReport.DataMenstrualCycle = doc.FormFields[11].Result; //shortFormReport.DataLeftChangesOfElectricalConductivity = doc.FormFields[15].Result; //shortFormReport.DataRightChangesOfElectricalConductivity = doc.FormFields[16].Result; //shortFormReport.DataLeftMammaryStruct = doc.FormFields[17].Result; //shortFormReport.DataRightMammaryStruct = doc.FormFields[18].Result; //shortFormReport.DataLeftLactiferousSinusZone = doc.FormFields[19].Result; //shortFormReport.DataRightLactiferousSinusZone = doc.FormFields[20].Result; //shortFormReport.DataLeftMammaryContour = doc.FormFields[21].Result; //shortFormReport.DataLeftMammaryContour = doc.FormFields[22].Result; //shortFormReport.DataLeftLocation = doc.FormFields[23].Result; //shortFormReport.DataRightLocation = doc.FormFields[24].Result; //shortFormReport.DataLeftNumber = doc.FormFields[25].Result; //shortFormReport.DataRightNumber = doc.FormFields[26].Result; //shortFormReport.DataLeftSize = doc.FormFields[27].Result; //shortFormReport.DataRightSize = doc.FormFields[28].Result; //shortFormReport.DataLeftShape = doc.FormFields[29].Result; //shortFormReport.DataRightShape = doc.FormFields[30].Result; //shortFormReport.DataLeftContourAroundFocus = doc.FormFields[31].Result; //shortFormReport.DataRightContourAroundFocus = doc.FormFields[32].Result; //shortFormReport.DataLeftInternalElectricalStructure = doc.FormFields[33].Result; //shortFormReport.DataRightInternalElectricalStructure = doc.FormFields[34].Result; //shortFormReport.DataLeftSurroundingTissues = doc.FormFields[35].Result; //shortFormReport.DataRightSurroundingTissues = doc.FormFields[36].Result; shortFormReport.DataLeftMeanElectricalConductivity1 = doc.FormFields[37].Result; shortFormReport.DataRightMeanElectricalConductivity1 = doc.FormFields[38].Result; shortFormReport.DataLeftMeanElectricalConductivity2 = doc.FormFields[39].Result; shortFormReport.DataRightMeanElectricalConductivity2 = doc.FormFields[40].Result; string dataMeanElectricalConductivity3 = doc.FormFields[41].Result; if (string.IsNullOrEmpty(dataMeanElectricalConductivity3)) { shortFormReport.DataMeanElectricalConductivity3 = "0";//""; } else if (dataMeanElectricalConductivity3.StartsWith("postmenopause") || dataMeanElectricalConductivity3.StartsWith("绝经后期")) { shortFormReport.DataMeanElectricalConductivity3 = "1";// App.Current.FindResource("ReportContext_103").ToString(); } else if (dataMeanElectricalConductivity3.StartsWith("pregnancy") || dataMeanElectricalConductivity3.StartsWith("妊娠")) { shortFormReport.DataMeanElectricalConductivity3 = "2";// App.Current.FindResource("ReportContext_104").ToString(); } else if (dataMeanElectricalConductivity3.StartsWith("lactation") || dataMeanElectricalConductivity3.StartsWith("哺乳期")) { shortFormReport.DataMeanElectricalConductivity3 = "3";// App.Current.FindResource("ReportContext_105").ToString(); } //ShortFormReport.DataMeanElectricalConductivity3 = doc.FormFields[41].Result; shortFormReport.DataLeftMeanElectricalConductivity3 = doc.FormFields[42].Result; shortFormReport.DataRightMeanElectricalConductivity3 = doc.FormFields[43].Result; shortFormReport.DataLeftComparativeElectricalConductivity1 = doc.FormFields[44].Result; //ShortFormReport.DataRightComparativeElectricalConductivity1 = doc.FormFields[44].Result; shortFormReport.DataLeftComparativeElectricalConductivity2 = doc.FormFields[45].Result; //ShortFormReport.DataRightComparativeElectricalConductivity2 = doc.FormFields[45].Result; shortFormReport.DataLeftComparativeElectricalConductivity3 = doc.FormFields[46].Result; //ShortFormReport.DataRightComparativeElectricalConductivity3 = doc.FormFields[46].Result; shortFormReport.DataLeftDivergenceBetweenHistograms1 = doc.FormFields[47].Result; //ShortFormReport.DataRightDivergenceBetweenHistograms1 = doc.FormFields[47].Result; shortFormReport.DataLeftDivergenceBetweenHistograms2 = doc.FormFields[48].Result; //ShortFormReport.DataRightDivergenceBetweenHistograms2 = doc.FormFields[48].Result; shortFormReport.DataLeftDivergenceBetweenHistograms3 = doc.FormFields[49].Result; //ShortFormReport.DataRightDivergenceBetweenHistograms3 = doc.FormFields[49].Result; shortFormReport.DataLeftPhaseElectricalConductivity = doc.FormFields[54].Result; shortFormReport.DataRightPhaseElectricalConductivity = doc.FormFields[55].Result; shortFormReport.DataAgeElectricalConductivityReference = doc.FormFields[56].Result; string dataLeftAgeElectricalConductivity = doc.FormFields[57].Result; if (string.IsNullOrEmpty(dataLeftAgeElectricalConductivity)) { shortFormReport.DataLeftAgeElectricalConductivity = "0";// ""; } else if (dataLeftAgeElectricalConductivity.StartsWith("<5")) { shortFormReport.DataLeftAgeElectricalConductivity = "1";// App.Current.FindResource("ReportContext_111").ToString(); } else if (dataLeftAgeElectricalConductivity.StartsWith(">95")) { shortFormReport.DataLeftAgeElectricalConductivity = "3";// App.Current.FindResource("ReportContext_113").ToString(); } else { shortFormReport.DataLeftAgeElectricalConductivity = "2";// App.Current.FindResource("ReportContext_112").ToString(); } //ShortFormReport.DataLeftAgeElectricalConductivity = doc.FormFields[57].Result; string dataRightAgeElectricalConductivity = doc.FormFields[58].Result; if (string.IsNullOrEmpty(dataRightAgeElectricalConductivity)) { shortFormReport.DataRightAgeElectricalConductivity = "0";// ""; } else if (dataRightAgeElectricalConductivity.StartsWith("<5")) { shortFormReport.DataRightAgeElectricalConductivity = "1";// App.Current.FindResource("ReportContext_111").ToString(); } else if (dataRightAgeElectricalConductivity.StartsWith(">95")) { shortFormReport.DataRightAgeElectricalConductivity = "3";// App.Current.FindResource("ReportContext_113").ToString(); } else { shortFormReport.DataRightAgeElectricalConductivity = "2";// App.Current.FindResource("ReportContext_112").ToString(); } //ShortFormReport.DataRightAgeElectricalConductivity = doc.FormFields[58].Result; string dataExamConclusion = doc.FormFields[59].Result; if (string.IsNullOrEmpty(dataExamConclusion)) { shortFormReport.DataExamConclusion = "0";//""; } else if (dataExamConclusion.StartsWith("Pubertal Period") || dataExamConclusion.StartsWith("青春期")) { shortFormReport.DataExamConclusion = "1";// App.Current.FindResource("ReportContext_116").ToString(); } else if (dataExamConclusion.StartsWith("Early childbearing age") || dataExamConclusion.StartsWith("育龄早期")) { shortFormReport.DataExamConclusion = "2";// App.Current.FindResource("ReportContext_117").ToString(); } else if (dataExamConclusion.StartsWith("Childbearing age") || dataExamConclusion.StartsWith("育龄期")) { shortFormReport.DataExamConclusion = "3";// App.Current.FindResource("ReportContext_118").ToString(); } else if (dataExamConclusion.StartsWith("Perimenopausal period") || dataExamConclusion.StartsWith("围绝经期")) { shortFormReport.DataExamConclusion = "4";// App.Current.FindResource("ReportContext_119").ToString(); } else if (dataExamConclusion.StartsWith("Postmenopausal period") || dataExamConclusion.StartsWith("Postmenopause period") || dataExamConclusion.StartsWith("绝经期")) { shortFormReport.DataExamConclusion = "5";// App.Current.FindResource("ReportContext_120").ToString(); } //ShortFormReport.DataExamConclusion = doc.FormFields[59].Result; string dataLeftMammaryGland=doc.FormFields[60].Result; if (string.IsNullOrEmpty(dataLeftMammaryGland)) { shortFormReport.DataLeftMammaryGland = "0";// ""; } else if (dataLeftMammaryGland.StartsWith("Ductal type") || dataLeftMammaryGland.StartsWith("导管型乳腺结构") || dataLeftMammaryGland.StartsWith("导管式结构")) { shortFormReport.DataLeftMammaryGland = "5";// App.Current.FindResource("ReportContext_126").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type with ductal component predominance") || dataLeftMammaryGland.StartsWith("混合型,导管型结构优势") || dataLeftMammaryGland.StartsWith("导管成分优先的")) { shortFormReport.DataLeftMammaryGland = "4";// App.Current.FindResource("ReportContext_125").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type of mammary gland structure") || dataLeftMammaryGland.StartsWith("Mixed type of structure") || dataLeftMammaryGland.StartsWith("混合型乳腺结构") || dataLeftMammaryGland.StartsWith("混合式结构")) { shortFormReport.DataLeftMammaryGland = "3";// App.Current.FindResource("ReportContext_124").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type with amorphous component predominance") || dataLeftMammaryGland.StartsWith("混合型,无定型结构优势") || ( dataLeftMammaryGland.Contains("无") && dataLeftMammaryGland.Contains("混合"))) { shortFormReport.DataLeftMammaryGland = "2";// App.Current.FindResource("ReportContext_123").ToString(); } else if (dataLeftMammaryGland.StartsWith("Amorphous type") || dataLeftMammaryGland.StartsWith("无定型乳腺结构") || (dataLeftMammaryGland.Contains("无") && !dataLeftMammaryGland.Contains("混合"))) { shortFormReport.DataLeftMammaryGland = "1";// App.Current.FindResource("ReportContext_122").ToString(); } //ShortFormReport.DataLeftMammaryGland = doc.FormFields[60].Result; string dataLeftAgeRelated = doc.FormFields[61].Result; if (string.IsNullOrEmpty(dataLeftAgeRelated)) { shortFormReport.DataLeftAgeRelated = "0";//""; } else if (dataLeftAgeRelated.StartsWith("<5")) { shortFormReport.DataLeftAgeRelated = "1";// App.Current.FindResource("ReportContext_111").ToString(); } else if (dataLeftAgeRelated.StartsWith(">95")) { shortFormReport.DataLeftAgeRelated = "3";// App.Current.FindResource("ReportContext_113").ToString(); } else { shortFormReport.DataLeftAgeRelated = "2";// App.Current.FindResource("ReportContext_112").ToString(); } //ShortFormReport.DataLeftAgeRelated = doc.FormFields[61].Result; string dataRightMammaryGland = doc.FormFields[64].Result; if (string.IsNullOrEmpty(dataLeftMammaryGland)) { shortFormReport.DataRightMammaryGland = "0";// ""; } else if (dataLeftMammaryGland.StartsWith("Ductal type") || dataLeftMammaryGland.StartsWith("导管型乳腺结构") || dataLeftMammaryGland.StartsWith("导管式结构")) { shortFormReport.DataRightMammaryGland = "5";// App.Current.FindResource("ReportContext_126").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type with ductal component predominance") || dataLeftMammaryGland.StartsWith("混合型,导管型结构优势") || dataLeftMammaryGland.StartsWith("导管成分优先的")) { shortFormReport.DataRightMammaryGland = "4";// App.Current.FindResource("ReportContext_125").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type of mammary gland structure") || dataLeftMammaryGland.StartsWith("Mixed type of structure") || dataLeftMammaryGland.StartsWith("混合型乳腺结构") || dataLeftMammaryGland.StartsWith("混合式结构")) { shortFormReport.DataRightMammaryGland = "3";// App.Current.FindResource("ReportContext_124").ToString(); } else if (dataLeftMammaryGland.StartsWith("Mixed type with amorphous component predominance") || dataLeftMammaryGland.StartsWith("混合型,无定型结构优势") || (dataLeftMammaryGland.Contains("无") && dataLeftMammaryGland.Contains("混合"))) { shortFormReport.DataRightMammaryGland = "2";// App.Current.FindResource("ReportContext_123").ToString(); } else if (dataLeftMammaryGland.StartsWith("Amorphous type") || dataLeftMammaryGland.StartsWith("无定型乳腺结构") || (dataLeftMammaryGland.Contains("无") && !dataLeftMammaryGland.Contains("混合"))) { shortFormReport.DataRightMammaryGland = "1";// App.Current.FindResource("ReportContext_122").ToString(); } //ShortFormReport.DataLeftMammaryGland = doc.FormFields[60].Result; string dataRightAgeRelated = doc.FormFields[65].Result; if (string.IsNullOrEmpty(dataRightAgeRelated)) { shortFormReport.DataRightAgeRelated = "0";// ""; } else if (dataRightAgeRelated.StartsWith("<5")) { shortFormReport.DataRightAgeRelated = "1";// App.Current.FindResource("ReportContext_111").ToString(); } else if (dataRightAgeRelated.StartsWith(">95")) { shortFormReport.DataRightAgeRelated = "3";// App.Current.FindResource("ReportContext_113").ToString(); } else { shortFormReport.DataRightAgeRelated = "2";// App.Current.FindResource("ReportContext_112").ToString(); } //ShortFormReport.DataRightMammaryGland = doc.FormFields[64].Result; //ShortFormReport.DataRightAgeRelated = doc.FormFields[65].Result; } catch(Exception){} finally { Type wordType = wordApp.GetType(); try { if (doc != null) { doc.Close(); } if (wordApp != null) { wordApp.Quit(); } } catch (Exception) { try { wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, wordApp, null); doc = null; wordApp = null; GC.Collect(); GC.WaitForPendingFinalizers(); } catch (Exception) { } } } return shortFormReport; }