public HermesMiddleware.DataAcquisitionServiceProxy.Subscription ConvertServer2Proxy(HermesMiddleware.DataAcquisitionServiceServer.Subscription sourceSubscription) { HermesMiddleware.DataAcquisitionServiceProxy.Subscription targetSubscription = new HermesMiddleware.DataAcquisitionServiceProxy.Subscription(); targetSubscription.GUID = sourceSubscription.GUID; targetSubscription.name = sourceSubscription.name; targetSubscription.variable = sourceSubscription.variable; targetSubscription.Items = new HermesMiddleware.DataAcquisitionServiceProxy.Expression[sourceSubscription.Items.Length]; for (int i = 0; i < sourceSubscription.Items.Length; i++) { targetSubscription.Items[i] = ConvertServer2Proxy(sourceSubscription.Items[i]); } return(targetSubscription); }
public override void Unsubscribe(string service, [System.Xml.Serialization.XmlElementAttribute("subscriptions")] HermesMiddleware.DataAcquisitionServiceServer.Subscription[] subscriptions, bool delegateCall) { // get global stuff (cross-application-domain) Global global = (Global)Global.GetObject(Global.sClassName, Global.port); // get addresses of peers (variable is null => we want all peers for given service) string[] sPeerAddresses = _GetPeers(global, service, null); if (sPeerAddresses != null) { foreach (string sPeerAddress in sPeerAddresses) { // get first part of name (e.g. PCC085C.us008.siemens.net) string[] sParts = sPeerAddress.Split('.'); if (String.Compare(sParts[0], Environment.MachineName, true) == 0) { // peer is this machine => remove subscriptions foreach (HermesMiddleware.DataAcquisitionServiceServer.Subscription subscription in subscriptions) { // remove subscriber global.RemoveSubscriber(subscription.GUID); } } else { if (delegateCall) { try { // peer is different machine => delegate it to its DataAcquisitionService // initialize service proxy HermesMiddleware.DataAcquisitionServiceProxy.DataAcquisitionService serviceProxy = new HermesMiddleware.DataAcquisitionServiceProxy.DataAcquisitionService(); serviceProxy.Url = "http://" + sPeerAddress + ":" + global.portNumber + global.sVirtRoot + global.sASMX; HermesMiddleware.DataAcquisitionServiceProxy.Subscription[] tmpSubscriptions = new HermesMiddleware.DataAcquisitionServiceProxy.Subscription[subscriptions.Length]; for (int i = 0; i < subscriptions.Length; i++) { tmpSubscriptions[i] = ConvertServer2Proxy(subscriptions[i]); } // unsubscribe serviceProxy.Unsubscribe(service, tmpSubscriptions, false); } catch (Exception exp) { Console.WriteLine(exp); } } } } } }