Пример #1
0
        public virtual bool Update(TEntity entity)
        {
            PropertyInfo prop = null;

            foreach (var item in typeof(TEntity).GetProperties())
            {
                if (item.GetCustomAttribute <KeyAttribute>() != null)
                {
                    prop = item;
                    break;
                }
            }
            var orginalModel = GetFirst(DynamicLinq.ConvertToExpression <TEntity>(prop.Name + "=" + prop.GetValue(entity), null));
            var entry        = Context.Entry(orginalModel);

            entry.CurrentValues.SetValues(entity);
            entry.State = EntityState.Modified;

            LogInfo = new LogInfo()
            {
                CallSite = typeof(TEntity).Name + ".Update",
                LogType  = LogType.Update,
                UserId   = (Thread.CurrentPrincipal.Identity as Identity).Id,
                Entry    = entry
            };

            return(true);
        }
Пример #2
0
        public void Log(string userId, ILogInfo info)
        {
            lock (this)
            {
                switch (info.LogType)
                {
                case EnumLogType.Error:
                {
                    if (EventErrorILogInfo != null)
                    {
                        EventErrorILogInfo(userId, info);
                    }
                } break;

                case EnumLogType.Message:
                {
                    if (EventMsgILogInfo != null)
                    {
                        EventMsgILogInfo(userId, info);
                    }
                } break;

                case EnumLogType.Status:
                {
                    if (EventStatusILogInfo != null)
                    {
                        EventStatusILogInfo(userId, info);
                    }
                } break;

                default: throw new NotImplementedException("unbekannter LogType- Enum");
                    break;
                }
            }
        }
        void ILogHnd.OnLog(string userId, ILogInfo info)
        {
            try
            {
                // Threadsicherer Aufruf der Listbox Add Methode
                if (_lbx.InvokeRequired)
                {
                    ILogHnd logHnd = this;
                    DGHnd   dg     = new DGHnd(logHnd.OnLog);
                    _lbx.BeginInvoke(dg, new object[] { userId, info });
                }
                else
                {
                    switch (info.LogType)
                    {
                    case EnumLogType.Error:
                    {
                        string descr = string.Format("Err: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                        Debug.Fail("WinFormListBoxLogHnd: " + descr);
                        _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                        _counter++;
                    }
                    break;

                    case EnumLogType.Message:
                        if (ShowMessage)
                        {
                            string descr = string.Format("Msg: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                            Debug.WriteLine("WinFormListBoxLogHnd: " + descr);
                            _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                            _counter++;
                        }
                        break;

                    case EnumLogType.Status:
                        if (ShowStatus)
                        {
                            string descr = string.Format("Sta: user= {0}: {1} / {2}", info.LogDate, userId, info.Message);
                            Debug.WriteLine("WinFormListBoxLogHnd: " + descr);
                            _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                            _counter++;
                        }
                        break;

                    default:
                    {
                        string descr = string.Format("Unbekannter Logtyp: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                        _lbx.Items.Add(_counter.ToString() + '\t' + descr);
                        Debug.Fail("WinFormListBoxLogHnd: " + descr);
                    }
                    break;
                    }
                }
            }
            catch (Exception ex)
            {
                SelfDeregisterILogHnd();
            }
        }
Пример #4
0
 /// <summary>
 /// ログを出力します。
 /// </summary>
 /// <param name="level">ログレベル</param>
 /// <param name="log">ログ情報</param>
 private async Task WriteAsync(LogLevel level, ILogInfo log)
 {
     if (!NeedWrite(level))
     {
         return;
     }
     await WriteAsyncCore(level, GetNextSequence(), DateTime.Now, log.BuildMessage());
 }
Пример #5
0
 /// <summary>
 /// ログを出力します。
 /// </summary>
 /// <param name="level">ログレベル</param>
 /// <param name="log">ログ情報</param>
 private void Write(LogLevel level, ILogInfo log)
 {
     if (!NeedWrite(level))
     {
         return;
     }
     WriteCore(level, GetNextSequence(), DateTime.Now, log.BuildMessage());
 }
 public CustomerService(
     IGatewayCustomerService gatewayService,
     ICustomerRepository customerRepository,
     ILogInfo logInfo
     )
 {
     this._customerRepository = customerRepository;
     this._logInfo            = logInfo;
     this.GatewayService      = gatewayService;
 }
Пример #7
0
 public void Log(string userId, ILogInfo info)
 {
     lock (this)
     {
         if (EventLog != null)
         {
             EventLog(userId, info);
         }
     }
 }
Пример #8
0
 void ILogHnd.OnError(string userId, ILogInfo info)
 {
     try
     {
         string msg = string.Format("user= {0}: {1} / {2}", userId, info.MessageCodeToString(), info.Message);
         Log("Err", msg);
     }
     catch (Exception ex)
     {
         SelfDeregisterILogHnd();
     }
 }
Пример #9
0
 void ILogHnd.OnStatus(string userId, ILogInfo info)
 {
     try
     {
         Console.WriteLine("Sta {0,4:D4}, user= {1}: {2} / {3}", msgCounter, userId, info.MessageCodeToString(), info.Message);
         msgCounter++;
     }
     catch (Exception ex)
     {
         SelfDeregisterILogHnd();
     }
 }
Пример #10
0
 public void Log(ILogInfo logInfo)
 {
     lock (threadLock)
     {
         logsInfo[countEvents] = logInfo;
         countEvents++;
         if (NeedToFlush())
         {
             FlushAllTargets();
         }
     }
 }
Пример #11
0
 void ILogHnd.OnError(string userId, ILogInfo info)
 {
     try
     {
         string descr = string.Format("Err: user= {0}: {1} / {2}", userId, info.MessageCodeToString(), info.Message);
         Debug.Fail("SysteEventLogHnd: " + descr);
         log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Error);
     }
     catch (Exception ex)
     {
         SelfDeregisterILogHnd();
     }
 }
Пример #12
0
        public virtual bool Remove(TEntity entity)
        {
            set.Remove(entity);

            LogInfo = new LogInfo()
            {
                CallSite = typeof(TEntity).Name + ".Remove",
                LogType  = LogType.Delete,
                UserId   = (Thread.CurrentPrincipal.Identity as Identity).Id,
                Entry    = Context.Entry(entity)
            };

            return(true);
        }
Пример #13
0
        public virtual bool Add(TEntity entity)
        {
            set.Add(entity);

            LogInfo = new LogInfo()
            {
                CallSite = typeof(TEntity).Name + ".Add",
                LogType  = LogType.Add,
                UserId   = (Thread.CurrentPrincipal.Identity as Identity).Id,
                Entry    = Context?.Entry(entity)
            };

            return(true);
        }
        public CustomerService(
            IRestRequest restRequest,
            IRestClient restClient,
            IConfigurationProvider configurationProvider,
            ILogInfo logInfo
            )
        {
            _restClient                = restClient;
            _logInfo                   = logInfo;
            this.RestRequest           = restRequest;
            this.ConfigurationProvider = configurationProvider;

            this.RestRequest.AddUrlSegment("endpoint", ENDPOINT);
        }
Пример #15
0
 private static IResultsSetInfo createResultsSet(ILogInfo item, string resultsName = "")
 {
     IObjectiveScores[] arrayScores = item.Scores as IObjectiveScores[];
     if (arrayScores != null && arrayScores.Length > 0)
     {
         IDictionary <string, string> tags = item.Tags;
         var result = ConvertOptimizationResults.Convert(arrayScores, attributes: tags);
         result.Name = resultsName;
         return(new ObjResultsInfo(result));
     }
     else
     {
         return(new SingleLineInfo(item.Tags));
     }
 }
        void ILogHnd.OnLog(string userId, ILogInfo info)
        {
            try
            {
                switch (info.LogType)
                {
                case EnumLogType.Error:
                {
                    string descr = string.Format("Err: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                    Debug.Fail("SysteEventLogHnd: " + descr);
                    log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Error);
                }


                break;

                case EnumLogType.Message:
                    if (MsgInEventLogSchreiben)
                    {
                        string descr = string.Format("Msg: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                        Debug.WriteLine("SysteEventLogHnd: " + descr);
                        log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Information);
                    }
                    break;

                case EnumLogType.Status:
                    if (StatusInEventLogSchreiben)
                    {
                        string descr = string.Format("Sta: user= {0}: {1} / {2}", info.LogDate, userId, info.Message);
                        Debug.WriteLine("SysteEventLogHnd: " + descr);
                        log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Information);
                    }
                    break;

                default:
                {
                    string descr = string.Format("Unbekannter Logtyp: user= {0:s}: {1} / {2}", info.LogDate, userId, info.Message);
                    log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Error);
                    Debug.Fail("SysteEventLogHnd: " + descr);
                }
                break;
                }
            }
            catch (Exception ex)
            {
                SelfDeregisterILogHnd();
            }
        }
Пример #17
0
        public bool Create(IUser user)
        {
            IUserDao dao = AlbianServiceRouter.ObjectGenerator <UserDao, IUserDao>();
            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("创建用户,用户id为:{0}", user.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = user.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Registr;
            IList <IAlbianObject> infos = new List <IAlbianObject> {
                user, log
            };

            return(dao.Create(infos));
        }
Пример #18
0
 void ILogHnd.OnStatus(string userId, ILogInfo info)
 {
     try
     {
         if (StatusInEventLogSchreiben)
         {
             string descr = string.Format("Sta: user= {0}: {1} / {2}", userId, info.MessageCodeToString(), info.Message);
             Debug.WriteLine("SysteEventLogHnd: " + descr);
             log.WriteEntry(descr, System.Diagnostics.EventLogEntryType.Information);
         }
     }
     catch (Exception ex)
     {
         SelfDeregisterILogHnd();
     }
 }
Пример #19
0
        public virtual bool Modify(IBizOffer bizoffer)
        {
            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("修改发布单,发布单id为:{0}", bizoffer.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = bizoffer.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Publish;

            IList <IAlbianObject> list = new List <IAlbianObject> {
                bizoffer, log
            };
            IBizofferDao dao = AlbianServiceRouter.ObjectGenerator <BizofferDao, IBizofferDao>();

            return(dao.Modify(list));
        }
Пример #20
0
        void ILogHnd.OnLog(string userId, ILogInfo info)
        {
            switch (info.LogType)
            {
            case EnumLogType.Error:
                Console.WriteLine(string.Format("{0,-20:s}# {1,4}# Err# \"{2}\"", info.LogDate, userId, info.Message));
                break;

            case EnumLogType.Message:
                Console.WriteLine(string.Format("{0,-20:s}# {1,4}# Msg# \"{2}\"", info.LogDate, userId, info.Message));
                break;

            case EnumLogType.Status:
                Console.WriteLine(string.Format("{0,-20:s}# {1,4}# Sta# \"{2}\"", info.LogDate, userId, info.Message));
                break;

            default:;
                break;
            }
        }
Пример #21
0
        /// <summary>
        /// Logs ILogInfo LogInfo
        /// </summary>
        public virtual void Log(ILogInfo info)
        {
            string            logRecordId   = GetLogRecordId().ToString();
            string            timestamp     = Timestamp;
            FormattableString logInfoString = null;
            string            data;

            data          = FormatILogInfoData(info.Data);
            logInfoString = $@"| {{ Id: {CleanString(logRecordId)} }}
                            | {{ Timestamp: {CleanString(timestamp)} }}
                            | {{ Action: {CleanString(info.ActionName)} }} 
                            | {{ Controller: {CleanString(info.ActionName)} }}
                            | {{ Message: {CleanString(info.Message)} }}
                            | {{ Data: {CleanString(data)} }}";

            using (StreamWriter writer = new StreamWriter(LogFilePath))
            {
                writer.WriteLine(CleanString(logInfoString.ToString()));
            }
            return;
        }
Пример #22
0
        public void Log(ILogInfo logInfo)
        {
            if (logInfo == null)
            {
                return;
            }

            NLog.Logger logger = LogManager.GetCurrentClassLogger();

            LogManager.Configuration.Variables["userid"]   = logInfo.UserId.ToString();
            LogManager.Configuration.Variables["callsite"] = logInfo.CallSite;
            LogManager.Configuration.Variables["logtype"]  = logInfo.LogType.ToString();

            if (logInfo.Exception == null)
            {
                logger.Info(logInfo.Message);
            }
            else
            {
                logger.Error(logInfo.Exception, logInfo.Message);
            }
        }
Пример #23
0
        public bool Modify(string id, string nickName)
        {
            IUserDao dao  = AlbianServiceRouter.ObjectGenerator <UserDao, IUserDao>();
            IUser    user = dao.Load(id);

            user.Nickname       = nickName;
            user.LastMofidyTime = DateTime.Now;
            user.LastModifier   = id;

            ILogInfo log = AlbianObjectFactory.CreateInstance <LogInfo>();

            log.Content    = string.Format("修改用户,用户id为:{0}", user.Id);
            log.CreateTime = DateTime.Now;
            log.Creator    = user.Id;
            log.Id         = AlbianObjectFactory.CreateId("Log");
            log.Style      = InfoStyle.Modify;
            IList <IAlbianObject> infos = new List <IAlbianObject> {
                user, log
            };

            return(dao.Modify(infos));
        }
Пример #24
0
        /// <summary>
        /// 包括IClientLogInfo、IUserLogInfo、IWebLogInfo
        /// </summary>
        /// <param name="logInfo"></param>
        /// <returns></returns>
        protected ILogInfo GetLogInfo(ILogInfo logInfo)
        {
            if (logInfo == null)
            {
                return(logInfo);
            }

            IClientLogInfo clientLogInfo = GetClientLogInfo(logInfo);

            if (clientLogInfo != null && clientLogInfo is ILogInfo)
            {
                logInfo = clientLogInfo as ILogInfo;
            }

            IWebLogInfo webLogInfo = GetWebLogInfo(logInfo);

            if (webLogInfo != null && webLogInfo is ILogInfo)
            {
                logInfo = webLogInfo as ILogInfo;
            }

            return(logInfo);
        }
Пример #25
0
        public void OnLog(string userId, ILogInfo info)
        {
            var dp = new DockPanel();

            dp.HorizontalAlignment = HorizontalAlignment.Left;

            var Time = new TextBlock();

            SetMonospaced12pt(Time, BlueText);
            Time.Text          = info.LogDate.ToLongTimeString();
            Time.TextAlignment = TextAlignment.Center;
            Time.Width         = 80;

            dp.Children.Add(Time);

            var Info = new TextBlock();

            Info.HorizontalAlignment = HorizontalAlignment.Stretch;
            Info.Text = info.Message;

            if (info.LogType == EnumLogType.Error)
            {
                SetMonospaced12pt(Info, RedText);
            }
            else
            {
                SetMonospaced12pt(Info, BlueText);
            }

            dp.Children.Add(Info);

            lbx.Items.Add(new ListBoxItem()
            {
                Content = dp
            });
        }
Пример #26
0
 /// <inheritdoc />
 void IEventLogger.AddLog(ILogInfo logInfo)
 {
     LogController.Instance.AddLog((LogInfo)logInfo);
 }
Пример #27
0
 /// Override Base Log Method; Log The LogInfo Object
 /// </summary>
 public override void Log(ILogInfo info)
 {
     base.Log(info);
 }
Пример #28
0
 public void Log(ILogInfo info)
 {
     Log("*", info);
 }
Пример #29
0
 /// <inheritdoc />
 void IEventLogService.DeleteLog(ILogInfo logInfo)
 {
     LogController.Instance.DeleteLog((LogInfo)logInfo);
 }
Пример #30
0
        private string HashAlbianObjectHandlerByCreatrUser(IAlbianObject target)
        {
            ILogInfo user = (ILogInfo)target;

            return(string.Format("_{0}", user.Style == InfoStyle.Registr || user.Style == InfoStyle.Modify ? "user":string.Empty));
        }