Пример #1
0
        /// <summary>process browser events</summary>
        /// <param name = "guiMgCtrl">browser control</param>
        /// <param name = "evt">the event code from InternalInterface</param>
        /// <param name = "text">the text of the event</param>
        internal void processBrowserEvent(GuiMgControl guiMgCtrl, int evt, String text)
        {
            var browserCtrl = (MgControl)guiMgCtrl;
            var rtEvt       = new RunTimeEvent(browserCtrl, browserCtrl.getDisplayLine(false), true);

            rtEvt.setInternal(evt);

            var argsList = new GuiExpressionEvaluator.ExpVal[1];
            //create the string for the blob
            string blobString = BlobType.createFromString(text, BlobType.CONTENT_TYPE_UNICODE);

            argsList[0] = new GuiExpressionEvaluator.ExpVal(StorageAttribute.BLOB, false, blobString);
            var args = new ArgumentsList(argsList);

            rtEvt.setArgList(args);

            ClientManager.Instance.EventsManager.addToTail(rtEvt);
        }
Пример #2
0
        public void Convert(DBField sourceField, DBField destinationField, FieldValue sourceValue, FieldValue destinationValue)
        {
            switch (destinationField.Storage)
            {
            case FldStorage.AnsiBlob:
                destinationValue.Value = BlobType.createFromString(string.Empty, BlobType.CONTENT_TYPE_ANSI);
                break;

            case FldStorage.UnicodeBlob:
                destinationValue.Value = BlobType.createFromString(string.Empty, BlobType.CONTENT_TYPE_UNICODE);
                break;

            case FldStorage.Blob:
                destinationValue.Value = BlobType.createFromString(string.Empty, BlobType.CONTENT_TYPE_BINARY);
                break;
            }
            destinationValue.Value = BlobType.copyBlob(destinationValue.Value.ToString(), sourceValue.Value.ToString());
        }
Пример #3
0
        /// <summary>
        /// Converts 'dotNetObj' to 'Blob' Magic type
        /// </summary>
        /// <param name="dotNetObj"></param>
        /// <returns></returns>
        private static string convertDotNetToBlob(object dotNetObj)
        {
            String blob       = BlobType.createFromString("", BlobType.CONTENT_TYPE_UNKNOWN);
            Type   dotNetType = dotNetObj.GetType();

            if (dotNetType == typeof(Byte))
            {
                Byte[] bytes = new Byte[] { (Byte)dotNetObj };
                blob = BlobType.createFromBytes(bytes, BlobType.CONTENT_TYPE_BINARY);
            }
            else if (dotNetType == typeof(Byte[]))
            {
                Byte[] bytes = (Byte[])dotNetObj;
                blob = BlobType.createFromBytes(bytes, BlobType.CONTENT_TYPE_BINARY);
            }
            else if (dotNetType == typeof(Char))
            {
                String blobStr = new String((Char)dotNetObj, 1);
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(Char[]))
            {
                String blobStr = new String((Char[])dotNetObj);
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(String))
            {
                blob = BlobType.createFromString((String)dotNetObj, BlobType.CONTENT_TYPE_UNICODE);
            }
            else if (dotNetType == typeof(StringBuilder))
            {
                String blobStr = ((StringBuilder)dotNetObj).ToString();
                blob = BlobType.createFromString(blobStr, BlobType.CONTENT_TYPE_UNICODE);
            }

            return(blob);
        }
Пример #4
0
        internal override object ConvertGatewayToRuntimeField(DBField dbField, object gatewayValue)
        {
            var gatewayBlob = (GatewayBlob)gatewayValue;

            return(BlobType.createFromString((string)gatewayBlob.Blob, BlobType.CONTENT_TYPE_ANSI));
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="attribute"></param>
        /// <param name="valueStr"></param>
        /// <returns></returns>
        protected virtual bool setDBFieldAttribute(DBField dbField, string attribute, string valueStr)
        {
            int tmp;

            switch (attribute)
            {
            case ConstInterface.MG_ATTR_ISN:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Isn = tmp;
                break;

            case ConstInterface.MG_ATTR_ATTR:
                dbField.Attr = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_ALLOW_NULL:
                dbField.AllowNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_DEFAULT_NULL:
                dbField.DefaultNull = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_STORAGE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Storage = (FldStorage)tmp;
                break;

            case ConstInterface.MG_ATTR_LENGTH:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Length = tmp;
                break;

            case ConstInterface.MG_ATTR_DATASOURCE_DEFINITION:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.DataSourceDefinition = (DatabaseDefinitionType)tmp;
                break;

            case ConstInterface.MG_ATTR_DIFF_UPDATE:
                dbField.DiffUpdate = valueStr[0];
                break;

            case ConstInterface.MG_ATTR_DEC:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Dec = tmp;
                break;

            case ConstInterface.MG_ATTR_WHOLE:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.Whole = tmp;
                break;

            case ConstInterface.MG_ATTR_PART_OF_DATETIME:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.PartOfDateTime = tmp;
                break;

            case ConstInterface.MG_ATTR_DEFAULT_STORAGE:
                dbField.DefaultStorage = valueStr[0] == '1';
                break;

            case ConstInterface.MG_ATTR_CONTENT:
                IntUtil.TryParse(valueStr, out tmp);
                dbField.BlobContent = (BlobContent)BlobType.ParseContentType(tmp);
                break;

            case ConstInterface.MG_ATTR_PICTURE:
                dbField.Picture = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_DEFAULT_VALUE:
                dbField.DbDefaultValue = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_FLD_DB_INFO:
                dbField.DbInfo = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_NAME:
                dbField.DbName = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_DB_TYPE:
                dbField.DbType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_USER_TYPE:
                dbField.UserType = XmlParser.unescape(valueStr);
                break;

            case ConstInterface.MG_ATTR_NULL_DISPLAY:
                dbField.NullDisplay = XmlParser.unescape(valueStr);
                break;

            case XMLConstants.MG_ATTR_DEFAULTVALUE:
                dbField.DefaultValue = valueStr;
                if (dbField.Attr == (char)StorageAttribute.ALPHA || dbField.Attr == (char)StorageAttribute.UNICODE)
                {
                    dbField.DefaultValue = XmlParser.unescape(valueStr);
                    dbField.DefaultValue = StrUtil.padStr(dbField.DefaultValue, dbField.Length);
                }
                else if (dbField.DefaultValue.Length == 0 && dbField.Attr != (char)StorageAttribute.BLOB &&
                         dbField.Attr != (char)StorageAttribute.BLOB_VECTOR)
                {
                    dbField.DefaultValue = null;
                }
                else if (dbField.Attr == (char)StorageAttribute.BLOB)
                {
                    dbField.DefaultValue = BlobType.createFromString(dbField.DefaultValue, (char)dbField.BlobContent);
                }
                break;

            case ConstInterface.MG_ATTR_FIELD_NAME:
                dbField.Name = XmlParser.unescape(valueStr);
                break;

            default:
                return(false);
            }
            return(true);
        }
Пример #6
0
        /// <summary>
        /// converts Alpha/Unicode values to Blob and vice versa.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="srcAttr"></param>
        /// <param name="expectedType"></param>
        /// <returns></returns>
        internal static String convertArgs(String value, StorageAttribute srcAttr, StorageAttribute expectedType)
        {
            int    key;
            object dotNetObj  = null;
            bool   invalidArg = false;

            if (srcAttr != StorageAttribute.DOTNET &&
                expectedType == StorageAttribute.DOTNET)
            {
                //Convert Magic To DotNet
                key       = _tempTableKey;
                dotNetObj = DNConvert.convertMagicToDotNet(value, srcAttr,
                                                           DNConvert.getDefaultDotNetTypeForMagicType(value, srcAttr));

                DNManager.getInstance().DNObjectsCollection.Update(key, dotNetObj);
                value = BlobType.createDotNetBlobPrefix(key);
            }
            else if (srcAttr == StorageAttribute.DOTNET &&
                     expectedType != StorageAttribute.DOTNET &&
                     expectedType != StorageAttribute.NONE)
            {
                //Convert DotNet to Magic
                key = BlobType.getKey(value);

                if (key != 0)
                {
                    dotNetObj = DNManager.getInstance().DNObjectsCollection.GetDNObj(key);
                    value     = DNConvert.convertDotNetToMagic(dotNetObj, expectedType);
                }
            }
            else
            {
                switch (expectedType)
                {
                case StorageAttribute.ALPHA:
                case StorageAttribute.UNICODE:
                    if (srcAttr == StorageAttribute.BLOB)
                    {
                        if (BlobType.isValidBlob(value))
                        {
                            value = BlobType.getString(value);
                        }
                    }
                    else if (!StorageAttributeCheck.IsTypeAlphaOrUnicode(srcAttr))
                    {
                        invalidArg = true;
                    }
                    break;

                case StorageAttribute.NUMERIC:
                case StorageAttribute.DATE:
                case StorageAttribute.TIME:
                    if (!StorageAttributeCheck.isTypeNumeric(srcAttr))
                    {
                        invalidArg = true;
                    }
                    break;

                case StorageAttribute.BLOB:
                    if (StorageAttributeCheck.IsTypeAlphaOrUnicode(srcAttr))
                    {
                        char contentType = srcAttr == StorageAttribute.ALPHA
                                           ? BlobType.CONTENT_TYPE_ANSI
                                           : BlobType.CONTENT_TYPE_UNICODE;
                        value = BlobType.createFromString(value, contentType);
                    }
                    else if (!StorageAttributeCheck.isTypeBlob(srcAttr))
                    {
                        invalidArg = true;
                    }
                    break;
                }

                //If there is mismatch in attribute, take default value of expectd argument.
                if (invalidArg)
                {
                    value = FieldDef.getMagicDefaultValue(expectedType);
                }
            }

            return(value);
        }