Esempio n. 1
0
        void bwBackup_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (File.Exists(tempPath + "\\" + "DB_Full.bak"))
                {
                    File.Delete(tempPath + "\\" + "DB_Full.bak");
                }


                int x = BaseDataBase._NonQuery(string.Format("BACKUP DATABASE [Ma3an] TO DISK = '{0}\\DB_Full.bak' WITH NOFORMAT, NOINIT, SKIP, NOREWIND, NOUNLOAD,  STATS = 10", tempPath, BaseDataBase.ConnectionStringMaster));
                if (x == -1)
                {
                    using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
                    {
                        zip.Password = "******";
                        string[] files = Directory.GetFiles(Environment.CurrentDirectory + "\\Data");
                        zip.AddFiles(files, "Data");
                        zip.AddFile(tempPath + "\\" + "DB_Full.bak", "");
                        zip.Save(e.Argument + "\\" + BaseDataBase.DateNow.ToString("DB_Backup_ddMMyyyy") + ".bak");
                    }

                    //ZipFile.CreateFromDirectory("Data", e.Argument + "\\" + BaseDataBase.DateNow.ToString("DB_Backup_ddMMyyyy") + ".bak", CompressionLevel.NoCompression, true);
                    //using (ZipArchive zip = ZipFile.Open(e.Argument + "\\" + BaseDataBase.DateNow.ToString("DB_Backup_ddMMyyyy") + ".bak", ZipArchiveMode.Update))
                    //{
                    //    zip.CreateEntryFromFile(tempPath + "\\" + "DB_Full.bak", "DB_Full.bak");
                    //}
                }
                else
                {
                    e.Cancel = true;
                }
            }
            catch (Exception ex) { e.Cancel = true; }
        }
Esempio n. 2
0
        public void galleryData_Change(IRibbonControl control, string selectedId, int selectedIndex)
        {
            string       fileName   = System.IO.Directory.GetFiles(Common.getConfigFolder(), "*.*")[selectedIndex];
            BaseDataBase db         = DbFactory.CreateDbInstanceFromXML();
            DataOutput   dataOutput = new DataOutput(Globals.ThisAddIn.Application, db);

            dataOutput.Execute(fileName);
        }
Esempio n. 3
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int?InternalSupportID = (int?)value;

            if (InternalSupportID == null)
            {
                return("Error");
            }
            return(BaseDataBase._Scalar("select dbo.[GetInternalSupportByID](" + InternalSupportID + ")"));
        }
Esempio n. 4
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int?ID = (int?)value;

            if (ID == null)
            {
                return("ERROR");
            }
            return(BaseDataBase._Scalar("select [dbo].[GetTrainedName](" + ID + ")"));
        }
Esempio n. 5
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int?ID = (int?)value;

            if (ID == null)
            {
                return("Naaalllll");
            }
            string s = BaseDataBase._Scalar("select dbo.[GetSupportGrouptAll](" + ID + ")");

            return(s.Replace("????", "\n").Replace("???", "\t\t\t"));
        }
        private void btnTestConnection_Click(object sender, EventArgs e)
        {
            BaseDataBase con = DbFactory.CreateDbInstance(ConnectionType,
                                                          txtUserId.Text, txtPassword.Text, txtServer.Text,
                                                          txtDatabase.Text);

            if (con.open())
            {
                MessageBox.Show("Connection OK!");
                con.close();
            }
            else
            {
                MessageBox.Show("Connection Fail!");
            }
        }
Esempio n. 7
0
        void bwRestore_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                if (Directory.Exists("Data"))
                {
                    Directory.Delete("Data", true);
                }
                if (Directory.Exists(tempPath + "\\Data"))
                {
                    Directory.Delete(tempPath + "\\Data", true);
                }
                if (File.Exists("DB_Full.bak"))
                {
                    File.Delete("DB_Full.bak");
                }
                if (File.Exists(tempPath + "\\DB_Full.bak"))
                {
                    File.Delete(tempPath + "\\DB_Full.bak");
                }

                using (Ionic.Zip.ZipFile zip = Ionic.Zip.ZipFile.Read(e.Argument.ToString()))
                {
                    zip.Password = "******";
                    zip.ExtractAll(Environment.CurrentDirectory, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                    zip.ExtractAll(tempPath, Ionic.Zip.ExtractExistingFileAction.OverwriteSilently);
                }
                //ZipFile.ExtractToDirectory(e.Argument.ToString(), Environment.CurrentDirectory);
                //ZipFile.ExtractToDirectory(e.Argument.ToString(), tempPath);

                BaseDataBase._NonQuery(@"ALTER DATABASE [Ma3an] SET SINGLE_USER WITH ROLLBACK IMMEDIATE", BaseDataBase.ConnectionStringMaster);
                int x = BaseDataBase._NonQuery(string.Format(@"RESTORE DATABASE [Ma3an] FROM DISK = '{0}' WITH  REPLACE;", tempPath + "\\DB_Full.bak"), BaseDataBase.ConnectionStringMaster);
                BaseDataBase._NonQuery(@"ALTER DATABASE [Ma3an] SET MULTI_USER", BaseDataBase.ConnectionStringMaster);
                if (x != -1)
                {
                    e.Cancel = true;
                }
            }
            catch (Exception ex)
            { e.Cancel = true; }
        }
 public DataOutput(Application iApp, BaseDataBase iDb)
 {
     this.application = iApp;
     this.db          = iDb;
 }
 public ExcelOutput(Application iApp, BaseDataBase iDb)
 {
     this.application = iApp;
     this.db          = iDb;
     initStyleFromXml();
 }