public CodeResultModel SaveButtonCode(ButtonHtml buttonHtml, ResultOperation resultOperation, FormModel formModel, CodeBaseSharedModel codeBaseShared) { DesignCodeModel designCodeModel = null; if (!string.IsNullOrWhiteSpace(buttonHtml.BackendCoding)) { designCodeModel = DesignCodeUtility.GetDesignCodeFromXml(buttonHtml.BackendCoding); } if (designCodeModel != null && (designCodeModel.CodeObjects?.Any() ?? false)) { var result = this.ExecuteOnExitFormCode(designCodeModel, formModel, codeBaseShared); if (!result.Result) { resultOperation.SetHasError(); if (!(result?.CodeBaseShared.MessageList?.Any() ?? false)) { resultOperation.AddError(LangUtility.Get("Failed.Text", "Engine")); } } return(result); } return(null); }
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)); }
/// <summary> /// mostly used in service task and execute runCode command in grid column. /// </summary> public CodeResultModel ExecuteScriptCode(DesignCodeModel designCodeModel, CodeBaseSharedModel codeBaseShared) { if (!(designCodeModel.CodeObjects?.Any() ?? false)) { return(null); } (bool result, CodeBase codeBase) = this.Execute(designCodeModel, null, codeBaseShared, onlyCondition: false); return(new CodeResultModel(result, codeBase.UrlHelper.RedirectUrlModel, codeBase.CodeBaseShared)); }
public static ResultOperation SetVariableByForms(ContentHtml contentHtml, CodeBaseSharedModel codeBaseShared, List <QueryModel> queryModels) { ResultOperation resultOperation = new ResultOperation(); foreach (RowHtml row in contentHtml.GetRowHtmls) { foreach (ColumnHtml column in row.Columns) { foreach (var item in column.children) { if (item is FormHtml) { SetVariableByForms(((FormHtml)item).ContentHtml, codeBaseShared, queryModels); } else { if (item is BindingElementBase) { BindingElementBase bindingItem = ((BindingElementBase)item); if (bindingItem.IsInForm(queryModels)) { bindingItem.IsValid(resultOperation); if (!resultOperation.IsSuccess) { return(resultOperation); } if (item is TextBoxHtml && ((TextBoxHtml)item).SubType == TextBoxHtml.e_TextBoxType.threadTaskDescription.ToString()) { codeBaseShared.ThreadTaskDescription = bindingItem.Value.ToStringObjNull(); } else { if (bindingItem.Type != "FILEUPLOAD") { string variableName = bindingItem.Map.Split('.').FirstOrDefault(); if (!codeBaseShared.ListSetVariable.Any(c => c.Name == variableName)) { codeBaseShared.ListSetVariable.Add(new VariableModel(variableName, new DataModel())); } codeBaseShared.ListSetVariable.FirstOrDefault(c => c.Name == variableName)[bindingItem.Map] = bindingItem.Value; } } } } } } } } return(resultOperation); }
public VariableCodeHelper(IDataManageEngine dataManageEngine, CodeBaseSharedModel codeBaseShared) { this.DataManageHelperService = dataManageEngine; this.CodeBaseShared = codeBaseShared; }
/// <summary> /// /// </summary> /// <param name="onlyCondition">Is true for condition rule like visibilty of form or gateway condition</param> /// <returns></returns> private (bool result, CodeBase codeBase) Execute(DesignCodeModel designCodeModel, FormModel formModel, CodeBaseSharedModel codeBaseShared, bool onlyCondition) { var listItem = designCodeModel.CodeObjects.Cast <DCBaseModel>().ToList(); CodeBase codeBase; bool result = true; if (listItem.Any(c => c is DCExpressionModel)) { codeBase = DynamicCodeEngine.LoadClass(designCodeModel.ID, base.EngineSharedModel.CurrentProcessID, base.EngineSharedModel.CurrentApplicationPageID); } else { codeBase = new CodeBase(); } codeBase.InitialProperties(base.EngineSharedModel.CurrentProcessID, base.EngineSharedModel.CurrentThreadID, base.EngineSharedModel.CurrentApplicationPageID, base.UnitOfWork, base.EngineSharedModel.BaseQueryModel, GetCurrentUserID(base.EngineSharedModel.CurrentUserName), base.EngineSharedModel.CurrentUserName, formModel, base.EngineSharedModel.ApiSessionID, codeBaseShared); this.ExecuteCodeModel(listItem, codeBase, onlyCondition, string.Empty, ref result); return(result, codeBase); }
private EngineResponseModel SaveContentHtmlByPage(Guid applicationPageId, string buttonControlId) { ResultOperation resultOperation = new ResultOperation(); RedirectUrlModel redirectUrlModel = null; CodeBaseSharedModel codeBaseShared = new CodeBaseSharedModel(); try { FormModel formModel = new FormModel(); sysBpmsDynamicForm dynamicForm = new DynamicFormService(base.UnitOfWork).GetInfoByPageID(applicationPageId); //conver form xml code to json object JObject obj = JObject.Parse(dynamicForm.DesignJson); //if json object has a control with type = CONTENT if (obj != null && obj["type"].ToString() == "CONTENT") { formModel = new FormModel(obj, HtmlElementHelper.MakeModel(base.EngineSharedModel, base.UnitOfWork, HtmlElementHelperModel.e_FormAction.OnPost, dynamicForm), null, null, dynamicForm, false); resultOperation = formModel.ResultOperation; } this.BeginTransaction(); if (resultOperation.IsSuccess) { CodeResultModel codeResultModel; //It sets variables by form's widgets and adds to the codeBaseShared's ListSetVariable. resultOperation = DataManageEngine.SetVariableByForms(formModel.ContentHtml, codeBaseShared, base.EngineSharedModel.BaseQueryModel); if (resultOperation.IsSuccess) { //execute form button backend code. if (!string.IsNullOrWhiteSpace(buttonControlId)) { ButtonHtml buttonHtml = (ButtonHtml)formModel.ContentHtml.FindControlByID(buttonControlId); DynamicCodeEngine dynamicCodeEngine = new DynamicCodeEngine(base.EngineSharedModel, base.UnitOfWork); codeResultModel = dynamicCodeEngine.SaveButtonCode(buttonHtml, resultOperation, formModel, codeBaseShared); redirectUrlModel = codeResultModel?.RedirectUrlModel ?? redirectUrlModel; if (buttonHtml.subtype != ButtonHtml.e_subtype.submit) { //If in code any variable is set, it Will save them all at the end dynamicCodeEngine.SaveExternalVariable(codeResultModel); base.FinalizeService(resultOperation); return(new EngineResponseModel().InitPost(resultOperation, codeBaseShared.MessageList, redirectUrlModel, isSubmit: false, listDownloadModel: codeBaseShared.ListDownloadModel)); } } //execute form OnExitFormCode if (!string.IsNullOrWhiteSpace(dynamicForm.OnExitFormCode)) { codeResultModel = new DynamicCodeEngine(base.EngineSharedModel, base.UnitOfWork).ExecuteOnExitFormCode(DesignCodeUtility.GetDesignCodeFromXml(dynamicForm.OnExitFormCode), formModel, codeBaseShared); DynamicCodeEngine.SetToErrorMessage(codeResultModel, resultOperation); redirectUrlModel = codeResultModel?.RedirectUrlModel ?? redirectUrlModel; } if (resultOperation.IsSuccess) { //save html element values into database. resultOperation = new DataManageEngine(base.EngineSharedModel, base.UnitOfWork).SaveIntoDataBase(formModel.ContentHtml, null, codeBaseShared.ListSetVariable, null); } } } base.FinalizeService(resultOperation); resultOperation.CurrentObject = formModel; } catch (Exception ex) { return(new EngineResponseModel().InitPost(base.ExceptionHandler(ex), codeBaseShared.MessageList, null)); } return(new EngineResponseModel().InitPost(resultOperation, codeBaseShared.MessageList, redirectUrlModel, listDownloadModel: codeBaseShared.ListDownloadModel)); }
public MessageCodeHelper(CodeBaseSharedModel codeBaseShared, IUnitOfWork unitOfWork) { this.CodeBaseShared = codeBaseShared; this.UnitOfWork = unitOfWork; }