}//createCheckStatusResponse // create subsription response private void createSubscriptionResponse() { Siri responseSiri = new Siri(); SubscriptionResponseStructure srs = new SubscriptionResponseStructure(); srs.ResponseTimestamp = DateTime.Now; ParticipantRefStructure responder = new ParticipantRefStructure(); responder.Value = "TfNSW_SIRI_Service"; srs.ResponderRef = responder; List<StatusResponseStructure> responseStatus = new List<StatusResponseStructure>(); //identify the subscription information SubscriptionRequest sr = (SubscriptionRequest)siri.Item; //esitmated timetable susbcription request if (sr.EstimatedTimetableSubscriptionRequest != null) { for (int i = 0; i < sr.EstimatedTimetableSubscriptionRequest.Length; i++) { responseStatus.Add(createSubscriptionResponseStatus(sr.EstimatedTimetableSubscriptionRequest[i])); } } //situation exchange subscription request if (sr.SituationExchangeSubscriptionRequest != null) { for (int i = 0; i < sr.SituationExchangeSubscriptionRequest.Length; i++) { responseStatus.Add(createSubscriptionResponseStatus(sr.SituationExchangeSubscriptionRequest[i])); } } //vehicle monitoring subscription request if (sr.VehicleMonitoringSubscriptionRequest != null) { for (int i = 0; i < sr.VehicleMonitoringSubscriptionRequest.Length; i++) { responseStatus.Add(createSubscriptionResponseStatus(sr.VehicleMonitoringSubscriptionRequest[i])); } } srs.ResponseStatus = responseStatus.ToArray(); responseSiri.Item = srs; this.response = responseSiri; }//createSubscriptionResponse
}//porcess // create check status response private void createCheckStatusResponse() { Siri responseSiri = new Siri(); CheckStatusRequestStructure checkStatusRequest = (CheckStatusRequestStructure)siri.Item; CheckStatusResponseStructure csr = new CheckStatusResponseStructure(); csr.ResponseTimestamp = DateTime.Now; csr.Status = true; csr.ServiceStartedTime = serviceInfo.ServiceStartTime; if (checkStatusRequest.MessageIdentifier != null) { MessageRefStructure requestMessageRef = new MessageRefStructure(); requestMessageRef.Value = checkStatusRequest.MessageIdentifier.Value; csr.RequestMessageRef = requestMessageRef; } responseSiri.Item = csr; this.response = responseSiri; }//createCheckStatusResponse
public ActionResult Post([FromBody] Siri siri) { if (!this.ModelState.IsValid || siri == null) { return(BadRequest()); } else { var maxExistingId = 0; if (Repository.Siris.Count > 0) { maxExistingId = Repository.Siris.Keys.Max(); } // siri.ID = maxExistingId + 1; Repository.Siris.Add(maxExistingId + 1, siri); SiriServiceInformation serviceInfo = new SiriServiceInformation(); serviceInfo.ServiceStartTime = _info.ServiceStartTime; SiriManager sm = new SiriManager(siri, serviceInfo); sm.process(); switch (sm.status) { case SiriManager.Status.ValidAndResponse: return(Ok(sm.response)); case SiriManager.Status.ValidNoResponse: return(Accepted()); case SiriManager.Status.ValidNotSupport: return(UnprocessableEntity()); default: return(BadRequest()); } } }
public SiriManager(Siri siriInput, SiriServiceInformation serviceInfoInput) { this.siri = siriInput; this.serviceInfo = serviceInfoInput; }