private static void EnsureData(AConFlowStep model) { model.ArgNames = model.ArgNames?.Trim(); model.AComposityId = model.AComposityId.Trim(); model.MethodName = model.MethodName?.Trim(); model.StorePoolKey = model.StorePoolKey?.Trim(); }
public int ToInsertStep([FromBody] AConFlowStep id) { var model = id; EnsureData(model); var allpos = m_codeService.InsertCode <AConFlowStep>(model); return(allpos); }
public int ToUpateStep([FromBody] AConFlowStep id) { var model = id; EnsureData(model); var allpos = m_codeService.UpdateSimpleCode(model); return(allpos); }
private static object HandleGetData(HttpContext httpContext, RuntimeStepModel newrunmodel, ISqlSugarClient dbFactory, AConFlowStep s) { object dynaObject = null; //var objParams2 = new List<object>(); //if (!string.IsNullOrEmpty(s.ArgNames)) //{ // var args = s.ArgNames.Split(','); // foreach (var aarg in args) // { // object obj = aarg; // if (aarg.StartsWith("&")) // { // obj = newrunmodel.Resuce(aarg); // } // objParams2.Add(obj); // } //} if (!String.IsNullOrEmpty(s.ArgNames)) { if (s.ArgNames.Contains(',')) { dynaObject = newrunmodel.Resuce(s.ArgNames.Split(',')[0]); } else { dynaObject = newrunmodel.Resuce(s.ArgNames); } } //if (objParams2 == null || objParams2.Count == 0) //{ // dynaObject = APP.GetData( s.InParamter1); //} //else //{ dynaObject = APP.GetData(s.InParamter1, dynaObject); //} return(dynaObject); }
private static StringBuilder UsingNameSpace(AConFlowStep s, RazorLightEngine engine) { var stringbuilder = new StringBuilder(); stringbuilder.Append(@"@using UniOrm @using UniOrm.Application @using UniOrm.Common @using UniOrm.Model @using UniOrm.Startup.Web @using System @using System.Web @using System.IO @using System.Text @using System.Text.Encodings @using System.Text.RegularExpressions @using System.Collections.Generic @using System.Diagnostics @using System.Linq @using System.Security.Claims @using System.Threading @using System.Threading.Tasks @using System.Reflection @using System.Dynamic @using System.Diagnostics @using System.Linq.Expressions @using System.Xml @using System.Xml.Linq @using System.Configuration @using System.Data @using System.Data.SqlClient @using System.Data.Common @using System.Data.OleDb @using System.Globalization @using System.Net @using System.Net.Http @using System.Net.Http.Headers @using System.Net.Mail @using System.Net.Security @using System.Net.Sockets @using System.Net.WebSockets @using System.Drawing @using System.Drawing.Printing @using Microsoft.Data.Sqlite @using MySql.Data.MySqlClient @using Npgsql @using SqlKata.Compilers @using SqlKata.Execution @using SqlSugar @using CSScriptLib; @using Newtonsoft.Json @using Newtonsoft.Json.Linq @using System.Numerics @using Microsoft.AspNetCore.Authentication @using Microsoft.AspNetCore.Authorization @using Microsoft.Extensions.DependencyInjection @using Microsoft.AspNetCore.Mvc"); if (!string.IsNullOrEmpty(s.ReferenceDlls)) { string[] dllnams = s.ReferenceDlls.Split(','); foreach (var n in dllnams) { var rootname = n.TrimEnd(".dll".ToCharArray()); engine.Options.Namespaces.Add(n.TrimEnd(".dll".ToCharArray())); stringbuilder.AppendLine(rootname); } } stringbuilder.AppendLine("\r\n@{ DisableEncoding = true; "); stringbuilder.AppendLine("\r\n var Page = new RazorTool(); "); stringbuilder.AppendLine("\r\n Page.Step=Model.Step; "); stringbuilder.AppendLine("\r\n Page.ResouceInfos=Model.Item as Dictionary<string, object>; "); stringbuilder.AppendLine("\r\n Page.Funs=Model.Funs as Dictionary<string, MethodDelegate>; "); stringbuilder.AppendLine("\r\n }"); return(stringbuilder); }
private static async Task <string> HandleRazorText(RuntimeStepModel newrunmodel, AConFlowStep s, HttpContext httpContext, string template) { var engine = APP.Razorengine; string stepResult = ""; StringBuilder stringbuilder = UsingNameSpace(s, engine); dynamic modelArg = null; var module = APPCommon.ModuleManager.GetModule(null, s.ModuleName); if (module == null) { modelArg = new { Step = s, Module = new { }, Item = newrunmodel.Res, Funs = newrunmodel.Funtions }; } else { modelArg = new { Step = s, Module = module.AsDynamic(), Item = newrunmodel.Res, Funs = newrunmodel.Funtions }; } var cachekey2 = template.ToMD5(); var cacheResult = engine.Handler.Cache.RetrieveTemplate(cachekey2); template = stringbuilder.AppendLine("\r\n").Append(template).ToString(); if (cacheResult.Success) { stepResult = await engine.RenderTemplateAsync(cacheResult.Template.TemplatePageFactory(), modelArg); } else { stepResult = await engine.CompileRenderStringAsync(cachekey2, template, modelArg); } return(stepResult); }
private static async Task <string> HandleRazorKey(RuntimeStepModel newrunmodel, AConFlowStep s) { dynamic modelArg = null; var module = APPCommon.ModuleManager.GetModule(null, s.ModuleName); if (module == null) { modelArg = new { Step = s, Module = new { }, Item = newrunmodel.Res, Funs = newrunmodel.Funtions }; } else { modelArg = new { Step = s, Module = module.AsDynamic(), Item = newrunmodel.Res, Funs = newrunmodel.Funtions }; } return(await APPCommon.RenderRazorKey(s.ProxyCode, modelArg)); }
private static object DealTheFunction(RuntimeStepModel newrunmodel, AConFlowStep s, HttpContext httpContext) { object rebject; var defaultNamespace = @"using UniOrm; using UniOrm.Application; using UniOrm.Common; using UniOrm.Model; using UniOrm.Startup.Web ; using System; using System.Web; using System.IO; using System.Text; using System.Text.Encodings; using System.Text.RegularExpressions; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Security.Claims; using System.Threading; using System.Threading.Tasks; using System.Reflection; using System.Dynamic ; using System.Diagnostics ; using System.Linq.Expressions; using System.Xml; using System.Xml.Linq; using System.Configuration ; using System.Data; using System.Data.SqlClient; using System.Data.Common; using System.Data.OleDb; using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mail; using System.Net.Security; using System.Net.Sockets; using System.Net.WebSockets; using System.Drawing; using System.Drawing.Printing; using Microsoft.Data.Sqlite; using MySql.Data.MySqlClient; using Npgsql; //using PetaPoco.SqlKata; using SqlKata.Compilers; using SqlKata.Execution; using SqlSugar; using CSScriptLib; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System.Numerics ; using Peachpie.AspNetCore.Web; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authorization; using Microsoft.Extensions.DependencyInjection; using Microsoft.AspNetCore.Mvc;"; var functionName = "FunctionName"; var selfnamespace = s.OutPutText; var allcode = defaultNamespace + "\r\n" + selfnamespace + "\r\n" + "public object " + functionName + "(object __param){ \r\n" + "var __model=__param.AsDynamic();" + "var Page=__model.Res[\"__page\"];" + s.ProxyCode + "\r\n}"; var runobj = CSScript.Evaluator.ReferenceAssembly(Assembly.GetExecutingAssembly()) .CreateDelegate(allcode); newrunmodel.Funtions.Add(s.StorePoolKey, runobj); var pagetool = newrunmodel.Res["__page"] as RazorTool; pagetool.Funs = newrunmodel.Funtions; rebject = runobj(newrunmodel); return(rebject); }
public WebSitHelper(IModule module, AConFlowStep step) { APPCommon.ApplicationServices.GetService <IHostingEnvironment>(); Module = module; Step = step; }
public AConFlowStep AddMathodStep(string comguidi, MethodInfo methodInfo, string returnValueName = null, List <string> Inparas = null) { var all = methodInfo.GetParameters(); string arags = string.Empty; for (var i = 0; i < all.Count(); i++) { if (all[i].IsIn) { arags += all[i].Name + ","; } } arags = arags.Trim(','); var guid = Guid.NewGuid().ToString(); var refsName = methodInfo.ReflectedType.Assembly.GetReferencedAssemblies(); string refsAll = string.Empty; for (var i = 0; i < refsName.Count(); i++) { refsAll += refsName[i].Name + ","; } refsAll = refsAll.Trim(','); var cc = new AConFlowStep() { AddTime = DateTime.Now, AComposityId = comguidi, FlowStepType = FlowStepType.CallMethod, ArgNames = arags, Connectionstring = "sys_default", IsUsingParentConnstring = true, Name = guid, Guid = guid, ExcuteType = ExcuteType.Syn, MethodName = methodInfo.Name, ReferenceDlls = refsAll, TypeLib = methodInfo.ReflectedType.Assembly.FullName, TypeFullName = methodInfo.ReflectedType.FullName, StorePoolKey = returnValueName, StoreValueProposal = StoreValueProposal.ComposityPool }; if (Inparas != null) { for (var i = 0; i < 9 && i < Inparas.Count; i++) { cc.SetPropertyValue("InParamter" + (i + 1), Inparas[i]); } } var allmax = DB.UniClient.Queryable <AConFlowStep>().Where(p => p.AComposityId == comguidi).ToList(); var maxOrder = 0; if (allmax != null) { maxOrder = allmax.Max(p => p.StepOrder) + 1; } cc.StepOrder = maxOrder; var reint = DB.UniClient.Insertable(cc).ExecuteCommand(); return(DB.UniClient.Queryable <AConFlowStep>().Where(p => p.Guid == guid).First()); }