Exemplo n.º 1
0
        public void Set(Subject subject)
        {
            try
            {
                IContextData data       = Access <IContextData>();
                bool         noContinue = true;
                object       reasons;
                string       decision   = "accept";
                bool         disconnect = false;
                int          transaction;

                transaction = _ContextManager.StartContextChanges(_ParticipantCoupon);
                data.SetItemValues(_ParticipantCoupon, subject.ToItemNameArray(), subject.ToItemValueArray(), transaction);
                reasons = _ContextManager.EndContextChanges(transaction, ref noContinue);

                //
                // If any application responded that they cannot apply the change we need to display
                // a dialog that displays the reasons for the problems.
                //
                if ((reasons != null && ((string[])reasons).Length > 0) || noContinue)
                {
                    ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);
                    DialogResult  result;

                    result = pd.ShowDialog();
                    if (noContinue)
                    {
                        decision = "cancel";
                    }
                    if (result == DialogResult.OK)
                    {
                        decision = "accept";
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        decision = "cancel";
                    }
                    else
                    {
                        decision   = "cancel";
                        disconnect = true;
                    }
                }

                _ContextManager.PublishChangesDecision(transaction, decision);
                if (disconnect)
                {
                    Leave();
                }
            }
            catch (Exception e)
            {
                Messager.ShowError(null, e);
            }
        }
Exemplo n.º 2
0
        public void Set(Subject subject)
        {
            if (!IsSecurityAny(subject))
            {
                SetSecure(subject);
                return;
            }

            try
            {
                IContextData data       = Access <IContextData>();
                bool         noContinue = true;
                object       reasons;
                string       decision   = "accept";
                bool         disconnect = false;
                int          transaction;

                _MainForm.Log("=> StartContextChanges({0})", _ParticipantCoupon);
                transaction = _ContextManager.StartContextChanges(_ParticipantCoupon);
                _MainForm.Log("     Received transaction coupon: {0}", transaction);
                _MainForm.Log("=> SetItemValues([{0}],[{1}],{2},{3})", _ParticipantCoupon, string.Join(",", subject.ToItemNameArray()),
                              string.Join(",", Array.ConvertAll <object, string>(subject.ToItemValueArray(), new Converter <object, string>(Convert))), transaction);
                data.SetItemValues(_ParticipantCoupon, subject.ToItemNameArray(), subject.ToItemValueArray(), transaction);
                _MainForm.Log("=> EndContextChanges({0},ref noContinue)", transaction);
                reasons = _ContextManager.EndContextChanges(transaction, ref noContinue);

                //
                // If any application responded that they cannot apply the change we need to display
                // a dialog that displays the reasons for the problems.
                //
                if ((reasons != null && ((string[])reasons).Length > 0) || noContinue)
                {
                    ProblemDialog pd = new ProblemDialog((string[])reasons, noContinue);

                    DialogResult result = pd.ShowDialog();
                    if (noContinue)
                    {
                        decision = "cancel";
                    }
                    if (result == DialogResult.OK)
                    {
                        decision = "accept";
                    }
                    else if (result == DialogResult.Cancel)
                    {
                        decision = "cancel";
                    }
                    else
                    {
                        decision   = "cancel";
                        disconnect = true;
                    }
                }

                _MainForm.Log("=> PublishChangesDecision({0},{1})", transaction, decision);
                _ContextManager.PublishChangesDecision(transaction, decision);
                if (disconnect)
                {
                    Leave();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }