예제 #1
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            PingFMApi.api_key = "29e2b905210c5a0cf77f74e2462f8ea4";
            PingFMApi ping = new PingFMApi("9404ad4bc7011436a829e73abe4d3d86-1263593153");

            ping.Post(new PingFMApi.OutgoingMessage(xInfo.PresenceInfo.Info));
        }
예제 #2
0
 public PingFMClient(string appKey)
 {
     pingfm = new PingFMApi (appKey);
     services = new List<Item> ();
 }
예제 #3
0
        private void postStatusToPing()
        {
            GamervineDataContext dataContext = new GamervineDataContext();

            try
            {
                var users = from u in dataContext.Users
                            join up in dataContext.UserPrefs on u.UserId equals up.UserId
                            join gt in dataContext.Gamertags on u.UserId equals gt.UserId
                            where gt.State != 2
                            select new
                {
                    u.UserId,
                    u.PingFmKey,
                    up.PublishGameFrequency,
                    up.PublishInterval,
                    up.PublishStatus,
                    up.PublishUniqueStatus,
                    up.StatusFormat,
                    gt.TagId,
                    gt.State,
                    gt.Type
                };

                foreach (var user in users)
                {
                    var latestData = from xd in dataContext.XboxData
                                     where xd.TagId == user.TagId
                                     orderby xd.RetrieveDate descending
                                     select xd;

                    string status = bcXboxData.GetStatusString(user.StatusFormat, latestData.First());

                    var lastPost = from ph in dataContext.PostHistories
                                   where ph.UserId == user.UserId
                                   orderby ph.PostDate descending
                                   select ph;

                    string strLastPost = string.Empty;
                    if (lastPost.Count() > 0)
                    {
                        strLastPost = lastPost.First().PostString;
                    }

                    if (strLastPost.Equals(string.Empty) || !status.ToLower().Equals(strLastPost.ToLower()))
                    {
                        if ((strLastPost.ToLower().Contains(" is currently offline. last seen ") &&
                             !status.ToLower().Contains(" is currently offline. last seen ")) ||
                            (!strLastPost.ToLower().Contains(" is currently offline. last seen ") &&
                             status.ToLower().Contains(" is currently offline. last seen ")) ||
                            (!strLastPost.ToLower().Contains(" is currently offline. last seen ") &&
                             !status.ToLower().Contains(" is currently offline. last seen ")))
                        {
                            //Hit the Ping.fm service
                            PingFMApi.api_key = "29e2b905210c5a0cf77f74e2462f8ea4";
                            PingFMApi ping            = new PingFMApi(user.PingFmKey);
                            PingFMApi.PingResponse pr = ping.Post(new PingFMApi.OutgoingMessage(status));

                            //Record the post history in the database
                            PostHistory ph = new PostHistory();
                            ph.PostDate      = DateTime.UtcNow;
                            ph.PostHistoryId = _nextPostHistoryID++;
                            ph.PostString    = status;
                            ph.UserId        = user.UserId;

                            dataContext.PostHistories.InsertOnSubmit(ph);
                        }
                    }
                }
            }
            finally
            {
                dataContext.SubmitChanges();
            }
        }