12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046 |
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "AppGlobalF.h"
- #include "ITSDbF.h"
- #include "FRMLoginF.h"
- #include "ITSUtilF.h"
- #include "CDSVmsObjTypeF.h"
- #include <inifiles.hpp>
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- //---------------------------------------------------------------------------
- ST_GISINFO g_GisInfo;
- ST_SELLINK g_SelLink;
- String CenterCd = ""; // 지역센터 코드
- String CenterId = ""; // 지역센터 아이디
- String CenterName = ""; // 지역센터 명칭
- int g_nPid = -1; // Application Process ID
- String g_sAppDir = ""; // Application Directory
- String g_sAppName= ""; // Program name
- String g_sCfgDir = ""; // Config File Directory
- String g_sLogDir = ""; // Program Log Directory
- String g_sTempDir = ""; // Program Temp Directory
- String g_sFormsDir = ""; // Program Forms Directory
- String g_sBlackBox = "";
- String g_sLangDir = "";
- String g_sImageDir = "";
- String g_sVideoDir = "";
- String g_sMapDir = "";
- APP_CONFIG g_AppCfg;
- LOGININFO *g_pLOGIN = NULL;
- LOG_INFO g_LogCfg;
- TITSLog *ITSLog = NULL;
- TITSLog *FDbLog = NULL;
- //TLangTrans *LangTrans = NULL;
- //---------------------------------------------------------------------------
- void LoadIcon(TIniFile* AIniFile, String ASection, String AItem, String& AValue)
- {
- try
- {
- AValue = AIniFile->ReadString(ASection, AItem, "");
- if (AValue != "")
- {
- AValue = g_sAppDir + "Image\\" + AValue;
- if (!FileExists(AValue)) AValue = "";
- }
- }
- catch(Exception &e)
- {
- }
- }
- //---------------------------------------------------------------------------
- #include <windows.h>
- #include <shlwapi.h>
- #pragma comment (lib, "shlwapi.lib")
- bool IsDirectoryExists(LPCTSTR path)
- {
- return PathFileExists(path);
- #if 0
- struct _stat buffer;
- int iRetTemp = 0;
- memset((void*)&buffer, 0, sizeof(buffer));
- iRetTemp = _stat(path, &buffer);
- if (iRetTemp == 0)
- {
- if (buffer.st_mode & _S_IFDIR)
- {
- return true;
- }
- }
- return false;
- #endif
- }
- //---------------------------------------------------------------------------
- bool LoadDefaultConfigInfo(String ACfgFile/*=""*/)
- {
- String sCfgFile;
- TIniFile *pIniFile = NULL;
-
- String sIniFile = ChangeFileExt(ExtractFileName(Application->ExeName), ".ini");
- if (!ACfgFile.IsEmpty())
- sIniFile = ACfgFile + ".ini";
- sCfgFile = g_sCfgDir + sIniFile;
- g_AppCfg.sConfigFile = sCfgFile;
- g_AppCfg.AutoLogout.Enabled = false;
- g_AppCfg.AutoLogout.IntervalMin = 0;
- g_AppCfg.AutoLogout.LogoutExit = false;
- g_AppCfg.thr.pThread = NULL;
- g_AppCfg.thr.dwThreadId = 0;
- g_AppCfg.thr.nHandle = 0;
- g_AppCfg.thr.bRunning = false;
- g_AppCfg.bAppClose = false;
- try
- {
- String sTmp;
- pIniFile = new TIniFile(sCfgFile);
- g_AppCfg.sTitle = pIniFile->ReadString("APPLICATION", "TITLE", "광역교통정보 교통관리시스템");
- g_AppCfg.sProcessId = pIniFile->ReadString("APPLICATION", "PROCESSID", "999999");
- g_AppCfg.sLogDay = pIniFile->ReadString("APPLICATION", "LOGDAY", "");
- g_AppCfg.sAppPath = pIniFile->ReadString("APPLICATION", "APP_PATH", "");
- g_AppCfg.sSkinName = pIniFile->ReadString("APPLICATION", "SKINNAME", "Black");
- if (g_AppCfg.sSkinName.IsEmpty()) g_AppCfg.sSkinName = "Blue";
- sTmp = pIniFile->ReadString("APPLICATION", "SAVEFORM", "1");
- g_AppCfg.bSaveForm = (sTmp == "1") ? true : false;
- sTmp = "1";
- sTmp = pIniFile->ReadString("APPLICATION", "LOGINPROMPT", "1");
- g_AppCfg.bLoginPrompt = (sTmp == "1") ? true : false;
- g_AppCfg.sDefUseId = pIniFile->ReadString("APPLICATION", "LASTUSER", "");
- g_AppCfg.sLang = pIniFile->ReadString("APPLICATION", "LANGUAGE", "kr");
- g_AppCfg.sLang = g_AppCfg.sLang.LowerCase();
- if (g_AppCfg.sLang != "en" && g_AppCfg.sLang != "kr")
- g_AppCfg.sLang = "kr";
- g_AppCfg.bDebug = false;
- sTmp = pIniFile->ReadString("APPLICATION", "DEBUG", "0");
- if (sTmp == "1") g_AppCfg.bDebug = true;
- g_AppCfg.bTermChildProg = true;
- sTmp = pIniFile->ReadString("APPLICATION", "TERMCHILD", "1");
- if (sTmp == "0") g_AppCfg.bTermChildProg = false;
- g_AppCfg.bOnlyOneScreen = true;
- sTmp = pIniFile->ReadString("APPLICATION", "ONESCREEN", "1");
- if (sTmp == "0") g_AppCfg.bOnlyOneScreen = false;
- sTmp = pIniFile->ReadString("ALARM", "WINDOW", "1");
- g_AppCfg.Alarm.Window = (sTmp == "1") ? true : false;
- sTmp = pIniFile->ReadString("ALARM", "ENABLED", "0");
- g_AppCfg.Alarm.Enabled = (sTmp == "1") ? true : false;
- sTmp = pIniFile->ReadString("ALARM", "TIMEOUT", "10");
- g_AppCfg.Alarm.TimeOut = sTmp.ToIntDef(0);
- if (g_AppCfg.Alarm.TimeOut == 0) g_AppCfg.Alarm.TimeOut = 10;
- if (g_AppCfg.Alarm.TimeOut > 60) g_AppCfg.Alarm.TimeOut = 60;
- sTmp = pIniFile->ReadString("TEMPERATURE", "ALARMVALUE", "45");
- g_AppCfg.Temp.AlarmValue = sTmp.ToIntDef(0);
- sTmp = pIniFile->ReadString("INCIDENT", "WINDOW", "1");
- g_AppCfg.Incident.Window = (sTmp == "1") ? true : false;
- sTmp = pIniFile->ReadString("INCIDENT", "ENABLED", "0");
- g_AppCfg.Incident.Enabled = (sTmp == "1") ? true : false;
- sTmp = pIniFile->ReadString("INCIDENT", "TIMEOUT", "30");
- g_AppCfg.Incident.TimeOut = sTmp.ToIntDef(0);
- if (g_AppCfg.Incident.TimeOut == 0) g_AppCfg.Incident.TimeOut = 30;
- if (g_AppCfg.Incident.TimeOut > 300) g_AppCfg.Incident.TimeOut = 60;
- sTmp = pIniFile->ReadString("AUTOLOGOUT", "ENABLED", "0");
- g_AppCfg.AutoLogout.Enabled = (sTmp == "1") ? true : false;
- sTmp = pIniFile->ReadString("AUTOLOGOUT", "INTERVALMIN", "10");
- g_AppCfg.AutoLogout.IntervalMin = sTmp.ToIntDef(0);
- if (g_AppCfg.AutoLogout.IntervalMin == 0) g_AppCfg.AutoLogout.IntervalMin = 10;
- sTmp = pIniFile->ReadString("AUTOLOGOUT", "LOGOUTEXIT", "0");
- g_AppCfg.AutoLogout.LogoutExit = (sTmp == "1") ? true : false;
- String sSqlLog;
- g_AppCfg.itsdb.bSqlLog = false;
- g_AppCfg.itsdb.sConnectStr = "";
- g_AppCfg.itsdb.sConnectStr = pIniFile->ReadString("ITSDB", "CONNECTSTR", "");
- if (g_AppCfg.itsdb.sConnectStr == "")
- {
- g_AppCfg.itsdb.sProvider = pIniFile->ReadString("ITSDB", "PROVIDER", "OraOLEDB.Oracle.1");
- g_AppCfg.itsdb.sServerName = pIniFile->ReadString("ITSDB", "SERVERNAME", "HANTE");
- g_AppCfg.itsdb.sUserName = pIniFile->ReadString("ITSDB", "USERNAME", "hnits");
- g_AppCfg.itsdb.sPassword = pIniFile->ReadString("ITSDB", "PASSWORD", "hnits");
- }
- //sSqlLog = pIniFile->ReadString("ITSDB", "SQLLOG", "0");
- //if (sSqlLog == "1") g_AppCfg.itsdb.bSqlLog = true;
- //시설물 아이콘 경로 로딩ㄷ
- LoadIcon(pIniFile, "VMS", "ICON_N", g_AppCfg.vms.ICON[icon_n]);
- LoadIcon(pIniFile, "VMS", "ICON_E", g_AppCfg.vms.ICON[icon_e]);
- LoadIcon(pIniFile, "VMS", "ICON_M", g_AppCfg.vms.ICON[icon_m]);
- LoadIcon(pIniFile, "VMS", "ICON_R", g_AppCfg.vms.ICON[icon_r]);
- LoadIcon(pIniFile, "VMS", "ICON_S", g_AppCfg.vms.ICON[icon_s]);
- LoadIcon(pIniFile, "VDS", "ICON_N", g_AppCfg.vds.ICON[icon_n]);
- LoadIcon(pIniFile, "VDS", "ICON_E", g_AppCfg.vds.ICON[icon_e]);
- LoadIcon(pIniFile, "VDS", "ICON_M", g_AppCfg.vds.ICON[icon_m]);
- LoadIcon(pIniFile, "VDS", "ICON_R", g_AppCfg.vds.ICON[icon_r]);
- LoadIcon(pIniFile, "VDS", "ICON_S", g_AppCfg.vds.ICON[icon_s]);
- CenterId = pIniFile->ReadString("CENTER", "CENTERID", "L01");
- CenterName = pIniFile->ReadString("CENTER", "CENTERNAME", "중앙센터");
- CenterCd = CenterId.SubString(2, 2).ToIntDef(0);
- // GIS 설정정보 로딩
- g_GisInfo.mapType = pIniFile->ReadInteger("MAP", "MAPTYPE", 1);
- g_GisInfo.offLineMapPath = pIniFile->ReadString ("MAP", "OFFLINEMAP", "");
- //g_GisInfo.onLineMapPath = pIniFile->ReadString ("MAP", "ONLINEMAP", "");
- if (g_GisInfo.mapType != 0 && g_GisInfo.mapType != 1) g_GisInfo.mapType = 1; /* 1: Online, 0: Offline */
- if (IsDirectoryExists(g_GisInfo.offLineMapPath.c_str()))
- {
- g_GisInfo.offLineMapPath = g_GisInfo.offLineMapPath+"\\";
- g_GisInfo.offLineMapPath = StringReplace(g_GisInfo.offLineMapPath, ":\\", "://", TReplaceFlags() << rfReplaceAll);
- g_GisInfo.offLineMapPath = StringReplace(g_GisInfo.offLineMapPath, "\\", "/", TReplaceFlags() << rfReplaceAll);
- }
- else
- {
- if (g_GisInfo.offLineMapPath.UpperCase().Pos("HTTP"))
- {
- g_GisInfo.offLineMapPath = g_GisInfo.offLineMapPath+"/";
- }
- else
- {
- g_GisInfo.offLineMapPath = "";
- }
- }
- g_GisInfo.imagePath = g_sMapDir+"images\\";
- g_GisInfo.imagePath = StringReplace(g_GisInfo.imagePath, ":\\", "://", TReplaceFlags() << rfReplaceAll);
- g_GisInfo.imagePath = StringReplace(g_GisInfo.imagePath, "\\", "/", TReplaceFlags() << rfReplaceAll);
- g_GisInfo.sApiKey = pIniFile->ReadString ("MAP", "APIKEY", "");
- g_GisInfo.nZoomLevel = pIniFile->ReadInteger("MAP", "INITZOOM", 11);
- g_GisInfo.nMinZoom = pIniFile->ReadInteger("MAP", "MINZOOM", 1);
- g_GisInfo.nMaxZoom = pIniFile->ReadInteger("MAP", "MAXZOOM", 19);
- g_GisInfo.nFacilityZoom = pIniFile->ReadInteger("MAP", "FACILITYZOOM", 14);
- g_GisInfo.dCenterX = pIniFile->ReadString ("MAP", "CENTERX", "33.3536449").ToDouble();
- g_GisInfo.dCenterY = pIniFile->ReadString ("MAP", "CENTERY", "126.5278103").ToDouble();
- //VMS FTP
- g_AppCfg.vmsFtp.SERVER = pIniFile->ReadString("VMS_FTP", "SERVER", "");
- g_AppCfg.vmsFtp.PORT = pIniFile->ReadString("VMS_FTP", "PORT", "21").ToIntDef(21);
- g_AppCfg.vmsFtp.USER = pIniFile->ReadString("VMS_FTP", "USER", "");
- g_AppCfg.vmsFtp.PSWD = pIniFile->ReadString("VMS_FTP", "PSWD", "");
- g_AppCfg.vmsFtp.PASSIVE = pIniFile->ReadString("VMS_FTP", "PASSIVE", "0").ToIntDef(0) == 0 ? false : true;
- }
- __finally
- {
- if (pIniFile) delete pIniFile;
- pIniFile = NULL;
- WriteConfigInfo(sIniFile, "AUTOLOGOUT", "LOGOUTEXIT", "0");
- }
- return true;
- }
- //---------------------------------------------------------------------------
- bool CMM_InsertLoginHist(PLOGININFO pLogin, bool ALogin)
- {
- String sQry;
- bool bResult= false;
- TADOQuery *adoQry = NULL;
- if (!pLogin) return false;
- if (ALogin)
- {
- sQry = "INSERT INTO TB_USER_CNNC_HS ( \r\n"
- " LOGIN_HMS, \r\n"
- " USER_ID, \r\n"
- " LOGOUT_HMS \r\n"
- " ) \r\n"
- "VALUES ( \r\n"
- " :p01, \r\n"
- " :p02, \r\n"
- " NULL \r\n"
- " ) \r\n";
- }
- else
- {
- sQry = "UPDATE TB_USER_CNNC_HS SET \r\n"
- " LOGOUT_HMS = TO_CHAR(SYSDATE, 'YYYYMMDDHH24MISS') \r\n"
- " WHERE LOGIN_HMS = :p01 \r\n"
- " AND USER_ID = :p02 \r\n";
- }
- try
- {
- try
- {
- adoQry = new TADOQuery(NULL);
- adoQry->Connection = ITSDb_GetConnection();
- ITSDb_GetConnection()->BeginTrans();
- adoQry->Close();
- adoQry->SQL->Text = sQry;
- adoQry->Parameters->ParamByName("p01")->Value = pLogin->sLoginTime;
- adoQry->Parameters->ParamByName("p02")->Value = pLogin->sUserId;
- int nRowCnt = adoQry->ExecSQL();
- ITSDb_GetConnection()->CommitTrans();
- bResult = nRowCnt > 1 ? true : false;
- }
- catch (Exception &exception)
- {
- ITSDb_GetConnection()->RollbackTrans();
- throw Exception(String(exception.ClassName()) + exception.Message);
- }
- catch (...)
- {
- ITSDb_GetConnection()->RollbackTrans();
- }
- }
- __finally
- {
- if (adoQry)
- {
- adoQry->Close();
- delete adoQry;
- }
- }
- return bResult;
- }
- //---------------------------------------------------------------------------
- bool ITSLoginProc(String sConnSystem, String sDefUser, TComponent *Owner)
- {
- bool bResult= false;
- PLOGININFO pLogin = ITSDb_GetLoginInfo();
- if (NULL == pLogin) return bResult;
-
- FRMLogin = new TFRMLogin(Owner);
- if (FRMLogin)
- {
- FRMLogin->EdUserID->Text = sDefUser;
- FRMLogin->ShowModal();
- pLogin->bLogin = FRMLogin->m_bLogin;
- if (pLogin->bLogin)
- {
- pLogin->sUserId = FRMLogin->m_sUserID;
- pLogin->sUserName = FRMLogin->m_sUserName;
- pLogin->sUserRightId = FRMLogin->m_sUserRightID;
- pLogin->sUserRightName = FRMLogin->m_sUserRightName;
- pLogin->sConnSystem = sConnSystem;
- pLogin->sLoginIp = FRMLogin->GetLocalIp();
- pLogin->sLoginTime = FRMLogin->m_sLoginTime;
- }
- else
- {
- pLogin->sUserId = "default";
- pLogin->sUserName = "default";
- pLogin->sUserRightId = "1";
- pLogin->sUserRightName = "";
- pLogin->sConnSystem = "OPR";
- pLogin->sLoginSeq = "0";
- pLogin->sLoginIp = "127.0.0.1";
- pLogin->sLoginTime = Now().FormatString("yyyymmddhhnnss");
- }
-
- delete FRMLogin;
- FRMLogin = NULL;
- bResult = pLogin->bLogin;
- }
- else
- {
- bResult = false;
- }
- if (bResult) CMM_InsertLoginHist(pLogin, true);
-
- return bResult;
- }
- //---------------------------------------------------------------------------
- void ITSLogoutProc()
- {
- if (ITSDb_IsOpen() == false) return;
- PLOGININFO pLogin = ITSDb_GetLoginInfo();
- if (pLogin)
- {
- if (pLogin->bLogin) CMM_InsertLoginHist(pLogin, false);
- pLogin->bLogin = false;
- }
- }
- //---------------------------------------------------------------------------
- int UserLogin()
- {
- if (ITSLoginProc("OPR", g_AppCfg.sDefUseId, Application))
- {
- g_pLOGIN = ITSDb_GetLoginInfo();
- if (g_pLOGIN) WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "LASTUSER", g_pLOGIN->sUserId);
- }
- return g_pLOGIN == NULL ? 0 : 1;
- }
- //---------------------------------------------------------------------------
- int UserLogout()
- {
- if (g_pLOGIN)
- WriteConfigInfo(g_AppCfg.sConfigFile, "APPLICATION", "LASTUSER", g_pLOGIN->sUserId);
- if (g_AppCfg.AutoLogout.LogoutExit)
- WriteConfigInfo(g_AppCfg.sConfigFile, "AUTOLOGOUT", "LOGOUTEXIT", "1");
- else
- WriteConfigInfo(g_AppCfg.sConfigFile, "AUTOLOGOUT", "LOGOUTEXIT", "0");
- ITSLogoutProc();
- g_pLOGIN = NULL;
- return 0;
- }
- //---------------------------------------------------------------------------
- /*
- * 환경설정 정보를 저장하는 함수.
- * arguments
- * String : RegisterKey 또는 파일이름
- * return
- * bool : 실패하면 false
- */
- bool WriteConfigInfo(String sCfgFile, String sTitle, String sItem, String sValue)
- {
- String ConfigFile;
- TIniFile *pIniFile = NULL;
- ConfigFile = sCfgFile;
- try
- {
- pIniFile = new TIniFile(ConfigFile);
- if (pIniFile == NULL)
- {
- return false;
- }
- pIniFile->WriteString(sTitle, sItem, sValue);
- }
- catch(...)
- {
- }
- if (pIniFile)
- {
- pIniFile->Free();
- pIniFile = NULL;
- }
- return true;
- }
- //---------------------------------------------------------------------------
- /*
- * 환경설정 정보를 읽어오는 함수.
- * arguments
- * String : RegisterKey 또는 파일이름
- * return
- * bool : 실패하면 false
- */
- bool ReadConfigInfo(String sCfgFile, String sTitle, String sItem, String &sValue)
- {
- bool bRes;
- String ConfigFile;
- TIniFile *pIniFile = NULL;
- bRes = false;
- ConfigFile = sCfgFile;
- try
- {
- pIniFile = new TIniFile(ConfigFile);
- if (pIniFile == NULL)
- {
- return bRes;
- }
- sValue = pIniFile->ReadString(sTitle, sItem, "");
- if (sValue != "")
- {
- bRes = true;
- }
- }
- catch(...)
- {
- }
- if (pIniFile)
- {
- pIniFile->Free();
- pIniFile = NULL;
- }
- return bRes;
- }
- //---------------------------------------------------------------------------
- void ShowErrorMsg(String ATitle, String AErrMsg)
- {
- Application->NormalizeTopMosts();
- Application->MessageBox(AErrMsg.c_str(), ATitle.c_str(), MB_OK|MB_ICONERROR|MB_APPLMODAL);
- Application->RestoreTopMosts();
- }
- //----------------------------------------------------------------------------
- String APP_FillCode(TcxComboBox *ACombo, String ACode)
- {
- String sReturn = "";
- ACombo->Properties->Items->Clear();
- TItsCode *FCodeRMF = ItsCodeManager->FLists.Find(ACode);
- if (FCodeRMF)
- {
- FOR_STL(TItsSubCode *, pSubCode, FCodeRMF->FSubLists)
- {
- if (pSubCode->USE_YN == "N") continue;
- ACombo->Properties->Items->Add(" [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM);
- if (sReturn == "")
- {
- sReturn = " [" + pSubCode->CMMN_CD + "] " + pSubCode->CMMN_CD_KOR_NM;
- }
- }
- }
- ACombo->ItemIndex = 0;
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCode(TcxComboBox *ACombo)
- {
- String sReturn = "";
- if (ACombo->ItemIndex >= 0)
- {
- String sDesc = ACombo->Properties->Items->Strings[ACombo->ItemIndex];
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- sReturn = sCode;
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCodeName(TcxComboBox *ACombo, String ACode)
- {
- String sReturn = "";
- for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
- {
- String sDesc = ACombo->Properties->Items->Strings[ii];
- String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- if (ACode == sCode)
- {
- sReturn = sName.Trim();
- break;
- }
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCodeIdByName(TcxComboBox *ACombo, String AName)
- {
- String sReturn = "3";
- for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
- {
- String sDesc = ACombo->Properties->Items->Strings[ii];
- String sName = sDesc.SubString(sDesc.Pos("]") + 1, sDesc.Length());
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- if (sName.Trim() == AName.Trim())
- {
- sReturn = sCode;
- break;
- }
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCodeDesc(TcxComboBox *ACombo, String ACode)
- {
- String sReturn = "";
- for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
- {
- String sDesc = ACombo->Properties->Items->Strings[ii];
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- if (ACode == sCode)
- {
- sReturn = sDesc;
- break;
- }
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCodeDefCode(TcxComboBox *ACombo)
- {
- String sReturn = "";
- if (ACombo->Properties->Items->Count > 0)
- {
- String sDesc = ACombo->Properties->Items->Strings[0];
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- sReturn = sCode;
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- String APP_GetCodeDefDesc(TcxComboBox *ACombo)
- {
- String sReturn = "";
- if (ACombo->Properties->Items->Count > 0)
- {
- String sDesc = ACombo->Properties->Items->Strings[0];
- sReturn = sDesc;
- }
- return sReturn;
- }
- //----------------------------------------------------------------------------
- int APP_SetCode(TcxComboBox *ACombo, String ACode)
- {
- int nItemIndex = -1;
- for (int ii = 0; ii < ACombo->Properties->Items->Count; ii++)
- {
- String sDesc = ACombo->Properties->Items->Strings[ii];
- String sCode = sDesc.SubString(sDesc.Pos("[") + 1,
- sDesc.Pos("]") - (sDesc.Pos("[") + 1));
- if (ACode == sCode)
- {
- nItemIndex = ii;
- break;
- }
- }
- ACombo->ItemIndex = nItemIndex;
- return nItemIndex;
- }
- //----------------------------------------------------------------------------
- ULONG ProcIDFromWnd(HWND hwnd) // 윈도우 핸들로 프로세스 아이디 얻기
- {
- ULONG idProc;
- GetWindowThreadProcessId( hwnd, &idProc );
- return idProc;
- }
- //----------------------------------------------------------------------------
- HWND GetWinHandle(ULONG pid) // 프로세스 아이디로 윈도우 핸들 얻기
- {
- HWND tempHwnd = FindWindow(NULL,NULL); // 최상위 윈도우 핸들 찾기
- while( tempHwnd != NULL )
- {
- if( GetParent(tempHwnd) == NULL ) // 최상위 핸들인지 체크, 버튼 등도 핸들을 가질 수 있으므로 무시하기 위해
- if( pid == ProcIDFromWnd(tempHwnd) )
- return tempHwnd;
- tempHwnd = GetWindow(tempHwnd, GW_HWNDNEXT); // 다음 윈도우 핸들 찾기
- }
- return NULL;
- }
- String ITSUtil_FormatStr(String AStrDateTime, String AFormat)
- {
- #define SYEAR "-"
- #define STIME ":"
- #define SPACE " "
- String sDateTime = "";
- String sInData = AStrDateTime;//AnsiString(AStrDateTime);
- String sFormat = AFormat;
- if (sInData.IsEmpty())
- return sInData;
- try
- {
- if (sFormat == STR_DATETIME)
- {
- if (sInData.Length() < 14) return sInData;
- sDateTime = sInData.SubString( 1, 4) + SYEAR +
- sInData.SubString( 5, 2) + SYEAR +
- sInData.SubString( 7, 2) + SPACE +
- sInData.SubString( 9, 2) + STIME +
- sInData.SubString(11, 2) + STIME +
- sInData.SubString(13, 2);
- }
- else
- if (sFormat == STR_HHNN)
- {
- if (sInData.Length() < 12) return sInData;
- sDateTime = sInData.SubString( 1, 4) + SYEAR +
- sInData.SubString( 5, 2) + SYEAR +
- sInData.SubString( 7, 2) + SPACE +
- sInData.SubString( 9, 2) + STIME +
- sInData.SubString(11, 2);
- }
- else
- if (sFormat == STR_DATEHOUR)
- {
- if (sInData.Length() < 10) return sInData;
- sDateTime = sInData.SubString( 1, 4) + SYEAR +
- sInData.SubString( 5, 2) + SYEAR +
- sInData.SubString( 7, 2) + SPACE +
- sInData.SubString( 9, 2);
- }
- else
- if (sFormat == STR_DATE)
- {
- if (sInData.Length() < 8) return sInData;
- sDateTime = sInData.SubString( 1, 4) + SYEAR +
- sInData.SubString( 5, 2) + SYEAR +
- sInData.SubString( 7, 2);
- }
- else
- if (sFormat == STR_MM)
- {
- if (sInData.Length() < 6) return sInData;
- sDateTime = sInData.SubString( 1, 4) + SYEAR +
- sInData.SubString( 5, 2);
- }
- else
- {
- sDateTime = sInData;
- }
- }
- catch(Exception &E)
- {
- throw Exception(String(E.ClassName()) + E.Message);
- }
- return sDateTime;
- }
- //---------------------------------------------------------------------------
- TColor g_DispColor[MAX_DISPCOLOR];
- void APP_InitDisplayColor()
- {
- #if 0
- g_DispColor[ 0] = Graphics::clBlue;
- g_DispColor[ 1] = Graphics::clRed;
- g_DispColor[ 2] = Graphics::clLime;
- g_DispColor[ 3] = Graphics::clMaroon;
- g_DispColor[ 4] = Graphics::clGreen;
- g_DispColor[ 5] = Graphics::clMenuHighlight;
- g_DispColor[ 6] = Graphics::clBackground;
- g_DispColor[ 7] = Graphics::clPurple;
- g_DispColor[ 8] = Graphics::clTeal;
- g_DispColor[ 9] = Graphics::clYellow;
- g_DispColor[10] = Graphics::clFuchsia;
- g_DispColor[11] = Graphics::clAqua;
- g_DispColor[12] = Graphics::clMoneyGreen;
- g_DispColor[13] = Graphics::clSkyBlue;
- g_DispColor[14] = Graphics::clRed;
- g_DispColor[15] = Graphics::clLime;
- g_DispColor[16] = Graphics::clYellow;
- g_DispColor[17] = Graphics::clBlue;
- g_DispColor[18] = Graphics::clFuchsia;
- g_DispColor[19] = Graphics::clAqua;
- g_DispColor[20] = Graphics::clMoneyGreen;
- g_DispColor[21] = Graphics::clActiveCaption;
- #else
- g_DispColor[ 0] = Graphics::clLime;
- g_DispColor[ 1] = (TColor)RGB(0xFF, 0x00, 0x00);
- g_DispColor[ 2] = (TColor)RGB(0x00, 0x00, 0xFF);
- g_DispColor[ 3] = (TColor)RGB(0xFF, 0x82, 0x00);
- g_DispColor[ 4] = (TColor)RGB(0x94, 0x00, 0xD3);
- g_DispColor[ 5] = (TColor)RGB(0x00, 0x00, 0x00);
- g_DispColor[ 6] = (TColor)RGB(0x82, 0x82, 0x82);
- g_DispColor[ 7] = (TColor)RGB(0x1E, 0x90, 0xFF);
- g_DispColor[ 8] = (TColor)RGB(0xB9, 0x06, 0x2F);
- g_DispColor[ 9] = (TColor)RGB(0x8c, 0x00, 0x8c);
- g_DispColor[10] = (TColor)RGB(0xFF, 0x82, 0x00);
- g_DispColor[11] = (TColor)RGB(0x94, 0x00, 0xD3);
- g_DispColor[12] = (TColor)RGB(0xB0, 0xC4, 0xDE);
- g_DispColor[13] = (TColor)RGB(0x00, 0xBF, 0xFF);
- g_DispColor[14] = (TColor)RGB(0x87, 0xCE, 0xEB);
- g_DispColor[15] = (TColor)RGB(0x87, 0xCE, 0xFA);
- g_DispColor[16] = (TColor)RGB(0xAD, 0xD8, 0xE6);
- g_DispColor[17] = (TColor)RGB(0xB0, 0xE0, 0xE6);
- g_DispColor[18] = (TColor)RGB(0xE6, 0xE6, 0xFA);
- g_DispColor[19] = (TColor)RGB(0xF0, 0xF8, 0xFF);
- #endif
- }
- //---------------------------------------------------------------------------
- TColor APP_GetDisplayColor(int ASeq)
- {
- return g_DispColor[ASeq % MAX_DISPCOLOR];
- }
- //---------------------------------------------------------------------------
- void APP_DelVmsSizeCombo(TcxComboBox *cboBox)
- {
- TStrings *pStrItems;
- TVmsSizeType *Ov;
- pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
- for (int ii = pStrItems->Count-1; ii >= 0; ii--)
- {
- Ov = (TVmsSizeType *)pStrItems->Objects[ii];
- if (Ov != NULL)
- {
- delete Ov;
- Ov = NULL;
- }
- }
- }
- //---------------------------------------------------------------------------
- void APP_FillVmsSizeType(TcxComboBox *cboBox, bool bAddAll/*=false*/)
- {
- String sQry;
- TStrings *pStrItems;
- TADOQuery *pADO = NULL;
- APP_DelVmsSizeCombo(cboBox);
- pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
- ((TcxComboBox *)cboBox)->Properties->Items->Clear();
- FOR_STL(TVmsType*, pObj, VmsTypeManager->FLists)
- {
- String sTypeCd = pObj->VMS_TYPE_CD;
- String sTypeNm = pObj->VMS_TYPE_NM;
- int nW = pObj->VMS_WDTH;
- int nH = pObj->VMS_HGHT;
- pStrItems->AddObject(" [" + sTypeCd + "] " + sTypeNm + " (" + String(nW) + "x" + String(nH) + ")", new TVmsSizeType(sTypeCd, sTypeNm, nW, nH) );
- }
- if (bAddAll)
- {
- String sAllName = "전체";
- pStrItems->AddObject(" [ALL] 전체" , new TVmsSizeType("ALL", sAllName, 384, 64));
- }
- cboBox->ItemIndex = 0;
- }
- //---------------------------------------------------------------------------
- TVmsSizeType* APP_GetVmsSizeTypeObject(TcxComboBox *cboBox)
- {
- TStrings *pStrItems;
- TVmsSizeType *Ov = NULL;
- int nItemIndex;
- pStrItems = ((TcxComboBox *)cboBox)->Properties->Items;
- nItemIndex= ((TcxComboBox *)cboBox)->ItemIndex;
- if (nItemIndex < 0)
- {
- return Ov;
- }
- Ov = (TVmsSizeType *)pStrItems->Objects[nItemIndex];
- if (Ov == NULL)
- {
- Ov = NULL;
- }
- return Ov;
- }
- //---------------------------------------------------------------------------
- void APP_ImageClear(TCanvas *c, int offX, int offY, int w, int h, TColor color)
- {
- try
- {
- c->Pen->Color = clWhite;
- c->Pen->Width = 0;
- c->Pen->Style = psClear;
- c->Brush->Style = bsSolid;
- c->Brush->Color = color;
- c->Rectangle(offX, offY, w+offX+2, h+offY+2);
- }
- catch(...)
- {
- }
- }
- //---------------------------------------------------------------------------
- #include <DateUtils.hpp>
- TDateTime APP_StrToDateTime(String AStrDateTime)
- {
- TDateTime dtReturnValue = NULL;
- if (AStrDateTime.IsEmpty()) return dtReturnValue;
- if (AStrDateTime.Length() != 14) return dtReturnValue;
- AnsiString sDateTime = AnsiString(AStrDateTime);
- try
- {
- #if 0
- sDateTime.printf(L"%s-%s-%s %s:%s:%s",
- AStrDateTime.SubString( 1, 4).c_str(),
- AStrDateTime.SubString( 5, 2).c_str(),
- AStrDateTime.SubString( 7, 2).c_str(),
- AStrDateTime.SubString( 9, 2).c_str(),
- AStrDateTime.SubString(11, 2).c_str(),
- AStrDateTime.SubString(13, 2).c_str());
- dtReturnValue = StrToDateTime(sDateTime);
- #endif
- // swscanf(sRgb.c_str(), L"%d,%d,%d", &r, &g, &b);
- int year, month, day, hour, minute, second;
- sscanf(sDateTime.c_str(), "%4d%2d%2d%2d%2d%2d", &year, &month, &day, &hour, &minute, &second);
- dtReturnValue = EncodeDateTime(year, month, day, hour, minute, second, 0);
- }
- catch(...)
- {
- }
- return dtReturnValue;
- }
- //---------------------------------------------------------------------------
- void APP_SetSummaryItemKind(TcxSummaryEventArguments &Arguments,
- TcxSummaryEventOutArguments &OutArguments,
- int pKind,
- bool pCaptionDisplay,
- bool pPointDisplay)
- {
- #if 0
- String sAvgCaption, sSumCaption, sMinCaption, sMaxCaption, sCntCaption;
- sAvgCaption = "";
- sMinCaption = "";
- sMaxCaption = "";
- //sCntCaption = "";
- sSumCaption = "";
- if (pCaptionDisplay)
- {
- sAvgCaption = "";//"평균: ";
- sMinCaption = "최소: ";
- sMaxCaption = "최대: ";
- if (pKind == 1)
- {
- sSumCaption = "소계: ";
- }
- else
- {
- sSumCaption = "합계: ";
- }
- }
- //sCntCaption = " 건";
- #endif
- #if 0
- if (VarIsNull(OutArguments.Value))
- {
- OutArguments.Done = true;
- return;
- }
- #endif
- #if 0
- if (Arguments.SummaryItem->Kind == skSum)
- {
- if (!VarIsNull(OutArguments.Value))
- {
- if (!VarSameValue(OutArguments.Value, Variant(0)))
- {
- OutArguments.CountValue++;
- OutArguments.SummaryValue += OutArguments.Value;
- OutArguments.Done = true;
- }
- else
- {
- //OutArguments.CountValue--;
- OutArguments.Done = true;
- }
- }
- else
- {
- //OutArguments.CountValue--;
- OutArguments.Done = true;
- }
- }
- else
- #endif
- if (Arguments.SummaryItem->Kind == skAverage)
- {
- if (!VarIsNull(OutArguments.Value))
- {
- if (!VarSameValue(OutArguments.Value, Variant(0)))
- {
- OutArguments.CountValue++;
- //OutArguments.Value = Variant(0);
- OutArguments.SummaryValue += OutArguments.Value;
- OutArguments.Done = true;
- }
- else
- {
- //OutArguments.CountValue--;
- OutArguments.Done = true;
- }
- }
- else
- {
- //OutArguments.CountValue--;
- OutArguments.Done = true;
- }
- #if 0
- if (pPointDisplay)
- Arguments.SummaryItem->Format = sAvgCaption + "#,##0.0";
- else
- Arguments.SummaryItem->Format = sAvgCaption + "#,##0";
- #endif
- }
- #if 0
- else if (Arguments.SummaryItem->Kind == skSum)
- Arguments.SummaryItem->Format = sSumCaption + "#,##0.##";
- else if (Arguments.SummaryItem->Kind == skMin)
- Arguments.SummaryItem->Format = sMinCaption + "#,##0.##";
- else if (Arguments.SummaryItem->Kind == skMax)
- Arguments.SummaryItem->Format = sMaxCaption + "#,##0.##";
- else if (Arguments.SummaryItem->Kind == skCount)
- Arguments.SummaryItem->Format = "#,##0" + sCntCaption;
- #endif
- }
- //---------------------------------------------------------------------------
|