private void mainBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { DataEditorActionArgs actionArgs = (DataEditorActionArgs)e.Argument; DataActionEventArgs eventArgs = new DataActionEventArgs(actionArgs.Data); switch (actionArgs.Action) { case DataEditorAction.Load: OnLoadAsync(eventArgs); break; case DataEditorAction.Save: case DataEditorAction.SaveClose: { OnSaveAsync(eventArgs); switch (editorMode) { case DataEditorMode.Create: OnCreateAsync(eventArgs); break; case DataEditorMode.Update: OnUpdateAsync(eventArgs); break; } } break; } DataEditorActionResult result = new DataEditorActionResult( eventArgs.Data, actionArgs.StatusGuid, eventArgs.Cancelled, eventArgs.UserMessage, actionArgs.Action); e.Result = result; }
private void runActionAsyncMainEvents(DataEditorAction action, object data) { DataActionBeforeEventArgs beforeArgs = new DataActionBeforeEventArgs(data); switch (action) { case DataEditorAction.Load: { if (AutoChangeStatus) { beforeArgs.StatusGuid = AsyncStatusChange("Loading..."); } OnBeforeLoadAsync(beforeArgs); } break; case DataEditorAction.Save: case DataEditorAction.SaveClose: { if (AutoChangeStatus) { beforeArgs.StatusGuid = AsyncStatusChange("Saving..."); } OnBeforeSaveAsync(beforeArgs); switch (editorMode) { case DataEditorMode.Create: OnBeforeCreateAsync(beforeArgs); break; case DataEditorMode.Update: OnBeforeUpdateAsync(beforeArgs); break; } } break; } if (!beforeArgs.Cancel) { DataEditorActionArgs args = new DataEditorActionArgs( beforeArgs.Data, beforeArgs.StatusGuid, action); mainBackgroundWorker.RunWorkerAsync(args); } else { DataEditorActionResult result = new DataEditorActionResult( beforeArgs.Data, beforeArgs.StatusGuid, true, string.Empty, action); handleAfterDataAction(result); } }