コード例 #1
0
ファイル: BootCommandsModule.cs プロジェクト: pk8est/Antd
        public BootCommandsModule()
        {
            Get["/boot/commands"] = x => {
                var setupConfiguration = new SetupConfiguration();
                var model = new PageBootCommandsModel {
                    HasConfiguration = setupConfiguration.Get().Any(),
                    Controls         = setupConfiguration.Get().OrderBy(_ => _.Index)
                };
                return(JsonConvert.SerializeObject(model));
            };

            Post["/boot/commands"] = x => {
                string data     = Request.Form.Data;
                var    dataArr  = data.Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
                var    controls = new List <Control>();
                foreach (var ctrl in dataArr)
                {
                    var ctrlArr = ctrl.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    var control = new Control {
                        Index        = Convert.ToInt32(ctrlArr[0]),
                        FirstCommand = ctrlArr[1]
                    };
                    controls.Add(control);
                }
                var setupConfiguration = new SetupConfiguration();
                setupConfiguration.Export(controls);
                return(HttpStatusCode.OK);
            };
        }