コード例 #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
ファイル: DbUtil.cs プロジェクト: stevesloka/bvcms
        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
ファイル: Organization.cs プロジェクト: vs06/bvcms
 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
ファイル: DbUtil.cs プロジェクト: chrisgundersen/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);
            //		    }
        }