コード例 #1
0
ファイル: LogsBll.cs プロジェクト: wanxb/mvc_demo
 /// <summary>
 /// 结束时写入执行日志
 /// </summary>
 /// <param name="m">起始日志Model</param>
 /// <param name="result">方法执行结果</param>
 /// <param name="retcontent">方法返回内容</param>
 public void AddEndLogs(t_logs m, string result, string retcontent)
 {
     m.result     = result;
     m.retcontent = retcontent;
     m.e_date     = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     new Dal.BaseData.t_logsDal().Add(m);
 }
コード例 #2
0
ファイル: t_logsDal.cs プロジェクト: wanxb/mvc_demo
        /// <summary>
        ///Save,保存方法,先删除,再增加
        /// </summary>
        public void Save(t_logs model, SqlTransaction tran = null, params string[] str)
        {
            string        tran_flag = "1";
            SqlConnection conn      = new SqlConnection(Dal.DataHelper.constr);

            conn.Open();
            if (tran == null)
            {
                tran_flag = "0";
                tran      = conn.BeginTransaction();
            }
            try
            {
                Delete(model, tran, str);
                Add(model, tran);

                //如果传入事物,提交否则外层提交
                if (tran_flag == "0")
                {
                    tran.Commit();
                    conn.Close();
                }
            }
            catch (Exception e)
            {
                if (tran_flag == "0")
                {
                    tran.Rollback();
                    conn.Close();
                }
                throw e;
            }
        }
コード例 #3
0
ファイル: LogsBll.cs プロジェクト: wanxb/mvc_demo
        /// <summary>
        /// 开始写入执行日志
        /// </summary>
        /// <param name="param">传入参数</param>
        /// <param name="action">方法名</param>
        /// <returns></returns>
        public t_logs AddBeginLogs(ApiParams param, string action)
        {
            t_logs m = new t_logs();

            m.ctype  = "xxkj_api_logs";
            m.action = action;
            m.ip     = param.ip;
            m.accout = param.accout;
            m.param  = param.paramMain + "/" + param.paramDetails;
            m.b_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            return(m);
        }
コード例 #4
0
ファイル: t_logsDal.cs プロジェクト: wanxb/mvc_demo
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public override void Add(dynamic obj, SqlTransaction tran = null)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_logs(");
            strSql.Append("b_date,e_date,cdef1,cdef2,cdef3,cdef4,cdef5,cdef6,cdef7,cdef8,ctype,cdef9,cdef10,action,ip,accout,param,result,retcontent,memo");
            strSql.Append(") values (");
            strSql.Append("@b_date,@e_date,@cdef1,@cdef2,@cdef3,@cdef4,@cdef5,@cdef6,@cdef7,@cdef8,@ctype,@cdef9,@cdef10,@action,@ip,@accout,@param,@result,@retcontent,@memo");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@b_date",     SqlDbType.VarChar,  100),
                new SqlParameter("@e_date",     SqlDbType.VarChar,  100),
                new SqlParameter("@cdef1",      SqlDbType.VarChar,   50),
                new SqlParameter("@cdef2",      SqlDbType.VarChar,   50),
                new SqlParameter("@cdef3",      SqlDbType.VarChar,   50),
                new SqlParameter("@cdef4",      SqlDbType.VarChar,   50),
                new SqlParameter("@cdef5",      SqlDbType.VarChar,   50),
                new SqlParameter("@cdef6",      SqlDbType.VarChar,  100),
                new SqlParameter("@cdef7",      SqlDbType.VarChar,  100),
                new SqlParameter("@cdef8",      SqlDbType.VarChar,  100),
                new SqlParameter("@ctype",      SqlDbType.VarChar,  100),
                new SqlParameter("@cdef9",      SqlDbType.VarChar,  100),
                new SqlParameter("@cdef10",     SqlDbType.VarChar,  100),
                new SqlParameter("@action",     SqlDbType.VarChar,  100),
                new SqlParameter("@ip",         SqlDbType.VarChar,  100),
                new SqlParameter("@accout",     SqlDbType.VarChar,  100),
                new SqlParameter("@param",      SqlDbType.VarChar,   -1),
                new SqlParameter("@result",     SqlDbType.VarChar,  100),
                new SqlParameter("@retcontent", SqlDbType.VarChar, 2000),
                new SqlParameter("@memo",       SqlDbType.VarChar, 1000)
            };
            t_logs model = (t_logs)obj;

            parameters[0].Value  = SqlNull(model.b_date);
            parameters[1].Value  = SqlNull(model.e_date);
            parameters[2].Value  = SqlNull(model.cdef1);
            parameters[3].Value  = SqlNull(model.cdef2);
            parameters[4].Value  = SqlNull(model.cdef3);
            parameters[5].Value  = SqlNull(model.cdef4);
            parameters[6].Value  = SqlNull(model.cdef5);
            parameters[7].Value  = SqlNull(model.cdef6);
            parameters[8].Value  = SqlNull(model.cdef7);
            parameters[9].Value  = SqlNull(model.cdef8);
            parameters[10].Value = SqlNull(model.ctype);
            parameters[11].Value = SqlNull(model.cdef9);
            parameters[12].Value = SqlNull(model.cdef10);
            parameters[13].Value = SqlNull(model.action);
            parameters[14].Value = SqlNull(model.ip);
            parameters[15].Value = SqlNull(model.accout);
            parameters[16].Value = SqlNull(model.param);
            parameters[17].Value = SqlNull(model.result);
            parameters[18].Value = SqlNull(model.retcontent);
            parameters[19].Value = SqlNull(model.memo);
            if (tran == null)
            {
                DataHelper.ExcuteNonQuery(strSql.ToString(), parameters, false);
            }
            else
            {
                DataHelper.ExcuteNonQuery(strSql.ToString(), tran, parameters, false);
            }
        }