Esempio n. 1
0
    protected void ForceHeartbeat_Click(object sender, EventArgs e)
    {
        int?serviceId = ServiceIdParameter;

        if (serviceId != null)
        {
            RtEngineBase engine = RtEngines.GetRtEngine((int)serviceId);
            engine.ForceHeartbeat();
            loadEngineStatus();
        }
    }
Esempio n. 2
0
    protected void ForceConfigReload_Click(object sender, EventArgs e)
    {
        int?serviceId = ServiceIdParameter;

        if (serviceId != null)
        {
            RtEngineBase engine = RtEngines.GetRtEngine((int)serviceId);
            engine.ForceReloadConfiguration();
            loadEngineStatus();
        }
    }
    protected void ReloadEngineConfig_Click(object sender, EventArgs e)
    {
        RtEngineBase engine = RtEngines.GetRtEngine(ServiceId);
        Database     db     = Global.GetDbConnection();
        Service      dbSvc  = db.GetService(engine.ServiceId);

        dbSvc.ReloadConfiguration = true;
        db.SaveService(dbSvc);

        loadEngineStatus();
    }
Esempio n. 4
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;
        }
    }