示例#1
0
        public ActionResult CallBack(Controller c)
        {
            Controller = c;

            // init
            UpdateType = CallBackUpdateType.None;

            // read request
            JsonData input      = SimpleJsonDeserializer.Deserialize(c.Request.InputStream);
            String   action     = (string)input["action"];
            JsonData parameters = input["parameters"];
            JsonData header     = input["header"];
            JsonData data       = input["data"]; // custom data

            Version.Check((string)header["v"]);

            StartDate            = (DateTime)header["startDate"];
            WeekStarts           = WeekStartsParser.FromIntJavaScript((int)header["weekStarts"]);
            HeaderBackColor      = (string)header["headerBackColor"];
            BackColor            = (string)header["backColor"];
            NonBusinessBackColor = (string)header["nonBusinessBackColor"];
            Id = (string)header["id"];

            OnPrepare();

            switch (action)
            {
            case "EventMove":
                OnEventMove(EventMoveArgs.FromJson(parameters, new string[] {}, data));
                break;

            case "EventResize":
                OnEventResize(EventResizeArgs.FromJson(parameters, new string[] {}, data));
                break;

            case "EventClick":
                OnEventClick(EventClickArgs.FromJson(parameters, new string[] {}, data));
                break;

            case "TimeRangeSelected":
                OnTimeRangeSelected(TimeRangeSelectedArgs.FromJson(parameters, data));
                break;

            case "Command":
                OnCommand(CommandArgs.FromJson(parameters, data));
                break;

            case "Init":
                OnInit(new InitArgs());
                break;
            }

            OnFinish();
            LoadEvents();


            Hashtable result = new Hashtable();

            result["UpdateType"] = UpdateType.ToString();

            if (_callbackRedirect != null)
            {
                result["CallBackRedirect"] = _callbackRedirect;
                return(new JsonResult {
                    Data = result
                });
            }

            if (UpdateType == CallBackUpdateType.None)
            {
                return(new JsonResult {
                    Data = result
                });
            }

            result["Events"]       = GetEvents();
            result["CallBackData"] = _callbackData;

            if (UpdateType == CallBackUpdateType.Full)
            {
                result["StartDate"]            = StartDate.ToString("s");
                result["WeekStarts"]           = Week.ResolveAsInt(WeekStarts);
                result["HeaderBackColor"]      = HeaderBackColor;
                result["BackColor"]            = BackColor;
                result["NonBusinessBackColor"] = NonBusinessBackColor;
            }

            JsonResult json = new JsonResult();

            json.Data = result;

            return(json);
        }
示例#2
0
        public ActionResult CallBack(Stream stream)
        {
            // init
            UpdateType = CallBackUpdateType.None;

            // read request
            JsonData input      = SimpleJsonDeserializer.Deserialize(stream);
            var      action     = (string)input["action"];
            JsonData parameters = input["parameters"];
            JsonData header     = input["header"];
            JsonData data       = input["data"]; // custom data

            Version.Check((string)header["v"]);

            Id                 = (string)header["id"];
            StartDate          = (DateTime)header["startDate"];
            Days               = (int)header["days"];
            HeightSpec         = HeightSpecParser.Parse((string)header["heightSpec"]);
            BusinessBeginsHour = (int)header["businessBeginsHour"];
            BusinessEndsHour   = (int)header["businessEndsHour"];
            ViewType           = ViewTypeParser.Parse((string)header["viewType"]);
            CellBackColor      = (string)header["backColor"];
            EventHeaderVisible = header["eventHeaderVisible"] != null && (bool)header["eventHeaderVisible"];
            TimeFormat         = TimeFormatParser.Parse((string)header["timeFormat"]);

            // required for custom hour header rendering
            HourNameBackColor = (string)header["hourNameBackColor"];
            HourFontFamily    = (string)header["hourFontFamily"];
            HourFontSize      = (string)header["hourFontSize"];
            HourFontColor     = (string)header["hourFontColor"];

            OnPrepare();

            switch (action)
            {
            case "Command":
                OnCommand(CommandArgs.FromJson(parameters, data));
                break;

            case "EventClick":
                OnEventClick(EventClickArgs.FromJson(parameters, data));
                break;

            case "EventMove":
                OnEventMove(EventMoveArgs.FromJson(parameters, data));
                break;

            case "EventResize":
                OnEventResize(EventResizeArgs.FromJson(parameters, data));
                break;

            case "TimeRangeSelected":
                OnTimeRangeSelected(TimeRangeSelectedArgs.FromJson(parameters, data));
                break;

            case "Init":
                OnInit(new InitArgs());
                break;

            default:
                throw new Exception(String.Format("Unknown CallBack command '{0}'.", action));
            }

            OnFinish();
            LoadEvents();
            LoadColumns();

            var result = new Hashtable();

            result["UpdateType"] = UpdateType.ToString();

            if (_callbackRedirect != null)
            {
                result["CallBackRedirect"] = _callbackRedirect;
                return(new JsonResult {
                    Data = result
                });
            }

            if (UpdateType == CallBackUpdateType.None)
            {
                return(new JsonResult {
                    Data = result
                });
            }

            result["Events"] = GetEvents();

            if (UpdateType == CallBackUpdateType.Full)
            {
                result["Days"]      = Days;
                result["StartDate"] = StartDate.ToString("s");
                result["ViewType"]  = ViewType.ToString();
                result["Columns"]   = _columns;
            }

            return(new JsonResult {
                Data = result
            });
        }