Beispiel #1
0
 public JsonResult DeleteApp(string id)
 {
     if (string.IsNullOrEmpty(id))
     {
         return(Json(new { code = -1, msg = "appid为能为空。" }));
     }
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         try
         {
             int r = Models.AppDal.Instance.DeletApp(PubConn, id);
             if (r == 0)
             {
                 return(Json(new { code = -1, msg = "appid [" + id + "]不存在或已被删除" }));
             }
             return(Json(new { code = 1 }));
         }
         finally
         {
             Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
             log.opecontent = "删除应用。";
             Models.CertCenterLogDal.Instance.Add(PubConn, log);
         }
     }
 }
Beispiel #2
0
        public JsonResult Delete(int apptype, int categoryid)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();

                int r = Models.AppcategoryDal.Instance.DeleteCategory(PubConn, apptype, categoryid);
                Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                log.opecontent = "删除应用分类,操作结果:" + r;
                Models.CertCenterLogDal.Instance.Add(PubConn, log);
                if (r > 0)
                {
                    return(Json(new { code = 1 }));
                }
                else
                {
                    if (r == -2)
                    {
                        return(Json(new { code = -2, msg = "此分类下存在接口,无法删除。" }));
                    }
                    else
                    {
                        return(Json(new { code = -1, msg = "删除失败,不存在或已被删除" }));
                    }
                }
            }
        }
Beispiel #3
0
        public JsonResult GetAppGradeData(string id, string lv, string n)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                List <Models.Z_TreeModel> ztree = new List <Models.Z_TreeModel>();
                PubConn.Open();

                for (int i = 0; i <= 2; i++)
                {
                    Models.Z_TreeModel tempnode = new Models.Z_TreeModel();
                    tempnode.name     = Models.CertCenterComm.APPTYPENAME[i];
                    tempnode.iconSkin = "";
                    tempnode.open     = "true";
                    tempnode.id       = i.ToString();
                    List <Models.DbModels.appgrade> tempgrade = Models.AppGradeDal.Instance.GetGrades(PubConn, i);
                    tempnode.children = new List <Models.Z_TreeModel>();
                    foreach (var a in tempgrade)
                    {
                        tempnode.children.Add(new Models.Z_TreeModel()
                        {
                            id = i + "_" + a.appgradeno.ToString(), name = a.appgradename
                        });
                    }
                    tempnode.isParent = tempnode.children.Count == 0 ? "false" : "true";
                    ztree.Add(tempnode);
                }
                return(Json(ztree));
            }
        }
Beispiel #4
0
        public JsonResult GetApiCategoryData(string id, string lv, string n)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                List <Models.Z_TreeModel> ztree = new List <Models.Z_TreeModel>();
                PubConn.Open();

                for (int i = 0; i <= 2; i++)
                {
                    Models.Z_TreeModel tempnode = new Models.Z_TreeModel();
                    tempnode.name     = Models.CertCenterComm.APPTYPENAME[i];
                    tempnode.iconSkin = "";
                    tempnode.id       = i.ToString();
                    tempnode.open     = "true";
                    List <Models.DbModels.appcategory> tempgrade = Models.AppcategoryDal.Instance.GetAppTypeCategorys(PubConn, i);
                    tempnode.children = new List <Models.Z_TreeModel>();
                    foreach (var a in tempgrade)
                    {
                        tempnode.children.Add(new Models.Z_TreeModel()
                        {
                            id = i + "_" + a.categoryid.ToString(), name = a.categorytitle
                        });
                    }
                    tempnode.isParent = tempnode.children.Count == 0 ? "false" : "true";
                    ztree.Add(tempnode);
                }
                //Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                //log.opecontent = "得到分类数据据";
                //Models.CertCenterLogDal.Instance.Add(PubConn, log);
                return(Json(ztree));
            }
        }
Beispiel #5
0
 public ActionResult GetApiList(int apptype = 0, int categoryid = 1)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         List <Models.DbModels.api> listapi = Models.ApiDal.Instance.GetCategoryApis(PubConn, apptype, categoryid);
         return(Json(new { code = 1, response = listapi }));
     }
 }
Beispiel #6
0
 public JsonResult UseApptypeGetcategories(int apptype)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         List <Models.DbModels.appcategory> grades = Models.AppcategoryDal.Instance.GetAppTypeCategorys(PubConn, apptype);
         return(Json(new { code = 1, response = grades }));
     }
 }
Beispiel #7
0
 public JsonResult GetAppGradeInfo(int apptype, int appgradeno)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         Models.DbModels.appgrade model = Models.AppGradeDal.Instance.GetGradeInfo(PubConn, apptype, appgradeno);
         if (model == null)
         {
             return(Json(new { code = -1, msg = "不存在此等级信息。" }));
         }
         return(Json(new { code = 1, response = model }));
     }
 }
Beispiel #8
0
 public JsonResult apidetails(int id)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         Models.DbModels.api model = Models.ApiDal.Instance.Get(PubConn, id);
         if (model == null)
         {
             return(Json(new { code = -1, msg = "不存在编号为 [" + id + "] 的接口。" }));
         }
         return(Json(new { code = 1, response = model }));
     }
 }
Beispiel #9
0
        //
        // GET: /Api/

        public ActionResult Index()
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();
                Dictionary <string, List <Models.DbModels.appcategory> > apis = new Dictionary <string, List <Models.DbModels.appcategory> >();
                for (int i = 0; i <= 2; i++)
                {
                    List <Models.DbModels.appcategory> tempcategory = Models.AppcategoryDal.Instance.GetAppTypeCategorys(PubConn, i);
                    apis.Add(Models.CertCenterComm.APPTYPENAME[i], tempcategory);
                }
                return(View(apis));
            }
        }
Beispiel #10
0
 public JsonResult Edit(Models.DbModels.appcategory model)
 {
     if (string.IsNullOrEmpty(model.categorytitle))
     {
         return(Json(new { code = -1, msg = "分类名称不能为空" }));
     }
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         try
         {
             if (model.categoryid < 1)//添加
             {
                 int r = Models.AppcategoryDal.Instance.Addcategory(PubConn, model);
                 if (r > 0)
                 {
                     return(Json(new { code = 1, response = model }));
                 }
                 else
                 {
                     return(Json(new { code = -1, msg = "新增失败,原因不明" }));
                 }
             }
             else//修改
             {
                 int r = Models.AppcategoryDal.Instance.UpdateCategory(PubConn, model);
                 if (r > 0)
                 {
                     return(Json(new { code = 1, response = model }));
                 }
                 else
                 {
                     return(Json(new { code = -1, msg = "修改失败,原因不明" }));
                 }
             }
         }
         catch (Exception ex)
         {
             return(Json(new { code = -1, msg = ex.Message }));
         }
         finally
         {
             Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
             log.opecontent = "修改应用分类";
             Models.CertCenterLogDal.Instance.Add(PubConn, log);
         }
     }
 }
Beispiel #11
0
 public JsonResult deleteapi(int id)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         bool r = Models.ApiDal.Instance.Delete(PubConn, id);
         Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
         log.opecontent = "删除接口,操作结果:" + r;
         Models.CertCenterLogDal.Instance.Add(PubConn, log);
         if (r)
         {
             return(Json(new { code = 1 }));
         }
         return(Json(new { code = -1, msg = "不存在编号为 [" + id + "] 的接口或已被删除。" }));
     }
 }
Beispiel #12
0
        //
        // GET: /WorkLog/

        public ActionResult Index(int pno = 1, string keywords = "")
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();
                int pagesize   = 10;
                int totalcount = 0;
                List <Models.DbModels.certcenterlog> listtoken = Models.CertCenterLogDal.Instance.GetPage(PubConn, pno, pagesize, keywords, out totalcount);
                Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.certcenterlog> pager = new Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.certcenterlog>(listtoken, pno, pagesize, totalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("List", pager));
                }
                return(View(pager));
            }
        }
Beispiel #13
0
        //
        // GET: /Toekn/

        public ActionResult Index(int pno = 1, string keywords = "", Models.DbModels.TokenType tokentype = Models.DbModels.TokenType.usertoken)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();
                int pagesize   = 10;
                int totalcount = 0;
                List <Models.DbModels.tb_token> listtoken = Models.TokenDal.Instance.GetByPage(PubConn, pno, pagesize, keywords, tokentype, out totalcount);
                Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.tb_token> pager = new Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.tb_token>(listtoken, pno, pagesize, totalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("List", pager));
                }
                return(View(pager));
            }
        }
Beispiel #14
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~!@#"))
            {
                dbconn.Open();
                string sql_count = "select count(1) from tb_customer";
                int    allcount  = 40000;// (int)dbconn.ExecuteScalar(sql_count, null);

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

                int pagesize = 1000;

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

                for (int i = start; i < end; i = i + pagesize)
                {
                    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();
                        try
                        {
                            pwd = XXF.Db.LibCrypto.DeDES(pwd);
                        }
                        catch (Exception ex)
                        {
                        }
                        var token = sp.Login(dr["f_yhzh"].ToString(), pwd);
                        if (token != null)
                        {
                            lock (tokens)
                                tokens.Add(token);
                            Console.WriteLine(token.token);
                        }
                        else
                        {
                            Console.WriteLine("error");
                        }
                    }
                }
            }
        }
Beispiel #15
0
        //
        // GET: /App/

        public ActionResult Index(int pno = 1, string keywords = "")
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();
                int pagesize   = 10;
                int totalcount = 10;
                pno = pno < 1 ? 1 : pno;
                List <Models.DbModels.app> listapp = Models.AppDal.Instance.GetList(PubConn, pno, pagesize, keywords, out totalcount);
                Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.app> pager = new Webdiyer.WebControls.Mvc.PagedList <Models.DbModels.app>(listapp, pno, pagesize, totalcount);
                if (Request.IsAjaxRequest())
                {
                    return(PartialView("List", pager));
                }
                return(View(pager));
            }
        }
Beispiel #16
0
        public ActionResult GetAppSecret(Controller controller)
        {
            JsonResult jsonr = new JsonResult();

            jsonr.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            CertComm.ServerResult r = new CertComm.ServerResult();
            jsonr.Data = r;
            string appid = controller.Request["appid"];

            if (string.IsNullOrEmpty(appid))
            {
                r.code = -3;
                r.msg  = "请求参数appid不能为空";
                return(jsonr);
            }
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();//打开基本
                bool ex = CertCenter.Models.AppDal.Instance.ExitAppid(PubConn, appid);
                if (!ex)
                {
                    r.code = -1;
                    r.msg  = "appid不存在";
                    return(jsonr);
                }

                CertCenter.Models.DbModels.app app = CertCenter.Models.AppDal.Instance.GetAppInfo(PubConn, appid);
                if (app == null)
                {
                    r.code = -1;
                    r.msg  = "appid不存在";
                    return(jsonr);
                }
                else
                {
                    r.code     = 1;
                    r.msg      = "OK";
                    r.response = app.appsecret;
                    return(jsonr);
                }
            }

            return(jsonr);
        }
Beispiel #17
0
        public JsonResult edit(Models.DbModels.api model)
        {
            if (string.IsNullOrEmpty(model.apititle))
            {
                return(Json(new { code = -1, msg = "请输入接口标题" }));
            }
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();

                Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                try
                {
                    if (model.apiid == 0)
                    {
                        if (Models.ApiDal.Instance.Add(PubConn, model))
                        {
                            model.apiid = PubConn.GetIdentity();
                            return(Json(new { code = 1, response = model }));
                        }
                        else
                        {
                            return(Json(new { code = -1, msg = "添加失败" }));
                        }
                    }
                    else
                    {
                        if (Models.ApiDal.Instance.Edit(PubConn, model))
                        {
                            return(Json(new { code = 1, response = model }));
                        }
                        else
                        {
                            return(Json(new { code = -1, msg = "修改失败" }));
                        }
                    }
                }
                finally
                {
                    log.opecontent = "修改接口";
                    Models.CertCenterLogDal.Instance.Add(PubConn, log);
                }
            }
        }
Beispiel #18
0
 public JsonResult DeleteLog(int id)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         bool r = Models.CertCenterLogDal.Instance.Delete(PubConn, id);
         Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
         log.opecontent = "删除操作日志。结果:" + r;
         Models.CertCenterLogDal.Instance.Add(PubConn, log);
         if (r)
         {
             return(Json(new { code = 1 }));
         }
         else
         {
             return(Json(new { code = -1, msg = "删除失败,日志不存在或存已被删除。" }));
         }
     }
 }
Beispiel #19
0
 public ActionResult Edit(string id)
 {
     using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
     {
         PubConn.Open();
         if (string.IsNullOrEmpty(id))
         {
             ViewBag.appgrades = Models.AppGradeDal.Instance.GetGrades(PubConn, 0);
             return(View());
         }
         else
         {
             ViewBag.act = "edit";
             Models.DbModels.app model = Models.AppDal.Instance.GetAppInfo(PubConn, id);
             ViewBag.appgrades = Models.AppGradeDal.Instance.GetGrades(PubConn, model.apptype);
             return(View(model));
         }
     }
 }
Beispiel #20
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);
         }
     }
 }
Beispiel #21
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);
                }
            }
        }
Beispiel #22
0
        public JsonResult GetApiCategoryInfo(int apptype, int categoryid)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();

                Models.DbModels.appcategory model = Models.AppcategoryDal.Instance.GetCategoryInfo(PubConn, apptype, categoryid);

                if (model == null)
                {
                    return(Json(new CertComm.ServerResult()
                    {
                        code = -1, msg = "无查项"
                    }));
                }
                return(Json(new CertComm.ServerResult()
                {
                    code = 1, msg = "", response = model
                }));
            }
        }
Beispiel #23
0
        public JsonResult deletetoken(string id, Models.DbModels.TokenType tokentype)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();

                bool r = Models.TokenDal.Instance.Delete(PubConn, id, tokentype);

                Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                log.opecontent = "删除token。tokentype=" + tokentype.ToString() + " result=" + r;
                Models.CertCenterLogDal.Instance.Add(PubConn, log);
                if (r)
                {
                    return(Json(new { code = 1 }));
                }
                else
                {
                    return(Json(new { code = -905, msg = "删除失败,token不存在或存已被删除。" }));
                }
            }
        }
Beispiel #24
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);
                    }
                }
        }
Beispiel #25
0
 public ActionResult Login(string appid, string returnurl)
 {
     if (!string.IsNullOrEmpty(appid))
     {
         using (XXF.Db.DbConn pubconn = XXF.Db.DbConfig.CreateConn())
         {
             pubconn.Open();
             string constr = CertCenter.Areas.CertApi.Models.ApiCommDal.GetConnStr(Models.DbModels.TokenType.managetoken);
             if (!string.IsNullOrEmpty(appid))
             {
                 CertCenter.Models.DbModels.app app = CertCenter.Models.AppDal.Instance.GetAppInfo(pubconn, appid);
                 if (app == null)
                 {
                     ViewBag.msg = "应用不存在";
                 }
                 else
                 {
                     ViewBag.appname = app.appname;
                 }
             }
         }
     }
     return(View());
 }
Beispiel #26
0
        public ActionResult Edit(Models.DbModels.app model, string act)
        {
            using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
            {
                PubConn.Open();
                ViewBag.appgrades = Models.AppGradeDal.Instance.GetGrades(PubConn, model.apptype);
                ViewBag.act       = act;
                if (string.IsNullOrEmpty(model.appname))
                {
                    ModelState.AddModelError("appname", "应用名不能为空。");
                    return(View(model));
                }
                if (model.appgradeno <= 0)
                {
                    ModelState.AddModelError("appgradeno", "请选择应用级别。");
                    return(View(model));
                }

                try
                {
                    if (string.IsNullOrEmpty(model.appid))
                    {
                        model.appid = XXF.Db.LibString.MakeRandomNumber(16);
                    }
                    if (string.IsNullOrEmpty(model.appsecret))
                    {
                        model.appsecret = Guid.NewGuid().ToString().Replace("-", "");
                    }
                    if (act == "edit")
                    {
                        int r = Models.AppDal.Instance.UpdateApp(PubConn, model);
                        if (r > 0)
                        {
                            return(RedirectToAction("index"));
                        }
                        else
                        {
                            ViewBag.act = "edit";
                            return(View(model));
                        }
                    }
                    else
                    {
                        int r = Models.AppDal.Instance.AddApp(PubConn, model);
                        if (r > 0)
                        {
                            return(RedirectToAction("index"));
                        }
                        else
                        {
                            if (r == -1)
                            {
                                ModelState.AddModelError("appid", "appid已存在,请更换");
                            }
                            return(View(model));
                        }
                    }
                }
                catch (Exception ex)
                {
                    ModelState.AddModelError("", ex.Message);
                    return(View(model));
                }
                finally
                {
                    Models.DbModels.certcenterlog log = new Models.DbModels.certcenterlog(this);
                    log.opecontent = "修改应用";
                    Models.CertCenterLogDal.Instance.Add(PubConn, log);
                }
            }
        }
Beispiel #27
0
        public ActionResult Login(string userid, string pwd, string returnurl, string appid)
        {
            XXF.Db.DbConn pubconn = null;
            XXF.Db.DbConn dbconn  = null;
            try
            {
                pubconn = XXF.Db.DbConfig.CreateConn();
                pubconn.Open();
                ViewBag.userid = userid;
                ViewBag.pwd    = pwd;
                string constr = CertCenter.Areas.CertApi.Models.ApiCommDal.GetConnStr(Models.DbModels.TokenType.managetoken);
                if (!string.IsNullOrEmpty(appid))
                {
                    CertCenter.Models.DbModels.app app = CertCenter.Models.AppDal.Instance.GetAppInfo(pubconn, appid);
                    if (app == null)
                    {
                        ViewBag.msg = "应用不存在";
                        return(View());
                    }
                }

                dbconn = XXF.Db.DbConfig.CreateConn(constr);
                dbconn.Open();
                Models.DbModels.manage model = Models.AccountDal.Instance.getManage(dbconn, userid);
                if (model == null)
                {
                    ViewBag.msg = "用户名不存在";
                    return(View());
                }
                if (model.freeze == 1)
                {
                    ViewBag.msg = "用户已被冻结";
                    return(View());
                }
                if (pwd != model.pwd)
                {
                    ViewBag.msg = "密码不正确";
                    return(View());
                }
                //if (string.IsNullOrEmpty(appid))
                //{

                FormsAuthentication.SetAuthCookie(userid + " " + model.username, false);
                return(RedirectToAction("Index", "Home"));
                //}
                //else
                //{
                //    if (returnurl.Contains("?")&&returnurl.Contains("&"))
                //    {
                //        returnurl = returnurl + "&token="+;
                //    }
                //    return Redirect(returnurl);
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (pubconn != null)
                {
                    pubconn.Dispose();
                }
                if (dbconn != null)
                {
                    dbconn.Dispose();
                }
            }
        }
Beispiel #28
0
        private void PrepareTokens(int allcount)
        {
            Console.WriteLine("正在准备内存token...");
            Thread mainthrad = new Thread(() =>
            {
                using (XXF.Db.DbConn qxdbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "dyd_new_qx", "sa", "Xx~!@#"))
                {
                    qxdbconn.Open();


                    // int allcount = 999000;// (int)dbconn.ExecuteScalar(sql_count, null);

                    int pagesize = 200000;

                    StringBuilder sb = new StringBuilder();
                    int i            = 0;
                    while (true)
                    {
                        sb.Clear();
                        string sql   = "select  * from (select row_number() over(order by token) as Rownum,* from usertoken ) A where A.Rownum between " + (i + 1) + " and " + (i + pagesize) + "";
                        DataTable tb = qxdbconn.SqlToDataTable(sql, null);
                        foreach (DataRow dr in tb.Rows)
                        {
                            sp.Add(new CertSdk.Token()
                            {
                                appid      = dr["appid"].ToString(),
                                createtime = XXF.Db.LibConvert.ObjToDateTime(dr["createtime"]),
                                expires    = XXF.Db.LibConvert.ObjToDateTime(dr["expires"]),
                                id         = dr["id"].ToString(),
                                token      = dr["token"].ToString(),
                                userid     = dr["userid"].ToString(),
                                username   = dr["username"].ToString()
                            });
                            _PrepareTokens_count++;
                            if (_PrepareTokens_count >= allcount)
                            {
                                break;
                            }
                        }
                        if (_PrepareTokens_count >= allcount)
                        {
                            break;
                        }
                    }
                }
            });
            Thread m = new Thread(() =>
            {
                while (true)
                {
                    Thread.Sleep(3000);
                    Console.WriteLine("当前准备token总数={0}", _PrepareTokens_count);
                    if (mainthrad.ThreadState == System.Threading.ThreadState.Stopped)
                    {
                        return;
                    }
                }
            });

            mainthrad.Start();
            m.Start();
            m.Join();

            Console.WriteLine("准备内存token完成!");
        }
Beispiel #29
0
        private void GetTestUsers(int count)
        {
            Console.WriteLine("正在准备登录用户...");
            Thread maint = new Thread(() =>
            {
                using (XXF.Db.DbConn qxdbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "cert_test_main", "sa", "Xx~!@#"))
                {
                    qxdbconn.Open();
                    int allcount = (int)qxdbconn.ExecuteScalar("select count(1) from testuser", null);
                    if (allcount >= count)
                    {
                        string sql   = "select top " + count + " * from testuser";
                        DataTable tb = qxdbconn.SqlToDataTable(sql, null);
                        foreach (DataRow dr in tb.Rows)
                        {
                            willtestusers.Add(dr["f_yhzh"].ToString());
                            _GetTestUsers_count++;
                        }
                        return;
                    }
                }

                int pagesize = 50;
                using (XXF.Db.DbConn qxdbconn = XXF.Db.DbConn.CreateConn(XXF.Db.DbType.SQLSERVER, "192.168.17.236", "cert_test_main", "sa", "Xx~!@#"))
                {
                    qxdbconn.Open();
                    int allcount = (int)qxdbconn.ExecuteScalar("select count(1) from tb_customer", null);
                    for (int i = 0; i < count; i = i + pagesize)
                    {
                        Random r        = new Random();
                        int start_index = r.Next(1, allcount - pagesize);
                        string sql      = "select top " + pagesize + " A.f_yhzh from (select row_number() over(order by f_id) as Rownum,f_yhzh from tb_customer ) A where A.Rownum >=" + start_index + "";
                        DataTable tb    = qxdbconn.SqlToDataTable(sql, null);
                        foreach (DataRow dr in tb.Rows)
                        {
                            willtestusers.Add(dr["f_yhzh"].ToString());
                            _GetTestUsers_count++;
                        }
                    }
                }
                WriteTestUserToDB();
            });
            Thread m = new Thread(() =>
            {
                while (true)
                {
                    Thread.Sleep(3000);
                    Console.WriteLine("当前准备测试用户总数={0}", _GetTestUsers_count);
                    if (maint.ThreadState == System.Threading.ThreadState.Stopped)
                    {
                        return;
                    }
                }
            });

            maint.Start();
            m.Start();
            m.Join();

            Console.WriteLine("准备登录用户完成!");
        }
Beispiel #30
0
        public static JsonResult Visit(Func <XXF.Db.DbConn, object> action, Controller controller)
        {
            //msgs.Add(-100, "认证失败");
            //msgs.Add(-905, "token不存在或已过期");
            //msgs.Add(-102, "请求超时");
            //msgs.Add(-103, "	sign不正确");
            //msgs.Add(-104, "无权操作该接口");
            //msgs.Add(-105, "接口已被冻结");
            //msgs.Add(-106, "应用被冻结");

            //msgs.Add(-111, "参数不完整");
            //msgs.Add(-112, "用户不存在");
            //msgs.Add(-113, "pwd不正确");
            //msgs.Add(-114, "用户被冻结");

            CertComm.ServerResult       sr   = new CertComm.ServerResult();
            Dictionary <string, string> para = GetRequestPara(controller);

            if (para.ContainsKey("appid") && string.IsNullOrEmpty(para["appid"]))
            {
                sr.code = -111;
                sr.msg  = "appid不能为空";
            }
            else if (para.ContainsKey("timespan") && string.IsNullOrEmpty(para["timespan"]))
            {
                sr.code = -111;
                sr.msg  = "timespan不能为空";
            }
            else if (para.ContainsKey("sign") && string.IsNullOrEmpty(para["sign"]))
            {
                sr.code = -111;
                sr.msg  = "sign不能为空";
            }
            else if (para.ContainsKey("userid") && string.IsNullOrEmpty(para["userid"]))
            {
                sr.code = -111;
                sr.msg  = "userid不能为空";
            }
            else if (para.ContainsKey("pwd") && string.IsNullOrEmpty(para["pwd"]))
            {
                sr.code = -111;
                sr.msg  = "pwd不能为空";
            }
            else
            {
                if (!CertComm.Authcomm.TestTimeSpanOk(para["timespan"], 10 * 60))
                {
                    sr.code = -102;
                    sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                }
                else
                {
                    using (XXF.Db.DbConn PubConn = XXF.Db.DbConfig.CreateConn())
                    {
                        PubConn.Open();
                        Models.DbModels.app appitem = Models.AppDal.Instance.GetAppInfo(PubConn, para["appid"]);
                        if (appitem == null)
                        {
                            sr.code = -103;
                            sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                        }
                        else if (appitem.freeze == 1)
                        {
                            sr.code = -107;
                            sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                        }
                        else
                        {
                            string nowsign = CertComm.Authcomm.ToSign(para, appitem.appsecret);
                            if (nowsign.ToLower() != para["sign"].ToLower())
                            {
                                sr.code = -104;
                                sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                            }
                            else//用户相关验证
                            {
                                Models.DbModels.manage manager = Models.AccountDal.Instance.getManage(PubConn, para["userid"]);
                                if (manager == null)
                                {
                                    sr.code = -112;
                                    sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                                }
                                else if (manager.freeze == 1)
                                {
                                    sr.code = -114;
                                    sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                                }
                                else if (CertComm.Authcomm.ToMD5String(manager.pwd) != para["pwd"])
                                {
                                    sr.code = -113;
                                    sr.msg  = AUTH_CODE_MSG.Get(sr.code);
                                }
                            }
                        }
                    }
                }
            }
            if (sr.code < -100)
            {
                return(new JsonResult()
                {
                    Data = sr
                });
            }
            return(null);
        }