From 3a6cc97a72a22159182696db2dfece2caae6a4b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=BA=20=E6=9D=A8?= Date: Thu, 28 Mar 2024 10:52:05 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E9=A1=B5=E9=94=9A=E5=AE=9A?= =?UTF-8?q?=E7=82=B9=E4=BC=98=E5=8C=96=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App_Code/MysqlDBHelper.cs | 91 +++++++++++++++++++++++++++++++++++++++ Temp/Default.aspx | 59 ++++++++++++------------- Temp/Default.aspx.cs | 52 ++++++++++++---------- css/default.css | 27 ++++++++++-- js/index.js | 20 ++++++--- 5 files changed, 186 insertions(+), 63 deletions(-) create mode 100644 App_Code/MysqlDBHelper.cs diff --git a/App_Code/MysqlDBHelper.cs b/App_Code/MysqlDBHelper.cs new file mode 100644 index 0000000..e897ea5 --- /dev/null +++ b/App_Code/MysqlDBHelper.cs @@ -0,0 +1,91 @@ +using Dapper; +using MySql.Data.MySqlClient; +using System.Data; +using System.Data.SqlClient; + + +/// +/// 数据库操作类 需要nuget 安装 Dapper 和 MySql.Data +/// +public class MysqlDBHelper +{ + // todo 生产环境切换数据库地址 +//#if DEBUG + private const string _basicConnectionStr = + "Server=192.168.2.9;Port=3306;Database=marking_basic;Uid=root;Pwd=qwe123!@#;MinimumPoolSize=1;MaximumPoolSize=100;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=True;"; +//#else +// private const string _basicConnectionStr = +// "Server=mk-rds.23544.com;Port=33306;Database=marking_basic;Uid=marking;Pwd=poiuytPOIUYT098765)(*&^%;MinimumPoolSize=1;MaximumPoolSize=100;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=True;"; +//#endif + + + private string _tenantConnectionStr; + + public MysqlDBHelper(long tenantCode) + { + if (tenantCode <= 0) + { + throw new System.ArgumentNullException("tenantCode"); + } + _tenantConnectionStr = GetTenantConnectionString(tenantCode); + } + + private string GetTenantConnectionString(long tenantCode) + { + using (IDbConnection connection = new MySqlConnection(_basicConnectionStr)) + { + var tenant = connection.QueryFirst("select * from tenant where tenant_code=" + tenantCode); + return "Server=" + tenant.ip_addr + ";Port=" + tenant.port + ";Database=" + tenant.database + ";Uid=" + tenant.dbuser + ";Pwd=" + tenant.password + ";MinimumPoolSize=1;MaximumPoolSize=100;CharSet=utf8mb4;AllowLoadLocalInfile=true;AllowUserVariables=True;"; + } + } + + public DataTable ExecuteQuery(string sql) + { + DataTable dt = new DataTable(); + using (IDbConnection connection = new MySqlConnection(_tenantConnectionStr)) + { + using (var reader = connection.ExecuteReader(sql)) + { + dt.Load(reader); + } + } + return dt; + } + + public object ExecuteScalar(string sql) + { + using (IDbConnection connection = new MySqlConnection(_tenantConnectionStr)) + { + return connection.ExecuteScalar(sql); + } + } + + public int ExecuteNoQuery(string sql) + { + using (IDbConnection connection = new MySqlConnection(_tenantConnectionStr)) + { + return connection.Execute(sql); + } + } + + public int ExecuteNoQuery(string sql, params MySqlParameter[] sp) + { + using (MySqlConnection connection = new MySqlConnection(_tenantConnectionStr)) + { + connection.Open(); + using (MySqlCommand cmd = new MySqlCommand(sql, connection)) + { + cmd.CommandType = CommandType.Text; + + if (sp != null && sp.Length > 0) + { + cmd.Parameters.AddRange(sp); + } + + return cmd.ExecuteNonQuery(); + } + } + } +} + + diff --git a/Temp/Default.aspx b/Temp/Default.aspx index a54dcbc..68aacad 100644 --- a/Temp/Default.aspx +++ b/Temp/Default.aspx @@ -8,18 +8,18 @@ 导入外部答题卡制作模板 - <%-- 禁用浏览器缓存 --%> + <%-- 禁用浏览器缓存 --%> diff --git a/Temp/Default.aspx.cs b/Temp/Default.aspx.cs index e6f6d85..a81330f 100644 --- a/Temp/Default.aspx.cs +++ b/Temp/Default.aspx.cs @@ -57,7 +57,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page case 1: UpdateTempData(); break; - // 锁定 + // 锁定 case 2: LockTemp(); break; @@ -337,7 +337,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page Image currentFramext = new Image(PictureBoxBitMap); Image myImage = new Image(commonUse.FilterRed(PictureBoxBitMap)); - + // 进行中值滤波 CvInvoke.MedianBlur(myImage, myImage, 5); // 进行高斯滤波 @@ -368,7 +368,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page //VectorOfVectorOfPoint selected_contours1; //selected_contours1 = commonUse.GetUsefulContoursDingWei(mat_dilate1, 1); string message = string.Empty; - Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(currentFramext.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv,out message); + Mat color_mxxx = commonUse.GetPostionXYByFindPostionAndXieLv(currentFramext.Mat, selected_contours1, GetData[0], out PYPostionList, currentFramext, out xielv, out message); if (xielv == -100) { Response.Write(message); @@ -515,7 +515,7 @@ public partial class 外部答题卡_Default : System.Web.UI.Page int wL = Convert.ToInt32(W / xuanXiang); int hL = Convert.ToInt32(H / tiliang); - + Image bytimg = GetMatCutImg(color_mat.Bitmap, X, Y, W, H); //Bitmap bmp = ScaleToSize(tempImage.Bitmap, tempImage.Bitmap.Width * 4, tempImage.Bitmap.Height * 4, groupNo); @@ -1075,28 +1075,34 @@ public partial class 外部答题卡_Default : System.Web.UI.Page } if (GetData[8] != "") { - string[] list = GetData[8].Split(','); - Xleft = Convert.ToDouble(list[0]); - Xtop = Convert.ToDouble(list[1]); - Xwidth = Convert.ToDouble(list[2]); - Xheight = Convert.ToDouble(list[3]); - if (Xleft < pyLeft) - { - return "批阅分数编辑框左边超过定位点边界!"; + string[] datipiyue = GetData[8].Split('^'); - } - if (Xleft + Xwidth - pyLeft > oldWidth) + foreach (string slist in datipiyue) { - return "批阅分数编辑框编辑框右边超过定位点边界!"; - } - if (Xtop < pyTop) - { - return "批阅分数编辑框编辑框上边超过定位点边界!"; - } + string[] list = slist.Split(','); + Xleft = Convert.ToDouble(list[0]); + Xtop = Convert.ToDouble(list[1]); + Xwidth = Convert.ToDouble(list[2]); + Xheight = Convert.ToDouble(list[3]); + string tihao = list[4]; + if (Xleft < pyLeft) + { + return "题号:[" + tihao + "]批阅分数编辑框左边超过定位点边界!"; - if (Xtop + Xheight - pyTop > oldHeight) - { - return "批阅分数编辑框编辑框下边超过定位点边界!"; + } + if (Xleft + Xwidth - pyLeft > oldWidth) + { + return "题号:[" + tihao + "]批阅分数编辑框右边超过定位点边界!"; + } + if (Xtop < pyTop) + { + return "题号:[" + tihao + "]批阅分数编辑框上边超过定位点边界!"; + } + + if (Xtop + Xheight - pyTop > oldHeight) + { + return "题号:[" + tihao + "]批阅分数编辑框下边超过定位点边界!"; + } } } if (HideAreaPostionList != "") diff --git a/css/default.css b/css/default.css index 868968a..7b3a292 100644 --- a/css/default.css +++ b/css/default.css @@ -1,10 +1,29 @@ - +/*// 滚动条宽度*/ +::-webkit-scrollbar { + width: 8px; +} + +/*// 滚动条轨道*/ +::-webkit-scrollbar-track { + background: rgb(239, 239, 239); + border-radius: 2px; +} + +/*// 小滑块*/ +::-webkit-scrollbar-thumb { + background: #044775; + border-radius: 10px; +} + +::-webkit-scrollbar-thumb:hover { + background: #40a0ff; +} body {height: 100%; overflow-x:hidden;font-family:'Microsoft YaHei UI'; } -::-webkit-scrollbar { +/*::-webkit-scrollbar { width: 0; height: 0; -} +}*/ ul { text-decoration:none; list-style-type:none; } img { max-width: 100%;} a, abbr, address, b, blockquote, body, caption, cite, code, dd, del, dfn, div, dl, dt, em, fieldset, form, h1, h2, h3, h4, h5, h6, html, i, iframe, img, ins, kbd, label, legend, li, object, ol, p, pre, q, samp, small, span, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, ul, var { @@ -115,7 +134,7 @@ a, abbr, address, b, blockquote, body, caption, cite, code, dd, del, dfn, div, d } .right_list .lineul li div.sm { float:left; width:30px; background:#cd0a0a; text-align:center; padding:5px; height:20px; line-height:20px;} .right_list .lineul li div.sx { float:left; width:50px; background:#0361e1; color:#fff; text-align:center; padding:5px;height:20px; line-height:20px;} -.right_list .lineul li div.sd { float:left; width:40px; text-align:center; background:#000; color:#fff; text-align:center; padding:5px; float:right;height:20px; line-height:20px; font-size:12px; } +.right_list .lineul li div.sd { float:left; width:40px; text-align:center; background:#000; color:#fff; text-align:center; padding:5px; float:right;height:20px; line-height:20px; font-size:12px; cursor:pointer; } .right_list .lineul li div.ss { float: left; width: 40px; diff --git a/js/index.js b/js/index.js index d692cd0..0c245d6 100644 --- a/js/index.js +++ b/js/index.js @@ -214,7 +214,7 @@ function SetZhuguanTi() { $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); $("#keguan_" + zhuguan_tihao).resizable({ containment: ".main_papermain", handles: 'all' }); - $("#NowSelect").append("
  • 主观题
    " + zhuguan_tihao + "
    " + zhuguan_xiaoti + "
    " + score + "
    " + scoretypeText + "
    x
  • "); + $("#NowSelect").append("
  • 主观题
    " + zhuguan_tihao + "
    " + zhuguan_xiaoti + "
    " + score + "
    " + scoretypeText + "
    X
  • "); //如果是手阅 GetZhuguantiScoreList(); } @@ -329,10 +329,16 @@ function SetMaoDingDian(obj, pageIndex) { if (pageIndex == 1) { ocrText = prompt("请输入学科:"); if (ocrText == '' || ocrText == null) { - alert("请输入学科"); + alert("请输入学科!"); return; } - } + } else { + ocrText = prompt("请输入识别的文字:", ocrText); + if (ocrText == '' || ocrText == null) { + alert("请输入识别的文字!"); + return; + } + } $(".main_papermain").append("
    " + zhuguan_tihao + "
    " + ocrText + "
    "); $("#keguan_" + zhuguan_tihao).draggable({ containment: ".main_papermain" }); @@ -393,10 +399,10 @@ function SetPYPostion(type) { lineWh = "width:736px;height:30px;"; } - if (score.indexOf(".") > -1) { - alert("题目分数不能有小数点"); - return; - } + //if (score.indexOf(".") > -1) { + // alert("题目分数不能有小数点"); + // return; + //} var html = "";