示例#1
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(Object sender, EventArgs e)
        {
            T_UserEntity data = (T_UserEntity)ViewState["data"];

            data = this.GetFormValue <T_UserEntity>(data);
            if (!IsEdit)
            {
                data.LastSignTime = data.JoinDate;
                data.Salt         = TextHelper.RandomText(10);
            }

            CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT;

            if (db.ExecuteCommand <T_UserEntity>(data, cmd))
            {
                if (!IsEdit)
                {
                    UserName.Text = "";
                }
                if (Admin.ID == EditID)
                {
                    Admin.Update();                    //如果是当前登录用户,更新用户数据
                }
                Alert(Label1, "保存成功!", "line1px_3");

                String text = String.Format("{0}用户:{1}.", IsEdit ? "编辑" : "添加", data.UserName);
                AppendLogs(text, IsEdit ? LogsAction.Edit : LogsAction.Create);
            }
        }
示例#2
0
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(Object sender, EventArgs e)
        {
            if (!IsEdit && ChkUser(UserName.Text))
            {
                Alert(Label1, "用户已经存在!", "line1px_2");
            }
            else
            {
                T_UserEntity data = (T_UserEntity)ViewState["data"];
                data = this.GetFormValue <T_UserEntity>(data);
                if (!IsEdit)
                {
                    data.LastSignTime = data.JoinDate;
                }
                CmdType cmd = IsEdit ? CmdType.UPDATE : CmdType.INSERT;

                if (db.ExecuteCommand <T_UserEntity>(data, cmd))
                {
                    if (!IsEdit)
                    {
                        UserName.Text = "";
                    }
                    if (Admin.ID == EditID)
                    {
                        Admin.Update();                    //如果是当前登录用户,更新用户数据
                    }
                    Alert(Label1, "保存成功!", "line1px_3");
                }
            }
        }
示例#3
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="userEntity"></param>
        /// <param name="unitEntity"></param>
        /// <param name="roleEntity"></param>
        public void AddUser(ref T_UserEntity userEntity, t_unitEntity unitEntity, T_RoleEntity roleEntity)
        {
            //新增员工
            userEntity.user_status      = "1";
            userEntity.user_status_desc = "有效";

            userEntity.user_id        = Guid.NewGuid().ToString("N");
            userEntity.user_password  = "******"; //888888
            userEntity.fail_date      = DateTime.Now.AddYears(20).ToString("yyyy-MM-dd");
            userEntity.customer_id    = CurrentUserInfo.ClientID;
            userEntity.create_user_id = "open";
            userEntity.create_time    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            Create(userEntity);

            //新增员工角色
            var userRoleEntity = new TUserRoleEntity();

            userRoleEntity.user_role_id   = Guid.NewGuid().ToString();
            userRoleEntity.user_id        = userEntity.user_id;
            userRoleEntity.role_id        = roleEntity.role_id;
            userRoleEntity.unit_id        = unitEntity.unit_id;
            userRoleEntity.status         = "1";
            userRoleEntity.create_time    = DateTime.Now;
            userRoleEntity.create_user_id = "open";
            userRoleEntity.modify_time    = DateTime.Now;
            userRoleEntity.modify_user_id = "open";
            userRoleEntity.default_flag   = "1";
            AddUserRole(userRoleEntity);
        }
示例#4
0
 internal void Delete(T_UserEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         conn.Open();
         conn.Delete(dbEntity);
     }
 }
示例#5
0
        /// 内部消息
        /// </summary>
        public string GetGroupNewsByID(string pRequest)
        {
            var    rp         = pRequest.DeserializeJSONTo <APIRequest <GetGroupNewsByIDRP> >();//不需要参数
            string userId     = rp.UserID;
            string customerId = rp.CustomerID;

            if (string.IsNullOrEmpty(rp.Parameters.GroupNewsID))
            {
                throw new APIException("缺少参数【GroupNewsID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            // var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            InnerGroupNewsBLL bll = new InnerGroupNewsBLL(loggingSessionInfo);

            var rd = new GetGroupNewsByIDRD();
            var ds = bll.GetByID(rp.Parameters.GroupNewsID);   //

            if (ds != null && !string.IsNullOrEmpty(ds.CreateBy))
            {
                //t_user从取创建用户
                T_UserBLL bll2 = new T_UserBLL(loggingSessionInfo);
                //更新为已读
                T_UserEntity t_user = bll2.GetByID(ds.CreateBy);
                if (t_user != null)
                {
                    ds.CreateBy = t_user.user_name;
                }
                else
                {
                    ds.CreateBy = "";
                }
                //把该条信息设置为已经读过

                NewsUserMappingBLL    bll3 = new NewsUserMappingBLL(loggingSessionInfo);
                NewsUserMappingEntity en   = new NewsUserMappingEntity();
                en.UserID      = rp.UserID;
                en.GroupNewsID = rp.Parameters.GroupNewsID;
                NewsUserMappingEntity[] lsen = bll3.QueryByEntity(en, null);
                if (lsen != null && lsen.Length != 0)
                {
                    en         = lsen[0];
                    en.HasRead = 1;
                    bll3.Update(en, null);
                }
            }

            rd.InnerGroupNewsInfo = ds;

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
示例#6
0
 internal void Update(T_UserEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         dbEntity.modify_time = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
         //dbEntity.modify_user_id = "ERP";
         conn.Open();
         conn.Update(dbEntity);
     }
 }
示例#7
0
        /// <summary>
        /// 设置扩展信息
        /// </summary>
        /// <param name="data"></param>
        private static void SetUserData(T_UserEntity data)
        {
            String sql = String.Format("SELECT * FROM [T_UserRole] WHERE id={0}", data.RoleID);

            data.UserRole = db.ExecuteObject <T_UserRoleEntity>(sql);

            //sql = String.Format("SELECT * FROM [T_AccessControl] WHERE role={0}", data.RoleID);
            //data.AccessControl = db.ExecuteObject<List<T_AccessControlEntity>>(sql);

            HttpContext.Current.Session[ISessionKeys.session_admin] = data;
        }
示例#8
0
        /// <summary>
        /// 初始化编辑数据
        /// </summary>
        protected void LoadData()
        {
            T_UserEntity data = db.ExecuteObject <T_UserEntity>("SELECT * FROM [T_User] WHERE id=" + EditID);

            ViewState["data"] = data;
            this.SetFormValue(data);

            if (Admin.ID == EditID)
            {
                Status.Enabled = false;
            }
        }
示例#9
0
        /// <summary>
        /// 添加日志记录
        /// </summary>
        /// <param name="content">内容</param>
        /// <param name="action">操作类型</param>
        /// <param name="user">用户</param>
        public static void Append(String content, LogsAction action, T_UserEntity user)
        {
            if (SiteParameter.Config.RecordLog)
            {
                T_LogsEntity log = new T_LogsEntity();
                log.UserID     = user.ID;
                log.UserName   = user.UserName;
                log.Content    = content;
                log.PubDate    = DateTime.Now;
                log.ActionType = action;
                log.UserIP     = Utils.GetIp();

                db.ExecuteCommand <T_LogsEntity>(log, CmdType.INSERT);
            }
        }
示例#10
0
        public string DisableUser(string pRequest)
        {
            var rd     = new APIResponse <DisableUserRD>();
            var rdData = new DisableUserRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <DisableUserRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            T_UserBLL bll = new T_UserBLL(loggingSessionInfo);

            try
            {
                string[]     staffIdArr = rp.Parameters.UserID.Split(',');
                T_UserEntity entity     = null;
                for (int i = 0; i < staffIdArr.Length; i++)
                {
                    entity = bll.GetByID(staffIdArr[i]);
                    if (entity == null)
                    {
                        continue;
                    }
                    entity.user_status      = "0";
                    entity.user_status_desc = "离职";
                    entity.modify_time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    entity.modify_user_id   = rp.UserID;
                    bll.Update(entity);
                }
                rdData.IsSuccess = true;
                rd.ResultCode    = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
示例#11
0
        private T_UserEntity ConvertToT_User(UserContract contract)
        {
            var result = new T_UserEntity
            {
                user_id        = contract.UserId,
                user_code      = contract.UserCode,
                user_name      = contract.UserName,
                user_telephone = contract.UserTelephone,
                create_time    = contract.CreateTime != null?contract.CreateTime.Value.ToString("yyyy-MM-dd hh:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                                     modify_time = contract.ModifyTime != null?contract.ModifyTime.Value.ToString("yyyy-MM-dd hh:mm:ss") : DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),
                                                       customer_id = ConfigMgr.CustomerId,
                                                       user_status = "1"
            };

            return(result);
        }
示例#12
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(T_UserEntity pEntity)
 {
     _currentDAO.Create(pEntity);
     try
     {
         var msg = new EventContract
         {
             Operation  = OptEnum.Create,
             EntityType = EntityTypeEnum.User,
             Id         = pEntity.user_id
         };
         var service = new EventService();
         service.PublishMsg(msg);
     }
     catch (Exception)
     {
         throw new Exception("RabbitMQ Error");
     }
 }
示例#13
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="username">用户名</param>
        /// <param name="password">登录密码</param>
        /// <returns></returns>
        public static void LoginUser(String username, String password, ref IJsonResult result)
        {
            ExecuteObject obj = new ExecuteObject();

            obj.tableName = "T_User";
            obj.cmdtype   = CmdType.SELECT;
            obj.terms.Add("UserName", username);
            obj.terms.Add("UserPass", password);

            T_UserEntity data = db.ExecuteObject <T_UserEntity>(obj);

            if (data.ID > 0)
            {
                if (data.IsLock)
                {
                    result.Text = "当前账号无法登录,请与管理员联系!";
                    T_LogsHelper.Append("尝试登录管理系统.", LogsAction.Login, data);
                }
                else
                {
                    result.Status     = true;
                    data.LastSignTime = DateTime.Now;
                    db.ExecuteCommand <T_UserEntity>(data, CmdType.UPDATE);
                    T_LogsHelper.Append("成功登录管理系统.", LogsAction.Login, data);
                    SetUserData(data);

                    FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "root", DateTime.Now, DateTime.Now.AddMinutes(60), false, data.ID.ToString());
                    String authticket = FormsAuthentication.Encrypt(ticket);

                    CookieHelper.AddCookie(FormsAuthentication.FormsCookieName, authticket);

                    //HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, authticket);
                    //cookie.Expires = DateTime.Now.AddMinutes(60);
                    //cookie.HttpOnly = false;
                    //cookie.Path = FormsAuthentication.FormsCookiePath;
                    //cookie.Secure = FormsAuthentication.RequireSSL;
                    //cookie.Domain = FormsAuthentication.CookieDomain;
                    //HttpContext.Current.Response.Cookies.Set(cookie);
                    //HttpContext.Current.Response.Redirect("/Developer", true);
                }
            }
        }
示例#14
0
        public string DelUser(string pRequest)
        {
            var rd     = new APIResponse <DelUserRD>();
            var rdData = new DelUserRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <DelUserRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = new LoggingSessionManager().CurrentSession;

            T_UserBLL bll = new T_UserBLL(loggingSessionInfo);

            try
            {
                T_UserEntity entity = bll.GetByID(rp.Parameters.UserID);
                entity.user_status      = "-1";
                entity.user_status_desc = "已删除";
                entity.modify_time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                entity.modify_user_id   = rp.UserID;
                bll.Update(entity);
                rdData.IsSuccess = true;
                rd.ResultCode    = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
示例#15
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(T_UserEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
        public string ExportData(string pCustomerID, LoggingSessionInfo pLoggingSessionInfo, DataTable pExportData, JobFunctionEntity[] pJobFuncE, TUnitEntity[] pDeptE, IList <RoleModel> pRoleE)
        {
            T_UserBLL             tubll         = new T_UserBLL(pLoggingSessionInfo);
            UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(pLoggingSessionInfo);
            //客户id
            string customerID = pCustomerID;

            //var tran = this.SQLHelper.CreateTransaction();
            //using (tran.Connection)
            //{
            try
            {
                string   createUserID     = pLoggingSessionInfo.CurrentUser.User_Id;
                string   lastUpdateUserID = pLoggingSessionInfo.CurrentUser.User_Id;
                DateTime dt = DateTime.Now;
                int      existsEmaliNum = 0, notExistsEmailNum = 0;
                string   email = string.Empty;

                if (pExportData != null && pExportData.Rows.Count > 0)
                {
                    DataTable    dTable = pExportData;
                    T_UserEntity tue    = null;
                    foreach (DataRow row in dTable.Rows)
                    {
                        dt = DateTime.Now;
                        //检测邮箱是否存在
                        if (row["邮箱"] == null || string.IsNullOrEmpty(row["邮箱"].ToString()))
                        {
                            continue;
                        }
                        email = row["邮箱"].ToString().Trim().ToLower();
                        tue   = tubll.GetUserEntityByEmail(email, customerID);
                        if (tue != null)
                        {
                            //存在
                            existsEmaliNum++;
                            continue;
                        }
                        else
                        {
                            //不存在
                            notExistsEmailNum++;
                            #region 保存用户
                            tue = new T_UserEntity();
                            string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                            tue.user_id = userId;
                            if (email != null && !string.IsNullOrEmpty(email))
                            {
                                tue.user_email = email;
                            }
                            tue.user_name    = row["用户名称"].ToString();
                            tue.user_name_en = row["英文名"].ToString();
                            if (row["性别"] != null && !string.IsNullOrEmpty(row["性别"].ToString()))
                            {
                                if (row["性别"].ToString().Trim() == "男")
                                {
                                    tue.user_gender = "1";
                                }
                                else if (row["性别"].ToString().Trim() == "女")
                                {
                                    tue.user_gender = "2";
                                }
                                else
                                {
                                    tue.user_gender = "0"; //未知
                                }
                            }
                            else
                            {
                                tue.user_gender = "0";
                            }
                            if (row["生日"] != null && !string.IsNullOrEmpty(row["生日"].ToString()))
                            {
                                tue.user_birthday = Convert.ToDateTime(row["生日"]).ToString("yyyy-MM-dd");
                            }
                            if (row["手机"] != null && !string.IsNullOrEmpty(row["手机"].ToString()))
                            {
                                tue.user_telephone = row["手机"].ToString();
                            }
                            if (row["固话"] != null && !string.IsNullOrEmpty(row["固话"].ToString()))
                            {
                                tue.user_cellphone = row["固话"].ToString();
                            }
                            if (row["用户编码"] != null && !string.IsNullOrEmpty(row["用户编码"].ToString()))
                            {
                                tue.user_code = row["用户编码"].ToString();
                            }

                            tue.user_status      = "1";
                            tue.user_status_desc = "正常";
                            tue.fail_date        = "2020-01-02";
                            tue.user_address     = "";
                            tue.user_password    = MD5Helper.Encryption("123");//默认密码
                            tue.customer_id      = customerID;
                            tue.create_user_id   = tue.modify_user_id = createUserID;
                            tue.create_time      = tue.modify_time = dt.ToString("yyyy-MM-dd HH:mm:ss");
                            tue.msn           = "";
                            tue.qq            = "";
                            tue.blog          = "";
                            tue.user_postcode = "";
                            tue.user_remark   = "";
                            //T_User表
                            //Create(tue, tran);
                            tubll.Create(tue);
                            #endregion

                            #region 保存用户角色
                            //T_User_Role 表
                            string          deptID = pDeptE.Where(a => a.UnitName == row["部门"].ToString().Trim()).First().UnitID.ToString();
                            RoleModel       rm     = pRoleE.Where(a => a.Role_Name == row["角色"].ToString().Trim()).First();
                            TUserRoleEntity ture   = new TUserRoleEntity
                            {
                                user_role_id   = Guid.NewGuid().ToString(),
                                user_id        = userId,
                                role_id        = rm.Role_Id,
                                unit_id        = deptID,
                                status         = "1",
                                create_time    = dt,
                                create_user_id = createUserID,
                                modify_time    = dt,
                                modify_user_id = lastUpdateUserID,
                                default_flag   = "1"
                            };
                            tubll.InsertUserRole(ture);
                            #endregion

                            #region 保存部门、职衔
                            //UserDeptJobMapping表
                            string jobFuncID = pJobFuncE.Where(a => a.Name == row["职衔"].ToString().Trim()).First().JobFunctionID.ToString();
                            UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity
                            {
                                UserDeptID       = Guid.NewGuid(),
                                UserID           = userId,
                                JobFunctionID    = jobFuncID,
                                USERID           = userId,
                                CustomerID       = customerID,
                                CreateTime       = dt,
                                CreateUserID     = createUserID,
                                LastUpdateTime   = dt,
                                LastUpdateUserID = lastUpdateUserID,
                                IsDelete         = 0,
                                UnitID           = deptID
                            };
                            deptJobMapBll.Create(udjme);
                            #endregion
                        }
                    }
                    Loggers.DEFAULT.Debug(new DebugLogInfo()
                    {
                        Message = "重复:" + existsEmaliNum + "条,新增:" + notExistsEmailNum + "条,共:" + dTable.Rows.Count
                    });
                }
                //tran.Commit();
            }
            catch (Exception ex)
            {
                //回滚&转抛异常
                //tran.Rollback();
                throw;
            }
            return("1|成功");
            //}
        }
示例#17
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(T_UserEntity pEntity, IDbTransaction pTran)
 {
     Update(pEntity, true, pTran);
 }
示例#18
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(T_UserEntity pEntity)
 {
     Update(pEntity, true);
 }
示例#19
0
 public void Update(T_UserEntity pEntity, bool pIsUpdateNullField, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pIsUpdateNullField, pTran);
 }
        public string ModifyUserPersonalInfo(string pRequest)
        {
            var rd     = new APIResponse <ModifyUserPersonalInfoRD>();
            var rdData = new ModifyUserPersonalInfoRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <ModifyUserPersonalInfoRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                T_UserBLL    bll    = new T_UserBLL(loggingSessionInfo);
                T_UserEntity entity = bll.GetUserEntityByID(rp.Parameters.UserID);
                if (entity != null)
                {
                    entity.user_code      = rp.Parameters.UserCode;
                    entity.user_name      = rp.Parameters.UserName;
                    entity.user_gender    = rp.Parameters.UserGender;
                    entity.user_email     = rp.Parameters.UserEmail;
                    entity.user_telephone = rp.Parameters.UserTelephone;
                    entity.user_status    = rp.Parameters.UserStatus;

                    if (!string.IsNullOrEmpty(rp.Parameters.UserNameEn))
                    {
                        entity.user_name_en = rp.Parameters.UserNameEn;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserBirthday))
                    {
                        entity.user_birthday = rp.Parameters.UserBirthday;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserPassword))
                    {
                        entity.user_password = rp.Parameters.UserPassword;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.UserCellphone))
                    {
                        entity.user_cellphone = rp.Parameters.UserCellphone;
                    }
                    if (!string.IsNullOrEmpty(rp.Parameters.FailDate))
                    {
                        entity.fail_date = rp.Parameters.FailDate;
                    }

                    bll.Update(entity);

                    //更新LineManagerID
                    UserDeptJobMappingBLL    mappingBll    = new UserDeptJobMappingBLL(loggingSessionInfo);
                    UserDeptJobMappingEntity mappingEntity = mappingBll.GetByUserID(entity.user_id);
                    if (mappingEntity != null)
                    {
                        mappingEntity.LineManagerID = rp.Parameters.LineManagerID;
                        mappingBll.Update(mappingEntity);
                    }
                    rdData.IsSuccess = true;
                    rd.ResultCode    = 0;
                }
                else
                {
                    rdData.IsSuccess = false;
                    rd.ResultCode    = 101;
                    rd.Message       = "用户不存在";
                }
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
示例#21
0
 /// <summary>
 /// 在事务内创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Create(T_UserEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Create(pEntity, pTran);
 }
示例#22
0
        public string AddUser(string pRequest)
        {
            var rd     = new APIResponse <AddUserRD>();
            var rdData = new AddUserRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <AddUserRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var       loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            T_UserBLL bll = new T_UserBLL(loggingSessionInfo);

            try
            {
                string       email = rp.Parameters.UserEmail, customerID = rp.CustomerID;
                T_UserEntity tue = new T_UserEntity();
                tue = bll.GetUserEntityByEmail(rp.Parameters.UserEmail, customerID);
                if (tue == null)
                {
                    DateTime dt = DateTime.Now;

                    #region 保存用户
                    string userId = Guid.NewGuid().ToString().Replace("-", "").ToUpper();
                    tue = new T_UserEntity()
                    {
                        user_id          = userId,
                        user_code        = rp.Parameters.UserCode,
                        user_name        = rp.Parameters.UserName,
                        user_name_en     = rp.Parameters.UserNameEn,
                        user_email       = rp.Parameters.UserEmail,
                        user_password    = MD5Helper.Encryption("123"),//默认密码
                        user_gender      = rp.Parameters.UserGender,
                        user_birthday    = rp.Parameters.UserBirthday,
                        user_telephone   = rp.Parameters.UserTelephone,
                        user_cellphone   = rp.Parameters.UserCellphone,
                        user_status      = "1",
                        user_status_desc = "正常",
                        fail_date        = string.IsNullOrEmpty(rp.Parameters.FailDate) == true ? "2020-01-01" : rp.Parameters.FailDate,
                        customer_id      = customerID,
                        create_time      = dt.ToString("yyyy-MM-dd HH:mm:ss"),
                        create_user_id   = rp.UserID,
                        modify_time      = dt.ToString("yyyy-MM-dd HH:mm:ss"),
                        modify_user_id   = rp.UserID
                    };
                    //T_User表
                    //Create(tue, tran);
                    bll.Create(tue);
                    #endregion

                    #region 保存用户角色
                    //T_User_Role 表
                    TUserRoleEntity ture = new TUserRoleEntity
                    {
                        user_role_id   = Guid.NewGuid().ToString(),
                        user_id        = userId,
                        role_id        = rp.Parameters.RoleID,
                        unit_id        = rp.Parameters.UnitID,
                        status         = "1",
                        create_time    = dt,
                        create_user_id = rp.UserID,
                        modify_time    = dt,
                        modify_user_id = rp.UserID,
                        default_flag   = "1"
                    };
                    bll.InsertUserRole(ture);
                    #endregion

                    #region 保存部门、职衔
                    UserDeptJobMappingBLL deptJobMapBll = new UserDeptJobMappingBLL(loggingSessionInfo);
                    //UserDeptJobMapping表
                    UserDeptJobMappingEntity udjme = new UserDeptJobMappingEntity
                    {
                        UserDeptID       = Guid.NewGuid(),
                        UserID           = userId,
                        JobFunctionID    = rp.Parameters.JobFunctionID,
                        USERID           = userId,
                        CustomerID       = customerID,
                        CreateTime       = dt,
                        CreateUserID     = rp.UserID,
                        LastUpdateTime   = dt,
                        LastUpdateUserID = rp.UserID,
                        IsDelete         = 0,
                        UnitID           = rp.Parameters.UnitID,
                        LineManagerID    = rp.Parameters.LineManagerID,
                        UserLevel        = "0"//默认0
                    };
                    deptJobMapBll.Create(udjme);
                    #endregion

                    rdData.UserID = userId;
                    rd.ResultCode = 0;
                }
                else
                {
                    rd.ResultCode = 101;
                    rd.Message    = "邮箱已存在";
                }
                rd.Data = rdData;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            return(rd.ToJSON());
        }
示例#23
0
 public void Create(T_UserEntity dbEntity)
 {
     _cmd.Create(dbEntity);
 }
示例#24
0
 public void Delete(T_UserEntity dbEntity)
 {
     _cmd.Delete(dbEntity);
 }
示例#25
0
        protected override GetVIPCardRD ProcessRequest(DTO.Base.APIRequest <GetVIPCardRP> pRequest)
        {
            GetVIPCardRD Data = new GetVIPCardRD();
            var          rd   = new GetVIPCardListRD();
            var          para = pRequest.Parameters;
            var          loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            #region 业务对象
            //会员卡
            var VipCardBLL = new VipCardBLL(loggingSessionInfo);
            //会员
            var VipBLL = new VipBLL(loggingSessionInfo);
            //卡状态变更记录
            var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo);
            //卡与Vip关系
            var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            //门店
            var unitBll = new t_unitBLL(loggingSessionInfo);
            //员工
            var UserBLL = new T_UserBLL(loggingSessionInfo);
            //卡类型
            var SysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo);
            //商户配置
            var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);
            //积分
            var VipIntegralBLL = new VipIntegralBLL(loggingSessionInfo);
            #endregion



            #region 会员卡
            VipCardEntity resultData = null;
            if (!string.IsNullOrWhiteSpace(para.VipID))
            {
                //会员编号获取详情
                VipCardVipMappingEntity m_VipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VIPID = para.VipID
                }, null).FirstOrDefault();
                if (m_VipMappingData != null && !string.IsNullOrWhiteSpace(m_VipMappingData.VipCardID))
                {
                    resultData = VipCardBLL.GetByID(para.VipCardID);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(para.VipCardID))
                {
                    //卡ID获取详情
                    resultData = VipCardBLL.GetByID(para.VipCardID);
                }
                else
                {
                    //刷卡获取详情
                    List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                    };
                    if (!string.IsNullOrEmpty(para.VipCardISN))
                    {
                        complexCondition.Add(new DirectCondition("VipCardCode='" + para.VipCardISN + "' or VipCardISN='" + para.VipCardISN.ToString() + "' "));
                    }
                    resultData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault();
                }
            }

            //try
            //{
            //    if (resultData == null)
            //        throw new APIException("该卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
            //}
            //catch (APIException apiEx)
            //{
            //    throw new APIException(apiEx.ErrorCode, apiEx.Message);
            //}
            #endregion

            #region 卡关系
            VipCardVipMappingEntity VipCardVipMappingData = null;
            if (resultData != null)
            {
                VipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VipCardID = resultData.VipCardID
                }, null).FirstOrDefault();
            }
            //else
            //{
            //    return Data;
            //}
            #endregion

            #region 门店
            t_unitEntity unidData = null;
            if (resultData != null && !string.IsNullOrWhiteSpace(resultData.MembershipUnit))
            {
                unidData = unitBll.GetByID(resultData.MembershipUnit);
            }
            #endregion

            #region 会员,积分

            VipEntity         VipData      = null;
            VipIntegralEntity IntegralData = null;
            //string VIPID = VipCardVipMappingData == null ? "" : VipCardVipMappingData.VIPID;
            string VIPID = para.VipID;
            if (!string.IsNullOrWhiteSpace(VIPID))
            {
                VipData = VipBLL.NewGetByID(VIPID);
                //IntegralData = VipIntegralBLL.GetByID(VIPID);
                IntegralData = VipIntegralBLL.QueryByEntity(new VipIntegralEntity()
                {
                    VipID = VipData.VIPID, VipCardCode = VipData.VipCode
                }, null).FirstOrDefault();
            }
            #endregion

            #region 员工
            T_UserEntity UserData = null;
            if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy))
            {
                UserData = UserBLL.GetByID(resultData.CreateBy);
            }
            #endregion

            #region 响应对象赋值
            if (resultData != null)
            {
                //卡
                Data.VipCardID      = resultData.VipCardID;
                Data.VipCardCode    = resultData.VipCardCode;
                Data.VipCardISN     = resultData.VipCardISN;
                Data.CraeteUserName = UserData == null ? "" : UserData.user_name;

                Data.VipCardStatusId    = resultData.VipCardStatusId.Value;
                Data.MembershipTime     = resultData.MembershipTime == null ? "" : resultData.MembershipTime.Value.ToString("yyyy-MM-dd");
                Data.MembershipUnitName = unidData == null ? "" : unidData.unit_name;
                //Data.TotalAmount = resultData.RechargeTotalAmount == null ? 0 : resultData.RechargeTotalAmount.Value;
                //Data.BalanceAmount = resultData.BalanceAmount == null ? 0 : resultData.BalanceAmount.Value;
                Data.BeginDate     = resultData.BeginDate;
                Data.EndDate       = "永久有效";
                Data.SalesUserName = resultData.SalesUserName == null ? "" : resultData.SalesUserName;
                #region 卡类型名称
                SysVipCardTypeEntity SysVipCardTypeData = SysVipCardTypeBLL.GetByID(resultData.VipCardTypeID);
                Data.VipCardName = SysVipCardTypeData == null ? "" : SysVipCardTypeData.VipCardTypeName;
                #endregion

                #region 状态变更记录列表

                var VipCardStatusChangeLogArray = VipCardStatusChangeLogBLL.Query
                                                      (new IWhereCondition[] { new EqualsCondition()
                                                                               {
                                                                                   FieldName = "VipCardID", Value = resultData.VipCardID
                                                                               } },
                                                      new OrderBy[] { new OrderBy()
                                                                      {
                                                                          FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                      } }).ToList();
                //转换业务对象
                Data.StatusLogList = (from t in VipCardStatusChangeLogArray
                                      select new VipCardStatusChangeLog()
                {
                    CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd"),
                    UnitName = t.UnitName == null ? "" : t.UnitName,
                    Action = t.Action == null ? "" : t.Action,
                    ChangeReason = t.Reason == null ? "" : t.Reason,
                    Remark = t.Remark == null ? "" : t.Remark,
                    CreateBy = t.CreateByName,
                    ImageUrl = t.PicUrl == null ? "" : t.PicUrl
                }).ToList();
                #endregion
            }
            #region 会员
            if (VipData != null)
            {
                Data.VipID   = VipData.VIPID;
                Data.VipCode = VipData.VipCode;
                if (Data.VipCardCode == null)
                {
                    Data.VipCardCode = VipData.VipCode;
                }
                if (!string.IsNullOrWhiteSpace(VipData.VipRealName))
                {
                    Data.VipName = VipData.VipRealName;
                }
                else
                {
                    Data.VipName = VipData.VipName ?? "";
                }
                Data.Phone    = VipData.Phone;
                Data.Birthday = VipData.Birthday == null ? "" : VipData.Birthday;
                Data.Gender   = VipData.Gender ?? 0;
                //Data.Integration = VipData.Integration == null ? 0 : VipData.Integration.Value;
                //会员创建人姓名
                T_UserEntity VipUserData = null;
                if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy))
                {
                    VipUserData = UserBLL.GetByID(resultData.CreateBy);
                }
                Data.VipCreateByName = VipUserData == null ? "" : VipUserData.user_name;
                Data.IDNumber        = VipData.IDNumber == null ? "" : VipData.IDNumber;

                #region 会员生日是否可修改字段赋值
                //Col22 字段赋值
                ////CustomerBasicSettingEntity SettingData = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "FSR_NotTwoUpdateVipBirthday" }, null).FirstOrDefault();
                ////if (SettingData != null)
                Data.Col22 = VipData.Col22 == null ? "Y" : VipData.Col22;
                #endregion
            }
            #endregion

            #region 积分
            if (IntegralData != null)
            {
                Data.Integration        = IntegralData.ValidIntegral != null ? IntegralData.ValidIntegral.Value : 0;
                Data.CumulativeIntegral = IntegralData.CumulativeIntegral != null ? IntegralData.CumulativeIntegral.Value : 0;
            }
            #endregion

            #region 余额和返现
            var vipAmountBLL  = new VipAmountBLL(loggingSessionInfo);
            var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity()
            {
                VipId = VipData.VIPID, VipCardCode = VipData.VipCode
            }, null).FirstOrDefault();
            if (vipAmountInfo != null)
            {
                Data.TotalAmount       = vipAmountInfo.TotalAmount == null ? 0 : vipAmountInfo.TotalAmount.Value;
                Data.BalanceAmount     = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
                Data.ValidReturnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                Data.TotalReturnAmount = vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value;
            }
            #endregion


            #endregion
            return(Data);
        }
示例#26
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Delete(T_UserEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Delete(pEntity, pTran);
 }
示例#27
0
 public void Update(T_UserEntity dbEntity)
 {
     _cmd.Update(dbEntity);
 }
示例#28
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public T_UserEntity[] QueryByEntity(T_UserEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
示例#29
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSalesReturnRP> pRequest)
        {
            var rd             = new EmptyResponseData();
            var para           = pRequest.Parameters;
            var salesReturnBLL = new T_SalesReturnBLL(CurrentUserInfo);
            var historyBLL     = new T_SalesReturnHistoryBLL(CurrentUserInfo);
            var pTran          = salesReturnBLL.GetTran();//事务
            T_SalesReturnEntity        salesReturnEntity = null;
            T_SalesReturnHistoryEntity historyEntity     = null;


            var          vipBll     = new VipBLL(CurrentUserInfo);    //会员BLL实例化
            var          userBll    = new T_UserBLL(CurrentUserInfo); //店员BLL实例化
            VipEntity    vipEntity  = null;                           //会员信息
            T_UserEntity userEntity = null;                           //店员信息

            using (pTran.Connection)
            {
                try
                {
                    switch (para.OperationType)
                    {
                    case 1:    //申请
                        salesReturnEntity = new T_SalesReturnEntity();
                        salesReturnEntity.SalesReturnNo = DateTime.Now.ToString("yyyyMMddHHmmssfff");
                        salesReturnEntity.VipID         = CurrentUserInfo.UserID;
                        salesReturnEntity.ServicesType  = para.ServicesType;
                        salesReturnEntity.DeliveryType  = para.DeliveryType;
                        salesReturnEntity.OrderID       = para.OrderID;
                        salesReturnEntity.ItemID        = para.ItemID;
                        salesReturnEntity.SkuID         = para.SkuID;
                        salesReturnEntity.Qty           = para.Qty;
                        salesReturnEntity.ActualQty     = para.Qty;

                        salesReturnEntity.UnitID   = para.UnitID;
                        salesReturnEntity.UnitName = para.UnitName;
                        salesReturnEntity.UnitTel  = para.UnitTel;
                        salesReturnEntity.Address  = para.Address;

                        salesReturnEntity.Contacts = para.Contacts;
                        salesReturnEntity.Phone    = para.Phone;

                        salesReturnEntity.Reason     = para.Reason;
                        salesReturnEntity.Status     = 1;   //待审核
                        salesReturnEntity.CustomerID = CurrentUserInfo.ClientID;

                        salesReturnBLL.Create(salesReturnEntity, pTran);

                        vipEntity = vipBll.GetByID(CurrentUserInfo.UserID);

                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 1,
                            OperationDesc = "申请",
                            OperatorID    = CurrentUserInfo.UserID,
                            HisRemark     = "申请",
                            OperatorName  = vipEntity.VipName,
                            OperatorType  = 0
                        };
                        historyBLL.Create(historyEntity, pTran);
                        break;

                    case 2:    //取消
                        salesReturnEntity = salesReturnBLL.GetByID(para.SalesReturnID);
                        vipEntity         = vipBll.GetByID(CurrentUserInfo.UserID);
                        if (salesReturnEntity != null)
                        {
                            salesReturnEntity.Status = 2;       //取消申请
                            salesReturnBLL.Update(salesReturnEntity, pTran);
                            historyEntity = new T_SalesReturnHistoryEntity()
                            {
                                SalesReturnID = salesReturnEntity.SalesReturnID,
                                OperationType = 2,
                                OperationDesc = "取消申请",
                                OperatorID    = CurrentUserInfo.UserID,
                                HisRemark     = "取消申请",
                                OperatorName  = vipEntity.VipName,
                                OperatorType  = 0
                            };
                            historyBLL.Create(historyEntity, pTran);
                        }
                        break;

                    default:
                        break;
                    }
                    pTran.Commit();  //提交事物
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事务
                    throw new APIException(ex.Message);
                }
            }
            return(rd);
        }
示例#30
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <T_UserEntity> PagedQueryByEntity(T_UserEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }