/// <summary> /// BaseFilterControl Constructor /// </summary> /// <param name="BAO">Entity Business Object</param> /// <param name="ValeursFiltre"></param> public BaseFilterControl(IGwinBaseBLO BAO, Dictionary <string, object> ValeursFiltre) { InitializeComponent(); if (GwinApp.isRightToLeft) { this.flowLayoutPanel1.FlowDirection = FlowDirection.RightToLeft; this.groupBoxFiltrage.RightToLeft = RightToLeft.Yes; } else { this.flowLayoutPanel1.FlowDirection = FlowDirection.LeftToRight; this.groupBoxFiltrage.RightToLeft = RightToLeft.No; } this.FilterContainer = this.flowLayoutPanel1; this.BLO = BAO; this.DefaultFilterValues = ValeursFiltre; this.ConfigEntity = ConfigEntity.CreateConfigEntity(this.BLO.TypeEntity); CreatFiltre(); }
public void GwinAppStart() { GwinApp.Start(typeof(ModelContext), typeof(BaseBLO <>), new FormApplication(), null); configEntity = ConfigEntity.CreateConfigEntity(typeof(TaskProject)); Entity = new TaskProject(); entityMiniConfigBLO = GwinBaseBLO <BaseEntity> .CreateBLO_Instance(typeof(TaskProject), typeof(BaseBLO <>)); }
public MissionConvocationFrom(IGwinBaseBLO EtityBLO, BaseEntity entity, Dictionary <string, object> critereRechercheFiltre, bool AutoGenerateField) : base(EtityBLO, entity, critereRechercheFiltre, false) { InitializeComponent(); }
/// <summary> /// Configuration de Contôle /// </summary> /// <param name="Service"></param> /// <param name="propertyInfo">L'objet propertyInfo de la collection de la classe de déclaration</param> /// <param name="DefaultValueList"> /// Liste des objet BaseEntity qui représente la valeur de chaque /// ComboBox de critère de filtrage /// </param> /// <param name="Entity">L'objet qui contient la collection</param> public void Config(IGwinBaseBLO Service, PropertyInfo propertyInfo, List <BaseEntity> DefaultValueList, BaseEntity Entity) { // Paramétres this.Service = Service; this.DefaultValueList = DefaultValueList; this.PropertyInfoOfCollection = propertyInfo; this.Entity = Entity; this.TypeObjetOfCollection = PropertyInfoOfCollection.PropertyType.GetGenericArguments()[0]; this.MetaSelectionCriteria = (SelectionCriteriaAttribute)PropertyInfoOfCollection.GetCustomAttribute(typeof(SelectionCriteriaAttribute)); // Trouver les valeurs par défaut this.CalculatesDefaultValues(); // Création de l'interface this.CreateInterface(); // Affichage des données this.ViewingData(); // Affecter les valeurs par défaut // this.SetDefaullValues(); this.Show_List_Of_Choices(); this.Show_Display_Selected_Entity(); }
public override void ProcessInvocation(IInvocation invocation) { // Create Business Instance IGwinBaseBLO blo = (IGwinBaseBLO)Activator.CreateInstance(invocation.Method.DeclaringType, GwinApp.Instance.TypeDBContext); String EntityReference = blo.ConfigEntity.TypeOfEntity.FullName; if (AttributeExistsOnMethodOrEntity <DoNotPerformPermissionCheck>(invocation, blo.TypeEntity)) { // Run the intercepted method as normal. invocation.Proceed(); return; } // Check autorization if (GwinApp.Instance.user.Reference == nameof(User.Users.Root) || GwinApp.Instance.user.HasAccess(EntityReference, invocation.Method.Name)) { invocation.Proceed(); } else { string msg = String.Format("You d'ont have permission to execute the action {0} in business object {1}", invocation.Method.Name, EntityReference); throw new GwinAccessException(msg); // MessageToUser.AddMessage(MessageToUser.Category.BusinessRule, msg); } }
/// <summary> /// Creating an instance of the Service object from the entity type /// </summary> /// <param name="TypeEntity">the entity type</param> /// <returns></returns> public override IGwinBaseBLO CreateServiceBLOInstanceByTypeEntity(Type TypeEntity) { Type TypeEntityService = typeof(BaseBLO <>).MakeGenericType(TypeEntity); IGwinBaseBLO EntityService = (IGwinBaseBLO)Activator.CreateInstance(TypeEntityService, this.Context); return(EntityService); }
/// <summary> /// Affichage des données dans les ComboBox /// </summary> protected void ViewingData() { // Affichage des données du premiere comboBox // les autres comboBox sont afficher par l'événement ValueChange du ComboBox if (ListeComboBox.Values.Count() <= 0) { return; } ManyToOneField comboBox = ListeComboBox.Values.ElementAt(0); string key = ListeComboBox.Keys.ElementAt(0); IGwinBaseBLO service = this.Service .CreateServiceBLOInstanceByTypeEntity(LsiteTypeObjetCritere[key]); IList ls_source = service.GetAll(); // Add Black Value if requorid if (this.ConfigProperty?.EntryForm?.isDefaultIsEmpty == true || this.ConfigProperty?.Filter?.isDefaultIsEmpty == true) { ls_source.Insert(0, new EmptyEntity()); } // Initalisation avec la valeur par défaux s'il existe if (this.ListeValeursInitiaux != null && this.ListeValeursInitiaux.Keys.Contains(key)) { this.StopEventSelectedIndexChange = true; comboBox.DataSource = ls_source; this.StopEventSelectedIndexChange = false; comboBox.SelectedValue = this.ListeValeursInitiaux[key]; } else { comboBox.DataSource = ls_source; } }
/// <summary> /// Constructor /// </summary> /// <param name="EntityBLO">Business object instance</param> /// <param name="EntryFormInstance">Entry form instance</param> /// <param name="FilterValues">Values of Filter</param> /// <param name="MdiForm">Mdi form instance</param> public ManagerForm( IGwinBaseBLO EntityBLO, BaseEntryForm EntryFormInstance, Dictionary <string, object> FilterValues, Form MdiForm) { InitializeComponent(); managerFormControl = new ManagerFormControl(EntityBLO, EntryFormInstance, null, null, FilterValues, MdiForm); managerFormControl.Dock = DockStyle.Fill; this.Name = EntityBLO.GetType().ToString(); this.Text = EntityBLO.ConfigEntity.ManagementForm?.FormTitle; this.Controls.Add(managerFormControl); // Confirm RightToLeft this.RightToLeft = RightToLeft.Yes; this.RightToLeftLayout = GwinApp.isRightToLeft; // Confib Width and Height if (EntityBLO.ConfigEntity.ManagementForm.Width != 0) { this.Width = EntityBLO.ConfigEntity.ManagementForm.Width; } if (EntityBLO.ConfigEntity.ManagementForm.Height != 0) { this.Height = EntityBLO.ConfigEntity.ManagementForm.Height; } }
public SelectionFilterManager( IGwinBaseBLO Service, ConfigProperty ConfigProperty, Control MainContainner, Size SizeLabel, Size SizeControl, Orientation OrientationFiled, Int64 DefaultValue ) { this.ConfigProperty = ConfigProperty; this.MainContainner = MainContainner; this.SizeLabel = SizeLabel; this.SizeControl = SizeControl; this.OrientationFiled = OrientationFiled; this.Service = Service; this.ListeComboBox = new Dictionary <string, ManyToOneField>(); this.ListeValeursInitiaux = new Dictionary <string, long>(); this.LsiteTypeObjetCritere = new Dictionary <string, Type>(); if (this.ConfigProperty.SelectionCriteria != null) { InitInterface(); } CalculeValeursInitiaux((Int64)DefaultValue); ViewingData(); }
/// <summary> /// Affectation des valeurs par défaut /// </summary> protected void SetDefaullValues() { for (int i = 0; i < ListeComboBox.Count; i++) { ComboBox comboBox = ListeComboBox.Values.ElementAt(i); string key = ListeComboBox.Keys.ElementAt(i); // Valeur par défaut if (ListeValeursCritere.ContainsKey(key) && ListeValeursCritere[key].Id != 0) { comboBox.CreateControl(); comboBox.SelectedValue = ListeValeursCritere[key].Id; // Actualisation de ComboBoxs suivant IGwinBaseBLO EntityPereService = this.Service .CreateServiceBLOInstanceByTypeEntity(LsiteTypeObjetCritere[key]); BaseEntity EntityPere = EntityPereService.GetBaseEntityByID(ListeValeursCritere[key].Id); ComboBox comboBox_suivant = ListeComboBox.Values.ElementAt(i + 1); string key_suivant = ListeComboBox.Keys.ElementAt(i + 1); PropertyInfo PropertyFils = EntityPere.GetType() .GetProperties() .Where(p => p.Name == key_suivant + "s") .SingleOrDefault(); if (PropertyFils == null) { throw new PropertyDoesNotExistException("La classe " + EntityPere.GetType().Name + " ne contient pas la propriété " + key_suivant + "s"); } comboBox_suivant.DataSource = PropertyFils.GetValue(EntityPere); } } }
/// <summary> /// Creating an instance of the Service object from the entity type and Context /// </summary> /// <param name="TypeEntity">the entity type</param> /// <param name="context">the context</param> /// <returns></returns> public virtual IGwinBaseBLO CreateServiceBLOInstanceByTypeEntityAndContext(Type TypeEntity, DbContext context) { Type TypeEntityService = typeof(BaseBLO <>).MakeGenericType(TypeEntity); IGwinBaseBLO EntityService = (IGwinBaseBLO)Activator.CreateInstance(TypeEntityService, context); return(EntityService); }
public override object ConvertValue(BaseFieldTraitementParam param) { List <BaseEntity> ls = null; ls = param.BaseField.Value as List <BaseEntity>; IGwinBaseBLO ServicesEntity = param.EntityBLO .CreateServiceBLOInstanceByTypeEntityAndContext( param.ConfigProperty.PropertyInfo.PropertyType.GetGenericArguments()[0], param.EntityBLO.Context ); Type TypeListeObjetValeur = typeof(List <>).MakeGenericType( param.ConfigProperty.PropertyInfo.PropertyType.GetGenericArguments()[0]); IList ls_valeur = (IList)Activator.CreateInstance(TypeListeObjetValeur); foreach (BaseEntity b in ls) { var entity_valeur = ServicesEntity.GetBaseEntityByID(b.Id); ls_valeur.Add(entity_valeur); } return(ls_valeur); }
public InputCollectionControle(IGwinBaseBLO Service, PropertyInfo propertyInfo, List <BaseEntity> DefaultValueList, BaseEntity Entity) { InitializeComponent(); this.Config(Service, propertyInfo, DefaultValueList, Entity); }
public ManyToOneField(IGwinBaseBLO Service, PropertyInfo propertyInfo, Control MainContainner, Orientation OrientationFiled, Size SizeLabel, Size SizeControl, Int64 DefaultFiltreValues, ConfigEntity ConfigEntity, BaseEntity EntityInstance) : this(Service, null, propertyInfo, MainContainner, OrientationFiled, SizeLabel, SizeControl, DefaultFiltreValues, ConfigEntity, EntityInstance) { }
/// <summary> /// Create an Show ManagerForm /// </summary> /// <param name="EntityType">Type of Entity</param> /// <returns></returns> public ManagerForm ShowManagerForm(Type EntityType) { IGwinBaseBLO baseRepository = GwinBaseBLO <BaseEntity> .CreateBLO_Instance(EntityType, GwinApp.Instance.TypeBaseBLO); ManagerForm form = new ManagerForm(baseRepository, null, null, (Form)this.MdiForm); this.ShwoForm(form); return(form); }
public BaseEntityTabControl(IGwinBaseBLO Service, BaseFilterControl BaseFilterControl, Form MdiParent, BaseEntryForm Formulaire) { InitializeComponent(); this.Service = Service; this.BaseFilterControl = BaseFilterControl; this.MdiParent = MdiParent; this.Formulaire = Formulaire; InitPropertyListDataGrid(); }
public override object ConvertValue(BaseFieldTraitementParam param) { IGwinBaseBLO ServicesEntity = param .EntityBLO .CreateServiceBLOInstanceByTypeEntity(param.ConfigProperty.PropertyInfo.PropertyType); BaseEntity ManyToOneEntity = ServicesEntity.GetBaseEntityByID(Convert.ToInt64(param.BaseField.Value)); return(ManyToOneEntity); }
/// <summary> /// Creating an instance of the BLO /// Without Proxy /// </summary> /// <param name="TypeEntity">The entity type</param> /// <param name="TypeBaseBLO">Type of Base BLO object</param> /// <returns>BLO Instance</returns> public static IGwinBaseBLO CreateBLO_Instance_WithoutProxy(Type TypeEntity, Type TypeBaseBLO) { // Load TypeEntityBLO Type TypeEntityBLO = Detemine_Type_EntityBLO(TypeEntity, TypeBaseBLO); IGwinBaseBLO EntityBLO = (IGwinBaseBLO)Activator.CreateInstance(TypeEntityBLO); return(EntityBLO); }
/// <summary> /// Create Instance of Business Logic Object of Entity Params /// It instance BLO Class if exist /// in else case it use generic BaseBLO /// </summary> /// <param name="TypeEntity">The entity type</param> /// <param name="TypeBaseBLO">Type of Base BLO object</param> /// <returns>BLO Instance</returns> public static IGwinBaseBLO Create_Instance(Type TypeBaseBLO) { // Load TypeEntityBLO Type TypeEntityBLO = Detemine_Type_EntityBLO(typeof(T), TypeBaseBLO); // EntityBLO = (IGwinBaseBLO)Activator.CreateInstance(TypeEntityBLO); IGwinBaseBLO EntityBLO = DependencyResolver.For(TypeEntityBLO) as IGwinBaseBLO; return(EntityBLO); }
/// <summary> /// Calcule des valeurs initiaux /// </summary> private void CalculeValeursInitiaux(Int64 Value) { if (Value == 0) { return; } /// Le ComboBox précédent prend les valeurs de l'Entite actuel de comboBox /// car l'entité actuel doit avoir une prorpiété de type type de l'entityé précédent /// Le nom de cette propiété égale Nom d'entité /// si cette propiété n'existe pas la méthode lance une exception /// // Initialisation de la liste des valeurs par défaux if (ListeValeursInitiaux.Count() < this.LsiteTypeObjetCritere.Count()) { for (int i = 0; i < this.LsiteTypeObjetCritere.Count(); i++) { ListeValeursInitiaux.Add(ListeComboBox.Keys.ElementAt(i), 0); } } // Init la de la vlaeur de comboBox Actuel if (ListeValeursInitiaux.Count > 0) { ListeValeursInitiaux[ListeValeursInitiaux.Last().Key] = Value; } IGwinBaseBLO curentService = this.Service .CreateServiceBLOInstanceByTypeEntity(LsiteTypeObjetCritere[ListeValeursInitiaux.Last().Key]); BaseEntity curentEntity = curentService.GetBaseEntityByID(Value); BaseEntity previousEntity = null; for (int i = this.LsiteTypeObjetCritere.Count() - 1; i >= 1; i--) { string curentKey = LsiteTypeObjetCritere.Keys.ElementAt(i); string Previouskey = ListeComboBox.Keys.ElementAt(i - 1); PropertyInfo PropertyPrevious = curentEntity.GetType() .GetProperties() .Where(p => p.Name == Previouskey) .SingleOrDefault(); if (PropertyPrevious == null) { throw new PropertyNotExistInEntityException(); } // Affectation des valeurs au ComboBox précédent previousEntity = PropertyPrevious.GetValue(curentEntity) as BaseEntity; ListeValeursInitiaux[Previouskey] = previousEntity.Id; curentEntity = previousEntity; } }
public ExportExcelDataAction(IGwinBaseBLO EntityBLO, Dictionary <string, object> FilterValues) { this.EntityBLO = EntityBLO; this.FilterValues = FilterValues; this.Text = "Export to Excel"; this.Width = 120; this.Height = 45; this.Click += ExportExcelDataAction_Click; }
public void ApplyBusinessRolesAfterValuesChangedTest() { TaskProject EntityMiniConfig = new TaskProject(); EntityMiniConfig.Title.Current = "Hello"; // Create entityMinConfigBLO dynamicly IGwinBaseBLO entityMinConfigBLO = GwinBaseBLO <BaseEntity> .CreateBLO_Instance(typeof(TaskProject), typeof(BaseBLO <>)); entityMinConfigBLO.ApplyBusinessRolesAfterValuesChanged(nameof(TaskProject.Title), EntityMiniConfig); Assert.AreEqual(EntityMiniConfig.Title.Current, "HELLO"); }
public void Add_BaseEntryFormTest() { // Test All EntryForm using (ModelContext db = new ModelContext()) { foreach (var item in new GwinEntitiesManager().GetAll_Entities_Type()) { IGwinBaseBLO EntityBLO = GwinBaseBLO <BaseEntity> .CreateBLO_Instance(item, GwinApp.Instance.TypeBaseBLO); BaseEntryForm baseEntryForm = new BaseEntryForm(EntityBLO); } } }
/// <summary> /// Affichage des données dans les ComboBox /// </summary> protected void ViewingData() { // Affichage des données du premiere comboBox // les autres comboBox sont afficher par l'événement ValueChange du ComboBox if (ListeComboBox.Values.Count() <= 0) { return; } ComboBox comboBox = ListeComboBox.Values.ElementAt(0); string key = ListeComboBox.Keys.ElementAt(0); IGwinBaseBLO service = this.Service .CreateServiceBLOInstanceByTypeEntity(LsiteTypeObjetCritere[key]); comboBox.DataSource = service.GetAll(); }
/// <summary> /// Create Entry form instance /// </summary> /// <param name="EtityBLO"></param> /// <param name="entity"></param> /// <param name="critereRechercheFiltre"></param> /// <param name="AutoGenerateField"></param> public BaseEntryForm( IGwinBaseBLO EtityBLO, BaseEntity entity, Dictionary <string, object> critereRechercheFiltre, bool AutoGenerateField) { InitializeComponent(); errorProvider.RightToLeft = GwinApp.isRightToLeft; if (System.ComponentModel.LicenseManager.UsageMode != System.ComponentModel.LicenseUsageMode.Designtime) { CheckPramIsNull.CheckParam_is_NotNull(EtityBLO, this, nameof(EtityBLO)); // Init Variables this.EntityBLO = EtityBLO; this.Entity = entity; this.FilterValues = critereRechercheFiltre; this.AutoGenerateField = AutoGenerateField; this.ConfigEntity = ConfigEntity.CreateConfigEntity(this.EntityBLO.TypeEntity); // Default values this.ConteneurFormulaire = FlowLayoutContainer; this.isStepInitializingValues = false; this.MessageValidation = new MessageValidation(errorProvider); this.Fields = new Dictionary <string, BaseField>(); this.GroupsBoxes = new Dictionary <string, GroupBox>(); // Create PLO Instance if PLO exist if (this.EntityPLO == null && this.ConfigEntity.PresentationLogic != null) { this.EntityPLO = (IGwinPLO)Activator.CreateInstance(this.ConfigEntity.PresentationLogic.TypePLO); } // Create or Config Entity Instance if (this.EntityBLO != null && this.Entity == null) { this.Entity = (BaseEntity)EtityBLO.CreateEntityInstance(); } if ((this.Entity == null || this.Entity.Id == 0) && this.FilterValues != null) { this.InitialisationEntityParCritereRechercheFiltre(); } // Create Field in Form this.CreateFieldIfNotGenerated(); } }
/// <summary> /// Constructor : Create Application Menu /// </summary> /// <param name="FormMenu">MDI Form that cotain Menu of Application</param> public CreateApplicationMenu(IApplicationMenu FormMenu) { // Params this.MdiFormWithMenu = FormMenu; this.menuStrip = FormMenu.getMenuStrip(); // MenuStruct Instance MenuItems = new Dictionary <string, Type>(); MenuStruct = new MenuStruct(); // Properties this.ShowManagementForm = new CreateAndShowManagerFormHelper(GwinApp.Instance.TypeDBContext, FormMenu); this.MenuItemApplicationService = GwinBaseBLO <BaseEntity> .CreateBLO_Instance(typeof(MenuItemApplication), GwinApp.Instance.TypeBaseBLO); // Create Menu this.CalculateMenuItems(); this.ShowMenuItems(); }
/// <summary> /// Edit the collection ManyToMany_Creation /// Create Instead Manager form of ManyToMany_Creation collection /// </summary> private void DataGridControl_ManyToMany_Creation(object sender, EventArgs e) { // Init Params BaseEntity obj = this.DataGridControl_Instance.SelectedEntity; PropertyInfo propertyInfo = this.DataGridControl_Instance.SelectedProperty; // Selected the Tab id allready in edition if (tabControl_MainManager.TabPages.ContainsKey(obj + propertyInfo.Name)) { tabControl_MainManager.SelectedTab = tabControl_MainManager.TabPages[obj + propertyInfo.Name]; return; } // Create Business object of the collection Type type_objet_of_collection = propertyInfo.PropertyType.GetGenericArguments()[0]; IGwinBaseBLO service_objet_of_collection = this.BLO_Instance.CreateServiceBLOInstanceByTypeEntity(type_objet_of_collection); // Default filter values Dictionary <string, object> ValeursFiltre = new Dictionary <string, object>(); ValeursFiltre[propertyInfo.DeclaringType.Name] = obj.Id; // Create ManagerFormControl Instance ManagerFormControl form = new ManagerFormControl(service_objet_of_collection, ValeursFiltre, this.FrmParent); ConfigEntity configEntity = ConfigEntity.CreateConfigEntity(propertyInfo.DeclaringType); string formTitle = Glossary.Update + " : "; formTitle += new ConfigProperty(propertyInfo, configEntity).DisplayProperty.Title; // Entity formTitle += " " + Glossary.For + " "; formTitle += obj; form.ChangeTabGridTitle(formTitle); // Not Show In RunTume Mode //if (!Debugger.IsAttached) form.ShowFilter(false); // Insertion de la gestion à l'interface this.AddMenyToMeny_Creation_to_TabPage(form, propertyInfo, obj); }
/// <summary> /// Create EntityDataGrid Instance /// </summary> /// <param name="EtityBLO">Business object instance</param> /// <param name="FilterValues">Filter values</param> public GwinDataGridComponent(IGwinBaseBLO EtityBLO, Dictionary <string, object> FilterValues) { CheckPramIsNull.CheckParam_is_NotNull(EtityBLO, this, nameof(EtityBLO)); InitializeComponent(); // Init Params values this.EntityBLO = EtityBLO; this.FilterValues = FilterValues; // Init ShownEntityProperties var requete = from i in EntityBLO.TypeEntity.GetProperties() where i.GetCustomAttribute(typeof(DataGridAttribute)) != null orderby((DataGridAttribute)i.GetCustomAttribute(typeof(DataGridAttribute))).Ordre select i; this.ShownEntityProperties = requete.ToList <PropertyInfo>(); _Insert_Column_In_DataGrid(); }
/// <summary> /// Afficher la liste de choix /// </summary> private void Show_List_Of_Choices() { IGwinBaseBLO service = this.Service.CreateServiceBLOInstanceByTypeEntity(this.TypeObjetOfCollection); // this.listBoxChoices.DataSource = service.GetAll(); if (DefaultValueList == null) { return; } for (int i = 0; i < this.listBoxChoices.Items.Count; i++) { BaseEntity item = (BaseEntity)this.listBoxChoices.Items[i]; if (this.DefaultValueList.Contains(item)) { this.listBoxChoices.SelectedItems.Add(item); } } }
/// <summary> /// Check if User Exist /// </summary> /// <param name="login">Login </param> /// <param name="password">Password </param> /// <returns>Existance User or Null</returns> private User CheckUser(string login, string password) { // Create UserBLO Instance IGwinBaseBLO userBLO = GwinBaseBLO <User> .CreateBLO_Instance(typeof(User), GwinApp.Instance.TypeBaseBLO); Dictionary <string, object> rechercheInfos = new Dictionary <string, object>(); rechercheInfos.Add(nameof(User.Login), "=" + login); rechercheInfos.Add(nameof(User.Password), "=" + password); List <object> resultat = userBLO.Recherche(rechercheInfos); if (resultat != null && resultat.Count > 0) { return(resultat[0] as User); } else { return(null); } }