コード例 #1
0
        /// <summary>
        /// Sets the extension success status.
        /// </summary>
        /// <param name="serviceId">The service id.</param>
        /// <param name="success">if set to <c>true</c> [success].</param>
        /// <param name="serviceStatusDatabasePath">The service status database path.</param>
        public static void SetExtensionSuccessStatus(int serviceId, bool success, string serviceStatusDatabasePath, FileLoggerConfiguration loggerConfiguration)
        {
            var svcMon = new SC_StatusDbDt.ServiceMonitor();

            dynamic data = new { };

            if (svcMon.Count(string.Format("ServiceId = {0}", serviceId)) > 0)
            {
                if (success)
                {
                    data = new { ServiceSuccessRunTime = DateTime.Now };
                }
                else
                {
                    data = new { ServiceFailRunTime = DateTime.Now };
                }
                svcMon.Update(data, new { ServiceId = serviceId });
            }
            else
            {
                if (success)
                {
                    data = new { ServiceSuccessRunTime = DateTime.Now, ServiceId = serviceId };
                }
                else
                {
                    data = new { ServiceFailRunTime = DateTime.Now, ServiceId = serviceId };
                }
                svcMon.Insert(data);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the service monitor time.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="serviceStatusDatabasePath">The service status database path.</param>
        /// <returns></returns>
        public static DateTime GetServiceMonitorTime(Service service, string serviceStatusDatabasePath, FileLoggerConfiguration loggerConfiguration)
        {
            DateTime returnTime = new DateTime();

            var svcMon = new SC_StatusDbDt.ServiceMonitor();

            var monitorTime = svcMon.Single(new { ServiceId = service.ServiceId });

            returnTime = monitorTime.MonitorTime;

            return(returnTime);
        }
コード例 #3
0
        /// <summary>
        /// Updates the service monitor.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="serviceStatusDatabasePath">The service status database path.</param>
        public static void UpdateServiceMonitor(Service service, string serviceStatusDatabasePath, FileLoggerConfiguration loggerConfiguration)
        {
            var svcMon = new SC_StatusDbDt.ServiceMonitor();

            if (svcMon.Count(string.Format("ServiceId = {0}", service.ServiceId)) > 0)
            {
                svcMon.Update(new { MonitorTime = DateTime.Now }, new { ServiceId = service.ServiceId });
            }
            else
            {
                svcMon.Insert(new { MonitorTime = DateTime.Now, ServiceId = service.ServiceId });
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets the extension execute status time.
        /// </summary>
        /// <param name="service">The service.</param>
        /// <param name="success">if set to <c>true</c> [success].</param>
        /// <param name="serviceStatusDatabasePath">The service status database path.</param>
        /// <returns></returns>
        public static DateTime GetExtensionExecuteStatusTime(Service service, bool success, string serviceStatusDatabasePath, FileLoggerConfiguration loggerConfiguration)
        {
            DateTime returnTime = DateTime.MinValue;

            var svcMon = new SC_StatusDbDt.ServiceMonitor();

            var monitorTime = svcMon.Single(new { ServiceId = service.ServiceId });

            if (success)
            {
                returnTime = monitorTime.ServiceSuccessRunTime;
            }
            else
            {
                returnTime = monitorTime.ServiceFailRunTime;
            }

            return(returnTime);
        }