コード例 #1
0
        private void RecoverAutoSaveFile(AutoSaveIndexEntry file)
        {
            Log.Debug("{class} {method} {message}", "DocumentTabViewModel", "RecoverAutoSaveFile", $"Starting AutoSave Recovery for {file.DisplayName} ({file.AutoSaveId})");
            var newDoc = _documentFactory(_windowManager, _eventAggregator);

            using (new StatusBarMessage(newDoc, $"Recovering \"{file.DisplayName}\""))
            {
                newDoc.DisplayName    = file.DisplayName;
                newDoc.IsDiskFileName = file.IsDiskFileName;
                newDoc.FileName       = file.OriginalFileName;
                newDoc.AutoSaveId     = file.AutoSaveId;
                newDoc.State          = DocumentState.RecoveryPending;

                Items.Add(newDoc);
                ActivateItem(newDoc);
                ActiveDocument = newDoc;
                newDoc.IsDirty = true;

                file.ShouldOpen = false;

                _eventAggregator.PublishOnUIThread(new OutputMessage(MessageType.Information, $"Recovering File: '{file.DisplayName}'"));

                Log.Debug("{class} {method} {message}", "DocumentTabViewModel", "RecoverAutoSaveFile", $"Finished AutoSave Recovery for {file.DisplayName} ({file.AutoSaveId})");
            }
        }
コード例 #2
0
        private void RecoverAutoSaveFile(AutoSaveIndexEntry file)
        {
            var newDoc = _documentFactory(_windowManager, _eventAggregator);

            using (new StatusBarMessage(newDoc, $"Recovering \"{file.DisplayName}\""))
            {
                newDoc.DisplayName    = file.DisplayName;
                newDoc.IsDiskFileName = file.IsDiskFileName;
                newDoc.FileName       = file.OriginalFileName;
                newDoc.AutoSaveId     = file.AutoSaveId;
                newDoc.State          = DocumentState.RecoveryPending;

                Items.Add(newDoc);
                ActivateItem(newDoc);
                ActiveDocument = newDoc;
                newDoc.IsDirty = true;

                file.ShouldOpen = false;
                //_eventAggregator.PublishOnUIThreadAsync(message);

                //return newDoc;

                // hack - need to wait for the document to load properly
                // otherwise the view model only appears to be semi-loaded
                // and we get errors when the auto save timer kicks in
                //while (newDoc.State != DocumentState.Loaded)
                //{
                //    Thread.Sleep(100);
                //    Log.Verbose("{class} {method} {message}", "DocumentTabViewModel", "RecoverAutoSaveFile", "Waiting for document to reach the loaded state");
                //}
                Log.Information("{class} {method} {message}", "DocumentTabViewModel", "RecoverAutoSaveFile", $"AutoSave Recovery complete for {file.DisplayName} ({file.AutoSaveId})");
            }
        }