public override void SetSynchronizationPoint() { int subscriptionKey = SoapReferanceHeaderProcessing(unknownHeaders); ConfStorageLoad(); EventServerLoad(); EventServer.SynchronizationPoint(subscriptionKey); EventServerSave(); ConfStorageSave(); actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/PullPointSubscription/SetSynchronizationPointResponse"; }
public override EndpointReferenceType CreatePullPointSubscription(FilterType Filter, [System.Xml.Serialization.XmlElementAttribute(IsNullable = true)] string InitialTerminationTime, CreatePullPointSubscriptionSubscriptionPolicy SubscriptionPolicy, [System.Xml.Serialization.XmlAnyElementAttribute()] ref System.Xml.XmlElement[] Any, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2")] out System.DateTime CurrentTime, [System.Xml.Serialization.XmlElementAttribute(Namespace = "http://docs.oasis-open.org/wsn/b-2", IsNullable = true)] out System.Nullable <System.DateTime> TerminationTime) { SoapHeaderProcessing(unknownHeaders); ConfStorageLoad(); EventServerLoad(); EndpointReferenceType res = new EndpointReferenceType(); DateTime terminationTime; bool nullInitialTerminationTime = false; if (InitialTerminationTime == null) { InitialTerminationTime = "PT10S"; nullInitialTerminationTime = true; } try { TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(InitialTerminationTime); terminationTime = DateTime.UtcNow.Add(timeSpan.Add(new TimeSpan(0, 0, 1))); } catch (Exception) { try { terminationTime = System.Xml.XmlConvert.ToDateTime(InitialTerminationTime, XmlDateTimeSerializationMode.Utc); } catch (Exception) { throw FaultLib.GetSoapException(FaultType.General, "Wrong Initial Termination Time."); } } string rawRequest = RequestListener.Take(); XmlElement filterElement = Utils.GetFilterElements(rawRequest, true); int subscriptionKey = EventServer.AddSubscribtion(null, Filter, filterElement, terminationTime, nullInitialTerminationTime); CurrentTime = DateTime.UtcNow; TerminationTime = terminationTime; res.ReferenceParameters = new ReferenceParametersType(); res.Address = new AttributedURIType(); string hostAndPort = HttpContext.Current.Request.Url.Authority; res.Address.Value = "http://" + hostAndPort + "/ServiceEvents10/PullpointSubscriptionService.asmx"; res.ReferenceParameters.Any = new System.Xml.XmlElement[1]; NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); nsmgr.AddNamespace("dut", "http://dut"); nsmgr.AddNamespace("tdc", "http://www.onvif.org/ver10/doorcontrol/wsdl"); XmlDocument referenceParameters = new XmlDocument(nt); res.ReferenceParameters.Any[0] = referenceParameters.CreateElement("dut", "id", "http://dut"); res.ReferenceParameters.Any[0].InnerXml = subscriptionKey.ToString(); EventServerSave(); ConfStorageSave(); actionHeader.actionValue = "http://www.onvif.org/ver10/events/wsdl/EventPortType/CreatePullPointSubscriptionResponse"; EventServer.SynchronizationPoint(subscriptionKey); return(res); }
public override SubscribeResponse Subscribe([System.Xml.Serialization.XmlElementAttribute("Subscribe", Namespace = "http://docs.oasis-open.org/wsn/b-2")] Subscribe Subscribe1) { SoapHeaderProcessing(unknownHeaders); ConfStorageLoad(); EventServerLoad(); SubscribeResponse res = new SubscribeResponse(); DateTime terminationTime; try { TimeSpan timeSpan = System.Xml.XmlConvert.ToTimeSpan(Subscribe1.InitialTerminationTime); terminationTime = DateTime.UtcNow.Add(timeSpan.Add(new TimeSpan(0, 0, 1))); } catch (Exception) { try { terminationTime = System.Xml.XmlConvert.ToDateTime(Subscribe1.InitialTerminationTime, XmlDateTimeSerializationMode.Utc); } catch (Exception) { throw FaultLib.GetSoapException(FaultType.General, "Wrong Initial Termination Time."); } } string rawRequest = RequestListener.Take(); XmlElement filterElement = Utils.GetFilterElements(rawRequest); int subscriptionKey = EventServer.AddSubscribtion(Subscribe1.ConsumerReference.Address.Value, Subscribe1.Filter, filterElement, terminationTime, false); res.CurrentTimeSpecified = true; res.CurrentTime = DateTime.UtcNow; res.TerminationTimeSpecified = true; res.TerminationTime = terminationTime; res.SubscriptionReference = new EndpointReferenceType(); res.SubscriptionReference.Address = new AttributedURIType(); string hostAndPort = HttpContext.Current.Request.Url.Authority; res.SubscriptionReference.Address.Value = "http://" + hostAndPort + "/ServiceEvents10/SubscriptionManagerService.asmx"; res.SubscriptionReference.ReferenceParameters = new ReferenceParametersType(); res.SubscriptionReference.ReferenceParameters.Any = new System.Xml.XmlElement[1]; NameTable nt = new NameTable(); XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); nsmgr.AddNamespace("xs", "http://www.w3.org/2001/XMLSchema"); nsmgr.AddNamespace("dut", "http://dut"); nsmgr.AddNamespace("tdc", "http://www.onvif.org/ver10/doorcontrol/wsdl"); XmlDocument referenceParameters = new XmlDocument(nt); res.SubscriptionReference.ReferenceParameters.Any[0] = referenceParameters.CreateElement("dut", "id", "http://dut"); res.SubscriptionReference.ReferenceParameters.Any[0].InnerXml = subscriptionKey.ToString(); EventServerSave(); ConfStorageSave(); actionHeader.actionValue = "http://docs.oasis-open.org/wsn/bw-2/NotificationProducer/SubscribeResponse"; EventServer.SynchronizationPoint(subscriptionKey); return(res); }