Ejemplo n.º 1
0
        public override void Execute()
        {
            if ((SceneElement)this.SceneViewModel.FindPanelClosestToRoot() == null)
            {
                return;
            }
            if (this.importManager == null)
            {
                IServices services = this.SceneViewModel.DesignerContext.Services;
                this.importManager = new ImportManager(this.SceneViewModel.DesignerContext.ImportService, services.GetService <IPrototypingService>(), services.GetService <IMessageDisplayService>());
            }
            DoWorkEventArgs args = new DoWorkEventArgs((object)null);

            args.Result = (object)AsyncProcessResult.Done;
            IImportManagerContext importManagerContext = (IImportManagerContext) new ImportManagerContext((string)null, this.SceneViewModel, (IProject)null, true);

            importManagerContext.FileName = this.FilePath;
            this.importManager.Import(importManagerContext, this.filterImportersID, args);
            if (this.helper == null)
            {
                this.helper = new AsyncExecutionHelper();
            }
            if (!args.Result.Equals((object)AsyncProcessResult.StillGoing))
            {
                return;
            }
            this.helper.Clear();
            this.helper.StartAsyncProcess(this.SceneViewModel.DesignerContext.ExpressionInformationService, new Action <object, DoWorkEventArgs>(this.DoWork), new EventHandler(this.OnBeginTask), new EventHandler(this.OnCompleteTask), (EventHandler)null, new EventHandler(this.OnKillTask));
        }
Ejemplo n.º 2
0
 private void ResetInternal()
 {
     this.hostData.Clear();
     this.insertionPoint          = (ISceneInsertionPoint)null;
     this.initialInsertionPoint   = (ISceneInsertionPoint)null;
     this.supportingFolderName    = (string)null;
     this.supportingDirectoryPath = (string)null;
     this.asyncHandler            = (Action <object, DoWorkEventArgs>)null;
     this.asyncHandlerArgument    = (object)null;
     this.countMessages           = 0;
     this.completeRatio           = 0.0;
     this.importContext           = (IImportManagerContext)null;
     if (this.temporaryFolderPlaceholder != null)
     {
         this.temporaryFolderPlaceholder.Dispose();
     }
     this.temporaryFolderPlaceholder = new ProjectPathHelper.TemporaryDirectory(false, true);
     this.supportingFiles            = (IList <KeyValuePair <string, string> >) new List <KeyValuePair <string, string> >();
 }
Ejemplo n.º 3
0
        public bool Import(IImportManagerContext importManagerContext, string[] filterImportersId, DoWorkEventArgs args)
        {
            this.ResetInternal();
            this.importContext = importManagerContext;
            this.uilessMode    = !string.IsNullOrEmpty(importManagerContext.FileName);
            IImporter importer = this.PromptUserForAnImporter(filterImportersId);

            if (importer == null)
            {
                return(false);
            }
            this.importContext.CreateEditTransaction();
            Stream importData = (Stream)null;
            object property1  = importer.GetProperty("StripDotsFromLastPathComponent");

            if (property1 != null)
            {
                this.stripDotsFromLastPathComponent = (bool)property1;
            }
            object property2 = importer.GetProperty("ImportDataStoreSupport");

            if (property2 != null && (bool)property2)
            {
                IImporterDataStore importerDataStore = this.importService as IImporterDataStore;
                if (importerDataStore != null)
                {
                    string path = importerDataStore.GetDataFileEntry(this.importContext.FileName) ?? importerDataStore.CreateDataFileEntry(this.importContext.FileName);
                    if (path != null)
                    {
                        try
                        {
                            importData = (Stream) new FileStream(path, FileMode.OpenOrCreate);
                        }
                        catch (IOException ex)
                        {
                            importData = (Stream)null;
                        }
                    }
                }
            }
            bool flag1 = false;

            this.importService.ImporterManager = (object)this;
            this.CurrentlyImporting            = true;
            bool flag2;

            try
            {
                flag2 = importer.Import((object)this, DocumentReference.Create(this.importContext.FileName), importData);
            }
            catch (OperationCanceledException ex)
            {
                flag2 = false;
            }
            catch (Exception ex)
            {
                flag2 = false;
                flag1 = true;
            }
            if (importData != null)
            {
                importData.Dispose();
            }
            if (this.asyncHandler == null)
            {
                if (flag2)
                {
                    this.CommitImportOperation();
                    this.LogMessage(string.Format((IFormatProvider)CultureInfo.CurrentCulture, StringTable.ImportSucceededReportPane, new object[1]
                    {
                        (object)this.importContext.FileName
                    }));
                }
                else
                {
                    this.CancelImportOperation();
                    if (flag1)
                    {
                        int num = (int)this.messageDisplayService.ShowMessage(new MessageBoxArgs()
                        {
                            Message = string.Format((IFormatProvider)CultureInfo.CurrentCulture, this.countMessages == 0 ? StringTable.ImportFailed : StringTable.ImportFailedMoreInfo, new object[1]
                            {
                                (object)this.importContext.FileName
                            }),
                            Button = MessageBoxButton.OK,
                            Image  = MessageBoxImage.Hand
                        });
                    }
                }
                this.CurrentlyImporting = false;
                return(flag2);
            }
            args.Result = (object)AsyncProcessResult.StillGoing;
            return(true);
        }