Beispiel #1
0
 public void OpenUserAudios(long?UserId = null, long?AlbumId = null, bool OpenInNewTab = true)
 {
     MainApi.ClientLog("Opening user audios");
     if (OpenInNewTab)
     {
         AddNewTab();
     }
     FillAudioList(new FillAudioBody(TabPageBodies.Count - 1, FillAudioType.UserAudio, AlbumId: AlbumId, UserId: UserId));
 }
Beispiel #2
0
        private async void ClearCacheBtn_Click(object sender, EventArgs e)
        {
            this.AudioClearCacheBtn.Enabled = false;
            MessageBox.Show("Cache will be cleaned in background", "Cache Cleaner", MessageBoxButtons.OK, MessageBoxIcon.Information);
            MainApi.ClientLog(LogStrings.Info.Audio.CacheCleanStarted);

            await Task.Run(() =>
            {
                foreach (var item in MainApi.DB.Select(DBTable.Audio, MainApi.Audio.CacheCount()))
                {
                    MainApi.Audio.DeleteFromCache(Convert.ToInt32((item as object[])[0]));
                }
            });

            MainApi.ClientLog(LogStrings.Info.Audio.CacheCleanFinished);
            this.AudioClearCacheBtn.Enabled = true;
            CalculateCacheSize();
        }
Beispiel #3
0
 public Task Login(AuthInstance Inst)
 {
     MainApi.ClientLog("Started authorization");
     if (UpdateOnLogin != null)
     {
         UpdateOnLogin(this, new UpdateOnLoginEventArgs(false, Enums.Win.WorkerState.Working, "Authorization: Working"));
     }
     return(Task.Run(() =>
     {
         _isAuthorizerWorking = true;
         bool success = false;
         if (Inst.IsNormal)
         {
             success = MainApi.Authorize(Inst.EmailOrAccKey, Inst.PassOrId);
         }
         else
         {
             long userId = 0;
             try
             {
                 userId = Convert.ToInt64(Inst.PassOrId);
             }
             catch (Exception)
             {
                 if (ShowMBox != null)
                 {
                     ShowMBox(this, new ShowMBoxEventArgs(LogStrings.Error.Auth.InvalidAccKey, "Error", System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxButtons.OK));
                 }
                 _isAuthorizerWorking = false;
                 CheckAuthorization();
                 return;
             }
             success = MainApi.Authorize(Inst.EmailOrAccKey, userId);
         }
         if (!success)
         {
             if (ShowMBox != null)
             {
                 ShowMBox(this, new ShowMBoxEventArgs("Failed to authorize you at vk.com.\nThis may happen because of:\n\t1.Invalid email or password.\n\t2.You have no internet connection.\n\t3.Vk servers are down.", "Authorization error", System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxButtons.OK));
             }
         }
         _isAuthorizerWorking = false;
         CheckAuthorization();
     }));
 }