public PageModel <Model.TaskWorkLog> PageWorkLogErrorMode(DateTime date, List <string> notContainText, DateTime?begintime, DateTime?endtime, int pno) { int pagesize = 20; using (RLib.DB.DbConn dbconn = Pub.GetConn()) { int totalcount = 0; if (!Pub.ExistTableInDB(dbconn, Pub.BuildWTbName(date))) { return(new PageModel <Model.TaskWorkLog>() { List = new List <Model.TaskWorkLog>(), PageNo = pno, PageSize = pagesize, TotalCount = 0 }); } var model = tasklogdal.GetWorkLogPage(dbconn, date, null, null, 1, false, notContainText, null, null, begintime, endtime, pno, pagesize, out totalcount); return(new PageModel <Model.TaskWorkLog>() { List = model, PageNo = pno, PageSize = pagesize, TotalCount = totalcount }); } }
public PageModel <Model.TaskWorkLog> PageWorkLog(DateTime date, int?taskid, int?nodeid, int?logtype, string runguid, string keywords, DateTime?begintime, DateTime?endtime, int pno) { int pagesize = 20; using (RLib.DB.DbConn dbconn = Pub.GetConn()) { int totalcount = 0; if (!Pub.ExistTableInDB(dbconn, Pub.BuildWTbName(date))) { return(new PageModel <Model.TaskWorkLog>() { List = new List <Model.TaskWorkLog>(), PageNo = pno, PageSize = pagesize, TotalCount = 0 }); } var model = tasklogdal.GetWorkLogPage(dbconn, date, taskid, nodeid, logtype, false, null, runguid, keywords, begintime, endtime, pno, pagesize, out totalcount); return(new PageModel <Model.TaskWorkLog>() { List = model, PageNo = pno, PageSize = pagesize, TotalCount = totalcount }); } }
//public int AddWorkLogs(RLib.DB.DbConn dbconn, DateTime date, List<Model.TaskWorkLog> models) //{ // if (models == null || models.Count == 0) // return 0; // string sql = "insert into " + Pub.BuildWTbName(date) + "(taskid,nodeid,dispatchid,logtype,logtext,servertime) values "; // string vt = " (@taskid_{0},@nodeid_{0},@dispatchid_{0},@logtype_{0},@logtext_{0},@servertime_{0})"; // List<string> valsql = new List<string>(); // List<RLib.DB.ProcedureParameter> paras = new List<RLib.DB.ProcedureParameter>(); // for (int i = 0; i < models.Count; i++) // { // valsql.Add(string.Format(vt, i)); // paras.Add(new RLib.DB.ProcedureParameter("@taskid_" + i, models[i].TaskId)); // paras.Add(new RLib.DB.ProcedureParameter("@nodeid_" + i, models[i].NodeId)); // paras.Add(new RLib.DB.ProcedureParameter("@dispatchid_" + i, models[i].DispatchId ?? "")); // paras.Add(new RLib.DB.ProcedureParameter("@logtype_" + i, models[i].LogType)); // paras.Add(new RLib.DB.ProcedureParameter("@logtext_" + i, models[i].LogText ?? "")); // paras.Add(new RLib.DB.ProcedureParameter("@servertime_" + i, models[i].ServerTime)); // } // string insqlsql = sql + string.Join(",", valsql); // int r = dbconn.ExecuteSql(insqlsql, paras); // return r; //} public int AddWorkLogs(RLib.DB.DbConn dbconn, DateTime date, List <Model.TaskWorkLog> models) { var tbname = Pub.BuildWTbName(date); if (models == null || models.Count == 0) { return(0); } //区分大小写 System.Data.DataTable tb = new System.Data.DataTable(tbname); tb.Columns.Add("taskId"); tb.Columns.Add("nodeId"); tb.Columns.Add("dispatchId"); tb.Columns.Add("logType"); tb.Columns.Add("logText"); tb.Columns.Add("serverTime"); foreach (var a in models) { tb.Rows.Add( a.TaskId, a.NodeId, a.DispatchId ?? "", a.LogType, a.LogText, a.ServerTime ); } dbconn.BuckCopy(tb, null, null); return(models.Count); }
public Model.TaskWorkLog AddWorkLog(RLib.DB.DbConn dbconn, DateTime date, Model.TaskWorkLog model) { string sql = "insert into " + Pub.BuildWTbName(date) + "(taskid,nodeid,dispatchid,logtype,logtext,servertime) values " + " (@taskid,@nodeid,@dispatchid,@logtype,@logtext,@servertime);select @@identity;"; model.LogId = dbconn.ExecuteScalar <int>(sql, new { taskid = model.TaskId, nodeid = model.NodeId, dispatchid = model.DispatchId ?? "", logtype = model.LogType, logtext = model.LogText ?? "", servertime = model.ServerTime }); // dbconn.GetIdentity(); return(model); }
public List <Model.TaskWorkLog> GetWorkLogPage(RLib.DB.DbConn dbconn, DateTime date, int?taskid, int?nodeid, int?logtype, bool isorderbyId, List <string> notContainText, string runguid, string keywords, DateTime?begintime, DateTime?endtime, int pno, int pagesize, out int totalcount) { List <RLib.DB.ProcedureParameter> paras = new List <RLib.DB.ProcedureParameter>(); paras.Add(new RLib.DB.ProcedureParameter("begintime", begintime == null ? System.DBNull.Value : (object)begintime.Value)); paras.Add(new RLib.DB.ProcedureParameter("endtime", endtime == null ? System.DBNull.Value : (object)endtime.Value)); paras.Add(new RLib.DB.ProcedureParameter("taskid", taskid ?? 0)); paras.Add(new RLib.DB.ProcedureParameter("nodeid", nodeid ?? 0)); paras.Add(new RLib.DB.ProcedureParameter("logtype", logtype ?? 0)); paras.Add(new RLib.DB.ProcedureParameter("runguid", runguid ?? "")); paras.Add(new RLib.DB.ProcedureParameter("keywords", keywords ?? "")); paras.Add(new RLib.DB.ProcedureParameter("startindex", (pno - 1) * pagesize + 1)); paras.Add(new RLib.DB.ProcedureParameter("pagesize", pagesize)); string sqltp = "select {0} from " + Pub.BuildWTbName(date) + " with(nolock) {1} {2}"; string fields = "row_number() over(order by " + (isorderbyId ? " logid asc " : " servertime desc,logid desc") + " ) as rownum,*"; string wherecon = " where 1=1 "; if (taskid != null && taskid > 0) { wherecon += " and taskid=@taskid "; } if (nodeid != null && nodeid > 0) { wherecon += " and nodeid=@nodeid "; } if (logtype != null) { wherecon += " and logtype=@logtype "; } if (!string.IsNullOrWhiteSpace(keywords)) { wherecon += " and ( logtext like '%'+@keywords+'%' ) "; } if (!string.IsNullOrWhiteSpace(runguid)) { wherecon += " and dispatchId=@runguid "; } if (begintime != null) { wherecon += " and createtime>=@begintime "; } if (endtime != null) { wherecon += " and createtime<=@endtime "; } if (notContainText != null && notContainText.Count > 0) { int notlikeindex = 0; foreach (var a in notContainText) { if (string.IsNullOrWhiteSpace(a)) { continue; } notlikeindex++; wherecon += " and logText not like '%'+@notlikeindex" + (notlikeindex) + "+'%'"; paras.Add(new RLib.DB.ProcedureParameter("notlikeindex" + notlikeindex, a)); } } string countsql = string.Format(sqltp, "count(1)", wherecon, ""); string querysql = string.Format("select * from ( {0} ) A where A.rownum>=@startindex and A.rownum<@startindex+@pagesize ", string.Format(sqltp, fields, wherecon, "")); totalcount = dbconn.ExecuteScalar <int>(countsql, paras); var models = dbconn.Query <Model.TaskWorkLog>(querysql, paras); return(models); }