Example #1
0
        public int TeamDown(List <string> ids)
        {
            using (var db = new BFdbContext())
            {
                int res = 0;

                using (var tx = db.BeginTransaction())
                {
                    try
                    {
                        foreach (string id in ids)
                        {
                            string sqlteam = string.Format("update tbl_teams set eventid=2 where teamid='{0}'", id);
                            db.ExecuteSqlCommand(sqlteam);

                            string sqlusers = string.Format("update tbl_match_users set isdown='1' where teamid='{0}'", id);
                            db.ExecuteSqlCommand(sqlusers);
                        }
                        tx.Commit();
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        throw ex;
                    }
                }

                return(res);
            }
        }
Example #2
0
        public int AllTeamDown(string matchid)
        {
            using (var db = new BFdbContext())
            {
                int res = 0;

                using (var tx = db.BeginTransaction())
                {
                    try
                    {
                        string sqlteam = string.Format("update tbl_teams set eventid=2 where status=0  and match_id='{0}'", matchid);
                        db.ExecuteSqlCommand(sqlteam);

                        string sqlusers = string.Format("update tbl_match_users set isdown='1' where status=1 and match_id='{0}'", matchid);
                        db.ExecuteSqlCommand(sqlusers);

                        tx.Commit();
                    }
                    catch (Exception ex)
                    {
                        tx.Rollback();
                        throw ex;
                    }
                }

                return(res);
            }
        }
Example #3
0
        public string EditUserRule(string userid, string ruleids)
        {
            try
            {
                using (BFdbContext db = new BFdbContext())
                {
                    var tran = db.BeginTransaction();
                    db.ExecuteSqlCommand(string.Format("delete from cmn_relation where userid='{0}'", userid));

                    var rids = ruleids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var id in rids)
                    {
                        db.ExecuteSqlCommand(string.Format(@"insert into cmn_relation(userid, device, layer, ruleid)
                                                             select '{0}',a.device,a.layer,a.id from cmn_rule a where a.id='{1}'", userid, id));
                    }
                    tran.Commit();

                    return("");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Example #4
0
        /// <summary>
        /// 添加关系
        /// </summary>
        /// <param name="role"></param>
        /// <param name="menuids"></param>
        /// <returns></returns>
        public string AddRoleMenu(string role, string menuids)
        {
            try
            {
                using (BFdbContext db = new BFdbContext())
                {
                    var tran = db.BeginTransaction();
                    db.ExecuteSqlCommand(string.Format("delete from tb_rolemenurelation where roleid='{0}'", role));

                    //角色ID
                    var rids = menuids.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var id in rids)
                    {
                        db.ExecuteSqlCommand(string.Format("insert into tb_rolemenurelation(roleid, menuid) values('{0}','{1}')", role, id));
                    }
                    tran.Commit();

                    return("");
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Example #5
0
        public string ResetSerial(string matchid, string lineid, string linesid)
        {
            string ret = "-1";

            using (var db = new BFdbContext())
            {
                try
                {
                    StringBuilder sql = new StringBuilder();
                    sql.Append("update tbl_teams set teamno = '0' where 1=1 ");

                    if (!string.IsNullOrEmpty(matchid))
                    {
                        sql.AppendFormat(" AND match_id  =  '{0}'", matchid);
                    }

                    if (!string.IsNullOrEmpty(lineid))
                    {
                        sql.AppendFormat(" AND lineid  =  '{0}'", lineid);
                    }

                    if (!string.IsNullOrEmpty(linesid))
                    {
                        sql.AppendFormat(" AND linesid  =  '{0}'", linesid);
                    }

                    db.ExecuteSqlCommand(sql.ToString());
                    ret = "0";
                }
                catch { }
            }

            return(ret);
        }
Example #6
0
 /// <summary>
 /// sql执行数据库
 /// </summary>
 /// <param name="sql"></param>
 /// <param name="parms"></param>
 /// <returns></returns>
 public int ExecuteSqlCommand(string sql, params object[] parms)
 {
     using (var db = new BFdbContext())
     {
         return(db.ExecuteSqlCommand(sql, parms));
     }
 }
Example #7
0
        public string AddDict(List <CMNDICT> dictEntity)
        {
            try
            {
                var rs = false;

                using (BFdbContext db = new BFdbContext())
                {
                    db.ExecuteSqlCommand("delete from cmn_dict where dictid='3000'");

                    using (db.BeginTransaction())
                    {
                        foreach (var entity in dictEntity)
                        {
                            db.TInsert <CMNDICT>(entity);
                        }
                    }

                    db.SaveChanges();

                    rs = true;
                }

                return(rs ? "0" : "-1");
            }
            catch (Exception ex)
            {
                log.Error(ex);
                throw GetFault(ex);
            }
        }
Example #8
0
        public int UpdateUser(tblusers usr)
        {
            using (var db = new BFdbContext())
            {
                var tusr = db.tblusers.FirstOrDefault(p => p.userid == usr.userid);
                if (tusr == null)
                {
                    return(-1);
                }
                else
                {
                    tusr.birthday = usr.birthday;
                    tusr.cardno   = usr.cardno;
                    tusr.cardtype = usr.cardtype;
                    tusr.Mobile   = usr.Mobile;
                    tusr.Name     = usr.Name;
                    tusr.sexy     = usr.sexy;
                    tusr.Isupt    = "1";
                    tusr.Ismod    = "1";
                    tusr.Modtime  = DateTime.Now;

                    // or match_id='6a61b95b-2d5d-4373-abaf-bf4e4c438800')
                    string sql = string.Format(@"update tbl_match_users set birthday='{0}',age={1},cardno='{2}',cardtype='{3}',sexy={4},mobile='{5}',nickname='{6}' 
                    where userid='{7}' and (match_id in (select match_id from tbl_match where status in (0,1)) or match_id='c83aa363-873e-489e-ac07-373489c94320')",
                                               tusr.birthday.Value.ToString("yyyy-MM-dd"), SetYearOld(tusr.birthday.Value), tusr.cardno, tusr.cardtype, tusr.sexy, tusr.Mobile, tusr.Name, tusr.userid);

                    db.ExecuteSqlCommand(sql);

                    return(db.Update <tblusers>(tusr));
                }
            }
        }
Example #9
0
        public int changeteam(tblteams tm)
        {
            using (var db = new BFdbContext())
            {
                var team = db.tblteams.FirstOrDefault(p => p.teamid == tm.teamid);

                if (team == null)
                {
                    return(-1);
                }

                if (team.Status.Value == 0)
                {
                    return(-2);
                }

                if (db.tblteams.Any(p => p.teamid != tm.teamid && p.match_id == team.match_id && p.Teamname == tm.Teamname))
                {
                    return(-3);
                }

                string sql = string.Format("update tbl_match_users set teamname='{0}' where teamid='{1}'", tm.Teamname, tm.teamid);
                db.ExecuteSqlCommand(sql);

                team.Teamname = tm.Teamname;
                return(db.Update <tblteams>(team));
            }
        }
Example #10
0
 public int UpdateUserLastTime(string userid)
 {
     using (var db = new BFdbContext())
     {
         string sql = string.Format("update tbl_users set last_time=now() where userid='{0}'", userid);
         return(db.ExecuteSqlCommand(sql));
     }
 }
Example #11
0
        public int DelTeam(string tid)
        {
            using (var db = new BFdbContext())
            {
                string sql = "delete from tbl_teams where status='6' and teamid='" + tid + "'";
                int    res = db.ExecuteSqlCommand(sql);

                if (res > 0)
                {
                    sql = "delete from tbl_match_users where teamid='" + tid + "'";
                    res = db.ExecuteSqlCommand(sql);

                    sql = "delete from tbl_orders where status=0 and teamid='" + tid + "'";
                    res = db.ExecuteSqlCommand(sql);
                }

                return(res);
            }
        }