Beispiel #1
0
 private IPromise <TokenCredentials> ValidCredentials(bool async)
 {
     if (_tokenCreds == null)
     {
         _tokenCreds = GetCredentials(async);
         return(_tokenCreds);
     }
     else
     {
         return(_tokenCreds.Continue(c =>
         {
             if (c.Expires <= DateTime.UtcNow)
             {
                 _tokenCreds = GetCredentials(async);
                 return _tokenCreds;
             }
             else
             {
                 return Promises.Resolved(c);
             }
         }));
     }
 }
Beispiel #2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (_currentRun == null)
                {
                    if (_conn == null)
                    {
                        outputEditor.Text = "Please select a connection first";
                        return;
                    }

                    btnSubmit.Text    = "► Cancel";
                    outputEditor.Text = "Processing...";

                    _currentRun = _conn
                                  .Continue(c => _script.Execute(c))
                                  .UiPromise(this)
                                  .Done(s =>
                    {
                        outputEditor.Text = s;
                        _currentRun       = null;
                    })
                                  .Fail(ex => outputEditor.Text = ex.ToString());
                }
                else
                {
                    btnSubmit.Text = "► Run";
                    _currentRun.Cancel();
                    _currentRun = null;
                }
            }
            catch (Exception ex)
            {
                outputEditor.Text = ex.ToString();
            }
        }