コード例 #1
0
ファイル: FilesTree.cs プロジェクト: rsram27/MSAccess-SVN
        private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            LoadObjectsAsyncParams loadParams = (LoadObjectsAsyncParams)e.Argument;

            AccessIO.BackupHelper backup = new AccessIO.BackupHelper(loadParams.App.FileName);
            backup.DoBackUp();
            string currentObjectName = null;

            try {
                List <IObjecOptions> selectedObjects = loadParams.SelectedObjects;
                int i = 0;
                foreach (IObjecOptions currentObject in selectedObjects)
                {
                    currentObjectName = currentObject.Name;
                    ((BackgroundWorker)sender).ReportProgress(i++ *100 / selectedObjects.Count, currentObject);
                    AccessObject accessObject = AccessObject.CreateInstance(loadParams.App, currentObject.ObjectType, currentObject.ToString());
                    accessObject.Options = currentObject.Options;
                    accessObject.Load(currentObjectName);
                }
                backup.Commit();
                e.Result = selectedObjects.Count;
            } catch (Exception ex) {
                backup.RollBack();
                string msg = String.Format(Properties.Resources.ErrorLoadingObject, currentObjectName, ex.Message);
                throw new Exception(msg, ex);
            }
        }
コード例 #2
0
ファイル: FilesTree.cs プロジェクト: rsram27/MSAccess-SVN
        /// <summary>
        /// Load, in background, the selected objects to the database referenced by <see cref="AccessApp.FileName"/>
        /// </summary>
        public void LoadSelectedObjectsAsync(AccessApp app)
        {
            LoadObjectsAsyncParams loadParams = new LoadObjectsAsyncParams();

            loadParams.App             = app;
            loadParams.SelectedObjects = SelectedNodes;
            backgroundWorker.RunWorkerAsync(loadParams);
        }