コード例 #1
0
        public static ValidateResult Validate(DateTime?scheduledTime, DateTime checkInTime, out string message)
        {
            message = "";
            if (scheduledTime == null)
            {
                message = SR.MessageCheckInUnscheduledProcedure;
                return(ValidateResult.NotScheduled);
            }

            var earlyBound = scheduledTime.Value.AddMinutes(-Default.EarlyCheckInWarningThreshold);
            var lateBound  = scheduledTime.Value.AddMinutes(Default.LateCheckInWarningThreshold);

            if (checkInTime < earlyBound)
            {
                var threshold = TimeSpan.FromMinutes(Default.EarlyCheckInWarningThreshold);
                message = string.Format(SR.MessageAlertCheckingInTooEarly, TimeSpanFormat.FormatDescriptive(threshold));
                return(ValidateResult.TooEarly);
            }

            if (checkInTime > lateBound)
            {
                var threshold = TimeSpan.FromMinutes(Default.LateCheckInWarningThreshold);
                message = string.Format(SR.MessageAlertCheckingInTooLate, TimeSpanFormat.FormatDescriptive(threshold));
                return(ValidateResult.TooLate);
            }

            return(ValidateResult.Success);
        }
コード例 #2
0
        private bool Confirm(IEnumerable <CheckInOrderTableEntry> checkedEntries)
        {
            var warnProcedures  = new List <ProcedureSummary>();
            var errorProcedures = new List <ProcedureSummary>();

            // Get the list of Order EntityRef from the table
            foreach (var entry in checkedEntries)
            {
                string checkInValidationMessage;
                var    result = CheckInSettings.Validate(entry.Procedure.ScheduledStartTime, _checkInTime, out checkInValidationMessage);
                switch (result)
                {
                case CheckInSettings.ValidateResult.TooEarly:
                case CheckInSettings.ValidateResult.TooLate:
                    warnProcedures.Add(entry.Procedure);
                    break;

                case CheckInSettings.ValidateResult.NotScheduled:
                    errorProcedures.Add(entry.Procedure);
                    break;
                }
            }

            if (errorProcedures.Count > 0)
            {
                var messageBuilder = new StringBuilder();
                messageBuilder.Append(SR.MessageCheckInProceduresNotScheduled);
                messageBuilder.AppendLine();
                messageBuilder.AppendLine();
                CollectionUtils.ForEach(errorProcedures, procedure => messageBuilder.AppendLine(ProcedureFormat.Format(procedure)));

                this.Host.DesktopWindow.ShowMessageBox(messageBuilder.ToString(), MessageBoxActions.Ok);
                return(false);
            }

            if (warnProcedures.Count > 0)
            {
                var earlyThreshold = TimeSpan.FromMinutes(CheckInSettings.Default.EarlyCheckInWarningThreshold);
                var lateThreshold  = TimeSpan.FromMinutes(CheckInSettings.Default.LateCheckInWarningThreshold);

                var messageBuilder = new StringBuilder();
                messageBuilder.AppendFormat(SR.MessageCheckInProceduresTooLateOrTooEarly,
                                            TimeSpanFormat.FormatDescriptive(earlyThreshold),
                                            TimeSpanFormat.FormatDescriptive(lateThreshold));
                messageBuilder.AppendLine();
                messageBuilder.AppendLine();
                CollectionUtils.ForEach(warnProcedures, procedure => messageBuilder.AppendLine(ProcedureFormat.Format(procedure)));
                messageBuilder.AppendLine();
                messageBuilder.Append(SR.MessageConfirmCheckInProcedures);

                if (DialogBoxAction.No == this.Host.DesktopWindow.ShowMessageBox(messageBuilder.ToString(), MessageBoxActions.YesNo))
                {
                    return(false);
                }
            }
            return(true);
        }