예제 #1
0
 public LogPresentationStub(log dbItem)
 {
     this.Id = dbItem.id;
     this.Timestamp = dbItem.timestamp;
     this.Application = dbItem.application;
     this.Ip = dbItem.ip;
     this.User = dbItem.user;
     this.Action = dbItem.action;
     this.Data = dbItem.data;
 }
예제 #2
0
 public LogPresentationStub(log dbItem)
 {
     Id = dbItem.id;
     Timestamp = dbItem.timestamp;
     Ip = dbItem.ip;
     User = dbItem.user;
     Action = dbItem.action;
     Data = System.Net.WebUtility.UrlDecode(dbItem.data);
     Application = dbItem.application;
 }
예제 #3
0
        private log GetLog(RouteData routeData, HttpContextBase httpContext)
        {
            string application = "Minibank";
            string username = httpContext.User.Identity.Name;
            string controllerName = routeData.Values["controller"].ToString();
            string actionName = routeData.Values["action"].ToString();
            //string areaName = routeData.Values["area"].ToString();

            string ipAddress = httpContext.Request.UserHostAddress;
            string url = httpContext.Request.Url.PathAndQuery;
            string requestBody = "";
            using (StreamReader reader = new StreamReader(httpContext.Request.InputStream))
            {
                try
                {
                    httpContext.Request.InputStream.Position = 0;
                    requestBody = reader.ReadToEnd();
                }
                catch (Exception ex)
                {
                    requestBody = string.Empty;
                    //log errors
                }
                finally
                {
                    httpContext.Request.InputStream.Position = 0;
                }

                if (requestBody.Contains("password"))
                {
                    requestBody = requestBody.Substring(0, requestBody.IndexOf("password"));
                }
            }

            log log = new log { action = url, application = application, data = requestBody, ip = ipAddress, timestamp = DateTime.Now, user = username };

            return log;
        }
예제 #4
0
        public long Save(log dbItem)
        {
            if (dbItem.id == 0) //create
            {
                context.logs.Add(dbItem);
            }
            else //edit
            {
                context.logs.Attach(dbItem);

                var entry = context.Entry(dbItem);
                entry.State = EntityState.Modified;

                //field yang tidak ditentukan oleh user
                //entry.Property(e => e.is_delete).IsModified = false;
            }
            context.SaveChanges();

            return dbItem.id;
        }
예제 #5
0
 public log GetDbObject(log dbItem)
 {
     dbItem.id = this.Id;
     dbItem.timestamp = this.Timestamp;
     dbItem.application = this.Application;
     dbItem.ip = this.Ip;
     dbItem.user = this.User;
     dbItem.action = this.Action;
     dbItem.data = this.Data;
     return dbItem;
 }