public object ExecuteFormResource(EbApi Api, Service Service)
        {
            try
            {
                int     RecordId = 0;
                NTVDict _params  = new NTVDict();
                foreach (KeyValuePair <string, object> p in Api.GlobalParams)
                {
                    EbDbTypes _type;
                    if (p.Value is int)
                    {
                        _type = EbDbTypes.Int32;
                    }
                    else //check other types here if required
                    {
                        _type = EbDbTypes.String;
                    }
                    _params.Add(p.Key, new NTV()
                    {
                        Name = p.Key, Type = _type, Value = p.Value
                    });
                }

                if (!string.IsNullOrWhiteSpace(this.DataIdParam) && Api.GlobalParams.ContainsKey(this.DataIdParam))
                {
                    int.TryParse(Convert.ToString(Api.GlobalParams[this.DataIdParam]), out RecordId);
                }
                InsertOrUpdateFormDataRqst request = new InsertOrUpdateFormDataRqst
                {
                    RefId        = this.Reference,
                    PushJson     = this.PushJson,
                    UserId       = Api.UserObject.UserId,
                    UserAuthId   = Api.UserObject.AuthId,
                    RecordId     = RecordId,
                    LocId        = Convert.ToInt32(Api.GlobalParams["eb_loc_id"]),
                    SolnId       = Api.SolutionId,
                    WhichConsole = "uc",
                    FormGlobals  = new FormGlobals {
                        Params = _params
                    },
                    //TransactionConnection = TransactionConnection
                };

                EbConnectionFactory        ebConnection = new EbConnectionFactory(Api.SolutionId, Api.Redis);
                InsertOrUpdateFormDataResp resp         = EbFormHelper.InsertOrUpdateFormData(request, Api.DataDB, Service, Api.Redis, ebConnection);

                if (resp.Status == (int)HttpStatusCode.OK)
                {
                    return(resp.RecordId);
                }
                else
                {
                    throw new Exception(resp.Message);
                }
            }
            catch (Exception ex)
            {
                throw new ApiException("[ExecuteFormResource], " + ex.Message);
            }
        }
 protected void InitOnLoadExpressions()
 {
     foreach (EbMobileControl ctrl in dataGrid.ChildControls)
     {
         EbFormHelper.EvaluateExprOnLoad(ctrl, dataGrid.FormRenderMode);
     }
 }
 //builder side - now it is using to get design html, rec call from AfterRedisGet
 public void AfterRedisGet(Service service)
 {
     EbFormHelper.AfterRedisGet(this, service.Redis, null, service);
     foreach (EbControl c in this.Controls)
     {
         EbFormHelper.RenameControlsRec(c, this.Name);
     }
 }
Ejemplo n.º 4
0
        public virtual void ValueChanged(string source = null)
        {
            if (source != null && EbFormHelper.ContainsInValExpr(this.Name, source, this.Parent))
            {
                return;
            }

            if (PropagateChange)
            {
                EbFormHelper.ControlValueChanged(this.Name, this.Parent);
            }
        }
        public string GetSql(Service service)// duplicate
        {
            EbDataReader dr  = EbFormHelper.GetEbObject <EbDataReader>(this.DataSourceId, null, service.Redis, service);
            string       Sql = dr.Sql.Trim();

            if (Sql.LastIndexOf(";") == Sql.Length - 1)
            {
                Sql = Sql.Substring(0, Sql.Length - 1);
            }

            return(Sql);
        }
Ejemplo n.º 6
0
 private void Render()
 {
     try
     {
         FormViewContainer.Children.Clear();
         EbFormHelper.AddAllControlViews(FormViewContainer, Controls, FormMode, NetWorkType, Context, "form", false);
     }
     catch (Exception ex)
     {
         EbLog.Error(ex.Message);
     }
 }
        public override void FetchParamsMeta(IServiceClient ServiceClient, IRedisClient redis, EbControl[] Allctrls, Service service)
        {
            EbChartVisualization ChartVisualization = EbFormHelper.GetEbObject <EbChartVisualization>(TVRefId, ServiceClient, redis, service);

            if (string.IsNullOrEmpty(ChartVisualization.DataSourceRefId))
            {
                throw new FormException($"Missing Data Reader of Chart control view that is connected to {this.Label}.");
            }
            EbDataReader DrObj = EbFormHelper.GetEbObject <EbDataReader>(ChartVisualization.DataSourceRefId, ServiceClient, redis, service);

            this.ParamsList = DrObj.GetParams(redis as RedisClient);
        }
        protected void InitDefaultValueExpressions()
        {
            foreach (EbMobileControl ctrl in dataGrid.ChildControls)
            {
                if (!ctrl.DefaultExprEvaluated)
                {
                    EbScript defExp = ctrl.DefaultValueExpression;

                    if (defExp != null && !defExp.IsEmpty())
                    {
                        EbFormHelper.SetDefaultValue(ctrl.Name);
                    }
                }
            }
        }
        private void OnSaveAndContinueClicked(object sender, EventArgs e)
        {
            if (isTapped || this.dataGrid.IsTaped())
            {
                return;
            }
            isTapped = true;
            string invalidMsg = EbFormHelper.ValidateDataGrid(this.dataGrid);

            if (invalidMsg == null)
            {
                OnInserted?.Invoke(mode == GridMode.New ? null : rowName);
                Utils.Toast("1 row added.");
                ResetControls();
                EbFormHelper.ExecDGOuterDependency(this.dataGrid.Name);
            }
            else
            {
                Utils.Toast(invalidMsg);
            }
            isTapped = false;
        }
        private void RowDelete_Clicked(object sender, EventArgs e)
        {
            if (isTapped)
            {
                return;
            }
            isTapped = true;
            Button button = sender as Button;

            foreach (View el in Body.Children)
            {
                if (el.ClassId == button.ClassId)
                {
                    Body.Children.Remove(el);
                    if (this.dataGrid.FormRenderMode == FormMode.EDIT)
                    {
                        if (dataDictionary.TryGetValue(el.ClassId, out MobileTableRow row))
                        {
                            if (row.RowId == 0)
                            {
                                dataDictionary.Remove(el.ClassId);
                            }
                            else
                            {
                                row.IsDelete = true;
                            }
                        }
                    }
                    else
                    {
                        dataDictionary.Remove(el.ClassId);
                    }
                    EbFormHelper.ExecDGOuterDependency(this.dataGrid.Name);
                    break;
                }
            }
            isTapped = false;
        }
        private async void OnSaveAndCloseClicked(object sender, EventArgs e)
        {
            if (isTapped || this.dataGrid.IsTaped())
            {
                return;
            }
            isTapped = true;
            string invalidMsg = EbFormHelper.ValidateDataGrid(this.dataGrid);

            if (invalidMsg == null)
            {
                OnInserted?.Invoke(mode == GridMode.New ? null : rowName);
                ResetControls();
                EbFormHelper.ExecDGOuterDependency(this.dataGrid.Name);
                await App.Navigation.PopMasterModalAsync(true);

                this.dataGrid.IsDgViewOpen = false;
            }
            else
            {
                Utils.Toast(invalidMsg);
            }
            isTapped = false;
        }
 private void OnEditButtonClicked(object sender, EventArgs e)
 {
     viewModel.IsEditButtonVisible = false;
     viewModel.IsSaveButtonVisible = true;
     EbFormHelper.SwitchViewToEdit();
 }
        public void InitFromDataBase(JsonServiceClient ServiceClient, IRedisClient redis)
        {
            EbChartVisualization ChartVisualization = EbFormHelper.GetEbObject <EbChartVisualization>(TVRefId, ServiceClient, redis, null);

            this.ChartVisualizationJson = EbSerializers.Json_Serialize(ChartVisualization);
        }
 private void CreateForm()
 {
     EbFormHelper.AddAllControlViews(ControlContainer, dataGrid.ChildControls, dataGrid.FormRenderMode, dataGrid.NetworkType, null, dataGrid.Name, true);
 }
        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 });
        }
Ejemplo n.º 16
0
 public override void ReplaceRefid(Dictionary <string, string> RefidMap)
 {
     EbFormHelper.ReplaceRefid(this, RefidMap);
 }
Ejemplo n.º 17
0
 public override List <string> DiscoverRelatedRefids()
 {
     return(EbFormHelper.DiscoverRelatedRefids(this));
 }
 public override void AfterRedisGet(RedisClient Redis, IServiceClient client)
 {
     EbFormHelper.AfterRedisGet(this, Redis, client, null);
 }
        //public override string DiscoverRelatedRefids()
        //{
        //    var x = this.RefId;
        //    string refids = "";
        //    foreach (EbControl control in Controls)
        //    {
        //        PropertyInfo[] _props = control.GetType().GetProperties();
        //        foreach (PropertyInfo _prop in _props)
        //        {
        //            if (_prop.IsDefined(typeof(OSE_ObjectTypes)))
        //                refids += _prop.GetValue(control, null).ToString() + ",";
        //        }
        //    }
        //    Console.WriteLine(this.RefId + "-->" + refids);
        //    return refids;
        //}

        public void AfterRedisGet(Service service)
        {
            EbFormHelper.AfterRedisGet(this, service.Redis, null, service);
        }