private void WriteFiles(CaseType caseType, DistrictsScenario scenario, IDictionary <string, List <int> > dict) { List <string> lines = new List <string>(); foreach (string key in dict.Keys) { string line = ""; Console.Write(key + " "); line = line + (key + ","); foreach (int i in dict[key]) { Console.Write(i + ","); line = line + (i + ","); } Console.WriteLine(); //lines.Add(""); lines.Add(line); } using (StreamWriter op = new StreamWriter("districs_data_" + caseType.ToString().ToLower() + "_" + scenario.name + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".csv")) { foreach (string line in lines) { op.WriteLine(line); } op.Flush(); } }
public EmbedBuilder ToEmbedBuilder(DiscordSocketClient client) { var guild = client?.GetGuild(GuildId); var moderator = guild?.GetUser(ModeratorId); var builder = new EmbedBuilder(); bool isTemporary = this.IsTempCase(); builder.AddField("Type:", CaseType.ToString(), true); if (moderator != null) { builder.AddField("Admin:", moderator.Username, true); } builder.AddField("Created:", CreatedOn.ToLocalTime().ValueToString(), true); builder.AddField("Expires:", isTemporary ? ExpiresOn.ToLocalTime().ValueToString() : "-", true); builder.AddField("Reason:", Reason); return(builder); }
public static async Task LogCaseAsync(DatabaseContext database, SocketGuild socketGuild, SocketUser user, SocketUser mod, CaseType caseType, string reason = null) { var guild = await database.Guilds.AsNoTracking().Include(x => x.Cases).FirstAsync(x => x.GuildId == socketGuild.Id); reason = reason ?? "No Reason Specified"; var modChannel = socketGuild.GetTextChannel(guild.CaseLogChannel); IUserMessage message = null; if (!(modChannel is null)) { var cases = guild.Cases.Where(x => x.UserId == user.Id); var embed = EmbedHelper.Embed(EmbedHelper.Case) .WithAuthor("Case Number: " + guild.Cases.Count + 1) .WithTitle(caseType.ToString()) .AddField("User", user.Mention + " `" + user + "` (" + user.Id + ")") .AddField("History", "Cases: " + cases.Count() + "\n" + "Warnings: " + cases.Count(x => x.CaseType == CaseType.Warning) + "\n" + "Mutes: " + cases.Count(x => x.CaseType == CaseType.Mute) + "\n" + "Auto Mutes: " + cases.Count(x => x.CaseType == CaseType.AutoMute) + "\n") .AddField("Reason", reason) .AddField("Moderator", mod) .WithCurrentTimestamp() .Build(); message = await modChannel.SendMessageAsync(embed : embed); } await database.Cases.AddAsync(new Case { UserId = user.Id, Reason = reason, CaseType = caseType, ModeratorId = mod.Id, CaseDate = DateTime.Now, Number = guild.Cases.Count + 1, MessageId = message?.Id ?? 0, GuildId = guild.Id }); await database.SaveChangesAsync(); }
private async Task BuildCasesAsync(string selection) { IList <ICase> casesData; try { _isBusyBuildCases = true; if (_caseType == CaseType.SF) { casesData = await Task.Run(() => SFConnector.Instance.GetCasesAsync(selection)); } else { throw new ArgumentException($"CaseType is not set to a proper type: {_caseType.ToString()}"); } } finally { _isBusyBuildCases = false; } LoggerController.Log(casesData.Count + $" {_caseType.ToString()} cases Retrived."); Cases = new ObservableCollection <ICase>(casesData); SelectedCase = (Cases.Count > 0) ? Cases[0] : default(ICase); }
public static RepositoryFactory getInstance(CaseType caseType) { return((RepositoryFactory)(HttpContext.Current.Items["RepositoryFactory" + caseType.ToString()] ?? (HttpContext.Current.Items["RepositoryFactory" + caseType.ToString()] = new RepositoryFactory(caseType)))); }
public void SetCaseType(CaseType caseType = null) { caseType ??= CaseType.FromString(_c.Test.TestData.HearingDetails.CaseType); _c.Test.HearingDetails.CaseType = CaseType.FromString(_c.Test.TestData.HearingDetails.CaseType); _commonSharedSteps.WhenTheUserSelectsTheOptionFromTheDropdown(_browsers[_c.CurrentUser].Driver, HearingDetailsPage.CaseTypeDropdown, CaseType.ToString(caseType)); }
public override string ToString() { return(Name + " (" + Culture.Get(CaseType.ToString()) + ")"); }