public void Fill(ParticipantList participants) { if (participants == null) { return; } tableParticipants.TableModel.Rows.Clear(); foreach (Participant p in participants) { Cell[] cells = new Cell[4]; //string[] cells = new string[4]; cells[0] = new Cell(p.Role); cells[1] = new Cell(p.Name); if (p.TrackNumber > 0) { cells[2] = new Cell(p.TrackNumber); } else { cells[2] = new Cell(""); } cells[3] = new Cell(p.Comment); XPTable.Models.Row row = new XPTable.Models.Row(cells); tableParticipants.TableModel.Rows.Add(row); } }
public void TestParseToText() { var list = new ParticipantList(); list.Name = "ToText"; list.Add(new Participant() { Name = "Tim", Email = "*****@*****.**" }); list.Add(new Participant() { Name = "Tom", Email = "*****@*****.**" }); string expected = @"Name: ToText Tim <*****@*****.**> Tom <*****@*****.**> "; Assert.AreEqual(expected, FileParser.ParseToText(list)); }
public static IList <Participant> GetConferenceParticipantsList(string conferenceId) { string acctId = getAcctId(); string apiKey = getApiKey(); IList <Participant> ret = new List <Participant> (); FreeClimbClient client = new FreeClimbClient(acctId, apiKey); // the last two parameters are to filter on the participants talk and listen properties respectively ParticipantList participantList = client.getConferencesRequester.getParticipants(conferenceId); if (participantList.getTotalSize > 0) { // Retrieve all pages of results while (participantList.getLocalSize < participantList.getTotalSize) { participantList.loadNextPage(); } foreach (IFreeClimbCommon item in participantList.export()) { Participant participant = item as Participant; // do whatever you need to do with participant object which contains all the conference properties ret.Add(participant); } } return(ret); }
private void when(ParticipantsListUpdated e) { this.ParticipantList.ToList().RemoveAll(participant => !e.ParticipantList.Contains(participant.UserId)); e.ParticipantList.ToList().Except(ParticipantList.Select(p => p.UserId)).ToList() .ForEach(p => this.ParticipantList.Add(new Participant(p, EventAcceptanceState.Pending))); this.Id = e.AggregateId; }
public static ParticipantList ParseList(string content) { ParticipantList list = new ParticipantList(); var lines = content.Split('\n'); if (!lines[0].StartsWith("Name:")) { throw new Exception("Parse Error, textfile is missing a name on line 1"); } list.Name = lines[0].Substring(5).Trim(); for (int i = 1; i < lines.Length; i++) { if (string.IsNullOrWhiteSpace(lines[i])) { continue; } if (!lines[i].Contains("<") && !lines[i].Contains(">")) { throw new Exception($"Parse Error, invalid participant Syntax on line {i + 1}"); } list.Add(new Participant() { Name = lines[i].Substring(0, lines[i].IndexOf("<")).Trim(), Email = DetermineEmail(lines[i]) } ); } return(list); }
public IActionResult ViewLeaveActivity(int activityId) { ParticipantList participantToRemove = dbContext.ParticipantLists.Where(participant => participant.ActivityId == activityId).FirstOrDefault(p => p.UserId == HttpContext.Session.GetInt32("UserId")); dbContext.ParticipantLists.Remove(participantToRemove); dbContext.SaveChanges(); return(RedirectToAction("ViewActivity", new { activityId = activityId })); }
private int FetchId(ParticipantList list) { int amountLeft = this.GiveToList.Count; var random = new Random(); int id = random.Next(0, amountLeft + 1); return(id); }
// GET: participant public ActionResult Index() { var UserSession = (CustomerDetail)Session["ChitaleUser"]; ParticipantList objlist = new ParticipantList(); List <ParticipantList> lstparticipantLists = new List <ParticipantList>(); lstparticipantLists = pr.GetParticipantList(UserSession.CustomerId, UserSession.Type); return(View(lstparticipantLists)); }
public static string ParseToText(ParticipantList participants) { string text = $"Name: {participants.Name} \r\n"; foreach (var participant in participants) { text += $"{participant.Name} <{participant.Email}> \r\n"; } return(text); }
public IActionResult ViewJoinActivity(int activityId) { ParticipantList participantToAdd = new ParticipantList() { UserId = (int)HttpContext.Session.GetInt32("UserId"), ActivityId = activityId }; dbContext.ParticipantLists.Add(participantToAdd); dbContext.SaveChanges(); return(RedirectToAction("ViewActivity", new { activityId = activityId })); }
public JsonResult GetNestedParticipantList(string customerId, string CustomerType) { //var UserSession = (CustomerDetail)Session["ChitaleUser"]; ParticipantList objlist = new ParticipantList(); List <ParticipantList> lstparticipantLists = new List <ParticipantList>(); lstparticipantLists = pr.GetParticipantList(customerId, CustomerType); return(new JsonResult() { Data = lstparticipantLists, JsonRequestBehavior = JsonRequestBehavior.AllowGet, MaxJsonLength = Int32.MaxValue }); }
/// <summary> /// Connects the GUI (e.g. Data Grids, ...) to the data model /// </summary> private void ConnectGUIToParticipants() { // Connect with GUI DataGrids ObservableCollection <Participant> participants = _dm.GetParticipants(); _editParticipants = new ParticipantList(participants, _dm, new IImportListProvider[] { _dsvData, _fisData }); _viewParticipants = new CollectionViewSource(); _viewParticipants.Source = _editParticipants; dgParticipants.ItemsSource = _viewParticipants.View; createParticipantOfRaceColumns(); createParticipantOfRaceCheckboxes(); }
public ParticipantList GetData() { ParticipantList participants = new ParticipantList(); int i = 0; foreach (XPTable.Models.Row row in tableParticipants.TableModel.Rows) { Participant newParticipant = new Participant(); newParticipant.Role = row.Cells[0].Text; newParticipant.Name = row.Cells[1].Text; if (row.Cells[2].Data != null) { try { newParticipant.TrackNumber = (int)row.Cells[2].Data; } catch { } } newParticipant.Comment = row.Cells[3].Text; participants.Add(newParticipant); i++; } return(participants); }
private static void Main(string[] args) { if (args == null || !args.Any()) { Console.Error.WriteLine("Specify a .json settings file path as the first argument."); return; } string smtpHost = Environment.GetEnvironmentVariable("SMTP_HOST")?.Trim(); string smtpUser = Environment.GetEnvironmentVariable("SMTP_USER")?.Trim(); string smtpPass = Environment.GetEnvironmentVariable("SMTP_PASS")?.Trim(); string wishListLink = Environment.GetEnvironmentVariable("WISHLIST_LINK")?.Trim(); if (string.IsNullOrEmpty(smtpHost) || string.IsNullOrEmpty(smtpUser) || string.IsNullOrEmpty(smtpPass) || string.IsNullOrEmpty(wishListLink)) { Console.Error.WriteLine("Please specify the following environment variables: SMTP_HOST, SMTP_USER, SMTP_PASS, WISHLIST_LINK"); return; } try { _settings = Settings.Load(args[0]); _participants = _settings.Participants; // Main selection loop while (true) { // Pre-matches var preSelectedGivers = new List <Participant>(); if (_settings.PreMatches != null) { foreach (var match in _settings.PreMatches) { var from = _participants.GetParticipantByEmail(match.FromEmail); var to = _participants.GetParticipantByEmail(match.ToEmail); _matches.Add(new Match(from, to)); preSelectedGivers.Add(from); } } // Random matches var r = new Random(); bool reset = false; foreach (var from in _participants.Except(preSelectedGivers)) { var candidates = GetCandidatesForParticipant(from); if (!candidates.Any()) { // Bad run, reset and try again reset = true; break; } var to = candidates[r.Next(0, candidates.Count)]; // Choose a receiver at random _matches.Add(new Match(from, to)); } if (reset) { Console.WriteLine("Bad run, trying again..."); _matches.Clear(); continue; } // Sanity check if (_matches.Count != _participants.Count) { Console.Error.WriteLine("Something really weird happened, trying again..."); _matches.Clear(); continue; } break; } Console.WriteLine("Matches selected! Sending emails..."); Console.WriteLine(); // Send mail var smtpClient = new SmtpClient(smtpHost) { Credentials = new NetworkCredential(smtpUser, smtpPass), EnableSsl = true }; Email.DefaultSender = new SmtpSender(smtpClient); foreach (var match in _matches) { Console.WriteLine($"Sending email to {match.From.Email}..."); var email = Email.From(smtpUser) .To(match.From.Email) .Subject($"Hey {match.From.Name}! Your secret santa has been chosen.") .Body($"Your secret santa recipient this year is <b>{match.To.Name}</b>!<br><br><img src=\"{match.To.ImageUrl}\" alt=\"{match.To.Name}\"/><br><br>To see their wishlist and to fill out your own, go here!: <a href=\"{wishListLink}\" _target=\"blank\">{wishListLink}</a>", isHtml: true) .Send(); if (email.Successful) { Console.WriteLine($"Sent email to {match.From.Email}."); } else { Console.Error.WriteLine($"Failed to send to {match.From.Email}. Errors: {string.Join(", ", email.ErrorMessages)}"); } } Console.WriteLine(); Console.WriteLine("Done!"); } catch (Exception e) { Console.Error.WriteLine($"{e.GetType().Name}: {e.Message}"); } }
public void ReadData() { this.content = File.ReadAllText(this.Path); this.Participants = FileParser.ParseList(this.content); }
public DataFile() { this.Participants = new ParticipantList(); }
private void OnLoaded(string obj) { ParticipantList.Add(new ClientModel { Id = FIRST_PARTICIPANT, TitleName = "(空)", IsSelected = false }); foreach (Participant person in AppContext.Default.MeetingDetail.Participants) { if ((person.TitleGroup == 0 || person.TitleGroup == 1 || person.TitleGroup == 2) && !(UtilsMethods.Decrypt(person.Name) == "原告席") && !(UtilsMethods.Decrypt(person.Name) == "被告席")) { ParticipantList.Add(new ClientModel { Id = person.Id, TitleName = person.Title + "-" + UtilsMethods.Decrypt(person.Name), TitleGroup = person.TitleGroup, Title = person.Title, Name = UtilsMethods.Decrypt(person.Name), }); } } clientModelsList = ParticipantList.ToList(); ClientModel clientModel = clientModelsList[0]; MicrophoneList = new ObservableCollection <MicrophoneModel> { new MicrophoneModel { MicrophoneId = "(1)", MicPort = ConfigFile.micPort1of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(2)", MicPort = ConfigFile.micPort2of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(3)", MicPort = ConfigFile.micPort3of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(4)", MicPort = ConfigFile.micPort4of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(5)", MicPort = ConfigFile.micPort5of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(6)", MicPort = ConfigFile.micPort6of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(7)", MicPort = ConfigFile.micPort7of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(8)", MicPort = ConfigFile.micPort8of9, SelectedClient = clientModel }, new MicrophoneModel { MicrophoneId = "(9)", MicPort = ConfigFile.micPort9of9, SelectedClient = clientModel }, }; _asrManager = AsrServerManager.GetInstance(_nemo, _dataService, _eventAggregator); List <string> res = _asrManager.GetAsrMicrophoneConfig(); if (res != null && res.Count > 0) { for (int i = 0; i < res.Count; i++) { MicrophoneList[i].TitleName = res[i]; string title = string.Empty, name = string.Empty; ConvertString2TitleName(res[i], ref title, ref name); MicrophoneList[i].Title = title; MicrophoneList[i].Name = name; ClientModel clientSelected = clientModelsList.FirstOrDefault(x => x.Id != FIRST_PARTICIPANT && x.Title.Equals(title) && x.Name.Equals(name)); if (clientSelected != null) { clientSelected.IsSelected = true; MicrophoneList[i].SelectedClient = clientSelected; } } ParticipantList = new ObservableCollection <ClientModel>(clientModelsList); } InitDeviceList(); }