/// <summary> /// CTOR that creates a "Value" type argument from a given Expression Value /// </summary> /// <param name = "expVal">the source expression value</param> protected internal Argument(GuiExpressionEvaluator.ExpVal expVal) { _type = ConstInterface.ARG_TYPE_VALUE; _fld = null; _exp = null; _skip = false; if (expVal.IsNull) { _val = null; } else { _val = expVal.ToMgVal(); if (expVal.Attr == StorageAttribute.DOTNET && (String.IsNullOrEmpty(_val) || !BlobType.isValidDotNetBlob(_val))) { _dnObjectCollectionKey = DNManager.getInstance().DNObjectsCollection.CreateEntry(null); _val = BlobType.createDotNetBlobPrefix(_dnObjectCollectionKey); if (expVal.DnMemberInfo != null) { DNManager.getInstance().DNObjectsCollection.Update(_dnObjectCollectionKey, expVal.DnMemberInfo.value); } // add this key into 'tempDNObjectsCollectionKeys', so that it can be freed later. ClientManager.Instance.getTempDNObjectCollectionKeys().Add(_dnObjectCollectionKey); } } _valueIsNull = (_val == null); _valueAttr = expVal.Attr; }
/// <summary> /// exp value to field value /// </summary> /// <param name="expVal"></param> /// <returns></returns> FieldValue GetFieldValue(GuiExpressionEvaluator.ExpVal expVal, char wildCharFiller) { FieldValue fieldValue = new FieldValue() { IsNull = expVal.IsNull }; if (!expVal.IsNull) { switch (expVal.Attr) { case StorageAttribute.ALPHA: case StorageAttribute.UNICODE: fieldValue.Value = expVal.StrVal; break; case StorageAttribute.NUMERIC: case StorageAttribute.DATE: case StorageAttribute.TIME: fieldValue.Value = expVal.MgNumVal; break; case StorageAttribute.BOOLEAN: fieldValue.Value = (expVal.BoolVal == true) ? 1 : 0; break; default: //TODO: Error break; } } return(fieldValue); }
/// <summary> /// computes the min and max expression to check their values /// </summary> protected internal void compute(bool padValueWithMinMaxCharacters) { if (hasMinExp()) { //evaluate the min expression // String minVal = min.evaluate(getExpType(),size, true, DATA_TYPE_SKIP); String minVal = _min.evaluate(getExpType(), _size); if (minVal != null) { minVal = minVal.TrimEnd(); } _minExpVal = new GuiExpressionEvaluator.ExpVal(getExpType(), (minVal == null), minVal); // check and set the MaxEqualsMin before the wild chars are replaced on the string result MaxEqualsMin = IsMaxEqualsMin(); if (!_minExpVal.IsNull && (_minExpVal.Attr == StorageAttribute.ALPHA || _minExpVal.Attr == StorageAttribute.UNICODE)) { if (padValueWithMinMaxCharacters) { _minExpVal.StrVal = DisplayConvertor.StringValueToMgValue(_minExpVal.StrVal, _minExpVal.Attr, Char.MinValue, _size).ToString(); MaxEqualsMin = false; } _minExpVal.StrVal = StrUtil.SearchAndReplaceWildChars(_minExpVal.StrVal, _size, Char.MinValue); } DiscardMin = _min.DiscardCndRangeResult(); } if (hasMaxExp()) { //evaluate the max expression // String maxVal = max.evaluate(getExpType(),size, true, DATA_TYPE_SKIP); String maxVal = _max.evaluate(getExpType(), _size); _maxExpVal = new GuiExpressionEvaluator.ExpVal(getExpType(), (maxVal == null), maxVal); if (!_maxExpVal.IsNull && (_maxExpVal.Attr == StorageAttribute.ALPHA || _maxExpVal.Attr == StorageAttribute.UNICODE)) { if (padValueWithMinMaxCharacters) { _maxExpVal.StrVal = DisplayConvertor.StringValueToMgValue(_maxExpVal.StrVal, _maxExpVal.Attr, Char.MaxValue, _size).ToString(); } _maxExpVal.StrVal = StrUtil.SearchAndReplaceWildChars(_maxExpVal.StrVal, _size, Char.MaxValue); } DiscardMax = _max.DiscardCndRangeResult(); } }
/// <summary> /// /// </summary> /// <param name="hasBoundary"></param> /// <param name="IsMaxEqualsMin"></param> /// <param name="expVal"></param> /// <returns></returns> BoundaryValue BuildBoundaryValue(bool hasBoundary, bool IsMaxEqualsMin, GuiExpressionEvaluator.ExpVal expVal, char wildCharFiller, bool shouldDiscard) { BoundaryValue boundaryValue = new BoundaryValue(); boundaryValue.Type = ComputeRangeType(hasBoundary, IsMaxEqualsMin); if (hasBoundary) { boundaryValue.Value = GetFieldValue(expVal, wildCharFiller); if (shouldDiscard) { boundaryValue.Discard = true; } } return(boundaryValue); }
/// <summary>process browser events</summary> /// <param name = "guiMgCtrl">browser control</param> /// <param name = "evt">the event code from InternalInterface</param> /// <param name = "text">the text of the event</param> internal void processBrowserEvent(GuiMgControl guiMgCtrl, int evt, String text) { var browserCtrl = (MgControl)guiMgCtrl; var rtEvt = new RunTimeEvent(browserCtrl, browserCtrl.getDisplayLine(false), true); rtEvt.setInternal(evt); var argsList = new GuiExpressionEvaluator.ExpVal[1]; //create the string for the blob string blobString = BlobType.createFromString(text, BlobType.CONTENT_TYPE_UNICODE); argsList[0] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.BLOB, false, blobString); var args = new ArgumentsList(argsList); rtEvt.setArgList(args); ClientManager.Instance.EventsManager.addToTail(rtEvt); }
/// <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); }
/// <summary> /// /// </summary> /// <param name="record"></param> /// <param name="checkRange"></param> /// <returns></returns> internal override UnitComputeResult Compute(IRecord record, bool checkRange, bool recompute, bool computeInitExpressions) { UnitComputeResult result = new UnitComputeResult(); if (!checkRange) { return(result); } if (!expression.DiscardCndRangeResult()) { GuiExpressionEvaluator.ExpVal expVal = expression.evaluate(StorageAttribute.BOOLEAN); if (!expVal.BoolVal) { result.ErrorCode = UnitComputeErrorCode.RangeFailed; } } return(result); }
/// <summary> /// this function gets a value and checks whether it satisfies the range section /// </summary> /// <param name = "val">- the value to be compared /// </param> protected internal bool checkRange(String val, bool IsNull) { bool res = true; var cmpVal = new GuiExpressionEvaluator.ExpVal(getExpType(), IsNull, val); if (cmpVal.IsNull && ((hasMinExp() && _minExpVal.IsNull) || (hasMaxExp() && _maxExpVal.IsNull))) { res = true; } else { //check min expression Compliance if (hasMinExp()) { //if both of the compared values are not null if (!_minExpVal.IsNull && !cmpVal.IsNull) { try { //the compared value must be equal or greater to the min value if (ExpressionEvaluator.val_cmp_any(cmpVal, _minExpVal, true) < 0) { res = false; } } catch (ExpressionEvaluator.NullValueException) { res = false; } } else if (cmpVal.IsNull != _minExpVal.IsNull) { res = false; } } //check max expression Compliance if (hasMaxExp() && res) { //if both of the compared values are not null if (!_maxExpVal.IsNull && !cmpVal.IsNull) { try { //the compared value must be equal or greater to the min value if (ExpressionEvaluator.val_cmp_any(cmpVal, _maxExpVal, true) > 0) { res = false; } } catch (ExpressionEvaluator.NullValueException) { res = false; } } // if one of them is null and null is the greatest value there is we must check that maxExpVal is not null else if (cmpVal.IsNull != _maxExpVal.IsNull) { res = false; } } } return(res); }