Exemplo n.º 1
0
        private void CheckOnline(bool silent = false)
        {
            if (!Program.NoGit)
            {
                // Is remote on in the config
                if (_config["UseGitRemote"])
                {
                    // Check if the remote is there
                    if (GitHandling.CheckConnection(_config["GitRemote"]))
                    {
                        // looks good, let's try
                        this.gitRepoOffline = false;
                    }

                    // Do a fetch to get the latest repo.
                    if (!GitRepo.Fetch(_config["GitUser"], DecryptConfig(_config["GitPass"], "pass4win")))
                    {
                        // nope not online
                        this.gitRepoOffline = true;
                        MessageBox.Show(Strings.Error_connection, Strings.Error, MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                    else
                    {
                        // We're online
                        toolStripOffline.Visible = false;
                        // sync with remote
                        if (!GitRepo.Push(_config["GitUser"], DecryptConfig(_config["GitPass"], "pass4win")))
                        {
                            MessageBox.Show(
                                Strings.FrmMain_EncryptCallback_Push_to_remote_repo_failed_,
                                Strings.Error,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                        }
                    }
                }
                else
                {
                    // no remote checkbox so we're staying offline
                    if (!silent)
                    {
                        MessageBox.Show(
                            Strings.Error_remote_disabled,
                            Strings.Error,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Validates if the host is filled when the remote repo is checked
 /// Also checkes on alive (with a connect) and when that fails if it's a valid formed URL
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtGitHostValidating(object sender, CancelEventArgs e)
 {
     if (chkboxRemoteRepo.Checked && txtGitHost.Text == "")
     {
         errorProvider1.SetError(txtGitHost, Strings.Error_required_field);
         if (this.valCancel)
         {
             e.Cancel = true;
         }
     }
     else
     {
         if (chkboxRemoteRepo.Checked)
         {
             if (!GitHandling.CheckConnection(txtGitHost.Text))
             {
                 if (this.valCancel)
                 {
                     Uri hostTest;
                     if (!Uri.TryCreate(txtGitHost.Text, UriKind.Absolute, out hostTest))
                     {
                         errorProvider1.SetError(txtGitHost, Strings.Error_notvalid_URL);
                         e.Cancel = true;
                     }
                 }
                 else
                 {
                     errorProvider1.SetError(txtGitHost, Strings.Error_host_unreachable);
                     this.offline = true;
                 }
             }
             else
             {
                 this.offline = false;
             }
         }
     }
 }