예제 #1
0
        static void Main(string[] args)
        {
            Application application = new Application();

            application.DisplayAlerts = false;
            Workbook scheduleWorkbook = null;
            var      startDate        = DateTime.Now.Date;
            var      endDate          = startDate.AddMonths(1);

            try
            {
                scheduleWorkbook = application.Workbooks.Add();
                var tat = new TatarstanWorkDayCalendar(TimeSpan.FromHours(10),
                                                       TimeSpan.FromHours(18));
                tat.EnsureInitializedAsync().Wait();
                var workTimeCalculator =
                    new WorkTimeCalculator(tat);
                Worksheet scheduleSheet = scheduleWorkbook.ActiveSheet;
                PrintDateRow(scheduleSheet, startDate, endDate);
                var schedule = workTimeCalculator.GetSchedule(startDate, new WorkTime(20, 0, 0));
                PrintSchedule(scheduleSheet, 2, schedule);
                scheduleWorkbook.SaveAs(@"\C:\Users\almaz\OneDrive\Документы\test.xlsx");
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            finally
            {
                scheduleWorkbook?.Close(true);
                application.Quit();
                Marshal.ReleaseComObject(application);
            }
        }
예제 #2
0
        public void GetSchedule_10122018And4900_Returns121120180100()
        {
            var timeCalculator = new WorkTimeCalculator(new SimpleWorkDayCalendar(TimeSpan.FromHours(10), TimeSpan.FromHours(18)));
            var expected       = new DateTime(2018, 12, 18, 11, 0, 0);
            var actual         = timeCalculator.GetSchedule(new DateTime(2018, 12, 10), new WorkTime(49 * 60));

            Assert.NotNull(actual);
        }