public ContentResult NativeSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            var data = new DHXSchedulerModelsDataContext();

            try
            {
                switch (action.Type)
                {
                case DataActionTypes.Insert:
                    data.ValidEvents.InsertOnSubmit(changedEvent);
                    break;

                case DataActionTypes.Delete:
                    changedEvent = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    data.ValidEvents.DeleteOnSubmit(changedEvent);
                    break;

                default:    // "update"
                    var eventToUpdate = data.ValidEvents.SingleOrDefault(ev => ev.id == action.SourceId);
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ActionResult LightboxControl(ValidEvent ev)
        {
            var context = new DHXSchedulerModelsDataContext();
            var current = context.ValidEvents.SingleOrDefault(e => e.id == ev.id);

            if (current == null)
            {
                current = ev;
            }
            return(View(current));
        }
Beispiel #3
0
        /// <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 DHXSchedulerModelsDataContext().Events;

            return(Content(renderer.ToICal(events)));
            //you can also use custom function for rendering of the events
            //renderer.ToICal(events, RenderItem);
        }
        public ActionResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);

            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();

            try
            {
                var changedEvent = (Recurring)DHXEventsHelper.Bind(typeof(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
            {
                action.Type = DataActionTypes.Error;
            }

            return(new AjaxSaveResponse(action));
        }
        public ContentResult CustomFormSave(DataAction action, ValidEvent changedEvent, FormCollection actionValues)
        {
            if (actionValues["actionType"] != null)
            {
                var actionType = actionValues["actionType"].ToLower();
                var data       = new DHXSchedulerModelsDataContext();
                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
                {
                    action.Type = DataActionTypes.Error;
                }
            }



            return(new SchedulerFormResponseScript(action, changedEvent));
        }
        protected bool deleteRelated(DataAction action, Recurring changedEvent, DHXSchedulerModelsDataContext 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 CustomSave(Event changedEvent, FormCollection actionValues)
        {
            var action = new DataAction(DataActionTypes.Update, changedEvent.id, changedEvent.id);

            if (actionValues["actionButton"] != null)
            {
                DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();
                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
                {
                    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 DHXSchedulerModelsDataContext().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));
        }
Beispiel #9
0
        public ActionResult Index()
        {
            var sched = new DHXScheduler(this);

            var unit = new UnitsView("unit1", "room_id");


            sched.Views.Add(unit);
            var context = new DHXSchedulerModelsDataContext();

            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 Save(int?id, FormCollection actionValues)
        {
            var action       = new DataAction(actionValues);
            var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();

            if (this.Request.IsAuthenticated && changedEvent.user_id == data.UserDetails.SingleOrDefault(u => u.UserName == this.HttpContext.User.Identity.Name).UserId)
            {
                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
                {
                    action.Type = DataActionTypes.Error;
                }
            }
            else
            {
                action.Type = DataActionTypes.Error;
            }
            return(new AjaxSaveResponse(action));
        }
Beispiel #11
0
        public ActionResult Index()
        {
            var sched = new DHXScheduler(this);
            var unit  = new UnitsView("unit1", "room_id");

            sched.Views.Add(unit);


            var context = new DHXSchedulerModelsDataContext();

            //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");

            timeline.RenderMode = TimelineView.RenderModes.Bar;
            var rooms = context.Rooms.ToList();

            timeline.FitEvents = false;
            sched.Views.Add(timeline);
            timeline.AddOptions(rooms);


            var select = new LightboxSelect("color", "Priority");

            select.AddOptions(new List <object> {
                new { key = "#ccc", label = "Low" },
                new { key = "#76B007", label = "Medium" },
                new { key = "#FE7510", label = "Hight" }
            });
            sched.Lightbox.Add(select);


            select = new LightboxSelect("room_id", "Room id");
            select.AddOptions(rooms);
            sched.Lightbox.Add(select);

            sched.LoadData            = true;
            sched.EnableDataprocessor = true;
            sched.InitialDate         = new DateTime(2011, 9, 5);
            return(View(sched));
        }
        /// <summary>
        /// Add resources views - units and timeline
        /// </summary>
        /// <returns></returns>
        public ActionResult MultipleResources()
        {
            var scheduler = new DHXScheduler(this);

            scheduler.Skin = DHXScheduler.Skins.Terrace;
            var rooms = new DHXSchedulerModelsDataContext().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));
        }
        public ActionResult Index(FormCollection data)
        {
            var sched = new DHXScheduler(this);

            sched.Extensions.Add(SchedulerExtensions.Extension.Cookie);

            var rooms = new DHXSchedulerModelsDataContext().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)));
        }
Beispiel #14
0
        public ActionResult Index(FormCollection data)
        {
            var sched = new DHXScheduler(this);

            var rooms = new DHXSchedulerModelsDataContext().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 DHXSchedulerModelsDataContext();

            if (Request.IsAuthenticated)
            {
                var user = context.UserDetails.SingleOrDefault(u => u.UserName == this.HttpContext.User.Identity.Name);
                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));
        }
Beispiel #16
0
        public ContentResult Data()
        {
            var dc = new DHXSchedulerModelsDataContext();

            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 ContentResult Save(int?id, FormCollection actionValues)
        {
            var action = new DataAction(actionValues);
            DHXSchedulerModelsDataContext data = new DHXSchedulerModelsDataContext();

            try
            {
                var changedEvent = (Event)DHXEventsHelper.Bind(typeof(Event), actionValues);
                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);
                    //update all properties, except for id
                    DHXEventsHelper.Update(eventToUpdate, changedEvent, new List <string>()
                    {
                        "id"
                    });
                    break;
                }
                data.SubmitChanges();
                action.TargetId = changedEvent.id;
            }
            catch
            {
                action.Type = DataActionTypes.Error;
            }
            return(new AjaxSaveResponse(action));
        }
Beispiel #18
0
        /// <summary>
        /// applying client side filters for each view
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            var scheduler = new DHXScheduler();

            var rooms = new DHXSchedulerModelsDataContext().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));
        }
        /// <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 DHXSchedulerModelsDataContext().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 Index()
        {
            SchedulerLocalization.Localizations lang;
            var language = this.Request.QueryString["language"];
            var skn      = this.Request.QueryString["skin"];

            DHXScheduler.Skins skin;
            #region language
            switch (this.Request.QueryString["language"])
            {
            case "ar":
                lang = SchedulerLocalization.Localizations.Arabic;
                break;

            case "be":
                lang = SchedulerLocalization.Localizations.Belarusian;
                break;

            case "ca":
                lang = SchedulerLocalization.Localizations.Catalan;
                break;

            case "cn":
                lang = SchedulerLocalization.Localizations.Chinese;
                break;

            case "cs":
                lang = SchedulerLocalization.Localizations.Czech;
                break;

            case "da":
                lang = SchedulerLocalization.Localizations.Danish;
                break;

            case "nl":
                lang = SchedulerLocalization.Localizations.Dutch;
                break;

            case "fi":
                lang = SchedulerLocalization.Localizations.Finnish;
                break;

            case "fr":
                lang = SchedulerLocalization.Localizations.French;
                break;

            case "de":
                lang = SchedulerLocalization.Localizations.German;
                break;

            case "el":
                lang = SchedulerLocalization.Localizations.Greek;
                break;

            case "he":
                lang = SchedulerLocalization.Localizations.Hebrew;
                break;

            case "hu":
                lang = SchedulerLocalization.Localizations.Hungarian;
                break;

            case "id":
                lang = SchedulerLocalization.Localizations.Indonesia;
                break;

            case "it":
                lang = SchedulerLocalization.Localizations.Italian;
                break;

            case "jp":
                lang = SchedulerLocalization.Localizations.Japanese;
                break;

            case "no":
                lang = SchedulerLocalization.Localizations.Norwegian;
                break;

            case "pl":
                lang = SchedulerLocalization.Localizations.Polish;
                break;

            case "pt":
                lang = SchedulerLocalization.Localizations.Portuguese;
                break;

            case "ro":
                lang = SchedulerLocalization.Localizations.Romanian;
                break;

            case "ru":
                lang = SchedulerLocalization.Localizations.Russian;
                break;

            case "si":
                lang = SchedulerLocalization.Localizations.Slovenian;
                break;

            case "es":
                lang = SchedulerLocalization.Localizations.Spanish;
                break;

            case "sv":
                lang = SchedulerLocalization.Localizations.Swedish;
                break;

            case "tr":
                lang = SchedulerLocalization.Localizations.Turkish;
                break;

            case "ua":
                lang = SchedulerLocalization.Localizations.Ukrainian;
                break;

            default:
                lang     = SchedulerLocalization.Localizations.English;
                language = "en";
                break;
            }
            #endregion

            #region skin
            switch (this.Request.QueryString["skin"])
            {
            case "glossy":
                skin = DHXScheduler.Skins.Glossy;
                break;

            case "terrace":
                skin = DHXScheduler.Skins.Terrace;
                break;

            default:
                skin = DHXScheduler.Skins.Standart;
                skn  = "classic";
                break;
            }
            #endregion
            var scheduler = new DHXScheduler(this);
            scheduler.Skin        = DHXScheduler.Skins.Terrace;
            scheduler.InitialDate = new DateTime(2011, 11, 24);

            scheduler.XY.scroll_width          = 0;
            scheduler.Config.first_hour        = 8;
            scheduler.Config.last_hour         = 19;
            scheduler.Config.time_step         = 30;
            scheduler.Config.multi_day         = true;
            scheduler.Config.limit_time_select = true;
            scheduler.Skin = skin;
            scheduler.Localization.Directory = "locale";
            scheduler.Localization.Set(lang, false);

            var rooms = new DHXSchedulerModelsDataContext().Rooms.ToList();

            var unit = new UnitsView("unit1", "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);


            scheduler.EnableDataprocessor = true;
            scheduler.LoadData            = true;
            scheduler.InitialDate         = new DateTime(2011, 9, 19);
            return(View(new LocaleData(scheduler, language, skn)));
        }