frmModeConfig.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.Runtime.InteropServices;
  9. using System.Collections;
  10. using System.Diagnostics;
  11. using System.IO;
  12. using System.Text.RegularExpressions;
  13. namespace FPER
  14. {
  15. public partial class frmModeConfig : Form
  16. {
  17. //[DllImport("kernel32.dll")]
  18. //private extern static void GetSystemTime(ref SYSTEMTIME lpSystemTime);
  19. [DllImport("kernel32.dll")]
  20. private extern static uint SetSystemTime(ref SYSTEMTIME lpSystemTime);
  21. private struct SYSTEMTIME
  22. {
  23. public ushort wYear;
  24. public ushort wMonth;
  25. public ushort wDayOfWeek;
  26. public ushort wDay;
  27. public ushort wHour;
  28. public ushort wMinute;
  29. public ushort wSecond;
  30. public ushort wMilliseconds;
  31. }
  32. //private SYSTEMTIME GetTime()
  33. //{
  34. // // Call the native GetSystemTime method
  35. // // with the defined structure.
  36. // SYSTEMTIME stime = new SYSTEMTIME();
  37. // GetSystemTime(ref stime);
  38. // return stime;
  39. // //// Show the current time.
  40. // //MessageBox.Show("Current Time: " +
  41. // // stime.wHour.ToString() + ":"
  42. // // + stime.wMinute.ToString());
  43. //}
  44. //private void SetTime(SYSTEMTIME systime)
  45. //{
  46. // // Call the native GetSystemTime method
  47. // // with the defined structure.
  48. // //SYSTEMTIME systime = new SYSTEMTIME();
  49. // //GetSystemTime(ref systime);
  50. // //// Set the system clock ahead one hour.
  51. // //systime.wHour = (ushort)(systime.wHour + 1 % 24);
  52. // SetSystemTime(ref systime);
  53. // //MessageBox.Show("New time: " + systime.wHour.ToString() + ":"
  54. // // + systime.wMinute.ToString());
  55. //}
  56. MDIParent mdi;
  57. //최초 시간설정을 위해
  58. bool TimeTicker_Start = false;
  59. DateTime sSystemDateTime;
  60. delegate void deleFormInit();
  61. string temppw;
  62. ReceiverConfigVo configVO;
  63. public frmModeConfig()
  64. {
  65. InitializeComponent();
  66. // cyim 2013.7.29 시운전모드 속성 변경
  67. this.checkBox_TestRunFlag.Visible = false;
  68. }
  69. public void Form_Init()
  70. {
  71. try
  72. {
  73. if (this.InvokeRequired)
  74. {
  75. deleFormInit d = new deleFormInit(Form_Init);
  76. this.Invoke(d, new object[] { });
  77. }
  78. else
  79. {
  80. this.configVO.Fire_accumulation_mode = mdi.MyConfigVO.Fire_accumulation_mode;
  81. this.configVO.Fire_accumulation_time = mdi.MyConfigVO.Fire_accumulation_time;
  82. this.configVO.Fire_process_mode = mdi.MyConfigVO.Fire_process_mode;
  83. this.configVO.Master_user_id = mdi.MyConfigVO.Master_user_id;
  84. this.configVO.Master_password = mdi.MyConfigVO.Master_password;
  85. this.configVO.Building_name = mdi.MyConfigVO.Building_name;
  86. this.configVO.Background_image = mdi.MyConfigVO.Background_image;
  87. getData();
  88. }
  89. }
  90. catch (Exception ex)
  91. {
  92. Util.UErrorMessage(ex, 0, 0);
  93. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.Source), Application.ProductName);
  94. }
  95. }
  96. private void frmModeConfig_Load(object sender, EventArgs e)
  97. {
  98. // cyim 2013.8.1 : 더블버퍼링 적용
  99. SetStyle(ControlStyles.UserPaint, true);
  100. //this.UpdateStyles();
  101. SetStyle(ControlStyles.AllPaintingInWmPaint, true);
  102. //this.UpdateStyles();
  103. SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
  104. this.UpdateStyles();
  105. try
  106. {
  107. mdi = (MDIParent)this.MdiParent;
  108. //
  109. // cyim 2016.04.06 : 감지기의 낮시간대 설정
  110. //
  111. DacReceiverConfig TB_DayTime = new DacReceiverConfig(mdi.MyReceiverID);
  112. if (TB_DayTime.TB_DAYTIME_Exist() != null && TB_DayTime.TB_DAYTIME_Exist().Count != 0) // 처음 접근할 당시에 해당 테이블이 있다면 UI 가 새로 생긴다
  113. {
  114. // 설정된 값이 존재한다면
  115. DataRowCollection drc = TB_DayTime.TB_DAYTIME_Get();
  116. if (drc.Count == 0)
  117. {
  118. this.textBox_Start_Hour.Text = "0";
  119. this.textBox_Start_Minute.Text = "0";
  120. this.textBox_End_Hour.Text = "0";
  121. this.textBox_End_Minute.Text = "0";
  122. }
  123. else
  124. {
  125. string START_HOUR = ((drc[0]["START_HOUR"]) == null) ? "00" : (drc[0]["START_HOUR"]).ToString();
  126. string START_MIN = ((drc[0]["START_MIN"]) == null) ? "00" : (drc[0]["START_MIN"]).ToString();
  127. string END_HOUR = ((drc[0]["END_HOUR"]) == null) ? "00" : (drc[0]["END_HOUR"]).ToString();
  128. string END_MIN = ((drc[0]["END_MIN"]) == null) ? "00" : (drc[0]["END_MIN"]).ToString();
  129. groupBox_TBDayTime.Visible = true;
  130. this.textBox_Start_Hour.Text = START_HOUR;
  131. this.textBox_Start_Minute.Text = START_MIN;
  132. this.textBox_End_Hour.Text = END_HOUR;
  133. this.textBox_End_Minute.Text = END_MIN;
  134. }
  135. }
  136. else
  137. groupBox_TBDayTime.Visible = false;
  138. // cyim 2016.12.14 : IFC2000, IFC1000 은 아날로그 감지기 시간대 설정화면이 출력되지 않는다
  139. if (mdi.ReceiverModel == "IFC2000" || mdi.ReceiverModel == "IFC1000")
  140. groupBox_TBDayTime.Visible = false;
  141. txtThisReceiverID.Text = string.Format("{0:00}", mdi.myReceiverID);
  142. this.configVO = new ReceiverConfigVo(mdi.myReceiverID);
  143. this.configVO.Fire_accumulation_mode = mdi.MyConfigVO.Fire_accumulation_mode;
  144. this.configVO.Fire_accumulation_time = mdi.MyConfigVO.Fire_accumulation_time;
  145. this.configVO.Fire_process_mode = mdi.MyConfigVO.Fire_process_mode;
  146. this.configVO.Master_user_id = mdi.MyConfigVO.Master_user_id;
  147. this.configVO.Master_password = mdi.MyConfigVO.Master_password;
  148. this.configVO.Building_name = mdi.MyConfigVO.Building_name;
  149. this.configVO.Background_image = mdi.MyConfigVO.Background_image;
  150. // cyim 2013.7.29 화재시화면전환 정보 데이타베이스 저장 및 읽기
  151. this.configVO.Jump_field_flag = mdi.MyConfigVO.Jump_field_flag;
  152. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  153. this.configVO.Test_run_flag = mdi.MyConfigVO.Test_run_flag;
  154. //축적(30초, 40초, 50초, 60초 선택) , 비축적
  155. ArrayList ary = new ArrayList();
  156. ary.Add(new cboitem("30", "30초"));
  157. ary.Add(new cboitem("40", "40초"));
  158. ary.Add(new cboitem("50", "50초"));
  159. ary.Add(new cboitem("60", "60초"));
  160. //ary.Add(new cboitem("0", "비축적"));
  161. Util.ComboSetting(cboFireAccumulationTime, ary, null);
  162. // cyim 2016.12.09 : 수신기 모델을 표시 (운전모드 설정화면)
  163. label_ReceiverModel.Text = mdi.ReceiverModel;
  164. getData();
  165. timer1.Enabled = true;
  166. }
  167. catch (Exception ex)
  168. {
  169. // cyim 2016.04.06 : 감지기의 낮시간대 설정
  170. groupBox_TBDayTime.Visible = false;
  171. Util.UErrorMessage(ex, 0, 0);
  172. }
  173. }
  174. private void frmModeConfig_Activated(object sender, EventArgs e)
  175. {
  176. try
  177. {
  178. this.mdi.SelectMenuIndex = 2;
  179. }
  180. catch (Exception ex)
  181. {
  182. Util.UErrorMessage(ex, 0, 0);
  183. }
  184. }
  185. private void frmModeConfig_Disposed(object sender, EventArgs e)
  186. {
  187. try
  188. {
  189. this.mdi.SelectMenuIndex = 0;
  190. }
  191. catch (Exception ex)
  192. {
  193. Util.UErrorMessage(ex, 0, 0);
  194. }
  195. }
  196. private void getData()
  197. {
  198. try
  199. {
  200. if (this.InvokeRequired)
  201. {
  202. deleFormInit d = new deleFormInit(getData);
  203. this.Invoke(d, new object[] { });
  204. }
  205. else
  206. {
  207. //축적모드
  208. chkFireAccumulationMode.Checked = this.configVO.Fire_accumulation_mode;
  209. if (!chkFireAccumulationMode.Checked) chkFireAccumulationMode_CheckedChanged(chkFireAccumulationMode, EventArgs.Empty);
  210. //화재모드
  211. chkFireProcessMode.Checked = this.configVO.Fire_process_mode;
  212. if (!chkFireProcessMode.Checked) chkFireProcessMode_CheckedChanged(chkFireProcessMode, EventArgs.Empty);
  213. //관리자ID
  214. txtMasterUserId.Text = this.configVO.Master_user_id;
  215. //관리자암호
  216. txtMasterPassword.Text = this.configVO.Master_password;
  217. temppw = txtMasterPassword.Text;
  218. //관리자암호재입력
  219. txtMasterPasswordRe.Text = this.configVO.Master_password;
  220. //건물명
  221. txtBuildingName.Text = this.configVO.Building_name;
  222. //배경이미지
  223. //txtBackgroundImagePath.Text = this.configVO.Background_image;
  224. txtBackgroundImagePath.Text = "";
  225. //화재시화면전환 // cyim 2013.7.29 화재시화면전환 정보 데이타베이스 저장 및 읽기
  226. if (this.configVO.Jump_field_flag == "N") checkBox_JumpField.Checked = false;
  227. else checkBox_JumpField.Checked = true;
  228. //시운전모드 // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  229. if (this.configVO.Test_run_flag == "N") checkBox_TestRunFlag.Checked = false;
  230. else checkBox_TestRunFlag.Checked = true;
  231. }
  232. }
  233. catch (Exception ex)
  234. {
  235. Util.UErrorMessage(ex, 0, 0);
  236. //MessageBox.Show(ex.Message, Application.ProductName);
  237. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  238. }
  239. }
  240. private void chkFireAccumulationMode_CheckedChanged(object sender, EventArgs e)
  241. {
  242. try
  243. {
  244. if (chkFireAccumulationMode.Checked)
  245. {
  246. chkFireAccumulationMode.Text = "화재축적사용";
  247. this.cboFireAccumulationTime.Visible = true;
  248. if (this.configVO.Fire_accumulation_time > 0) cboFireAccumulationTime.SelectedValue = this.configVO.Fire_accumulation_time.ToString();
  249. else cboFireAccumulationTime.SelectedIndex = 0;
  250. }
  251. else
  252. {
  253. chkFireAccumulationMode.Text = "화재축적비사용";
  254. cboFireAccumulationTime.SelectedValue = "0";
  255. this.cboFireAccumulationTime.Visible = false;
  256. }
  257. // cyim 2013.7.12 디자인개선작업 : 운전설정
  258. if (chkFireAccumulationMode.Checked) this.chkFireAccumulationMode.BackgroundImage = (Image)Properties.Resources.일반버튼_대_주황_215_58;
  259. else this.chkFireAccumulationMode.BackgroundImage = (Image)Properties.Resources.일반버튼_대_회색_215_58;
  260. this.panel_Main.Focus();
  261. }
  262. catch (Exception ex)
  263. {
  264. Util.UErrorMessage(ex, 0, 0);
  265. }
  266. }
  267. private void chkFireProcessMode_CheckedChanged(object sender, EventArgs e)
  268. {
  269. try
  270. {
  271. if (chkFireProcessMode.Checked)
  272. {
  273. chkFireProcessMode.Text = "화재지속";
  274. mdi.CommandLog(MappingStatus.Log, string.Format("복구모드 변경(화재지속)"));
  275. }
  276. else
  277. {
  278. chkFireProcessMode.Text = "자동복구";
  279. mdi.CommandLog(MappingStatus.Log, string.Format("복구모드 변경(자동복구)"));
  280. }
  281. // cyim 2013.7.12 디자인개선작업 : 운전설정
  282. if (chkFireProcessMode.Checked) this.chkFireProcessMode.BackgroundImage = (Image)Properties.Resources.일반버튼_대_회색_215_58;
  283. else this.chkFireProcessMode.BackgroundImage = (Image)Properties.Resources.일반버튼_대_주황_215_58;
  284. this.panel_Main.Focus();
  285. }
  286. catch (Exception ex)
  287. {
  288. Util.UErrorMessage(ex, 0, 0);
  289. }
  290. }
  291. private void timer1_Tick(object sender, EventArgs e)
  292. {
  293. try
  294. {
  295. int nowHour = Util.StrToInt(string.Format("{0:HH}", DateTime.Now), 0);
  296. int sysHour = Util.StrToInt(string.Format("{0:HH}", sSystemDateTime), 0);
  297. if (!TimeTicker_Start)
  298. {
  299. dateTimePicker1.Value = DateTime.Now;
  300. numericUpDown1.Value = nowHour;
  301. numericUpDown2.Value = DateTime.Now.Minute;
  302. sSystemDateTime = DateTime.Now;
  303. TimeTicker_Start = true;
  304. }
  305. else
  306. {
  307. if (DateTime.Now.Minute != sSystemDateTime.Minute) numericUpDown2.Value = DateTime.Now.Minute;
  308. if (sysHour != nowHour) numericUpDown1.Value = nowHour;
  309. //if (DateTime.Now.Date != sSystemDateTime.Date) dateTimePicker1.Value = DateTime.Now;
  310. sSystemDateTime = DateTime.Now;
  311. }
  312. txtSystemSecond.Text = string.Format("{0}", DateTime.Now.Second);
  313. }
  314. catch (Exception ex)
  315. {
  316. Util.UErrorMessage(ex, 0, 0);
  317. }
  318. }
  319. private void btnTimeApply_Click(object sender, EventArgs e)
  320. {
  321. try
  322. {
  323. DateTime sDateTimeValue = dateTimePicker1.Value;
  324. //string myDateTimeValue = string.Format("2/16/1992 12:15:12");
  325. string myDateTimeValue = string.Format("{0:MM}/{0:dd}/{0:yyyy} {1:00}:{2:00}:{3:00}", sDateTimeValue
  326. , numericUpDown1.Value, numericUpDown2.Value, Util.StrToInt(txtSystemSecond.Text, 0));
  327. DateTime myDateTime = DateTime.Parse(myDateTimeValue);
  328. // cyim 2015.10.1 시간 동기화를 위해 시간정보를 셋팅한것을 메인에게 알리는 이벤트
  329. DateTime TempDateTime = myDateTime;
  330. SYSTEMTIME systime = new SYSTEMTIME();
  331. //GetSystemTime(ref systime);
  332. myDateTime = myDateTime.AddHours(-9);
  333. int nowHour = Util.StrToInt(string.Format("{0:HH}", myDateTime), 0);
  334. systime.wYear = (ushort)myDateTime.Year;
  335. systime.wMonth = (ushort)myDateTime.Month;
  336. systime.wDay = (ushort)myDateTime.Day;
  337. systime.wHour = (ushort)(nowHour);
  338. systime.wMinute = (ushort)myDateTime.Minute;
  339. systime.wSecond = (ushort)myDateTime.Second;
  340. SetSystemTime(ref systime); //시간설정
  341. // cyim 2015.10.1 시간 동기화를 위해 시간정보를 셋팅한것을 메인에게 알리는 이벤트 (라벨은 적용버튼 누르면 보임)
  342. mdi.Event.TimeSync_Setup_SendMessage_Write(TempDateTime.ToString("yyyy-MM-dd HH:mm:ss"));
  343. this.label_Inform.Visible = true;
  344. }
  345. catch (Exception ex)
  346. {
  347. Util.UErrorMessage(ex, 0, 0);
  348. //MessageBox.Show(ex.Message, Application.ProductName);
  349. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  350. }
  351. }
  352. //비밀번호 규칙 설정
  353. //6~20자리 문자열 숫자와 문자와 같이 있어야 함
  354. public static bool IsRegexMatch(int type, string plainText)
  355. {
  356. Regex rx;
  357. switch (type)
  358. {
  359. case 1: //숫자
  360. rx = new Regex(@"^[0-9]$", RegexOptions.None);
  361. break;
  362. case 2: //영문자
  363. rx = new Regex(@"^[a-zA-Z]$", RegexOptions.None);
  364. break;
  365. case 3: //한글
  366. rx = new Regex(@"^[가-힣]$", RegexOptions.None);
  367. break;
  368. case 4: //한글+영문자
  369. rx = new Regex(@"^[a-zA-Z]$", RegexOptions.None);
  370. break;
  371. case 5: //숫자+영문자+한글
  372. rx = new Regex(@"^[a-zA-Z0-9가-힣]$", RegexOptions.None);
  373. break;
  374. case 6: //숫자+영문자+한글 + 개수
  375. rx = new Regex(@"^[a-zA-Z0-9가-힣]{4,16}$", RegexOptions.None);
  376. break;
  377. default:
  378. return false;
  379. }
  380. return (string.IsNullOrEmpty(plainText)) ? false : rx.IsMatch(plainText);
  381. }
  382. //문자열중 하나라도 숫자가 존재하는지 체크
  383. public bool IsNumeric(string value)
  384. {
  385. bool result = false;
  386. foreach (char cData in value)
  387. {
  388. if (false == Char.IsNumber(cData))
  389. {
  390. result = false;
  391. }
  392. else
  393. {
  394. result = true;
  395. break;
  396. }
  397. }
  398. if (result)
  399. {
  400. return true;
  401. }
  402. else
  403. {
  404. return false;
  405. }
  406. }
  407. //문자열중 하나라도 문자가 존재하는지 체크
  408. public bool IsLetter(string value)
  409. {
  410. bool result = false;
  411. foreach (char cData in value)
  412. {
  413. if (false == Char.IsLetter(cData))
  414. {
  415. result = false;
  416. }
  417. else
  418. {
  419. result = true;
  420. break;
  421. }
  422. }
  423. if (result)
  424. {
  425. return true;
  426. }
  427. else
  428. {
  429. return false;
  430. }
  431. }
  432. private void btnRepeaterSave_Click(object sender, EventArgs e)
  433. {
  434. try
  435. {
  436. // cyim 2013.7.12 디자인개선작업 : 운전설정
  437. this.panel_Main.Focus();
  438. // cyim 2015.10.1 시간 동기화 : 라벨은 적용버튼 누르면 보이지만, 전체적용버튼 누르면 사라짐
  439. this.label_Inform.Visible = false;
  440. bool chkConfigVoChange = false; //데몬에 넘길 데이터 변경여부
  441. bool chkConfigVoChangeAll = false; //전체데이터 변경여부
  442. Util.ChkTxtBox(txtMasterUserId, "관리자ID");
  443. string ID = txtMasterUserId.Text.Trim().ToLower();
  444. string passwd = txtMasterPassword.Text.Trim().ToLower();
  445. string passwdre = txtMasterPasswordRe.Text.Trim().ToLower();
  446. if (!((temppw == passwd) && (temppw == passwdre)))
  447. {
  448. if (!passwd.Equals(passwdre))
  449. {
  450. MessageBox.Show("암호와 재입력 암호가 일치하지 않습니다.", Application.ProductName);
  451. return;
  452. }
  453. if (ID.Equals(passwd))
  454. {
  455. MessageBox.Show("ID와 비밀번호가 동일하면 안됩니다.", Application.ProductName);
  456. return;
  457. }
  458. if (!IsRegexMatch(6, passwd)) // 개수
  459. {
  460. MessageBox.Show("비밀번호는 숫자와 문자의 조합으로 구성되어야합니다(4~16자)", Application.ProductName);
  461. return;
  462. }
  463. if (!IsNumeric(passwd)) //숫자
  464. {
  465. MessageBox.Show("비밀번호는 숫자와 문자의 조합으로 구성되어야합니다(4~16자, 숫자 필요)", Application.ProductName);
  466. return;
  467. }
  468. if (!IsLetter(passwd)) //문자
  469. {
  470. MessageBox.Show("비밀번호는 숫자와 문자의 조합으로 구성되어야합니다(4~16자, 문자 필요)", Application.ProductName);
  471. return;
  472. }
  473. }
  474. Util.ChkTxtBox(txtBuildingName, "건물표시명");
  475. this.Cursor = Cursors.WaitCursor;
  476. this.configVO.Fire_accumulation_mode = chkFireAccumulationMode.Checked;
  477. this.configVO.Fire_accumulation_time = Util.StrToInt(cboFireAccumulationTime.SelectedValue, 0);
  478. this.configVO.Fire_process_mode = chkFireProcessMode.Checked;
  479. this.configVO.Master_user_id = txtMasterUserId.Text.Trim();
  480. if (!passwd.Equals("1234567890"))
  481. {
  482. this.configVO.Master_password = passwd;
  483. }
  484. this.configVO.Building_name = txtBuildingName.Text.Trim();
  485. //byte[] imgbytes = null;
  486. if (txtBackgroundImagePath.Text.Length > 0)
  487. {
  488. //imgbytes = fileByte(txtBackgroundImagePath.Text.Trim());
  489. this.configVO.Background_image = txtBackgroundImagePath.Text.Trim(); //imgbytes;
  490. }
  491. // cyim 2013.7.29 화재시화면전환 정보 데이타베이스 저장 및 읽기
  492. if (checkBox_JumpField.Checked == true) this.configVO.Jump_field_flag = "Y";
  493. else this.configVO.Jump_field_flag = "N";
  494. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  495. if (checkBox_TestRunFlag.Checked == true) this.configVO.Test_run_flag = "Y";
  496. else this.configVO.Test_run_flag = "N";
  497. //축적모드,축적시간,화재모드만 변경여부를 체크하여 쓴다.
  498. if (mdi.MyConfigVO.Fire_accumulation_mode != this.configVO.Fire_accumulation_mode) chkConfigVoChange = true;
  499. if (mdi.MyConfigVO.Fire_accumulation_time != this.configVO.Fire_accumulation_time) chkConfigVoChange = true;
  500. if (mdi.MyConfigVO.Fire_process_mode != this.configVO.Fire_process_mode) chkConfigVoChange = true;
  501. // cyim 2013.7.29 화재시화면전환 정보 데이타베이스 저장 및 읽기
  502. if (mdi.MyConfigVO.Jump_field_flag != this.configVO.Jump_field_flag) chkConfigVoChange = true;
  503. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  504. if (mdi.MyConfigVO.Test_run_flag != this.configVO.Test_run_flag) chkConfigVoChange = true;
  505. //전체변경여부 체크
  506. chkConfigVoChangeAll = chkConfigVoChange;
  507. if (!mdi.MyConfigVO.Master_user_id.Equals(this.configVO.Master_user_id)) chkConfigVoChangeAll = true;
  508. if (!mdi.MyConfigVO.Master_password.Equals(this.configVO.Master_password)) chkConfigVoChangeAll = true;
  509. if (!mdi.MyConfigVO.Building_name.Equals(this.configVO.Building_name)) chkConfigVoChangeAll = true;
  510. if (!mdi.MyConfigVO.Background_image.Equals(this.configVO.Background_image)) chkConfigVoChangeAll = true;
  511. if (chkConfigVoChangeAll)
  512. {
  513. DacReceiverConfig dacReceiverConfig = new DacReceiverConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  514. dacReceiverConfig.Config_Update(QUERYMode.InsertAndUpdate, mdi.myReceiverID
  515. , this.configVO.Fire_accumulation_mode ? "Y" : "N"
  516. , this.configVO.Fire_accumulation_time, this.configVO.Fire_process_mode ? "Y" : "N"
  517. , this.configVO.Sound_process_mode ? "Y" : "N"
  518. , this.configVO.Master_user_id, this.configVO.Master_password
  519. , this.configVO.Building_name, this.configVO.Background_image
  520. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  521. , this.configVO.Test_run_flag
  522. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  523. , this.configVO.Jump_field_flag);
  524. }
  525. //데몬통신
  526. if (chkConfigVoChange)
  527. {
  528. /***************************************************************/
  529. /* 환경설정변경명령 Progress 표시 */
  530. /***************************************************************/
  531. frmProgress frm = new frmProgress(mdi); // cyim 2016.12.07 : 수신기 모델별 내부 로직 변경
  532. //중계기 설정 데이터를 CmdInfo에 넣어준다..
  533. CmdInfo cmd = new CmdInfo(prt_cmd_define.read_command_status, mdi.myReceiverID, 1, 0, 0, null);
  534. cmd.CommandType = "CS";
  535. cmd.ApplyRange = "A"; //차단레벨(회로타입차단용) A-All,C-Comm,B-Board,L-Loop,R-중계기,D-회로,I-입력회로,O-출력회로
  536. cmd.CommandData = this.configVO; //변경데이터-명령
  537. frm.Commandinfo = cmd;
  538. frm.ConfigVoMy = this.mdi.MyConfigVO; //원본데이터-비교를 위해
  539. frm.ui = this.mdi.ui;
  540. frm.ShowDialog();
  541. /**************************************************************/
  542. }
  543. // cyim 2013.7.29 화재시화면전환 정보 데이타베이스 저장 및 읽기
  544. DacFieldConfig dacfieldconfig = new DacFieldConfig(mdi.myReceiverID);// cyim 2015.7.30 데이타베이스 접속 루틴 변경
  545. if (this.checkBox_JumpField.Checked == true) mdi.MyConfigVO.Jump_field_flag = "Y";
  546. else mdi.MyConfigVO.Jump_field_flag = "N";
  547. dacfieldconfig.UpdateJumpField(mdi.myReceiverID, this.checkBox_JumpField.Checked);
  548. //자신의 환경정보도 변경한다..
  549. mdi.MyConfigVO = this.configVO;
  550. this.Cursor = Cursors.Default;
  551. //MessageBox.Show("저장 적용 되었습니다.", Application.ProductName);
  552. //
  553. // cyim 2016.04.06 : 감지기의 낮시간대 설정
  554. //
  555. if (this.groupBox_TBDayTime.Visible == true)
  556. {
  557. DacReceiverConfig TB_DayTime = new DacReceiverConfig(mdi.MyReceiverID);
  558. if (TB_DayTime.TB_DAYTIME_Exist() != null && TB_DayTime.TB_DAYTIME_Exist().Count != 0) // 처음 접근할 당시에 해당 테이블이 있다면 UI 가 새로 생긴다
  559. {
  560. TB_DayTime.TB_DAYTIME_Init();
  561. TB_DayTime.TB_DAYTIME_Set(
  562. this.textBox_Start_Hour.Text,
  563. this.textBox_Start_Minute.Text,
  564. this.textBox_End_Hour.Text,
  565. this.textBox_End_Minute.Text);
  566. }
  567. }
  568. // cyim 2015.2.10 운전설정 적용하기 실행
  569. mdi.CommandLog(MappingStatus.Log, string.Format("운전설정 적용 [축적:{0}, 모드:{1}]", chkFireAccumulationMode.Text, chkFireProcessMode.Text));
  570. MessageBox.Show("적용되었습니다.", Application.ProductName);
  571. }
  572. catch (Exception ex)
  573. {
  574. MessageBox.Show("실패하였습니다.", Application.ProductName);
  575. Util.UErrorMessage(ex, 0, 0);
  576. //MessageBox.Show(ex.Message, Application.ProductName);
  577. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  578. }
  579. }
  580. private byte[] fileByte(string path)
  581. {
  582. byte[] buffer = null;
  583. try
  584. {
  585. string fileName = path;
  586. if (fileName.Length > 0)
  587. {
  588. FileInfo file = new FileInfo(path);
  589. if (file.Exists)
  590. {
  591. FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  592. BinaryReader br = new BinaryReader(fs);
  593. buffer = br.ReadBytes((int)fs.Length);
  594. br.Close();
  595. fs.Close();
  596. }
  597. }
  598. }
  599. catch (Exception ex)
  600. {
  601. Util.UErrorMessage(ex, 0, 0);
  602. throw ex;
  603. }
  604. return buffer;
  605. }
  606. private void btnBackgroundImageSearch_Click(object sender, EventArgs e)
  607. {
  608. //'디렉토리 정보를 가져오는 다이어그램을 연다.
  609. try
  610. {
  611. string init_path = Application.StartupPath;
  612. FindImageFileDialog.InitialDirectory = init_path;
  613. FindImageFileDialog.Filter = "GIF 이미지(*.gif)|*.gif|JPEG 이미지(*.jpg,*.jpeg,*.jpe)|*.jpg,*.jpeg,*.jpe|BMP 이미지(*.bmp)|*.bmp|모든파일|*.*";
  614. if (FindImageFileDialog.ShowDialog() == DialogResult.OK)
  615. {
  616. txtBackgroundImagePath.Text = FindImageFileDialog.FileName;
  617. }
  618. }
  619. catch (Exception ex)
  620. {
  621. Util.UErrorMessage(ex, 0, 0);
  622. //MessageBox.Show(ex.Message, Application.ProductName);
  623. //MessageBox.Show(string.Format("[{0}]\r\n{1}", ex.Message, ex.StackTrace), Application.ProductName);
  624. }
  625. }
  626. private void btnWinClose_Click(object sender, EventArgs e)
  627. {
  628. this.Close();
  629. }
  630. // cyim 2013.6.27 운전설정시에 시운전 모드 체크박스 추가 및 메인 UI 표시
  631. private void checkBox_TestRunFlag_CheckedChanged(object sender, EventArgs e)
  632. {
  633. if (this.checkBox_TestRunFlag.Checked == true)
  634. this.label_TestRunFlag.Visible = true;
  635. else
  636. this.label_TestRunFlag.Visible = false;
  637. }
  638. //
  639. // Hidden Key 를 입력
  640. //
  641. // cyim 2017.01.23 : Explorer 프로세스 제어 루틴 추가
  642. private void label_ExplorerDisable_Click(object sender, EventArgs e)
  643. {
  644. if (_Data.FireDeskMode == false)
  645. _Diagnostics.taskkill_explorer();
  646. }
  647. private void label_ExplorerEnable_Click(object sender, EventArgs e)
  648. {
  649. if (_Data.FireDeskMode == false)
  650. _Diagnostics.start_explorer();
  651. }
  652. }
  653. }