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(Action<DatabaseWriter> save)
        { // TODO - TEST 
            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.CreateRecycleBin(
                x, database.RecycleBin));

            IsEnabled = true;
        }
Exemplo n.º 3
0
        private void Save()
        {
            progBusy.IsBusy = true;
            string errorMessage = string.Empty;
            string groupId;
            if (!NavigationContext.QueryString
                .TryGetValue("group", out groupId))
            {
                groupId = null;
            }

            if (IsReservedName())
            {
                errorMessage = Strings.EntryDetails_NameReserved;
            }

            var duplicate = GetAnyDuplicateField();
            if (duplicate != null)
                errorMessage = string.Format(Strings.EntryDetails_NameDuplicate, duplicate.Name);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage, "Warning", MessageBoxButton.OK);
                progBusy.IsBusy = false;
                return;
            }

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

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

                foreach (var fild in _fields)
                {
                    _entry.Add(new Field() { Name = fild.Name, Value = fild.Value, Protected = fild.Protected });
                }
                if (_entry.ID != null)
                {
                    _binding.Save();
                    writer.Details(_entry);
                }
                else
                {
                    database.AddNew(
                        _entry, groupId);

                    writer.New(_entry);
                }

                info.SetDatabase(x => writer.CreateRecycleBin(
                    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.º 4
0
        private void Save()
        {
            progBusy.IsBusy = true;

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

            ThreadPool.QueueUserWorkItem(_ =>
            {
                AnalyticsTracker.Track(_entry.ID != null
                    ? "save_entry" : "new_entry");

                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)
                    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;
                    CurrentEntry.HasChanges = false;

                    MessageBox.Show(
                        Properties.Resources.SavedCaption,
                        Properties.Resources.SavedTitle,
                        MessageBoxButton.OK);
                });

                ThreadPool.QueueUserWorkItem(
                    __ => Cache.AddRecent(_entry.ID));
            });
        }
Exemplo n.º 5
0
        private void Save()
        {
            progBusy.IsBusy = true;

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

            ThreadPool.QueueUserWorkItem(_ =>
            {
                AnalyticsTracker.Track("modify",
                    _entry.ID != null
                        ? "save_entry"
                        : "new_entry");

                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)
                    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));
            });
        }