public override async void DeleteAction() { try { if (Model.IsValid) { Model.UpdatedBy = EasyApp.Current.User.Login; SECRole data = null; if (Permisions.FirstOrDefault(x => x.Id == 3).Active) { data = ((SECRole)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Remove, Options.Me, EasyApp.Current.DefaultDatabaseSettingName, "")); } else { throw new Exception(GetLocalizedMessage(Language.ApplicationValidateSaveModified, GetLocalizedMessage(Language.ApplicationDelete))); } if (data != null) { Model.Details.Remove(data); PostDeleteAction(); } } else { PostDeleteAction(errorTitle: GetLocalizedMessage(Language.ApplicationInformation), errorMessage: GetLocalizedMessage(Language.ApplicationPendingValidations), showMessageError: true, image: MessageBoxImage.Information); } } catch (Exception ex) { PostDeleteAction(errorTitle: GetLocalizedMessage(Language.ApplicationError), errorMessage: new BusinessException(ex).GetExceptionMessage(), showMessageError: true, image: MessageBoxImage.Error); } }
public override SECRole Execute(SECRole data, Actions action, Options option, string token) { try { if (action == Actions.Add || action == Actions.Modify || action == Actions.Remove || (action == Actions.Find && (option == Options.Me || option == Options.Exist))) { if ((action == Actions.Add || action == Actions.Modify) && option == Options.All) { BenginTransaction(); sECRolePermissionDl = new SECRolePermissionBLL(Work); sECUserDl = new SECUserBLL(Work); } data = base.Execute(data, action, option, token); if (action == Actions.Find && option == Options.Me) { sECRolePermissionDl = new SECRolePermissionBLL(this.Work.Settings); sECUserDl = new SECUserBLL(this.Work.Settings); data.RolePermissions = sECRolePermissionDl.FindAll(new SECRolePermission { RoleId = data.Id }, Options.All); } if ((action == Actions.Add || action == Actions.Modify) && option == Options.All) { AddDetails(data); } return(data); } else if (action == Actions.Find && (option == Options.All || option == Options.Light)) { if (option == Options.All) { data.Entities = FindAll(data, Options.All); } else if (option == Options.Light) { data.Entities = FindAll(data, Options.Light); } return(data); } else { throw new NotImplementedException(GetLocalizedMessage(Language.DLACTIONNOTIMPLEMENT, action.ToString(), option.ToString())); } } catch (FaultException <BusinessException> f) { Rollback(); throw f; } catch (Exception e) { Rollback(); throw new BusinessException(e).GetFaultException(); } finally { Commit(); } }
public override void SetQueryParameters(IQuery query, SECRole data, Boolean byId) { base.SetQueryParameters(query, data, byId); if (byId) { //add more parameters to method for query by id } else { //Determine if the boolean values are taken included as part of the consultation //query.SetBoolean("Active", data.Active); //add more parameters to method for query by any field } }
public override String GetQuery(SECRole data, Boolean byId) { String dml = base.GetQuery(data, byId); if (byId) { //add more parameters to method for query by id } else { //Determine if the boolean values are taken included as part of the consultation //dml += " AND a.Active = :Active \n" ; //add more parameters to method for query by any field dml += " order by a.Id asc "; } return(dml); }
public void AddDetails(SECRole data) { if (data.RolePermissions != null && data.RolePermissions.Count > 0) { for (int i = 0; i < data.RolePermissions.Count; i++) { data.RolePermissions[i].RoleId = data.Id; data.RolePermissions[i].LastUpdate = DateTime.Now; data.RolePermissions[i].UpdatedBy = data.UpdatedBy; if (data.RolePermissions[i].Id == 0) { data.RolePermissions[i] = sECRolePermissionDl.Add(data.RolePermissions[i]); } else { data.RolePermissions[i] = sECRolePermissionDl.Modify(data.RolePermissions[i]); } } } }
public override async void FindAction() { try { SECRole data = ((SECRole)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Find, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); if (data.Entities != null && data.Entities.Count > 0) { Model.Details = new BindingList <SECRole>(data.Entities); } else { Model.Details = new BindingList <SECRole>(); } PostFindAction(queryName: "SECRols", recordNumber: Model.Details.Count, errorMessage: ""); } catch (Exception ex) { PostFindAction("", 0, new BusinessException(ex).GetExceptionMessage()); } }
public override void AddMoreDetailFindById(SECRole data) { }
public override void SaveOrUpdateDetails(SECRole data) { base.SaveOrUpdateDetails(data); }
public override void RemoveRules(SECRole data) { base.RemoveRules(data); }
public override void ModifyRules(SECRole data) { base.ModifyRules(data); data.LastUpdate = DateTime.Now; }
public override void AddRules(SECRole data) { base.AddRules(data); data.LastUpdate = DateTime.Now; }
public override void CommonRules(SECRole data) { base.CommonRules(data); }
public override async void SaveAction(bool createNew) { try { if (Model.IsValid) { Model.UpdatedBy = EasyApp.Current.User.Login; if (Model.RoleMenuPermissions != null && Model.RoleMenuPermissions.Count > 0) { foreach (MenuModel menu in Model.RoleMenuPermissions) { if (menu.Permissions != null && menu.Permissions.Count > 0) { foreach (Permission perm in menu.Permissions) { SECRolePermission exist = Model.RolePermissions.FirstOrDefault(x => x.MenuId == menu.Id && x.RoleId == Model.Id && x.PermissionId == perm.Id); if (exist != null) { exist.Active = perm.Active; } else { exist = new SECRolePermission(); exist.Active = perm.Active; exist.MenuId = menu.Id; exist.RoleId = Model.Id; exist.PermissionId = perm.Id; Model.RolePermissions.Add(exist); } } } } } SECRole data = null; if (Model.Id == 0 && Permisions.FirstOrDefault(x => x.Id == 1).Active) { data = ((SECRole)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Add, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); } else if (Model.Id != 0 && Permisions.FirstOrDefault(x => x.Id == 2).Active) { data = ((SECRole)await EasyApp.Current.eToolsServer().ExecuteAsync(Model.Entity, Actions.Modify, Options.All, EasyApp.Current.DefaultDatabaseSettingName, "")); } else { throw new Exception(GetLocalizedMessage(Language.ApplicationValidateSaveModified, ((Model.Id == 0) ? GetLocalizedMessage(Language.ApplicationAdd) : GetLocalizedMessage(Language.ApplicationModified)))); } if (data != null) { if (Model.Details.IndexOf(data) != -1) { Model.Details[Model.Details.IndexOf(data)] = data; } else { Model.Details.Add(data); } Model.Entity = data; PostSaveAction(createNew: true); } } else { PostSaveAction(errorTitle: GetLocalizedMessage(Language.ApplicationInformation), errorMessage: GetLocalizedMessage(Language.ApplicationPendingValidations), showMessageError: true, createNew: false, image: MessageBoxImage.Information); } } catch (Exception ex) { PostSaveAction(errorTitle: GetLocalizedMessage(Language.ApplicationError), errorMessage: new BusinessException(ex).GetExceptionMessage(), showMessageError: true, createNew: false, image: MessageBoxImage.Error); } }
public override SECRole FindById(SECRole data) { return(base.FindById(data)); }
public override void FindByIdRules(SECRole data) { base.FindByIdRules(data); }
public override List <SECRole> FindAll(SECRole data, Options option) { return(base.FindAll(data, option)); }
public void InstallLocalData() { Configuration conf = GetConfiguration(); ENDefaultData defaultData = new ENDefaultData(); try { DomainLogic dl = new DomainLogic(conf.DataBaseSettings[0]); if (defaultData.Roles() != null && defaultData.Roles().Count > 0) { foreach (SECRole rol in defaultData.Roles()) { SECRole data = dl.GetSECRoleBLL().Add(rol); if (rol.Users != null && rol.Users.Count > 0) { foreach (SECUser user in rol.Users) { user.Role = data; user.RoleId = data.Id; dl.GetSECUserBLL().Add(user); } } } } //if (defaultData.Languages() != null && defaultData.Languages().Count > 0) //{ // foreach (SECLanguage language in defaultData.Languages()) // { // SECLanguage data = dl.GetSECLanguageDL().Add(language); // } //} //if (defaultData.Types() != null && defaultData.Types().Count > 0) //{ // foreach (SECType type in defaultData.Types()) // { // SECType data = dl.GetSECTypeDL().Add(type); // if (type.TypeValues != null && type.TypeValues.Count > 0) // foreach (SECTypeValue typeValue in type.TypeValues) // { // typeValue.TypeId = type.Id; // SECTypeValue data1 = dl.GetSECTypeValueDL().Add(typeValue); // if (typeValue.TypeValueDetails != null && typeValue.TypeValueDetails.Count > 0) // foreach (SECTypeValueDetail typeValueDetail in typeValue.TypeValueDetails) // { // typeValueDetail.TypeValueId = typeValue.Id; // SECTypeValueDetail data2 = dl.GetSECTypeValueDetailDL().Add(typeValueDetail); // } // } // } //} if (defaultData.Companies() != null && defaultData.Companies().Count > 0) { foreach (SECCompany company in defaultData.Companies()) { SECCompany data = dl.GetSECCompanyBLL().Add(company); } } List <SECCompany> companies = dl.GetSECCompanyBLL().FindAll(new SECCompany { Active = true }, Options.All); List <SECUser> users = dl.GetSECUserBLL().FindAll(new SECUser { Active = true }, Options.All); SECUserCompany useCompany = new SECUserCompany { Active = true, CompanyId = companies[0].Id, UserId = users[0].Id, LastUpdate = DateTime.Now, UpdatedBy = "admin" }; dl.GetSECUserCompanyBLL().Add(useCompany); } catch (Exception e) { throw new BusinessException(e).GetFaultException(); } }