Esempio n. 1
0
 protected abstract int OnResponseMessage(string ticket, string responseXml, HResult hResult);
Esempio n. 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);
        }
Esempio n. 3
0
 protected virtual string OnConnectionError(string ticket, HResult hResult)
 {
     return("done");
 }
Esempio n. 4
0
 protected virtual bool OnRetryConnection(DbContext db, EfParaquickSession efSession, HResult hResult, out string companyFilePath)
 {
     //default behavior is to not retry
     //but implmentations may want to instruct the webconnector to try again, optionally with another file
     companyFilePath = null;
     return(false);
 }