示例#1
0
		/// <summary>
		/// Регистрирует настройку для типа сообщений
		/// </summary>
		/// <param name="configuration"></param>
		public void Register(SessionLogTypeConfiguration configuration){
			_config[configuration.Code] = configuration;
		}
示例#2
0
 /// <summary>
 /// Регистрирует настройку для типа сообщений
 /// </summary>
 /// <param name="configuration"></param>
 public void Register(SessionLogTypeConfiguration configuration)
 {
     _config[configuration.Code] = configuration;
 }
示例#3
0
		private LogMessage ProcessConfigured(LogMessage message, SessionLogTypeConfiguration cfg){
			lock (this){
				var realmessage = _log.FirstOrDefault(
					_ =>
					_.Code == message.Code &&
					(cfg.IsSingleton || (cfg.RequireAccept && !_.Accepted)));

				if (null == realmessage){
					_log.Add(message);
					realmessage = message;
				}
				else{
					bool changed = !string.IsNullOrWhiteSpace(message.Message) && (message.Message != realmessage.Message);
					changed = changed || message.Level != realmessage.Level;
					changed = changed || message.ETag != realmessage.ETag;
					if (!changed){
						if (null != message.Data && null != realmessage.Data){
							if (null != cfg.CustomComparer){
								changed = !cfg.CustomComparer.Equals(message.Data, realmessage.Data);
							}
							else{
								changed = !message.Data.Equals(realmessage.Data);
							}
						}
						else{
							if (null != message.Data || null != realmessage.Data){
								changed = true;
							}
						}
					}
					if (!changed) return realmessage;
					if (message.Time > realmessage.Time && cfg.UpgradeTime){
						realmessage.Time = message.Time;
					}
					realmessage.Level = message.Level;
					if (!string.IsNullOrWhiteSpace(message.Message)){
						realmessage.Message = message.Message;
					}
					realmessage.ETag = message.ETag;
					realmessage.Accepted = message.Accepted;

					realmessage.Data = message.Data;
				}

				if (cfg.RequireAccept){
					realmessage.RequireAccept = true;
				}
				if (realmessage.Level < cfg.AutoAcceptBelow){
					realmessage.Accepted = true;
				}
				if (realmessage.Level < cfg.AutoRemoveBelow){
					realmessage.Active = false;
				}

				return realmessage;
			}
		}
示例#4
0
        private LogMessage ProcessConfigured(LogMessage message, SessionLogTypeConfiguration cfg)
        {
            lock (this){
                var realmessage = _log.FirstOrDefault(
                    _ =>
                    _.Code == message.Code &&
                    (cfg.IsSingleton || (cfg.RequireAccept && !_.Accepted)));

                if (null == realmessage)
                {
                    _log.Add(message);
                    realmessage = message;
                }
                else
                {
                    bool changed = !string.IsNullOrWhiteSpace(message.Message) && (message.Message != realmessage.Message);
                    changed = changed || message.Level != realmessage.Level;
                    changed = changed || message.ETag != realmessage.ETag;
                    if (!changed)
                    {
                        if (null != message.Data && null != realmessage.Data)
                        {
                            if (null != cfg.CustomComparer)
                            {
                                changed = !cfg.CustomComparer.Equals(message.Data, realmessage.Data);
                            }
                            else
                            {
                                changed = !message.Data.Equals(realmessage.Data);
                            }
                        }
                        else
                        {
                            if (null != message.Data || null != realmessage.Data)
                            {
                                changed = true;
                            }
                        }
                    }
                    if (!changed)
                    {
                        return(realmessage);
                    }
                    if (message.Time > realmessage.Time && cfg.UpgradeTime)
                    {
                        realmessage.Time = message.Time;
                    }
                    realmessage.Level = message.Level;
                    if (!string.IsNullOrWhiteSpace(message.Message))
                    {
                        realmessage.Message = message.Message;
                    }
                    realmessage.ETag     = message.ETag;
                    realmessage.Accepted = message.Accepted;

                    realmessage.Data = message.Data;
                }

                if (cfg.RequireAccept)
                {
                    realmessage.RequireAccept = true;
                }
                if (realmessage.Level < cfg.AutoAcceptBelow)
                {
                    realmessage.Accepted = true;
                }
                if (realmessage.Level < cfg.AutoRemoveBelow)
                {
                    realmessage.Active = false;
                }

                return(realmessage);
            }
        }