CFG0000MF.cpp 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. //---------------------------------------------------------------------------
  2. #include <vcl.h>
  3. #include "ITSSkinF.h"
  4. #include "ITSUtilF.h"
  5. #include "ITSDbF.h"
  6. #include "AppGlobalF.h"
  7. #include "ITSLangTransF.h"
  8. #pragma hdrstop
  9. #include "CFG0000MF.h"
  10. //---------------------------------------------------------------------------
  11. #pragma package(smart_init)
  12. #pragma link "cxButtonEdit"
  13. #pragma link "cxButtons"
  14. #pragma link "cxCheckBox"
  15. #pragma link "cxContainer"
  16. #pragma link "cxControls"
  17. #pragma link "cxEdit"
  18. #pragma link "cxGraphics"
  19. #pragma link "cxGroupBox"
  20. #pragma link "cxLookAndFeelPainters"
  21. #pragma link "cxLookAndFeels"
  22. #pragma link "cxMaskEdit"
  23. #pragma link "cxSpinEdit"
  24. #pragma link "cxTextEdit"
  25. #pragma link "dxSkinBlack"
  26. #pragma link "dxSkinBlue"
  27. #pragma link "dxSkinsCore"
  28. #pragma link "cxLabel"
  29. #pragma resource "*.dfm"
  30. TCFG0000M *CFG0000M = NULL;
  31. //---------------------------------------------------------------------------
  32. __fastcall TCFG0000M::TCFG0000M(TComponent* Owner)
  33. : TForm(Owner)
  34. {
  35. LangTrans->Translate(this, ITSDb_GetConnection());
  36. ITSSkin_Load(this);
  37. CMM_LoadForm(g_sFormsDir, this);
  38. GrpMap->Visible = false;
  39. //GrpAlarm->Visible = true;
  40. GrpLogout->Visible = false;
  41. Height = 418;
  42. FTitle = Caption;//"환경설정";
  43. }
  44. //---------------------------------------------------------------------------
  45. void __fastcall TCFG0000M::CommClose()
  46. {
  47. CMM_SaveForm(g_sFormsDir, this);
  48. }
  49. //---------------------------------------------------------------------------
  50. void __fastcall TCFG0000M::FormShow(TObject *Sender)
  51. {
  52. Refresh();
  53. TmrShow->Enabled = true;
  54. }
  55. //---------------------------------------------------------------------------
  56. void __fastcall TCFG0000M::TmrShowTimer(TObject *Sender)
  57. {
  58. TmrShow->Enabled = false;
  59. RefreshData();
  60. }
  61. //---------------------------------------------------------------------------
  62. void __fastcall TCFG0000M::RefreshData()
  63. {
  64. // 정보를 읽어와서 표출하자.
  65. #if 0
  66. ST_GISINFO GisInfo;
  67. String sLeftTopX = GetConfigValue("MAP", "LEFTTOPX", "126.891");
  68. String sLeftTopY = GetConfigValue("MAP", "LEFTTOPY", "037.383");
  69. String sRightBottomX = GetConfigValue("MAP", "RIGHTBOTTOMX", "126.981");
  70. String sRightBottomY = GetConfigValue("MAP", "RIGHTBOTTOMY", "037.318");
  71. String sCenterX = GetConfigValue("MAP", "CENTERX", "126.935");
  72. String sCenterY = GetConfigValue("MAP", "CENTERY", "037.360");
  73. GisInfo.dLeftTopX = sLeftTopX.ToDouble();
  74. GisInfo.dLeftTopY = sLeftTopY.ToDouble();
  75. GisInfo.dRightBottomX = sRightBottomX.ToDouble();
  76. GisInfo.dRightBottomY = sRightBottomY.ToDouble();
  77. GisInfo.dCenterX = sCenterX.ToDouble();
  78. GisInfo.dCenterY = sCenterY.ToDouble();
  79. GisInfo.sCenterName = CenterName;
  80. GisInfo.sMapFileNameL0 = GetConfigValue("MAP", "MAPFILEL0", "");
  81. GisInfo.sIdxMapFileName = "";//GetConfigValue("MAP", "INDEXMAPFILE", "");
  82. #endif
  83. EdCenterId->Text = CenterId;
  84. EdCenterName->Text = CenterName;
  85. //EdGisFile->Text = g_GisInfo.sMapFileNameL0;
  86. EdDbProvider->Text = g_AppCfg.itsdb.sProvider;
  87. EdDbUser->Text = g_AppCfg.itsdb.sUserName;
  88. EdDbSource->Text = g_AppCfg.itsdb.sServerName;
  89. EdDbPasswd->Text = g_AppCfg.itsdb.sPassword;
  90. EdProcessId->Text = g_AppCfg.sProcessId;
  91. //EdTaskId->Text = "";
  92. //EdNodeId->Text = "";
  93. //EdSequence->Text = "";
  94. SeTemp->Value = g_AppCfg.Temp.AlarmValue;
  95. ChkAlarm->Checked = g_AppCfg.Alarm.Enabled;
  96. ChkAlarmWindow->Checked = g_AppCfg.Alarm.Window;
  97. SeAlarmTimeOut->Value = g_AppCfg.Alarm.TimeOut;
  98. ChkIncident->Checked = g_AppCfg.Incident.Enabled;
  99. SeIncidentTimeOut->Value = g_AppCfg.Incident.TimeOut;
  100. ChkSaveForm->Checked = g_AppCfg.bSaveForm;
  101. ChkAutoLogout->Checked = g_AppCfg.AutoLogout.Enabled;
  102. SeInterevalMin->Value = g_AppCfg.AutoLogout.IntervalMin;
  103. }
  104. //---------------------------------------------------------------------------
  105. void __fastcall TCFG0000M::BtnCloseClick(TObject *Sender)
  106. {
  107. Close();
  108. }
  109. //---------------------------------------------------------------------------
  110. void __fastcall TCFG0000M::BtnSaveClick(TObject *Sender)
  111. {
  112. //bool bSaved = false;
  113. String sMsgString;
  114. String sID, sIPAddress;
  115. int sMsgType = MB_OK|MB_ICONWARNING|MB_APPLMODAL;
  116. sMsgString = lblQry->Caption;//"시스템 환경설정 정보를 저장하시겠습니까?";
  117. sMsgType = MB_YESNO|MB_ICONINFORMATION|MB_APPLMODAL;
  118. if (Application->MessageBox(sMsgString.c_str(), FTitle.c_str(), sMsgType)==IDNO)
  119. {
  120. return;
  121. }
  122. String sCenterId = EdCenterId->Text.Trim();
  123. String sCenterName = EdCenterName->Text.Trim();
  124. String sGisFile = EdGisFile->Text.Trim();
  125. String sDbProvider = EdDbProvider->Text.Trim();
  126. String sDbUser = EdDbUser->Text.Trim();
  127. String sDbSource = EdDbSource->Text.Trim();
  128. String sDbPasswd = EdDbPasswd->Text.Trim();
  129. String sProcessId = EdProcessId->Text.Trim();
  130. g_AppCfg.bSaveForm = ChkSaveForm->Checked;
  131. String sSaveForm = g_AppCfg.bSaveForm ? "1" : "0";
  132. //String sTaskId = EdTaskId->Text.Trim();
  133. //String sNodeId = EdNodeId->Text.Trim();
  134. //String sSequence = EdSequence->Text.Trim();
  135. g_AppCfg.Temp.AlarmValue = SeTemp->Value;
  136. g_AppCfg.Alarm.Enabled = ChkAlarm->Checked;
  137. g_AppCfg.Alarm.Window = ChkAlarmWindow->Checked;
  138. g_AppCfg.Alarm.TimeOut = SeAlarmTimeOut->Value;
  139. String sAlarm = g_AppCfg.Alarm.Enabled ? "1" : "0";
  140. String sAlarmWindow = g_AppCfg.Alarm.Window ? "1" : "0";
  141. String sAlarmTimeOut = String(g_AppCfg.Alarm.TimeOut);
  142. g_AppCfg.Incident.Enabled = ChkIncident->Checked;
  143. g_AppCfg.Incident.TimeOut = SeIncidentTimeOut->Value;
  144. String sIncident = g_AppCfg.Incident.Enabled ? "1" : "0";
  145. String sIncidentTimeOut = String(g_AppCfg.Incident.TimeOut);
  146. g_AppCfg.AutoLogout.Enabled = ChkAutoLogout->Checked;
  147. g_AppCfg.AutoLogout.IntervalMin = SeInterevalMin->Value;
  148. String sAutoLogout = g_AppCfg.AutoLogout.Enabled ? "1" : "0";
  149. String sInterMin = String(g_AppCfg.AutoLogout.IntervalMin);
  150. try {
  151. SetConfigValue("CENTER", "CENTERID", sCenterId);
  152. SetConfigValue("CENTER", "CENTERNAME", sCenterName);
  153. //SetConfigValue("MAP", "MAPFILEL0", sGisFile);
  154. SetConfigValue("ITSDB", "PROVIDER", sDbProvider);
  155. SetConfigValue("ITSDB", "SERVERNAME", sDbSource);
  156. SetConfigValue("ITSDB", "USERNAME", sDbUser);
  157. SetConfigValue("ITSDB", "PASSWORD", sDbPasswd);
  158. SetConfigValue("TEMPERATURE", "ALARMVALUE", String(g_AppCfg.Temp.AlarmValue));
  159. SetConfigValue("ALARM", "ENABLED", sAlarm);
  160. SetConfigValue("ALARM", "WINDOW", sAlarmWindow);
  161. SetConfigValue("ALARM", "TIMEOUT", sAlarmTimeOut);
  162. SetConfigValue("INCIDENT", "ENABLED", sIncident);
  163. SetConfigValue("INCIDENT", "TIMEOUT", sIncidentTimeOut);
  164. SetConfigValue("AUTOLOGOUT", "ENABLED", sAutoLogout);
  165. SetConfigValue("AUTOLOGOUT", "INTERVALMIN", sInterMin);
  166. SetConfigValue("APPLICATION", "PROCESSID", sProcessId);
  167. SetConfigValue("APPLICATION", "SAVEFORM", sSaveForm);
  168. CenterId = sCenterId;
  169. CenterName = sCenterName;
  170. CenterCd = String(StrToInt(CenterId.SubString(2, 2)));
  171. //g_GisInfo.sMapFileNameL0 = sGisFile;
  172. g_AppCfg.itsdb.sProvider = sDbProvider;
  173. g_AppCfg.itsdb.sUserName = sDbUser;
  174. g_AppCfg.itsdb.sServerName = sDbSource;
  175. g_AppCfg.itsdb.sPassword = sDbPasswd;
  176. g_AppCfg.sProcessId = sProcessId;
  177. Application->MessageBox(lblQryRes->Caption.c_str(),//L"환경설정 정보를 정상적으로 저장하였습니다.\r\일부 환경설정은 다음 프로그램 실행 부터 반영됩니다.",
  178. FTitle.c_str(), MB_OK|MB_ICONINFORMATION|MB_APPLMODAL);
  179. CMM_SetFormPosition(g_AppCfg.bSaveForm);
  180. } catch(...) {
  181. }
  182. //Close();
  183. }
  184. //---------------------------------------------------------------------------
  185. void __fastcall TCFG0000M::FormClose(TObject *Sender, TCloseAction &Action)
  186. {
  187. CommClose();
  188. CFG0000M = NULL;
  189. Action = caFree;
  190. }
  191. //---------------------------------------------------------------------------
  192. String __fastcall TCFG0000M::GetConfigValue(String sSection, String sIdent, String sDefVal)
  193. {
  194. String sResult = sDefVal;
  195. TIniFile *pIniFile = NULL;
  196. String sCfgFile = ExtractFilePath(Application->ExeName) + "\\cfg\\" + FIniFile;
  197. try
  198. {
  199. pIniFile = new TIniFile(sCfgFile);
  200. sResult = pIniFile->ReadString(sSection, sIdent, sDefVal);
  201. }
  202. __finally
  203. {
  204. if (pIniFile) delete pIniFile;
  205. pIniFile = NULL;
  206. }
  207. return sResult;
  208. }
  209. //---------------------------------------------------------------------------
  210. void __fastcall TCFG0000M::SetConfigValue(String sSection, String sIdent, String sSetVal)
  211. {
  212. TIniFile *pIniFile = NULL;
  213. String sCfgFile = ExtractFilePath(Application->ExeName) + "\\cfg\\" + FIniFile;
  214. try
  215. {
  216. pIniFile = new TIniFile(sCfgFile);
  217. pIniFile->WriteString(sSection, sIdent, sSetVal);
  218. }
  219. __finally
  220. {
  221. if (pIniFile) delete pIniFile;
  222. pIniFile = NULL;
  223. }
  224. }
  225. //---------------------------------------------------------------------------
  226. void __fastcall TCFG0000M::EdGisFilePropertiesButtonClick(TObject *Sender, int AButtonIndex)
  227. {
  228. try {
  229. OpenDialog1->FileName = EdGisFile->Text.Trim();
  230. OpenDialog1->InitialDir = ExtractFilePath(Application->ExeName) + "\\cfg\\";
  231. OpenDialog1->HistoryList->Clear();
  232. OpenDialog1->Filter = "지도설정파일 (*.DVA)|*.DVA";
  233. //OpenDialog1->Options = dlgOpen->Options << ofFileMustExist;
  234. //OpenDialog1->Options = dlgOpen->Options >> ofAllowMultiSelect;
  235. if (!OpenDialog1->Execute()) return;
  236. EdGisFile->Text = OpenDialog1->FileName;
  237. } catch(...) {}
  238. }
  239. //---------------------------------------------------------------------------