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); } }
internal override CommandLine Run() { if (App == null && Objects.Count > 0) { InitializeAccessApplication(); } foreach (IObjecOptions currentObject in Objects) { Console.Write(Properties.Resources.Loading, currentObject); AccessObject accessObject = AccessObject.CreateInstance(App, currentObject.ObjectType, currentObject.ToString()); accessObject.Options = currentObject.Options; accessObject.Load(currentObject.Name); Console.WriteLine(Properties.Resources.ColonOk); } return(this); }