public void SetStatus(string new_status, StatusTypes StatusType = StatusTypes.SetValueStatus) { if (string.IsNullOrWhiteSpace(new_status) && string.IsNullOrWhiteSpace(protected_Status)) { AppLogger.LogTrace("Попытка установить статус null на null. Проигнорировано."); return; } if (string.IsNullOrWhiteSpace(new_status) && StatusType != StatusTypes.SystemStatus) { StatusType = StatusTypes.DebugStatus; } switch (StatusType) { case StatusTypes.SetValueStatus: AppLogger.LogWarning(new_status); break; case StatusTypes.ErrorStatus: AppLogger.LogError(new_status); break; case StatusTypes.DebugStatus: AppLogger.LogDebug(new_status); break; case StatusTypes.SystemStatus: AppLogger.LogDebug("status set null"); break; default: AppLogger.LogCritical("Тип статуса [" + StatusType.ToString() + "] за пределами доступных значений: " + new_status); break; } protected_Status = new_status; lock (TracertChangeStatus) { TracertChangeStatus.Add(new TracertItemModel() { DateCreate = DateTime.Now, Information = new_status, TypeTracert = StatusType, Id = TracertChangeStatus.Count + 1 }); TracertChangeStatus = new ConcurrentBag <TracertItemModel>(TracertChangeStatus.OrderByDescending(x => x.DateCreate)); if (TracertChangeStatus.Count() > MaximumSizeSchedulerStatusTraceStack + 10) { TracertChangeStatus = new ConcurrentBag <TracertItemModel>(TracertChangeStatus.Skip(TracertChangeStatus.Count() - MaximumSizeSchedulerStatusTraceStack)); } if (StartChangeStatusDateTime.AddSeconds(MaximumLifetimeSchedulerStatusTrace) < DateTime.Now) { TracertChangeStatus = new ConcurrentBag <TracertItemModel>(TracertChangeStatus.Where(x => x.DateCreate > DateTime.Now.AddSeconds(-MaximumLifetimeSchedulerStatusTrace))); } } }