internal string RestoreDB(string URL, string BackupPath,bool makeNewDB) { string DBName = GetDBNameFromURL(URL); ConnectionVO cvo = new ConnectionVO(URL, DBName); WebServiceServer.ServerMain.getInstance().RestoreDB(BackupPath, cvo, makeNewDB); return DBName; }
internal string CreateDB(string URL) { string DBName = GetDBNameFromURL(URL); ConnectionVO cvo = new ConnectionVO(URL, DBName); WebServiceServer.ServerMain.getInstance().CreateDB(cvo); return DBName; }
internal void AddDBConnection(ConnectionVO connVO) { //잘못된 URL형식 걸러내기 if (!(connVO.ServiceURL.Contains("http://")) || (connVO.ServiceURL.Replace("http://", string.Empty).Length == 0)) { return; } try { IDBService DBModel = new PostgresSQLDBServicecs(connVO); ConnDic.Add(connVO.ServiceURL, DBModel); ActiveDBKeyList.Add(connVO.ServiceURL); } catch (Exception ex) { LogController.getInstance().WriteLogFile(ex.Message); } }
public PostgresSQLDBServicecs(ConnectionVO connVO, string HostURL) { try { this.myConnVO = connVO; NpgsqlConnectionStringBuilder nsb = new NpgsqlConnectionStringBuilder(); nsb.Host = HostURL; nsb.Port = 5432; nsb.SSL = false; nsb.IntegratedSecurity = false; nsb.UserName = "******"; nsb.Database = connVO.DataBaseName; nsb.Password = connVO.DBPassword; NpgConn = new NpgsqlConnection(nsb.ToString()); NpgConn.Open(); } catch (Exception ex) { throw ex; } }
public void AddService(ConnectionVO connVO) { if (!this.ServerReady) { throw new Exception("서버가 준비되지 않았습니다"); } //중복된 URL골라내기 bool isDuplicate = false; IDictionary<string,bool> serviceDic=WebServiceServer.ServerMain.getInstance().ActiveServiceDic; ICollection<string> urlList = serviceDic.Keys; foreach (string url in urlList) { if (connVO.ServiceURL==url) { isDuplicate = true; break; } } if (!isDuplicate) { ServerConsole.AddService(connVO); } }
public void StartService(ConnectionVO connVO) { if (!this.ServerReady) { throw new Exception("서버가 준비되지 않았습니다"); } if (ServerConsole.ActiveServiceDic[connVO.ServiceURL]) { throw new Exception("이미 활성화된 서비스 입니다"); } ServerConsole.AddService(connVO); }
public void RestoreDB(string BackupFilePath, ConnectionVO connVO,bool makeNewDB) { DBController.RestoreDB(BackupFilePath, connVO, makeNewDB); }
public void DropDB(ConnectionVO connVO) { DBController.getInstance().DropDB(connVO); }
public void CreateDB(ConnectionVO connVO) { DBController.getInstance().CreateDB(connVO); }
public void AddService(ConnectionVO connVO) { this.ServiceConnController.AddServiceURL(connVO.ServiceURL); dbConn.AddDBConnection(connVO); CheckServices(); }
public static void ExecScript(string scriptPath, ConnectionVO connVO) { if (!new DBEngineModel().CheckServerEngine()) { throw new Exception("PostgresSQL서버가 설치되어 있지 않습니다. 프로그램을 다시 시작하여 주십시오"); } string psqlPath = string.Format("{0}\\psql.exe", new DBEngineModel().GetPostSQLUtillPath()); string psql_args = string.Format("-h {0} -p {1} -U {2} -d {3} -a -f {4}", connVO.HostURL,connVO.port,connVO.DBID, connVO.DataBaseName, scriptPath); new FileExecuter().Exec(psqlPath, psql_args); }
internal void DropDB(string URL) { string DBName = GetDBNameFromURL(URL); ConnectionVO cvo = new ConnectionVO(URL, DBName); WebServiceServer.ServerMain.getInstance().DropDB(cvo); }
public static void DropDB( ConnectionVO connVO) { if (!new DBEngineModel().CheckServerEngine()) { throw new Exception("PostgresSQL서버가 설치되어 있지 않습니다. 프로그램을 다시 시작하여 주십시오"); } string dropdbPath = string.Format("{0}\\dropdb.exe", new DBEngineModel().GetPostSQLUtillPath()); string dropdb_args = string.Format("-h {0} -p {1} -U {2} {3}", connVO.HostURL, connVO.port, connVO.DBID, connVO.DataBaseName); new FileExecuter().Exec(dropdbPath, dropdb_args); }
internal static void RestoreDB(string BackupFilePath, ConnectionVO connVO, bool makeNewDB) { PostgresSQLDBServicecs.Restore(BackupFilePath, connVO, makeNewDB); }
internal void DropDB(ConnectionVO connVO) { try { //db가 존재하는지 검증 IDBService ds = new PostgresSQLDBServicecs(connVO); ds.Dispose(); } catch (Exception) { return; //DB가 없는 경우는 그냥 나간다 } try { //DB에 연결되어 있는 경우는 연결 종료한다 ConnDic[connVO.ServiceURL].Dispose(); } catch (Exception) { } PostgresSQLDBServicecs.DropDB(connVO); }
internal void CreateDB(ConnectionVO connVO) { try { //db가 이미 존재하는지 검증 IDBService ds = new PostgresSQLDBServicecs(connVO); ds.Dispose(); return; } catch (Exception) { //DB가 없으면 DB를 만든다 PostgresSQLDBServicecs.CreateDB(connVO); PostgresSQLDBServicecs.ExecScript(string.Format("{0}\\lib\\htpDBSchema.sql", Environment.CurrentDirectory), connVO); } }
public static void Restore(string BackupFilePath, ConnectionVO connVO,bool makeNewDB) { if (!new DBEngineModel().CheckServerEngine()) { throw new Exception("PostgresSQL서버가 설치되어 있지 않습니다. 프로그램을 다시 시작하여 주십시오"); } //[1] 백업파일 압축해제 string tmpDump = string.Format("{0}\\tmpDump{1}.dump", BackupFilePath.Substring(0, BackupFilePath.LastIndexOf("\\")), DateTime.Now.Ticks); new ZIPManager().UnZip(tmpDump, BackupFilePath); if (!File.Exists(tmpDump)) { return; } //DB생성 if (makeNewDB) { CreateDB(connVO); ExecScript(string.Format("{0}\\lib\\htpDBSchema.sql", Environment.CurrentDirectory), connVO); } ExecScript(tmpDump, connVO); //임시 덤프파일 삭제 File.Delete(tmpDump); }
/// <summary> /// 웹서비스를 상황에 맞게 세팅 /// </summary> /// <param name="CommonSettingsVO"> /// 공통설정정보VO /// 없으면 null입력 /// </param> /// <param name="serviceURLDic"> /// 서비스 정보 리스트 /// key: url value:DBPath /// 없으면 null 입력 /// </param> private void SetWebService(CommonSettingsVO CommonSettingsVO, IDictionary<string, string> serviceURLDic) { if (CommonSettingsVO == null) { //[1]공통설정정보가 없는 경우의 예외처리 WebServiceManager = null; MessageBox.Show("서비스를 시작하지 못했습니다. 먼저 서버설정을 하여 주십시오"); return; } else if (serviceURLDic == null || serviceURLDic.Count==0) { //[2]서비스 정보 목록이 없는경우 예외처리 WebServiceManager = new WebServiceManager(CommonSettingsVO); if (!WebServiceManager.ServerReady) { WebServiceManager.ServerOn(rdSecurityMode.Checked); } } else { //[3] 정상적인 경우의 처리 WebServiceManager = new WebServiceManager(CommonSettingsVO); if (!WebServiceManager.ServerReady) { bool UseSecurity = false; if (CommonSettingsVO.MessageCredentialType!=MessageCredentialType.None) { UseSecurity = true; } WebServiceManager.ServerOn(UseSecurity); } IList<ConnectionVO> connList = new List<ConnectionVO>(); //웹서비스 Param foreach (string url in serviceURLDic.Keys) { ConnectionVO cvo = new ConnectionVO(url,serviceURLDic[url]); connList.Add(cvo); } WebServiceManager.AddService(connList); } }
public static void CreateDB(ConnectionVO connVO) { try { //[1] postgresSQL설치여부 검증 if (!new DBEngineModel().CheckServerEngine()) { throw new Exception("PostgresSQL서버가 설치되어 있지 않습니다. 프로그램을 다시 시작하여 주십시오"); } //[2] postgresSQL설치된 경로 가져오기 string createdbPath = string.Format("{0}/createdb.exe", new DBEngineModel().GetPostSQLUtillPath()); //[3] postgresSQL설치된 경로에서 createdb.exe 실행해서 DB생성 string createdb_args = string.Format("-h 127.0.0.1 -p {0} -U {1} -O {1} -E {2} {3}", connVO.port, connVO.DBID, connVO.Charset, connVO.DataBaseName); new FileExecuter().Exec(createdbPath, createdb_args); } catch (Exception ex) { throw ex; } }