internal Message AddMessage(EfParaquickMessage efMessage) { Message message = new Message(efMessage); _messages.Add(message); return(message); }
public void Save() { using (var db = ServiceUtils.CreateDbContext()) { EfParaquickSession efSession = new EfParaquickSession(); efSession.CompanyId = CompanyId; efSession.Ticket = Ticket; efSession.CreateDate = CreateDate; efSession.StatusId = (long)SessionStatuses.New; ServiceUtils.TruncateSession(efSession); db.ParaquickSessions.Add(efSession); //add requests foreach (var msgSet in _messageSets.OrderBy(ms => ms.Sequence)) { foreach (var msg in msgSet.Messages.OrderBy(r => r.Sequence)) { if (msg.RqMsg != null) { string rqTypeName = msg.RqMsg.GetType().Name; var efMessageType = (from mt in db.ParaquickMessageTypes where mt.RequestTypeName == rqTypeName select mt).FirstOrDefault(); if (efMessageType != null) { EfParaquickMessage efMessage = new EfParaquickMessage(); efMessage.Session = efSession; efMessage.MessageSetSequence = msgSet.Sequence; efMessage.MessageSequence = msg.Sequence; efMessage.ApplicationEntityId = msg.ApplicationEntityId; efMessage.RequestId = msg.RequestId; efMessage.RequestDate = msg.RequestDate; efMessage.MessageType = efMessageType; efMessage.RequestXml = msg.RqMsg.Serialize(); ServiceUtils.TruncateMessage(efMessage); db.ParaquickMessages.Add(efMessage); } else { throw new InvalidOperationException($"RqMsg type not found ({rqTypeName})"); } } else { throw new InvalidOperationException("RqMsg must have a value"); } } } db.SaveChanges(); //refresh stuff Id = efSession.Id; LoadMessageSets(db, efSession); } }
internal Message(EfParaquickMessage efMessage) { Id = efMessage.Id; Sequence = efMessage.MessageSequence; ApplicationEntityId = efMessage.ApplicationEntityId; RequestDate = efMessage.RequestDate; RqMsg = (IRqMsg)Msg.Deserialize(efMessage.MessageType.RequestTypeName, efMessage.RequestXml); RequestId = RqMsg.requestID; }
internal static void RequestError(DbContext db, EfParaquickMessage efMessage, string errorMessage) { //update message with non-Qb (application defined) error efMessage.ResponseDate = DateTime.Now; efMessage.StatusCode = "-1"; efMessage.StatusMessage = $"Request Error [{errorMessage}]"; TruncateMessage(efMessage); db.SaveChanges(); }
internal static void Request(DbContext db, EfParaquickMessage efMessage, IRqMsg rqMsg) { //re-serialize efMessage.RequestXml = rqMsg.Serialize(); //truncate TruncateMessage(efMessage); //save db.SaveChanges(); }
internal static void Response(DbContext db, EfParaquickMessage efMessage, IRsMsg rsMsg) { //update message with response efMessage.ResponseDate = DateTime.Now; efMessage.ResponseXml = rsMsg.Serialize(); efMessage.StatusCode = rsMsg.statusCode; efMessage.StatusSeverity = rsMsg.statusSeverity; efMessage.StatusMessage = rsMsg.statusMessage; TruncateMessage(efMessage); db.SaveChanges(); }
public MessageSet(EfParaquickMessage efMessage) { Sequence = efMessage.MessageSetSequence; }
protected void ResponseError(DbContext db, EfParaquickSession efSession, EfParaquickMessage efMessage, string errorMessage) { //error message is already in messages table OnResponseError(db, efSession, efMessage, errorMessage); }
protected virtual void OnResponseError(DbContext db, EfParaquickSession efSession, EfParaquickMessage efMessage, string errorMessage) { }
protected void RequestError(DbContext db, EfParaquickSession efSession, EfParaquickMessage efMessage, string errorMessage) { ServiceUtils.RequestError(db, efMessage, errorMessage); OnRequestError(db, efSession, efMessage, errorMessage); }
protected virtual void OnResponse(DbContext db, EfParaquickMessage efMessage, IRsMsg rsMsg) { }
protected virtual string OnRequest(DbContext db, EfParaquickMessage efMessage, IRqMsg rqMsg) { //nothing wrong, proceed return(null); }
public static void TruncateMessage(EfParaquickMessage efMessage) { DataAnnotations.ObjectTruncator.Truncate(efMessage); }