Beispiel #1
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);
        }
Beispiel #2
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);
        }