Esempio n. 1
0
        private void TransactionCallback(Transaction trans)
        {
            switch (trans.Result)
            {
                case  TransactionResult.Fail:
                    {
                        var reqPrms = trans.RequestParams.Clone() as RequestParams;
                        var resPrms = trans.ResponseParams.Clone() as ResponseParams;

                        UseOneAttempt();
                        StartNewTransaction(reqPrms, resPrms);
                    }
                    break;
                case TransactionResult.Success:
                    {
                        if (CollectCookie)
                        {
                            SaveCookies(trans.Responce.ResponseUri, trans.Responce.Cookies);
                        }

                        if (trans.ResponseParams.AllowRedirect)
                        {
                            Uri redirect = null;
                            if (CheckRedirect(trans.Responce, ref redirect))
                            {
                                RedirectWithCookie(trans, redirect);
                            }
                        }
                    }
                    break;
                default:
                    SessionCallback();
                    break;
            }
        }
Esempio n. 2
0
        private void RedirectWithCookie(Transaction trans, Uri redirect)
        {
            var reqPrms = trans.RequestParams.Clone() as RequestParams;
            reqPrms.Uri = redirect;
            reqPrms.Cookie = trans.Responce.Cookies;

            var resPrms = trans.ResponseParams.Clone() as ResponseParams;

            StartNewTransaction(reqPrms, resPrms);
        }
Esempio n. 3
0
        private void StartNewTransaction(RequestParams reqPrmsPattern, ResponseParams resPrmsPattern)
        {
            Transaction tr = new Transaction(reqPrmsPattern, resPrmsPattern, TransactionCallback);
            Transactions.Add(tr);

            if (Attempts > 0)
            {
                tr.Begin();
            }
            else
            {
                SessionCallback();
            }
        }