Ejemplo n.º 1
0
 protected void EnableControl(Control control, CRUDAction action)
 {
     if (!((control is GroupBox) || (control is Panel)))
     {
         control.Enabled = ((action == CRUDAction.Create) || (action == CRUDAction.Update));
     }
 }
Ejemplo n.º 2
0
        public void ShowCRUDForm(CRUDAction action, Persistent persistent)
        {
            SetBusy();
            ErrorMessages msgError = new ErrorMessages();

            if (crudForm == null)
            {
                lastAction = action;
                if (!CRUDActionAllowed(action, persistent, msgError))
                {
                    MessageBox.Show(msgError.GetAllMessages(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                CreateCRUDForm();

                businessLogic.Refresh(persistent);
                if (crudForm is CRUDForm)
                {
                    (crudForm as CRUDForm).Open(action, persistent);
                }
            }
            CRUDSuccedeed = false;
            crudForm.Show();
            crudForm.BringToFront();
            ClearBusy();
        }
Ejemplo n.º 3
0
        protected virtual bool PersistCRUD(CRUDAction action, Persistent persistentObject, ErrorMessages messages)
        {
            bool result = true;

            SetBusy();
            try {
                switch (action)
                {
                case CRUDAction.Create: result = businessLogic.Save(persistentObject); break;

                case CRUDAction.Retrieve: break;

                case CRUDAction.Update: result = businessLogic.Update(persistentObject); break;

                case CRUDAction.Delete: result = businessLogic.Delete(persistentObject); break;
                }
            }
            catch (Exception ex) {
                messages.Add(ex.Message);
                result = false;
            }
            if (!result && (messages.Count() == 0))
            {
                messages.Add("Couldn't perform operation.Uknown error");
            }
            ClearBusy();
            return(result);
        }
Ejemplo n.º 4
0
 protected override bool CRUDActionDone(ICRUDForm form, CRUDAction action, Persistent persistentObject)
 {
     SetBusy();
     CRUDSuccedeed = base.CRUDActionDone(form, action, persistentObject);
     ClearBusy();
     return(CRUDSuccedeed);
 }
Ejemplo n.º 5
0
 public void Open(CRUDAction action, Persistent persistentParent, Persistent persistent)
 {
     this.persistentParent = persistentParent;
     if ((action == CRUDAction.Update) && (persistent.Id == 0))
     {
         persistentCopy = persistent.Clone();
     }
     this.Open(action, persistent);
 }
Ejemplo n.º 6
0
        public void ShowCRUDForm()
        {
            SetBusy();
            CRUDAction action     = CRUDAction.Create;
            Persistent persistent = businessLogic.GetNewInstance();

            ShowCRUDForm(action, persistent);
            ClearBusy();
        }
Ejemplo n.º 7
0
        private bool RequireCRUDActionDone(CRUDAction action, Persistent persistent)
        {
            bool result = false;

            if (CRUDActionDone != null)
            {
                result = CRUDActionDone(this, action, persistent);
            }
            return(result);
        }
Ejemplo n.º 8
0
 public bool HavePermissions(Modules module, CRUDAction action)
 {
     if ((module == null) || (isSuperUser))
     {
         return(true);
     }
     else
     {
         return(usuarioActual.UserGroup.FunctionsList.Contains(new CRUDFunctions(module, action)));
     }
 }
Ejemplo n.º 9
0
        protected virtual bool CRUDActionAllowed(CRUDAction action, Persistent persistentParent, Persistent persistent, ErrorMessages messages)
        {
            SetBusy();
            bool result = CRUDActionAllowed(action, persistent, messages);

            if ((action == CRUDAction.Create) && !businessLogic.CreateAllowed(persistentParent, messages))
            {
                result = false;
            }
            ClearBusy();
            return(result);
        }
Ejemplo n.º 10
0
 protected virtual void RefreshGridAfterCRUD(CRUDAction action)
 {
     SetBusy();
     if ((action == CRUDAction.Create) || (action == CRUDAction.Delete))
     {
         ReloadGrid();
     }
     else if (action == CRUDAction.Update)
     {
         RefreshGrid();
     }
     ClearBusy();
 }
Ejemplo n.º 11
0
            public void Enable(Control control, CRUDAction action)
            {
                if (control.Controls.Count > 0)
                {
                    control.Enabled = true;
                }

                foreach (Control childControl in control.Controls)
                {
                    EnableControl(childControl, action);
                    Enable(childControl, action);
                }
            }
Ejemplo n.º 12
0
        public static async Task UpdateSearchIndex <T>(T entityToUpdate, CRUDAction action) where T : Entity, new()
        {
            if (IsElasticUsed)
            {
                if (entityToUpdate is IElasticSearcheable searchable)
                {
                    var indexObject = searchable.GetIndexObject();
                    if (indexObject != null)
                    {
                        var targetType = typeof(T).Name.ToLower();
                        try
                        {
                            StringResponse response;
                            switch (action)
                            {
                            case CRUDAction.Create:
                            {
                                indexObject.CreatedAt = DateTime.Now;
                                response = await _lowlevelClient.IndexAsync <StringResponse>(targetType, targetType,
                                                                                             indexObject.Id, PostData.Serializable(indexObject));
                            }
                            break;

                            case CRUDAction.Update:
                            {
                                indexObject.UpdatedAt = DateTime.Now;
                                response =
                                    await _lowlevelClient.IndexPutAsync <StringResponse>(targetType, targetType,
                                                                                         indexObject.Id, PostData.Serializable(indexObject));

                                break;
                            }

                            case CRUDAction.Delete:
                            {
                                response =
                                    await _lowlevelClient.DeleteAsync <StringResponse>(targetType, targetType,
                                                                                       indexObject.Id);

                                break;
                            }
                            }
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }
            }
        }
Ejemplo n.º 13
0
        public void Open(CRUDAction action, Persistent persistent)
        {
            this.action = action;
            Persistent  = persistent;

            refreshingControls = true;
            RefreshControls();

            Show();
            RequireLoadLayout();

            FillControls();
            refreshingControls = false;
            EnableControls();
        }
Ejemplo n.º 14
0
 public void Enable(Form form, CRUDAction action)
 {
     foreach (Control control in form.Controls)
     {
         EnableControl(control, action);
         Enable(control, action);
     }
     if ((form.AcceptButton != null) && (form.AcceptButton is Control))
     {
         ((Control)form.AcceptButton).Enabled = true;
     }
     if ((form.CancelButton != null) && (form.CancelButton is Control))
     {
         ((Control)form.CancelButton).Enabled = (action != CRUDAction.Retrieve);
     }
 }
Ejemplo n.º 15
0
        protected virtual bool CRUDActionDone(ICRUDForm form, CRUDAction action, Persistent persistentObject)
        {
            SetBusy();
            bool result = ValidateCRUD(action, persistentObject, form.ErrorMessages);

            if (result)
            {
                if (PersistOnCRUDDone)
                {
                    result = PersistCRUD(action, persistentObject, form.ErrorMessages);
                }
                if (result)
                {
                    RefreshGridAfterCRUD(action);
                }
            }
            ClearBusy();
            return(result);
        }
Ejemplo n.º 16
0
        protected virtual bool ValidateCRUD(CRUDAction action, Persistent persistentObject, ErrorMessages messages)
        {
            SetBusy();
            bool result = true;

            if ((action == CRUDAction.Create) || (action == CRUDAction.Update))
            {
                if (businessLogic.RequiredFieldsValidator(persistentObject, messages))
                {
                    if (!businessLogic.BusinessValidator(persistentObject, messages))
                    {
                        result = false;
                    }
                }
                else
                {
                    result = false;
                }
            }
            ClearBusy();
            return(result);
        }
Ejemplo n.º 17
0
        protected virtual bool CRUDActionAllowed(CRUDAction action, Persistent persistent, ErrorMessages messages)
        {
            SetBusy();
            bool result = true;

            switch (action)
            {
            case CRUDAction.Create:
                if (!businessLogic.CreateAllowed(messages))
                {
                    result = false;
                }
                break;

            case CRUDAction.Delete:
                if (!businessLogic.DeleteAllowed(persistent, messages))
                {
                    result = false;
                }
                break;

            case CRUDAction.Retrieve:
                if (!businessLogic.RetrieveAllowed(persistent, messages))
                {
                    result = false;
                }
                break;

            case CRUDAction.Update:
                if (!businessLogic.UpdateAllowed(persistent, messages))
                {
                    result = false;
                }
                break;
            }
            ClearBusy();
            return(result);
        }
        public void Actor_CRUDTest()
        {
            _accountService.Create_CRUDActor("CrudActor");

            IActorRef crudActor = _accountService.GetLocalActor("CrudActor");

            crudActor.Tell(_accountService as ICurdRepo <User>);  //사용할 서비스 지정

            String testNick = "iam actor";

            CRUDAction res = crudActor.Ask(new CRUDAction()
            {
                action = "insert",
                data   = new User()
                {
                    MyId = "actor1", PassWord = "******", NickName = testNick
                },
                isupdate = true
            }).Result as CRUDAction;

            User someUser = _context.Users.FirstOrDefault(u => u.NickName == testNick);

            Assert.Equal(testNick, someUser.NickName);
        }
Ejemplo n.º 19
0
        protected void ShowCRUDForm(CRUDAction action, Persistent persistentParent, Persistent persistent)
        {
            SetBusy();
            if (crudForm == null)
            {
                ErrorMessages msgError = new ErrorMessages();

                if (!CRUDActionAllowed(action, persistentParent, persistent, msgError))
                {
                    MessageBox.Show(msgError.GetAllMessages(), "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                CreateCRUDForm();

                if (crudForm is CRUDChildForm)
                {
                    (crudForm as CRUDChildForm).Open(action, persistentParent, persistent);
                }
            }
            crudForm.Show();
            crudForm.BringToFront();
            ClearBusy();
        }
Ejemplo n.º 20
0
 public bool IsActionAllowed(CRUDAction action) => allowedActions?.Contains(action) ?? true;
Ejemplo n.º 21
0
 protected Functions CreateCRUDFunction(Modules module, CRUDAction action)
 {
     return(new CRUDFunctions(module, action));
 }
Ejemplo n.º 22
0
 public CRUDFunctions(Modules module, CRUDAction action)
 {
     this.module = module;
     this.action = action;
 }