Beispiel #1
0
 private void optionsToolStripMenuItem2_Click(object sender, EventArgs e)
 {
     FormOptions Options = new FormOptions();
     Options.FormClosing += new FormClosingEventHandler(FormOptions_Close);
     Options.ShowDialog();
 }
Beispiel #2
0
        async private void checkUpdates()
        {
            timer.Start();

            // Set the images to blank
            imgCore.Visible = false;
            imgPlugins.Visible = false;
            imgThemes.Visible = false;

            progressBar.Style = ProgressBarStyle.Continuous;
            progressBar.Maximum = 100;
            progressBar.Value = 5;

            string BaseUrl = Properties.Settings.Default.sitesList[0].BaseUrl.ToString();
            string Username = Properties.Settings.Default.sitesList[0].Username.ToString();
            string Password = Properties.Settings.Default.sitesList[0].Password.ToString();

            corecheck.Text = plugincheck.Text = themecheck.Text = "Checking...";

            FormOptions Options = new FormOptions();

            // WordPressSharp: https://github.com/abrudtkuhl/WordPressSharp
            using (var client = new WordPressClient(new WordPressSiteConfig
            {
                BaseUrl = BaseUrl,
                Username = Username,
                Password =  Options.DecryptString(Password),
                BlogId = 1
            }))
            {

                //var id = Convert.ToInt32(client.NewPost(post));
                //var username = Convert.ToString(client.GetUser(1).Nicename);
                //var plugins = Convert.ToString(client.GetPluginUpdateCheck());

                // Close off the Options object, only needed to Decrypt Password
                Options = null;

                var thereAreUpdates = false;

                progressBar.Value = 40;

                var response = client.GetAllUpdatesCheck();

                if (response.core)
                {
                    corecheck.Text = "Core updates!";
                    thereAreUpdates = true;
                    imgCore.Image = Properties.Resources.error;
                    imgCore.Visible = true;
                }
                else
                {
                    corecheck.Text = "No updates for Core.";
                    imgCore.Image = Properties.Resources.check;
                    imgCore.Visible = true;
                }

                if (response.plugins)
                {
                    plugincheck.Text = "Plugin Updates!";
                    thereAreUpdates = true;
                    imgPlugins.Image = Properties.Resources.error;
                    imgPlugins.Visible = true;
                }
                else
                {
                    plugincheck.Text = "No updates for Plugins.";
                    imgPlugins.Image = Properties.Resources.check;
                    imgPlugins.Visible = true;
                }

                if (response.themes)
                {
                    themecheck.Text = "Theme updates!";
                    thereAreUpdates = true;
                    imgThemes.Image = Properties.Resources.error;
                    imgThemes.Visible = true;
                }
                else
                {
                    themecheck.Text = "No updates for Themes.";
                    imgThemes.Image = Properties.Resources.check;
                    imgThemes.Visible = true;
                }

                if (thereAreUpdates == true)
                {
                    //if (this.WindowState == FormWindowState.Minimized)
                    {
                        this.notifyIcon1.BalloonTipText = "There are some updates! Double click me to check the details.";
                        this.notifyIcon1.BalloonTipTitle = "Updates!";
                        this.notifyIcon1.Visible = true;
                        this.notifyIcon1.ShowBalloonTip(3000);
                    }
                }

                progressBar.Value = 100;

                //var plugins = Convert.ToString(client.GetAllUpdatesCheck());

                //plugincheck.Text = username;
                //plugincheck.Text = plugins;

                // Figure out next run time

                var numHours = Int32.Parse(comboBox1.GetItemText(comboBox1.SelectedItem));
                var nextTime = DateTime.Now.AddHours(numHours);
                //var nextTime = DateTime.Now.AddMinutes(numHours); // FIXME!! should be hours

                labelNextRun.Text = nextTime.ToString();

                timerTickCount = DateTimeToUnixTimestamp(nextTime) - DateTimeToUnixTimestamp(DateTime.Now);
                
                await Task.Delay(getWaitTime() * 3600 * 1000);
                //await Task.Delay(getWaitTime() * 60 * 1000);
                checkUpdates();
            }
        }
Beispiel #3
0
 private void wordPressSitesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormOptions Options = new FormOptions();
     Options.ShowDialog();
 }