Пример #1
0
        /// <summary>
        /// Do not call this method directly. Call App.Kp2a.LoadDatabase instead.
        /// </summary>
        public void LoadData(IKp2aApp app, IOConnectionInfo iocInfo, MemoryStream databaseData, CompositeKey compositeKey, ProgressDialogStatusLogger status, IDatabaseFormat databaseFormat)
        {
            PwDatabase pwDatabase = new PwDatabase();

            IFileStorage fileStorage = _app.GetFileStorage(iocInfo);
            Stream       s           = databaseData ?? fileStorage.OpenFileForRead(iocInfo);
            var          fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo);

            PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat);
            try
            {
                LastFileVersion = fileVersion;

                status.UpdateSubMessage("");

                Root = pwDatabase.RootGroup;
                PopulateGlobals(Root);


                KpDatabase   = pwDatabase;
                SearchHelper = new SearchDbHelper(app);

                _databaseFormat = databaseFormat;

                CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
                Loaded   = true;
            }
            catch (Exception)
            {
                Clear();
                throw;
            }
        }
Пример #2
0
        private void SetupProgressDialog(IKp2aApp app)
        {
            string currentMessage    = "Initializing...";
            string currentSubmessage = "";

            if (_progressDialogStatusLogger != null)
            {
                currentMessage    = _progressDialogStatusLogger.Message;
                currentSubmessage = _progressDialogStatusLogger.SubMessage;
            }

            if (_progressDialog != null)
            {
                var pd = _progressDialog;
                app.UiThreadHandler.Post(() =>
                {
                    pd.Dismiss();
                });
            }

            // Show process dialog
            _progressDialog = app.CreateProgressDialog(_activeActivity);
            _progressDialog.SetTitle(_app.GetResourceString(UiStringKey.progress_title));
            _progressDialogStatusLogger = new ProgressDialogStatusLogger(_app, _handler, _progressDialog);
            _progressDialogStatusLogger.UpdateMessage(currentMessage);
            _progressDialogStatusLogger.UpdateSubMessage(currentSubmessage);
        }
Пример #3
0
        /// <summary>
        /// Do not call this method directly. Call App.Kp2a.LoadDatabase instead.
        /// </summary>
        public void LoadData(IKp2aApp app, IOConnectionInfo iocInfo, MemoryStream databaseData, CompositeKey compositeKey, ProgressDialogStatusLogger status, IDatabaseFormat databaseFormat)
        {
            PwDatabase pwDatabase = new PwDatabase();

            IFileStorage fileStorage = _app.GetFileStorage(iocInfo);
            Stream s = databaseData ?? fileStorage.OpenFileForRead(iocInfo);
            var fileVersion = _app.GetFileStorage(iocInfo).GetCurrentFileVersionFast(iocInfo);
            PopulateDatabaseFromStream(pwDatabase, s, iocInfo, compositeKey, status, databaseFormat);
            try
            {
                LastFileVersion = fileVersion;

                status.UpdateSubMessage("");

                Root = pwDatabase.RootGroup;
                PopulateGlobals(Root);

                Loaded = true;
                KpDatabase = pwDatabase;
                SearchHelper = new SearchDbHelper(app);

                _databaseFormat = databaseFormat;

                CanWrite = databaseFormat.CanWrite && !fileStorage.IsReadOnly(iocInfo);
            }
            catch (Exception)
            {
                Clear();
                throw;
            }
        }