/// <summary> /// Add resources views - units and timeline /// </summary> /// <returns></returns> public ActionResult MultipleResources() { var scheduler = new DHXScheduler(this); var rooms = new DHXSchedulerDataContext().Rooms.ToList(); scheduler.Views.Clear(); scheduler.Views.Add(new MonthView()); var unit = new UnitsView("unit", "room_id"); unit.AddOptions(rooms);//parse model objects scheduler.Views.Add(unit); var timeline = new TimelineView("timeline", "room_id"); timeline.RenderMode = TimelineView.RenderModes.Bar; timeline.FitEvents = false; timeline.AddOptions(rooms); scheduler.Views.Add(timeline); //show timeline view by default scheduler.InitialView = timeline.Name; scheduler.Lightbox.AddDefaults();//add default set of options - text and timepicker //add controls to the details form var select = new LightboxSelect("room_id", "Room id"); select.AddOptions(rooms); scheduler.Lightbox.Add(select); scheduler.LoadData = true; scheduler.InitialDate = new DateTime(2011, 9, 7); scheduler.EnableDataprocessor = true; return View(scheduler); }
/// <summary> /// applying client side filters for each view /// </summary> /// <returns></returns> public ActionResult Index() { var scheduler = new DHXScheduler(); var rooms = new DHXSchedulerDataContext().Rooms.ToList(); //each view can have multiple rules //they also can be added on the client scheduler.Views[1].Filter.Rules.Add(//month new Rule("start_date", Operator.GreaterOrEqual, new DateTime(2011, 9, 6)) ); scheduler.Views[1].Filter.Rules.Add( new Rule("end_date", Operator.LowerOrEqual, new DateTime(2011, 9, 14)) ); scheduler.Views[2].Filter.Rules.Add(//day new Rule("room_id", Operator.Equals, rooms.First().key) ); scheduler.Views[2].Filter.Rules.Add(//day new ExpressionRule("{text}.length > 4 && {text}.length < 20") ); var select = new LightboxSelect("room_id", "Room"); select.AddOptions(rooms); scheduler.Lightbox.AddDefaults(); scheduler.Lightbox.Add(select); scheduler.Controller = "BasicScheduler";//using BasicSchedulerController to load data scheduler.LoadData = true; scheduler.InitialDate = new DateTime(2011, 9, 7); return View(scheduler); }
public ContentResult Save(int? id, FormCollection actionValues) { var action = new DataAction(actionValues); var changedEvent = DHXEventsHelper.Bind<Event>(actionValues); DHXSchedulerDataContext data = new DHXSchedulerDataContext(); try { switch (action.Type) { case DataActionTypes.Insert: data.Events.InsertOnSubmit(changedEvent); break; case DataActionTypes.Delete: changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); data.Events.DeleteOnSubmit(changedEvent); break; default:// "update" var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); break; } data.SubmitChanges(); action.TargetId = changedEvent.id; } catch (Exception a) { action.Type = DataActionTypes.Error; } return (new AjaxSaveResponse(action)); }
/// <summary> /// Serializing data /// </summary> /// <returns></returns> public ActionResult ExportServerSide() { Response.ContentType = "text/plain"; Response.AppendHeader("content-disposition", "attachment; filename=dhtmlxScheduler.ics"); var renderer = new ICalRenderer(); var events = new DHXSchedulerDataContext().Events; return Content(renderer.ToICal(events)); //you can also use custom function for rendering of the events //renderer.ToICal(events, RenderItem); }
protected bool deleteRelated(DataAction action, Recurring changedEvent, DHXSchedulerDataContext context) { bool finished = false; if ((action.Type == DataActionTypes.Delete || action.Type == DataActionTypes.Update) && !string.IsNullOrEmpty(changedEvent.rec_type)) { context.Recurrings.DeleteAllOnSubmit(from ev in context.Recurrings where ev.event_pid == changedEvent.id select ev); } if (action.Type == DataActionTypes.Delete && (changedEvent.event_pid != 0 && changedEvent.event_pid != null)) { Recurring changed = (from ev in context.Recurrings where ev.id == action.TargetId select ev).Single() ; changed.rec_type = "none"; finished = true; } return finished; }
public ActionResult Index() { var sched = new DHXScheduler(this); var unit = new UnitsView("unit1", "room_id"); sched.Views.Add(unit); var context = new DHXSchedulerDataContext(); unit.AddOptions(context.Rooms.ToList()); sched.Data.Parse(context.Events); sched.EnableDataprocessor = true; sched.InitialDate = new DateTime(2011, 9, 5); return View(sched); }
public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues) { if (actionValues["actionType"] != null) { var actionType = actionValues["actionType"].ToLower(); var data = new DHXSchedulerDataContext(); try { if (actionType == "save") { if (data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId) != null) { //update event var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId); DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); action.Type = DataActionTypes.Update; } else { //create event data.ValidEvents.InsertOnSubmit(changedEvent); action.Type = DataActionTypes.Insert; } } else if (actionType == "delete") { changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId); data.ValidEvents.DeleteOnSubmit(changedEvent); action.Type = DataActionTypes.Delete; } data.SubmitChanges(); } catch (Exception e) { action.Type = DataActionTypes.Error; } } return (new SchedulerFormResponseScript(action, changedEvent)); }
public ContentResult Data() { var dc = new DHXSchedulerDataContext(); IEnumerable<Event> dataset; if (this.Request.QueryString["rooms"] == null) dataset = dc.Events; else{ var current_room = int.Parse(this.Request.QueryString["rooms"]); dataset = from ev in dc.Events where ev.room_id == current_room select ev; } var data = new SchedulerAjaxData(dataset); return (data); }
public ActionResult Index(FormCollection data) { var sched = new DHXScheduler(this); var rooms = new DHXSchedulerDataContext().Rooms.ToList(); var unit = new UnitsView("rooms", "room_id"); unit.Label = "Rooms"; unit.AddOptions(rooms); sched.Views.Add(unit); sched.InitialView = unit.Name; sched.InitialDate = new DateTime(2011, 9, 7); sched.LoadData = true; sched.EnableDataprocessor = true; return View(new SchedulerFilterModel(sched, rooms)); }
// // GET: /SchedulerAuthorization/ public ActionResult Index() { var sched = new DHXScheduler(this); sched.LoadData = true; sched.EnableDataprocessor = true; var context = new DHXSchedulerDataContext(); if (Request.IsAuthenticated) { var user = context.Users.SingleOrDefault(u => u.UserId == (Guid)Membership.GetUser().ProviderUserKey); sched.SetUserDetails(user, "UserId");//pass dictionary<string, object> or any object which can be serialized to json(without circular references) sched.Authentication.EventUserIdKey = "user_id";//set field in event which will be compared to user id(same as sched.Authentication.UserIdKey by default) } sched.SetEditMode(EditModes.OwnEventsOnly, EditModes.AuthenticatedOnly); sched.InitialDate = new DateTime(2011, 9, 26); return View(sched); }
public ActionResult Save(int? id, FormCollection actionValues) { var action = new DataAction(actionValues); DHXSchedulerDataContext data = new DHXSchedulerDataContext(); try { var changedEvent = DHXEventsHelper.Bind<Recurring>(actionValues); //operations with recurring events require some additional handling bool isFinished = deleteRelated(action, changedEvent, data); if (!isFinished) { switch (action.Type) { case DataActionTypes.Insert: data.Recurrings.InsertOnSubmit(changedEvent); if (changedEvent.rec_type == "none")//delete one event from the serie action.Type = DataActionTypes.Delete; break; case DataActionTypes.Delete: changedEvent = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId); data.Recurrings.DeleteOnSubmit(changedEvent); break; default:// "update" var eventToUpdate = data.Recurrings.SingleOrDefault(ev => ev.id == action.SourceId); DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); break; } } data.SubmitChanges(); action.TargetId = changedEvent.id; } catch (Exception a) { action.Type = DataActionTypes.Error; } return (new AjaxSaveResponse(action)); }
public ActionResult CustomSave(Event changedEvent, FormCollection actionValues) { var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id); if (actionValues["actionButton"] != null) { DHXSchedulerDataContext data = new DHXSchedulerDataContext(); try { if (actionValues["actionButton"] == "Save") { if (data.Events.SingleOrDefault(ev => ev.id == action.SourceId) != null) { var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); } else { action.Type = DataActionTypes.Insert; data.Events.InsertOnSubmit(changedEvent); } }else if(actionValues["actionButton"] == "Delete"){ action.Type = DataActionTypes.Delete; changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); data.Events.DeleteOnSubmit(changedEvent); } data.SubmitChanges(); } catch (Exception e) { action.Type = DataActionTypes.Error; } } else { action.Type = DataActionTypes.Error; } return (new SchedulerFormResponseScript(action, changedEvent)); }
// // GET: /CustomizeScale/ public ActionResult Index() { var sched = new DHXScheduler(this); sched.Config.first_hour = 8; sched.Config.last_hour = 18; sched.InitialDate = new DateTime(2011, 9, 19); var rooms = new DHXSchedulerDataContext().Rooms.ToList(); var timeline = new TimelineView("timeline", "room_id"); timeline.X_Unit = TimelineView.XScaleUnits.Hour; timeline.X_Size = 72; timeline.Scale.IgnoreRange(19, 23); timeline.Scale.IgnoreRange(0, 7); timeline.RenderMode = TimelineView.RenderModes.Bar; timeline.FitEvents = false; sched.TimeSpans.Add(new DHXMarkTime { FullWeek = true, Zones = new List<Zone> { new Zone(8 * 60 + 10, 19 * 60 - 10) }, CssClass = "day_split", InvertZones = true, Sections = new List<Section>{ new Section(timeline.Name, rooms.Select(r => r.key.ToString()).ToList()) } }); timeline.AddOptions(rooms); sched.Views.Add(timeline); sched.InitialView = timeline.Name; var week = sched.Views[1]; week.Scale.Ignore((int)DayOfWeek.Saturday, (int)DayOfWeek.Sunday); sched.LoadData = true; return View(sched); }
public ContentResult Save(int? id, FormCollection actionValues) { var action = new DataAction(actionValues); var changedEvent = DHXEventsHelper.Bind<Event>(actionValues); if (this.Request.IsAuthenticated && changedEvent.user_id == (Guid)Membership.GetUser().ProviderUserKey) { DHXSchedulerDataContext data = new DHXSchedulerDataContext(); try { switch (action.Type) { case DataActionTypes.Insert: changedEvent.room_id = data.Rooms.First().key; data.Events.InsertOnSubmit(changedEvent); break; case DataActionTypes.Delete: changedEvent = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); data.Events.DeleteOnSubmit(changedEvent); break; default:// "update" var eventToUpdate = data.Events.SingleOrDefault(ev => ev.id == action.SourceId); DHXEventsHelper.Update(eventToUpdate, changedEvent, new List<string>() { "id" }); break; } data.SubmitChanges(); action.TargetId = changedEvent.id; } catch (Exception a) { action.Type = DataActionTypes.Error; } } else { action.Type = DataActionTypes.Error; } return (new AjaxSaveResponse(action)); }
public ActionResult Index() { var sched = new DHXScheduler(this); sched.Skin = DHXScheduler.Skins.Terrace; var unit = new UnitsView("unit1", "room_id"); sched.Views.Add(unit); var context = new DHXSchedulerDataContext(); //can add IEnumerable of objects, native units or dictionary unit.AddOptions(context.Rooms);//parse model objects sched.Config.details_on_create = true; sched.Config.details_on_dblclick = true; var timeline = new TimelineView("timeline", "room_id"); var items = new List<object>(); timeline.FitEvents = false; sched.Views.Add(timeline); timeline.AddOptions(context.Rooms); var select = new LightboxSelect("textColor", "Priority"); items = new List<object>(); items.Add(new { key = "gray", label = "Low" }); items.Add(new { key = "blue", label = "Medium" }); items.Add(new { key = "red", label = "Hight" }); select.AddOptions(items); sched.Lightbox.Add(select); select = new LightboxSelect("room_id", "Room id"); select.AddOptions(context.Rooms); sched.Lightbox.Add(select); sched.LoadData = true; sched.EnableDataprocessor = true; sched.InitialDate = new DateTime(2011, 9, 5); return View(sched); }
public ActionResult Index(FormCollection data) { var sched = new DHXScheduler(this); sched.Extensions.Add(SchedulerExtensions.Extension.Cookie); var rooms = new DHXSchedulerDataContext().Rooms.ToList(); int selectedRoom; if (this.Request.QueryString["filter"] != null) { // parameters will be added to data url sched.Data.Loader.AddParameters(this.Request.QueryString); selectedRoom = int.Parse(this.Request.QueryString["rooms"]); } else { selectedRoom = rooms.First().key; } var unit = new UnitsView("rooms", "room_id"); unit.Label = "Rooms"; unit.AddOptions(rooms); sched.Views.Add(unit); sched.Lightbox.AddDefaults(); var select = new LightboxSelect("room_id", "Room"); select.AddOptions(rooms); sched.Lightbox.Add(select); sched.LoadData = true; sched.EnableDataprocessor = true; sched.InitialView = unit.Name; ViewData["rooms"] = selectedRoom; sched.InitialDate = new DateTime(2011, 9, 7); return View(new SchedulerFilterModel(sched, rooms)); }
public ActionResult LightboxControl(int? id, FormCollection actionValues) { var ev = DHXEventsHelper.Bind<Event>(actionValues); var context = new DHXSchedulerDataContext(); var current = context.Events.SingleOrDefault(e => e.id == ev.id); if (current == null) current = ev; return View(current); }
/// <summary> /// Block time areas /// </summary> /// <returns></returns> public ActionResult Limit() { var sched = new DHXScheduler(this); sched.InitialDate = new DateTime(2011, 9, 19); // block specific date range sched.TimeSpans.Add(new DHXBlockTime() { StartDate = new DateTime(2011, 9, 14), EndDate = new DateTime(2011, 9, 17) }); // block each tuesday from 12AM to 15PM sched.TimeSpans.Add(new DHXBlockTime() { Day = DayOfWeek.Tuesday, Zones = new List<Zone>() { new Zone { Start = 0, End = 15 * 60 } } }); // block each sunday sched.TimeSpans.Add(new DHXBlockTime() { Day = DayOfWeek.Sunday }); // block each monday from 12am to 8am, and from 18pm to 12am of the next day sched.TimeSpans.Add(new DHXBlockTime() { Day = DayOfWeek.Monday, Zones = new List<Zone>() { new Zone { Start = 0, End = 8 * 60 }, new Zone { Start = 18 * 60, End = 24 * 60 } } }); #region add units and timeline var rooms = new DHXSchedulerDataContext().Rooms.ToList(); var unit = new UnitsView("unit", "room_id"); unit.AddOptions(rooms);//parse model objects sched.Views.Add(unit); var timeline = new TimelineView("timeline", "room_id"); timeline.RenderMode = TimelineView.RenderModes.Bar; timeline.FitEvents = false; timeline.AddOptions(rooms); sched.Views.Add(timeline); #endregion //block different sections in timeline and units view sched.TimeSpans.Add(new DHXBlockTime() { FullWeek = true, Sections = new List<Section>() { new Section(unit.Name, rooms.Take(2).Select(r => r.key.ToString()).ToArray()), new Section(timeline.Name, rooms.Skip(2).Select(r => r.key.ToString()).ToArray()) } }); sched.LoadData = true; sched.EnableDataprocessor = true; return View(sched); }
public ActionResult LightboxControl(ValidEvent ev) { var context = new DHXSchedulerDataContext(); var current = context.ValidEvents.SingleOrDefault(e => e.id == ev.id); if (current == null) current = ev; return View(current); }