Ejemplo n.º 1
0
 public DataEditorActionResult(
     object data,
     Guid statusGuid,
     bool cancelled,
     string userMessage,
     DataEditorAction action)
     : base(data, statusGuid, cancelled, userMessage)
 {
     this.Action = action;
 }
Ejemplo n.º 2
0
        private void runActionAsync(DataEditorAction action, object data)
        {
            if (!mainBackgroundWorker.IsBusy)
            {
                suspendChangeMadeNotify = true;

                bool cancelMainEvents = false;
                if ((action == DataEditorAction.Save) || (action == DataEditorAction.SaveClose))
                {
                    // Only validate on save or save and close.
                    cancelMainEvents = !RunValidateData();
                }

                if (!cancelMainEvents)
                {
                    runActionAsyncMainEvents(action, data);
                }
            }
        }
Ejemplo n.º 3
0
 public DataEditorActionArgs(object data, Guid statusGuid, DataEditorAction action)
     : base(data, statusGuid)
 {
     this.Action = action;
 }
Ejemplo n.º 4
0
        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);
            }
        }