Beispiel #1
0
        public void BAT_FILE_CREATE_AND_RUN_CMD(string BackupStorePath, string timeOfBackup)
        {
            //New Folder Create
            NewFolderCreate();
            //string strPath = Application.StartupPath + "\\STORE_PROCEDURE\\";
            string Zippath = "rar a -ep " + BackupStorePath + "\\DB_BACKUP\\" + SQLHelper.mInitalCatalog + ".Zip " + BackupStorePath + "\\DB_BACKUP\\" + SQLHelper.mInitalCatalog + ".bak\r\n";

            #region ALL_DATABASE_BACKUP str
            string ALL_DATABASE_BACKUP = AccessPermission.CMDAccessPermission() +
                                         "@echo==================MAKE DIIRECTORY============================================\r\n" +
                                         "IF NOT EXIST " + BackupStorePath + "\\DB_BACKUP (\r\n" +
                                         "MD " + BackupStorePath + "\\DB_BACKUP\r\n" +
                                         "@ECHO FOLDER CREATE SUCCESSFULL.....................\r\n" +
                                         ")\r\n" +

                                         "echo=============BACKUP DATABASE=======================\r\n" +
                                         "set  DATABASENAME=" + SQLHelper.mInitalCatalog + "\r\n" +
                                         ":: filename format Name-Date \r\n" +
                                         "set BACKUPFILENAME=" + BackupStorePath + "\\DB_BACKUP\\" + SQLHelper.mInitalCatalog + ".bak \r\n" +
                                         "set SERVERNAME=" + SQLHelper.mDataSource + "\r\n" +
                                         "sqlcmd  -S %SERVERNAME%  -d %DATABASENAME% -Q \"BACKUP DATABASE [%DATABASENAME%] TO DISK = N'%BACKUPFILENAME%' WITH INIT , NOUNLOAD , NAME = N'%DATABASENAME% backup', NOSKIP , STATS = 10, NOFORMAT\"\r\n" +
                                         "echo .\r\n" +

                                         //CONVERT ZIP FILE____________________________________________________________
                                         "IF EXIST %ProgramFiles%\\WinRAR(go to ProgramFiles)\r\n" +
                                         "IF EXIST C:\\Program Files (x86)\\WinRAR(go to ProgramFiles86)\r\n" +
                                         ":ProgramFiles\r\n" +
                                         "set path=%ProgramFiles%\\WinRAR\r\n" +
                                         Zippath +
                                         ":ProgramFiles86\r\n" +
                                         "set path=C:\\Program Files (x86)\\WinRAR\r\n" + Zippath;

            #endregion

            #region SQL_AUTO_BACKUP str
            string SQL_AUTO_BACKUP = AccessPermission.CMDAccessPermission() +
                                     "@echo==================SQL_BACKUP_AUTORUN USE TASK SHEDULER===========================================\r\n" +
                                     "SCHTASKS.EXE /CREATE /SC DAILY /MO 1 /TN \"SQL_AUTOMATIC_BACKUP\" /ST " + timeOfBackup + ":00 /SD 01/01/2000 /TR '%CD%\\ALL_DATABASE_BACKUP.bat' /RU SYSTEM /F\r\n";

            #endregion

            //create Task_Shedule Setting bat file
            WriteBat(SQL_AUTO_BACKUP, "SQL_AUTO_BACKUP.BAT");
            // Create run sql ,make directory,backup database
            WriteBat(ALL_DATABASE_BACKUP, "ALL_DATABASE_BACKUP.bat");
            //run Task_Shedule Code
            RunCmd("SQL_AUTO_BACKUP.BAT");
        }
        //**************************************************************************
        //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");
        }
Beispiel #3
0
        public MainWindow()
        {
            InitializeComponent();
            AppInfo();
            GetButtonControl();
            pnlLogin.BringToFront();
            this.FormBorderStyle = FormBorderStyle.None;
            ThisMaximize();

            mPreviousSize = new Size(859, 517);
            int x = (this.Width - Screen.PrimaryScreen.WorkingArea.Width) / 2;
            int y = (this.Height - Screen.PrimaryScreen.WorkingArea.Height) / 2;

            mPreviousLocation = new Point(x, y);

            ApplicationDesign.btnObject = btnDashBoard;
            object o = (object)btnDashBoard;

            ApplicationDesign.SetButtonDesign(ref o);
            //Arup
            ChangeDateFormate();
            AccessPermission.GrantAccess();
        }
Beispiel #4
0
        public static void RunCmd(string CurrentAssemblyProduct, string UpdateSource, string mCurrentApplicationLocation, ref Panel pnl)
        {
            try
            {
                string str = AccessPermission.CMDAccessPermission() + "@echo Automatic Stop your Application..................\r\n" +
                             // "TASKKILL /F /IM " + CurrentAssemblyProduct + ".exe /T \r\n " +
                             "@echo Please wait Your process is running...........................\r\n" +
                             "XCopy /Y \"" + UpdateSource + "\" \"" + mCurrentApplicationLocation + "\"\r\n" +
                             "RD /S /Q \"" + UpdateSource + "\"\r\n" +
                             "\"" + Application.ExecutablePath + "\"";

                string batPath = WriteBat(str, mCurrentApplicationLocation);
                Thread a       = new Thread(new ThreadStart(() => Process.Start(batPath)));
                Application.Exit();
                a.Start();
                //Process.GetCurrentProcess().Kill();
            }
            catch (Exception e)
            {
                pnl.BackColor = Color.Red;
                MessageBox.Show("Alart : " + e.Message);
            }
        }