public int RemoveTickets(List<Ticket> ticketList, BrokerDB brokerDb) { ArrayList coupons = new ArrayList(); Coupon coupon = null; int ticketCount = 0; int couponCount = 0; if (ticketList.Count > 0) { Utilities.WriteLog("RemoveTickets: expired count = " + ticketList.Count); foreach (Ticket ticket in ticketList) { if (!coupons.Contains(ticket.couponId)) { coupons.Add(ticket.couponId); } if (coupon == null || coupon.couponId != ticket.couponId) { coupon = brokerDb.GetIssuedCoupon(ticket.couponId); } switch (ticket.type) { case TicketTypes.ADMINISTER_EXPERIMENT: string payload = ticket.payload; if (payload != null) { XmlQueryDoc xDoc = new XmlQueryDoc(payload); string url = xDoc.Query("AdministerExperimentPayload/essURL"); string expStr = xDoc.Query("AdministerExperimentPayload/experimentID"); long expID = Convert.ToInt64(expStr); ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); essProxy.OperationAuthHeaderValue = new OperationAuthHeader(); essProxy.OperationAuthHeaderValue.coupon = coupon; essProxy.Url = url; StorageStatus expStatus = essProxy.SetExperimentStatus(expID, (int)StorageStatus.CLOSED_TIMEOUT); DataStorageAPI.UpdateExperimentStatus(expStatus); } break; case TicketTypes.RETRIEVE_RECORDS: case TicketTypes.STORE_RECORDS: break; case TicketTypes.EXECUTE_EXPERIMENT: case TicketTypes.ALLOW_EXPERIMENT_EXECUTION: break; default: // Every other Ticket type break; } bool statusR = false; if (ticket.redeemerGuid != brokerDb.GetIssuerGuid()) { ProcessAgentInfo redeemer = brokerDb.GetProcessAgentInfo(ticket.redeemerGuid); if ((redeemer != null) && !redeemer.retired) { ProcessAgentProxy paProxy = new ProcessAgentProxy(); paProxy.AgentAuthHeaderValue = new AgentAuthHeader(); paProxy.Url = redeemer.webServiceUrl; paProxy.AgentAuthHeaderValue.coupon = redeemer.identOut; paProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; statusR = paProxy.CancelTicket(coupon, ticket.type, ticket.redeemerGuid); } } if (ticket.issuerGuid == brokerDb.GetIssuerGuid()) { brokerDb.DeleteIssuedTicket(ticket.ticketId); ticketCount++; } } foreach (long id in coupons) { int count = brokerDb.GetIssuedCouponCollectionCount(id); if (count == 0) { brokerDb.DeleteIssuedCoupon(id); couponCount++; } } Utilities.WriteLog("RemoveTickets: ticketCount=" + ticketCount + " \tcouponCount=" + couponCount); } return ticketCount; }