Example #1
0
        public int AddApp(XXF.Db.DbConn PubConn, Models.DbModels.app model)
        {
            if (string.IsNullOrEmpty(model.appid))
            {
                model.appid = XXF.Db.LibString.MakeRandomNumber(16).ToLower();
            }
            if (ExitAppid(PubConn, model.appid))
            {
                return(-2);
            }
            if (string.IsNullOrEmpty(model.appsecret))
            {
                model.appsecret = Guid.NewGuid().ToString().Replace("-", "");
            }

            string sql = "insert into app(appid,appname,apptype,appgradeno,appsecret,appdesc,freeze) values(@appid,@appname,@apptype,@appgradeno,@appsecret,@appdesc,@freeze)";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@appid", model.appid);
            para.Add("@appsecret", model.appsecret);
            para.Add("@appname", model.appname);
            para.Add("@apptype", model.apptype);
            para.Add("@appgradeno", model.appgradeno);
            para.Add("@freeze", model.freeze);
            para.Add("@appdesc", model.appdesc ?? "");

            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #2
0
        public int DeletApp(XXF.Db.DbConn PubConn, string appid)
        {
            string sql = "delete from app where appid=@appid";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@appid", appid);
            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #3
0
        public int UpdateCategory(XXF.Db.DbConn PubConn, Models.DbModels.appcategory model)
        {
            model.categorydesc = model.categorydesc ?? "";
            string sql = "update  appcategory set categorytitle=@categorytitle,categorydesc=@categorydesc where  apptype=@apptype and categoryid=@categoryid";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", model.apptype);
            para.Add("@categoryid", model.categoryid);
            para.Add("@categorytitle", model.categorytitle);
            para.Add("@categorydesc", model.categorydesc);
            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #4
0
        public int UpdateGrade(XXF.Db.DbConn PubConn, Models.DbModels.appgrade model)
        {
            model.appgradedesc = model.appgradedesc ?? "";
            string sql = "update  appgrade set appgradename=@appgradename,appgradedesc=@appgradedesc where  apptype=@apptype and appgradeno=@appgradeno";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", model.apptype);
            para.Add("@appgradeno", model.appgradeno);
            para.Add("@appgradename", model.appgradename);
            para.Add("@appgradedesc", model.appgradedesc);
            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #5
0
        public int Addcategory(XXF.Db.DbConn PubConn, Models.DbModels.appcategory model)
        {
            model.categorydesc = model.categorydesc ?? "";
            string getcatid = "select isnull(max(categoryid),0)+1 from appcategory where apptype=" + model.apptype;

            model.categoryid = Convert.ToInt32(PubConn.ExecuteScalar(getcatid, null));
            string addsql = "insert into appcategory(apptype,categoryid,categorytitle,categorydesc) values(@apptype,@categoryid,@categorytitle,@categorydesc)";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", model.apptype);
            para.Add("@categoryid", model.categoryid);
            para.Add("@categorytitle", model.categorytitle);
            para.Add("@categorydesc", model.categorydesc);
            int r = PubConn.ExecuteSql(addsql, para.ToParameters());

            return(r);
        }
Example #6
0
        public int UpdateApp(XXF.Db.DbConn PubConn, Models.DbModels.app model)
        {
            string sql = "update app   set appname=@appname,appsecret=@appsecret,appdesc=@appdesc ,freeze=@freeze ,apptype = @apptype,appgradeno =@appgradeno where appid=@appid";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@appid", model.appid);
            para.Add("@appsecret", model.appsecret);
            para.Add("@appname", model.appname);
            para.Add("@apptype", model.apptype);
            para.Add("@appgradeno", model.appgradeno);
            para.Add("@freeze", model.freeze);
            para.Add("@appdesc", model.appdesc ?? "");

            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #7
0
        public int AddGrade(XXF.Db.DbConn PubConn, Models.DbModels.appgrade model)
        {
            model.appgradedesc = model.appgradedesc ?? "";
            string getcatid = "select isnull(max(appgradeno),0)+1 from appgrade where apptype=" + model.apptype;

            model.appgradeno = Convert.ToInt32(PubConn.ExecuteScalar(getcatid, null));
            string addsql = "insert into appgrade(apptype,appgradeno,appgradename,appgradedesc) values(@apptype,@appgradeno,@appgradename,@appgradedesc)";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", model.apptype);
            para.Add("@appgradeno", model.appgradeno);
            para.Add("@appgradename", model.appgradename);
            para.Add("@appgradedesc", model.appgradedesc);
            int r = PubConn.ExecuteSql(addsql, para.ToParameters());

            return(r);
        }
Example #8
0
        public int DeleteCategory(XXF.Db.DbConn PubConn, int apptype, int categoryid)
        {
            string countsql = "  select COUNT(*) from gradepermission where apptype=" + apptype + " and categoryid=" + categoryid + "";
            int    c        = (int)PubConn.ExecuteScalar(countsql, null);

            if (c != 0)
            {
                return(-2);
            }
            string sql = "delete from appcategory where  apptype=@apptype and categoryid=@categoryid";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", apptype);
            para.Add("@categoryid", categoryid);
            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #9
0
        public int DeleteGrade(XXF.Db.DbConn PubConn, int apptype, int appgradeno)
        {
            string countsql = "  select COUNT(*) from api where apptype=" + apptype + " and appgradeno=" + appgradeno + "";
            int    c        = (int)PubConn.ExecuteScalar(countsql, null);

            if (c != 0)
            {
                return(-2);
            }
            string sql = "delete from appgrade where  apptype=@apptype and appgradeno=@appgradeno";

            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@apptype", apptype);
            para.Add("@appgradeno", appgradeno);
            int r = PubConn.ExecuteSql(sql, para.ToParameters());

            return(r);
        }
Example #10
0
        public static void AddLog(XXF.Db.DbConn PubConn, DbModels.apilog log)
        {
            XXF.Db.SimpleProcedureParameter para = new XXF.Db.SimpleProcedureParameter();
            para.Add("@reqsource", log.reqsource);
            para.Add("@url", log.url);
            para.Add("@reqpara", log.reqpara);
            para.Add("@token", log.token);
            para.Add("@appid", log.appid);
            //    para.Add("@appname", log.appname);
            para.Add("@userid", log.userid);
            para.Add("@username", log.username);
            para.Add("@reqdate", log.reqdate);
            para.Add("@opecontent", log.opecontent);

            string sql = "INSERT INTO operationlog (reqsource  ,url  ,reqpara ,token ,appid ,appname,userid ,username ,reqdate ,opecontent)" +
                         "VALUES (@reqsource,@url, @reqpara,@token,@appid,@appname,@userid, @username,@reqdate,@opecontent)";

            PubConn.ExecuteSql(sql, para.ToParameters());
        }
Example #11
0
 private void WriteTestUserToDB()
 {
     using (XXF.Db.DbConn qxdbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "cert_test_main", "sa", "Xx~!@#"))
     {
         qxdbconn.Open();
         StringBuilder sb       = new StringBuilder();
         int           pagesize = 1000;
         int           i        = 0;
         while (i < willtestusers.Count)
         {
             sb.Clear();
             for (int j = 0; j < pagesize && i < willtestusers.Count; j++)
             {
                 sb.AppendFormat("insert into testuser(f_yhzh) values('{0}');\r\n", willtestusers[i]);
                 i++;
             }
             qxdbconn.ExecuteSql(sb.ToString(), null);
         }
     }
 }
Example #12
0
        private void Do()
        {
            using (XXF.Db.DbConn pubconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "cert_test_main", "sa", "Xx~!@#"))
            {
                pubconn.Open();
                long          curr_uid = start_userid;
                StringBuilder sb       = new StringBuilder();
                while (currcount < count)
                {
                    sb.Clear();
                    for (int i = 0; i < 1000; i++)
                    {
                        sb.AppendFormat("insert into tb_customer(f_yhzh,f_yhxm,f_dlmm,f_sfdj) values('{0}','{1}','{2}',0);\r\n", curr_uid, "yhm_" + curr_uid, pwd);

                        curr_uid++;
                        currcount++;
                    }
                    pubconn.ExecuteSql(sb.ToString(), null);
                }
            }
        }
Example #13
0
        private void Init(object obj)
        {
            int[] para = obj == null ? new int[] { 1, 1 } : (int[])obj;
            using (XXF.Db.DbConn dbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "cert_test_main", "sa", "Xx~!@#"))
                using (XXF.Db.DbConn qxdbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "dyd_new_qx", "sa", "Xx~!@#"))
                {
                    dbconn.Open();
                    qxdbconn.Open();
                    int allcount = 1200000;// (int)dbconn.ExecuteScalar(sql_count, null);

                    int threadsizecount = (int)Math.Ceiling(allcount / (double)para[1]);

                    int pagesize = 200;

                    int start = (para[0]) * threadsizecount;
                    int end   = (para[0] + 1) * threadsizecount;

                    StringBuilder sb = new StringBuilder();
                    for (int i = start; i < end; i = i + pagesize)
                    {
                        sb.Clear();
                        string    sql = "select top " + pagesize + " * from (select row_number() over(order by f_id) as Rownum,* from tb_customer ) A where A.Rownum between " + (i + 1) + " and " + (end) + "";
                        DataTable tb  = dbconn.SqlToDataTable(sql, null);
                        foreach (DataRow dr in tb.Rows)
                        {
                            count_me[para[0]]++;
                            string pwd   = dr["f_dlmm"].ToString();
                            string yhzh  = dr["f_yhzh"].ToString();
                            string id    = dr["f_id"].ToString();
                            string yhxm  = dr["f_yhxm"].ToString();
                            string token = Guid.NewGuid().ToString().Replace("-", "");
                            sb.AppendFormat("insert into usertoken (token,userid,id,username,appid,createtime,expires) " +
                                            "  values('{0}','{1}','{2}','{3}','Customer','2015-07-01','2015-08-31');\r\n", token, yhzh, id, yhxm);
                        }
                        qxdbconn.ExecuteSql(sb.ToString(), null);
                    }
                }
        }