Skip to content

Instantly share code, notes, and snippets.

@maor365scores
Created June 14, 2022 07:33
Show Gist options
  • Save maor365scores/0f9c00248888de76e5ad73f765c1b524 to your computer and use it in GitHub Desktop.
Save maor365scores/0f9c00248888de76e5ad73f765c1b524 to your computer and use it in GitHub Desktop.
if (update.CreateGame && createGamePriority != DataSourcesDAL.EPriorityLevel.Ignore)
{
bool bWasDeleted = IsDeleted;
IsDeleted = false;
if (bWasDeleted && createGamePriority != DataSourcesDAL.EPriorityLevel.Neutral)
{
CreateUpdate(update, EUpdateTypes.NewGame);
GamesDal.UpdateGameLastUpdateTime(ID, DateTime.UtcNow);
try
{
// check if in the destination start time range there is already a game
long nOtherGame = Consts.NOT_GIVEN;
if (GamesDal.CheckIfGameExist(Competition.ID, StartTime, update.CompetitorsParsedIDs,
ID, out nOtherGame, Competition.RecognitionTimeSpan))
{
// Try to delete the game
CGame OtherGame = General.Games[nOtherGame];
if (OtherGame != null)
{
OtherGame.DeleteGame();
}
}
}
catch (Exception e)
{
ExceptionsHandler.HandleException(e);
}
}
else
{
// Update last update time for this game, if wasn't updated for the last 5 minutes
// Todo: Make Async
if (!IsDeleted && DateTime.UtcNow.Subtract(LastUpdateTime) > TimeSpan.FromMinutes(5))
{
UpdateGameLastUpdateTime();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment