Ejemplo n.º 1
0
        /// <summary>
        ///  Deserialize information about the last logged in user; get information about user with such an id from server;
        ///  store user info in <c>CurrentUser</c> property
        /// </summary>
        private void DeserializeLastUser()
        {
            User userCandidate;

            try
            {
                userCandidate = Serializator.Deserialize <User>(FileFolderHelper.LastUserFilePath);
            }
            catch (Exception ex)
            {
                userCandidate = null;
                Logger.Log("Failed to Deserialize last user", ex);
            }
            if (userCandidate == null)
            {
                Logger.Log("User was not deserialized");
                return;
            }
            using (var restClient = new UserApiService())
            {
                userCandidate = restClient.GetUserByGuid(userCandidate.Guid);
            }
            if (userCandidate == null)
            {
                Logger.Log("Failed to relogin last user");
            }
            else
            {
                CurrentUser = userCandidate;
            }
        }