예제 #1
0
            public View(EventLogDb.EventLog entity)
            {
                Id         = entity.id;
                Autor      = entity.author;
                VerfasstAm = entity.created;
                Typ        = entity.EventLogTypes.name;

                Log = entity.log.Value;
            }
예제 #2
0
        public void OnLog(string userId, mko.Log.ILogInfo info)
        {
            try
            {
                var ctx = new EventLogDb.DtxEventLogDataContext();

                var entity = new EventLogDb.EventLog();
                entity.author  = userId;
                entity.created = info.LogDate;

                switch (info.LogType)
                {
                case mko.Log.EnumLogType.Error:
                    entity.EventLogType_id = ctx.EventLogTypes.Where(r => r.name == "Error").First().id;
                    entity.log             = new System.Xml.Linq.XElement(ErrElem);
                    break;

                case mko.Log.EnumLogType.Message:
                    entity.EventLogType_id = ctx.EventLogTypes.Where(r => r.name == "Message").First().id;
                    entity.log             = new System.Xml.Linq.XElement(MsgElem);
                    break;

                case mko.Log.EnumLogType.Status:
                    entity.EventLogType_id = ctx.EventLogTypes.Where(r => r.name == "Status").First().id;
                    entity.log             = new System.Xml.Linq.XElement(StaElem);
                    break;

                default:
                    Debug.Fail("Unbekannter LogTyp");
                    SelfDeregisterDelegate(this);
                    break;
                }

                entity.log.Add(info.Message);
                ctx.EventLog.InsertOnSubmit(entity);
                ctx.SubmitChanges();
            }
            catch (Exception ex)
            {
                Debug.Fail("In DbLogHnd.OnLog: " + ex.Message);
                throw new Exception("In DbLogHnd.OnLog:", ex);
            }
        }