Пример #1
0
        private void Trans_DataValid(object sender, DataValidEventArgs e)
        {
            if (DataValid == null)
            {
#if TroposDesktop || TroposWebService
                using (Transactions trans = new Transactions())
                {
#else
                using (TDK.Common.Helper.Transactions trans = new TDK.Common.Helper.Transactions())
                {
#endif
                    trans.Reply(e.TransactionKey, TroposConfirmationResponse.No);
                }
                throw new InvalidOperationException("DataValid event unhandled");
            }
            else
            {
                DataValid(this, e);
            }
        }
Пример #2
0
        public bool Execute(ExecuteMode mode)
        {
            string         action = "SLDY";
            TransactionDTO SLDY   = getDTO(action);

#if TroposDesktop || TroposWebService
            using (Transactions trans = new Transactions())
            {
#else
            using (TDK.Common.Helper.Transactions trans = new TDK.Common.Helper.Transactions())
            {
#endif
                trans.DataValid += Trans_DataValid;

                trans.AddTransaction(SLDY);

                _results = trans.ExecuteTransaction(out _errors, mode);

                if (Results.Count > 0)
                {
                    //Use reflection to populate each property with the transaction results
                    Dictionary <string, object> f = Results[0].Fields;
                    _ActionFields = new Dictionary <string, string>();
                    foreach (string key in f.Keys)
                    {
                        string property = key.Replace("$", "_").Replace("-", "_");
                        if (this.GetType().GetProperty(property) != null)
                        {
                            this.GetType().GetProperty(property).SetValue(this, f[key], null);
                        }

                        if (key.StartsWith("i", System.StringComparison.Ordinal) || key.StartsWith("v", System.StringComparison.Ordinal))
                        {
                            _ActionFields.Add(key, f[key].ToString());
                        }
                    }
                }
            }

            if (_results[0].ScrollLines.Rows.Count > 0)
            {
                _ScrollLines = new Collection <string>();
                foreach (DataRow Row in _results[0].ScrollLines.Rows)
                {
                    ScrollLines.Add(Row["ScrollLine"].ToString());
                }
            }
#if TroposWebService
            this.WaitefReturn = _results[0].WaitefReturn;
#endif

            int nonErrors = 0;
            if (_errors.Count > 0)
            {
                //Count the non-errors
                foreach (TransactionError te in _errors)
                {
                    if (te.Severity == TroposErrorSeverity.Severe ||
                        te.Severity == TroposErrorSeverity.Validation)
                    {
                        break;
                    }
                    else
                    {
                        nonErrors++;
                    }
                }
            }
            //Return true if no errors or all the errors are not severe or validation (warnings, none, informational)
            return(_errors.Count == nonErrors);
        }