Example #1
0
        /// <summary>
        ///   Need part input String to relevant for the class data
        /// </summary>
        internal IClientCommand fillData()
        {
            XmlParser parser = ClientManager.Instance.RuntimeCtx.Parser;

            int endContext = parser.getXMLdata().IndexOf(XMLConstants.TAG_TERM, parser.getCurrIndex());

            if (endContext != -1 && endContext < parser.getXMLdata().Length)
            {
                // last position of its tag
                String tag = parser.getXMLsubstring(endContext);
                parser.add2CurrIndex(tag.IndexOf(ConstInterface.MG_TAG_COMMAND) + ConstInterface.MG_TAG_COMMAND.Length);

                List <String> tokensVector = XmlParser.getTokens(parser.getXMLsubstring(endContext),
                                                                 XMLConstants.XML_ATTR_DELIM);
                IClientTargetedCommand command = initElements(tokensVector);
                parser.setCurrIndex(endContext + XMLConstants.TAG_TERM.Length); // to delete ">" too

                var openUrlCommand = command as OpenURLCommand;
                if (openUrlCommand != null)
                {
                    getTaskXML(parser);
                    openUrlCommand.NewTaskXML = newTaskXML;
                }

                return(command);
            }
            Logger.Instance.WriteDevToLog("in Command.FillData() out of string bounds");
            return(null);
        }
Example #2
0
        /// <summary>
        ///   returns the next command to execute or null if there is no such command
        ///   the abort commands are returned first
        /// </summary>
        /// <param name = "frame">the frame from which to extract a command </param>
        private IClientCommand extractCmd(int frame)
        {
            int size = getSize();
            IClientTargetedCommand cmd       = null;
            IClientTargetedCommand verifyCmd = null;
            int    verifyIndex;
            Task   verifyTask = null;
            Task   abortTask  = null;
            int    startIterationIdx;
            String tid;

            if (size == 0)
            {
                return(null);
            }

            if (_iterationIdx >= size)
            {
                _iterationIdx = 0;
            }

            startIterationIdx = _iterationIdx;

            // try to find an ABORT command and return it
            for (; _iterationIdx < size; _iterationIdx++)
            {
                cmd = getCmd(_iterationIdx) as AbortCommand;
                if (cmd != null && !cmd.TaskTag.StartsWith("-") && cmd.Frame == frame)
                {
                    // if an abort command was found, execute all previous verify commands of the task or its' sub-tasks
                    for (verifyIndex = 0; verifyIndex < _iterationIdx; verifyIndex++)
                    {
                        verifyCmd = getCmd(verifyIndex) as VerifyCommand;
                        if (verifyCmd != null && verifyCmd.Frame == frame)
                        {
                            verifyTask = (Task)MGDataCollection.Instance.GetTaskByID(verifyCmd.TaskTag);
                            abortTask  = (Task)MGDataCollection.Instance.GetTaskByID(cmd.TaskTag);

                            // Sometimes the task which issued the verify is not known to the client (e.g. a batch task).
                            if (verifyTask != null && verifyTask.isDescendentOf(abortTask))
                            {
                                _cmds.RemoveAt(verifyIndex);
                                _iterationIdx--;
                                return(verifyCmd);
                            }
                        }
                    }
                    _cmds.RemoveAt(_iterationIdx);

                    // for an abort CMD of task "tid", the server might send another abort CMD for task
                    // "-tid". We should combine them and get rid of the second CMD.
                    size = getSize();
                    for (startIterationIdx = 0; startIterationIdx < size; startIterationIdx++)
                    {
                        tid = ((IClientTargetedCommand)getCmd(startIterationIdx)).TaskTag;
                        if (tid != null && tid.Substring(1).Equals(cmd.TaskTag))
                        {
                            //cmd.combine((IClientTargetedCommand)getCmd(startIterationIdx));
                            _cmds.RemoveAt(startIterationIdx);
                            break;
                        }
                    }

                    return(cmd);
                }
            }

            // at this stage no ABORT command was found in the table

            for (verifyIndex = 0; verifyIndex < size; verifyIndex++)
            {
                verifyCmd = getCmd(verifyIndex) as VerifyCommand;
                if (verifyCmd != null && verifyCmd.Frame == frame &&
                    MGDataCollection.Instance.GetTaskByID(verifyCmd.TaskTag) != null)
                {
                    _cmds.RemoveAt(verifyIndex);
                    return(verifyCmd);
                }
            }

            // at this stage no VERIFY command was found in the table

            for (_iterationIdx = 0; _iterationIdx < size; _iterationIdx++)
            {
                cmd = getCmd(_iterationIdx) as IClientTargetedCommand;
                if (cmd.Frame == frame)
                {
                    _cmds.RemoveAt(_iterationIdx);
                    return(cmd);
                }
            }
            return(null);
        }