Пример #1
0
        internal override object ConvertRuntimeFieldToGateway(DBField dbField, string runtimeValue)
        {
            Debug.Assert(BlobType.getContentType(runtimeValue) == BlobType.CONTENT_TYPE_ANSI);
            GatewayBlob gatewayValue = new GatewayBlob();

            gatewayValue.Blob        = BlobType.getString(runtimeValue);
            gatewayValue.blobContent = BlobContent.Ansi;
            gatewayValue.BlobSize    = BlobType.getBlobSize(runtimeValue);
            return(gatewayValue);
        }
Пример #2
0
        /// <summary>
        /// Converts 'dotNetObj' to 'Vector' Magic type
        /// </summary>
        /// <param name="dotNetObj"></param>
        /// <returns></returns>
        private static string convertDotNetToVector(object dotNetObj)
        {
            String retObject  = "";
            Type   dotNetType = dotNetObj.GetType();

            if (dotNetType.IsArray)
            {
                Array            arrObj      = (Array)dotNetObj;
                Type             arrCellType = arrObj.GetType().GetElementType();
                StorageAttribute vecCellType = getDefaultVecCellTypeForDotNet(arrCellType);

                if (vecCellType != StorageAttribute.NONE)
                {
                    VectorType vector;
                    String[]   magicVals = new String[arrObj.Length];
                    long       maxLength = 0;

                    // convert each element of array into magic equivalent and store it in temp string array.
                    for (int idx = 0; idx < arrObj.Length; idx++)
                    {
                        magicVals[idx] = convertDotNetToMagic(arrObj.GetValue(idx), vecCellType);

                        // evaluate max length
                        if (magicVals[idx].Length > maxLength)
                        {
                            maxLength = magicVals[idx].Length;
                        }
                    }

                    if (vecCellType == StorageAttribute.BLOB)
                    {
                        maxLength = 28; // length for a blob is always 28
                    }
                    // find cellContentType and create a vector
                    char cellContentType = BlobType.CONTENT_TYPE_UNKNOWN;
                    if (vecCellType == StorageAttribute.BLOB && magicVals.Length > 0)
                    {
                        cellContentType = BlobType.getContentType(magicVals[0]);
                    }
                    vector = new VectorType(vecCellType, cellContentType, "", true, true, maxLength);

                    // set the temp string array into vector
                    for (int idx = 0; idx < arrObj.Length; idx++)
                    {
                        vector.setVecCell(idx + 1, magicVals[idx], false);
                    }

                    // get the flattened string
                    retObject = vector.ToString();
                }
            }

            return(retObject);
        }
Пример #3
0
        /// <summary>
        /// gets the default dotnet type for vector
        /// </summary>
        /// <param name="vector"></param>
        /// <returns></returns>
        private static Type getDefaultDotNetTypeForVector(VectorType vector)
        {
            StorageAttribute vecCellAttr = vector.getCellsAttr();
            Type             dotNetType  = null;

            switch (vecCellAttr)
            {
            case StorageAttribute.NUMERIC:
                dotNetType = typeof(Double);
                break;

            case StorageAttribute.ALPHA:
            case StorageAttribute.UNICODE:
                dotNetType = typeof(String);
                break;

            case StorageAttribute.DATE:
                dotNetType = typeof(DateTime);
                break;

            case StorageAttribute.TIME:
                dotNetType = typeof(TimeSpan);
                break;

            case StorageAttribute.BOOLEAN:
                dotNetType = typeof(Boolean);
                break;

            case StorageAttribute.BLOB:
                if (vector.getVecSize() > 0 && BlobType.getContentType(vector.getVecCell(1)) == BlobType.CONTENT_TYPE_BINARY)
                {
                    dotNetType = typeof(Byte[]);
                }
                else
                {
                    dotNetType = typeof(String);
                }
                break;

            case StorageAttribute.BLOB_VECTOR:
                dotNetType = typeof(Array);
                break;

            case StorageAttribute.DOTNET:
                dotNetType = typeof(Object);
                break;
            }

            return(dotNetType);
        }
Пример #4
0
        /// <returns> translation of this argument into Magic URL style (e.g. -Aalpha or -N17 etc.)</returns>
        protected internal void toURL(StringBuilder htmlArgs, bool makePrintable)
        {
            if (!skipArg())
            {
                String           argValue = null, rangeStr = null;
                StorageAttribute attribute = StorageAttribute.NONE;
                bool             isNull    = false;
                PIC      pic = null;
                NUM_TYPE num1, num2;
                Expression.ReturnValue retVal;
                int compIdx = 0;

                // Get the value and attribute and set the "is null" flag according
                // to the argument type
                switch (_type)
                {
                case ConstInterface.ARG_TYPE_VALUE:
                    isNull    = _valueIsNull;
                    attribute = _valueAttr;
                    argValue  = _val;
                    break;

                case ConstInterface.ARG_TYPE_EXP:
                    retVal   = _exp.evaluate(2000);
                    argValue = retVal.mgVal;
                    if (argValue == null)
                    {
                        isNull = true;
                    }
                    else
                    {
                        attribute = retVal.type;
                    }
                    compIdx = _exp.getTask().getCompIdx();
                    break;

                case ConstInterface.ARG_TYPE_FIELD:
                    if (_fld.isNull())
                    {
                        isNull = true;
                    }
                    else
                    {
                        argValue  = _fld.getValue(false);
                        attribute = _fld.getType();
                    }
                    compIdx = _fld.getTask().getCompIdx();
                    break;

                case ConstInterface.ARG_TYPE_SKIP:
                    isNull = true; //#919535 If argument is skipped then pass NULL it will handled in server.
                    break;
                }

                // Create the argument string
                if (isNull)
                {
                    htmlArgs.Append(ConstInterface.REQ_ARG_NULL);
                }
                else
                {
                    switch (attribute)
                    {
                    case StorageAttribute.NUMERIC:
                        num1 = new NUM_TYPE(argValue);
                        num2 = new NUM_TYPE(argValue);
                        num1.round(0);
                        if (NUM_TYPE.num_cmp(num1, num2) == 0)
                        {
                            pic = new PIC("" + UtilStrByteMode.lenB(argValue),
                                          StorageAttribute.ALPHA, compIdx);
                            String numDispVal = num2.to_a(pic).Trim();
                            if (numDispVal.Length <= 9)
                            {
                                htmlArgs.Append(ConstInterface.REQ_ARG_NUMERIC + num2.to_a(pic).Trim());
                            }
                            else
                            {
                                htmlArgs.Append(ConstInterface.REQ_ARG_DOUBLE + num2.to_double());
                            }
                        }
                        else
                        {
                            htmlArgs.Append(ConstInterface.REQ_ARG_DOUBLE + num2.to_double());
                        }
                        break;

                    case StorageAttribute.DATE:
                        pic      = new PIC(Manager.GetDefaultDateFormat(), attribute, compIdx);
                        rangeStr = "";
                        htmlArgs.Append(ConstInterface.REQ_ARG_ALPHA);
                        break;

                    case StorageAttribute.TIME:
                        pic      = new PIC(Manager.GetDefaultTimeFormat(), attribute, compIdx);
                        rangeStr = "";
                        htmlArgs.Append(ConstInterface.REQ_ARG_ALPHA);
                        break;

                    case StorageAttribute.ALPHA:
                    // alpha strings are kept internally as Unicode, so fall through to unicode case...

                    case StorageAttribute.UNICODE:
                        pic      = new PIC("" + UtilStrByteMode.lenB(argValue), attribute, compIdx);
                        rangeStr = "";

                        /* TODO: Kaushal. this should be "-U".
                         * "-U" is currently used for null value.
                         */
                        htmlArgs.Append(ConstInterface.REQ_ARG_UNICODE);
                        break;

                    case StorageAttribute.BLOB:
                        pic      = new PIC("", attribute, compIdx);
                        rangeStr = "";

                        char contentType = BlobType.getContentType(argValue);
                        // ANSI blobs are later translated to Unicode
                        if (contentType == BlobType.CONTENT_TYPE_UNICODE || contentType == BlobType.CONTENT_TYPE_ANSI)
                        {
                            htmlArgs.Append(ConstInterface.REQ_ARG_UNICODE);
                        }
                        else
                        {
                            htmlArgs.Append(ConstInterface.REQ_ARG_ALPHA);
                        }
                        break;

                    case StorageAttribute.BLOB_VECTOR:
                        pic      = new PIC("", attribute, compIdx);
                        rangeStr = "";
                        htmlArgs.Append(ConstInterface.REQ_ARG_ALPHA);
                        //QCR 970794 appending eye catcher for vectors passed as arguments on hyperlink
                        argValue = ConstInterface.MG_HYPER_ARGS + BlobType.removeBlobPrefix(argValue) +
                                   ConstInterface.MG_HYPER_ARGS;
                        break;

                    case StorageAttribute.BOOLEAN:
                        pic      = new PIC("5", attribute, compIdx);
                        rangeStr = "TRUE,FALSE";
                        htmlArgs.Append(ConstInterface.REQ_ARG_LOGICAL);
                        break;
                    }

                    if (attribute != StorageAttribute.NUMERIC)
                    {
                        string finalValue = StrUtil.rtrim(DisplayConvertor.Instance.mg2disp(argValue, rangeStr, pic, compIdx, false));

                        //QCR 970794 converting the url to a legal format
                        htmlArgs.Append(makePrintable
                                    ? GUIManager.Instance.makeURLPrintable(finalValue)
                                    : finalValue);
                    }
                }
            }
        }