Exemple #1
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);
                    }
                }
            }
        }