/// <summary> /// ComputeAndRefresh DataColumn /// </summary> /// <param name="colID"></param> /// <param name="removeHandler"></param> /// <param name="colVal"></param> private void ComputeAndRefreshColumn(int colID, bool removeHandler, ref object colVal) { Field field = null; if (colID > 0) { int fldIdx = DVDataTableObj.GetFldIdx(colID); field = (Field)DVControl.getForm().getTask().DataView.getField(fldIdx); } //First column is 'Isn'. Give a call to core to fetch PosCache's current Isn. And store it if (colID == 0) { colVal = (int)((TaskBase)DVControl.getForm().getTask()).GetDVControlPosition(); } else if (field != null) { String value = String.Empty; Object dnValue = null; bool isNull = false; //get field's value by ((TaskBase)field.getTask()).getFieldDisplayValue(field, ref value, ref isNull); dnValue = DNConvert.convertMagicToDotNet(value, field.getType(), typeof(Object)); colVal = dnValue; } }
/// <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); }