Esempio n. 1
0
        private static int GetMyInstalls(string trackName)
        {
            int installs   = 0;
            var localTrack = LocalSettings.GetTracks().Where(t => t.Name == trackName).SingleOrDefault();

            if (localTrack != null)
            {
                installs = localTrack.MyDownloads;
            }
            return(installs);
        }
Esempio n. 2
0
        private static bool GetFavorite(string trackName)
        {
            bool favorite   = false;
            var  localTrack = LocalSettings.GetTracks().Where(t => t.Name == trackName).SingleOrDefault();

            if (localTrack != null)
            {
                favorite = localTrack.Favorite;
            }
            return(favorite);
        }
Esempio n. 3
0
        private static void ShareTracks(string trackType)
        {
            try
            {
                var currentSharedList = HttpUtility.Get <SharedReflexTracks[]>("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/share");
                var randomNames       = HttpUtility.Get <string[]>("http://names.drycodes.com/10?nameOptions=games");
                var trackSetName      = randomNames.Where(n => currentSharedList.Any(t => t.Name == n) == false).FirstOrDefault();
                if (trackSetName != null)
                {
                    var installedTracks = LocalSettings.GetTracks().Where(t => t.Installed && t.Type == trackType).Select(t => t.Name).ToArray();

                    SharedReflexTracks tracksToShare = new SharedReflexTracks
                    {
                        Name         = trackSetName,
                        Type         = trackType,
                        Tracks       = string.Join(",", installedTracks),
                        CreationTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow)
                    };

                    bool success = HttpUtility.Post("https://spptqssmj8.execute-api.us-east-1.amazonaws.com/test/share", tracksToShare);
                    if (success)
                    {
                        Log.Add(Trackmanagement.LogMessageType.LogInfo, string.Format("Uploaded your {0} tracks as '{1}'. Tell your party to install it from the Shared Tracks Window.", trackType, trackSetName));
                        long nextShareTime = TimeUtility.DateTimeToUnixTimeStamp(DateTime.UtcNow) + TrackSharing.ShareRateLimitInSeconds;
                        m_shareRateLimiter[trackType] = nextShareTime;
                    }
                    else
                    {
                        Log.Add(Trackmanagement.LogMessageType.LogError, string.Format("An unexpected error occured attempting to share your {0} tracks.", trackType));
                    }
                }
                else
                {
                    Log.Add(Trackmanagement.LogMessageType.LogError, string.Format("Unable to share your {0} tracks because a unique name could not be generated. Please try again later.", trackType));
                }
            }
            catch (Exception e)
            {
                ExceptionLogger.LogException(e);
            }
        }
 public override Task <Trackmanagement.TrackResponse> GetInstalledTracks(Trackmanagement.InstalledTrackRequest request, ServerCallContext context)
 {
     return(Task.FromResult(new Trackmanagement.TrackResponse
     {
         Tracks = { LocalSettings.GetTracks().Where(t => t.Installed == true && t.Type == request.TrackType)
                    .Select(t => new Trackmanagement.Track
             {
                 Name = t.Name,
                 Type = t.Type,
                 Image = t.Image,
                 Author = t.Author,
                 Slot = t.Slot,
                 Date = TimeUtility.UnixTimeStampToString(t.CreationTime),
                 Installs = t.TotalDownloads,
                 MyInstalls = t.MyDownloads,
                 Favorite = t.Favorite
             })
                    .OrderBy(t => t.Slot)
                    .ToArray() }
     }));
 }