예제 #1
0
        /// <summary>
        /// Save data modification details to the update table
        /// </summary>
        /// <param name="id">Represents references</param>
        /// <param name="table">Represents the reference table</param>
        /// <param name="actionType">Reference the table modification type</param>
        public static void Update(string id, string table, ActionType actionType)
        {
            SalonDbEntities db     = new SalonDbEntities();
            tbllog          update = new tbllog
            {
                ref_table         = table,
                ref_id            = id,
                updated_date_time = DateTime.Now,
                action_type       = System.Enum.GetName(typeof(ActionType), actionType)
            };

            db.tbllogs.Add(update);
            db.SaveChanges();
        }
예제 #2
0
        public async Task <object> setLogData([FromBody] tbllog data)
        {
            object resdata = null;

            try
            {
                resdata = DataAccess.saveData(data);
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            return(resdata);
        }
예제 #3
0
파일: BaseBll.cs 프로젝트: zyzhouone/www
        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="type"> 1.登录 2.注册 3.报名 4.支付 5.比赛</param>
        /// <param name="userid"></param>
        /// <param name="ip"></param>
        /// <param name="note"></param>
        /// <returns></returns>
        public int OptLog(int type, string userid, string ip, string note)
        {
            tbllog log = new tbllog();

            log.createtime = System.DateTime.Now;
            log.IP         = ip;
            log.opttype    = type;
            log.remark     = note;
            log.tid        = System.Guid.NewGuid().ToString();
            log.userid     = userid;
            log.source     = 1; //来源 1.web 2.app
            using (var db = new BFdbContext())
            {
                return(db.Insert <tbllog>(log));
            }
        }
        public static int saveData(tbllog data)
        {
            int result = 0;

            try
            {
                sql = Staticinfos.qruryInsert;

                if (con != null && con.State == ConnectionState.Closed)
                {
                    con.Open();
                }

                using (var cmd = new NpgsqlCommand())
                {
                    cmd.CommandText = sql;
                    cmd.CommandType = CommandType.Text;
                    cmd.Connection  = con;
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("logdetails", data.logdetails);
                    cmd.Parameters.AddWithValue("logdate", DateTime.Now);
                    IDataReader dr = cmd.ExecuteReader();
                    result = dr.RecordsAffected;
                }
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                if (con.State == ConnectionState.Open)
                {
                    con.Close();
                }
            }

            return(result);
        }