Beispiel #1
0
        public bool SetSecure(Subject s)
        {
            try
            {
                ISecureContextData secure = Access <ISecureContextData>();
                List <string>      v      = new List <string>();
                string[]           names  = s.ToItemNameArray();
                object[]           values = s.ToItemValueArray();
                object             reasons;
                string             decision = "accept", appSignature = string.Empty;
                int  transaction;
                bool noContinue = true, disconnect = false;

                transaction = _ContextManager.StartContextChanges(_ParticipantCoupon);
                for (int i = 0; i < names.Length; i++)
                {
                    v.Add(values[i].ToString());
                }

                appSignature = _ParticipantCoupon.ToString() + string.Join("", names) +
                               string.Join("", v.ToArray()) + transaction.ToString();
                appSignature = CreateSignature(appSignature);
                secure.SetItemValues(_ParticipantCoupon, names, values, transaction, appSignature);
                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 (decision == "accept")
                {
                }

                if (disconnect)
                {
                    Leave();
                }
            }
            catch (Exception e)
            {
                Messager.ShowError(null, e);
                return(false);
            }
            return(true);
        }