public ErrorModel MapEntity(Error entity) { Guid = entity.Guid; ApplicationName = entity.ApplicationName; Host = entity.Host; Type = entity.Type; Source = entity.Source; Message = entity.Message; User = entity.User; Time = entity.Time; DateCreated = entity.Time.ToFriendly(); RelativeTime = entity.Time.ToRelativeString(AppTime.Now()); StatusCode = entity.StatusCode; Browser = entity.Browser; Detail = entity.Detail; ServerVariables = entity.ServerVariables ?? new Dictionary <string, string>(); QueryString = entity.QueryString ?? new Dictionary <string, string>(); Form = entity.Form ?? new Dictionary <string, string>(); Cookies = entity.Cookies ?? new Dictionary <string, string>(); CustomData = entity.CustomData ?? new Dictionary <string, string>(); Severity = entity.Severity; IsCustom = entity.IsCustom; Url = entity.Url; Method = entity.Method; Log = new LogModel { LogId = entity.LogId }; return(this); }
public static void SeedLogs() { GrowlHelper.SimpleGrowl("Seeding Legacy Logs"); var lines = File.ReadAllLines(Path.Combine(AppPaths.Instance.GetMigrationDataFolder(), "legacy_logs.csv")).Select(a => a.Split(';')); var repo = new LogRepository(); foreach (var l in lines) { var x = new Log(); x.DateCreated = DateTime.Parse(l.First().Split(',')[0].Trimmed()); x.DateModified = AppTime.Now(); x.LogId = l.First().Split(',')[2].Trimmed(); x.Name = l.First().Split(',')[3].Trimmed(); x.UserId = l.First().Split(',')[4].Trimmed(); x.ShortName = l.First().Split(',')[5].Trimmed(); x.WidgetColor = l.First().Split(',')[6].Trimmed(); var existing = repo.FindByLogId(x.LogId); if (!existing.Any()) { repo.Add(x); } } }
public CallForSpeech(CallForSpeechNumber number, Speech speech, Speaker speaker, Category cat) : this(number, CallForSpeechStatus.New, speaker, speech, cat, null, new Registration(AppTime.Now()), null, null, new CallForSpeechId(0)) { }
public void Accept(Judge decisionBy) { if (Status == CallForSpeechStatus.AcceptedByJudge) { throw new ApplicationException("You already Accepted this CallForSpeech"); } if (Status == CallForSpeechStatus.Rejected) { throw new ApplicationException("Cannot accept application that is already rejected"); } if (Status != CallForSpeechStatus.PreliminaryAcceptedByJudge) { throw new ApplicationException("Cannot accept application that wasn't PreliminaryAccepted FIRST"); } if (ScoreResult == null) { throw new ApplicationException("Cannot accept application before scoring"); } if (!decisionBy.CanAccept(this.Category.Id)) { throw new ApplicationException("Judge is from diffrent category. Can't Accept"); } Status = CallForSpeechStatus.AcceptedByJudge; FinalDecision = new Decision(AppTime.Now(), decisionBy); }
public ExecutionStatus TryPreliminaryAccept(Judge decisionBy) { if (Status == CallForSpeechStatus.PreliminaryAcceptedByJudge) { return(ExecutionStatus. LogicError("You already PreliminaryAcceptedByJudge this CallForSpeech")); } if (Status != CallForSpeechStatus.EvaluatedByMachine) { return(ExecutionStatus.LogicError("Cannot accept application that WASNT'T in EvaluatedByMachine")); } if (ScoreResult == null) { return(ExecutionStatus.LogicError("Cannot accept application before scoring")); } if (!decisionBy.CanAccept(this.Category.Id)) { return(ExecutionStatus. LogicError("Judge is from diffrent category. Can't Accept")); } Status = CallForSpeechStatus.PreliminaryAcceptedByJudge; PreliminaryDecision = new Decision(AppTime.Now(), decisionBy); return(ExecutionStatus.LogicOk()); }
public async Task <ExecutionStatus> Run(CallForSpeechId id, JudgeId judge, CallForSpeechStatus status) { using var connection = new SqliteConnection(_geekLemonContext.ConnectionString); var q = @"UPDATE CallForSpeakes SET FinalDecision_DecisionBy = @JudgeId, FinalDecision_Date = @Date, Status = @Status WHERE Id = @Id;"; try { var result = await connection.ExecuteAsync(q, new { @JudgeId = judge.Value, @Date = AppTime.Now().ToLongDateString(), @Id = id.Value, @Status = (int)status }); return(ExecutionStatus.DbOk()); } catch (Exception ex) { if (ExecutionFlow.Options.ThrowExceptions) { throw; } return(ExecutionStatus.DbError(ex)); } }
public static string GenerateZipName(int count) { return(count + "-inbox-files-" + AppTime.Now().ToString("MM_dd_yyyy", CultureInfo.InvariantCulture) + "_" + ShortGuid.NewGuid() + ".zip"); }
void log(Guid?conversationId, object message, Exception ex = null) { this.LogInfo($"${conversationId} - {AppTime.Now()} - {message.GetType().FullName} - {JsonConvert.SerializeObject(message)}"); if (ex != null) { this.LogException(ex); } }
public static DateTime AdjustUploadDate(this DateTime uploadDate) { if (uploadDate > AppTime.Now()) { uploadDate = AppTime.Now(); } return(uploadDate); }
public static Log ToNewEntity(this LogModel m) { var x = new Log { DateCreated = AppTime.Now(), Name = m.Name, LogId = Guid.NewGuid().ToString(), WidgetColor = m.WidgetColor, ShortName = m.Name.GetRandomLetters(2) }; return(x); }
public User ToEntity(UserModel m) { var x = new User(); x.FirstName = m.FirstName; x.LastName = m.LastName; x.Email = m.Email; x.DateCreated = IsNullOrEmpty(m.DateCreated) ? DateTime.UtcNow : DateTime.Parse(m.DateCreated); x.DateModified = AppTime.Now(); x.IsActive = m.IsActive; x.PictureUrl = m.PictureUrl; return(x); }
public static User UpdateFromModel(this User entity, UserModel model) { entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.DateModified = AppTime.Now(); entity.IsActive = model.IsActive; entity.Name = model.Name; entity.PictureUrl = model.PictureUrl; entity.Auth0Id = model.UserId; entity.DateCreated = string.IsNullOrEmpty(model.DateCreated) ? AppTime.Now() : DateTime.Parse(model.DateCreated); return(entity); }
public async Task <IHttpActionResult> Update(LogModel model) { try { var log = await _logRepository.FindByLogIdAsync(model.LogId); if (log == null) { return(BadRequest(ResponseMessages.LogNotFound.ToDesc())); } if (log.Name != model.Name && await _logRepository.LogAlreadyExistsAsync(model.Name, log.UserId)) { return(BadRequest(ResponseMessages.LogNameDuplicate.ToDesc())); } log.WidgetColor = model.WidgetColor; log.Name = model.Name; log.DateModified = AppTime.Now(); await _logRepository.UpdateAsync(log); var notification = CreateNotification(log, model); await _notificationRepository.CreateOrUpdate(notification); var isExist = await _notificationRepository.IsUserSubscribedToDigestAsync(notification.UserId); if (isExist) { _jobRunner.CreateDigestEmailJobIfNotExists(notification); } else { _jobRunner.DeleteDigestEmailJobIfExists(notification); } this.LogInfo(IsDbUser ? $"{CurrentUser.FullName} updatd log with id {model.LogId}" : $"{Auth0User.Email} updated log with id {model.LogId}"); return(Ok(ResponseMessages.LogAdded.ToDesc())); } catch (Exception ex) { this.LogInfo($"{CurrentUserId} tried to updated log with error: {ex.InnerException.Message}"); } return(InternalServerError()); }
public void Reject(Judge decisionBy) { if (Status == CallForSpeechStatus.Rejected || Status == CallForSpeechStatus.AcceptedByJudge) { throw new ApplicationException("Cannot reject application that is already accepted or rejected"); } if (!decisionBy.CanAccept(this.Category.Id)) { throw new ApplicationException("Judge is from diffrent category. Can't Accept"); } Status = CallForSpeechStatus.Rejected; FinalDecision = new Decision(AppTime.Now(), decisionBy); }
public static string ToServerPath(this string baseDir, User user) { string filePath = Path.Combine( baseDir, AppTime.Now().Year.ToString(), AppTime.Now().ToString("MMM", CultureInfo.InvariantCulture), AppTime.Now().ToString("MM_dd_yyyy", CultureInfo.InvariantCulture), user.Email ); var outputDir = new DirectoryInfo(filePath); if (!Directory.Exists(outputDir.FullName)) { Directory.CreateDirectory(outputDir.FullName); } return(outputDir.FullName); }
public static List <LogModel> ToToday(this List <LogModel> items, IErrorRepository errorRepository) { var startDate = AppTime.Now().StartOfDay().AddDays(-1); var endDate = AppTime.Now().EndOfDay(); foreach (var m in items) { m.Errors = new List <ErrorModel>(); m.Errors = errorRepository.FindByLogId(m.LogId, startDate, endDate, DefaultQueryLimitSize) .Select(x => new ErrorModel().MapEntity(x)) .ToList(); m.LatestErrorCount = errorRepository.CountForPeriodAsync(m.LogId, startDate, endDate).Result; } return(items); }
public User ToNewLicensedUser(UserModel m) { var x = new User { FirstName = m.FirstName, LastName = m.LastName, Email = m.Email, DateCreated = IsNullOrEmpty(m.DateCreated) ? AppTime.Now() : DateTime.Parse(m.DateCreated), DateModified = AppTime.Now(), IsActive = true, IsDeleted = false, PictureUrl = m.PictureUrl, Name = m.Name, Auth0Id = m.UserId }; return(x); }
public ExecutionStatus TryReject(Judge decisionBy) { if (Status == CallForSpeechStatus.Rejected || Status == CallForSpeechStatus.AcceptedByJudge) { return(ExecutionStatus. LogicError("Cannot reject application that is already accepted or rejected")); } if (!decisionBy.CanAccept(this.Category.Id)) { return(ExecutionStatus. LogicError("Judge is from diffrent category. Can't Accept")); } Status = CallForSpeechStatus.Rejected; FinalDecision = new Decision(AppTime.Now(), decisionBy); return(ExecutionStatus.LogicOk()); }
public bool IsSatisfiedBy(CallForSpeech cfs) { return(cfs.Speaker.AgeInYearsAt(AppTime.Now()) < 70.Years()); }
public override DateTime?Next(IGenerationContext context) { return(AppTime.Now()); }
public SpeakerBuilder WithAge(int age) { this.birthDate = AppTime.Now().AddYears(-1 * age); return(this); }
protected DomainEvent(int version) { TimeStamp = AppTime.Now(); Version = version; }
public async Task ReassignLogsOwnerAsync(string currentOwnerId, string newOwnerId) { var items = await _collection.Find(x => x.UserId == currentOwnerId).ToListAsync(); foreach (var item in items) { var filter = Builders <Log> .Filter.Eq("LogId", item.LogId); var update = Builders <Log> .Update.Set("Owner.UserId", newOwnerId).Set("DateModified", AppTime.Now()); await _collection.UpdateOneAsync(filter, update); } }