public IActionResult Main() { ViewData["Title"] = "Главное меню"; var command = new FunctionCommand("table(pkg_cmacros.getSheets)", new Param[] { new Param("accesslevel", User.FindFirst(x => x.Type == ClaimsIdentity.DefaultRoleClaimType).Value) }); var caller = new DbCaller(command); caller.DoWork(); if (((DataTable)caller.GetResult()).Rows.Count == 0) { ViewBag.Message = "Данному пользователю недоступны какие-либо действия!"; return(RedirectToAction("Login", "Home")); } List <string> availableSheetsName = new List <string>(); foreach (DataRow row in ((DataTable)caller.GetResult()).Rows) { availableSheetsName.Add(row[0].ToString()); } List <Sheet> availableSheets = (List <Sheet>)Options.Sheets.Where(sheet => availableSheetsName.Contains(sheet.Name)); return(View("Main", availableSheets)); }
public ActionResult FillPartialTable(string sheetName, Param[] parameters) { var command = new FunctionCommand(Options.Sheets[sheetName].Procedure); var caller = new DbCaller(command); caller.DoWork(); return(PartialView("_GetDelayedSO", (DataTable)caller.GetResult())); }
public ActionResult GetLoadPrice(int numberIPO) { var command = new FunctionCommand("table(pkg_cmacros.LoadPriceToIPO)"); var caller = new DbCaller(command); caller.DoWork(); return(PartialView("_LoadPrice", (DataTable)caller.GetResult())); //return Helper.GetXlsxFile("Purchaser", "LoadPrice", new Param("№ ЗП", numberIPO)); }
private static OApiSchema?NormalToSchema(Type type) { type = FunctionCommand.UnwrapReturnType(type); if (type.IsArray) { return(new OApiSchema("array") { Items = NormalToSchema(type.GetElementType() !) });
public void Function(FunctionCommand command) { _file.WriteLine($"// Function {command.Arg1} ({command.Arg2})"); _file.WriteLine($"({command.Arg1})"); _file.WriteLine($"D=0"); for (int i = 0; i < command.Arg2; i++) { this.PushFromDRegister(); } }
public void FunctionCommand() { FUNCTIONS["listen"] = new FunctionDefinition("listen", new List <string>()); var command = ParseCommand("goto \"listen\""); Assert.IsTrue(command is FunctionCommand); FunctionCommand functionCommand = (FunctionCommand)command; Assert.AreEqual("listen", functionCommand.functionDefinition.functionName); Assert.AreEqual(FunctionType.GOTO, functionCommand.type); }
public void CreateFunctionCommand() { string name = "foo"; IList <string> argnames = new string[] { "a", "b" }; ICommand body = new ExpressionCommand(new ConstantExpression(2)); FunctionCommand fcmd = new FunctionCommand(name, argnames, body); Assert.AreEqual(name, fcmd.Name); Assert.AreSame(argnames, fcmd.ArgumentNames); Assert.AreSame(body, fcmd.Body); }
public void FunctionCommandFromExplicitString() { var program = MDKFactory.CreateProgram <Program>(); program.functions["listen"] = new FunctionDefinition("listen", new List <string>()); var command = program.ParseCommand("goto 'listen'"); Assert.IsTrue(command is FunctionCommand); FunctionCommand functionCommand = (FunctionCommand)command; Assert.AreEqual("listen", functionCommand.functionDefinition.functionName); Assert.AreEqual(Function.GOTO, functionCommand.type); }
public IActionResult Main() { ViewData["Title"] = "Главное меню"; var command = new FunctionCommand("table(pkg_cmacros.getSheets)", new Param[] { new Param("accesslevel", User.FindFirst(x => x.Type == ClaimsIdentity.DefaultRoleClaimType).Value) }); var caller = new DbCaller(command); caller.DoWork(); if (((DataTable)caller.GetResult()).Rows.Count == 0) { ViewBag.Message = "Данному пользователю недоступны какие-либо действия!"; return(RedirectToAction("Login", "Home")); } return(View("Main", caller.GetResult())); }
public void EvaluateFunctionCommand() { string name = "foo"; IList <string> argnames = new string[] { "a", "b" }; ICommand body = new ExpressionCommand(new ConstantExpression(2)); Context context = new Context(); FunctionCommand fcmd = new FunctionCommand(name, argnames, body); fcmd.Execute(context); var result = context.GetValue("foo"); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Function)); }
public void FunctionCommandWithParameters() { FUNCTIONS["listen"] = new FunctionDefinition("listen", new List <string>() { "a", "b" }); var command = ParseCommand("goto \"listen\" 2 3"); Assert.IsTrue(command is FunctionCommand); FunctionCommand functionCommand = (FunctionCommand)command; Assert.AreEqual("listen", functionCommand.functionDefinition.functionName); Assert.AreEqual(FunctionType.GOTO, functionCommand.type); Assert.AreEqual(2, CastNumber(functionCommand.inputParameters["a"].GetValue()).GetNumericValue()); Assert.AreEqual(3, CastNumber(functionCommand.inputParameters["b"].GetValue()).GetNumericValue()); }
public void FunctionCommandWithParameters() { var program = MDKFactory.CreateProgram <Program>(); program.functions["listen"] = new FunctionDefinition("listen", new List <string>() { "a", "b" }); var command = program.ParseCommand("goto \"listen\" 2 3"); Assert.IsTrue(command is FunctionCommand); FunctionCommand functionCommand = (FunctionCommand)command; Assert.AreEqual("listen", functionCommand.functionDefinition.functionName); Assert.AreEqual(Function.GOTO, functionCommand.type); Assert.AreEqual(2, CastNumber(functionCommand.inputParameters["a"].GetValue()).GetTypedValue()); Assert.AreEqual(3, CastNumber(functionCommand.inputParameters["b"].GetValue()).GetTypedValue()); }
public ActionResult GetDelayedSO() { // Вызов осуществляется не через хелпер, так как функционал не так прост. Нужно передать извлеченную информацию в частичное представление. Сам метод работает в аяксе var command = new FunctionCommand(Options.Sheets["GetDelayedSO"].Procedure); var caller = new DbCaller(command); caller.DoWork(); return(PartialView("_DelayedSO", (DataTable)caller.GetResult())); /* * var command = new TextCommand(@"select 1 ""OrderNumber"", 1 ""LineNumber"", 1 ""DelayedDays"", 1 ""SupplementaryText5"", rf.* from dbo.""RefFoms"" rf", Returns.Table); * var caller = new DbCaller(command, null, "PgSQL2"); * caller.DoWork(); * return PartialView("_DelayedSO", (DataTable)caller.GetResult()); * /* * Sheet currentSheet = Purchaser.GetSheet("Задерживается ЗК"); * var command = new FunctionCommand(currentSheet.Procedure); * var caller = new DbCaller(command); * caller.DoWork(); * return PartialView("_DelayedSO", (DataTable)caller.GetResult()); */ }
private static OApiSchema NormalToSchema(Type type) { type = FunctionCommand.UnwrapReturnType(type); if (type.IsArray) { return(new OApiSchema { type = "array", items = NormalToSchema(type.GetElementType()) }); } if (type == typeof(bool)) { return(OApiSchema.FromBasic("boolean")); } else if (type == typeof(sbyte)) { return(OApiSchema.FromBasic("integer", "int8")); } else if (type == typeof(byte)) { return(OApiSchema.FromBasic("integer", "uint8")); } else if (type == typeof(short)) { return(OApiSchema.FromBasic("integer", "int16")); } else if (type == typeof(ushort)) { return(OApiSchema.FromBasic("integer", "uint16")); } else if (type == typeof(int)) { return(OApiSchema.FromBasic("integer", "int32")); } else if (type == typeof(uint)) { return(OApiSchema.FromBasic("integer", "uint32")); } else if (type == typeof(long)) { return(OApiSchema.FromBasic("integer", "int64")); } else if (type == typeof(ulong)) { return(OApiSchema.FromBasic("integer", "uint64")); } else if (type == typeof(float)) { return(OApiSchema.FromBasic("number", "float")); } else if (type == typeof(double)) { return(OApiSchema.FromBasic("number", "double")); } else if (type == typeof(TimeSpan)) { return(OApiSchema.FromBasic("string", "duration")); } else if (type == typeof(DateTime)) { return(OApiSchema.FromBasic("string", "date-time")); } else if (type == typeof(string)) { return(OApiSchema.FromBasic("string", null)); } else if (type == typeof(JsonEmpty) || type == typeof(void)) { return(null); } else if (type == typeof(JsonObject) || type == typeof(object) || type == typeof(ICommandResult)) { return(OApiSchema.FromBasic("object")); } else if (type == typeof(ICommand)) { return(OApiSchema.FromBasic("λ")); } else { return(OApiSchema.FromBasic(type.Name)); } }