Example #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);
        }
Example #2
0
        /// <summary>
        /// Converts Magic 'Date' Type to 'dotNetType'
        /// </summary>
        /// <param name="magicVal"></param>
        /// <param name="dotNetType"></param>
        /// <returns></returns>
        private static object convertDateToDotNet(string magicVal, Type dotNetType)
        {
            if (dotNetType == typeof(DateTime))
            {
                NUM_TYPE         numType          = new NUM_TYPE(magicVal);
                DisplayConvertor displayConvertor = DisplayConvertor.Instance;

                int date = numType.NUM_2_LONG();
                if (date == 0)
                {
                    magicVal = FieldDef.getMagicDefaultValue(StorageAttribute.DATE);
                    numType  = new NUM_TYPE(magicVal);
                    date     = numType.NUM_2_LONG();
                }

                // Break date into its components - year month date
                DisplayConvertor.DateBreakParams breakParams = displayConvertor.getNewDateBreakParams();
                displayConvertor.date_break_datemode(breakParams, date, true, -1);
                int year  = breakParams.year;
                int month = breakParams.month;
                int day   = breakParams.day;

                return(new DateTime(year, month, day));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
 /// <summary>
 ///   returns the value of the Yes/No/Expression
 /// </summary>
 internal bool getVal()
 {
     if (_exp != null)
     {
         return(DisplayConvertor.toBoolean(_exp.evaluate(StorageAttribute.BOOLEAN, 0)));
     }
     return(_val);
 }
Example #4
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);
 }
Example #5
0
        /// <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();
            }
        }
Example #6
0
        /// <summary>
        /// Convert Hebrew year/day to a string
        /// </summary>
        /// <param name="outStr"></param>
        /// <param name="len"></param>
        /// <param name="full_len"></param>
        /// <param name="hyear"></param>
        /// <param name="trim"></param>
        /// <param name="use_ending"></param>
        /// <returns>length</returns>
        internal static int dateheb_2_str(char[] outStr, int strPos, int len, ref int out_len, int full_len, int hyear, bool trim, bool use_ending)
        {
            bool quote;
            int  heb_len;
            int  rem_len;

            quote = (len > full_len && outStr[strPos + full_len] == outStr[strPos]);
            if (quote)
            {
                full_len++;
            }
            heb_len = dateheb_i_2_h(hyear % 1000, outStr, strPos, use_ending, quote);

            rem_len = full_len - heb_len;
            if (rem_len > 0)
            {
                if (trim)
                {
                    out_len -= rem_len;
                    int tmp_out_len = len - full_len;
                    if (tmp_out_len > 0)
                    {
                        DisplayConvertor.char_memcpy(outStr, strPos + heb_len, outStr, strPos + full_len, tmp_out_len);
                    }
                    else
                    {
                        heb_len = full_len;
                    }
                }
                else
                {
                    // Do not over the string length. It may be when YYYY in the end. (DDD MMMMM YYYY)
                    if (rem_len > outStr.Length - strPos - heb_len)
                    {
                        rem_len = outStr.Length - strPos - heb_len;
                    }
                    DisplayConvertor.char_memset(outStr, strPos + heb_len, ' ', rem_len);
                    heb_len = full_len;
                }
            }

            return(heb_len);
        }
Example #7
0
        /// <summary>
        /// init the boundary
        /// </summary>
        /// <param name="boundaryValue"></param>
        /// <param name="storageAttribute"></param>
        /// <param name="discard"></param>
        /// <param name="value"></param>
        private void InitBoundary(BoundaryValue boundaryValue, StorageAttribute storageAttribute, bool discard, string value, int length, char filler)
        {
            if (discard)
            {
                boundaryValue.Type         = RangeType.RangeNoVal;
                boundaryValue.Value.IsNull = true;
            }
            else
            {
                if (value == null)
                {
                    boundaryValue.Value.IsNull = true;
                }
                else
                {
                    if (storageAttribute == StorageAttribute.ALPHA ||
                        storageAttribute == StorageAttribute.UNICODE)
                    {
                        if (IsLocate)
                        {
                            boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                        }
                        else
                        {
                            boundaryValue.Value.Value = value;
                        }

                        boundaryValue.Value.Value = StrUtil.SearchAndReplaceWildChars((string)boundaryValue.Value.Value, length, filler);
                    }
                    else
                    {
                        boundaryValue.Value.Value = DisplayConvertor.StringValueToMgValue(value, storageAttribute, filler, length);
                    }
                }

                boundaryValue.Type = RangeType.RangeParam;
            }
        }
Example #8
0
        /// <summary>
        /// Converts Magic 'Time' Type to 'dotNetType'
        /// </summary>
        /// <param name="magicVal"></param>
        /// <param name="dotNetType"></param>
        /// <returns></returns>
        private static object convertTimeToDotNet(string magicVal, Type dotNetType)
        {
            Object retObject = null;

            if (dotNetType == typeof(DateTime) || dotNetType == typeof(TimeSpan))
            {
                NUM_TYPE         numType          = new NUM_TYPE(magicVal);
                DisplayConvertor displayConvertor = DisplayConvertor.Instance;

                int time = numType.NUM_2_ULONG();

                // Break time into its components - hour min sec
                DisplayConvertor.TimeBreakParams breakParams = displayConvertor.getNewTimeBreakParams();
                DisplayConvertor.time_break(breakParams, time);
                int hour   = breakParams.hour;
                int minute = breakParams.minute;
                int second = breakParams.second;

                if (dotNetType == typeof(DateTime))
                {
                    DateTime dateTimeObj = new DateTime();

                    dateTimeObj = dateTimeObj.AddHours(hour);
                    dateTimeObj = dateTimeObj.AddMinutes(minute);
                    dateTimeObj = dateTimeObj.AddSeconds(second);

                    retObject = dateTimeObj;
                }
                else if (dotNetType == typeof(TimeSpan))
                {
                    retObject = new TimeSpan(hour, minute, second);
                }
            }

            return(retObject);
        }
Example #9
0
        /// <summary>
        /// set the field attribute in parsing
        /// </summary>
        protected virtual bool setAttribute(string attribute, string valueStr)
        {
            bool isTagProcessed = true;

            switch (attribute)
            {
            case XMLConstants.MG_ATTR_TYPE:
                _type = (StorageAttribute)valueStr[0];
                break;

            case XMLConstants.MG_ATTR_SIZE:
                _size = XmlParser.getInt(valueStr);
                if (_size <= 0)
                {
                    Events.WriteExceptionToLog("in Field.initElements(): size must be greater than zero");
                }
                break;

            case XMLConstants.MG_ATTR_VAR_NAME:
                _varName = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_VAR_DISP_NAME:
                VarDisplayName = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_PICTURE:
                _picture = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_VEC_CELLS_SIZE:
                _vecCellsSize = Int32.Parse(valueStr);
                break;

            case XMLConstants.MG_ATTR_VEC_CELLS_ATTR:
                _vecCellsType = (StorageAttribute)valueStr[0];
                break;

            case XMLConstants.MG_ATTR_VEC_CELLS_CONTENT:
                _vecCellsContentType = valueStr[0];
                break;

            case XMLConstants.MG_ATTR_NULLVALUE:
                if (_type == StorageAttribute.NUMERIC || _type == StorageAttribute.DATE ||
                    _type == StorageAttribute.TIME)
                {
                    //working in hex or base64
                    if (Manager.Environment.GetDebugLevel() > 1)
                    {
                        _nullValue = XmlParser.unescape(valueStr);
                    }
                    else
                    {
                        _nullValue = Base64.decodeToHex(valueStr);
                    }
                }
                else
                {
                    _nullValue = XmlParser.unescape(valueStr);
                }
                break;

            case XMLConstants.MG_ATTR_NULLDISPLAY:
                _nullDisplay = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_NULLDEFAULT:
                _nullDefault = DisplayConvertor.toBoolean(valueStr);
                break;

            case XMLConstants.MG_ATTR_DB_MODIFIABLE:
                DbModifiable = DisplayConvertor.toBoolean(valueStr);
                break;

            case XMLConstants.MG_ATTR_DEFAULTVALUE:
                DefaultValue = valueStr;
                if (_type == StorageAttribute.ALPHA || _type == StorageAttribute.UNICODE)
                {
                    DefaultValue = XmlParser.unescape(valueStr);
                    DefaultValue = StrUtil.padStr(DefaultValue, _size);
                }
                else if (_type != StorageAttribute.BLOB && _type != StorageAttribute.BOOLEAN)
                //working in hex or base64
                {
                    if ((_type == StorageAttribute.BLOB_VECTOR &&
                         (_vecCellsType == StorageAttribute.NUMERIC ||
                          _vecCellsType == StorageAttribute.DATE ||
                          _vecCellsType == StorageAttribute.TIME)) ||
                        (_type == StorageAttribute.NUMERIC || _type == StorageAttribute.DATE ||
                         _type == StorageAttribute.TIME))
                    {
                        if (Manager.Environment.GetDebugLevel() < 1)
                        {
                            DefaultValue = Base64.decodeToHex(valueStr);
                        }
                    }
                }
                else if (DefaultValue.Length == 0 && _type != StorageAttribute.BLOB &&
                         _type != StorageAttribute.BLOB_VECTOR)
                {
                    DefaultValue = null;
                }
                else if (_type == StorageAttribute.BLOB)
                {
                    DefaultValue = BlobType.createFromString(DefaultValue, _contentType);
                }
                break;

            case XMLConstants.MG_ATTR_NULLALLOWED:
                NullAllowed = DisplayConvertor.toBoolean(valueStr);
                break;

            case XMLConstants.MG_ATTR_BLOB_CONTENT:
                _contentType = valueStr[0];
                break;

            case XMLConstants.MG_ATTR_PART_OF_DATAVIEW:
                _partOfDataview = DisplayConvertor.toBoolean(valueStr);
                break;

            case XMLConstants.MG_ATTR_DOTNET_TYPE:
                _dotNetType = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_DOTNET_ASSEMBLY_ID:
                _assemblyId = XmlParser.getInt(valueStr);
                break;

            case XMLConstants.MG_ATTR_STORAGE:
                Storage = (FldStorage)XmlParser.getInt(valueStr);
                break;

            default:
                isTagProcessed = false;
                break;
            }

            return(isTagProcessed);
        }
Example #10
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);
 }