/// <summary> /// 集中打印按钮 /// </summary> private void BtnPrint_Click(object sender, EventArgs e) { if (MessageBox.Show("文书是否要集中打印", "集中打印", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } // 集中打印文书前,记录当前文书的名称,在集中打印完成后重新设置回来。 // 之所以记录当前文书名称,是防止在打印各时,需要根据根据文书名称来实现个性化的功能. string strCurDocName = ExtendAppContext.Current.CurrentDocName; foreach (CheckedListBoxItem item in chkDocCheckList.Items) { if (item.CheckState == CheckState.Checked) { ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(item.Value.ToString()); //没有找到退出 if (string.IsNullOrEmpty(document.Caption)) { DialogResult dialogResult = MessageBoxFormPC.Show(string.Format("无法加载文书'{0}'的设计模版,请确保模版文件已经存在", item.Value.ToString()), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); continue; } try { // 减少资源消耗,每次加载文书前都手动释放资源 GC.Collect(); GC.Collect(); // 使用using(){} 格式,确保在执行完该代码块时调用Dispose,实现手动释放资源 Type t = Type.GetType(document.Type); using (CustomBaseDoc baseDoc = Activator.CreateInstance(t) as CustomBaseDoc) { baseDoc.BackColor = Color.White; baseDoc.Name = item.Value.ToString(); ExtendAppContext.Current.CurrentDocName = baseDoc.Name; baseDoc.HideScrollBar(); baseDoc.Initial(); baseDoc.LoadReport(ExtendAppContext.Current.AppPath + document.Path); bool IsPrintSuccess = baseDoc.PrintBaseDoc(); baseDoc.CommitDocNoMess(); } List <string> fileList = new List <string>(); foreach (CheckedListBoxItem boxItem in chkDocCheckList.Items) { if (boxItem.CheckState == CheckState.Checked) { fileList.Add(boxItem.Value.ToString()); } } } catch { } finally { // 减少资源消耗,每次加载文书前都手动释放资源 GC.Collect(); GC.Collect(); } } } // 重置当前文书名称 ExtendAppContext.Current.CurrentDocName = strCurDocName; //打印结束后,自动关闭打印选择界面。 this.Close(); }
private void button1_Click(object sender, EventArgs e) { if (MessageBox.Show("文书是否要集中打印", "集中打印", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { return; } foreach (CheckedListBoxItem item in chkDocCheckList.Items) { if (item.CheckState == CheckState.Checked) { ApplicationConfiguration.MedicalDocucementElement document = ApplicationConfiguration.GetMedicalDocument(item.Value.ToString()); //没有找到退出 if (string.IsNullOrEmpty(document.Caption)) { DialogResult dialogResult = MessageBoxFormPC.Show(string.Format("无法加载文书'{0}'的设计模版,请确保模版文件已经存在", item.Value.ToString()), "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information); continue; } try { Type t = Type.GetType(document.Type); CustomBaseDoc baseDoc = Activator.CreateInstance(t) as CustomBaseDoc; baseDoc.BackColor = Color.White; baseDoc.Name = item.Value.ToString(); baseDoc.HideScrollBar(); baseDoc.Initial(); baseDoc.LoadReport(ExtendApplicationContext.Current.AppPath + document.Path); bool IsPrintSuccess = baseDoc.PrintBaseDoc(); List <string> fileList = new List <string>(); foreach (CheckedListBoxItem boxItem in chkDocCheckList.Items) { if (boxItem.CheckState == CheckState.Checked) { fileList.Add(boxItem.Value.ToString()); } } //ApplicationConfiguration.multiPrintNames = string.Join(",", fileList.ToArray()); //(new ConfigurationDA()).UpdateConfigTableDataTable(ExtendApplicationContext.Current.CommDict.ConfigDict); //if (ExtendApplicationContext.Current.PatientInformation != null && IsPrintSuccess) //{ // Common.MED_ANES_BUTTON_MARKDataTable buttonMarkDT = new CommonDA().GetAnesDocButtonMarkData(ExtendApplicationContext.Current.PatientInformation.PatientID, // ExtendApplicationContext.Current.PatientInformation.VisitID, ExtendApplicationContext.Current.PatientInformation.OperID, MedicalDocSettings.ReturnDocNameByKey(baseDoc.Name)); // if (buttonMarkDT.Count == 0) // { // Common.MED_ANES_BUTTON_MARKRow dr = buttonMarkDT.NewMED_ANES_BUTTON_MARKRow(); // dr.PATIENT_ID = ExtendApplicationContext.Current.PatientInformation.PatientID; // dr.VISIT_ID = ExtendApplicationContext.Current.PatientInformation.VisitID; // dr.OPER_ID = ExtendApplicationContext.Current.PatientInformation.OperID; // dr.BUTTON_NAME = MedicalDocSettings.ReturnDocNameByKey(baseDoc.Name); // dr.RGB = new CommonDA().returnRGB(Color.Blue); // buttonMarkDT.AddMED_ANES_BUTTON_MARKRow(dr); // } // else if (buttonMarkDT.Count > 0) // { // Common.MED_ANES_BUTTON_MARKRow dr = buttonMarkDT[0] as Common.MED_ANES_BUTTON_MARKRow; // dr.RGB = new CommonDA().returnRGB(Color.Blue); // } // try // { // int r = new CommonDA().UpdateAnesDocButtonMarkData(buttonMarkDT); // } // catch (Exception ex) // { // ExceptionHandler.Handle(ex); // } //todo //} } catch { } } } }