/// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        static public string getXmlTaskURL(TaskDefinitionIdsManager taskIdsManager, TaskDefinitionId taskDefinitionId)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

            string taskFileName = taskIdsManager.GetXmlId(taskDefinitionId);

            if (taskFileName == null)
            {
                return(null);
            }
            string defaultTagList = taskIdsManager.GetDefaultTagList(taskDefinitionId);


            StringBuilder response = new StringBuilder();

            response.Append("<");
            response.Append(ConstInterface.MG_TAG_TASKURL);
            response.Append(" xmlId=\"");
            response.Append(taskFileName);
            response.Append("\" ");

            response.Append("tagList");
            response.Append("=\"");
            response.Append(defaultTagList);
            response.Append("\">");

            response.Append("</");
            response.Append(ConstInterface.MG_TAG_TASKURL);
            response.Append(">");

            return(response.ToString());
        }
Esempio n. 2
0
        /// <summary>
        ///   opens a new Transaction or set reference to the existing Transaction
        /// </summary>
        internal void SetLocalTransaction()
        {
            MGDataCollection mgdTab      = MGDataCollection.Instance;
            Transaction      transaction = null;

            if (task.DataviewManager.LocalDataviewManager.Transaction == null)
            {
                // 1. find the first task that have local transaction in the branch.
                transaction = FindTheLocalDeferredTransactionInBranch();

                // 2. if there is not transaction opned the , get transaction begin value and create a new transaction info
                if (transaction == null)
                {
                    char transBegin = GetTransactionBeginValue(true);
                    if (AllowTransaction(transBegin, true))
                    {
                        transaction = new Transaction(task, task.getTaskTag(), true);
                        PrepareTransactionProperties(transaction, true);
                    }
                }

                // 3. set the transaction member on the data view manager
                task.DataviewManager.LocalDataviewManager.Transaction = transaction;
            }
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="res"></param>
        public override void Execute(rt.IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

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

            Debug.Assert(task.IsSubForm);

            // Fixed Defect#:77149
            // if we in rollback command and we get clientRefresh command from server ,
            // first we need to rollback the local transaction and then we need to do refresh to the view .
            // the refresh to the view will be handled in rollback command
            if (ClientIsInRollbackCommand)
            {
                return;
            }

            if (task.AfterFirstRecordPrefix && !task.InEndTask)
            {
                // QCR #284789. When the subform execute it's recompute, we do not needed to execute it's view refresh,
                // we need execute only it's subforms refresh. It will be done in recompute.
                if (((DataView)task.DataView).getCurrRec().InRecompute)
                {
                    task.ExecuteClientSubformRefresh = true;
                }
                else
                {
                    // Do not execute RP & RS of the parent, because it was done already.
                    task.PerformParentRecordPrefix = false;
                    ((Task)task).getParent().SubformRefresh(task, true);
                    task.PerformParentRecordPrefix = true;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// execute all pending commands - create the equivalent local commands and invoke its' execute method
        /// </summary>
        /// <param name="sendingInstruction"></param>
        /// <param name="sessionStage"></param>
        /// <param name="res"></param>
        internal override void Execute(SendingInstruction sendingInstruction, SessionStage sessionStage, IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

            // loop on all MGData
            for (int i = 0; i < mgDataTab.getSize(); i++)
            {
                MGData mgd = mgDataTab.getMGData(i);
                if (mgd != null && !mgd.IsAborting)
                {
                    CommandsTable commands = mgd.CmdsToServer;

                    // go over all commands
                    while (commands.getSize() > 0)
                    {
                        // extract command from CmdsToServer
                        IClientCommand          command             = commands.ExtractCommand(0);
                        LocalRunTimeCommandBase localRunTimeCommand = _localRunTimeCommandFactory.CreateLocalRunTimeCommand(command);
                        localRunTimeCommand.Execute();
                    }

                    Debug.Assert(mgd.CmdsToClient.getSize() == 0, "Not all commands were executed");
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Execute AddSortCommand
        /// </summary>
        /// <param name="res"></param>
        public override void  Execute(rt.IResultValue res)
        {
            MGDataCollection           mgDataTab = MGDataCollection.Instance;
            Task                       task      = (Task)mgDataTab.GetTaskByID(TaskTag);
            AddUserSortDataViewCommand command   = CommandFactory.CreateAddUserSortDataviewCommand(TaskTag, UserSort);

            task.DataviewManager.Execute(command);
        }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="exp"></param>
        public override void Execute(rt.IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

            Task task = (Task)(mgDataTab.GetTaskByID(TaskTag) ?? mgDataTab.GetTaskByID(_callingTaskTag));

            if (task == null)
            {
                task = ClientManager.Instance.getLastFocusedTask();
            }

            // In order to keep the behavior same as in Online, verify operation warning messages
            // will be written as error messages in Client log (QCR #915122)
            if (_errLogAppend)
            {
                Logger.Instance.WriteExceptionToLog(_text + ", program : " + ClientManager.Instance.getPrgName());
            }

            //Blank Message will not be shown, same as in Online
            if (!String.IsNullOrEmpty(_text))
            {
                if (_display == ConstInterface.DISPLAY_BOX)
                {
                    MgForm currForm;
                    int    style = 0;

                    // on verify box, show translated value. (status is handled in property).
                    String mlsTransText  = ClientManager.Instance.getLanguageData().translate(_text);
                    String mlsTransTitle = String.Empty;

                    if (task != null && task.isStarted())
                    {
                        currForm = (MgForm)task.getTopMostForm();
                    }
                    else
                    {
                        currForm = null;
                    }

                    PrepareMessageBoxForDisplay(task, ref mlsTransTitle, ref style);

                    int returnValue = Commands.messageBox(currForm, mlsTransTitle, mlsTransText, style);

                    ProcessMessageBoxResponse(task, returnValue);
                }
                // display message on status only if we have a task
                //Blank Message will not be shown, same as in Online
                else if (_display == ConstInterface.DISPLAY_STATUS && task != null)
                {
                    task.DisplayMessageToStatusBar(_text);
                }
            }

            if (_sendAck)
            {
                task.CommandsProcessor.Execute(CommandsProcessorBase.SendingInstruction.NO_TASKS_OR_COMMANDS);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Execute ResetRange command.
        /// </summary>
        /// <param name="res"></param>
        public override void  Execute(rt.IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

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

            IClientCommand command = CommandFactory.CreateDataViewCommand(TaskTag, DataViewCommandType.ResetUserRange);

            task.DataviewManager.Execute(command);
        }
Esempio n. 8
0
        public override void Execute(IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;
            int    oldMgdID            = MGDataCollection.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();

            MGDataCollection.Instance.currMgdID = mgd.GetId();
            GUIManager.Instance.abort((MgForm)task.getForm());
            MGDataCollection.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();
                }
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Execute AddLocateCommand
        /// </summary>
        /// <param name="exp"></param>
        public override void  Execute(rt.IResultValue res)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

            Task     task     = (Task)mgDataTab.GetTaskByID(TaskTag);
            FieldDef fieldDef = task.DataView.getField((int)UserRange.veeIdx - 1);
            int      parsedLen;

            AddUserLocateDataViewCommand command = CommandFactory.CreateAddUserLocateDataviewCommand(TaskTag, UserRange);

            if (!UserRange.nullMin)
            {
                command.Range.min = RecordUtils.deSerializeItemVal(UserRange.min, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen);
            }
            if (!UserRange.nullMax)
            {
                command.Range.max = RecordUtils.deSerializeItemVal(UserRange.max, fieldDef.getType(), fieldDef.getSize(), true, fieldDef.getType(), out parsedLen);
            }

            task.DataviewManager.Execute(command);
        }
Esempio n. 10
0
        /// <summary>
        /// execute the command - add the command to the pending client commands and execute them
        /// </summary>
        /// <param name="command"></param>
        internal void Execute(IClientCommand command)
        {
            MGDataCollection mgDataTab = MGDataCollection.Instance;

            mgDataTab.currMgdID = MGDataCollection.Instance.currMgdID;
            MGData mgd = mgDataTab.getCurrMGData();

            // Add the command to the queue
            mgd.CmdsToClient.Add(command);

            try
            {
                // execute the command
                mgd.CmdsToClient.Execute(null);
            }
            catch (Exception)
            {
                mgd.CmdsToClient.clear();
                throw;
            }
        }
Esempio n. 11
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);
            }
        }