/// <summary>
        /// Generates the absolute number of the shift that the specified localTime
        /// belongs to. The index is built according to the below formula:
        ///
        /// YYYY*10^5 + MM*10^3 + dd*10^1 + shiftNumber
        ///
        /// for example, RusHydro's day shift of 2018.12.03 has its ShiftAbsoluteIndex of 201.812.031
        /// (where . is the thousands separator)
        /// </summary>
        public static long GetAbsoluteIndex(DateTime localTime)
        {
            const long fY        = 100000;
            const long fM        = 1000;
            const long fD        = 10;
            var        shiftDate = RusHydroScheduler.GetShiftStartDate(localTime, out bool _, out int shiftNumber);

            return(shiftDate.Year * fY + shiftDate.Month * fM + shiftDate.Day * fD + shiftNumber);
        }
Ejemplo n.º 2
0
        private WorkingShiftDescriptor GetShiftDescriptor(DateTime completionLocalTime)
        {
            var absIndex   = WorkingShiftAbsoluteIndex.GetAbsoluteIndex(completionLocalTime);
            var shiftDate  = RusHydroScheduler.GetShiftStartDate(completionLocalTime, out bool _, out int shiftNumber);
            var shiftStart = RusHydroScheduler.GetShiftStartTime(completionLocalTime, out bool _, out int _);

            return(new WorkingShiftDescriptor
            {
                ShiftAbsoluteIndex = absIndex,
                ShiftDate = shiftDate,
                ShiftStartTime = shiftStart.TimeOfDay,
                ShiftNumber = shiftNumber,
                // watch out, some localizable strings here!
                ShiftName = shiftNumber == 1 ? "день" : "ночь"
            });
        }
        public async Task <string> ProcessInspectionResultsAsync(Guid inspectionId, CancellationToken cancellationToken)
        {
            var generator = new PreShiftSummaryGenerator();
            var testData  = await GetTestDataAsync(inspectionId);

            if (testData == null)
            {
                return(null);
            }

            var summary = generator.GenerateSummary(_environmentId, inspectionId, testData.Employee, testData.SvmrRawData, testData.HrvRawData);

            summary.DepartmentId   = testData.Inspection.DepartmentId;
            summary.BranchOfficeId = testData.Inspection.BranchOfficeId;

            // add shift start date & number
            summary.WorkingShiftDate = RusHydroScheduler.GetShiftStartDate(
                summary.CompletionTime.LocalDateTime, out bool isDayShift, out int shiftNumber);
            summary.WorkingShiftNumber = shiftNumber;

            await StoreSummary(summary);

            return($"api/plugins/rushydro-psa/summary/inspection/{inspectionId}");
        }