Пример #1
0
        public Models.DbModels.tb_token GetToken(DbConn PubConn, string token, DbModels.TokenType tokentype)
        {
            string sql = " select token,userid,id,username,appid,createtime,expires from " + tokentype.ToString() + " where token=@token";
            List <ProcedureParameter> Par = new List <ProcedureParameter>();

            Par.Add(new ProcedureParameter("@token", token));
            DataSet ds = new DataSet();

            PubConn.SqlToDataSet(ds, sql, Par);

            if (ds.Tables[0].Rows.Count != 1)
            {
                return(null);
            }
            return(CreateModel(ds.Tables[0].Rows[0]));
        }
Пример #2
0
        public virtual bool Delete(DbConn PubConn, string id, DbModels.TokenType tokentype)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>();

            Par.Add(new ProcedureParameter("@token", id));

            string Sql = "delete from " + tokentype.ToString() + " where token=@token";
            int    rev = PubConn.ExecuteSql(Sql, Par);

            if (rev == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        internal string getUserName(XXF.Db.DbConn PubConn, string userid, DbModels.TokenType tokentype)
        {
            CertCenter.Models.DbModels.manage model = null;
            switch (tokentype)
            {
            case DbModels.TokenType.usertoken:
                model = getUser(PubConn, userid); break;

            case DbModels.TokenType.managetoken:
                model = getManage(PubConn, userid);
                break;

            case DbModels.TokenType.shoptoken:
                model = getShop(PubConn, userid);
                break;
            }
            if (model == null)
            {
                return("");
            }
            return(model.username);
        }
Пример #4
0
        public virtual bool Edit(DbConn PubConn, DbModels.tb_token model, DbModels.TokenType tokentype)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>()
            {
                //
                new ProcedureParameter("@token", model.token),
                //
                new ProcedureParameter("@userid", model.userid),
                //
                new ProcedureParameter("@id", model.id),
                //
                new ProcedureParameter("@username", model.username),
                //
                new ProcedureParameter("@appid", model.appid),
                //
                new ProcedureParameter("@createtime", model.createtime),
                //
                new ProcedureParameter("@expires", model.expires)
            };
            int rev = PubConn.ExecuteSql("update " + tokentype.ToString() + " set userid=@userid,id=@id,username=@username,appid=@appid,createtime=@createtime,expires=@expires where token=@token", Par);

            return(rev == 1);
        }
Пример #5
0
        public List <Models.DbModels.tb_token> GetByPage(XXF.Db.DbConn PubConn, int pno, int pagesize, string keywords, DbModels.TokenType tokentype, out int totalcount)
        {
            List <DbModels.tb_token> tokenlist = new List <DbModels.tb_token>();
            string basesql = "select {0} from " + tokentype.ToString() + " ";
            string whercon = "";

            XXF.Db.SimpleProcedureParameter para = new SimpleProcedureParameter();
            string querysql = string.Format(basesql, "ROW_NUMBER() over (order by createtime desc) as rownum, token,userid,id,username,appid,createtime,expires");

            if (!string.IsNullOrEmpty(keywords))
            {
                para.Add("@keywords", keywords);
                whercon = " where token=@keywords or userid like '%' + @keywords + '%' or username  like '%' + @keywords + '%' or appid  like '%' + @keywords + '%' ";
            }

            querysql = string.Concat("select A.* from (", querysql, whercon, ") A ", " where A.rownum between ", (pno - 1) * pagesize + 1, " and ", pagesize * pno);
            DataSet ds = new DataSet();

            PubConn.SqlToDataSet(ds, querysql, para.ToParameters());
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                tokenlist.Add(CreateModel(dr));
            }
            totalcount = (int)PubConn.ExecuteScalar(string.Format(basesql, " count(*) ") + whercon, para.ToParameters());
            return(tokenlist);
        }