Beispiel #1
0
        public int UpdateCompose([FromBody] ComposeEntity id)
        {
            id.AddTime     = DateTime.Now;
            id.Guid        = id.Guid?.Trim();
            id.TrigeMethod = id.TrigeMethod?.Trim();

            var ce      = m_codeService.GetSimpleCode <ComposeEntity>(new { AComposityId = id.Id }).FirstOrDefault();
            var oldguid = string.Empty;

            if (ce != null)
            {
                oldguid = ce.Guid;
            }
            if (string.IsNullOrEmpty(oldguid))
            {
                return(-1);
            }

            var ww = m_codeService.GetSimpleCode <AConFlowStep>(new { AComposityId = oldguid });

            if (ww.Any())
            {
                foreach (var ss in ww)
                {
                    ss.AComposityId = id.Guid;
                    m_codeService.UpdateSimpleCode <AConFlowStep>(ss);
                }
            }
            var allFlowSteps = m_codeService.UpdateSimpleCode(id);

            return(allFlowSteps);
        }
Beispiel #2
0
        public int AddCompose([FromBody] ComposeEntity id)
        {
            id.AddTime = DateTime.Now;
            id.Guid    = id.Guid?.Trim();
            var allFlowSteps = m_codeService.InsertCode <ComposeEntity>(id);

            return(allFlowSteps);
        }
Beispiel #3
0
        public async Task Run(params object[] parameters)
        {
            var st         = new System.Diagnostics.StackTrace();
            var lastMethod = st.GetFrame(1).GetMethod();

            //var appconfigstring = Config.GetValue<AppConfig>("App").AppConfigs;

            if (appConfig.AppType == "aspnetcore")
            {
                ComposeEntity cons = null;

                cons = FindComposity(appConfig, null);
                if (cons == null)
                {
                    Logger.LogError(logName, "Run -> Find composity returns null ");
                    return;
                }

                var newrunmodel = new RuntimeStepModel(Config)
                {
                    ComposeEntity = cons,
                    HashCode      = cons.GetHash()
                };
                newrunmodel.Res["__actioncontext"] = parameters[0];
                newrunmodel.Res["__httpcontext"]   = parameters[0].GetProp("HttpContext");
                httpContext = newrunmodel.Res["__httpcontext"] as HttpContext;
                newrunmodel.Res["__session"] = httpContext.Session;
                newrunmodel.Res["__db"]      = DB.Kata;
                var pagetool = new RazorTool();
                pagetool.ActionContext      = parameters[0] as ActionExecutingContext;
                pagetool.ResouceInfos       = newrunmodel.Res;
                pagetool.Funs               = newrunmodel.Funtions;
                newrunmodel.Res["__page"]   = pagetool;
                newrunmodel.Res["__config"] = appConfig;

                if (!string.IsNullOrEmpty(cons.Templateid))
                {
                    newrunmodel.ComposeTemplate = FindComposeTemplet(cons.Templateid);
                }

                await RunComposity(parameters[0].GetHashCode(), httpContext, newrunmodel, DbFactory, CodeService, Config);
            }
            //var context = parameters[0] as ActionExecutingContext;
            //var resp = context.HttpContext.Response;
            //resp.ContentType = "text/html";

            //using (StreamWriter sw = new StreamWriter(resp.Body))
            //{
            //    sw.Write("Write a string to response in WriteResponseWithoutReturn!");
            //}
        }
Beispiel #4
0
        public ComposeEntity NewComposy(string name, string discription = null)
        {
            var guid = Guid.NewGuid().ToString();
            var cc   = new ComposeEntity()
            {
                AddTime                 = DateTime.Now,
                AppType                 = "aspnetcore",
                Description             = discription,
                IsBuildIn               = false,
                TrigeType               = "urlreg",
                Connectionstring        = "sys_default",
                IsUsingParentConnstring = true,
                Name = name,
                Guid = guid
            };
            var reint = DB.UniClient.Insertable(cc).ExecuteCommand();

            return(DB.UniClient.Queryable <ComposeEntity>().Where(p => p.Guid == guid).First());
        }
Beispiel #5
0
        private ComposeEntity FindComposity(AppConfig appconfig, string allname)
        {
            lock (lockobj)
            {
                ComposeEntity cons = null;
                if (APPCommon.AppConfig.IsUseGloableCahe)
                {
                    cons = APP.Composeentitys.FirstOrDefault(p => p.Guid == appconfig.StartUpCompoistyID);
                    if (cons == null)
                    {
                        cons = CodeService.GetConposity(appconfig.StartUpCompoistyID, allname).FirstOrDefault();
                        if (cons != null)
                        {
                            APP.Composeentitys.Add(cons);
                        }
                    }
                }
                else
                {
                    cons = CodeService.GetConposity(appconfig.StartUpCompoistyID, allname).FirstOrDefault();
                }

                if (cons == null)
                {
                    cons = new ComposeEntity()
                    {
                        Name    = allname,
                        RunMode = RunMode.Coding,
                        Guid    = appconfig.StartUpCompoistyID
                    };
                    var reint = CodeService.InsertCode(cons);
                    APP.Composeentitys.Add(cons);
                }

                return(cons);
            }
        }
Beispiel #6
0
        private static async Task CheckAndRunNextRuntimeComposity(int requsetHash, HttpContext httpContext, RuntimeStepModel newrunmodel, ISqlSugarClient dbFactory, ISysDatabaseService codeService, IConfiguration config)
        {
            var resouce = newrunmodel.Resuce(newrunmodel.NextRunTimeKey);

            if (resouce != null)
            {
                var guid = (string)resouce;
                if (string.IsNullOrEmpty(guid))
                {
                    //newrunmodel.ResouceInfos.Remove(newrunmodel.NextRunTimeKey);
                    return;
                }
                var nextcon = codeService.GetConposity(guid).FirstOrDefault();
                if (nextcon == null)
                {
                    nextcon = new ComposeEntity()
                    {
                        Guid    = guid,
                        RunMode = RunMode.Coding
                    };
                    var reint = codeService.InsertCode(nextcon);
                }
                else
                {
                    var nextRnmodel = new RuntimeStepModel(config)
                    {
                        ParentRuntimeModel = newrunmodel,
                        Res           = newrunmodel.Res,
                        ComposeEntity = nextcon,
                        HashCode      = nextcon.GetHash()
                    };
                    nextRnmodel.Res.Remove(newrunmodel.NextRunTimeKey);
                    await RunComposity(requsetHash, httpContext, nextRnmodel, dbFactory, codeService, config);
                }
            }
        }