Esempio n. 1
0
        private void SetStateAndLastCheck()
        {
            ServiceActivity activity = ActivityDAO.GetActivityData();

            if (!activity.IsSucceeded)
            {
                lblLastCheck.Text    = "n/a";
                lblCurrentState.Text = "n/a";

                progressBar1.ProgressText = "";
                progressBar1.Value        = 0;
                if (!isLastConnectionFailed)
                {
                    isLastConnectionFailed = true;
                    Program.ShowMessageBox("Unable to establish DB connection. Check Database settings.");
                    listView1.Items[2].Selected = true;
                    listView1.Items[2].Focused  = true;
                    listView1.Select();
                }

                return;
            }

            isLastConnectionFailed = false;
            lblLastCheck.Text      = activity.LastCheck.ToString(@"M/d/yyyy hh:mm:ss tt");
            lastCheckDate          = activity.LastCheck;

            bool bWorkingState = (activity.WorkingState &&
                                  (lblCurrentStatus.Text == ServiceControllerStatus.Running.ToString()));

            lblCurrentState.Text = bWorkingState ? "Working" : "Idle";

            if (bWorkingState)
            {
                if (progressBar1.Maximum != activity.TotalProgress)
                {
                    progressBar1.Maximum = activity.TotalProgress;
                    progressBar1.Value   = 0;
                }

                progressBar1.ProgressText = activity.PassedProgress + " out of " + activity.TotalProgress + "...";
                progressBar1.Value        = activity.PassedProgress;
            }
            else
            {
                progressBar1.ProgressText = "";
                progressBar1.Value        = 0;
            }
        }
Esempio n. 2
0
        private static void ShowBalloon(object sender, MouseEventArgs e)
        {
            if (!isBalloonShown && !notifyIcon.ContextMenuStrip.Visible)
            {
                StringBuilder strBalloon = new StringBuilder();
                strBalloon.AppendLine("Current service status  " + serviceController.Status);
                ServiceActivity activity = ActivityDAO.GetActivityData();

                strBalloon.AppendLine("Time when service ran the last check  " +
                                      (activity.IsSucceeded ? activity.LastCheck.ToString(@"M/d/yyyy hh:mm:ss tt") : "n/a"));
                if (!activity.IsSucceeded)
                {
                    strBalloon.AppendLine("Current state  n/a");
                }
                else
                {
                    if ((activity.WorkingState &&
                         (serviceController.Status == ServiceControllerStatus.Running)))
                    {
                        strBalloon.AppendLine("Current state  Working: " +
                                              activity.PassedProgress + " out of " + activity.TotalProgress + "...");
                    }
                    else
                    {
                        strBalloon.AppendLine("Current state  Idle");
                    }
                }

                string        path   = Utils.ServiceInfo.GetServicePath();
                Configuration config = Utils.ServiceInfo.GetServiceConfig(path);
                if (config.AppSettings.Settings["EmailServerName"] != null)
                {
                    strBalloon.AppendLine("SMTP/Exchange server name/IP  " + config.AppSettings.Settings["EmailServerName"].Value);
                }

                string sBalloon = strBalloon.ToString();

                balloonPosition = Cursor.Position;
                notifyIcon.ShowBalloonTip(5000, "Service information",
                                          sBalloon,
                                          ToolTipIcon.Info);

                isBalloonShown = true;
            }
        }