Пример #1
0
        protected override string OnConnectionError(string ticket, HResult hResult)
        {
            if (ticket != ServiceUtils.ZeroTicket)
            {
                using (var db = ServiceUtils.CreateDbContext())
                {
                    EfParaquickSession efSession = ServiceUtils.FindSession(db, ticket);

                    if (efSession != null)
                    {
                        //log this error
                        SessionError(db, efSession, hResult.Format());

                        //ask the implementation if we should tell the WC to retry
                        string companyFilePath;
                        if (OnRetryConnection(db, efSession, hResult, out companyFilePath))
                        {
                            return(companyFilePath);
                        }
                        else
                        {
                            //if not, we reset the session to "New" and let the user fix it and try again
                            ServiceUtils.Reset(db, efSession);
                        }
                    }
                    else
                    {
                        //note: getLastError will not be called so we log this here
                        Error("Can't find ticket ({ticket}) during connection error");
                    }
                }
            }
            else
            {
                //note: getLastError will not be called so we log this here
                Error("Can't process zeroticket during connection error");
            }

            return("done");
        }
Пример #2
0
        protected override int OnResponseMessage(string ticket, string responseXml, HResult hResult)
        {
            //zerotickets should never be seen here, but if so, they will recur in getLastError and be logged there
            if (ticket != ServiceUtils.ZeroTicket)
            {
                using (var db = ServiceUtils.CreateDbContext())
                {
                    EfParaquickSession efSession = ServiceUtils.FindSession(db, ticket);

                    //bad tickets will recur in getLastError and be logged there
                    if (efSession != null)
                    {
                        //COM error?
                        if (hResult == null)
                        {
                            //deserialize response and process success/error
                            RsMsgSet rsMsgSet = new RsMsgSet();
                            QBXML    qbxml    = rsMsgSet.Deserialize(responseXml);

                            //TODO update paraquick entities based on response type
                            foreach (var rsMsg in rsMsgSet)
                            {
                                var efMessage = efSession.ParaquickMessages.Where(m => m.RequestId == rsMsg.requestID).FirstOrDefault();

                                if (efMessage != null)
                                {
                                    ServiceUtils.Response(db, efMessage, rsMsg);

                                    //allow implementor to do something with response
                                    OnResponse(db, efMessage, rsMsg);

                                    if (rsMsg.statusCode != "0")
                                    {
                                        //TODO stop on errors?
                                        ResponseError(db, efSession, efMessage, rsMsg.statusMessage);
                                    }
                                }
                                else
                                {
                                    //TODO stop on errors?
                                    SessionError(db, efSession, $"Can't find request ({rsMsg.requestID})");
                                }
                            }


                            //TODO StopOnErrors? do we stop on errors here (return -1) or keep going?
                            //report "%" - completed messages/total messages for session
                            int pctComplete = ServiceUtils.CalculatePercentComplete(db, efSession);
                            return(pctComplete);
                        }
                        else
                        {
                            SessionError(db, efSession, $"COM Error {hResult.Format()}");
                        }
                    }
                }
            }

            //error condition
            return(-1);
        }