Ejemplo n.º 1
0
        private void GridViewEntityRules_CalcPreviewText(object sender, DevExpress.XtraGrid.Views.Grid.CalcPreviewTextEventArgs e)
        {
            JarsRule current = e.Row as JarsRule;

            if (current != null)
            {
                e.PreviewText = $"{current.SourceCriteriaString}{Environment.NewLine}{current.TargetCriteriaString}";
            }
        }
Ejemplo n.º 2
0
        public override void OnAddData()
        {
            base.OnAddData();
            //Create a new entityRule record
            ctrl_frEdSourceEntityRule.FilterString = string.Empty;
            ctrl_frEdTargetEntityRule.FilterString = string.Empty;
            JarsRule newOp = defaultBindingSource.AddNew() as JarsRule;

            defaultBindingSource.Position = defaultBindingSource.IndexOf(newOp);
        }
Ejemplo n.º 3
0
        private void ctrl_frEdTargetEntityRule_FilterTextChanged(object sender, DevExpress.XtraEditors.FilterTextChangedEventArgs e)
        {
            JarsRule currentRule = defaultBindingSource.Current as JarsRule;

            if (currentRule != null)
            {
                currentRule.TargetCriteriaString = ctrl_frEdTargetEntityRule.FilterString;
                UpdateRuleSummary();
            }
        }
Ejemplo n.º 4
0
        private void UpdateLinkedBindingSources()
        {
            JarsRule currentRule = defaultBindingSource.Current as JarsRule;

            if (currentRule != null)
            {
                ctrl_frEdSourceEntityRule.FilterString = currentRule.SourceCriteriaString;
                ctrl_frEdTargetEntityRule.FilterString = currentRule.TargetCriteriaString;
                ctrl_frEdSourceEntityRule.Invalidate();
                ctrl_frEdTargetEntityRule.Invalidate();
                UpdateRuleSummary();
            }
        }
Ejemplo n.º 5
0
        public override void OnSaveData()
        {
            try
            {
                this.Validate();
                if (CriteriaHelper.ValidateStringAsFilterCriteria(ctrl_frEdSourceEntityRule.FilterString) &&
                    CriteriaHelper.ValidateStringAsFilterCriteria(ctrl_frEdTargetEntityRule.FilterString, true) &&
                    dxValidator.Validate())
                {
                    JarsRule saveRule = defaultBindingSource.Current as JarsRule;
                    saveRule.SourceCriteriaString = ctrl_frEdSourceEntityRule.FilterString;
                    saveRule.TargetCriteriaString = ctrl_frEdTargetEntityRule.FilterString;

                    StoreJarsRule store = new StoreJarsRule()
                    {
                        Rule = saveRule
                    };

                    JarsRuleResponse response = ServiceClient.Post(store);

                    if (response.ResponseStatus == null)
                    {
                        saveRule = response.Rule;

                        ServiceClient.Post(new JarsRulesNotification
                        {
                            Selector     = SelectorTypes.store,
                            FromUserName = LoggedInUser.UserName,
                            Ids          = new List <int> {
                                response.Rule.Id
                            }
                        });
                    }

                    base.OnSaveData();
                }
            }
            catch (Exception exS)
            {
                OnExceptionEvent(exS);
            }
        }
Ejemplo n.º 6
0
        void OnSaveEntityRule(JarsRule rule)
        {
            StoreJarsRules storeRules = new StoreJarsRules()
            {
                Rules = new List <JarsRule>()
                {
                    rule
                }
            };
            var response = ServiceClient.Post(storeRules);

            if (response.ResponseStatus == null)
            {
                rule = response.Rules.FirstNonDefault();
                ServiceClient.Post(new JarsRulesNotification()
                {
                    Selector     = SelectorTypes.store,
                    FromUserName = Context.LoggedInUser.UserName,
                    Ids          = response.Rules.Select(r => r.Id).ToList()
                });
            }
        }
Ejemplo n.º 7
0
        public override void OnMessageEvent(ServiceStack.ServerEventMessage msg)
        {
            if (msg.Channel != typeof(JarsRule).Name)
            {
                return;
            }

            switch (msg.Selector)
            {
            case SelectorTypes.delete:
                MessageBox.Show($"DELETE - Op:{msg.Op} Selector:{msg.Selector} Target:{msg.Target} Channel:{msg.Channel} EventId:{msg.EventId}");
                break;

            case SelectorTypes.store:
                if (msg.Channel == nameof(JarsRule))
                {
                    JarsRule entityCon = msg.Json.FromJson <JarsRule>();
                    //IEntityRule findCond = ResourceEntityConditionsList.FirstOrDefault(c => c.Id == entityCon.Id);
                    //if (findCond != null)
                    //{
                    //    //replace
                    //    ResourceEntityConditionsList.Remove(findCond);
                    //    ResourceEntityConditionsList.Add(entityCon);
                    //}
                    //else
                    //{
                    //    //add
                    //    ResourceEntityConditionsList.Add(entityCon);
                    //}
                    //update bindings
                    UpdateLinkedBindingSources();
                }
                //MessageBox.Show($"SAVE - Op:{msg.Op} Selector:{msg.Selector} Target:{msg.Target} Channel:{msg.Channel} EventId:{msg.EventId}");
                break;
            }
            base.OnMessageEvent(msg);
        }
Ejemplo n.º 8
0
        public override bool OnDeleteData()
        {
            try
            {
                if (base.OnDeleteData(true))
                {
                    JarsRule delOp = defaultBindingSource.Current as JarsRule;

                    DeleteJarsRules delete = new DeleteJarsRules()
                    {
                        Id = delOp.Id
                    };
                    ServiceClient.Delete(delete);
                    defaultBindingSource.RemoveCurrent();
                    defaultBindingSource.ResetBindings(false);
                }
            }
            catch (Exception exD)
            {
                OnExceptionEvent(exD);
            }
            //call this after the record removal was successful.
            return(base.OnDeleteData());
        }