Exemplo n.º 1
0
        private void Save(Action <DatabaseWriter> save)
        {
            IsEnabled = false;

            var info     = Cache.DbInfo;
            var database = Cache.Database;
            var writer   = new DatabaseWriter();

            info.OpenDatabaseFile(x => writer
                                  .LoadExisting(x, info.Data.MasterKey));

            save(writer);
            info.SetDatabase(x => writer.Save(
                                 x, database.RecycleBin));

            IsEnabled = true;
            ThreadPool.QueueUserWorkItem(_ => ListItems(
                                             _group, Cache.Database.RecycleBin));

            Cache.UpdateRecents();
            lstHistory.ItemsSource = null;

            ThreadPool.QueueUserWorkItem(_ =>
                                         ListHistory(database));

            Dispatcher.BeginInvoke(() =>
                                   info.NotifyIfNotSyncable());
        }
Exemplo n.º 2
0
        private void Save()
        {
            progBusy.IsBusy = true;

            string groupId;

            if (!NavigationContext.QueryString
                .TryGetValue("group", out groupId))
            {
                groupId = null;
            }

            ThreadPool.QueueUserWorkItem(_ =>
            {
                var info     = Cache.DbInfo;
                var database = Cache.Database;
                var writer   = new DatabaseWriter();

                info.OpenDatabaseFile(x => writer
                                      .LoadExisting(x, info.Data.MasterKey));

                if (_entry.ID != null)
                {
                    _binding.Save();
                    writer.Details(_entry);
                }
                else
                {
                    database.AddNew(
                        _entry, groupId);

                    writer.New(_entry);
                }

                info.SetDatabase(x => writer.Save(
                                     x, database.RecycleBin));

                Dispatcher.BeginInvoke(() =>
                {
                    UpdateNotes();
                    progBusy.IsBusy     = false;
                    _binding.HasChanges = false;

                    if (!info.NotifyIfNotSyncable())
                    {
                        new ToastPrompt
                        {
                            Title           = Properties.Resources.SavedTitle,
                            Message         = Properties.Resources.SavedCaption,
                            TextOrientation = System.Windows.Controls
                                              .Orientation.Vertical,
                        }.Show();
                    }
                });

                ThreadPool.QueueUserWorkItem(
                    __ => Cache.AddRecent(_entry.ID));
            });
        }
Exemplo n.º 3
0
        private void Save(Action <DatabaseWriter> save)
        {
            IsEnabled = false;

            var info     = Cache.DbInfo;
            var database = Cache.Database;
            var writer   = new DatabaseWriter();

            info.OpenDatabaseFile(x => writer
                                  .LoadExisting(x, info.Data.MasterKey));

            save(writer);
            info.SetDatabase(x => writer.Save(
                                 x, database.RecycleBin));

            IsEnabled = true;
        }