BLL.Common.Utils.StopTimelapse C# (CSharp) Метод

StopTimelapse() публичный статический Метод

Checks if given timelapse needs to be stopped
public static StopTimelapse ( Timelapse timelapse ) : bool
timelapse BLL.Entities.Timelapse
Результат bool
        public static bool StopTimelapse(Timelapse timelapse)
        {
            //if (timelapse.Status == (int)TimelapseStatus.NotFound)
            //{
            //    timelapse.StatusTag = "Camera details not found";
            //    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Not Found");
            //    return true;
            //}

            //if (timelapse.Status == (int)TimelapseStatus.Failed)
            //{
            //    timelapse.StatusTag = "Camera not accessible";
            //    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Failed");
            //    return true;
            //}

            if (timelapse.Status == (int)TimelapseStatus.Stopped)
            {
                timelapse.StatusTag = "Recording stopped";
                FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Stopped");
                return true;
            }

            if (timelapse.Status == (int)TimelapseStatus.Paused)
            {
                timelapse.StatusTag = "Timelapse Paused";
                FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Paused");
                return true;
            }

            // otherwise if new, processing or scheduled
            if (timelapse.DateAlways && !timelapse.TimeAlways)
            {
                if (timelapse.FromDT.Hour >= timelapse.ToDT.Hour)
                {
                    DateTime nextDay = DateTime.UtcNow.AddDays(1);
                    if (DateTime.UtcNow >= new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, timelapse.ToDT.Hour, timelapse.ToDT.Minute, 59) &&
                        DateTime.UtcNow < new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, timelapse.FromDT.Hour, timelapse.FromDT.Minute, 00))
                    {
                        timelapse.Status = (int)TimelapseStatus.Scheduled; timelapse.StatusTag = "Recording on schedule";
                        FileLog("Utils.StopTimelapse#" + timelapse.ID + " - NoStop Recording Everyday Next");
                        return false;
                    }
                }
                else if (DateTime.UtcNow < new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, timelapse.FromDT.Hour, timelapse.FromDT.Minute, 0) ||
                    DateTime.UtcNow > new DateTime(DateTime.UtcNow.Year, DateTime.UtcNow.Month, DateTime.UtcNow.Day, timelapse.ToDT.Hour, timelapse.ToDT.Minute, 59))
                {
                    timelapse.Status = (int)TimelapseStatus.Scheduled; timelapse.StatusTag = "Recording on schedule";
                    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - NoStop Recording Everyday");
                    return true;
                }
            }
            else if (!timelapse.DateAlways && timelapse.TimeAlways)
            {
                if (DateTime.UtcNow < new DateTime(timelapse.FromDT.Year, timelapse.FromDT.Month, timelapse.FromDT.Day, 0, 0, 0) ||
                    DateTime.UtcNow >= new DateTime(timelapse.ToDT.Year, timelapse.ToDT.Month, timelapse.ToDT.Day, 23, 59, 59))
                {
                    timelapse.Status = (int)TimelapseStatus.Expired; timelapse.StatusTag = "Out of schedule";
                    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Anytime - Expired");
                    return true;
                }
            }
            else if (!timelapse.DateAlways && !timelapse.TimeAlways)
            {
                if (DateTime.UtcNow.Date >= timelapse.FromDT.Date && DateTime.UtcNow.Date <= timelapse.ToDT.Date)
                {
                    timelapse.Status = (int)TimelapseStatus.Scheduled; timelapse.StatusTag = "Recording on schedule";
                    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - NoStop Recording Range");
                    return false;
                }
                else
                {
                    timelapse.Status = (int)TimelapseStatus.Expired; timelapse.StatusTag = "Out of schedule";
                    FileLog("Utils.StopTimelapse#" + timelapse.ID + " - Stop Recording Range - Expired");
                    return true;
                }
            }

            FileLog("Utils.StopTimelapse#" + timelapse.ID + " - NoStop Recording");
            return false;
        }