Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void GetQueryStringTest()
        {
            var target = new DeepLinkHelper();

            var queryString = target.GetQueryString("TestProcess", 123);
            const string Expected = "processname=TestProcess&itemid=123";

            Assert.AreEqual(Expected, queryString);
        }
Ejemplo n.º 3
0
        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();
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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();
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
0
        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();
        }
Ejemplo n.º 10
0
        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)
            {
            }
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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();
        }
Ejemplo n.º 14
0
 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
     {
     }
 }
Ejemplo n.º 15
0
 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)
     { }
 }
Ejemplo n.º 16
0
        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();
        }
Ejemplo n.º 17
0
        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();
        }
Ejemplo n.º 18
0
        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();
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        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);
        }