Exemplo n.º 1
0
 private void dB복원ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     //[변수 확정하기]
     string url = this.lvServiceList.SelectedItems[0].SubItems[0].Text;
     string DBName = new DBManager().GetDBNameFromURL(url);
     //[백업파일 존재여부 확인]
     bool FileExist = false;
     foreach (string FileName in Directory.GetFiles(CommonSettingsVO.BackupDIRPath))
     {
         string _FileName = FileName.Replace(CommonSettingsVO.BackupDIRPath + "\\","");
         if (_FileName.Length<=15)
         {
             continue;
         }
         _FileName = _FileName.Replace(_FileName.Substring(0, 15),string.Empty);
         _FileName = _FileName.Replace(".gz",string.Empty);
         if (_FileName == DBName)
         {
             FileExist = true;
             break;
         }
     }
     if (!FileExist)
     {
         MessageBox.Show("해당 서비스에 해당하는 백업파일이 존재하지 않습니다");
         return;
     }
     //[1] 해당 DB 초기화 또는 DB삭제
     new DBManager().DropDB(url);
     //[2] 백업파일 덤프 실행하기
     //가장 최근에 백업된 파일 찾기
     long lastestbackup=0;
     foreach (string bk in Directory.GetFiles(this.CommonSettingsVO.BackupDIRPath))
     {
         if (!bk.Contains(DBName))
         {
             continue;
         }
         string bkName = bk.Replace(this.CommonSettingsVO.BackupDIRPath+"\\",string.Empty);
         bkName = bkName.Replace("_"+DBName,string.Empty).Replace(".gz",string.Empty);
         if (lastestbackup<Convert.ToInt64(bkName))
         {
             lastestbackup = Convert.ToInt64(bkName);
         }
     }
     string lastestbackupFile = string.Format("{0}\\{1}_{2}.gz",this.CommonSettingsVO.BackupDIRPath,lastestbackup,DBName);
     //백업파일 덤프 실행
     new DBManager().RestoreDB(url, lastestbackupFile, true);
 }
Exemplo n.º 2
0
        private void DeleteAllServices( )
        {
            try
            {
                ServiceURLControllers suc = new ServiceURLControllers();
                IList<ServiceInfo> serviceList = suc.SelectServiceInfo();
                DBManager dm = new DBManager();
                //모든 서비스정보 삭제
                suc.DeleteServiceInfoFile();
                //모든 웹서비스 해제
                this.WebServiceManager.DeleteService();
                //모든 DB드롭
                foreach (ServiceInfo si in serviceList)
                {
                    dm.DropDB(si.ServiceURL);
                }
                this.lvServiceList.Items.Clear();
            }
            catch(KeyNotFoundException)
            {
                return;
            }
            catch (Exception)
            {

                throw;
            }
        }
Exemplo n.º 3
0
        //private void linkDBFinder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        //{
        //    if (rdDBFilePath.Checked)
        //    {
        //        OpenFileDialog ofd = new OpenFileDialog();
        //        if (ofd.ShowDialog() == DialogResult.OK)
        //        {
        //            txtDBPath.Text = ofd.FileName;
        //            btnAdd.Enabled = true;
        //            btnDelete.Enabled = true;
        //        }
        //    }
        //    else
        //    {
        //        FolderBrowserDialog fbd = new FolderBrowserDialog();
        //        if (fbd.ShowDialog() == DialogResult.OK)
        //        {
        //            txtDBPath.Text = fbd.SelectedPath;
        //            if (rdCreateDB.Checked)
        //            {
        //                btnAdd.Enabled = true;
        //                btnDelete.Enabled = true;
        //            }
        //        }
        //    }
        //}
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //DB생성 및 복원
            string DBName = new DBManager().GetDBNameFromURL(txtServiceURL.Text);
            try
            {
                if (rdCreateDB.Checked)
                {
                    //DB생성
                    new DBManager().CreateDB(txtServiceURL.Text);
                }
                else if (rdRestoreDB.Checked)
                {
                    if (txtBackupFile.Text == string.Empty)
                    {
                        MessageBox.Show("백업파일이 없어서 DB를 복원할수 없습니다");
                        return;
                    }
                    //DB복원
                    new DBManager().RestoreDB(txtServiceURL.Text, txtBackupFile.Text,true);
                }
                else
                {
                    MessageBox.Show("DB생성을 할수 없습니다");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("DB생성을 할수 없습니다 :{0}",ex.Message));
                return;
            }

            AddService(txtServiceURL.Text, DBName);
        }