public object GetAssignments(DayPilotScheduler scheduler) { DataTable dt = new DataTable(); var da = CreateDataAdapter("select * from [Assignment] where NOT (([AssignmentEnd] <= @start) OR ([AssignmentStart] >= @end))"); AddParameterWithValue(da.SelectCommand, "start", scheduler.StartDate); AddParameterWithValue(da.SelectCommand, "end", scheduler.EndDate.AddDays(1)); da.Fill(dt); return dt; }
protected string GetWorkPlanReport(DateTime dateTimeStartTO, DateTime dateTimeEndTO, ACType acType, /*TypeReport typeReports,*/ /*int planVersion,*/ bool oneHeader = false) { string html = ""; DayPilotScheduler scheduler = new DayPilotScheduler(); scheduler.HeaderFontSize = "11px"; scheduler.HeaderHeight = 16; scheduler.DataStartField = "start"; scheduler.ArrivalField = "arrival"; scheduler.DataEndField = "end"; scheduler.DepartureField = "departure"; scheduler.DataTextField = "name"; scheduler.DataValueField = "id"; scheduler.DataResourceField = "resource"; scheduler.EventFontSize = "10px"; scheduler.MHRField = "mhr"; scheduler.BookedMHRField = "bookedMHR"; scheduler.DataResourceNameField = "resourceName"; scheduler.ACTypeField = "acType"; scheduler.WorkTypeField = "workType"; scheduler.StationNameField = "stationName"; //отображение по дням без вертикальных линий по два часа //scheduler.CellDuration = 1440; //scheduler.CellWidth = 120; //scheduler.EventHeight = 45; //scheduler.RowHeaderWidth = 120; //scheduler.TwoHeaders = false; //отображение по два часа с дополнительным заголовком scheduler.CellDuration = 120; scheduler.CellWidth = 15; scheduler.TimeSpendingHeight = 14; scheduler.HeightBar = 4; scheduler.EventHeight = 50 + scheduler.TimeSpendingHeight; scheduler.RowHeaderWidth = 90; if (!oneHeader) { scheduler.TwoHeaders = true; } scheduler.BeforeEventRender += new BeforeEventRenderEventHandler(DayPilotScheduler_BeforeEventRender); scheduler.EventClickHandling = DayPilot.Web.Ui.Enums.EventClickHandlingEnum.JavaScript; scheduler.TimeRangeSelectedHandling = DayPilot.Web.Ui.Enums.TimeRangeSelectedHandling.Disabled; scheduler.CssOnly = true; scheduler.CssClassPrefix = "scheduler_transparent"; scheduler.TimeFormat = DayPilot.Web.Ui.Enums.TimeFormat.Clock24Hours; var entriesHome = new List <WPPlanDAO>() { new WPPlanDAO() { Arrival = new DateTime(2020, 08, 31, 16, 00, 00), Departure = new DateTime(2020, 08, 31, 20, 00, 00), WorkType = WorkType.Optional, Description = "Готовка еды", StartDate = new DateTime(2020, 08, 31, 20, 00, 00), EndDate = new DateTime(2020, 08, 31, 23, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Optional, Description = "Мойка посуды", StartDate = new DateTime(2020, 08, 31, 22, 00, 00), EndDate = new DateTime(2020, 08, 31, 23, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Sleep, Description = "Сон", StartDate = new DateTime(2020, 09, 01, 02, 00, 00), EndDate = new DateTime(2020, 09, 01, 10, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Sleep, Description = "Сон", StartDate = new DateTime(2020, 09, 02, 02, 00, 00), EndDate = new DateTime(2020, 09, 02, 10, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Sleep, Description = "Сон", StartDate = new DateTime(2020, 09, 03, 02, 00, 00), EndDate = new DateTime(2020, 09, 03, 10, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Sleep, Description = "Сон", StartDate = new DateTime(2020, 09, 04, 02, 00, 00), EndDate = new DateTime(2020, 09, 04, 10, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Sleep, Description = "Сон", StartDate = new DateTime(2020, 09, 05, 02, 00, 00), EndDate = new DateTime(2020, 09, 05, 10, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Задача 1 в блокноте", StartDate = new DateTime(2020, 09, 01, 10, 00, 00), EndDate = new DateTime(2020, 09, 01, 12, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Задача 2 в блокноте", StartDate = new DateTime(2020, 09, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 01, 20, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Подготовка к собеседованиям", StartDate = new DateTime(2020, 08, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 20, 20, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Переделать проект", StartDate = new DateTime(2020, 08, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 03, 20, 00, 00) } }; var entriesWork = new List <WPPlanDAO>() { new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Задача 789", StartDate = new DateTime(2020, 09, 01, 10, 00, 00), EndDate = new DateTime(2020, 09, 01, 12, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Задача 700", StartDate = new DateTime(2020, 09, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 01, 20, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Primary, Description = "Задача 56", StartDate = new DateTime(2020, 08, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 20, 20, 00, 00) }, new WPPlanDAO() { WorkType = WorkType.Optional, Description = "Задача 53", StartDate = new DateTime(2020, 08, 01, 12, 00, 00), EndDate = new DateTime(2020, 09, 03, 20, 00, 00) } }; var listResources = new List <Resource>() { new Resource("Дом", "A", entriesHome, new List <WorkType> { WorkType.Sleep, WorkType.Primary, WorkType.Optional }), new Resource("Работа", "B", entriesWork, new List <WorkType> { WorkType.Sleep, WorkType.Optional, WorkType.Primary }), }; foreach (var resource in listResources) { scheduler.Resources.Add(resource); } scheduler.StartDate = dateTimeStartTO; //scheduler.Days = 5;// DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month); scheduler.Days = (int)dateTimeStartTO.DifferenceBetweenTwoDatesAbs(dateTimeEndTO) + 1; var dataTable = CreateDataTableColumns(); CreateDataTable(scheduler.StartDate, dateTimeStartTO, dateTimeEndTO, null, dataTable, scheduler.Days, acType, /*typeReports, planVersion,*/ listResources); scheduler.DataSource = dataTable; //scheduler.DataSource = GetSchedulerData(); scheduler.DataBind(); var sb = new StringBuilder(); var sw = new StringWriter(sb); using (var htmlWriter = new HtmlTextWriter(sw)) { scheduler.RenderControl(htmlWriter); //2 - чтобы влезало ReportWidth = scheduler.GridWidth + scheduler.RowHeaderWidth + 5; //+ подпись ReportHeight = scheduler.GridHeight + 40 + 52; ReportRowHeadersWeight = scheduler.RowHeaderWidth; html = sb.ToString(); } return(html); }