示例#1
0
文件: User.cs 项目: davidbwire/bvcms
 private void attach_ActivityLogs(ActivityLog entity)
 {
     this.SendPropertyChanging();
     entity.User = this;
 }
示例#2
0
文件: User.cs 项目: davidbwire/bvcms
 private void detach_ActivityLogs(ActivityLog entity)
 {
     this.SendPropertyChanging();
     entity.User = null;
 }
示例#3
0
文件: DbUtil.cs 项目: hkouns/bvcms
 public static void LogActivity(string activity, string name = null, int? orgid = null, int? pid = null)
 {
     var db = new CMSDataContext(Util.ConnectionString);
     int? uid = Util.UserId;
     if (uid == 0)
         uid = null;
     var a = new ActivityLog
     {
         ActivityDate = Util.Now,
         UserId = uid,
         Activity = activity,
         Machine = System.Environment.MachineName,
         OrgId = orgid,
         PeopleId = pid,
     };
     db.ActivityLogs.InsertOnSubmit(a);
     db.SubmitChanges();
     db.Dispose();
     if (orgid.HasValue)
     {
         var mru = Util2.MostRecentOrgs;
         var i = mru.SingleOrDefault(vv => vv.Id == orgid);
         if (i != null)
             mru.Remove(i);
         mru.Insert(0, new Util2.MostRecentItem() { Id = orgid.Value, Name = name });
         if (mru.Count > 5)
             mru.RemoveAt(mru.Count - 1);
     }
     else if (pid.HasValue && pid != Util.UserPeopleId)
     {
         var mru = Util2.MostRecentPeople;
         var i = mru.SingleOrDefault(vv => vv.Id == pid);
         if (i != null)
             mru.Remove(i);
         mru.Insert(0, new Util2.MostRecentItem() { Id = pid.Value, Name = name });
         if (mru.Count > 5)
             mru.RemoveAt(mru.Count - 1);
     }
     //		    else if (qid.HasValue && pid != Util.UserPeopleId)
     //		    {
     //		        var mru = Util2.MostRecentQueries;
     //		        var i = mru.SingleOrDefault(vv => vv.Id == pid);
     //		        if (i != null)
     //		            mru.Remove(i);
     //		        mru.Insert(0, new Util2.MostRecentItem() { Id = pid.Value, Name = name });
     //                if (mru.Count > 5)
     //    	            mru.RemoveAt(mru.Count-1);
     //		    }
 }
示例#4
0
        private static void _logActivity(string host, string activity, int?orgId, int?peopleId, int?datumId, int?userId, string pageUrl = null, string clientIp = null)
        {
            var ip = HttpContext.Current?.Request.UserHostAddress;

            using (var db = Create(host))
            {
                if (!userId.HasValue || userId == 0)
                {
                    userId = Util.UserId;
                }
                if (userId == 0)
                {
                    userId = null;
                }
                if (orgId.HasValue && !db.PeopleIdOk(peopleId))
                {
                    peopleId = null;
                }
                if (peopleId.HasValue && !db.OrgIdOk(orgId))
                {
                    orgId = null;
                }

                var a = new ActivityLog
                {
                    ActivityDate = Util.Now,
                    UserId       = userId,
                    Activity     = activity.Truncate(200),
                    Machine      = Environment.MachineName,
                    OrgId        = orgId,
                    PeopleId     = peopleId,
                    DatumId      = datumId,
                    PageUrl      = pageUrl,
                    ClientIp     = clientIp ?? ip
                };

                db.ActivityLogs.InsertOnSubmit(a);
                db.SubmitChanges();
            }

            // Logging temporarily to monitor some major changes

//            if (!a.Activity.StartsWith("OnlineReg"))
//                return;
//
//            var cs = ConfigurationManager.ConnectionStrings["CmsLogging"];
//            if (cs != null)
//            {
//                using (var cn = new SqlConnection(cs.ConnectionString))
//                {
//                    cn.Open();
//                    cn.Execute(
//                        "INSERT dbo.RegActivity (db, dt, activity, oid, pid, did) VALUES(@db, @dt, @ac, @oid, @pid, @did)",
//                        new
//                        {
//                            db = host,
//                            ac = activity,
//                            dt = a.ActivityDate,
//                            oid = a.OrgId,
//                            pid = a.PeopleId,
//                            did = a.DatumId,
//                        });
//                }
//            }
        }
示例#5
0
        private static void _logActivity(string host, string activity, int? orgId, int? peopleId, int? datumId, int? userId, string pageUrl = null, string clientIp = null)
        {
            var db = Create(host);

            if (!userId.HasValue || userId == 0)
                userId = Util.UserId;
            if (userId == 0)
                userId = null;
            if (orgId.HasValue && !db.PeopleIdOk(peopleId))
                peopleId = null;
            if (peopleId.HasValue && !db.OrgIdOk(orgId))
                orgId = null;

            var a = new ActivityLog
            {
                ActivityDate = Util.Now,
                UserId = userId,
                Activity = activity.Truncate(200),
                Machine = Environment.MachineName,
                OrgId = orgId,
                PeopleId = peopleId,
                DatumId = datumId,
                PageUrl = pageUrl,
                ClientIp = clientIp
            };

            db.ActivityLogs.InsertOnSubmit(a);
            db.SubmitChanges();
            db.Dispose();

            // Logging temporarily to monitor some major changes

//            if (!a.Activity.StartsWith("OnlineReg"))
//                return;
//
//            var cs = ConfigurationManager.ConnectionStrings["CmsLogging"];
//            if (cs != null)
//            {
//                using (var cn = new SqlConnection(cs.ConnectionString))
//                {
//                    cn.Open();
//                    cn.Execute(
//                        "INSERT dbo.RegActivity (db, dt, activity, oid, pid, did) VALUES(@db, @dt, @ac, @oid, @pid, @did)",
//                        new
//                        {
//                            db = host,
//                            ac = activity,
//                            dt = a.ActivityDate,
//                            oid = a.OrgId,
//                            pid = a.PeopleId,
//                            did = a.DatumId,
//                        });
//                }
//            }
        }
示例#6
0
文件: Person.cs 项目: hkouns/bvcms
 private void detach_ActivityLogs(ActivityLog entity)
 {
     this.SendPropertyChanging();
     entity.Person = null;
 }
示例#7
0
 private void attach_ActivityLogs(ActivityLog entity)
 {
     this.SendPropertyChanging();
     entity.Organization = this;
 }
示例#8
0
文件: User.cs 项目: rossspoon/bvcms
 private void attach_ActivityLogs(ActivityLog entity)
 {
     this.SendPropertyChanging();
     entity.User = this;
 }
示例#9
0
        public static void LogActivity(string activity, string name = null, int?orgid = null, int?pid = null)
        {
            var db  = new CMSDataContext(Util.ConnectionString);
            int?uid = Util.UserId;

            if (uid == 0)
            {
                uid = null;
            }
            var a = new ActivityLog
            {
                ActivityDate = Util.Now,
                UserId       = uid,
                Activity     = activity,
                Machine      = System.Environment.MachineName,
                OrgId        = orgid,
                PeopleId     = pid,
            };

            db.ActivityLogs.InsertOnSubmit(a);
            db.SubmitChanges();
            db.Dispose();
            if (orgid.HasValue)
            {
                var mru = Util2.MostRecentOrgs;
                var i   = mru.SingleOrDefault(vv => vv.Id == orgid);
                if (i != null)
                {
                    mru.Remove(i);
                }
                mru.Insert(0, new Util2.MostRecentItem()
                {
                    Id = orgid.Value, Name = name
                });
                if (mru.Count > 5)
                {
                    mru.RemoveAt(mru.Count - 1);
                }
            }
            else if (pid.HasValue && pid != Util.UserPeopleId)
            {
                var mru = Util2.MostRecentPeople;
                var i   = mru.SingleOrDefault(vv => vv.Id == pid);
                if (i != null)
                {
                    mru.Remove(i);
                }
                mru.Insert(0, new Util2.MostRecentItem()
                {
                    Id = pid.Value, Name = name
                });
                if (mru.Count > 5)
                {
                    mru.RemoveAt(mru.Count - 1);
                }
            }
            //		    else if (qid.HasValue && pid != Util.UserPeopleId)
            //		    {
            //		        var mru = Util2.MostRecentQueries;
            //		        var i = mru.SingleOrDefault(vv => vv.Id == pid);
            //		        if (i != null)
            //		            mru.Remove(i);
            //		        mru.Insert(0, new Util2.MostRecentItem() { Id = pid.Value, Name = name });
            //                if (mru.Count > 5)
            //                  mru.RemoveAt(mru.Count-1);
            //		    }
        }