public string Open(object location = null)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool? result = false;

            if (location == null)
            {
                result = dialog.ShowDialog();
                location = dialog.FileName;
            }
            else
                result = true;

            if (result == true && !string.IsNullOrWhiteSpace(location.ToString()))
            {
                string loc = location.ToString();
                _container.Resolve<IStateService>().AddToRecentAndSetCurrent(loc);
                IFileHistoryService serv = _container.Resolve<IFileHistoryService>();
                if (serv.AddToRecent(loc))
                    serv.UpdateStorage().ContinueWith(prevTask =>
                    {
                        var exc = prevTask.Exception.Flatten().InnerException;
                        _container.Resolve<Core.Infrastructure.Base.ILogger>()
                            .Log(Core.Infrastructure.Base.LogSeverity.Error, exc.Message, exc);
                        prevTask.Dispose();
                    }, System.Threading.Tasks.TaskContinuationOptions.NotOnRanToCompletion);

                DocumentLoadingEvent openValue = new DocumentLoadingEvent() { Path = loc };
                _eventAggregator.GetEvent<DocumentLoadingEvent>().Publish(openValue);
                return loc;
            }
            return string.Empty;
        }
示例#2
0
        private void Workspace_OnFileLoaded(object sender, DocumentLoadingEvent args)
        {
            this.textEditor.Text = System.IO.File.ReadAllText(args.Document.FilePath);
            this.CurrentFile     = args.Document;

            PropertyChanged(this, new PropertyChangedEventArgs("CurrentFile"));
        }
示例#3
0
        public string OpenFromID(string contentID)
        {
            if (!string.IsNullOrWhiteSpace(contentID))
            {
                _container.Resolve <IStateService>().AddToRecentAndSetCurrent(contentID);
                IFileHistoryService serv = _container.Resolve <IFileHistoryService>();
                if (serv.AddToRecent(contentID))
                {
                    serv.UpdateStorage().ContinueWith(prevTask =>
                    {
                        var exc = prevTask.Exception.Flatten().InnerException;
                        _container.Resolve <Core.Infrastructure.Base.ILogger>()
                        .Log(Core.Infrastructure.Base.LogSeverity.Error, exc.Message, exc);
                        prevTask.Dispose();
                    }, System.Threading.Tasks.TaskContinuationOptions.NotOnRanToCompletion);
                }

                DocumentLoadingEvent openValue = new DocumentLoadingEvent()
                {
                    Path = contentID
                };
                _eventAggregator.GetEvent <DocumentLoadingEvent>().Publish(openValue);
                return(contentID);
            }
            return(string.Empty);
        }
        public string OpenFromID(string contentID)
        {
            if (!string.IsNullOrWhiteSpace(contentID))
            {
                _container.Resolve<IStateService>().AddToRecentAndSetCurrent(contentID);
                IFileHistoryService serv = _container.Resolve<IFileHistoryService>();
                if (serv.AddToRecent(contentID))
                    serv.UpdateStorage().ContinueWith(prevTask =>
                    {
                        var exc = prevTask.Exception.Flatten().InnerException;
                        _container.Resolve<Core.Infrastructure.Base.ILogger>()
                            .Log(Core.Infrastructure.Base.LogSeverity.Error, exc.Message, exc);
                        prevTask.Dispose();
                    }, System.Threading.Tasks.TaskContinuationOptions.NotOnRanToCompletion);

                DocumentLoadingEvent openValue = new DocumentLoadingEvent() { Path = contentID };
                _eventAggregator.GetEvent<DocumentLoadingEvent>().Publish(openValue);
                return contentID;
            }
            return string.Empty;
        }
示例#5
0
        public string Open(object location = null)
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool?          result = false;

            if (location == null)
            {
                result   = dialog.ShowDialog();
                location = dialog.FileName;
            }
            else
            {
                result = true;
            }

            if (result == true && !string.IsNullOrWhiteSpace(location.ToString()))
            {
                string loc = location.ToString();
                _container.Resolve <IStateService>().AddToRecentAndSetCurrent(loc);
                IFileHistoryService serv = _container.Resolve <IFileHistoryService>();
                if (serv.AddToRecent(loc))
                {
                    serv.UpdateStorage().ContinueWith(prevTask =>
                    {
                        var exc = prevTask.Exception.Flatten().InnerException;
                        _container.Resolve <Core.Infrastructure.Base.ILogger>()
                        .Log(Core.Infrastructure.Base.LogSeverity.Error, exc.Message, exc);
                        prevTask.Dispose();
                    }, System.Threading.Tasks.TaskContinuationOptions.NotOnRanToCompletion);
                }

                DocumentLoadingEvent openValue = new DocumentLoadingEvent()
                {
                    Path = loc
                };
                _eventAggregator.GetEvent <DocumentLoadingEvent>().Publish(openValue);
                return(loc);
            }
            return(string.Empty);
        }
示例#6
0
 private void OnLoadingDocument(DocumentLoadingEvent args)
 {
     IsBusy = true;
     try
     {
         _container.Resolve <ILogger>().Log(LogSeverity.Info, string.Format("Begin load document: {0}", args.Path), null);
         System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
         IParsingService service = _container.Resolve <IParsingService>();
         Entries = new ObservableCollection <LogItem>(service.ParseLog(args.Path));
         _container.Resolve <IStateService>().AddToRecentAndSetCurrent(args.Path);
         _container.Resolve <ICommandManager>().Refresh();
     }
     catch (Exception ex)
     {
         _container.Resolve <ILogger>().Log(LogSeverity.Error, ex.Message, ex);
         MessageBox.Show(System.Windows.Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         IsBusy = false;
     }
 }
 private void OnLoadingDocument(DocumentLoadingEvent args)
 {
     IsBusy = true;
     try
     {
         _container.Resolve<ILogger>().Log(LogSeverity.Info, string.Format("Begin load document: {0}", args.Path), null);
         System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));
         IParsingService service = _container.Resolve<IParsingService>();
         Entries = new ObservableCollection<LogItem>(service.ParseLog(args.Path));
         _container.Resolve<IStateService>().AddToRecentAndSetCurrent(args.Path);
         _container.Resolve<ICommandManager>().Refresh();
     }
     catch (Exception ex)
     {
         _container.Resolve<ILogger>().Log(LogSeverity.Error, ex.Message, ex);
         MessageBox.Show(System.Windows.Application.Current.MainWindow, ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     finally
     {
         IsBusy = false;
     }
 }