Ejemplo n.º 1
0
        /// <summary>
        /// errorLog
        /// </summary>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public IList <tb_error_model> GetPageList(DbConn conn, DateTime?startTime, DateTime?endTime, string mqpathid, string mqpath, string methodname, string info, int pageSize, int pageIndex, ref int count)
        {
            int tempCount = 0;
            var result    = SqlHelper.Visit((ps) =>
            {
                IList <tb_error_model> list          = new List <tb_error_model>();
                StringBuilder where                  = new StringBuilder();
                List <ProcedureParameter> parameters = new List <ProcedureParameter>();
                where.Append(" WHERE 1=1");
                if (startTime != null && endTime != null)
                {
                    parameters.Add(new ProcedureParameter("startTime", startTime.Value.ToString("yyyy-MM-dd")));
                    parameters.Add(new ProcedureParameter("endTime", endTime.Value.ToString("yyyy-MM-dd")));
                    where.Append(" AND createtime>=@startTime AND createtime<=@endTime ");
                }
                if (!string.IsNullOrWhiteSpace(mqpathid))
                {
                    parameters.Add(new ProcedureParameter("mqpathid", mqpathid));
                    where.Append(" AND mqpathid=@mqpathid ");
                }
                if (!string.IsNullOrWhiteSpace(mqpath))
                {
                    parameters.Add(new ProcedureParameter("mqpath", mqpath));
                    where.Append(" AND mqpath=@mqpath ");
                }
                if (!string.IsNullOrWhiteSpace(methodname))
                {
                    parameters.Add(new ProcedureParameter("methodname", methodname));
                    where.Append(" AND methodname like '%'+@methodname+'%' ");
                }
                if (!string.IsNullOrWhiteSpace(info))
                {
                    parameters.Add(new ProcedureParameter("info", info));
                    where.Append(" AND info like '%'+@info+'%' ");
                }
                StringBuilder sql = new StringBuilder();
                sql.Append("SELECT ROW_NUMBER() OVER(ORDER BY Id DESC) AS rownum,* FROM tb_error WITH(NOLOCK)");
                string countSql = string.Concat("SELECT COUNT(1) FROM tb_error WITH(NOLOCK) ", where.ToString());
                object obj      = conn.ExecuteScalar(countSql, parameters);
                if (obj != DBNull.Value && obj != null)
                {
                    tempCount = LibConvert.ObjToInt(obj);
                }
                string sqlPage = string.Concat("SELECT * FROM (", sql.ToString(), where.ToString(), ") A WHERE rownum BETWEEN ", ((pageIndex - 1) * pageSize + 1), " AND ", pageSize * pageIndex);
                DataTable dt   = conn.SqlToDataTable(sqlPage, parameters);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        tb_error_model model = CreateModel(dr);
                        list.Add(model);
                    }
                }
                return(list);
            });

            count = tempCount;
            return(result);
        }
 public void AddError(tb_error_model model)
 {
     AddLog(new tb_log_model {
         logcreatetime = model.errorcreatetime, logtype = model.errortype, msg = model.msg, taskid = model.taskid
     });
     SqlHelper.ExcuteSql(DllTask.SystemRuntimeInfo.TaskConnectString, (c) =>
     {
         dal.tb_error_dal errordal = new dal.tb_error_dal();
         model.msg = model.msg.SubString2(1000);
         errordal.Add(c, model);
     });
 }
Ejemplo n.º 3
0
        public int Add2(DbConn PubConn, tb_error_model model)
        {
            return(SqlHelper.Visit(ps =>
            {
                ps.Add("@msg", model.msg);
                ps.Add("@errortype", model.errortype);
                ps.Add("@errorcreatetime", model.errorcreatetime);
                ps.Add("@taskid", model.taskid);
                ps.Add("@nodeid", model.nodeid);
                return PubConn.ExecuteSql(@"insert into tb_error(msg,errortype,errorcreatetime,taskid,nodeid)
										   values(@msg,@errortype,@errorcreatetime,@taskid,@nodeid)"                                        , ps.ToParameters());
            }));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 添加节点错误日志
        /// </summary>
        /// <param name="msg"></param>
        public static void AddNodeError(string msg, Exception exp)
        {
            if (exp == null)
            {
                exp = new Exception();
            }
            ErrorLog.Write(msg, exp);
            tb_error_model model = new tb_error_model()
            {
                errorcreatetime = DateTime.Now,
                errortype       = (byte)BSF.BaseService.TaskManager.SystemRuntime.EnumTaskLogType.SystemError,
                msg             = msg + " 错误信息:" + exp.Message + " 堆栈:" + exp.StackTrace,
                taskid          = 0,
                nodeid          = GlobalConfig.NodeID
            };

            AddError(model);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 添加任务错误日志
        /// </summary>
        /// <param name="msg"></param>
        public static void AddTaskError(string msg, int taskid, Exception exp)
        {
            ErrorLog.Write(msg + "[taskid:" + taskid + "]", exp);
            if (exp == null)
            {
                exp = new Exception();
            }
            tb_error_model model = new tb_error_model()
            {
                errorcreatetime = DateTime.Now,
                errortype       = (byte)XXF.BaseService.TaskManager.SystemRuntime.EnumTaskLogType.CommonError,
                msg             = msg + " 错误信息:" + exp.Message + " 堆栈:" + exp.StackTrace,
                taskid          = taskid,
                nodeid          = GlobalConfig.NodeID
            };

            AddError(model);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// 添加错误日志
 /// </summary>
 /// <param name="model"></param>
 public static void AddError(tb_error_model model)
 {
     try
     {
         AddLog(new tb_log_model {
             logcreatetime = model.errorcreatetime, logtype = model.errortype, msg = model.msg, taskid = model.taskid
         });
         SqlHelper.ExcuteSql(Config.TaskConnectString, (c) =>
         {
             tb_error_dal errordal = new tb_error_dal();
             model.msg             = model.msg.SubString2(1000);
             errordal.Add2(c, model);
         });
     }
     catch (Exception exp)
     {
         XXF.Log.ErrorLog.Write("添加错误日志至数据库出错", exp);
     }
 }
Ejemplo n.º 7
0
        public virtual bool Add(DbConn PubConn, tb_error_model model)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>()
            {
                //
                new ProcedureParameter("@msg", model.msg),
                //
                new ProcedureParameter("@errortype", model.errortype),
                //
                new ProcedureParameter("@errorcreatetime", model.errorcreatetime),
                //
                new ProcedureParameter("@taskid", model.taskid),
                //
                new ProcedureParameter("@nodeid", model.nodeid)
            };
            int rev = PubConn.ExecuteSql(@"insert into tb_error(msg,errortype,errorcreatetime,taskid,nodeid)
										   values(@msg,@errortype,@errorcreatetime,@taskid,@nodeid)"                                        , Par);

            return(rev == 1);
        }
Ejemplo n.º 8
0
        public virtual bool Add(DbConn PubConn, tb_error_model model)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>()
            {
                //
                new ProcedureParameter("@mqpathid", model.mqpathid),
                //
                new ProcedureParameter("@mqpath", model.mqpath),
                //
                new ProcedureParameter("@methodname", model.methodname),
                //
                new ProcedureParameter("@info", model.info),
                //
                new ProcedureParameter("@createtime", model.createtime)
            };
            int rev = PubConn.ExecuteSql(@"insert into tb_error(mqpathid,mqpath,methodname,info,createtime)
										   values(@mqpathid,@mqpath,@methodname,@info,@createtime)"                                        , Par);

            return(rev == 1);
        }
Ejemplo n.º 9
0
        public virtual bool Edit(DbConn PubConn, tb_error_model model)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>()
            {
                //
                new ProcedureParameter("@msg", model.msg),
                //
                new ProcedureParameter("@errortype", model.errortype),
                //
                new ProcedureParameter("@errorcreatetime", model.errorcreatetime),
                //
                new ProcedureParameter("@taskid", model.taskid),
                //
                new ProcedureParameter("@nodeid", model.nodeid)
            };

            Par.Add(new ProcedureParameter("@id", model.id));

            int rev = PubConn.ExecuteSql("update tb_error set msg=@msg,errortype=@errortype,errorcreatetime=@errorcreatetime,taskid=@taskid,nodeid=@nodeid where id=@id", Par);

            return(rev == 1);
        }
Ejemplo n.º 10
0
        public virtual bool Edit(DbConn PubConn, tb_error_model model)
        {
            List <ProcedureParameter> Par = new List <ProcedureParameter>()
            {
                //
                new ProcedureParameter("@mqpathid", model.mqpathid),
                //
                new ProcedureParameter("@mqpath", model.mqpath),
                //
                new ProcedureParameter("@methodname", model.methodname),
                //
                new ProcedureParameter("@info", model.info),
                //
                new ProcedureParameter("@createtime", model.createtime)
            };

            Par.Add(new ProcedureParameter("@id", model.id));

            int rev = PubConn.ExecuteSql("update tb_error set mqpathid=@mqpathid,mqpath=@mqpath,methodname=@methodname,info=@info,createtime=@createtime where id=@id", Par);

            return(rev == 1);
        }
Ejemplo n.º 11
0
        public virtual tb_error_model CreateModel(DataRow dr)
        {
            var o = new tb_error_model();

            //
            if (dr.Table.Columns.Contains("id"))
            {
                o.id = dr["id"].Toint();
            }
            //
            if (dr.Table.Columns.Contains("msg"))
            {
                o.msg = dr["msg"].Tostring();
            }
            //
            if (dr.Table.Columns.Contains("errortype"))
            {
                o.errortype = dr["errortype"].ToByte();
            }
            //
            if (dr.Table.Columns.Contains("errorcreatetime"))
            {
                o.errorcreatetime = dr["errorcreatetime"].ToDateTime();
            }
            //
            if (dr.Table.Columns.Contains("taskid"))
            {
                o.taskid = dr["taskid"].Toint();
            }
            //
            if (dr.Table.Columns.Contains("nodeid"))
            {
                o.nodeid = dr["nodeid"].Toint();
            }
            return(o);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// 添加错误日志
 /// </summary>
 /// <param name="model"></param>
 private static void AddError(tb_error_model model)
 {
     try
     {
         AddLog(new tb_log_model
         {
             logcreatetime = model.errorcreatetime,
             logtype       = model.errortype,
             msg           = model.msg,
             taskid        = model.taskid,
             nodeid        = GlobalConfig.NodeID
         });
         SqlHelper.ExcuteSql(GlobalConfig.ConnectionString, (c) =>
         {
             tb_error_dal errordal = new tb_error_dal();
             model.msg             = model.msg.SubString2(1000);
             errordal.Add2(c, model);
         });
     }
     catch (Exception exp)
     {
         ErrorLog.Write("添加错误日志至数据库出错", exp);
     }
 }
Ejemplo n.º 13
0
        public virtual tb_error_model CreateModel(DataRow dr)
        {
            var o = new tb_error_model();

            //
            if (dr.Table.Columns.Contains("id"))
            {
                o.id = dr["id"].Tolong();
            }
            //
            if (dr.Table.Columns.Contains("mqpathid"))
            {
                o.mqpathid = dr["mqpathid"].Toint();
            }
            //
            if (dr.Table.Columns.Contains("mqpath"))
            {
                o.mqpath = dr["mqpath"].Tostring();
            }
            //
            if (dr.Table.Columns.Contains("methodname"))
            {
                o.methodname = dr["methodname"].Tostring();
            }
            //
            if (dr.Table.Columns.Contains("info"))
            {
                o.info = dr["info"].Tostring();
            }
            //
            if (dr.Table.Columns.Contains("createtime"))
            {
                o.createtime = dr["createtime"].ToDateTime();
            }
            return(o);
        }