//**************************************************************************
        //Name :CreateCompanyUtils
        //Description :describe ".sql" file and ".bat" file.
        //***************************************************************************
        public static void CreateCompanyUtils(string databasebam, string bakFileName, List <string> Otherquerylist)
        {
            FolderCreate.TEMPFolderCreate();
            string StartupPath = Application.StartupPath;

            string strPath = Application.StartupPath + "\\TEMP\\";

            #region sql str
            string sqlsb = "/****** Object:  Database [DAPRO] ON  PRIMARY ****/\r\n" +
                           "---------------Alrady exist check-------------------------\r\n" +
                           " IF (EXISTS (SELECT * FROM sys.databases where name='" + databasebam + "'))\r\n" +
                           "       RETURN\r\n" +
                           "       else	\r\n" +
                           "   \r\n" +
                           "---------------else part Alrady not exist check then run -------------------------  \r\n" +
                           " \r\n" +
                           "CREATE DATABASE [" + databasebam + "] ON  PRIMARY \r\n" +
                           "( NAME = N'IMAGINE', FILENAME = N'" + StartupPath + "\\" + databasebam + ".mdf' , SIZE = 13312KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )\r\n" +
                           " LOG ON \r\n" +
                           "( NAME = N'IMAGINE_log', FILENAME = N'" + StartupPath + "\\" + databasebam + "_log.LDF' , SIZE = 504KB , MAXSIZE = UNLIMITED, FILEGROWTH = 10%)\r\n" +
                           "---------------restore -------------------------  \r\n" +
                           "RESTORE database " + databasebam + " \r\n" +
                           "FROM  DISK=N'" + StartupPath + "\\" + bakFileName + "'\r\n" +
                           " WITH  REPLACE, RECOVERY\r\n" +
                           //********************Add other Query*********************************
                           listQueryToStringConvert(Otherquerylist);
            #endregion

            #region .bat str
            string cmdystr = AccessPermission.CMDAccessPermission() +
                             "echo============CLEAR====================================================\r\n" +
                             "echo off\r\n" +
                             "cls\r\n" +
                             "color B0\r\n" +
                             "@echo==================MAKE DB============================================\r\n" +
                             "sqlcmd -S " + SQLHelper.mDataSource + " -i %CD%\\CreateDBScript.sql";


            #endregion
            //create Task_Shedule Setting bat file
            WriteBat(strPath, sqlsb, "CreateDBScript.sql");
            // Create run sql ,make directory,backup database
            WriteBat(strPath, cmdystr, "CreateDBWithCMD.bat");
            RunCmd(strPath + "CreateDBWithCMD.bat");
        }
示例#2
0
        //*************************************************************************
        //Name:NewFolderCreate_mdfFileMove;
        //Description:Create New Folder And Move .mdf File when the Client server is selected
        //************************************************************************
        public void NewFolderCreate_mdfFileMove()
        {
            string path = System.IO.Directory.GetCurrentDirectory();
            string name = "\\TEMP";

            try
            {
                //TEMP folder create
                FolderCreate.TEMPFolderCreate();
                DirectoryInfo d = new DirectoryInfo(Application.StartupPath);
                foreach (var file in d.GetFiles("*.mdf"))
                {
                    File.Move(Application.StartupPath + "\\" + file.Name, path + name);
                }
            }
            catch (Exception e)
            {
                //MessageBox.Show(e.Message, "Error(Form:AppServerConfigWIndow)");
            }
        }
示例#3
0
        private void btnAutoBackup_Click(object sender, EventArgs e)
        {
            nudTime.Enabled = false;
            string BACKUPSOURCE = XMLTools.ReadXmlElementString(Application.StartupPath + "\\StoreProcedureInfo.xml", "BACKUPSOURCE");

            if (!BACKUPSOURCE.ISNullOrWhiteSpace())
            {
                FolderCreate.TEMPFolderCreate();//at first create temp folder Its must be importent

                Backup_RestoreTools.ComputerStartedBackup(BACKUPSOURCE);
                string APPPath = Application.StartupPath + "\\TEMP";
                CreateShortcutTools.CreateStartupShortcut(APPPath, APPPath + "\\DATABASE_BACKUP.bat");
                MessageBox.Show("PROCESS COMPLETE");
            }
            else
            {
                MessageBox.Show("Click 'OK' and go to Update Your Setting --->");
                btnSetting_Click(null, null);
            }
        }