예제 #1
0
        /// <summary>
        /// Save the selected objects to the <see cref="AccessApp.WorkingCopyPath"/> path
        /// </summary>
        /// <returns>Number of saved objects</returns>
        /// <remarks>It's recomended to use the async version</remarks>
        public int SaveSelectedObjects()
        {
            List <IObjecOptions> selectedObjects = this.SelectedNodes;

            foreach (IObjecOptions name in selectedObjects)
            {
                AccessObject accessObject = AccessObject.CreateInstance(this.App, name.ObjectType, name.Name);
                accessObject.Save();
            }
            return(selectedObjects.Count);
        }
예제 #2
0
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            //see http://msdn.microsoft.com/en-us/library/9hk12d4y.aspx for Event-based async pattern
            //see http://stackoverflow.com/questions/6184/how-do-i-make-event-callbacks-into-my-win-forms-thread-safe

            List <IObjecOptions> selectedObjects = (List <IObjecOptions>)e.Argument;
            int i = 0;

            foreach (IObjecOptions name in selectedObjects)
            {
                i++;
                ((BackgroundWorker)sender).ReportProgress(i * 100 / selectedObjects.Count, name);
                AccessObject accessObject = AccessObject.CreateInstance(this.App, name.ObjectType, name.Name);
                accessObject.Save();
            }
            e.Result = selectedObjects.Count;
        }
예제 #3
0
        internal override CommandLine Run()
        {
            if (App == null && Objects.Count > 0)
            {
                InitializeAccessApplication();
            }
            foreach (IObjecOptions currentObject in Objects)
            {
                ObjectTypeExtension ote = App.AllowedContainers.Find(currentObject.ObjectType);

                Console.Write(Properties.Resources.Exporting, ote.FileExtension, currentObject);
                AccessObject accessObject = AccessObject.CreateInstance(App, currentObject.ObjectType, currentObject.ToString());
                accessObject.Options = currentObject.Options;
                string outputFile = Path.Combine(RootPath, ote.Container.InvariantName, currentObject.ToString()) +
                                    String.Concat(".", ote.FileExtension, ".txt");
                accessObject.Save(outputFile);
                Console.WriteLine(Properties.Resources.ColonOk);
            }
            App.Dispose();
            return(this);
        }