Exemple #1
0
        /// <summary>
        ///   JGENGO: Return Japanese gengo (the name of an era)
        /// </summary>
        protected internal void eval_op_jgengo(ExpressionEvaluator.ExpVal resVal, NUM_TYPE val1, NUM_TYPE val2,
                                               DisplayConvertor displayConvertor)
        {
            String strFormat;
            int    intType;

            resVal.Attr = StorageAttribute.ALPHA;
            if (val1 == null || val2 == null)
            {
                _expressionEvaluator.SetNULL(resVal, StorageAttribute.ALPHA);
                return;
            }

            intType = val2.NUM_2_LONG();

            if (intType >= 4)
            {
                strFormat = "JJJJ";
            }
            else if (intType >= 2)
            {
                strFormat = "JJ";
            }
            else if (intType >= 1)
            {
                strFormat = "J";
            }
            else
            {
                resVal.StrVal = "";
                return;
            }

            _expressionEvaluator.eval_op_date_str(resVal, val1, strFormat, displayConvertor);
        }
Exemple #2
0
        /// <summary>
        ///   evaluate the expression and return the ReturnValue
        /// </summary>
        internal ReturnValue evaluate(int length)
        {
            ExpressionEvaluator.ExpVal expVal  = null;
            StorageAttribute           resType = StorageAttribute.NONE;
            ReturnValue retVal;
            String      val = null;

            if (computedByClient())
            {
                expVal = ExpressionEvaluator.eval(_expBytes, resType, _task);

                ConvertExpValForDotNet(expVal);

                // even if actual dotnet obj is null, we need to return blobPrefix
                if (expVal.IsNull && expVal.Attr != StorageAttribute.DOTNET)
                {
                    val = null;
                }
                else
                {
                    val = expVal.ToMgVal();
                }
                resType = expVal.Attr;
            }
            else
            {
                val     = evaluate(resType, length);
                resType = _type;
            }
            retVal = new ReturnValue(val, resType);
            return(retVal);
        }
Exemple #3
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);
        }
Exemple #4
0
 /// <summary>
 ///   create a new MirrorExpVal and add it to the map
 /// </summary>
 /// <param name = "s"></param>
 /// <param name = "v"></param>
 internal void set(string s, ExpressionEvaluator.ExpVal v)
 {
     if (v.IsNull || v.isEmptyString())
     {
         base.remove(s.Trim().ToUpper());
     }
     else
     {
         base.set(s.Trim().ToUpper(), new MirrorExpVal(v));
     }
 }
Exemple #5
0
 /// <summary>
 ///   JNDOW: Japanese version of NDOW
 /// </summary>
 protected internal void eval_op_jndow(ExpressionEvaluator.ExpVal resVal, ExpressionEvaluator.ExpVal val1,
                                       DisplayConvertor displayConvertor)
 {
     if (val1.MgNumVal == null)
     {
         _expressionEvaluator.SetNULL(resVal, StorageAttribute.ALPHA);
         return;
     }
     val1.MgNumVal = _expressionEvaluator.mul_add(val1.MgNumVal, 0, 6);
     eval_op_jcdow(resVal, val1.MgNumVal, displayConvertor);
 }
Exemple #6
0
        /// <summary>
        ///   update the result into expression DNObjectsCollection Entry and modifies Expval to contain the blob prefix
        /// </summary>
        /// <param name = "expVal"></param>
        private void ConvertExpValForDotNet(ExpressionEvaluator.ExpVal expVal)
        {
            if (expVal.Attr == StorageAttribute.DOTNET)
            {
                // update the value at DNObjectsCollection Key. This is updated into Expression DNObjectsCollection key, so no need to Cast.
                DNManager.getInstance().DNObjectsCollection.Update(_dnObjectCollectionKey, expVal.DnMemberInfo.value);

                bool isNull = (expVal.DnMemberInfo.value == null);

                expVal.Nullify();
                expVal.Init(StorageAttribute.DOTNET, isNull, BlobType.createDotNetBlobPrefix(_dnObjectCollectionKey));
            }
        }
Exemple #7
0
        /// <summary>
        ///   JMONTH: Japanese version of NMONTH
        /// </summary>
        protected internal void eval_op_jmonth(ExpressionEvaluator.ExpVal resVal, ExpressionEvaluator.ExpVal val1)
        {
            if (val1.MgNumVal == null)
            {
                _expressionEvaluator.SetNULL(resVal, StorageAttribute.ALPHA);
                return;
            }
            val1.MgNumVal = _expressionEvaluator.mul_add(val1.MgNumVal, 31, -30);
            _expressionEvaluator.eval_op_month(resVal, val1);
            int month = resVal.MgNumVal.NUM_2_LONG();

            resVal.Attr   = StorageAttribute.ALPHA;
            resVal.StrVal = UtilDateJpn.convertStrMonth(month);
        }
Exemple #8
0
        /// <summary>
        ///   set dot net parameters as arguments for the event
        /// </summary>
        /// <param name = "parameters"></param>
        internal void setDotNetArgs(object[] parameters)
        {
            ExpressionEvaluator.ExpVal[] argsList = new ExpressionEvaluator.ExpVal[parameters.Length];
            for (int i = 0; i < parameters.Length; i++)
            {
                int    key        = DNManager.getInstance().DNObjectsCollection.CreateEntry(null);
                String blobString = BlobType.createDotNetBlobPrefix(key);
                DNManager.getInstance().DNObjectsCollection.Update(key, parameters[i]);
                argsList[i] = new ExpressionEvaluator.ExpVal(StorageAttribute.DOTNET,
                                                             parameters[i] == null, blobString);
            }
            //create the string for the blob
            ArgumentsList args = new ArgumentsList(argsList);

            setArgList(args);
        }
Exemple #9
0
 /// <summary>
 ///   CTOR
 /// </summary>
 internal MirrorExpVal(ExpressionEvaluator.ExpVal val)
 {
     Copy(val);
 }
Exemple #10
0
 /// <summary>
 ///   JYEAR: Return Japanese year of an era
 /// </summary>
 protected internal void eval_op_jyear(ExpressionEvaluator.ExpVal resVal, ExpressionEvaluator.ExpVal val1)
 {
     _expressionEvaluator.eval_op_date_brk(resVal, val1.MgNumVal, 4);
 }
Exemple #11
0
 /// <summary>
 ///   JCDOW: Japanese version of CDOW
 /// </summary>
 protected internal void eval_op_jcdow(ExpressionEvaluator.ExpVal resVal, NUM_TYPE val1,
                                       DisplayConvertor displayConvertor)
 {
     _expressionEvaluator.eval_op_date_str(resVal, val1, "SSSSSST", displayConvertor);
 }
Exemple #12
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);
        }