示例#1
0
        public bool Login()
        {
            if (this.username.Length == 0 | this.password.Length == 0)
            {
                throw new SmugMugException("There is no username or password.");
            }

            if (this.connected == false && this.credentials.UserID == 0)
            {
                try
                {
                    this.credentials = SmugMugProxy.LoginWithPassword(this.username, this.password);
                    this.connected   = true;
                }
                catch
                {
                    return(false);
                }
            }
            else
            {
                LoginWithHash();
            }

            return(true);
        }
示例#2
0
 public int Upload(string path, int album_id)
 {
     try {
         return(SmugMugProxy.Upload(path, album_id, credentials.SessionID));
     }
     catch (Exception ex) {
         throw new SmugMugException("Could not upload file", ex.InnerException);
     }
 }
示例#3
0
 public Uri GetAlbumUrl(int image_id)
 {
     try {
         return(SmugMugProxy.GetAlbumUrl(image_id, credentials.SessionID));
     }
     catch (Exception ex) {
         throw new SmugMugException("Could not get album url", ex.InnerException);
     }
 }
示例#4
0
 public Album[] GetAlbums()
 {
     try {
         return(SmugMugProxy.GetAlbums(credentials.SessionID));
     }
     catch (Exception ex) {
         throw new SmugMugException("Could not get albums", ex.InnerException);
     }
 }
示例#5
0
 public Album CreateAlbum(string title, int category_id, bool is_public)
 {
     try {
         return(SmugMugProxy.CreateAlbum(title, category_id, credentials.SessionID, is_public));
     }
     catch (Exception ex) {
         throw new SmugMugException("Could not create album", ex.InnerException);
     }
 }
示例#6
0
 public Category[] GetCategories()
 {
     if (this.categories == null)
     {
         try {
             this.categories = SmugMugProxy.GetCategories(credentials.SessionID);
         }
         catch (Exception ex) {
             throw new SmugMugException("Could not retrieve Categories", ex.InnerException);
         }
     }
     return(this.categories);
 }
示例#7
0
        public void Logout()
        {
            if (!connected)
            {
                return;
            }

            if (this.credentials.SessionID == null && this.credentials.SessionID.Length == 0)
            {
                return;
            }

            SmugMugProxy.Logout(this.credentials.SessionID);
            connected        = false;
            this.credentials = new Credentials(null, 0, null);
        }
示例#8
0
        private void LoginWithHash()
        {
            try {
                string session_id = SmugMugProxy.LoginWithHash(this.credentials.UserID, this.credentials.PasswordHash);

                if (session_id != null && session_id.Length > 0)
                {
                    this.credentials.SessionID = session_id;
                }
                else
                {
                    throw new SmugMugException("SessionID was empty");
                }
            }
            catch (Exception ex) {
                throw new SmugMugException("A login error occured, SessionID may be invalid.", ex.InnerException);
            }
        }