Пример #1
0
        /// <summary>
        /// Perform several API calls and provide default handling of exceptions.
        /// </summary>
        /// <param name="op">Operation with API calls.</param>
        public static void HandleApiExceptions(SaveApiCall op)
        {
            Stopwatch watch = new Stopwatch();

            watch.Start();

            EventArgsOperationResult eventArgs = new EventArgsOperationResult();

            try
            {
                op();
                eventArgs.Result = new PsaException(Result.Success, "");
            }
            catch (PsaException ex)
            {
                eventArgs.Result = ex;
            }
            catch (Desko.Mrz.MrzException ex)
            {
                eventArgs.Result = new PsaException(Result.Fail, "MRZ error (" + ex.Result.ToString() + "):" + ex.Message);
            }

            watch.Stop();
            eventArgs.ElapsedMilliseconds = watch.ElapsedMilliseconds;
            if (OnOperationResultAvailable != null)
            {
                OnOperationResultAvailable(null, eventArgs);
            }
        }
Пример #2
0
        public void TestSaveApiCall()
        {
            var sf = new SaveApiCall(new ApiCallData()
            {
                Request      = "requestonbj",
                RequestId    = "11111",
                Response     = "responseobj",
                Comments     = "test strategy",
                StatusCode   = "5500",
                ErrorCode    = "0",
                ErrorMessage = "no errors",
                Url          = "stam"
            });

            sf.Execute();
        }