示例#1
0
 /// <summary>
 ///   This constructor creates a matching event object for the passed menuEntryEvent
 /// </summary>
 /// <param name = "menuEntryEvent">event menu entry for which we create this event</param>
 /// <param name = "currentTask">current task from which the menu entry was activated</param>
 /// <param name = "control"></param>
 internal RunTimeEvent(MenuEntryEvent menuEntryEvent, Task currentTask, MgControl control, int ctlIdx)
     : base(menuEntryEvent, ctlIdx)
 {
     _task    = currentTask;
     _taskTag = currentTask.getTaskTag();
     Control  = control;
 }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        internal override void Execute()
        {
            Task   parentTask = Manager.MGDataTable.GetTaskByID(CallingTaskTag) as Task;
            MgForm parentForm = parentTask.getForm() as MgForm;

            MgControl destSubformCtrl = parentForm.getSubFormCtrlByName(SubformCtrlName);

            // Subform task is not allowed to be opened before the first record prefix of the parent.
            // In Task Prefix or in the first Record Prefix do not execute call but put the task from the call on the subform control property.
            // So after the first record prefix the task from the call operation will be loaded into the subform control.
            if (destSubformCtrl != null && !((Task)destSubformCtrl.getForm().getTask()).AfterFirstRecordPrefix)
            {
                // QCR #310113. If the subform was loaded, now it must be closed.
                Task subformTaskToRemove = destSubformCtrl.getSubformTask();
                if (subformTaskToRemove != null)
                {
                    subformTaskToRemove.stop();
                }

                SetCalledTaskDefinitionId(destSubformCtrl);
                SetCalledSubformType(destSubformCtrl);
                destSubformCtrl.ArgList = ArgList;

                // TODO: Task Suffix
            }
            else
            {
                base.Execute();
            }
        }
示例#3
0
        /// <summary>
        /// Set subform type on the property of the subform control
        /// </summary>
        /// <param name="destSubformCtrl"></param>
        private void SetCalledSubformType(MgControl destSubformCtrl)
        {
            SubformType subformType = TaskDefinitionId.IsProgram == true ? SubformType.Program : SubformType.Subtask;
            String      mgNumString = DisplayConvertor.Instance.toNum(((int)subformType).ToString(), null, 0);

            destSubformCtrl.setProp(PropInterface.PROP_TYPE_SUBFORM_TYPE, mgNumString);
        }
示例#4
0
        /// <summary>
        /// Get the TaskDefinitionId of the task to be run, from the SelectProgram property on the command's control
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        private TaskDefinitionId GetTaskIdFromCommandCtrlProp(ExecOperCommand command)
        {
            Task      task    = Manager.MGDataTable.GetTaskByID(command.TaskTag) as Task;
            MgForm    form    = task.getForm() as MgForm;
            MgControl control = form.CtrlTab.getCtrl(command.DitIdx) as MgControl;
            Property  prop    = control.getProp(PropInterface.PROP_TYPE_SELECT_PROGRAM);

            return(prop.TaskDefinitionId);
        }
示例#5
0
        /// <summary>
        /// Sets subform control for the new opened subform task and
        /// sets subform task tag on the parent subform control
        /// </summary>
        /// <param name="parentTask"></param>
        /// <param name="subformControl"></param>
        internal override void PrepareForSubform(Task parentTask, MgControl subformControl)
        {
            List <Task> subformTaskList = MGDataCollection.Instance.GetTasks(t => !t.isStarted() && !t.isMainProg());

            Debug.Assert(subformTaskList.Count == 1, "Only 1 subform can be opened each time");

            Task subformTask = subformTaskList[0];

            subformControl.setSubformTaskId(subformTask.getTaskTag());
            subformTask.SubformControl = subformControl;
        }
示例#6
0
        /// <summary>Put ACT_CTRL_FOCUS, ACT_CTRL_HIT and MG_ACT_BEGIN_DROP to Runtime thread.</summary>
        protected override void processBeginDrop(GuiMgForm guiMgForm, GuiMgControl guiMgCtrl, int line)
        {
            MgControl mgControl = (MgControl)guiMgCtrl;

            if (mgControl != null && (mgControl.Type == MgControlType.CTRL_TYPE_TEXT || mgControl.Type == MgControlType.CTRL_TYPE_TREE))
            {
                ClientManager.Instance.EventsManager.addGuiTriggeredEvent(mgControl, line, InternalInterface.MG_ACT_CTRL_FOCUS, false);
            }

            base.processBeginDrop(guiMgForm, guiMgCtrl, line);
        }
示例#7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctrlRef"></param>
 /// <param name="guiTriggeredEvent"></param>
 internal RunTimeEvent(MgControl ctrlRef, bool guiTriggeredEvent)
     : this(ctrlRef)
 {
     _guiTriggeredEvent = guiTriggeredEvent;
     if (guiTriggeredEvent)
     {
         //Events that are triggered by GUI level, must be executed after all
         //other events, thus thay have low priority;
         _priority = Priority.LOW;
     }
 }
示例#8
0
        /// <summary>
        /// Set TaskDefinitionId on the property of the subform control
        /// </summary>
        /// <param name="destSubformCtrl">subform control</param>
        private void SetCalledTaskDefinitionId(MgControl destSubformCtrl)
        {
            // If 'Connect to' property was 'none'
            if (!destSubformCtrl.checkIfExistProp(PropInterface.PROP_TYPE_PRGTSK_NUM))
            {
                destSubformCtrl.setProp(PropInterface.PROP_TYPE_PRGTSK_NUM, null);
            }

            Property prop = destSubformCtrl.getProp(PropInterface.PROP_TYPE_PRGTSK_NUM);

            prop.SetTaskDefinitionId(TaskDefinitionId);
        }
示例#9
0
 /// <summary>
 ///   CTOR
 /// </summary>
 /// <param name = "ctrlRef">a reference to the control </param>
 internal RunTimeEvent(MgControl ctrlRef)
     : this(null, ctrlRef)
 {
     if (ctrlRef != null && getType() == Char.MinValue) // not initialized yet
     {
         // on the first time, if a TRIGGER property exists, parse the event and add it to the control
         Property prop = ctrlRef.getProp(PropInterface.PROP_TYPE_TRIGGER);
         if (prop != null)
         {
             var xmlParser = new XmlParser(prop.getValue());
             fillData(xmlParser, (Task)ctrlRef.getForm().getTask());
         }
     }
 }
示例#10
0
        /// <summary>
        /// Creates a command for a subform open
        /// </summary>
        /// <param name="subformCtrl"></param>
        /// <returns></returns>
        private LocalRunTimeCommandBase CreateSubformCallCommand(SubformOpenEventCommand command)
        {
            Task      task        = Manager.MGDataTable.GetTaskByID(command.TaskTag) as Task;
            MgForm    form        = task.getForm() as MgForm;
            MgControl subformCtrl = form.CtrlTab.getCtrl(command.DitIdx) as MgControl;
            Property  prop        = subformCtrl.getProp(PropInterface.PROP_TYPE_PRGTSK_NUM);

            return(new LocalRunTimeCommandOpenTask(prop.TaskDefinitionId)
            {
                ArgList = subformCtrl.ArgList,
                CallingTaskTag = task.getTaskTag(),
                PathParentTaskTag = task.getTaskTag(),
                SubformDitIdx = subformCtrl.getDitIdx()
            });
        }
示例#11
0
        /// <summary>
        /// CTOR
        /// </summary>
        /// <param name="taskDefinitionId"></param>
        /// <param name="command"></param>
        public LocalRunTimeCommandSelectProgram(TaskDefinitionId taskDefinitionId, IClientCommand command)
            : base(taskDefinitionId)
        {
            ExecOperCommand cmd = command as ExecOperCommand;

            Debug.Assert(cmd != null);

            Task   task = Manager.MGDataTable.GetTaskByID(cmd.TaskTag) as Task;
            MgForm form = task.getForm() as MgForm;

            mgControl = form.CtrlTab.getCtrl(cmd.DitIdx) as MgControl;

            CallingTaskTag    = cmd.TaskTag;
            PathParentTaskTag = CallingTaskTag;

            ForceModal = true;
        }
示例#12
0
文件: Command.cs 项目: rinavin/RCJS
        /// <summary>
        ///
        /// </summary>
        private void ExecuteAbortCommand()
        {
            MGDataTable mgDataTab = MGDataTable.Instance;
            int         oldMgdID  = MGDataTable.Instance.currMgdID;
            MGData      mgd       = null;

            var task = (Task)mgDataTab.GetTaskByID(TaskTag);

            // Pass transaction ownership
            if (_transOwner != null)
            {
                var newTransOwnerTask = (Task)mgDataTab.GetTaskByID(_transOwner);
                if (newTransOwnerTask != null)
                {
                    newTransOwnerTask.setTransOwnerTask();
                }
            }

            // On special occasions, the server may send abort commands on tasks which were not parsed yet
            if (task == null && ClientManager.Instance.EventsManager.ignoreUnknownAbort())
            {
                return;
            }
            Debug.Assert(task != null);
            mgd = task.getMGData();
            task.stop();
            mgd.abort();

            MGDataTable.Instance.currMgdID = mgd.GetId();
            GUIManager.Instance.abort((MgForm)task.getForm());
            MGDataTable.Instance.currMgdID = (mgd.GetId() != oldMgdID || mgd.getParentMGdata() == null
                                                   ? oldMgdID
                                                   : mgd.getParentMGdata().GetId());

            if (!ClientManager.Instance.validReturnToCtrl())
            {
                MgControl mgControl = GUIManager.getLastFocusedControl();
                ClientManager.Instance.ReturnToCtrl = mgControl;
                if (mgControl != null)// Refresh the status bar.
                {
                    ((MgForm)mgControl.getForm()).RefreshStatusBar();
                }
            }
        }
示例#13
0
        /// <summary> Add Open Context Menu event on right click on form.</summary>
        /// <param name = "guiMgControl">control </param>
        /// <param name = "guiMgForm">code of internal event </param>
        /// <param name = "left">code of internal event </param>
        /// <param name = "top">code of internal event </param>
        /// <param name = "line">code of internal event </param>
        public void AddOpenContextMenuEvent(GuiMgControl guiMgControl, GuiMgForm guiMgForm, int left, int top, int line)
        {
            MgControl ctrl = null;
            Task      task = null;

            if (guiMgControl != null)
            {
                if (guiMgControl is MgControl)
                {
                    ctrl = (MgControl)guiMgControl;
                    if (ctrl.Type == MgControlType.CTRL_TYPE_SUBFORM)
                    {
                        task = (Task)ctrl.GetSubformMgForm().getTask();
                    }
                    else
                    {
                        task = (Task)((MgControlBase)guiMgControl).getForm().getTask();
                    }
                }
            }
            else
            {
                task = (Task)((MgFormBase)guiMgForm).getTask();
            }

            // Prepare event for MG_ACT_CONTEXT_MENU to open context menu.
            var rtEvt = new RunTimeEvent(task);

            rtEvt.setInternal(InternalInterface.MG_ACT_CONTEXT_MENU);

            rtEvt.setCtrl(ctrl);
            //Prepare an argument list for left and top co-ordinate.
            var argsList = new GuiExpressionEvaluator.ExpVal[3];

            argsList[0] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, left.ToString());
            argsList[1] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, top.ToString());
            argsList[2] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.ALPHA, false, line.ToString());
            var args = new ArgumentsList(argsList);

            rtEvt.setArgList(args);

            ClientManager.Instance.EventsManager.addToTail(rtEvt);
        }
示例#14
0
        /// <summary>
        ///   This method is activated when an Event menu was selected. It performs the needed operations in order to
        ///   translate the selected event menu into the matching operation
        /// </summary>
        /// <param name = "menuEntryEvent">the selected menu \ bar menuEntryEvent object</param>
        /// <param name = "activeForm">last active Form</param>
        /// <param name = "ctlIdx">the index of the ctl which the menu is attached to in toolkit</param>
        internal static void onEventMenuSelection(MenuEntryEvent menuEntryEvent, MgForm activeForm, int ctlIdx)
        {
            MgControl lastFocusedControl = getLastFocusedControl(activeForm);
            Task      task = getLastFocusedTask(activeForm);

            RunTimeEvent aRtEvt = new RunTimeEvent(menuEntryEvent, task, lastFocusedControl, ctlIdx);

            aRtEvt.setPublicName();
            aRtEvt.setMainPrgCreator(null);

            // build the argument list from the mainProgVars
            List <String> mainProgVars = menuEntryEvent.MainProgVars;

            if (mainProgVars != null && mainProgVars.Count > 0)
            {
                ArgumentsList argList = new ArgumentsList();
                argList.fillListByMainProgVars(mainProgVars, task.getCtlIdx());
                aRtEvt.setArgList(argList);
                aRtEvt.setTask(null);
            }

            ClientManager.Instance.EventsManager.addToTail(aRtEvt);
        }
示例#15
0
 /// <summary>
 ///   CTOR
 /// </summary>
 /// <param name = "taskRef">reference to task</param>
 /// <param name = "ctrlRef">reference to control</param>
 internal RunTimeEvent(Task taskRef, MgControl ctrlRef)
     : this(ctrlRef != null ? (Task)ctrlRef.getForm().getTask() : taskRef)
 {
     Control = ctrlRef;
 }
示例#16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ctrlRef"></param>
 /// <param name="guiTriggeredEvent"></param>
 internal RunTimeEvent(MgControl ctrlRef, bool guiTriggeredEvent, bool ignoreSpecifiedControl)
     : this(ctrlRef, guiTriggeredEvent)
 {
     IgnoreSpecifiedControl = ignoreSpecifiedControl;
 }
示例#17
0
 /// <summary>
 ///   CTOR
 /// </summary>
 /// <param name = "ctrlRef">a reference to the control on which the event occured </param>
 /// <param name = "line">the line of the table in which the control is located </param>
 internal RunTimeEvent(MgControl ctrlRef, int line)
     : this(ctrlRef)
 {
     _displayLine = line;
 }
示例#18
0
        public override void Execute(rt.IResultValue res)
        {
            MGData           mgd       = null;
            MGDataCollection mgDataTab = MGDataCollection.Instance;
            bool             destinationSubformSucceeded = false;
            bool             refreshWhenHidden           = true;
            int          mgdID = 0;
            MgControl    subformCtrl = null;
            List <Int32> oldTimers = new List <Int32>(), newTimers = new List <Int32>();
            bool         moveToFirstControl = true;
            Task         guiParentTask;
            MGData       guiParentMgData = null;
            Task         callingTask     = (_callingTaskTag != null ? (Task)mgDataTab.GetTaskByID(_callingTaskTag) : null);
            Task         pathParentTask  = (_pathParentTaskTag != null ? (Task)mgDataTab.GetTaskByID(_pathParentTaskTag) : null);
            MgForm       formToBeActivatedOnClosingCurrentForm = null;

            Task lastFocusedTask = ClientManager.Instance.getLastFocusedTask();

            if (lastFocusedTask != null && lastFocusedTask.IsOffline)
            {
                formToBeActivatedOnClosingCurrentForm = (MgForm)lastFocusedTask.getForm();
            }

            // TODO (Ronak): It is wrong to set Parent task as a last focus task when
            // non-offline task is being called from an offline task.

            //When a nonOffline task was called from an Offline task (of course via MP event),
            //the calling task id was not sent to the server because the server is unaware of the
            //offline task. So, when coming back from the server, assign the correct calling task.
            //Task lastFocusedTask = ClientManager.Instance.getLastFocusedTask();
            //if (lastFocusedTask != null && lastFocusedTask.IsOffline)
            //   _callingTaskTag = lastFocusedTask.getTaskTag();

            guiParentTask = callingTask = (Task)mgDataTab.GetTaskByID(_callingTaskTag);
            if (callingTask != null)
            {
                mgd = callingTask.getMGData();
            }

            //QCR#712370: we should always perform refreshTables for the old MgData before before opening new window
            ClientManager.Instance.EventsManager.refreshTables();

            //ditIdx is send by server only for subform opening for refreshWhenHidden
            if ((_subformCtrlName != null) || (_ditIdx != Int32.MinValue))
            {
                subformCtrl = (_ditIdx != Int32.MinValue
                             ? (MgControl)callingTask.getForm().getCtrl(_ditIdx)
                             : ((MgForm)callingTask.getForm()).getSubFormCtrlByName(_subformCtrlName));
                if (subformCtrl != null)
                {
                    var subformTask = subformCtrl.getSubformTask();
                    guiParentTask   = (Task)subformCtrl.getForm().getTask();
                    mgdID           = guiParentTask.getMgdID();
                    guiParentMgData = guiParentTask.getMGData();
                    if (guiParentMgData.getTimerHandlers() != null)
                    {
                        oldTimers = guiParentMgData.getTimerHandlers().getTimersVector();
                    }

                    if (_ditIdx != Int32.MinValue) //for refresh when hidden
                    {
                        refreshWhenHidden  = false;
                        moveToFirstControl = false;
                    }
                    else //for destination
                    {
                        destinationSubformSucceeded = true;
                        // Pass transaction ownership
                        if (_transOwner != null)
                        {
                            var newTransOwnerTask = (Task)mgDataTab.GetTaskByID(_transOwner);
                            if (newTransOwnerTask != null)
                            {
                                newTransOwnerTask.setTransOwnerTask();
                            }
                        }

                        if (subformTask != null)
                        {
                            subformTask.setDestinationSubform(true);
                            subformTask.stop();
                        }

                        if (!ClientManager.Instance.validReturnToCtrl())
                        {
                            ClientManager.Instance.ReturnToCtrl = GUIManager.getLastFocusedControl();
                        }
                    }

                    subformCtrl.setSubformTaskId(_newId);
                }
            }

            MGData parentMgData;

            if (callingTask == null)
            {
                parentMgData = MGDataCollection.Instance.getMGData(0);
            }
            else
            {
                parentMgData = callingTask.getMGData();
            }

            if (!destinationSubformSucceeded && refreshWhenHidden)
            {
                mgdID = mgDataTab.getAvailableIdx();
                Debug.Assert(mgdID > 0);
                mgd = new MGData(mgdID, parentMgData, _isModal, _forceModal);
                mgd.copyUnframedCmds();
                MGDataCollection.Instance.addMGData(mgd, mgdID, false);

                MGDataCollection.Instance.currMgdID = mgdID;
            }

            Obj  = _key;
            _key = null;

            try
            {
                // Large systems appear to consume a lot of memory, the garbage collector is not always
                // "quick" enough to catch it, so free memory before initiating a memory consuming job as
                // reading a new MGData.
                if (GC.GetTotalMemory(false) > 30000000)
                {
                    GC.Collect();
                }

                ClientManager.Instance.ProcessResponse(NewTaskXML, mgdID, new OpeningTaskDetails(callingTask, pathParentTask, formToBeActivatedOnClosingCurrentForm), null);
            }
            finally
            {
                ClientManager.Instance.EventsManager.setIgnoreUnknownAbort(false);
            }

            if (callingTask != null && subformCtrl != null)
            {
                callingTask.PrepareForSubform(subformCtrl);
            }

            if (destinationSubformSucceeded || !refreshWhenHidden)
            {
                subformCtrl.initSubformTask();
                if (destinationSubformSucceeded)
                {
                    var subformTask = subformCtrl.getSubformTask();
                    moveToFirstControl = !callingTask.RetainFocus;
                    subformTask.setIsDestinationCall(true);
                }
            }

            if (subformCtrl != null)
            {
                if (guiParentMgData.getTimerHandlers() != null)
                {
                    newTimers = guiParentMgData.getTimerHandlers().getTimersVector();
                }
                guiParentMgData.changeTimers(oldTimers, newTimers);
            }

            Task nonInteractiveTask = ClientManager.Instance.StartProgram(destinationSubformSucceeded, moveToFirstControl, _varList, _returnVal, null);

            if (destinationSubformSucceeded || !refreshWhenHidden)
            {
                guiParentTask.resetRcmpTabOrder();
            }

            // in local tasks, ismodal is calculated after the main display, so we need to update the command member
            _isModal = mgd.IsModal;

            // If we have a non interactive task starting, we need to create an eventLoop for it , just like modal.
            // This is because we cannot allow the tasks above it to catch events.
            if (nonInteractiveTask == null)
            {
                // a non interactive parent will cause the called task to behave like modal by having its own events loop.
                // In case of main program caller (which is flagged as non interactive) we will have a new events loop for the called program
                // if the main program is without a form. If the main prog has a form , then the callee can be included in the main prog loop.
                if (callingTask != null &&
                    ((_isModal && !destinationSubformSucceeded && refreshWhenHidden) || (!callingTask.IsInteractive && (!callingTask.isMainProg() || callingTask.getForm() == null))))
                {
                    ClientManager.Instance.EventsManager.EventsLoop(mgd);
                }
            }
            else
            {
                ClientManager.Instance.EventsManager.NonInteractiveEventsLoop(mgd, nonInteractiveTask);
            }
        }
示例#19
0
 /// <summary>send wide action to the control</summary>
 ///<param name = "guiMgCtrl"></param>
 internal void processWide(MgControl ctrl)
 {
     ClientManager.Instance.EventsManager.addGuiTriggeredEvent(ctrl, InternalInterface.MG_ACT_WIDE, 0);
 }
示例#20
0
 internal RunTimeEvent(MgControl ctrlRef, int line, bool guiTriggeredEvent)
     : this(ctrlRef, guiTriggeredEvent)
 {
     _displayLine = line;
 }
示例#21
0
 /// <summary>
 /// Sets subform control for the new opened subform task and
 /// sets subform task tag on the parent subform control
 /// </summary>
 /// <param name="parentTask"></param>
 /// <param name="subformControl"></param>
 internal virtual void PrepareForSubform(Task parentTask, MgControl subformControl)
 {
 }
示例#22
0
 internal RunTimeEvent(MgControl ctrlRef, List <MgControlBase> controlsList, bool guiTriggeredEvent) :
     this(ctrlRef, guiTriggeredEvent)
 {
     _controlsList = controlsList;
 }
示例#23
0
 /// <summary> CTOR</summary>
 /// <param name="ctrlRef">a reference to the control on which the event occurred</param>
 /// <param name="direction">the direction of the sort we are now going to sort by</param>
 /// <param name="line">the line is kept in this CTOR to distinguish
 ///                    between the direction CTOR and the line CTOR
 /// </param>
 internal RunTimeEvent(MgControl ctrlRef, int direction, int line)
     : this(ctrlRef, true)
 {
     _direction = direction;
 }
示例#24
0
 internal RunTimeEvent(MgControl ctrlRef, String columnHeader, int x, int y, int width, int height)
     : this(ctrlRef, true)
 {
 }
示例#25
0
 /// <summary>
 ///   set a new control for the runtime event
 /// </summary>
 /// <param name = "newCtrl">a reference to the new control </param>
 internal void setCtrl(MgControl newCtrl)
 {
     _ctrl = newCtrl;
 }