Ejemplo n.º 1
0
        private void SaveLog(IStatelessSession session, TermLog entity)
        {
            if (session == null) return;

            using (var tx = session.BeginTransaction())
            {
                var currentEmployee = ApplicationCache.Get<Entity>(Global.LoginEmployee);
                if (currentEmployee != null)
                    entity.AlterEmployeeId = currentEmployee.Id;
                session.Insert(entity);
                
                tx.Commit();
            }
        }
Ejemplo n.º 2
0
        public void OnPostDelete(PostDeleteEvent @event)
        {
            var entity = default(Term);

            if (@event.TryCatchEntity(ref entity))
            {
                var statelessSession = @event.Persister.Factory.OpenStatelessSession();

                var log = new TermLog
                              {
                                  EmployeeId = entity.GetSnapshotValue<Guid>("EmployeeId"),
                                  Action = "D",
                                  Type = entity.GetType().Name,
                                  Name = entity.Text,
                                  Category = _alterWay,
                                  OldTime = FormatTime(entity.Start, entity.End),
                                  NewTime = null,
                                  Remark = _batchAlteringComments
                              };
                SaveLog(statelessSession, log);
                entity.EndEdit();
            }
        }
Ejemplo n.º 3
0
        public void OnPostUpdate(PostUpdateEvent @event)
        {
            var entity = default(Term);

            if (@event.TryCatchEntity(ref entity))
            {
                var statelessSession = @event.Persister.Factory.OpenStatelessSession();

                var start = entity.GetSnapshotValue<DateTime>("Start");
                var end = entity.GetSnapshotValue<DateTime>("End");
                var locked = entity.GetSnapshotValue<bool>("Locked");

                if (start == entity.Start && end == entity.End && locked == entity.Locked) // no changed
                    return;

                //var length = (entity.End - entity.Start).TotalMinutes;
                //var oldtime = (end - start).TotalMinutes;

                var log = new TermLog
                              {
                                  SourceId = entity.Id,
                                  EmployeeId = entity.GetSnapshotValue<Guid>("EmployeeId"),
                                  Type = entity.GetType().Name,
                                  Name = entity.Text,
                                  Category = _alterWay,
                                  OldTime = FormatTime(start, end),
                                  NewTime = FormatTime(entity.Start, entity.End),
                                  Remark = _batchAlteringComments
                              };
                log.Action = entity.GetAction();

                SaveLog(statelessSession, log);
                entity.EndEdit();
            }
        }