Пример #1
0
        public static void CopyObject(BusinessObject objFromObjectsInfo, BusinessObject objToObjectsInfo)
        {
            VinaDbUtil dbUtil = new VinaDbUtil();
            String     strToObjectTableName   = VinaUtil.GetTableNameFromBusinessObject(objToObjectsInfo);
            String     strFromObjectTableName = VinaUtil.GetTableNameFromBusinessObject(objFromObjectsInfo);

            if (objFromObjectsInfo.GetType().Name.Contains("ForView"))
            {
                strFromObjectTableName = objFromObjectsInfo.GetType().Name.Replace("ForView", "");
            }
            PropertyInfo[] properties = objToObjectsInfo.GetType().GetProperties();
            string         toObjectTablePrimaryKey = dbUtil.GetTablePrimaryColumn(strToObjectTableName);

            foreach (PropertyInfo prop in properties)
            {
                if (prop.Name != toObjectTablePrimaryKey && prop.Name != "IsTransferred" && !prop.Name.Contains("TransferredDate"))
                {
                    String strFromObjectPropertyName = string.Empty;
                    if (prop.Name.StartsWith(strToObjectTableName.Substring(0, strToObjectTableName.Length - 1)))
                    {
                        strFromObjectPropertyName = strFromObjectTableName.Substring(0, strFromObjectTableName.Length - 1) + prop.Name.Substring(strToObjectTableName.Length - 1);
                    }
                    PropertyInfo propFromObjectProperty = objFromObjectsInfo.GetType().GetProperty(strFromObjectPropertyName);
                    if (propFromObjectProperty != null)
                    {
                        object objValue = propFromObjectProperty.GetValue(objFromObjectsInfo, null);
                        prop.SetValue(objToObjectsInfo, objValue, null);
                    }
                    else
                    {
                        strFromObjectPropertyName = strFromObjectTableName.Substring(0, 2) + prop.Name.Substring(2);
                        propFromObjectProperty    = objFromObjectsInfo.GetType().GetProperty(strFromObjectPropertyName);
                        if (propFromObjectProperty != null)
                        {
                            object objValue = propFromObjectProperty.GetValue(objFromObjectsInfo, null);
                            prop.SetValue(objToObjectsInfo, objValue, null);
                        }
                        else
                        {
                            propFromObjectProperty = objFromObjectsInfo.GetType().GetProperty(prop.Name);
                            if (propFromObjectProperty != null)
                            {
                                object objValue = propFromObjectProperty.GetValue(objFromObjectsInfo, null);
                                prop.SetValue(objToObjectsInfo, objValue, null);
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        //protected void ShowAllMainScreens()
        //{
        //    for (int index = 0; index < this.Screens.Count; ++index)
        //    {
        //        BOSScreen screen = this.Screens[index];
        //        string screenNumber = this.Screens[index].ScreenNumber;
        //        if (screenNumber.StartsWith("DM") || screenNumber.StartsWith("SM") || screenNumber.StartsWith("SR"))
        //            this.ShowScreen(screen, true);
        //    }
        //}

        //public virtual void ShowScreen(BOSScreen scr, bool bIsChild)
        //{
        //}

        //public virtual BOSScreen GetScreenByScreenNumber(string strScreenNumber)
        //{
        //    for (int index = 0; index < this.Screens.Count; ++index)
        //    {
        //        if (this.Screens[index].ScreenNumber == strScreenNumber)
        //            return this.Screens[index];
        //    }
        //    return (BOSScreen)null;
        //}

        //public MethodInfo GetMethodInfoByMethodNameAndParametersType(string strMethodName, System.Type[] parametersType)
        //{
        //    return this.GetType().GetMethod(strMethodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, (Binder)null, parametersType, (ParameterModifier[])null);
        //}



        /// <summary>
        ///
        /// </summary>
        /// <param name="strMethodFullName"></param>
        /// <returns></returns>
        public System.Type[] GetParameterTypeArrayFromMethodFullName(string strMethodFullName)
        {
            string str = strMethodFullName.Substring(strMethodFullName.IndexOf("("));

            System.Type[] array = new System.Type[0];
            for (int index = str.IndexOf(","); index > 0; index = str.IndexOf(","))
            {
                Array.Resize <System.Type>(ref array, array.Length + 1);
                array.SetValue((object)System.Type.GetType(str.Substring(1, index - 1)), array.Length - 1);
                str = str.Substring(index + 1);
            }
            int num = str.IndexOf(")");

            if (num > 0 && !string.IsNullOrEmpty(str.Substring(1, num - 1)))
            {
                Array.Resize <System.Type>(ref array, array.Length + 1);
                array.SetValue((object)this.GetType(VinaUtil.GetFullTypeName(str.Substring(1, num - 1))), array.Length - 1);
            }
            return(array);
        }
Пример #3
0
 public static string GetBusinessControllerNameFromBusinessObject(BusinessObject objInfo)
 {
     return(VinaUtil.GetTableNameFromBusinessObject(objInfo) + "Controller");
 }