コード例 #1
0
        public void CanGetLabCleanConfiguration()
        {
            LabCleanConfiguration config = LabCleanConfiguration.GetCurrentConfiguration();

            Assert.AreEqual(1, config.Items.Count());
            Assert.AreEqual(1, config.Items.ElementAt(0).Days[0]);
            Assert.AreEqual(4, config.Items.ElementAt(0).Days[1]);
            Assert.AreEqual(510, config.Items.ElementAt(0).StartTime.TotalMinutes);
            Assert.AreEqual(570, config.Items.ElementAt(0).EndTime.TotalMinutes);
            Assert.AreEqual(0, config.Items.ElementAt(0).StartPadding);
            Assert.AreEqual(45, config.Items.ElementAt(0).EndPadding);
            Assert.IsTrue(config.Items.ElementAt(0).Active);
        }
コード例 #2
0
        public bool ShowLabCleanWarning(DateTime beginDateTime, DateTime endDateTime)
        {
            bool showWarning;

            string setting = ConfigurationManager.AppSettings["ShowLabCleanWarning"];

            if (string.IsNullOrEmpty(setting))
            {
                showWarning = true;
            }
            else
            {
                bool.TryParse(setting, out showWarning);
            }

            if (showWarning)
            {
                LabCleanConfiguration config = LabCleanConfiguration.GetCurrentConfiguration();

                DateTime sdate       = beginDateTime.Date;
                DateTime edate       = endDateTime.Date.AddDays(1);
                DateTime currentDate = sdate;

                while (currentDate < edate)
                {
                    DateTime yesterday = currentDate.AddDays(-1); //need this to determine lab clean days that are moved by holidays

                    DateTime labCleanBegin;
                    DateTime labCleanEnd;

                    foreach (var item in config.Items)
                    {
                        if (item.Active)
                        {
                            // current day is not a holiday and is included
                            // or previous day is a holiday and is included
                            bool isLabCleanDay =
                                (!Provider.Data.Holiday.IsHoliday(currentDate) && item.Days.Contains((int)currentDate.DayOfWeek)) || //we have a standard non-holiday lab clean day
                                (Provider.Data.Holiday.IsHoliday(yesterday) && item.Days.Contains((int)yesterday.DayOfWeek));    //we have a non standard lab clean day due to holiday

                            if (isLabCleanDay)
                            {
                                // Sandrine wants a 45 minute padding after the labclean end time as of 2018-10-22 - jg

                                var sPad = TimeSpan.FromMinutes(item.StartPadding);
                                var ePad = TimeSpan.FromMinutes(item.EndPadding);

                                labCleanBegin = currentDate
                                                .Add(item.StartTime) //e.g. 08:30
                                                .Subtract(sPad);     //e.g. 10 (minutes)

                                labCleanEnd = currentDate
                                              .Add(item.EndTime) //e.g. 09:30
                                              .Add(ePad);        //e.g. 45 (minutes)

                                if (beginDateTime < labCleanEnd && endDateTime > labCleanBegin)
                                {
                                    return(true);
                                }
                            }
                        }
                    }

                    currentDate = currentDate.AddDays(1);
                }
            }

            return(false);
        }