Пример #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (_textMessage == null)
        {
            TextMessagePanel.Visible = false;
        }
        else
        {
            Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex);

            TextMessagePanel.Visible    = true;
            TextMessageTimestamp.Text   = timeZone.ToLocalTime(_textMessage.Timestamp).ToString();
            TextMessage.Text            = _textMessage.Message;
            Acknowledge.CommandArgument = _textMessage.Id.ToString();
        }
    }
    private void loadEngineStatus()
    {
        Database db         = Global.GetDbConnection();
        Service  dbSvc      = db.GetService(ServiceId);
        DateTime serverTime = db.GetServerTime();

        Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex);

        bool suspectedCrash =
            dbSvc.Enabled &&
            (Math.Abs(dbSvc.LastRunTime.Subtract(serverTime).TotalMinutes) > dbSvc.RunIntervalMinutes * 2 ||
             // More than 2 cycles times have passed since last run time
             Math.Abs(dbSvc.LastHeartbeat.Subtract(serverTime).TotalMinutes) > EngineBase.HEARTBEAT_INTERVAL.TotalMinutes * 2);

        // More than 2 heartbeat cycle times have passed since last heartbeat

        Interval.Text      = dbSvc.RunIntervalMinutes.ToString();
        LastRunTime.Text   = dbSvc.LastRunTime == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastRunTime).ToString();
        LastHeartbeat.Text = dbSvc.LastHeartbeat == new DateTime()
                                        ? "Never"
                                        : timeZone.ToLocalTime(dbSvc.LastHeartbeat).ToString();
        ServerTime.Text  = timeZone.ToLocalTime(serverTime).ToString();
        NextRunTime.Text = dbSvc.Enabled
                                        ? "~" + timeZone.ToLocalTime(dbSvc.LastRunTime.AddMinutes(dbSvc.RunIntervalMinutes))
                                        : "Next time service is started";

        EngineStatus.Text = string.Format("{0}{1}{2}{3}",
                                          suspectedCrash
                                                        ? "<span style=\"font-weight:bold;\">Suspected crash (either 2 heartbeat or run times have past since last)</span><br />"
                                                        : string.Empty,
                                          dbSvc.ForceRun ? "Forced run pending<br />" : string.Empty,
                                          dbSvc.ReloadConfiguration ? "Reload configuration pending<br />" : string.Empty,
                                          dbSvc.ReloadConfiguration
                                                        ?
                                          (dbSvc.Enabled
                                                                        ? "Will be started next heartbeat"
                                                                        : "Will be stopped next hearteat")
                                                        :
                                          (dbSvc.Enabled ? "Enabled" : "Disabled"));
        StartEngine.Visible = !dbSvc.Enabled;
        StopEngine.Visible  = dbSvc.Enabled;

        ServiceInformation.Style.Add("color",
                                     suspectedCrash
                                                ? "red"
                                                : dbSvc.Enabled && !dbSvc.ReloadConfiguration ? "green" : "#E0691A");
    }
Пример #3
0
    private void loadEngineStatus()
    {
        int?serviceId = ServiceIdParameter;

        if (serviceId != null)
        {
            RtEngineBase engine     = RtEngines.GetRtEngine((int)serviceId);
            Database     db         = Global.GetDbConnection();
            Service      dbSvc      = db.GetService(engine.ServiceId);
            DateTime     serverTime = db.GetServerTime();

            Win32TimeZone timeZone = TimeZones.GetTimeZone(Profile.TimeZoneIndex);

            ServiceOwnerName.Text = engine.ServiceOwnerName;
            HeartBeating.Text     = engine.IsHeartBeating ? string.Empty : "Not";
            IsRunning.Text        = engine.IsRunning ? "Running" : "Stopped";
            IsServiceOwner.Text   = engine.IsServiceOwner ? "Yes" : "No";
            WebServiceInformation.Style.Add("color",
                                            engine.IsServiceOwner && engine.IsRunning ||
                                            !engine.IsServiceOwner && !engine.IsRunning
                                                                ? "green"
                                                                : "red");

            bool suspectedCrash =
                dbSvc.Enabled &&
                (Math.Abs(dbSvc.LastRunTime.Subtract(serverTime).TotalMinutes) > dbSvc.RunIntervalMinutes * 2 ||
                 // More than 2 cycles times have passed since last run time
                 Math.Abs(dbSvc.LastHeartbeat.Subtract(serverTime).TotalMinutes) > EngineBase.HEARTBEAT_INTERVAL.TotalMinutes * 2);
            // More than 2 heartbeat cycle times have passed since last heartbeat

            ServiceOwner.Text  = dbSvc.Owner;
            LastRunTime.Text   = dbSvc.LastRunTime == new DateTime() ? "Never" : timeZone.ToLocalTime(dbSvc.LastRunTime).ToString();
            LastHeartbeat.Text = dbSvc.LastHeartbeat == new DateTime()
                                                ? "Never"
                                                : timeZone.ToLocalTime(dbSvc.LastHeartbeat).ToString();
            ServerTime.Text  = timeZone.ToLocalTime(serverTime).ToString();
            NextRunTime.Text = dbSvc.Enabled
                                                ? "~" + timeZone.ToLocalTime(dbSvc.LastRunTime.AddMinutes(dbSvc.RunIntervalMinutes))
                                                : "Next time service is started";

            EngineDatabaseStatus.Text = string.Format("{0}{1}{2}{3}",
                                                      suspectedCrash
                                                                        ? "<span style=\"font-weight:bold;\">Suspected crash</span><br />"
                                                                        : string.Empty,
                                                      dbSvc.ForceRun ? "Forced run pending<br />" : string.Empty,
                                                      dbSvc.ReloadConfiguration
                                                                        ? "Reload configuration pending<br />"
                                                                        : string.Empty,
                                                      dbSvc.ReloadConfiguration
                                                                        ?
                                                      (dbSvc.Enabled
                                                                                        ? "Will be started next heartbeat"
                                                                                        : "Will be stopped next hearteat")
                                                                        :
                                                      (dbSvc.Enabled ? "Enabled" : "Disabled"));
            ServiceInformation.Style.Add("color",
                                         suspectedCrash
                                                        ? "red"
                                                        : dbSvc.Enabled && !dbSvc.ReloadConfiguration ? "green" : "#E0691A");

            StartHeartbeat.Visible = !engine.IsHeartBeating;
            StopHeartbeat.Visible  = engine.IsHeartBeating;
            StartEngine.Visible    = !engine.IsRunning;
            StopEngine.Visible     = engine.IsRunning;
        }
        else
        {
            AjaxPanel1.Visible = false;
        }
    }