示例#1
0
        public static UserStatus Update(UserInfo userMain, Dictionary <string, UserFieldInfo> dicField)
        {
            userMain.RealName    = User.GetStringFromDic("RealName", dicField);
            userMain.Gender      = User.GetStringFromDic("Gender", dicField);
            userMain.Birthday    = User.GetDateTimeFromDic("Birthday", dicField, new DateTime(1900, 1, 1));
            userMain.NickName    = User.GetStringFromDic("NickName", dicField);
            userMain.HeaderPhoto = User.GetStringFromDic("HeaderPhoto", dicField);
            userMain.CreditLine  = User.GetDecimalFromDic("CreditLine", dicField, 0.0m);
            userMain.Area        = User.GetStringFromDic("Area", dicField);
            userMain.Country     = User.GetStringFromDic("Country", dicField);
            userMain.Province    = User.GetStringFromDic("Province", dicField);
            userMain.City        = User.GetStringFromDic("City", dicField);
            userMain.County      = User.GetStringFromDic("County", dicField);
            string[] array = userMain.Area.Split(new char[]
            {
                ','
            });
            if (array.Length > 0)
            {
                userMain.Province = array[0];
            }
            if (array.Length > 1)
            {
                userMain.City = array[1];
            }
            if (array.Length > 2)
            {
                userMain.County = array[2];
            }
            userMain.Address   = User.GetStringFromDic("Address", dicField);
            userMain.PostCode  = User.GetStringFromDic("PostCode", dicField);
            userMain.TelePhone = User.GetStringFromDic("TelePhone", dicField);
            userMain.Remark    = User.GetStringFromDic("Remark", dicField);
            UserStatus result;

            if (User.IsExistsByName(userMain.UserName, userMain.AutoID))
            {
                result = UserStatus.ExistsUserName;
            }
            else if (User.IsExistsByEmail(userMain.Email, userMain.AutoID))
            {
                result = UserStatus.ExistsEmail;
            }
            else if (User.IsExistsByMobile(userMain.Mobile, userMain.AutoID))
            {
                result = UserStatus.ExistsMobile;
            }
            else if (User.Update(userMain))
            {
                UserGroupInfo         cacheUserGroupById       = UserGroup.GetCacheUserGroupById(userMain.GroupID);
                IList <UserFieldInfo> customFieldListByModelID = UserField.GetCustomFieldListByModelID(userMain.GroupID);
                foreach (UserFieldInfo current in customFieldListByModelID)
                {
                    if (current.FieldName == "UserID")
                    {
                        current.Value = userMain.AutoID.ToString();
                    }
                    else
                    {
                        current.Value = User.GetStringFromDic(current.FieldName, dicField);
                    }
                }
                User.UpdateCustomUser(userMain.AutoID, cacheUserGroupById.TableName, customFieldListByModelID);
                result = UserStatus.Success;
            }
            else
            {
                result = UserStatus.Error;
            }
            return(result);
        }
示例#2
0
        public static UserStatus Reg(UserInfo userMain, Dictionary <string, UserFieldInfo> dicField, ref int intUserID)
        {
            userMain.RealName    = User.GetStringFromDic("RealName", dicField);
            userMain.Gender      = User.GetStringFromDic("Gender", dicField);
            userMain.Birthday    = User.GetDateTimeFromDic("Birthday", dicField, new DateTime(1900, 1, 1));
            userMain.NickName    = User.GetStringFromDic("NickName", dicField);
            userMain.HeaderPhoto = User.GetStringFromDic("HeaderPhoto", dicField);
            userMain.CreditLine  = User.GetDecimalFromDic("CreditLine", dicField, 0.0m);
            userMain.Area        = User.GetStringFromDic("Area", dicField);
            userMain.Country     = User.GetStringFromDic("Country", dicField);
            userMain.Province    = User.GetStringFromDic("Province", dicField);
            userMain.City        = User.GetStringFromDic("City", dicField);
            userMain.County      = User.GetStringFromDic("County", dicField);
            userMain.Address     = User.GetStringFromDic("Address", dicField);
            userMain.PostCode    = User.GetStringFromDic("PostCode", dicField);
            userMain.TelePhone   = User.GetStringFromDic("TelePhone", dicField);
            userMain.Remark      = User.GetStringFromDic("Remark", dicField);
            string[] array = userMain.Area.Split(new char[]
            {
                ','
            });
            if (array.Length > 0)
            {
                userMain.Province = array[0];
            }
            if (array.Length > 1)
            {
                userMain.City = array[1];
            }
            if (array.Length > 2)
            {
                userMain.County = array[2];
            }
            userMain.Sort          = User.MaxSort + 1;
            userMain.AutoTimeStamp = DateTime.Now;
            userMain.LastLoginTime = DateTime.Now;
            if (userMain.FileSpace.Equals(0))
            {
                userMain.FileSpace = ConfigUtils.GetAppSetting <int>("FileCapacity");
            }
            UserStatus result;

            if (User.IsExistsByName(userMain.UserName))
            {
                result = UserStatus.ExistsUserName;
            }
            else if (User.IsExistsByEmail(userMain.Email))
            {
                result = UserStatus.ExistsEmail;
            }
            else if (User.IsExistsByMobile(userMain.Mobile))
            {
                result = UserStatus.ExistsMobile;
            }
            else
            {
                int num = User.Add(userMain);
                intUserID = num;
                if (num > 0)
                {
                    UserGroupInfo         cacheUserGroupById       = UserGroup.GetCacheUserGroupById(userMain.GroupID);
                    IList <UserFieldInfo> customFieldListByModelID = UserField.GetCustomFieldListByModelID(userMain.GroupID);
                    foreach (UserFieldInfo current in customFieldListByModelID)
                    {
                        if (current.FieldName == "UserID")
                        {
                            current.Value = num.ToString();
                        }
                        else
                        {
                            current.Value = User.GetStringFromDic(current.FieldName, dicField);
                        }
                    }
                    User.AddCustomContent(cacheUserGroupById, customFieldListByModelID);
                    result = UserStatus.Success;
                }
                else
                {
                    result = UserStatus.Error;
                }
            }
            return(result);
        }