private void runActionAsync(DataViewerAction action, object inputData)
        {
            if (!mainBackgroundWorker.IsBusy)
            {
                DataActionBeforeEventArgs beforeArgs = new DataActionBeforeEventArgs(inputData);
                switch (action)
                {
                case DataViewerAction.Load:
                    OnBeforeLoadAsync(beforeArgs);
                    break;

                case DataViewerAction.Open:
                    OnBeforeOpenAsync(beforeArgs);
                    break;

                case DataViewerAction.New:
                    OnBeforeNewAsync(beforeArgs);
                    break;

                case DataViewerAction.Delete:
                    OnBeforeDeleteAsync(beforeArgs);
                    break;
                }

                if (!beforeArgs.Cancel)
                {
                    DataViewerActionArgs args = new DataViewerActionArgs(
                        beforeArgs.Data,
                        beforeArgs.StatusGuid,
                        action);

                    mainBackgroundWorker.RunWorkerAsync(args);
                }
                else
                {
                    DataViewerActionResult result = new DataViewerActionResult(
                        beforeArgs.Data,
                        beforeArgs.StatusGuid,
                        true,
                        string.Empty,
                        action);

                    handleAfterDataAction(result);
                }
            }
        }
Exemplo n.º 2
0
 public DataViewerActionArgs(object data, Guid statusGuid, DataViewerAction action)
     : base(data, statusGuid)
 {
     this.Action = action;
 }