CFG0000MF.cpp 9.9 KB

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