/// <summary> /// Записать статус сервиса после выполнения /// </summary> /// <param name="id_service"></param> /// <param name="start"></param> /// <param name="stop"></param> /// <returns></returns> public static long WriteLogStatusServices(this int id_service, DateTime start, DateTime stop) { try { TimeSpan ts = stop - start; int cur_ms = (int)ts.TotalMilliseconds; EFServicesLog efsl = new EFServicesLog(_blog); LogStatusServices status = efsl.GetLogStatusServices(id_service); if (status == null) { status = new LogStatusServices() { id = 0, service = id_service, start = start, execution = start, min = cur_ms, max = cur_ms }; } status.execution = start; status.current = cur_ms; status.min = status.min == null || cur_ms < status.min ? cur_ms : status.min; status.max = status.max == null || cur_ms > status.max ? cur_ms : status.max; return(efsl.SaveLogStatusServices(status)); } catch (Exception e) { e.SaveErrorMethod(String.Format("WriteLogStatusServices(id_service={0}, start={1}, stop={2})", id_service, start, stop), _blog); return(-1); } }
/// <summary> /// Записать статус сервиса при запуске /// </summary> /// <param name="id_service"></param> /// <param name="start"></param> /// <returns></returns> public static long WriteLogStatusServices(this int id_service, DateTime start) { try { EFServicesLog efsl = new EFServicesLog(_blog); LogStatusServices status = efsl.GetLogStatusServices(id_service); if (status == null) { status = new LogStatusServices() { id = 0, service = id_service, }; } status.start = start; status.execution = null; status.current = null; return(efsl.SaveLogStatusServices(status)); } catch (Exception e) { e.SaveErrorMethod(String.Format("WriteLogStatusServices(id_service={0}, start={1})", id_service, start), _blog); return(-1); } }