public void ParseDidICatchUp(DidICatchUpRequest request, Peer from) { var catcherUp = new CatcherUpRequest() { EndOfLongestChain = _blockChainService.Info.EndOfLongestChain, Invs = new List <InvitationRequest>() }; foreach (var trans in _minerService.MemPool) { var inv = new InvitationRequest() { DataId = trans.Body.TransactionId, IsBlock = false }; catcherUp.Invs.Add(inv); } if (request.LastKnownEnd != _blockChainService.Info.EndOfLongestChain) { var newBs = _blockChainService.GetNewerBlockInfos(request.LastOnline, request.LastKnownEnd); foreach (var blockInfo in newBs) { var inv = new InvitationRequest() { DataId = blockInfo.Id, IsBlock = true }; catcherUp.Invs.Add(inv); } } Console.WriteLine("Response to didI {0} {1}", catcherUp.EndOfLongestChain, catcherUp.Invs.Count); _server.SendResponse(catcherUp, from); }
private bool MapEmployeeInvitation(int invitationId, InvitationRequest request) { bool retRes = false; try { foreach (var employee in request.SharedEmails) { _kalenderDb.EmployeeInvitationMap.Add(new Data.KalenderEntities.EmployeeInvitationMap() { InvitationId = invitationId, EmpId = employee.Id, }); } _kalenderDb.SaveChanges(); retRes = EmailSending(request.SharedEmails.Select(s => s.EmailId).ToList(), "", request.Description); } catch (Exception e) { //To do exception logging } return(retRes); }
public GameInvitePopup(InvitationRequest stats) { InitializeComponent(); Client.PVPNet.OnMessageReceived += PVPNet_OnMessageReceived; try { InviteInfo info = Client.InviteData[stats.InvitationId]; Client.Log("Tried to find a popup that existed but should have been blocked. ", "Error"); if (info == null) { throw new NullReferenceException("Tried to find a nonexistant popup"); } else { PVPNet_OnMessageReceived(this, stats); } //This should be hidden this.Visibility = Visibility.Hidden; } catch { LoadGamePopupData(stats); Unlock(); } }
public async Task SentInvitations(InvitationRequest invitationRequest) { string FilePath = Directory.GetCurrentDirectory() + "/Smtp/Templates/InvitationTemplate.html"; StreamReader str = new StreamReader(FilePath); string MailText = str.ReadToEnd(); str.Close(); MailText = MailText .Replace("[email]", invitationRequest.ToEmail); var email = new MimeMessage(); email.Sender = MailboxAddress.Parse(_mailSettings.Mail); email.To.Add(MailboxAddress.Parse(invitationRequest.ToEmail)); email.Subject = $"You have been invited to a virtual class"; var builder = new BodyBuilder(); builder.HtmlBody = MailText; email.Body = builder.ToMessageBody(); using var smtp = new SmtpClient(); smtp.CheckCertificateRevocation = false; smtp.Connect(_mailSettings.Host, _mailSettings.Port, SecureSocketOptions.Auto); smtp.Authenticate(_mailSettings.Mail, _mailSettings.Password); await smtp.SendAsync(email); smtp.Disconnect(true); }
public Invitation UpdateInvitation(string id, InvitationRequest invitationRequest) { Invitation invitationReceived = new Invitation(id, invitationRequest); _invitations.ReplaceOne(i => i.Id == id, invitationReceived); return(GetFromInvitationId(id)); }
public GameInvitePopup(InvitationRequest stats) { InitializeComponent(); Client.RiotConnection.MessageReceived += PVPNet_OnMessageReceived; if (!Client.InviteData.ContainsKey(stats.InvitationId)) { LoadGamePopupData(stats); Unlock(); } else { var info = Client.InviteData[stats.InvitationId]; Client.Log("Tried to find a popup that existed but should have been blocked. ", "Error"); if (info == null) { throw new NullReferenceException("Tried to find a nonexistant popup"); } PVPNet_OnMessageReceived(this, stats); //This should be hidden //Visibility = Visibility.Hidden; } }
public async Task <ActionResult> Index(InvitationRequest model) { if (!ModelState.IsValid) { return(View(model)); } try { await _authenticationService.SendInviteAsync(model); ViewBag.Feedback = $"Your invitation was successfully sent to '{model.Email}'. The invitation contains instructions on how to download our app."; ModelState.Clear(); model = new InvitationRequest(); } catch (AuthenticationServiceForbiddenException) { ViewBag.Feedback = $"Unfortunately invitations for this user can no longer be requested."; } catch (Exception ex) { ViewBag.Error = $"Uh oh. Something went wrong that we didn't expect. Please try again later. Details: {ex.Message}."; } return(View(model)); }
public bool WantedTransaction(InvitationRequest transInvitationRequest) { var atB = LookUpBlock(Info.EndOfLongestChain); var lastB = atB.Body.LastBlockId; for (int ii = 0; ii < Configurations.TRANSACTION_WANT_LIMIT; ii++) { if (atB == null) { _logger.Log($"Nullblock : {lastB}"); break; } foreach (var transaction in atB.Body.Tx) { if (transaction.Body.TransactionId == transInvitationRequest.DataId) { return(false); } } if (atB.Body.LastBlockId == "0") { break; } lastB = atB.Body.LastBlockId; atB = LookUpBlock(atB.Body.LastBlockId); } if (_minerService.HasTransactionInMemPool(transInvitationRequest.DataId)) { return(false); } return(true); }
public GameInviteAlert(InvitationRequest invite) : this() { this.invite = invite; this.metaData = JSONParser.ParseObject(invite.GameMetaData, 0); var map = GameMap.Maps.FirstOrDefault(m => m.MapId == (int)metaData["mapId"]); Message = invite.Inviter.summonerName + " has invited you to play a game"; MapName = map.DisplayName; ModeName = GameMode.Values[(string)metaData["gameMode"]].Value; QueueName = GameConfig.Values[(int)metaData["gameTypeConfigId"]].Value; if ((int)metaData["gameTypeConfigId"] == 12) { TypeName = "Team Builder"; } else { switch ((string)metaData["gameType"]) { case "PRACTICE_GAME": TypeName = "Custom"; break; case "NORMAL_GAME": TypeName = "Normal"; break; case "RANKED_TEAM_GAME": TypeName = "Ranked"; break; default: break; } } HistoryGrid.DataContext = this; PopupGrid.DataContext = this; MainGrid.Children.Remove(HistoryGrid); MainGrid.Children.Remove(PopupGrid); }
public static async Task <InvitationsIssued> UninviteAsync( ApplicationDbContext dbContext, InvitationRequest request) { using (var tx = dbContext.Database.BeginTransaction()) { bool succeeded = false; try { Invitation existing = await dbContext.Invitations.SingleOrDefaultAsync(e => e.Email == request.Email); if (existing != null) { dbContext.Invitations.Remove(existing); await dbContext.SaveChangesAsync(); } InvitationsIssued current = await GetCurrentInvitations(dbContext); tx.Commit(); succeeded = true; return(current); } finally { if (!succeeded) { tx.Rollback(); } } } }
public void Broadcast <T>(T data) { //TrySignUpToTracker(); var invit = new InvitationRequest(); var tdata = data as Transaction; var bdata = data as Block; if (tdata != null) { var tt = tdata; invit.IsBlock = false; invit.DataId = tt.Body.TransactionId; } else if (bdata != null) { var bb = bdata; invit.IsBlock = true; invit.DataId = bb.Body.Id; } else { Logger.Log("bad type bad shit"); return; } //Logger.Log($"Broadcasting : {invit.DataId} {invit.IsBlock}"); foreach (var peer in Peers) { _server.SendResponse(invit, peer); } }
private void Decline_Click(object sender, RoutedEventArgs e) { InvitationRequest Request = new InvitationRequest(); this.Visibility = Visibility.Hidden; Client.PVPNet.Decline(InvitationId); }
private bool OnInvitationRequest(InvitationRequest arg) { var invite = new Invitation(arg); invites[invite.Id] = invite; Invite?.Invoke(this, invite); return(true); }
public void Test() { InvitationRequest request = new InvitationRequest(1234); ProtocolMessageContainer container = new ProtocolMessageContainer(request); Assert.AreEqual(ProtocolMessage.MessageType.InvitationRequest, container.Type); Assert.AreEqual(request.SerializeAsBytes(), container.Data); }
void PVPNet_OnMessageReceived(object sender, object message) { if (message is InvitationRequest) { InvitationRequest stats = (InvitationRequest)message; try { InviteInfo info = Client.InviteData[stats.InvitationId]; //Data about this popup has changed. We want to set this if (info.popup == this) { switch (stats.InvitationState) { case "ON_HOLD": this.NotificationTextBox.Text = string.Format("The invite from {0} is now on hold", info.Inviter); this.Lockup(); this.Visibility = Visibility.Hidden; break; case "TERMINATED": this.NotificationTextBox.Text = string.Format("The invite from {0} has been terminated", info.Inviter); this.Lockup(); this.Visibility = Visibility.Hidden; break; case "REVOKED": this.NotificationTextBox.Text = string.Format("The invite from {0} has timed out"); this.Lockup(); this.Visibility = Visibility.Hidden; break; case "ACTIVE": this.NotificationTextBox.Text = ""; if (stats.Inviter == null) LoadGamePopupData(info.stats); else LoadGamePopupData(stats); this.Visibility = Visibility.Hidden; RenderNotificationTextBox(this.Inviter + " has invited you to a game"); RenderNotificationTextBox(""); RenderNotificationTextBox("Mode: " + this.mode); RenderNotificationTextBox("Map: " + this.MapName); RenderNotificationTextBox("Type: " + this.type); this.Unlock(); break; default: this.NotificationTextBox.Text = string.Format("The invite from {0} is now {1}", info.Inviter, Client.TitleCaseString(stats.InvitationState)); Lockup(); break; } } } catch { //We do not need this popup. it is a new one. Let it launch return; } } }
public MvcMailMessage InvitationRequest(InvitationRequest invitationRequest, string email) { ViewData = new System.Web.Mvc.ViewDataDictionary(invitationRequest); return(Populate(x => { x.Subject = "Invitation Request for VaWorks"; x.ViewName = "InvitationRequest"; x.To.Add(email); })); }
public ActionResult <Invitation> Put(string id, [FromBody] InvitationRequest invitationRequest) { var res = _invitationService.GetFromInvitationId(id); if (res == null) { return(NotFound()); } return(_invitationService.UpdateInvitation(id, invitationRequest)); }
/// <summary> /// Cancel an invitation. /// </summary> /// <param name="request">Who to uninvite.</param> /// <returns></returns> /// <returns>Lists of the outstanding and accepted invitations.</returns> public async Task <InvitationsIssued> PostUninviteAsync(InvitationRequest request) { UserInfo user = await GetUserInfoAsync(); if (!MasterEmails.Contains(user.Email)) { throw new HttpResponseException(HttpStatusCode.Forbidden); } return(await InvitationOperations.UninviteAsync(DbContext, request)); }
private async Task CreateInvitationRequestAndPublish(List <Invite> invites, DateTime date) { foreach (var inv in invites) { var contract = new InvitationRequest() { Id = inv.Id, Email = inv.Email, Date = date }; await _MessagePublisher.Publish <InvitationRequest>(contract); } }
public async Task <IActionResult> Post([FromBody] InvitationRequest request) { if (request != null) { return(Ok(await Mediator.Send(new CreateInvitationCommand { invitationRequest = request }))); } else { return(NotFound()); } }
public ActionResult RequestAccess(RequestInviteViewModel model) { if (ModelState.IsValid) { var invitationRequest = new InvitationRequest() { RequestDate = DateTimeOffset.Now, Company = model.Company + " " + model.Comments, Email = model.Email, Name = model.Name, Status = RequestStatus.New }; Database.InvitationRequests.Add(invitationRequest); Database.SaveChanges(); var roleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(Database)); var admins = from role in roleManager.Roles where role.Name == "System Administrator" from u in role.Users select u.UserId; IUserMailer mailer = new UserMailer(); foreach (var admin in admins) { Database.SystemMessages.Add(new SystemMessage() { UserId = admin, DateSent = DateTimeOffset.Now, Message = $"{model.Name} from {model.Company} is requesting access." }); // send the admin an email var email = Database.Users.Where(u => u.Id == admin).FirstOrDefault().Email; try { mailer.InvitationRequest(invitationRequest, email).Send(); } catch (Exception ex) { return(View("MailDown", ex)); } return(View("RequestAccessConfirmation")); } return(View("RequestAccessConfirmation")); } return(View(model)); }
public async Task <ActionResult <AuthenticationRequest> > Invite(InvitationRequest model) { try { return(Ok(await _authenticationService.SendInviteAsync(model))); } catch (AuthenticationServiceForbiddenException) { return(Forbid()); } catch (Exception ex) { return(StatusCode(500, $"Unexpected exception: {ex.Message}.")); } }
public void ShowInvite(InvitationRequest invite) { if (invite.InvitationState.Equals("ACTIVE")) { var user = RiotChat.GetUser(invite.Inviter.summonerId); if (ChatManager.Friends.ContainsKey(user)) { ChatManager.Friends[user].Invite = new Invitation(invite); } else { OnInvited(invite); } } }
private async Task <AuthenticationRequest> GetInviteAndValidateAsync(HttpClient client) { var invitation = new InvitationRequest { Name = TestUserName, Email = TestUserEmail }; var response = await client.PostAsync("api/auth/invite", new StringContent(JsonConvert.SerializeObject(invitation), Encoding.UTF8, "application/json")); Assert.IsTrue(response.IsSuccessStatusCode); var authenticationRequest = JsonConvert.DeserializeObject <AuthenticationRequest>(await response.Content.ReadAsStringAsync()); Assert.IsNotNull(authenticationRequest); Assert.IsFalse(String.IsNullOrWhiteSpace(authenticationRequest.Id)); Assert.IsFalse(String.IsNullOrWhiteSpace(authenticationRequest.Token)); return(authenticationRequest); }
private async void handleInvitationRequest(object message) { if (smurf.groupMember) { Logger.Push("Recieved party from group host, accepting.", "info", username); InvitationRequest req = message as InvitationRequest; Thread.Sleep(1000); await connection.AcceptInviteForMatchmakingGame(req.InvitationId); smurf.updateTimer(100); } else { Logger.Push("Recieved party request from a friend, not responding...", "warning", username); } }
public void Test() { InvitationRequest request = new InvitationRequest(1111); this.TestFactory(request); InvitationAck ack = new InvitationAck(2222); this.TestFactory(ack); byte[] data = { 12, 34, 56 }; FileDataResponse dataResponse = new FileDataResponse(data, 3333); this.TestFactory(dataResponse); FileEvent e1 = new FileEvent(); e1.Name = "1234"; List <FileEvent> lf = new List <FileEvent>(); lf.Add(e1); PatchRequest patchRequest = new PatchRequest(lf, 4444); this.TestFactory(patchRequest); PeerList peerList = PeerList.GetPeerList("abc"); peerList.AddPeer(new Peer("127.0.0.1", 5555)); PeerListMessage pm = new PeerListMessage(peerList, 6666); this.TestFactory(pm); SyncAck syncAck = new SyncAck(7777); this.TestFactory(syncAck); SyncRequest syncRequest = new SyncRequest(8888); this.TestFactory(syncRequest); File.WriteAllText(".Distribox/VersionList.txt", "[]"); VersionList vl = new VersionList(); VersionListMessage vm = new VersionListMessage(vl, 9999); this.TestFactory(vm); }
public async Task <string> GetGuestUserId( string accessToken, string userEmailId) { string endpoint = GraphRootUri + "invitations"; InvitationRequest objInvitation = new InvitationRequest() { invitedUserEmailAddress = userEmailId, sendInvitationMessage = true, inviteRedirectUrl = "https://teams.microsoft.com", invitedUserMessageInfo = new Invitedusermessageinfo() { customizedMessageBody = "Welcome to Teams" } }; return(await SendInvitationToGuestUser(accessToken, endpoint, JsonConvert.SerializeObject(objInvitation))); }
public async void GetPendingInvites() { object[] allInvites = await Client.PVPNet.getPendingInvitations(); foreach (var item in allInvites) { InvitationRequest invite = new InvitationRequest((TypedObject)item); Client.MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { var pop = new GameInvitePopup(invite) { HorizontalAlignment = HorizontalAlignment.Right, VerticalAlignment = VerticalAlignment.Bottom, Height = 230 }; Client.NotificationGrid.Children.Add(pop); })); } }
/// <summary> /// Create a new invitation request and publish to queue for a collection of invites! /// </summary> /// <param name="invites"></param> /// <param name="date"></param> /// <returns></returns> private async Task CreateInvitationRequestAndPublish(List <Invite> invites, DateTime date) { try { foreach (var inv in invites) { var contract = new InvitationRequest() { Id = inv.Id, Email = inv.Email, Date = date }; await _MessagePublisher.Publish <InvitationRequest>(contract); } return; } catch (System.InvalidOperationException e) { _Logger.LogError($"Exception Caught: {e.Message}"); } }
private async Task SendInviteAsync(InvitationRequest request) { try { if (!Validator.TryValidateObject(request, new ValidationContext(request), null)) { await DisplayAlert("Help Us Out", $"It looks like we're missing some information. Please ensure your name and email are correct.", "Dismiss"); return; } IsBusy = true; System.Diagnostics.Debug.WriteLine($"[{nameof(SendInviteAsync)}] - Name: '{request.Name}', Email: '{request.Email}'."); var response = await App.HttpClient.PostAsync($"api/auth/invite", new StringContent(JsonConvert.SerializeObject(request), Encoding.UTF8, "application/json")); IsBusy = false; if (response.IsSuccessStatusCode) { Analytics.TrackEvent(nameof(SendInviteAsync), new Dictionary <string, string> { { "Status", $"[SUCCESS] Name: '{request.Name}', Email: '{request.Email}'." } }); await DisplayAlert("Well Done", $"Your invitation was successfully sent to '{request.Email}'. Please check your email.", "Dismiss"); } else { Analytics.TrackEvent(nameof(SendInviteAsync), new Dictionary <string, string> { { "Status", $"[FAILED] Name: '{request.Name}', Email: '{request.Email}'." } }); await DisplayAlert("Oops", $"We were unable to send your invitation to '{request.Email}'. Please check youer email address and try again later.", "Dismiss"); } } catch (Exception ex) { Crashes.TrackError(ex); await DisplayAlert("Error", $"We appologize, but it looks like something bad happened. Please try again later. Details: {ex.Message}.", "Dismiss"); } finally { IsBusy = false; } }
private void Decline_Click(object sender, RoutedEventArgs e) { InvitationRequest Request = new InvitationRequest(); this.Visibility = Visibility.Hidden; Client.PVPNet.Decline(InvitationId); }
public GameInvitePopup(InvitationRequest stats) { InitializeComponent(); //IDK WHY I'M Receiving this stuff -.- Client.PVPNet.OnMessageReceived += Update_OnMessageReceived; GameMetaData = stats.GameMetaData; InvitationStateAsString = stats.InvitationStateAsString; InvitationState = stats.InvitationState; this.Inviter = SummonerName; InvitationId = stats.InvitationId; if (InvitationId != null) { NoGame.Visibility = Visibility.Hidden; } //Get who the Inviter's Name //Simple way to get lobby data with Json.Net invitationRequest m = JsonConvert.DeserializeObject<invitationRequest>(stats.GameMetaData); queueId = m.queueId; isRanked = m.isRanked; rankedTeamName = m.rankedTeamName; mapId = m.mapId; gameTypeConfigId = m.gameTypeConfigId; gameMode = m.gameMode; gameType = m.gameType; Client.PVPNet.getLobbyStatusInviteId = InvitationId; //So if there is a new map, it won't get a null error string MapName = "Unknown Map"; if (mapId == 1) { MapName = "Summoners Rift"; } else if (mapId == 10) { MapName = "The Twisted Treeline"; } else if (mapId == 12) { MapName = "Howling Abyss"; } else if (mapId == 8) { MapName = "The Crystal Scar"; } //This is used so we can call the ToTitleCase [first letter is capital rest are not] CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture; TextInfo textInfo = cultureInfo.TextInfo; var gameModeLower = textInfo.ToTitleCase(string.Format(gameMode.ToLower())); var gameTypeLower = textInfo.ToTitleCase(string.Format(gameType.ToLower())); //Why do I have to do this Riot? var gameTypeRemove = gameTypeLower.Replace("_game", ""); var removeAllUnder = gameTypeRemove.Replace("_", " "); if (Inviter == null) { RenderNotificationTextBox("An unknown player has invited you to a game"); RenderNotificationTextBox(""); RenderNotificationTextBox("Mode: " + gameModeLower); RenderNotificationTextBox("Map: " + MapName); RenderNotificationTextBox("Type: " + removeAllUnder); } else if (Inviter == "") { RenderNotificationTextBox("An unknown player has invited you to a game"); RenderNotificationTextBox(""); RenderNotificationTextBox("Mode: " + gameModeLower); RenderNotificationTextBox("Map: " + MapName); RenderNotificationTextBox("Type: " + removeAllUnder); } else if (Inviter != null && Inviter != "") { RenderNotificationTextBox(SummonerName + " has invited you to a game"); RenderNotificationTextBox(""); RenderNotificationTextBox("Mode: " + gameModeLower); RenderNotificationTextBox("Map: " + MapName); RenderNotificationTextBox("Type: " + removeAllUnder); } }
internal static void OnMessageReceived(object sender, object message) { MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async () => { if (message is StoreAccountBalanceNotification) { StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message; InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp; Client.LoginPacket.IpBalance = newBalance.Ip; Client.LoginPacket.RpBalance = newBalance.Rp; } else if (message is GameNotification) { GameNotification notification = (GameNotification)message; MessageOverlay messageOver = new MessageOverlay(); messageOver.MessageTitle.Content = notification.Type; switch (notification.Type) { case "PLAYER_BANNED_FROM_GAME": messageOver.MessageTitle.Content = "Banned from custom game"; messageOver.MessageTextBox.Text = "You have been banned from this custom game!"; break; default: messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine; messageOver.MessageTextBox.Text = Convert.ToString(notification.MessageArgument); break; } Client.OverlayContainer.Content = messageOver.Content; Client.OverlayContainer.Visibility = Visibility.Visible; Client.ClearPage(new CustomGameLobbyPage()); Client.SwitchPage(new MainPage()); } else if (message is EndOfGameStats) { EndOfGameStats stats = message as EndOfGameStats; EndOfGamePage EndOfGame = new EndOfGamePage(stats); Client.OverlayContainer.Visibility = Visibility.Visible; Client.OverlayContainer.Content = EndOfGame.Content; } else if (message is StoreFulfillmentNotification) { PlayerChampions = await PVPNet.GetAvailableChampions(); } else if (message is InvitationRequest) { //TypedObject body = (TypedObject)to["body"]; MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { InvitationRequest invite = new InvitationRequest(); //Gameinvite stuff GameInvitePopup pop = new GameInvitePopup(); await PVPNet.getPendingInvitations(); await PVPNet.checkLobbyStatus(); await PVPNet.getLobbyStatus(); PVPNetConnect.RiotObjects.Gameinvite.Contract.InvitationRequest Invite = new PVPNetConnect.RiotObjects.Gameinvite.Contract.InvitationRequest(); //await Invite.Callback; //Invite.InvitationRequest(body); pop.HorizontalAlignment = HorizontalAlignment.Right; pop.VerticalAlignment = VerticalAlignment.Bottom; pop.Height = 230; Client.NotificationGrid.Children.Add(pop); Client.InviteJsonRequest = LegendaryClient.Logic.JSON.InvitationRequest.PopulateGameInviteJson(); //message.GetType() == typeof(GameInvitePopup) })); } else if (message is GameDTO && RunonePop == false) { /* GameDTO Queue = message as GameDTO; MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { Client.OverlayContainer.Content = new QueuePopOverlay(Queue).Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); RunonePop = true;*/ //Client.PVPNet.OnMessageReceived -= GotQueuePop; } })); }