public static bool CheckReviewCompatibility(EbWebForm webForm) { if (webForm.TableRowId <= 0) { throw new FormException("Bad Request. [34]", (int)HttpStatusCode.BadRequest, "Review operation failed due to invalid data id", "EbReviewHelper -> CheckReviewCompatibility"); } EbReview ebReview = (EbReview)webForm.FormSchema.ExtendedControls.Find(e => e is EbReview); if (ebReview == null) { throw new FormException("Review control not found! Contact Admin.", (int)HttpStatusCode.BadRequest, "check the form refid and review control", "EbReviewHelper -> CheckReviewCompatibility"); } bool ok = false; if (webForm.FormData?.MultipleTables.ContainsKey(ebReview.TableName) == true) { SingleTable Table = webForm.FormData.MultipleTables[ebReview.TableName]; if (Table != null && Table.Count > 0) { Table.RemoveAll(e => e.RowId > 0); if (Table.Count == 1) { ok = true; } } } if (!ok) { throw new FormException("Bad review request", (int)HttpStatusCode.BadRequest, "check the form refid and review control", "EbReviewHelper -> CheckReviewCompatibility"); } return(true); }
private async Task <PushResponse> SendRecord(WebformData webdata, EbMobileForm Form, EbDataTable Dt, EbDataRow DataRow, int RowIndex) { PushResponse response = null; try { ClearWebFormData(webdata); SingleTable SingleTable = new SingleTable(); int localid = Convert.ToInt32(DataRow["id"]); SingleRow row = this.GetRow(Form, Dt, DataRow, RowIndex); SingleTable.Add(row); webdata.MultipleTables.Add(Form.TableName, SingleTable); await Form.UploadFiles(localid, webdata); this.GetLinesEnabledData(localid, Form, webdata); if (FormService.Instance == null) { new FormService(); } response = await FormService.Instance.SendFormDataAsync(null, webdata, 0, Form.WebFormRefId, row.LocId); response.LocalRowId = localid; } catch (Exception ex) { EbLog.Error("SyncServices.PushRow---" + ex.Message); } return(response); }
public void MergeFormData(WebformData FormData, WebFormSchema FormSchema) { if (FormData.MultipleTables.ContainsKey(this.TableName) && FormData.MultipleTables[this.TableName].Count > 0) { SingleTable rows = FormData.MultipleTables[this.TableName]; for (int i = 0; i < rows.Count; i++) { if (rows[i].RowId > 0) { rows.RemoveAt(i--); } } if (rows.Count == 1)//one new entry// need to write code for 'AfterSaveRoutines' { foreach (TableSchema t in FormSchema.Tables) { if (t.TableName != this.TableName) { FormData.MultipleTables.Remove(t.TableName);// approval execution, hence removing other data if present } } string[] str_t = { FormConstants.stage_unique_id, FormConstants.action_unique_id, FormConstants.eb_my_actions_id, FormConstants.comments }; for (int i = 0; i < str_t.Length; i++) { EbControl con = this.Controls.Find(e => e.Name == str_t[i]); FormData.MultipleTables[this.TableName][0].SetEbDbType(con.Name, con.EbDbType); FormData.MultipleTables[this.TableName][0].SetControl(con.Name, con); } } } }
public ActionResult LookCode(string baseInfoJson, string gridInfoJson, string gridColumnJson, string formInfoJson, string formFieldJson) { SingleTable default_Template = new SingleTable(); BaseConfigModel baseConfigModel = baseInfoJson.ToObject <BaseConfigModel>(); baseConfigModel.gridModel = gridInfoJson.ToObject <GridModel>(); baseConfigModel.gridColumnModel = gridColumnJson.ToList <GridColumnModel>(); baseConfigModel.formModel = formInfoJson.ToObject <FormModel>(); baseConfigModel.formFieldModel = formFieldJson.ToList <FormFieldModel>(); var tableFiled = new DataBaseTableBLL().GetTableFiledList(baseConfigModel.DataBaseLinkId, baseConfigModel.DataBaseTableName); string entitybuilder = default_Template.EntityBuilder(baseConfigModel, DataHelper.ListToDataTable <DataBaseTableFieldEntity>(tableFiled.ToList())); string entitymapbuilder = default_Template.EntityMapBuilder(baseConfigModel); string servicebuilder = default_Template.ServiceBuilder(baseConfigModel); string iservicebuilder = default_Template.IServiceBuilder(baseConfigModel); string businesbuilder = default_Template.BusinesBuilder(baseConfigModel); string controllerbuilder = default_Template.ControllerBuilder(baseConfigModel); string indexbuilder = default_Template.IndexBuilder(baseConfigModel); string formbuilder = default_Template.FormBuilder(baseConfigModel); var jsonData = new { entityCode = entitybuilder, entitymapCode = entitymapbuilder, serviceCode = servicebuilder, iserviceCode = iservicebuilder, businesCode = businesbuilder, controllerCode = controllerbuilder, indexCode = indexbuilder, formCode = formbuilder }; return(ToJsonResult(jsonData)); }
private static void GetCSharpFormGlobalsRec(_FG_WebForm fG_WebForm, EbControlContainer _container, WebformData _formdata) { SingleTable Table = _formdata.MultipleTables.ContainsKey(_container.TableName) ? _formdata.MultipleTables[_container.TableName] : new SingleTable(); if (_container is EbDataGrid) { _FG_DataGrid fG_DataGrid = new _FG_DataGrid(_container as EbDataGrid, Table); fG_WebForm.DataGrids.Add(fG_DataGrid); } else if (_container is EbReview) { fG_WebForm.Review = new _FG_Review(_container as EbReview, Table); } else { foreach (EbControl _control in _container.Controls) { if (_control is EbControlContainer) { GetCSharpFormGlobalsRec(fG_WebForm, _control as EbControlContainer, _formdata); } else { object data = null; if (_formdata.MultipleTables.ContainsKey(_container.TableName) && _formdata.MultipleTables[_container.TableName].Count > 0) { data = _formdata.MultipleTables[_container.TableName][0][_control.Name]; } fG_WebForm.FlatCtrls.Controls.Add(new _FG_Control(_control, data)); } } } }
private async Task PushDependencyData(WebformData webdata, EbMobileForm sourceForm, EbMobileForm dependencyForm, int liveId, int localId) { try { string RefColumn = $"{sourceForm.TableName}_id"; string query = string.Format(StaticQueries.STARFROM_TABLE_WDEP, dependencyForm.GetQuery(), dependencyForm.TableName, RefColumn, localId); EbDataTable dt = App.DataDB.DoQuery(query); if (dt.Rows.Any()) { SingleTable SingleTable = new SingleTable(); for (int i = 0; i < dt.Rows.Count; i++) { FillLiveId(dt, dt.Rows[i], liveId, RefColumn); PushResponse resp = await SendRecord(webdata, dependencyForm, dt, dt.Rows[i], i); if (resp.RowAffected <= 0) { continue; } dependencyForm.FlagLocalRow(resp); } } } catch (Exception ex) { EbLog.Error("SyncServices.PushDependencyData---" + ex.Message); } }
private void GetLinesEnabledData(int localid, EbMobileForm form, WebformData formData) { try { Dictionary <string, EbMobileControl> controls = form.ChildControls.ToControlDictionary(); foreach (var ctrl in controls.Values) { if (ctrl is ILinesEnabled Ilines) { SingleTable st = new SingleTable(); formData.MultipleTables.Add(Ilines.TableName, st); EbDataTable data = Ilines.GetLocalData(form.TableName, localid); foreach (var dr in data.Rows) { SingleRow row = new SingleRow { LocId = Convert.ToInt32(dr["eb_loc_id"]) }; row.Columns.AddRange(Ilines.GetColumnValues(data.Columns, dr)); st.Add(row); } } } } catch (Exception ex) { EbLog.Error(ex.Message); } }
public ActionResult LookCode(string baseInfoJson, string gridInfoJson, string gridColumnJson, string formInfoJson, string formFieldJson) { SingleTable default_Template = new SingleTable(); BaseConfigModel baseConfigModel = baseInfoJson.ToObject <BaseConfigModel>(); baseConfigModel.gridModel = gridInfoJson.ToObject <GridModel>(); baseConfigModel.gridColumnModel = gridColumnJson.ToList <GridColumnModel>(); baseConfigModel.formModel = formInfoJson.ToObject <FormModel>(); baseConfigModel.formFieldModel = formFieldJson.ToList <FormFieldModel>(); var tableFiled = new DataBaseTableBLL(baseConfigModel.DataBaseLinkId).GetTableFiledList(baseConfigModel.DataBaseLinkId, baseConfigModel.DataBaseTableName); baseConfigModel.DataBaseLinkName = ""; DataBaseLinkEntity dataBaseLinkEntity = new DataBaseLinkBLL().GetEntity(baseConfigModel.DataBaseLinkId); string connectionString = ConfigurationManager.ConnectionStrings["BaseDb"].ConnectionString; if (connectionString != dataBaseLinkEntity.F_DbConnection) { baseConfigModel.DataBaseLinkName = dataBaseLinkEntity.F_DBName; baseConfigModel.DataBaseLinkType = dataBaseLinkEntity.F_DbType; if (ConfigurationManager.ConnectionStrings[dataBaseLinkEntity.F_DBName] == null) { string providerName = "System.Data.SqlClient"; if (dataBaseLinkEntity.F_DbType == "MySql") { providerName = "MySql.Data.MySqlClient"; } else if (dataBaseLinkEntity.F_DbType == "Oracle") { providerName = "Oracle.ManagedDataAccess.Client"; } Config.UpdateOrCreateConnectionString("XmlConfig\\database.config", dataBaseLinkEntity.F_DBName, dataBaseLinkEntity.F_DbConnection, providerName); } } string entitybuilder = default_Template.EntityBuilder(baseConfigModel, DataHelper.ListToDataTable <DataBaseTableFieldEntity>(tableFiled.ToList())); string entitymapbuilder = default_Template.EntityMapBuilder(baseConfigModel); string servicebuilder = default_Template.ServiceBuilder(baseConfigModel); string iservicebuilder = default_Template.IServiceBuilder(baseConfigModel); string businesbuilder = default_Template.BusinesBuilder(baseConfigModel); string controllerbuilder = default_Template.ControllerBuilder(baseConfigModel); string indexbuilder = default_Template.IndexBuilder(baseConfigModel); string formbuilder = default_Template.FormBuilder(baseConfigModel); var jsonData = new { entityCode = entitybuilder, entitymapCode = entitymapbuilder, serviceCode = servicebuilder, iserviceCode = iservicebuilder, businesCode = businesbuilder, controllerCode = controllerbuilder, indexCode = indexbuilder, formCode = formbuilder }; return(ToJsonResult(jsonData)); }
static void Main(string[] args) { BaseConfigModel baseConfigModel = new BaseConfigModel(); baseConfigModel.OutputEntity = @"F:\files\CodeGeneratorTest"; CreateCodeFile.CreateExecution(baseConfigModel, "entityCode"); SingleTable singleTable = new SingleTable(); //var modelString = singleTable.EntityBuilder(baseConfigModel,new System.Data.DataTable()); }
private void GetPsQueryAndParams(PsDmDict _PsDmDict, Dictionary <string, List <int> > row_ids) { string psqry; int p_i = 0; EbDataReader dataReader; if (this.ebForm.EbConnectionFactory == null) { throw new FormException("Something went wrong", (int)HttpStatusCode.InternalServerError, "ConnectionFactory is null", "PsDmHelper -> GetPsQueryAndParams"); } foreach (EbControl psCtrl in this.drPsList) { row_ids.Add(psCtrl.EbSid, new List <int>()); List <Param> ParamsList = (psCtrl as IEbDataReaderControl).ParamsList; IEbPowerSelect ipsCtrl = psCtrl as IEbPowerSelect; if (ParamsList == null) { Console.WriteLine($"ParamsList in PowerSelect {psCtrl.Name} is null. Trying to UpdateParamsMeta..."); ipsCtrl.UpdateParamsMeta(service, service.Redis); ParamsList = (psCtrl as IEbDataReaderControl).ParamsList; if (ParamsList == null) { throw new FormException($"Invalid ParamsList in '{psCtrl.Label ?? psCtrl.Name}'. Contact Admin", (int)HttpStatusCode.InternalServerError, "Save object in dev side", "EbWebForm"); } } TableSchema _pstable = this.ebForm.FormSchema.Tables.Find(e => e.TableName == ipsCtrl.TableName); if (_pstable == null) { throw new FormException("Something went wrong", (int)HttpStatusCode.InternalServerError, "_pstable is null", "EbWebForm"); } SingleTable psTable = this._FormData.MultipleTables.ContainsKey(_pstable.TableName) ? this._FormData.MultipleTables[_pstable.TableName] : null; if (psTable == null) { Console.WriteLine("[INFO] PS_Table is null."); } string vm_vals = string.Empty; (psqry, dataReader) = ipsCtrl.GetSqlAndDr(this.service); IDatabase DataDB = dataReader.GetDatastore(this.ebForm.EbConnectionFactory); if (psCtrl is EbDGPowerSelectColumn dgpsCtrl && dgpsCtrl.StrictSelect && psTable?.Count > 0)// separate query { _PsDmDict.TryAdd(DataDB, psCtrl); foreach (SingleRow Row in psTable) { if (Row[psCtrl.Name] != null) { string temp = this.AddPsParams(psCtrl, DataDB, _PsDmDict.GetPList(DataDB), Row, ref p_i, psqry); List <int> nums = Convert.ToString(Row[psCtrl.Name]).Split(",").Select(e => { return(int.TryParse(e, out int ie) ? ie : 0); }).ToList(); _PsDmDict.AppendQuery(DataDB, GetPsDmSelectQuery(temp, ipsCtrl, nums)); p_i++; row_ids[psCtrl.EbSid].Add(Row.RowId); } } }
private static FG_DataGrid GetDataGridGlobal(EbDataGrid DG, SingleTable Table, SingleRow RowModel) { List <FG_Row> Rows = new List <FG_Row>(); Dictionary <string, object> Metas = null; foreach (SingleRow Row in Table) { if (Row.IsDelete) { continue; } FG_Row fG_Row = new FG_Row() { id = Convert.ToInt32(Row[FormConstants.id]) }; foreach (EbControl _control in DG.Controls) { if (_control is EbDGPowerSelectColumn) { Metas = new Dictionary <string, object>() { { FG_Constants.Columns, Row.GetColumn(_control.Name).R } } } ; else { Metas = null; } fG_Row.Controls.Add(new FG_Control(_control.Name, _control.ObjType, Row[_control.Name], Metas)); } Rows.Add(fG_Row); } FG_Row fG_RowModel = new FG_Row(); foreach (EbControl _control in DG.Controls) { if (_control is EbDGPowerSelectColumn) { Metas = new Dictionary <string, object>() { { FG_Constants.Columns, RowModel.GetColumn(_control.Name).R } } } ; else { Metas = null; } fG_RowModel.Controls.Add(new FG_Control(_control.Name, _control.ObjType, RowModel[_control.Name], Metas)); } return(new FG_DataGrid(DG.Name, Rows, fG_RowModel)); }
public _FG_Review(EbReview CtrlObj, SingleTable Table) { this.Name = CtrlObj.Name; this.CtrlObj = CtrlObj; this.Table = Table; SingleRow _Row = null; foreach (SingleRow Row in this.Table) { if (Row.RowId <= 0 && Row.Columns.Count > 0) { _Row = Row; break; } } this.stages = new Dictionary <string, _FG_Review_Stage>(); foreach (ReviewStageAbstract stage in this.CtrlObj.FormStages) { EbReviewStage _eb_stage = stage as EbReviewStage; List <_FG_Review_Action> fg_actions = new List <_FG_Review_Action>(); foreach (ReviewActionAbstract action in _eb_stage.StageActions) { fg_actions.Add(new _FG_Review_Action((action as EbReviewAction).Name)); } if (_Row != null && Convert.ToString(_Row["stage_unique_id"]) == _eb_stage.EbSid) { EbReviewAction eb_curAct = (EbReviewAction)_eb_stage.StageActions.Find(e => (e as EbReviewAction).EbSid == Convert.ToString(_Row["action_unique_id"])); _FG_Review_Action fg_curAct = null; if (eb_curAct != null) { fg_curAct = fg_actions.Find(e => e.name == eb_curAct.Name); } this.stages.Add(_eb_stage.Name, new _FG_Review_Stage(_eb_stage.Name, fg_actions, fg_curAct)); this.currentStage = this.stages[_eb_stage.Name]; } else { this.stages.Add(_eb_stage.Name, new _FG_Review_Stage(_eb_stage.Name, fg_actions, null)); } } }
//for system/mobile notification public DbParameter[] GetParameters(EbWebForm _this, IDatabase DataDB, Dictionary <string, string> QryParams) { List <DbParameter> _p = new List <DbParameter>(); int _idx = 0; foreach (KeyValuePair <string, string> p in QryParams) { SingleTable Table = null; if (_this.FormData.MultipleTables.ContainsKey(p.Value)) { Table = _this.FormData.MultipleTables[p.Value]; } else if (_this.FormDataBackup?.MultipleTables.ContainsKey(p.Value) == true) { Table = _this.FormDataBackup.MultipleTables[p.Value]; } else { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} not found in MultipleTables"); } TableSchema _table = _this.FormSchema.Tables.Find(e => e.TableName == p.Value); if (_table.TableType != WebFormTableTypes.Normal) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but it is not a normal table"); } if (Table.Count != 1) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but table is empty"); } SingleColumn Column = Table[0].Columns.Find(e => e.Control?.Name == p.Key); if (Column?.Control == null) { throw new FormException("Bad Request", (int)HttpStatusCode.BadRequest, $"SendNotifications: Notify by UserId parameter {p.Key} is not idetified", $"{p.Value} found in MultipleTables but data not available"); } ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(DataDB, _p, Column, _idx, _this.UserObj); Column.Control.ParameterizeControl(args, _this.CrudContext); _idx = args.i; _p[_idx - 1].ParameterName = p.Key; } return(_p.ToArray()); }
private static FG_Review GetReviewGlobal(EbReview Rev, SingleTable Table, SingleTable TableBkUp) { Dictionary <string, FG_Review_Stage> stages = new Dictionary <string, FG_Review_Stage>(); FG_Review_Stage currentStage = null; SingleRow Row = null; foreach (SingleRow _Row in Table) { if (_Row.RowId <= 0 && _Row.Columns.Count > 0) { Row = _Row; break; } } foreach (EbReviewStage stage in Rev.FormStages) { List <FG_Review_Action> actions = new List <FG_Review_Action>(); foreach (EbReviewAction action in stage.StageActions) { actions.Add(new FG_Review_Action(action.Name)); } if (Row != null && Convert.ToString(Row["stage_unique_id"]) == stage.EbSid) { EbReviewAction curAct = stage.StageActions.Find(e => e.EbSid == Convert.ToString(Row["action_unique_id"])); FG_Review_Action fg_curAct = null; if (curAct != null) { fg_curAct = actions.Find(e => e.name == curAct.Name); } stages.Add(stage.Name, new FG_Review_Stage(stage.Name, actions, fg_curAct)); currentStage = stages[stage.Name]; } else { stages.Add(stage.Name, new FG_Review_Stage(stage.Name, actions, null)); } } return(new FG_Review(stages, currentStage)); }
public _FG_DataGrid(EbDataGrid CtrlObj, SingleTable Table) { this.Name = CtrlObj.Name; this.CtrlObj = CtrlObj; this.Table = Table; }
private static void GetCSharpFormGlobalsRec_NEW(FG_WebForm fG_WebForm, EbControlContainer _container, WebformData _formdata, WebformData _formdataBkUp) { SingleTable Table = _formdata.MultipleTables.ContainsKey(_container.TableName) ? _formdata.MultipleTables[_container.TableName] : new SingleTable(); SingleTable TableBkUp = _formdataBkUp != null && _formdataBkUp.MultipleTables.ContainsKey(_container.TableName) ? _formdataBkUp.MultipleTables[_container.TableName] : new SingleTable(); if (_container is EbDataGrid) { fG_WebForm.DataGrids.Add(GetDataGridGlobal(_container as EbDataGrid, Table, _formdata.DGsRowDataModel[_container.TableName])); } else if (_container is EbReview) { fG_WebForm.Review = GetReviewGlobal(_container as EbReview, Table, TableBkUp); } else { foreach (EbControl _control in _container.Controls) { if (_control is EbControlContainer) { GetCSharpFormGlobalsRec_NEW(fG_WebForm, _control as EbControlContainer, _formdata, _formdataBkUp); } else { object data = null; Dictionary <string, object> Metas = new Dictionary <string, object>(); if (_control is EbAutoId && fG_WebForm.__mode == "new")// && fG_WebForm.id == 0 { data = FG_Constants.AutoId_PlaceHolder; } else { SingleColumn psSC = null; if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null && !(_control is EbAutoId)) //(!(_control is EbAutoId) || (_control is EbAutoId && fG_WebForm.__mode == "edit")))// && fG_WebForm.id > 0 { data = Table[0][_control.Name]; psSC = Table[0].GetColumn(_control.Name); } else if (TableBkUp.Count > 0 && TableBkUp[0].GetColumn(_control.Name) != null) { data = TableBkUp[0][_control.Name]; psSC = TableBkUp[0].GetColumn(_control.Name); } else if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null)// Hint: For BatchDataPusher, AutoId available in 'Table' only { data = Table[0][_control.Name]; psSC = Table[0].GetColumn(_control.Name); } if (psSC != null && _control is IEbPowerSelect) { Metas.Add(FG_Constants.Columns, psSC.R); } } if (_control is EbAutoId ebAI) { Metas.Add(FG_Constants.SerialLength, ebAI.Pattern?.SerialLength ?? 0); } fG_WebForm.FlatCtrls.Controls.Add(new FG_Control(_control.Name, _control.ObjType, data, Metas)); } } } }
public static SqlLinqBuilder Create(Type mainTable) => New(SingleTable.New(TableAlias.New(None, TableCache.GetTable(mainTable))), None, SelectedFields: Enumerable.Empty <string>(), OrderBy: Enumerable.Empty <string>(), None, None, false);
private string[] GetApproverEntityValues(ref int i, EbReviewStage nextStage, out bool hasPerm) { string _col = string.Empty, _val = string.Empty; this.webForm.MyActNotification = new MyActionNotification() { ApproverEntity = nextStage.ApproverEntity, SendPushNotification = !nextStage.HideNotification }; if (nextStage.ApproverEntity == ApproverEntityTypes.Role) { _col = "role_ids"; _val = $"@role_ids_{i}"; string roles = nextStage.ApproverRoles == null ? string.Empty : nextStage.ApproverRoles.Join(","); this.param.Add(this.DataDB.GetNewParameter($"role_ids_{i++}", EbDbTypes.String, roles)); this.webForm.MyActNotification.RoleIds = nextStage.ApproverRoles; hasPerm = this.webForm.UserObj.RoleIds.Any(e => nextStage.ApproverRoles.Contains(e)); } else if (nextStage.ApproverEntity == ApproverEntityTypes.UserGroup) { _col = "usergroup_id"; _val = $"@usergroup_id_{i}"; this.param.Add(this.DataDB.GetNewParameter($"usergroup_id_{i++}", EbDbTypes.Int32, nextStage.ApproverUserGroup)); this.webForm.MyActNotification.UserGroupId = nextStage.ApproverUserGroup; hasPerm = this.webForm.UserObj.UserGroupIds.Any(e => e == nextStage.ApproverUserGroup); } else if (nextStage.ApproverEntity == ApproverEntityTypes.Users || nextStage.ApproverEntity == ApproverEntityTypes.DynamicRole) { string t1 = string.Empty, t2 = string.Empty, t3 = string.Empty; List <DbParameter> _params = new List <DbParameter>(); int _idx = 0, ErrCod = (int)HttpStatusCode.BadRequest; string ErrMsg = "GetFirstMyActionInsertQuery: Review control parameter {0} is not idetified"; foreach (KeyValuePair <string, string> p in nextStage.QryParams) { if (EbFormHelper.IsExtraSqlParam(p.Key, this.webForm.TableName)) { continue; } SingleTable _Table = null; if (this.webForm.FormData.MultipleTables.ContainsKey(p.Value)) { _Table = this.webForm.FormData.MultipleTables[p.Value]; } else if (this.webForm.FormDataBackup != null && this.webForm.FormDataBackup.MultipleTables.ContainsKey(p.Value)) { _Table = this.webForm.FormDataBackup.MultipleTables[p.Value]; } else { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} not found in MultipleTables"); } TableSchema _table = this.webForm.FormSchema.Tables.Find(e => e.TableName == p.Value); if (_table.TableType != WebFormTableTypes.Normal) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but it is not a normal table"); } if (_Table.Count != 1) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but table is empty"); } SingleColumn Column = _Table[0].Columns.Find(e => e.Control?.Name == p.Key); if (Column == null || Column.Control == null) { throw new FormException($"Bad Request", ErrCod, string.Format(ErrMsg, p.Key), $"{p.Value} found in MultipleTables but data not available"); } ParameterizeCtrl_Params args = new ParameterizeCtrl_Params(this.DataDB, _params, Column, _idx, this.webForm.UserObj); Column.Control.ParameterizeControl(args, this.webForm.CrudContext); _idx = args.i; _params[_idx - 1].ParameterName = p.Key; } List <int> ids = new List <int>(); EbFormHelper.AddExtraSqlParams(_params, this.DataDB, this.webForm.TableName, this.webForm.TableRowId, this.webForm.LocationId, this.webForm.UserObj.UserId); string qry = nextStage.ApproverEntity == ApproverEntityTypes.Users ? nextStage.ApproverUsers.Code : nextStage.ApproverRoleQuery.Code; EbDataTable dt = this.DataDB.DoQuery(qry, _params.ToArray()); foreach (EbDataRow dr in dt.Rows) { int.TryParse(dr[0].ToString(), out int temp); if (!ids.Contains(temp)) { ids.Add(temp); } } _val = $"'{ids.Join(",")}'"; if (nextStage.ApproverEntity == ApproverEntityTypes.Users) { _col = "user_ids"; this.webForm.MyActNotification.UserIds = ids; hasPerm = ids.Any(e => e == this.webForm.UserObj.UserId); } else { _col = "role_ids"; this.webForm.MyActNotification.RoleIds = ids; hasPerm = this.webForm.UserObj.RoleIds.Any(e => ids.Contains(e)); } } else { throw new FormException("Unable to process review control", (int)HttpStatusCode.InternalServerError, "Invalid value for ApproverEntity : " + nextStage.ApproverEntity, "From GetMyActionInsertUpdateQuery"); } if (this.webForm.UserObj.Roles.Contains(SystemRoles.SolutionOwner.ToString()) || this.webForm.UserObj.Roles.Contains(SystemRoles.SolutionAdmin.ToString())) { hasPerm = true; } return(new string[] { _col, _val }); }