Example #1
0
        /// <summary> convert numbers to our secret format
        /// </summary>
        /// <param name="fileName"></param>
        private static String Encode(String numStr, StorageAttribute attr, String picStr)
        {
            PIC      pic      = new PIC(picStr, attr, 0);
            NUM_TYPE num_type = new NUM_TYPE(numStr, pic, 0);

            String encoded_num = num_type.toXMLrecord();

            encoded_num = Base64.encode(RecordUtils.byteStreamToString(encoded_num), ClientManager.Instance.getEnvironment().GetEncoding());
            return(XmlParser.escape(encoded_num));
        }
Example #2
0
        /// <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);
        }
Example #3
0
        /// <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);
        }