public async Task <bool> Send(int athleteID, string messageText, bool shareMyEmail) { var me = new UserProfileLogic(db).GetAthleteForUserName(this.User.Identity.Name); var athlete = db.Athletes.Single(i => i.AthleteID == athleteID); if (messageText == null) { messageText = ""; } string linkToAthlete = new DeepLinkHelper().BuildLinkToAthlete(me.AthleteID); string linkToOpenByb = new DeepLinkHelper().BuildOpenBybLink_Athlete(me.AthleteID); // send an email string myName = me.NameOrUserName; string myEmail = me.UserName; if (string.IsNullOrEmpty(me.RealEmail) == false) { myEmail = me.RealEmail; } string html = string.Format(htmlMessage, myName, messageText, shareMyEmail ? myEmail : "notshared", linkToAthlete, linkToOpenByb); await new EmailService().SendEmailToAthlete(athlete, "Snooker Byb Message", html); // send a push notification new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildPrivateMessage(me, messageText)); PushNotificationProcessor.TheProcessor.PushAllPendingNotifications(); return(true); }
public void GetQueryStringTest() { var target = new DeepLinkHelper(); var queryString = target.GetQueryString("TestProcess", 123); const string Expected = "processname=TestProcess&itemid=123"; Assert.AreEqual(Expected, queryString); }
private void ShareViaSMS_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); SmsComposeTask smsComposeTask = new SmsComposeTask() { Body = "Try \"DD News App\" for windows phone 8. It's great!. " + storeURI, }; smsComposeTask.Show(); }
private void ShareViaMail_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); EmailComposeTask emailComposeTask = new EmailComposeTask() { Subject = "Try \" DDNews App\" for windows phone 8", Body = "\" DDNews App\" is a easy way to read english and hindi news from DD.Please click on this link " + storeURI, }; emailComposeTask.Show(); }
public void DecryptQueryStringTest() { const string EncryptedQuery = "keycode=PAh-hfRXhM3ag7JFL2IP3V6RestaaWKefvS7tTYXgdMryPiFwnGDtT9hy3dibiNww_OmfyGjOCeUeVrFrhQfmU__bYfd_7_x95mtynMRIOA"; const string Expected = "processname=TestProcess&itemid=111&personid=222"; var target = new DeepLinkHelper(); var queryString = target.DecryptQueryString(EncryptedQuery); Assert.AreEqual(Expected, queryString); }
private void ShareViaMail_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); EmailComposeTask emailComposeTask = new EmailComposeTask() { Subject = "Try \"Outlook India App\" for windows phone 8", Body = "\"Outlook India App\" is helps you in reading news from outlook india magazine.Please click on this link " + storeURI, }; emailComposeTask.Show(); }
private void ShareViaSocialNetwork_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ShareLinkTask shareLinkTask = new ShareLinkTask(); shareLinkTask.Title = "DDNEWS App"; var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); shareLinkTask.LinkUri = new Uri(storeURI); shareLinkTask.Message = "\"DDNEWS App\" for Windows phone 8"; shareLinkTask.Show(); }
public void WhenDeeplinkBaseUrlIsEmpty_GetDeepLinkReturnsEmptyString() { const string ProcessName = "TestProcess"; const int ItemId = 123; var target = new DeepLinkHelper {ApplicationRootUrl = null}; var deepLink = target.GetDeepLink(ProcessName, ItemId); Assert.AreEqual(string.Empty, deepLink); }
private void ShareViaMail_Tap(object sender, System.Windows.Input.GestureEventArgs e) { var storeUri = DeepLinkHelper.BuildApplicationDeepLink(); EmailComposeTask emailComposeTask = new EmailComposeTask() { Subject = "Try \"The Hindu News App\" for windows phone 8 and 8.1", Body = "\"The Hindu News App\" is a easy way to customize and read the news which you are interested in. You can pin your interests and start reading in one click away.Please click on this link " + storeUri, }; emailComposeTask.Show(); }
async Task emailPeopleAboutNewScores(Athlete me, List <Score> newScoresConfirmed, List <Score> newScoresNotYetConfirmed) { try { ApplicationDbContext db = new ApplicationDbContext(); string link1 = new DeepLinkHelper().BuildLinkToSync(me.AthleteID); string link2 = new DeepLinkHelper().BuildOpenBybLink_Sync(me.AthleteID); string myName = me.NameOrUserName; foreach (Score score in newScoresConfirmed) { var athlete = db.Athletes.Single(i => i.AthleteID == score.AthleteBID); // build the email string strScore = score.PointsA + " : " + score.PointsB; if (score.PointsA < score.PointsB) { strScore += " (you won)"; } else if (score.PointsA > score.PointsB) { strScore += " (you lost)"; } string html = string.Format(htmlMessage_NewConfirmedScore, myName, strScore, score.Date.ToShortDateString(), link1, link2); // send the email await new EmailService().SendEmailToAthlete(athlete, "New match recorded and auto-confirmed", html); } foreach (Score score in newScoresNotYetConfirmed) { var athlete = db.Athletes.Single(i => i.AthleteID == score.AthleteBID); // build the email string strScore = score.PointsA + " : " + score.PointsB; if (score.PointsA < score.PointsB) { strScore += " (you won)"; } else if (score.PointsA > score.PointsB) { strScore += " (you lost)"; } string html = string.Format(htmlMessage_NewNotConfirmedScore, myName, strScore, score.Date.ToShortDateString(), link1, link2); // send the email await new EmailService().SendEmailToAthlete(athlete, "New match recorded & needs your confirmation", html); } } catch (Exception) { } }
public void GetDeepLinkTest() { const string ProcessName = "TestProcess"; const int ItemId = 123; var target = new DeepLinkHelper {ApplicationRootUrl = "http://example.com"}; var deepLink = target.GetDeepLink(ProcessName, ItemId); const string Expected = "http://example.com/#processname=TestProcess&itemid=123"; Assert.AreEqual(Expected, deepLink); }
public void GetEncryptedQueryStringTest() { const string ProcessName = "TestProcess"; const int ItemId = 111; const int PersonId = 222; var target = new DeepLinkHelper(); var queryString = target.GetEncryptedQueryString(ProcessName, ItemId, PersonId); const string Expected = "keycode=PAh-hfRXhM3ag7JFL2IP3V6RestaaWKefvS7tTYXgdMryPiFwnGDtT9hy3dibiNww_OmfyGjOCeUeVrFrhQfmU__bYfd_7_x95mtynMRIOA"; Assert.AreEqual(Expected, queryString); }
private void ShareViaSocialNetwork_Tap(object sender, System.Windows.Input.GestureEventArgs e) { ShareLinkTask shareLinkTask = new ShareLinkTask(); shareLinkTask.Title = "Outlook India"; var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); //await Windows.System.Launcher.LaunchUriAsync(storeURI); //shareLinkTask.LinkUri = new Uri("http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff431744(v=vs.92).aspx", UriKind.Absolute); shareLinkTask.LinkUri = new Uri(storeURI); shareLinkTask.Message = "\"Outlook India App\" for Windows phone 8"; shareLinkTask.Show(); }
private void ShareEmailArticle() { try { var storeURI = DeepLinkHelper.BuildApplicationDeepLink(); EmailComposeTask emailComposeTask = new EmailComposeTask { Subject = string.Format("Outlook India: {0}", Article.HeadLine), Body = String.Format("Hi,\n\nThis article will interest you: {0}\n\n{1}\n\nSent by the \"Outlook India\" for Windows Phone 8.For the App you can click this link. " + storeURI, Article.HeadLine, Article.WebURL) }; emailComposeTask.Show(); } catch { } }
private void ShareEmailArticle() { try { var storeUri = DeepLinkHelper.BuildApplicationDeepLink(); EmailComposeTask emailComposeTask = new EmailComposeTask { Subject = string.Format("TheHindu: {0}", Article.Title), Body = string.Format( "Hi,\n\nThis article will interest you: {0}\n\n{1}\n\nSent by the \"The Hindu News App\" for Windows Phone 8.For the App you can click this link. " + storeUri, Article.Title, Article.Url) }; emailComposeTask.Show(); } catch (Exception) { } }
async Task emailWantsToPlay(Athlete inviteeAthlete, Athlete hostAthlete, GameHost gameHost, Venue venue) { // send an email string inviteeName = inviteeAthlete.NameOrUnknown; string inviteeEmail = inviteeAthlete.UserName; if (string.IsNullOrEmpty(inviteeAthlete.RealEmail) == false) inviteeEmail = inviteeAthlete.RealEmail; string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString(); string subject = "'Byb' - " + inviteeName + " wants to join your game"; string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID); string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID); string html = string.Format(htmlMessage_WantsToPlay, inviteeName, when, venue.Name, gameHost.GameHostID.ToString(), link1, link2); await new EmailService().SendEmailToAthlete(hostAthlete, subject, html); // send a push notification new PushNotificationsLogic(db).SendNotification(hostAthlete.AthleteID, PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameWantsToBeInvited, inviteeAthlete, gameHost.GameHostID)); PushNotificationProcessor.TheProcessor.PushAllPendingNotifications(); }
async Task sendHostApproves(Athlete me, Athlete inviteeAthlete, GameHost gameHost, Venue venue) { // send an email string myName = me.NameOrUnknown; string myEmail = me.UserName; if (string.IsNullOrEmpty(me.RealEmail) == false) myEmail = me.RealEmail; string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString(); string subject = "'Byb' - Approved"; string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID); string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID); string html = string.Format(htmlMessage_HostApproves, myName, when, venue.Name, gameHost.GameHostID.ToString(), myEmail, link1, link2); await new EmailService().SendEmailToAthlete(inviteeAthlete, subject, html); // send a push notification new PushNotificationsLogic(db).SendNotification(inviteeAthlete.AthleteID, PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameApprovedByHost, me, gameHost.GameHostID)); PushNotificationProcessor.TheProcessor.PushAllPendingNotifications(); }
async Task sendAnInvite(Athlete me, Athlete athlete, GameHost gameHost, Venue venue, string comments) { // send an email string myName = me.NameOrUnknown; string myEmail = me.UserName; if (string.IsNullOrEmpty(me.RealEmail) == false) myEmail = me.RealEmail; string when = gameHost.When_InLocalTimeZone.ToLongDateString() + " - " + gameHost.When_InLocalTimeZone.ToShortTimeString(); string subject = "'Byb Invite' For a Game of Snooker"; string type = (gameHost.EventType == (int)EventTypeEnum.Private ? "Private event" : "Public event") + (gameHost.LimitOnNumberOfPlayers > 0 ? (", max. " + gameHost.LimitOnNumberOfPlayers.ToString() + " can join") : ""); string link1 = new DeepLinkHelper().BuildOpenBybLink_GameHost(gameHost.GameHostID); string link2 = new DeepLinkHelper().BuildLinkToGameHost(gameHost.GameHostID); string html = string.Format(htmlMessage_Invitation, myName, when, venue.Name, gameHost.GameHostID.ToString(), link1, link2, type, comments ?? ""); await new EmailService().SendEmailToAthlete(athlete, subject, html); // send a push notification new PushNotificationsLogic(db).SendNotification(athlete.AthleteID, PushNotificationMessage.BuildGameMessage(PushNotificationMessageTypeEnum.GameInvite, me, gameHost.GameHostID)); PushNotificationProcessor.TheProcessor.PushAllPendingNotifications(); }
public async Task <bool> RequestFriend(int athleteID) { var me = new UserProfileLogic(db).GetAthleteForUserName(this.User.Identity.Name); var athlete = db.Athletes.Single(i => i.AthleteID == athleteID); new FriendshipLogic(db).AddFriendship(me.AthleteID, athleteID); // send a push notification new PushNotificationsLogic(db).SendNotification(athleteID, PushNotificationMessage.BuildFriendRequest(me)); PushNotificationProcessor.TheProcessor.PushAllPendingNotifications(); // send an email string linkToAthlete = new DeepLinkHelper().BuildLinkToAthlete(me.AthleteID); string linkToOpenByb = new DeepLinkHelper().BuildOpenBybLink_Athlete(me.AthleteID); string myName = me.NameOrUserName; //string myEmail = me.UserName; //if (string.IsNullOrEmpty(me.RealEmail) == false) // myEmail = me.RealEmail; string html = string.Format(htmlMessage, myName, linkToAthlete, linkToOpenByb); await new EmailService().SendEmailToAthlete(athlete, "Friend Request", html); return(true); }
public void WhenDeepLinkBaseUrlIsEmpty_GetEncryptedDeepLinkReturnsEmptyString() { const string ProcessName = "Process1"; const int ItemId = 1; const int PersonId = 2; var target = new DeepLinkHelper{ApplicationRootUrl = null}; var deepLink = target.GetEncryptedDeepLink(ProcessName, ItemId, PersonId); Assert.AreEqual(string.Empty, deepLink); }
public void GetEncryptedDeepLinkTest() { const string ProcessName = "Process1"; const int ItemId = 1; const int PersonId = 2; var target = new DeepLinkHelper { ApplicationRootUrl = "http://example.com/" }; var deepLink = target.GetEncryptedDeepLink(ProcessName, ItemId, PersonId); const string expected = "http://example.com/#keycode=9btco-rKfHnAT3aNOGInVcSlVUj_kTW5uyVazGxPBysfJPiG65olpkfB4v77yw3LL44SJ7Vf4Ic_R-WXfTEhY2Wy5oybBzyYpT3TXnwyE-I"; Assert.AreEqual(expected, deepLink); }