コード例 #1
0
        public void GetFromBusinessObject(BusinessObject objBusinessObject)
        {
            BusinessObjectHelper.InitPropertyList(this.AATableName);
            BusinessObjectHelper.InitPropertyList(objBusinessObject.AATableName);

            foreach (PropertyInfo srcProp in BusinessObjectHelper.PropertyList[objBusinessObject.AATableName].Values)
            {
                PropertyInfo destProp = BusinessObjectHelper.GetProperty(this.AATableName, srcProp.Name);
                if (destProp != null)
                {
                    object objValue = ABCDynamicInvoker.GetValue(objBusinessObject, srcProp);
                    ABCDynamicInvoker.SetValue(this, destProp, objValue);
                }
            }
        }
コード例 #2
0
        public BusinessObject SetToBusinessObject(String strDestTableName)
        {
            BusinessObject objResultObject = BusinessObjectFactory.GetBusinessObject(strDestTableName + "Info");

            foreach (PropertyInfo destProp in BusinessObjectHelper.PropertyList[strDestTableName].Values)
            {
                PropertyInfo srcProp = BusinessObjectHelper.GetProperty(this.AATableName, destProp.Name);
                if (srcProp != null)
                {
                    object objValue = ABCDynamicInvoker.GetValue(this, srcProp);
                    ABCDynamicInvoker.SetValue(objResultObject, destProp, objValue);
                }
            }

            return(objResultObject);
        }
コード例 #3
0
        public static void SetValue(BusinessObject obj, String strColName, object value)
        {
            string key = obj.AATableName + strColName;

            try
            {
                SetHandler setHandler = null;
                if (lstSetHandler.TryGetValue(key, out setHandler) == false)
                {
                    Type type = obj.GetType();

                    PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName);
                    if (proInfo == null)
                    {
                        proInfo = type.GetProperty(strColName);
                    }

                    setHandler = ABCDynamicMethodCompiler.CreateSetHandler(type, proInfo);
                    lstSetHandler.Add(key, setHandler);
                }

                if (value is String && value.ToString().Replace("'", "").ToUpper() == "TRUE")
                {
                    value = true;
                }
                else if (value is String && value.ToString().Replace("'", "").ToUpper() == "FALSE")
                {
                    value = false;
                }
                setHandler(obj, value);
            }
            catch (System.Exception ex)
            {
                PropertyInfo proInfo = obj.GetType().GetProperty(strColName);
                if (proInfo == null)
                {
                    //    Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "SetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" );
                    return;
                }
                proInfo.SetValue(obj, value, null);
            }
        }
コード例 #4
0
        public static object GetValue(BusinessObject obj, String strColName)
        {
            if (obj == null)
            {
                return(null);
            }

            string key = obj.AATableName + strColName;

            try
            {
                GetHandler getHandler = null;
                if (lstGetHandler.TryGetValue(key, out getHandler) == false)
                {
                    Type type = obj.GetType();

                    PropertyInfo proInfo = BusinessObjectHelper.GetProperty(obj.AATableName, strColName);
                    if (proInfo == null)
                    {
                        proInfo = type.GetProperty(strColName);
                    }

                    getHandler = ABCDynamicMethodCompiler.CreateGetHandler(type, proInfo);
                    lstGetHandler.Add(key, getHandler);
                }

                return(getHandler(obj));
            }
            catch (System.Exception ex)
            {
                PropertyInfo proInfo = obj.GetType().GetProperty(strColName);
                if (proInfo == null)
                {
                    //    Utilities.ABCLogging.LogNewMessage( "ABCDataLib" , "" , "GetValue" , obj.GetType().Name+" not contain "+strColName , "FAILE" );
                    return(null);
                }

                return(proInfo.GetValue(obj, null));
            }
        }
コード例 #5
0
        public static bool CopyFKFields(BusinessObject objFrom, BusinessObject objTo, Boolean isCleanFieldOnly)
        {
            if (objFrom == null || objTo == null)
            {
                return(false);
            }

            bool isCopied = false;

            String strFromName = objFrom.AATableName;
            String strToName   = objTo.AATableName;

            BusinessObjectHelper.InitPropertyList(strToName);
            foreach (PropertyInfo propTo in BusinessObjectHelper.PropertyList[strToName].Values)
            {
                if (DataStructureProvider.IsForeignKey(strToName, propTo.Name) == false)
                {
                    continue;
                }

                PropertyInfo propFrom = BusinessObjectHelper.GetProperty(strFromName, propTo.Name);
                if (propFrom != null)
                {
                    if (isCleanFieldOnly == false || (isCleanFieldOnly && IsCleanField(objTo, propTo.Name)))
                    {
                        object objValue    = ABCDynamicInvoker.GetValue(objFrom, propFrom);
                        object objOldValue = ABCDynamicInvoker.GetValue(objTo, propTo);
                        ABCDynamicInvoker.SetValue(objTo, propTo, objValue);
                        if (objOldValue != objValue)
                        {
                            isCopied = true;
                        }
                    }
                }
            }
            return(isCopied);
        }