ConfigForm.cs 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using Microsoft.Win32;
  2. using System;
  3. using System.ComponentModel;
  4. using System.IO;
  5. using System.Windows.Forms;
  6. namespace CLIP.eForm.Consent.UI {
  7. public partial class ConfigForm : Form {
  8. private IConsentMain consentMain = null;
  9. private ConsentCommandCtrl commandControl = null;
  10. private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
  11. public ConfigForm() {
  12. InitializeComponent();
  13. }
  14. public ConfigForm(IConsentMain consentMain) {
  15. this.consentMain = consentMain;
  16. InitializeComponent();
  17. }
  18. protected override void OnLoad(EventArgs e) {
  19. if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
  20. return;
  21. }
  22. //consentMain = ConsentMainControl.GetConsentMainInterface(this);
  23. commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
  24. hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
  25. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  26. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  27. // AppDomain.CurrentDomain.DynamicDirectory
  28. // Server.MapPath("~")
  29. string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
  30. string fileName = @"\config.ini"; //파일명
  31. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  32. string filePath = path + fileName; //ini 파일 경로
  33. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  34. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  35. string sMoniterNumber = ini.GetIniValue("DCMC", "MONITER_NUMBER");
  36. decimal iMoniterNumber = 1;
  37. if (decimal.TryParse(sMoniterNumber, out iMoniterNumber)) {
  38. this.fixedMonitor.Value = iMoniterNumber;
  39. }
  40. int monitorCnt = 0;
  41. getActiveMonitors(out monitorCnt);
  42. fixedMonitor.Maximum = monitorCnt;
  43. base.OnLoad(e);
  44. }
  45. /// <summary>
  46. /// 현재 사용자의 최대 모니터 갯수를 가져온다
  47. /// </summary>
  48. /// <param name="monitorCount"></param>
  49. private static void getActiveMonitors(out int monitorCount) {
  50. monitorCount = Screen.AllScreens.Length;
  51. }
  52. /// <summary>
  53. /// 닫기 버튼 클릭
  54. /// </summary>
  55. /// <param name="sender"></param>
  56. /// <param name="e"></param>
  57. private void btnOK_Click(object sender, EventArgs e) {
  58. this.Close();
  59. }
  60. /// <summary>
  61. /// 대구가톨릭대학교병원
  62. /// 고정할 모니터를 병원정보시스템의 기준자료로 등록한다
  63. /// </summary>
  64. /// <param name="sender"></param>
  65. /// <param name="e"></param>
  66. private void button1_Click(object sender, EventArgs e) {
  67. var monitorId = fixedMonitor.Value.ToString().Trim();
  68. HospitalSvcRef.SingleReturnData data = null;
  69. // config.ini 파일 및 사용자 기준자료에 등록하여야 한다.
  70. try {
  71. data = hospitalWebService.SetUserPrefMonitor(commandControl.CurrentEndUser.userId, monitorId);
  72. }
  73. catch(Exception ex) {
  74. throw ex;
  75. }
  76. if(data == null || string.IsNullOrEmpty(data.responseData)) {
  77. return;
  78. }
  79. //현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
  80. FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
  81. //// AppDomain.CurrentDomain.DynamicDirectory
  82. //// Server.MapPath("~")
  83. string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
  84. string fileName = @"\config.ini"; //파일명
  85. //만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
  86. string filePath = path + fileName; //ini 파일 경로
  87. iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
  88. //이제 ini 객체를 이용해 맘것 사용하면 된다.
  89. ini.SetIniValue("DCMC", "MONITER_NUMBER", this.fixedMonitor.Value.ToString());
  90. consentMain.setDualViewerOption(this.fixedMonitor.Value.ToString().Trim());
  91. }
  92. }
  93. }