Esempio n. 1
0
        //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);
        }