public void ExecuteShutdown()
 {
     try
     {
         string path = "";
         bool   exists;
         try
         {
             path   = @"D:\المطعم";
             exists = Directory.Exists(path);
             if (!exists)
             {
                 Directory.CreateDirectory(path);
             }
         }
         catch
         {
         }
         try
         {
             path   = @"E:\المطعم";
             exists = Directory.Exists(path);
             if (!exists)
             {
                 Directory.CreateDirectory(path);
             }
         }
         catch
         {
             path = @"D:\المطعم";
         }
         using (GeneralDBContext db = new GeneralDBContext())
         {
             try
             {
                 string fileName = path + "\\RestaurantDB " + DateTime.Now.ToShortDateString().Replace('/', '-')
                                   + " - " + DateTime.Now.ToLongTimeString().Replace(':', '-');
                 string dbname     = db.Database.Connection.Database;
                 string sqlCommand = @"BACKUP DATABASE [{0}] TO  DISK = N'" + fileName + ".bak' WITH NOFORMAT, NOINIT,NAME = N'MyAir-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10";
                 db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, string.Format(sqlCommand, dbname));
             }
             catch
             {
             }
         }
         System.Windows.Application.Current.Shutdown();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private async void ExecuteBackupAsync()
        {
            try
            {
                if (BackupModel.Path == null)
                {
                    return;
                }
                using (GeneralDBContext db = new GeneralDBContext())
                {
                    try
                    {
                        Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                        string fileName = BackupModel.Path + "\\RestaurantDB " + DateTime.Now.ToShortDateString().Replace('/', '-')
                                          + " - " + DateTime.Now.ToLongTimeString().Replace(':', '-');
                        string dbname     = db.Database.Connection.Database;
                        string sqlCommand = @"BACKUP DATABASE [{0}] TO  DISK = N'" + fileName + ".bak' WITH NOFORMAT, NOINIT,NAME = N'MyAir-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10";
                        db.Database.ExecuteSqlCommand(TransactionalBehavior.DoNotEnsureTransaction, string.Format(sqlCommand, dbname));
                        BackupModel = new BackupDataModel();
                    }
                    catch
                    {
                        Mouse.OverrideCursor = null;
                        await currentWindow.HideMetroDialogAsync(backupDialog);

                        await currentWindow.ShowMessageAsync("فشل الحفظ", "يجب إختيار مكان آخر لحفظ النسخة الإحتياطية", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                        {
                            AffirmativeButtonText = "موافق",
                            DialogMessageFontSize = 25,
                            DialogTitleFontSize   = 30
                        });

                        await currentWindow.ShowMetroDialogAsync(backupDialog);

                        return;
                    }
                    finally
                    {
                        Mouse.OverrideCursor = null;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 public SpendingRepository(GeneralDBContext context)
     : base(context)
 {
 }
 public CategoryRepository(GeneralDBContext context)
     : base(context)
 {
 }
Exemplo n.º 5
0
 public BillRepository(GeneralDBContext context)
     : base(context)
 {
 }
 public ShiftRepository(GeneralDBContext context)
     : base(context)
 {
 }
 public RoleRepository(GeneralDBContext context)
     : base(context)
 {
 }
 public ItemRepository(GeneralDBContext context)
     : base(context)
 {
 }
 public UnitOfWork(GeneralDBContext context)
 {
     _context = context;
 }
 public UserRepository(GeneralDBContext context)
     : base(context)
 {
 }