private EngineResponseModel GetContentHtmlByPage(Guid applicationPageId) { CodeBaseSharedModel codeBaseShared = new CodeBaseSharedModel(); FormModel formModel = new FormModel(); sysBpmsDynamicForm dynamicForm = new DynamicFormService(base.UnitOfWork).GetInfoByPageID(applicationPageId); ResultOperation resultOperation = new ResultOperation(); //convert form xml code to json object JObject obj = JObject.Parse(dynamicForm.DesignJson); HtmlElementHelperModel htmlElementHelperModel = HtmlElementHelper.MakeModel(base.EngineSharedModel, base.UnitOfWork, HtmlElementHelperModel.e_FormAction.Onload, dynamicForm); //if json object has a control with type = CONTENT if (obj != null && obj["type"].ToString() == "CONTENT") { formModel = new FormModel(obj, htmlElementHelperModel, null, null, dynamicForm, false); resultOperation = formModel.ResultOperation; } CodeResultModel codeResultModel = null; if (resultOperation.IsSuccess) { if (!string.IsNullOrWhiteSpace(dynamicForm.OnEntryFormCode)) { DynamicCodeEngine dynamicCodeEngine = new DynamicCodeEngine(base.EngineSharedModel, base.UnitOfWork); codeResultModel = dynamicCodeEngine.ExecuteOnEntryFormCode(DesignCodeUtility.GetDesignCodeFromXml(dynamicForm.OnEntryFormCode), formModel, codeBaseShared); DynamicCodeEngine.SetToErrorMessage(codeResultModel, resultOperation); //If in code any variable is set, it Will save them all at the end dynamicCodeEngine.SaveExternalVariable(codeResultModel); } } return(new EngineResponseModel().InitGet(resultOperation, codeBaseShared.MessageList, codeResultModel?.RedirectUrlModel, formModel)); }
public void SaveExternalVariable(CodeResultModel codeResultModel) { //If in script task any variable is set, it Will save them all at the end if (codeResultModel?.CodeBaseShared?.ListSetVariable?.Any() == true) { foreach (var variableModel in codeResultModel.CodeBaseShared.ListSetVariable) { new DataManageEngine(base.EngineSharedModel, base.UnitOfWork).SaveIntoDataBase(variableModel, null); } } }
public static void SetToErrorMessage(CodeResultModel result, ResultOperation resultOperation) { if (result != null) { if (!result.Result) { if (resultOperation != null) { resultOperation.SetHasError(); if (!(result?.CodeBaseShared.MessageList?.Any() ?? false)) { resultOperation.AddError(LangUtility.Get("Failed.Text", "Engine")); } } } } }