Beispiel #1
0
        public void FillIdentityInfo(int userId, Dictionary <string, object> dictionary)
        {
            string        birth = null, industry = null;
            int?          gender = null, cityId = null;
            Vnet_Identity daIdentity = new Vnet_Identity();

            if (daIdentity.SelectByUser_Id(userId))
            {
                birth  = daIdentity.Birthday.HasValue ? daIdentity.Birthday.Value.ToString() : string.Empty;
                gender = daIdentity.Gender;
                if (daIdentity.Region_Id.HasValue)
                {
                    var region = ChinaArea.GetRegion(daIdentity.Region_Id.Value);
                    cityId = region?.City_ID;
                }
            }
            Tnet_User_Profile daUserProfile = new Tnet_User_Profile();

            if (daUserProfile.SelectByPk(userId))
            {
                if (daUserProfile.City_Id.HasValue)
                {
                    cityId = daUserProfile.City_Id.Value;
                }
                industry = daUserProfile.Industry;
            }
            dictionary.Add("Birthday", birth);
            dictionary.Add("Industry", industry);
            dictionary.Add("Gender", gender);
            dictionary.Add("CityId", cityId);
        }
Beispiel #2
0
        public object GetProfile(IUser user)
        {
            Dictionary <string, object> dictionary = new Dictionary <string, object>();
            Tnet_User_Profile           daProfile  = new Tnet_User_Profile();

            if (!daProfile.SelectOrgInfoByUserId(user.UserId))
            {
                return(dictionary);
            }
            dictionary.Add("Org_Code", daProfile.DataRow["ORG_CODE"]);
            dictionary.Add("Org_Name", daProfile.DataRow["ORG_NAME"]);
            dictionary.Add("Org_Type", daProfile.DataRow["ORG_TYPE"]);
            //dictionary.Add("User_Name", daProfile.DataRow["USER_NAME"]);
            //dictionary.Add("User_Code", daProfile.DataRow["User_Code"].ToString().ToMask(3, "****", 4));
            return(dictionary);
        }
Beispiel #3
0
        public bool ModifyUserProfile(Entities.ViewModels.UserModifyModel model)
        {
            if (!model.City_Id.HasValue && string.IsNullOrEmpty(model.Avatar) && !model.Org_Id.HasValue &&
                string.IsNullOrEmpty(model.Industry))
            {
                return(true);
            }
            var fac = UserModuleFactory.GetUserModuleInstance();

            if (fac == null)
            {
                Alert((ResultType)500, "系统错误");
                return(false);
            }
            IUser user = fac.GetUserByCode(model.UserCode);

            if (user == null)
            {
                Alert((ResultType)404, "找不到用户信息");
                return(false);
            }
            if (!model.City_Id.HasValue && string.IsNullOrEmpty(model.Avatar) && !model.Org_Id.HasValue &&
                !string.IsNullOrEmpty(user.Avatar) && user.Avatar.Equals(model.Avatar, StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            BeginTransaction();
            Tnet_User_Profile daProfile = new Tnet_User_Profile();

            daProfile.ReferenceTransactionFrom(Transaction);
            bool isExist = daProfile.SelectByPk(user.UserId);

            if (model.City_Id.HasValue)
            {
                daProfile.City_Id = model.City_Id.Value;
            }
            if (!string.IsNullOrEmpty(model.Industry))
            {
                daProfile.Industry = model.Industry;
            }
            if (model.Org_Id.HasValue)
            {
                daProfile.Org_Id = model.Org_Id.Value;
            }
            if (!isExist)
            {
                daProfile.User_Id = user.UserId;
                if (!daProfile.Insert())
                {
                    Rollback();
                    Alert((ResultType)541, "用户资料更新失败");
                    return(false);
                }
            }
            else
            {
                if (!daProfile.Update())
                {
                    Rollback();
                    Alert((ResultType)542, "用户资料更新失败");
                    return(false);
                }
            }
            if (!string.IsNullOrEmpty(model.Avatar))
            {
                user.Avatar = model.Avatar;
                var manager = fac.GetProfileManager(user);
                if (!manager.Update())
                {
                    Rollback();
                    Alert((ResultType)540, "头像上传失败");
                    return(false);
                }
            }

            Commit();
            return(true);
        }
Beispiel #4
0
        private bool UpgradeUserRole(SubOrder subOrder, UserLevel level)
        {
            DateTime start = DateTime.Now;

            BeginTransaction();
            Tnet_User_Role daVip = new Tnet_User_Role();

            daVip.ReferenceTransactionFrom(Transaction);
            if (!daVip.SelectByUserId_UserLevel(subOrder.User_Id, (int)level))
            {
                daVip.User_Id          = subOrder.User_Id;
                daVip.Expire_Time      = start.AddYears(1);
                daVip.Last_Modify_Time = DateTime.Now;
                daVip.User_Level       = (int)level;
                daVip.Role_Name        = UserLevel.VIP会员.ToString();
                if (!daVip.Insert())
                {
                    Rollback();
                    return(false);
                }
            }
            else
            {
                if (daVip.Expire_Time > start)
                {
                    start = daVip.Expire_Time;
                }
                daVip.Expire_Time      = start.AddYears(1);
                daVip.Last_Modify_Time = DateTime.Now;
                if (!daVip.Update())
                {
                    Rollback();
                    return(false);
                }
            }
            if (!string.IsNullOrEmpty(this.Order.Biz_Args))
            {
                JsonObject arg      = JsonObject.Parse(this.Order.Biz_Args);
                string     org_code = arg.GetString("Org_Code");
                if (!string.IsNullOrEmpty(org_code))
                {
                    Tnet_Organization daOrg = new Tnet_Organization();
                    if (!daOrg.SelectByOrgCode(org_code))
                    {
                        Rollback();
                        Alert("归属俱乐部未找到");
                        return(false);
                    }
                    Tnet_User_Profile daProfile = new Tnet_User_Profile();
                    daProfile.ReferenceTransactionFrom(Transaction);
                    daProfile.User_Id          = daVip.User_Id;
                    daProfile.Org_Id           = daOrg.Org_Id;
                    daProfile.Last_Modify_Time = DateTime.Now;
                    if (!daProfile.Update())
                    {
                        Rollback();
                        Alert("修改归属信息失败");
                        return(false);
                    }
                }
            }
            Tnet_User daUser = new Tnet_User();

            daUser.ReferenceTransactionFrom(Transaction);
            if (!daUser.UpdateUserLevel(subOrder.User_Id, level))
            {
                Rollback();
                Alert("更新会员角色失败");
                return(false);
            }
            Commit();
            return(true);
        }