using Microsoft.Win32;
using System;
using System.ComponentModel;
using System.IO;
using System.Windows.Forms;
namespace CLIP.eForm.Consent.UI {
public partial class ConfigForm : Form {
private IConsentMain consentMain = null;
private ConsentCommandCtrl commandControl = null;
private HospitalSvcRef.HospitalSvcSoapClient hospitalWebService = null;
public ConfigForm() {
InitializeComponent();
}
public ConfigForm(IConsentMain consentMain) {
this.consentMain = consentMain;
InitializeComponent();
}
protected override void OnLoad(EventArgs e) {
if (this.DesignMode || LicenseManager.UsageMode == LicenseUsageMode.Designtime) {
return;
}
//consentMain = ConsentMainControl.GetConsentMainInterface(this);
commandControl = consentMain.ConsentCommandCtrl as ConsentCommandCtrl;
hospitalWebService = WebMethodCommon.GetHospitalWebService(consentMain.PluginExecuteInfo["hospitalSvcUrl"]);
//현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
// AppDomain.CurrentDomain.DynamicDirectory
// Server.MapPath("~")
string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
string fileName = @"\config.ini"; //파일명
//만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
string filePath = path + fileName; //ini 파일 경로
iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
//이제 ini 객체를 이용해 맘것 사용하면 된다.
string sMoniterNumber = ini.GetIniValue("DCMC", "MONITER_NUMBER");
decimal iMoniterNumber = 1;
if (decimal.TryParse(sMoniterNumber, out iMoniterNumber)) {
this.fixedMonitor.Value = iMoniterNumber;
}
int monitorCnt = 0;
getActiveMonitors(out monitorCnt);
fixedMonitor.Maximum = monitorCnt;
base.OnLoad(e);
}
///
/// 현재 사용자의 최대 모니터 갯수를 가져온다
///
///
private static void getActiveMonitors(out int monitorCount) {
monitorCount = Screen.AllScreens.Length;
}
///
/// 닫기 버튼 클릭
///
///
///
private void btnOK_Click(object sender, EventArgs e) {
this.Close();
}
///
/// 대구가톨릭대학교병원
/// 고정할 모니터를 병원정보시스템의 기준자료로 등록한다
///
///
///
private void button1_Click(object sender, EventArgs e) {
var monitorId = fixedMonitor.Value.ToString().Trim();
HospitalSvcRef.SingleReturnData data = null;
// config.ini 파일 및 사용자 기준자료에 등록하여야 한다.
try {
data = hospitalWebService.SetUserPrefMonitor(commandControl.CurrentEndUser.userId, monitorId);
}
catch(Exception ex) {
throw ex;
}
if(data == null || string.IsNullOrEmpty(data.responseData)) {
return;
}
//현재 프로그램이 실행되고 있는정보 가져오기: 디버깅 모드라면 bin/debug/프로그램명.exe
FileInfo exefileinfo = new FileInfo(Path.GetDirectoryName(Application.StartupPath));
//// AppDomain.CurrentDomain.DynamicDirectory
//// Server.MapPath("~")
string path = Path.GetDirectoryName(Application.StartupPath);//@"C:\eForm Server\Consent-Web-Server-CNUH\";// HttpContext.Current.Request.PhysicalApplicationPath;
string fileName = @"\config.ini"; //파일명
//만약 현재 실행 되는 경로가 아닌 특정한 위치를 원한다면 위에 과정 상관없이 바로 경로셋팅 해 주면 된다. (예: c:\config.ini)
string filePath = path + fileName; //ini 파일 경로
iniUtil ini = new iniUtil(filePath); // 만들어 놓았던 iniUtil 객체 생성(생성자 인자로 파일경로 정보 넘겨줌)
//이제 ini 객체를 이용해 맘것 사용하면 된다.
ini.SetIniValue("DCMC", "MONITER_NUMBER", this.fixedMonitor.Value.ToString());
consentMain.setDualViewerOption(this.fixedMonitor.Value.ToString().Trim());
}
}
}