コード例 #1
0
ファイル: CommandModule.cs プロジェクト: ARMmaster17/Antd
        public CommandModule()
            : base("/command/mgmt")
        {
            this.RequiresAuthentication();

            Get["/"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.list = CommandDB.GetAll();
                return(View["page-command-mgmt", vmod]);
            };

            Post["/"] = x => {
                string command       = this.Request.Form.Command;
                string layout        = this.Request.Form.CommandLayout;
                string notes         = this.Request.Form.Notes;
                string inputid       = this.Request.Form.InputID;
                string inputlocation = this.Request.Url;
                CommandDB.Create(inputid, command, layout, inputlocation, notes);
                return(Response.AsRedirect("/command/mgmt"));
            };

            Post["/launch/{guid}"] = x => {
                string guid   = x.guid;
                string result = CommandDB.LaunchAndGetOutput(guid);
                return(Response.AsJson(result));
            };

            Post["/delete/{guid}"] = x => {
                string guid = x.guid;
                CommandDB.Delete(guid);
                return(Response.AsJson(true));
            };

            Get["/ex/{inputid}"] = x => {
                string inputid = x.inputid;
                var    r       = CommandDB.LaunchAndGetOutputUsingNewValue(inputid);
                return(Response.AsJson(r));
            };

            Get["/ex/{inputid}/{value}"] = x => {
                string inputid = x.inputid;
                string value   = x.value;
                var    r       = CommandDB.LaunchAndGetOutputUsingNewValue(inputid, value);
                return(Response.AsJson(r));
            };
        }
コード例 #2
0
        public CCTableModule()
            : base("/cctable")
        {
            this.RequiresAuthentication();

            Get["/"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.list = CCTableRepository.GetAll();
                return(View["_page-cctable", vmod]);
            };

            Post["/"] = x => {
                string tbl = (string)this.Request.Form.Alias;
                if (tbl != "")
                {
                    CCTableRepository.CreateTable(tbl);
                }
                return(Response.AsRedirect("/cctable"));
            };

            Post["/row"] = x => {
                string table        = (string)this.Request.Form.TableGuid;
                string tableName    = (string)this.Request.Form.TableName;
                string label        = (string)this.Request.Form.Label;
                string inputType    = (string)this.Request.Form.InputType.Value;
                string inputValue   = (string)this.Request.Form.InputLabel;
                string inputCommand = (string)this.Request.Form.InputCommand;
                string notes        = (string)this.Request.Form.Notes;
                CCTableRepository.CreateRow(table, tableName, label, inputType, inputValue, inputCommand, notes);

                string command       = this.Request.Form.CCTableCommand;
                string inputid       = "New" + tableName.UppercaseAllFirstLetters().RemoveWhiteSpace() + label.UppercaseAllFirstLetters().RemoveWhiteSpace();
                string inputlocation = "CCTable" + this.Request.Form.TableName;
                CommandDB.Create(inputid, command, command, inputlocation, notes);

                return(Response.AsRedirect("/cctable"));
            };

            Get["/delete/table/{guid}"] = x => {
                string guid = x.guid;
                CCTableRepository.DeleteTable(guid);
                return(Response.AsJson("CCTable deleted"));
            };
        }