public static async Task Main(string[] args) { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); LoggerSetup.Setup(configuration.HostLog, configuration.GraphiteServiceName); var optionsBuilder = new DbContextOptionsBuilder <UlearnDb>() .UseLazyLoadingProxies() .UseSqlServer(configuration.Database); var db = new UlearnDb(optionsBuilder.Options); var aOptionsBuilder = new DbContextOptionsBuilder <AntiPlagiarismDb>() .UseLazyLoadingProxies() .UseSqlServer(configuration.Database); var adb = new AntiPlagiarismDb(aOptionsBuilder.Options); //await ResendLti(db); //await FindExternalSolutionsPlagiarism.UploadSolutions(); //await FindExternalSolutionsPlagiarism.GetRawResults(); //await FindExternalSolutionsPlagiarism.PrepareResults(); //await UpdateExerciseVisits(db, "fpIntroduction"); //Users.PrintCourseAdmins(db); //await ScoresUpdater.UpdateTests(db, "java-rtf"); //GetMostSimilarSubmission(adb); //ParsePairWeightsFromLogs(); //GetBlackAndWhiteLabels(db, adb); //ParseTaskWeightsFromLogs(); //CampusRegistration(); //GetIps(db); //FillAntiplagFields.FillClientSubmissionId(adb); //await XQueueRunAutomaticChecking(db); }
public static void Main(string[] args) { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); var logsSubdirectory = configuration.GraphiteServiceName + (configuration.Environment == "staging" ? "-dev" : null); LoggerSetup.Setup(configuration.HostLog, logsSubdirectory); DirectoryInfo сompilerDirectory = null; if (args.Any(x => x.StartsWith("-p:"))) { var path = args.FirstOrDefault(x => x.StartsWith("-p:"))?.Substring(3); if (path != null) { сompilerDirectory = new DirectoryInfo(path); } } var isSelfCheck = args.Contains("--selfcheck"); var program = new Program(сompilerDirectory); if (isSelfCheck) { program.SelfCheck(); } else { program.Run(); } }
public static void Main(string[] args) { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); var logsSubdirectory = configuration.GraphiteServiceName + (configuration.Environment == "staging" ? "-dev" : null); LoggerSetup.Setup(configuration.HostLog, logsSubdirectory); try { var selfCheckIndex = args.FindIndex("--selfcheck"); var program = new Program(configuration.GraphiteServiceName); var hasNextArg = args.Length > selfCheckIndex + 1; if (selfCheckIndex >= 0 && hasNextArg) { program.SelfCheck(args[selfCheckIndex + 1]); } else { program.Run(); } } finally { FileLog.FlushAll(); } }
private static void SetupLog(IVostokCompositeLogBuilder logBuilder, UlearnConfiguration ulearnConfiguration) { var log = LoggerSetup.Setup(ulearnConfiguration.HostLog, ulearnConfiguration.GraphiteServiceName, false); logBuilder.AddLog(log); logBuilder.CustomizeLog(logCustomization => logCustomization.WithMinimumLevel(LogLevel.Debug)); const LogLevel minimumLevel = LogLevel.Info; var dbMinimumLevelString = ulearnConfiguration.HostLog.DbMinimumLevel ?? ""; if (!LoggerSetup.TryParseLogLevel(dbMinimumLevelString, out var dbMinimumLevel)) { dbMinimumLevel = minimumLevel; } var min = dbMinimumLevel > minimumLevel ? minimumLevel : dbMinimumLevel; logBuilder.SetupHerculesLog(herculesLogBuilder => { herculesLogBuilder.SetStream(ulearnConfiguration.Hercules.Stream); herculesLogBuilder.SetApiKeyProvider(() => ulearnConfiguration.Hercules.ApiKey); herculesLogBuilder.CustomizeLog(lb => lb .WithMinimumLevelForSourceContext("ULearnDb", dbMinimumLevel) // Database .WithMinimumLevel(min) ); }); }
public static void ConfigureLogging() { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); var log = LoggerSetup.Setup(configuration.HostLog, configuration.GraphiteServiceName, false) .WithProperty("user", () => new HttpContextUserNameProvider().ToString()) .WithProperty("address", () => new HttpContextAddressProvider().ToString()); Log.Logger = new LoggerConfiguration() .WriteTo.Sink(new VostokSink(log)) .CreateLogger(); SerilogWebClassic.Configure(cfg => cfg.UseLogger(Log.Logger)); LogProvider.Configure(log); }
static void Main(string[] args) { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); LoggerSetup.Setup(configuration.HostLog, configuration.GraphiteServiceName); /* Pass first argument 'send' to send emails to addresses from `emails.txt` with content from `content.txt` (notifications daemon is not started in this case)*/ if (args.Length > 0 && args[0] == "send") { var sender = new OneTimeEmailSender(); sender.SendEmailsAsync().Wait(); return; } new Program().MainLoop().Wait(); }
private static void Main(string[] args) { var settings = JObject.Parse(File.ReadAllText("appsettings.json")); var hostLog = settings["hostLog"].ToObject <HostLogConfiguration>(); var graphiteServiceName = settings["graphiteServiceName"].Value <string>(); LoggerSetup.Setup(hostLog, graphiteServiceName); try { var staff = new StaffClient(settings["staff"]["clientAuth"].Value <string>()); if (args.Contains("-r")) { Console.WriteLine("Username (example: KONTUR\\pe):"); var username = Console.ReadLine(); Console.WriteLine($"Password for {username}:"); var password = GetConsolePassword(); var refreshToken = staff.GetRefreshToken(username, password); Console.WriteLine($"RefreshToken: {refreshToken}"); return; } var telegramBot = new GiftsTelegramBot(); try { staff.UseRefreshToken(settings["staff"]["refreshToken"].Value <string>()); var maxGiftsPerRun = args.Length > 0 ? int.Parse(args[0]) : settings["maxGiftsPerRun"].Value <int>(); log.Info("UseGiftGrantsLimitPerRun\t" + maxGiftsPerRun); var db = new ULearnDb(); var repo = new VisitsRepo(db); var courses = settings["courses"].Values <string>(); var program = new Program(repo, staff, maxGiftsPerRun, settings, telegramBot); foreach (var courseId in courses) { program.GrantGiftsForCourse(courseId); } } catch (Exception e) { telegramBot.PostToChannel($"Error while grant staff gifts.\n\n{e}"); log.Error(e, "UnhandledException"); } } finally { FileLog.FlushAll(); } }
public static async Task Main(string[] args) { var configuration = ApplicationConfiguration.Read <UlearnConfiguration>(); LoggerSetup.Setup(configuration.HostLog, configuration.GraphiteServiceName); try { var optionsBuilder = new DbContextOptionsBuilder <UlearnDb>() .UseLazyLoadingProxies() .UseNpgsql(configuration.Database, o => o.SetPostgresVersion(13, 2)); var db = new UlearnDb(optionsBuilder.Options); var aOptionsBuilder = new DbContextOptionsBuilder <AntiPlagiarismDb>() .UseLazyLoadingProxies() .UseNpgsql(configuration.Database, o => o.SetPostgresVersion(13, 2)); var adb = new AntiPlagiarismDb(aOptionsBuilder.Options); var serviceProvider = ConfigureDI(adb, db); await Run(adb, db, serviceProvider); } finally { await FileLog.FlushAllAsync(); } }
private static void SetupLog(IVostokCompositeLogBuilder logBuilder, UlearnConfiguration ulearnConfiguration) { var log = LoggerSetup.Setup(ulearnConfiguration.HostLog, ulearnConfiguration.GraphiteServiceName, false); logBuilder.AddLog(log); logBuilder.CustomizeLog(logCustomization => logCustomization.WithMinimumLevel(LogLevel.Debug)); const LogLevel minimumLevel = LogLevel.Info; var dbMinimumLevelString = ulearnConfiguration.HostLog.DbMinimumLevel ?? ""; if (!LoggerSetup.TryParseLogLevel(dbMinimumLevelString, out var dbMinimumLevel)) dbMinimumLevel = minimumLevel; var min = dbMinimumLevel > minimumLevel ? minimumLevel : dbMinimumLevel; logBuilder.SetupHerculesLog(herculesLogBuilder => { herculesLogBuilder.SetStream(ulearnConfiguration.Hercules.Stream); herculesLogBuilder.SetApiKeyProvider(() => ulearnConfiguration.Hercules.ApiKey); herculesLogBuilder.CustomizeLog(lb => lb .DropEvents(LoggerSetup.FilterLogs) .SelectEvents(le => le.Level >= (LoggerSetup.IsDbSource(le) ? dbMinimumLevel : minimumLevel)) .WithMinimumLevel(min) ); }); }
private ServiceProvider GetServiceProvider() { var configuration = ApplicationConfiguration.Read <AntiPlagiarismUpdateDbConfiguration>(); var services = new ServiceCollection(); services.AddOptions(); services.Configure <AntiPlagiarismUpdateDbConfiguration>(ApplicationConfiguration.GetConfiguration()); services.Configure <AntiPlagiarismConfiguration>(ApplicationConfiguration.GetConfiguration()); LoggerSetup.Setup(configuration.HostLog, configuration.GraphiteServiceName); services.AddScoped(_ => GetDatabase(configuration)); services.AddScoped <AntiPlagiarismSnippetsUpdater>(); services.AddScoped <ISnippetsRepo, SnippetsRepo>(); services.AddScoped <ISubmissionsRepo, SubmissionsRepo>(); services.AddSingleton <CSharpCodeUnitsExtractor>(); services.AddSingleton <CodeUnitsExtractor>(); services.AddSingleton <TokensExtractor>(); services.AddSingleton <SnippetsExtractor>(); services.AddSingleton <SubmissionSnippetsExtractor>(); return(services.BuildServiceProvider()); }