Esempio n. 1
0
        public void insertErrLog(s_log_fence model)
        {
            using (conn = ConnectionFactory.CreateConnection())
            {
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }

                string sql = SqlFactory.GetInsertSql(model);
                conn.Execute(sql, model);

                s_task_exception task = conn.Query <s_task_exception>(" select * from s_task_exception where rwbh=@rwbh and type=@type", model).FirstOrDefault();

                if (task == null)//新增
                {
                    string sql1 = SqlFactory.GetInsertSql(model, "s_task_exception");
                    conn.Execute(sql1, model);
                }
                else
                {
                    task.des    = model.des;
                    task.dz_xx  = model.dz_xx;
                    task.fw     = model.fw;
                    task.cjsj   = model.cjsj;
                    task.state  = model.state;
                    task.wd     = model.wd;
                    task.jd     = model.jd;
                    task.wlxh   = model.wlxh;
                    task.status = 0;
                    string sql1 = SqlFactory.GetUpdateSql(task, "s_task_exception", "id");
                    conn.Execute(sql1, task);
                }
            }
        }
Esempio n. 2
0
        public void errorLog(HttpContext context)
        {
            try
            {
                authorityCheck(context);
                string taskNo = context.Request.Params["taskNo"];
                string des    = context.Request.Params["desc"];
                string type   = context.Request.Params["type"];
                string json   = context.Request.Params["json"];

                //writeLog("接收到异常请求,参数taskNo=" + taskNo + "\t desc=" + des + "\t type=" + type + "\t json=" + json);
                writeLog(string.Format("任务编号为{0}的数据监听异常,说明:{1},json:{2}", taskNo, des, json), "errorlog");

                s_log_fence log = new s_log_fence();
                log.id   = Guid.NewGuid().ToString();
                log.cjsj = DateTime.Now;
                log.des  = des;
                log.rwbh = taskNo;
                log.type = type;
                if (type == "0" && !string.IsNullOrEmpty(json))
                {
                    TaskRequest param = JsonConvert.DeserializeObject <TaskRequest>(json);
                    log.jd    = param.lng;
                    log.wd    = param.lat;
                    log.fw    = param.radius;
                    log.cph   = param.vno;
                    log.dz_xx = param.address;
                    log.wlxh  = param.no;
                    log.state = param.listenStatus;
                    if (log.wlxh == 1)// 只有第一个节点的异常才会结束任务
                    {
                        yw_hddz_wlgzEntity wlgz = new Interfaces.Service.FenceService().getWlgzByDzwlbh(taskNo);
                        if (wlgz.rwkssj.GetValueOrDefault().AddDays(1) < DateTime.Now)// 如果是第一个节点 且任务已开始1天 则关闭任务
                        {
                            string strerr = "";
                            this.stopTask(taskNo, out strerr);
                        }
                    }
                }

                new Interfaces.Service.FenceService().insertErrLog(log);



                res.result = true;
            }
            catch (Exception ex)
            {
                res.result = false;
                res.msg    = ex.Message;
                writeLog("errorLog出现异常:" + ex.Message);
            }
        }