Exemple #1
0
        /// <summary>
        /// 用户注册时,生成验证码
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public int GetSMS(string mobile, string ip)
        {
            using (var db = new BFdbContext())
            {
                if (db.tblusers.Any(p => p.Mobile == mobile && p.Status == 0))
                {
                    return(-1);
                }

                DateTime dt   = DateTime.Now.AddDays(-2);
                int      cntt = db.tbluserstime.Count(p => p.RomateIp == ip && p.crtdate >= dt);
                if (cntt >= 10)
                {
                    return(-3);
                }

                int cnt = db.tbluserstime.Count(p => p.Mobile == mobile && p.crtdate >= dt);
                if (cnt >= 10)
                {
                    return(-2);
                }

                tblusers usr = new tblusers();
                usr.Mobile = mobile;
                usr.Passwd = "-";
                usr.mono   = VerifyCode.Get6SzCode();
                //测试注册验证码改成固定数值
                //usr.mono = "123456";
                usr.Status   = 4;
                usr.Playerid = 0;
                usr.userid   = Guid.NewGuid().ToString();
                usr.Isupt    = "0";
                usr.Type     = "8";
                usr.Ismod    = "";

                int res = db.Insert <tblusers>(usr);

                tbluserstime tm = new tbluserstime();
                tm.crtdate  = DateTime.Now;
                tm.Mobile   = mobile;
                tm.tid      = Guid.NewGuid().ToString();
                tm.RomateIp = ip;
                db.Insert <tbluserstime>(tm);

                if (res > 0)
                {
                    SMSHepler.SendRegSms(mobile, usr.mono);
                }

                return(res);
            }
        }
Exemple #2
0
        /// <summary>
        /// 注册队伍
        /// </summary>
        /// <param name="id"></param>
        /// <param name="tid"></param>
        /// <param name="tname"></param>
        /// <param name="tcom"></param>
        /// <returns></returns>
        public int RegTname(string id, string tid, string tname, string tcom, string pwd)
        {
            using (var db = new BFdbContext())
            {
                if (db.tblteams.Any(p => p.match_id == tid && p.Teamname == tname))
                {
                    return(-1);
                }

                int uid = int.Parse(id);

                var usr = db.tblusers.FirstOrDefault(p => p.userid == uid.ToString());
                if (usr != null)
                {
                    usr.Passwd = pwd;
                    db.Update <tblusers>(usr);
                }

                tblteams tm = new tblteams();
                //tm.Company = string.IsNullOrEmpty(tcom) ? "个人" : tcom;
                tm.Createtime = DateTime.Now;
                tm.Eventid    = 1;
                tm.Lineid     = "";
                tm.match_id   = tid;
                tm.Status     = 6;
                tm.Teamname   = tname;
                tm.Teamno     = "";
                tm.Userid     = id;

                db.Insert <tblteams>(tm);

                return(db.SqlQuery <autoid>("select @@identity as id").FirstOrDefault().Id);
            }
        }
Exemple #3
0
 /// <summary>
 /// 新增数据
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="entity"></param>
 /// <returns></returns>
 public int Insert <T>(T entity) where T : class
 {
     using (var db = new BFdbContext())
     {
         return(db.Insert <T>(entity));
     }
 }
Exemple #4
0
        public string AddRule(string ruleid, string rulename, string descr, string device, string layer)
        {
            try
            {
                using (BFdbContext db = new BFdbContext())
                {
                    var rs = db.CMNRULE.Count(s => s.RULENAME == rulename) > 0;
                    if (rs)
                    {
                        return("-1");
                    }

                    CMNRULE ent = new CMNRULE();
                    ent.DESCRP      = descr;
                    ent.DEVICE      = device;
                    ent.ID          = ruleid;
                    ent.LAYER       = layer;
                    ent.RULENAME    = rulename;
                    ent.CREATEDDATE = Int64.Parse(DateTime.Now.ToString("yyyyMMddHHmmss"));
                    return(db.Insert <CMNRULE>(ent).ToString());
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Exemple #5
0
        /// <summary>
        /// 添加角色
        /// </summary>
        /// <param name="id"></param>
        /// <param name="rolename"></param>
        /// <param name="remark"></param>
        /// <param name="by"></param>
        /// <returns></returns>
        public string AddRole(string id, string rolename, string remark, string by)
        {
            try
            {
                using (BFdbContext db = new BFdbContext())
                {
                    if (db.TBROLE.Any(p => p.ROLENAME == rolename))
                    {
                        return("已经存在角色名称");
                    }

                    TBROLE role = new TBROLE();
                    role.ID         = id;
                    role.ROLENAME   = rolename;
                    role.REMARK     = remark;
                    role.CREATEDATE = DateTime.Now;
                    role.CREATEID   = by;
                    role.UPDATEDATE = DateTime.Now;
                    role.UPDATEID   = by;

                    return(db.Insert <TBROLE>(role).ToString());
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Exemple #6
0
        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="id"></param>
        /// <param name="userid"></param>
        /// <param name="pwd"></param>
        /// <param name="username"></param>
        /// <param name="telphone"></param>
        /// <param name="email"></param>
        /// <param name="remark"></param>
        /// <param name="by"></param>
        /// <returns></returns>
        public string AddUser(string id, string userid, string pwd, string username, string telphone, string email, string remark, string review, string by)
        {
            try
            {
                using (BFdbContext db = new BFdbContext())
                {
                    if (db.TBUSER.Any(p => p.USERID == userid && p.DELFLAG == "0"))
                    {
                        return("已经存在相同用户");
                    }

                    TBUSER user = new TBUSER();
                    user.ID         = id;
                    user.USERID     = userid;
                    user.USERNAME   = username;
                    user.PWD        = pwd;
                    user.DELFLAG    = "0";
                    user.EMAIL      = email;
                    user.REMARK     = remark;
                    user.TELEPHONE  = telphone;
                    user.CREATEDATE = DateTime.Now;
                    user.CREATEID   = by;
                    user.UPDATEDATE = DateTime.Now;
                    user.UPDATEID   = by;
                    user.RE_REVIEW  = review;
                    return(db.Insert <TBUSER>(user).ToString());
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Exemple #7
0
 /// <summary>
 /// 新增赛事
 /// </summary>
 /// <param name="ent"></param>
 /// <returns></returns>
 public int AddMatch(tblmatch ent)
 {
     using (var db = new BFdbContext())
     {
         return(db.Insert <tblmatch>(ent));
     }
 }
Exemple #8
0
 /// <summary>
 /// 新增线路
 /// </summary>
 /// <param name="ent"></param>
 /// <returns></returns>
 public int AddLine(tblline ent)
 {
     using (var db = new BFdbContext())
     {
         return(db.Insert <tblline>(ent));
     }
 }
Exemple #9
0
 /// <summary>
 /// 新增队伍
 /// </summary>
 /// <param name="ent"></param>
 /// <returns></returns>
 public int AddTeam(tblteams ent)
 {
     using (var db = new BFdbContext())
     {
         if (db.tblteams.Any(u => u.Teamname == ent.Teamname))
         {
             throw new ValidException("Mobile", "此队伍名称已经存在!");
         }
         return(db.Insert <tblteams>(ent));
     }
 }
Exemple #10
0
        /// <summary>
        /// 团队导入
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public int ImpTeams(DataTable data)
        {
            using (var db = new BFdbContext())
            {
                tblusers usr = new tblusers();
                //usr.Mobile = mobile;
                usr.mono   = VerifyCode.Get6SzCode();
                usr.Status = 6;

                return(db.Insert <tblusers>(usr));
            }
        }
Exemple #11
0
        /// <summary>
        /// 团队注册1步
        /// </summary>
        /// <param name="mobile"></param>
        /// <returns></returns>
        public int Step1(string mobile)
        {
            using (var db = new BFdbContext())
            {
                tblusers usr = new tblusers();
                usr.Mobile = mobile;
                usr.mono   = VerifyCode.Get6SzCode();
                usr.Status = 6;

                return(db.Insert <tblusers>(usr));
            }
        }
Exemple #12
0
 /// <summary>
 /// 新增会员
 /// </summary>
 /// <param name="ent"></param>
 /// <returns></returns>
 public int AddMember(tblusers ent)
 {
     using (var db = new BFdbContext())
     {
         if (db.tblusers.Any(u => u.Mobile == ent.Mobile))
         {
             throw new ValidException("Mobile", "已存在此名称的电话!");
         }
         ent.Last_Time = DateTime.Now;
         return(db.Insert <tblusers>(ent));
     }
 }
Exemple #13
0
 /// <summary>
 /// 新增用户
 /// </summary>
 /// <param name="ent"></param>
 /// <returns></returns>
 public int AddUser(sysuser ent)
 {
     using (var db = new BFdbContext())
     {
         if (db.sysuser.Any(u => u.Username == ent.Username))
         {
             throw new ValidException("Username", "已存在此名称的用户!");
         }
         ent.Delflag     = false;
         ent.Createddate = DateTime.Now;
         ent.Modifydate  = DateTime.Now;
         return(db.Insert <sysuser>(ent));
     }
 }
Exemple #14
0
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="type"> 1.登录 2.注册 3.报名 4.支付 5.比赛</param>
        /// <param name="userid"></param>
        /// <param name="ip"></param>
        /// <param name="note"></param>
        /// <returns></returns>
        public int OptLog(int type, string userid, string ip, string note)
        {
            tbllog log = new tbllog();

            log.createtime = System.DateTime.Now;
            log.IP         = ip;
            log.opttype    = type;
            log.remark     = note;
            log.tid        = System.Guid.NewGuid().ToString();
            log.userid     = userid;
            log.source     = 1; //来源 1.web 2.app
            using (var db = new BFdbContext())
            {
                return(db.Insert <tbllog>(log));
            }
        }
Exemple #15
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="loginname_"></param>
        /// <param name="password_"></param>
        /// <returns></returns>
        public UserInfoEntity Login(string loginname_, string password_)
        {
            try
            {
                UserInfoEntity ent = new UserInfoEntity();

                //验证服务器是否授权
                //int aut = DataCache.IsAuth;
                //if (aut != 0)
                //{
                //    ent.IsOK = aut;
                //    return ent;
                //}

                using (BFdbContext db = new BFdbContext())
                {
                    var user = db.TBUSER.FirstOrDefault(p => p.USERID.ToLower() == loginname_.ToLower() && p.PWD == password_ && p.DELFLAG == "0");
                    if (user == null)
                    {
                        ent.IsOK = -99;
                        ent.Msg  = "-1";
                    }
                    else
                    {
                        ent.IsOK      = 0;
                        ent.ID        = user.ID;
                        ent.USERID    = user.USERID;
                        ent.USERNAME  = user.USERNAME;
                        ent.PASSWORD  = user.PWD;
                        ent.EMAIL     = user.EMAIL;
                        ent.TELEPHONE = user.TELEPHONE;
                        ent.RE_REVIEW = user.RE_REVIEW;

                        string sql = @"select distinct a.id, a.menuname, a.menucode, a.remark,a.updatedate,a.updateid,a.createdate,a.createid 
                                    from tb_menu a,tb_rolemenurelation b,tb_userrolerelation c
                                    where a.id=b.menuid and b.roleid=c.roleid and c.userid='{0}'";
                        ent.MenuList = db.SqlQuery <TBMENU>(string.Format(sql, user.ID)).ToList();

                        //提供方法执行的上下文环境
                        OperationContext context = OperationContext.Current;
                        //获取传进的消息属性
                        MessageProperties properties = context.IncomingMessageProperties;

                        RemoteEndpointMessageProperty endpoint = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                        TBUSERLOG log = new TBUSERLOG();
                        log.CREATEDATE = DateTime.Now;
                        log.ID         = Guid.NewGuid().ToString("N");
                        log.IP         = endpoint.Address;
                        log.REMARK     = "";
                        log.TYPE       = "0";
                        log.USERID     = ent.ID;

                        db.Insert <TBUSERLOG>(log);
                    }

                    return(ent);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }