コード例 #1
0
ファイル: Mobile.svc.cs プロジェクト: jakub77/KServer
        /// <summary>
        /// Signs a mobile user out of the system.
        /// </summary>
        /// <param name="userKey">The client's key.</param>
        /// <returns>The outcome of the operation.</returns>
        public Response MobileSignOut(long userKey)
        {
            int mobileID;
            using (DatabaseConnectivity db = new DatabaseConnectivity())
            {
                // Try to establish a database connection
                Response r = db.OpenConnection();
                if (r.error)
                    return (Response)Common.LogError(r.message, Environment.StackTrace, r, 0);

                // Convert the userKey to MobileID
                r = MobileKeyToID(userKey, out mobileID, db);
                if (r.error)
                    return (Response)Common.LogError(r.message, Environment.StackTrace, r, 0);

                // Make sure the client isn't already logged out.
                r = MobileCheckStatus(mobileID, "!0", db);
                if (r.error)
                    return r;

                // A sign out seems to be valid. Also clears any device id found.
                r = db.MobileSignOut(mobileID);
                if(r.error)
                    return (Response)Common.LogError(r.message, Environment.StackTrace, r, 0);

                // Remove the key from the DB.
                r = db.MobileSetKey(mobileID, null);
                if (r.error)
                    return (Response)Common.LogError(r.message, Environment.StackTrace, r, 0);

                // Clear the venue from the DB
                r = db.MobileSetVenue(mobileID, null);
                if(r.error)
                    return (Response)Common.LogError(r.message, Environment.StackTrace, r, 0);
                return r;
            }
        }
コード例 #2
0
ファイル: Mobile.svc.cs プロジェクト: jakub77/KServer
        /// <summary>
        /// Signs a mobile user out of the system.
        /// </summary>
        /// <param name="userKey">The client's key.</param>
        /// <returns>The outcome of the operation.</returns>
        public Response MobileSignOut(long userKey)
        {
            int mobileID;
            using (DatabaseConnectivity db = new DatabaseConnectivity())
            {
                // Try to establish a database connection
                ExpResponse r = db.OpenConnection();
                if (r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                // Convert the userKey to MobileID
                r = MobileKeyToID(userKey, out mobileID, db);
                if (r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                // Make sure the client isn't already logged out.
                bool validStatus;
                r = MobileCheckStatus(mobileID, "!0", db, out validStatus);
                if (r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);
                if (!validStatus)
                {
                    r.setErMsg(true, Messages.ERR_STATUS_ALREADY_OUT);
                    return r;
                }

                r = MobileTryRemoveAllSongRequests(mobileID, db);
                if(r.error)
                    Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                // A sign out seems to be valid. Also clears any device id found.
                r = db.MobileSignOut(mobileID);
                if(r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                // Remove the key from the DB.
                r = db.MobileSetKey(mobileID, null);
                if (r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                // Clear the venue from the DB
                r = db.MobileSetVenue(mobileID, null);
                if(r.error)
                    return Common.LogErrorRetNewMsg(r, Messages.ERR_SERVER, Common.LogFile.Mobile);

                return r;
            }
        }