Exemplo n.º 1
0
        private Dictionary <int, ContainerUpdateOperation> CreateDeleteUserACEOperation(Dictionary <int, ContainerUpdateOperation> operations, ACEItem aceItem)
        {
            foreach (ContainerMembership container in userEndpoint.UserContainerMemberships)
            {
                bool aceFound = false;

                foreach (RealTimeAddress user in container.AllowedSubscribers)
                {
                    if (user.Uri.ToLowerInvariant() == aceItem.ItemValue.ToLowerInvariant())
                    {
                        aceFound = true;
                        break;
                    }
                }

                if (aceFound)
                {
                    if (operations.ContainsKey(container.ContainerId))
                    {
                        operations[container.ContainerId].DeleteUri(aceItem.ItemValue);
                    }
                    else
                    {
                        ContainerUpdateOperation operation = new ContainerUpdateOperation(container.ContainerId);
                        operation.DeleteUri(aceItem.ItemValue);
                        operations.Add(container.ContainerId, operation);
                    }
                    break;
                }
            }

            return(operations);
        }
Exemplo n.º 2
0
        private void UpdatePresenceRelationshipWithAnonymousSubsriber(string newAnonymousSubscriberUri, string oldAnonymousSubscriberUri)
        {
            SipUriParser parser;

            Debug.Assert(SipUriParser.TryParse(newAnonymousSubscriberUri, out parser));

            ContainerUpdateOperation AddACE = new ContainerUpdateOperation(ContainerIDForWebUsers);

            AddACE.AddUri(newAnonymousSubscriberUri);

            if (!String.IsNullOrEmpty(oldAnonymousSubscriberUri))
            {
                Debug.Assert(SipUriParser.TryParse(oldAnonymousSubscriberUri, out parser));
                AddACE.DeleteUri(oldAnonymousSubscriberUri);
            }

            List <ContainerUpdateOperation> listOfOperations = new List <ContainerUpdateOperation>();

            listOfOperations.Add(AddACE);

            try
            {
                _endpoint.LocalOwnerPresence.BeginUpdateContainerMembership(listOfOperations,
                                                                            add =>
                {
                    try
                    {
                        _endpoint.LocalOwnerPresence.EndUpdateContainerMembership(add);
                    }
                    catch (RealTimeException rtex)
                    {
                        _logger.Log("AcdPortal was unable to end update the container membership for Anonymous Subscriber", rtex);
                    }
                },
                                                                            null);
            }
            catch (InvalidOperationException ivoex)
            {
                _logger.Log("AcdPortal was unable to begin update the container membership for Anonymous Subscriber", ivoex);
            }
        }
Exemplo n.º 3
0
        private void Run()
        {
            // Prepare and instantiate the platform.
            _helper = new UCMASampleHelper();
            UserEndpointSettings userEndpointSettings = _helper.ReadUserSettings(
                "PresenceContainerMembership Sample subscribee" /*endpointFriendlyName*/);

            // Set auto subscription to LocalOwnerPresence
            userEndpointSettings.AutomaticPresencePublicationEnabled = true;
            _subscribee = _helper.CreateUserEndpoint(userEndpointSettings);

            // Establish the endpoint
            _helper.EstablishUserEndpoint(_subscribee);

            _subscriberUri = UCMASampleHelper.PromptUser("Please Enter the subscriber's Uri in the form "
                                                         + "sip:User@Hostuser. Please ensure that the uri is in the same domain as "
                                                         + _subscriberUriKey,
                                                         _subscriberUriKey);

            if (!_subscriberUri.StartsWith(_sipPrefix, StringComparison.OrdinalIgnoreCase))
            {
                _subscriberUri = _sipPrefix + _subscriberUri;
            }

            Console.WriteLine("{0} will block {1}, then unblock him. Please login to Microsoft Lync as {1}.",
                              _subscribee.OwnerUri,
                              _subscriberUri);

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to continue.");

            // First publish MachineStateOnline using default grammar. UCMA SDK
            // will publish to the correct containers.
            _subscribee.LocalOwnerPresence.BeginPublishPresence(
                new PresenceCategory[] { PresenceState.EndpointOnline, PresenceState.UserAvailable },
                HandleEndPublishPresence,
                null);

            Console.WriteLine("{0} has published 'Available'. ", _subscribee.OwnerUri);
            Console.WriteLine("Using Microsoft Lync, please subscribe to {0} when logged in as {1}. ",
                              _subscribee.OwnerUri,
                              _subscriberUri);
            Console.WriteLine("You should see that {0} is online and Available. ", _subscribee.OwnerUri);

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to continue.");

            ContainerUpdateOperation operation = new ContainerUpdateOperation(_blockedContainer);

            operation.AddUri(_subscriberUri);
            _subscribee.LocalOwnerPresence.BeginUpdateContainerMembership(
                new ContainerUpdateOperation[] { operation },
                HandleEndUpdateContainerMembership, null);

            Console.WriteLine("{0} has added {1} to container {2} - the blocked container.",
                              _subscribee.OwnerUri,
                              _subscriberUri,
                              _blockedContainer);
            Console.WriteLine("Microsoft Lync should display 'Offline' for user {0} now. ",
                              _subscribee.OwnerUri);

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to continue.");

            operation = new ContainerUpdateOperation(_blockedContainer);
            operation.DeleteUri(_subscriberUri);
            _subscribee.LocalOwnerPresence.BeginUpdateContainerMembership(
                new ContainerUpdateOperation[] { operation },
                HandleEndUpdateContainerMembership, null);

            Console.WriteLine("{0} has removed {1} from the blocked container. Microsoft Lync should display "
                              + "'online' for user {0} now. ",
                              _subscribee.OwnerUri,
                              _subscriberUri);
            Console.WriteLine(" Sample complete. ");

            UCMASampleHelper.PauseBeforeContinuing("Press ENTER to shutdown and exit.");

            // Shutdown Platform
            _helper.ShutdownPlatform();
        }