protected override void OnBackroundExecution() { int currentServerId = serverId; using (IUnitOfWork unitOfWork = unitOfWorkFactory.CreateUnitOfWork(contextSettings)) { if (serverId == 0) { InsertNewServer(unitOfWork); } else { UpdateServer(unitOfWork); } DeleteExpiredServers(unitOfWork); unitOfWork.Commit(); } if (currentServerId != serverId) { ServerDetails serverDetails = new ServerDetails(serverId, queues); ServerRegistrationMessage message = new ServerRegistrationMessage(serverDetails, this); serviceMessageProcessor.SendMessage(message); } }
protected override void OnBackroundException(Exception exception) { serverId = 0; ServerDetails serverDetails = new ServerDetails(serverId, queues); ServerRegistrationMessage message = new ServerRegistrationMessage(serverDetails, this); serviceMessageProcessor.SendMessage(message); base.OnBackroundException(exception); }
public bool HandleMessage(IServiceMessage message) { if (message is ServerRegistrationMessage) { lock (syncObject) { ServerRegistrationMessage serverRegistrationMessage = (ServerRegistrationMessage)message; serverDetails = serverRegistrationMessage.ServerDetails; } return(true); } return(false); }