Exemplo n.º 1
0
 private void SaveStates()
 {
     SpotifyAccessLayer.SaveArtistsToDatabase(this._Artists, this._WKAtrtist);
     SpotifyAccessLayer.SaveTracksToDatabase(this._Tracks, this._WKTracks);
     SpotifyAccessLayer.SavePlaylistsToDatabase(this._Playlists, this._WKPlaylists);
     SpotifyAccessLayer.SaveStatesToDatabase(this._SpotifyStates, this._WKState);
 }
        public static bool operator !=(SpotifyObjectBase obj1, SpotifyObjectBase obj2)
        {
            if (obj1.ID == 0)
            {
                SpotifyAccessLayer.UpdateObjectIDForSpotifyObject(obj1);
            }

            if (obj2.ID == 0)
            {
                SpotifyAccessLayer.UpdateObjectIDForSpotifyObject(obj2);
            }

            return(obj1.ID != obj2.ID);
        }
        public SpotifyUser(string sProfileID, string sAuthCode, string sAccessCode, string sRefreshCode, string sAccessTokenType, int iExpiresIn, DateTime dtToken, DateTime dtAuth)
        {
            this._SpotifyID = sProfileID;
            this._Name      = sProfileID;
            this._ID        = SpotifyAccessLayer.GetObjectIDForSpotifyID(this._SpotifyID);

            this._UserAuth = new SpotifyUserAuth(sAuthCode, dtAuth);
            SaveUserAndAuthToDatabase();
            this._RefreshToken = new SpotifyUserRefreshToken(sRefreshCode, dtToken);
            SaveRefreshTokenToDatebase();
            this._AccessToken = new SpotifyUserAccessToken(sAccessCode, sAccessTokenType, iExpiresIn, dtToken);
            SaveAccessTokenToDatabase();
            this._UserGuid = SpotifyAccessLayer.GetUserGuidForUserID(this._ID);
        }
Exemplo n.º 4
0
        public SpotifyPlaylistChangeManager  GetUserForUserGuid(string sUserGuid, DateTime? dtLastSeen = null)
        {

            SpotifyPlaylistChange[] Changes = SpotifyAccessLayer.GetSpotifyUserForGuid(sUserGuid).Changes.ToArray();
            SpotifyPlaylistChange[] ChangesFilteredWithDate;
            if (dtLastSeen != null)
            {
                ChangesFilteredWithDate = (from Change in Changes where Change.ChangedDate > dtLastSeen.Value.ToUniversalTime() select Change).ToArray();
            }
            else
            {
                ChangesFilteredWithDate = Changes;
            }
            return new SpotifyPlaylistChangeManager(ChangesFilteredWithDate);
        }
        public SpotifyUser(PrivateProfile oPrivateProfile, string sAuthCode, Token oToken)
        {
            this._SpotifyID = oPrivateProfile.Id;
            this._Name      = oPrivateProfile.Id;
            this._ID        = SpotifyAccessLayer.GetObjectIDForSpotifyID(this._SpotifyID);

            string   sAccessCode      = oToken.AccessToken;
            string   sRefreshCode     = oToken.RefreshToken;
            string   sAccessTokenType = oToken.TokenType;
            int      iAccessExpiresIn = oToken.ExpiresIn;
            DateTime dtToken          = oToken.CreateDate.ToUniversalTime();
            DateTime dtAuth           = oToken.CreateDate.ToUniversalTime();

            this._UserAuth = new SpotifyUserAuth(sAuthCode, dtAuth);
            SaveUserAndAuthToDatabase();
            this._RefreshToken = new SpotifyUserRefreshToken(sRefreshCode, dtToken);
            SaveRefreshTokenToDatebase();
            this._AccessToken = new SpotifyUserAccessToken(sAccessCode, sAccessTokenType, iAccessExpiresIn, dtToken);
            SaveAccessTokenToDatabase();
            this._UserGuid = SpotifyAccessLayer.GetUserGuidForUserID(this._ID);
        }
Exemplo n.º 6
0
 public UserManager() : base()
 {
     this._Users         = SpotifyAccessLayer.GetSpotifyUsersAndTokens().ToArray <SpotifyUser>();
     this._UserPlaylists = new Dictionary <Int64, List <SpotifyPlaylist> >();
     this._iCurrentIndex = 0;
 }
 protected SpotifyObjectBase(string sSpotifyID, string Name)
 {
     this.Name      = Name;
     this.SpotifyID = sSpotifyID;
     SpotifyAccessLayer.UpdateObjectIDForSpotifyObject(this);
 }
Exemplo n.º 8
0
 public void DeleteUserSession(string sUserGuid)
 {
     long iUserID = SpotifyAccessLayer.GetSpotifyUserForGuid(sUserGuid).ID;
     SpotifyAccessLayer.DeleteSessionForUser(iUserID);
 }
Exemplo n.º 9
0
 public bool AuthenticateUserSession(string sUserGuid, string sSessionGuid)
 {
     return SpotifyAccessLayer.AuthenticateUserWithSession(sUserGuid, sSessionGuid);
 }
 private void SaveAccessTokenToDatabase()
 {
     SpotifyAccessLayer.SaveAccessTokenForUserToDatabase(this.ID, this._AccessToken);
 }
 private void SaveRefreshTokenToDatebase()
 {
     SpotifyAccessLayer.SaveRefreshTokenForUserToDatabase(this.ID, this._RefreshToken);
 }
 private void SaveUserAndAuthToDatabase()
 {
     SpotifyAccessLayer.SaveUserAndAuthToDatabase(this);
 }
Exemplo n.º 13
0
 public long GetObjectIDForSpotifyID(string sSpotifyID)
 {
     return(SpotifyAccessLayer.GetObjectIDForSpotifyID(sSpotifyID));
 }
Exemplo n.º 14
0
 public IEnumerable <SpotifyPlaylistChange> GetPlaylistChangesForUser(long iUserID, DateTime dtStart, DateTime dtEnd)
 {
     return(SpotifyAccessLayer.GetPlaylistChanges(iUserID, dtStart, dtEnd));
 }