public override bool CancelTicket(Coupon coupon, string type, string redeemer) { bool status = false; if (dbTicketing.AuthenticateAgentHeader(agentAuthHeader)) { // Move all this into BrokerDB BrokerDB agentDB = new BrokerDB(); if (ProcessAgentDB.ServiceGuid.Equals(redeemer)) { // this ServiceBroker is the redeemer status = agentDB.CancelTicket(coupon, type, redeemer); } else { ProcessAgentInfo target = agentDB.GetProcessAgentInfo(redeemer); if (target != null) { if (target.retired) { throw new Exception("The ProcessAgent is retired"); } if (ProcessAgentDB.ServiceGuid.Equals(target.domainGuid)) { // Its a local domain processAgent ProcessAgentProxy paProxy = new ProcessAgentProxy(); paProxy.AgentAuthHeaderValue = new AgentAuthHeader(); paProxy.AgentAuthHeaderValue.coupon = target.identOut; paProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; paProxy.Url = target.webServiceUrl; status = paProxy.CancelTicket(coupon, type, redeemer); } else { ProcessAgentInfo remoteSB = agentDB.GetProcessAgentInfo(target.domainGuid); if (remoteSB != null) { if (remoteSB.retired) { throw new Exception("The ProcessAgent is retired"); } // Its from a known domain ProcessAgentProxy sbProxy = new ProcessAgentProxy(); sbProxy.AgentAuthHeaderValue = new AgentAuthHeader(); sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut; sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; sbProxy.Url = remoteSB.webServiceUrl; status = sbProxy.CancelTicket(coupon, type, redeemer); } } } } } return status; }