/// <summary> /// parse the expression /// </summary> /// <param name = "taskRef">a reference to the owner task</param> protected internal void fillData(Task taskRef) { XmlParser parser = ClientManager.Instance.RuntimeCtx.Parser; List <String> tokensVector; int endContext = parser.getXMLdata().IndexOf(XMLConstants.TAG_TERM, parser.getCurrIndex()); if (_task == null) { _task = taskRef; } if (endContext != -1 && endContext < parser.getXMLdata().Length) { //last position of its tag String tag = parser.getXMLsubstring(endContext); parser.add2CurrIndex(tag.IndexOf(ConstInterface.MG_TAG_EXP) + ConstInterface.MG_TAG_EXP.Length); tokensVector = XmlParser.getTokens(parser.getXMLsubstring(endContext), XMLConstants.XML_ATTR_DELIM); initElements(tokensVector); parser.setCurrIndex(endContext + XMLConstants.TAG_TERM.Length); //to delete "/>" too } else { Logger.Instance.WriteExceptionToLog("in Command.FillData() out of string bounds"); } }
private int _numerator; //generator for actCount /// <summary> /// Constructor /// </summary> internal ActionManager(Task parent) { _parentTask = parent; _numerator = 0; _actState = new bool[InternalInterface.MG_ACT_TOT_CNT]; _actCount = new int[InternalInterface.MG_ACT_TOT_CNT]; }
/// <summary> /// /// </summary> /// <param name="resType"></param> /// <returns></returns> internal ExpressionEvaluator.ExpVal evaluate(StorageAttribute resType) { ExpressionEvaluator.ExpVal expVal = null; String retVal; bool isNull = false; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, 0, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } if (retVal == null) { isNull = true; } // If we don't know what result type we got, and want to keep it, as in ExpCalc if (resType == StorageAttribute.NONE) { resType = _type; } expVal = new ExpressionEvaluator.ExpVal(resType, isNull, retVal); } _prevResType = resType; return(expVal); }
/// <summary> /// set the value of the Yes/No/Expression /// </summary> /// <param name = "task">the task to look for expression</param> /// <param name = "strVal">the string that contains the Yes/No/Expression</param> internal void setVal(Task task, String strVal) { switch (strVal[0]) { case 'Y': _val = true; break; case 'N': _val = false; break; default: int expId = XmlParser.getInt(strVal); if (task != null) { _exp = task.getExpById(expId); } break; } }
/// <summary> /// evaluate the expression and return the result /// </summary> /// <param name = "resType">is the expected type </param> /// <param name = "length">of expected Alpha string </param> /// <returns> evaluated value or null if value evaluated to null (by ExpressionEvaluator) </returns> internal String evaluate(StorageAttribute resType, int length) { ExpressionEvaluator.ExpVal expVal = null; String retVal = null; if (computedByClient()) { expVal = ExpressionEvaluator.eval(_expBytes, resType, _task); ConvertExpValForDotNet(expVal); if (expVal.IsNull) { // even if actual dotnet obj is null, we need to return blobPrefix if (expVal.Attr == StorageAttribute.DOTNET) { retVal = expVal.ToMgVal(); } else { retVal = null; } } else if (resType == StorageAttribute.BLOB_VECTOR && expVal.Attr == StorageAttribute.BLOB) { if (VectorType.validateBlobContents(expVal.StrVal)) { retVal = expVal.ToMgVal(); } else { retVal = null; } } else if (expVal.Attr == StorageAttribute.BLOB_VECTOR && resType != StorageAttribute.BLOB_VECTOR && resType != StorageAttribute.BLOB) { retVal = null; } else { retVal = expVal.ToMgVal(); } } else { RunTimeEvent rtEvt = ClientManager.Instance.EventsManager.getLastRtEvent(); Task mprgCreator = null; if (rtEvt != null) { mprgCreator = rtEvt.getMainPrgCreator(); } // create a new command object only when necessary if (resType != _prevResType) { _cmdToServer = CommandFactory.CreateEvaluateCommand(_task.getTaskTag(), resType, _id, length, mprgCreator); } ClientManager.Instance.execRequestWithSubformRecordCycle(_cmdsToServer, _cmdToServer, this, _task); if (resType != StorageAttribute.BLOB && resType != StorageAttribute.BLOB_VECTOR) { retVal = _resultValue; } else if (_resultValue != null && _resultValue.Equals(" ")) { retVal = ""; } else { retVal = RecordUtils.byteStreamToString(_resultValue); } } _prevResType = resType; return(retVal); }