Exemple #1
0
        public static object NewSetPoolIdentitySetUnionWithStrings()
        {
            var set = new IdentitySet <string>();

            set.UnionWith(Strings);
            set.Clear();
            return(set);
        }
Exemple #2
0
 private static Exception DoDig(Exception e, IdentitySet exceptionsRead)
 {
     if (e.InnerException != null && !exceptionsRead.Contains(e.InnerException))
     {
         exceptionsRead.Add(e.InnerException);
         return(DoDig(e.InnerException, exceptionsRead));
     }
     return(e);
 }
Exemple #3
0
 private static OneDriveIdentitySet CreateOneDriveIdentitySet(IdentitySet identitySet)
 {
     if (identitySet == null)
     {
         return(null);
     }
     return(new OneDriveIdentitySet
     {
         Application = CreateOneDriveIdentity(identitySet.Application),
         Device = CreateOneDriveIdentity(identitySet.Device),
         User = CreateOneDriveIdentity(identitySet.User),
     });
 }
Exemple #4
0
        /// <summary>
        /// Incoming call handler.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="CollectionEventArgs{TEntity}"/> instance containing the event data.</param>
        private void CallsOnIncoming(ICallCollection sender, CollectionEventArgs <ICall> args)
        {
            args.AddedResources.ForEach(call =>
            {
                // Get the compliance recording parameters.

                // The context associated with the incoming call.
                IncomingContext incomingContext =
                    call.Resource.IncomingContext;

                // The RP participant.
                string observedParticipantId =
                    incomingContext.ObservedParticipantId;

                // If the observed participant is a delegate.
                IdentitySet onBehalfOfIdentity =
                    incomingContext.OnBehalfOf;

                // If a transfer occured, the transferor.
                IdentitySet transferorIdentity =
                    incomingContext.Transferor;

                string countryCode        = null;
                EndpointType?endpointType = null;

                // Note: this should always be true for CR calls.
                if (incomingContext.ObservedParticipantId == incomingContext.SourceParticipantId)
                {
                    // The dynamic location of the RP.
                    countryCode = call.Resource.Source.CountryCode;

                    // The type of endpoint being used.
                    endpointType = call.Resource.Source.EndpointType;
                }

                IMediaSession mediaSession = Guid.TryParse(call.Id, out Guid callId)
                    ? this.CreateLocalMediaSession(callId)
                    : this.CreateLocalMediaSession();

                // Answer call
                call?.AnswerAsync(mediaSession).ForgetAndLogExceptionAsync(
                    call.GraphLogger,
                    $"Answering call {call.Id} with scenario {call.ScenarioId}.");
            });
        }
        /// <summary>
        /// Gets the participant.
        /// </summary>
        /// <param name="serialized">The serialized.</param>
        /// <returns>List&lt;IParticipant&gt;.</returns>
        public List <IParticipant> GetParticipant(SerializableAudioMediaBuffer serialized)
        {
            var list = new List <IParticipant>();

            if (serialized.SerializableUnmixedAudioBuffers != null)
            {
                foreach (var i in serialized.SerializableUnmixedAudioBuffers)
                {
                    var participant = new Participant();
                    var info        = new ParticipantInfo();
                    var identity    = new IdentitySet();
                    var user        = new Identity();

                    user.DisplayName    = i.DisplayName;
                    user.AdditionalData = i.AdditionalData;
                    user.Id             = i.AdId;

                    identity.User    = user;
                    info.Identity    = identity;
                    participant.Info = info;

                    var media = new Microsoft.Graph.MediaStream()
                    {
                        SourceId = i.ActiveSpeakerId.ToString()
                    };
                    participant.MediaStreams = new List <Microsoft.Graph.MediaStream>()
                    {
                        media
                    };

                    participant.IsInLobby = false;

                    list.Add(new ParticipantExtension(participant));
                }
            }

            return(list);
        }
Exemple #6
0
        // Merge vote 1 > vote 2
        // Modify task of vote 1 (may imply merge vote 1 > vote 2)
        // Delete vote 1
        // Change voter 1 votes to those made by voter 2
        // Delete voter 1

        /// <summary>
        /// Merges vote1 with vote2.
        /// Everyone who had previously supported vote1 gets added to the supporters
        /// for vote2, and vote1 is cleared.
        /// </summary>
        /// <param name="vote1">The 'from' vote.</param>
        /// <param name="vote2">The 'to' vote.</param>
        /// <param name="type">The type of vote.</param>
        public void Merge(VotePartition vote1, VotePartition vote2, VoteType type)
        {
            var votes = GetVoteEntries(type);

            if (!votes.TryGetValue(vote1, out var voters1))
            {
                voters1      = new IdentitySet();
                votes[vote1] = voters1;
            }

            if (!votes.TryGetValue(vote2, out var voters2))
            {
                voters2      = new IdentitySet();
                votes[vote2] = voters2;
            }

            // Save prior state to allow an undo
            PreserveMerge(vote1, vote2, voters1, voters2, type);

            // Update the votes->identity lookup
            voters2.UnionWith(voters1);
            voters1.Clear();
        }
        /// <summary>
        /// Adds participants asynchronously.
        /// </summary>
        /// <param name="callLegId">which call to add participants.</param>
        /// <param name="addParticipantBody">The add participant body.</param>
        /// <returns>The <see cref="Task"/>.</returns>
        public async Task AddParticipantAsync(string callLegId, AddParticipantRequestData addParticipantBody)
        {
            if (string.IsNullOrEmpty(callLegId))
            {
                throw new ArgumentNullException(nameof(callLegId));
            }

            if (string.IsNullOrEmpty(addParticipantBody.ObjectId))
            {
                throw new ArgumentNullException(nameof(addParticipantBody.ObjectId));
            }

            var target = new IdentitySet
            {
                User = new Identity
                {
                    Id = addParticipantBody.ObjectId,
                },
            };

            await this.Client.Calls()[callLegId].Participants
            .InviteAsync(target, addParticipantBody.ReplacesCallId)
            .ConfigureAwait(false);
        }
Exemple #8
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="EntityWriter" /> class.
        /// </summary>
        /// <param name="entityContext">
        ///     The entity context.
        /// </param>
        /// <param name="entityType">
        ///     The entity type.
        /// </param>
        /// <param name="entity">
        ///     The entity.
        /// </param>
        /// <param name="behaviors">
        ///     The behaviors.
        /// </param>
        /// <param name="entitiesWritten">
        ///     The entities written.
        /// </param>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.DoNotCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If <see cref="Behaviors.BypassWriteCache" /> has been combined with <see cref="Behaviors.CreateLazy" />.
        /// </exception>
        private EntityWriter(EntityContext entityContext, Type entityType, object entity, Behaviors behaviors,
                             IdentitySet entitiesWritten)
        {
            if (behaviors.IsCreateLazy())
            {
                if (behaviors.DoNotCache())
                {
                    throw new ArgumentException(@"DontCache cannot be combined with CreateLazy", nameof(behaviors));
                }

                if (behaviors.BypassWriteCache())
                {
                    throw new ArgumentException(@"BypassWriteCache cannot be combined with CreateLazy", nameof(behaviors));
                }
            }

            this.entityContext      = entityContext;
            this.behaviors          = behaviors;
            this.entityType         = entityType;
            this.entity             = entity;
            this.entitiesWritten    = entitiesWritten;
            this.entitySpecsWritten = entityContext.EntitySpecsWritten;
            this.entitySpecsFetched = entityContext.EntitySpecsFetched;
        }
Exemple #9
0
        public IList List(ISessionImplementor session, QueryParameters queryParameters)
        {
            // Delegate to the QueryLoader...
            ErrorIfDML();
            var  query            = ( QueryNode )_sqlAst;
            bool hasLimit         = queryParameters.RowSelection != null && queryParameters.RowSelection.DefinesLimits;
            bool needsDistincting = (query.GetSelectClause().IsDistinct || hasLimit) && ContainsCollectionFetches;

            QueryParameters queryParametersToUse;

            if (hasLimit && ContainsCollectionFetches)
            {
                log.Warn("firstResult/maxResults specified with collection fetch; applying in memory!");
                var selection = new RowSelection
                {
                    FetchSize = queryParameters.RowSelection.FetchSize,
                    Timeout   = queryParameters.RowSelection.Timeout
                };
                queryParametersToUse = queryParameters.CreateCopyUsing(selection);
            }
            else
            {
                queryParametersToUse = queryParameters;
            }

            IList results = _queryLoader.List(session, queryParametersToUse);

            if (needsDistincting)
            {
                int includedCount = -1;
                // NOTE : firstRow is zero-based
                int first = !hasLimit || queryParameters.RowSelection.FirstRow == RowSelection.NoValue
                                                        ? 0
                                                        : queryParameters.RowSelection.FirstRow;
                int max = !hasLimit || queryParameters.RowSelection.MaxRows == RowSelection.NoValue
                                                        ? -1
                                                        : queryParameters.RowSelection.MaxRows;

                int size        = results.Count;
                var tmp         = new List <object>();
                var distinction = new IdentitySet();

                for (int i = 0; i < size; i++)
                {
                    object result = results[i];
                    if (!distinction.Add(result))
                    {
                        continue;
                    }
                    includedCount++;
                    if (includedCount < first)
                    {
                        continue;
                    }
                    tmp.Add(result);
                    // NOTE : ( max - 1 ) because first is zero-based while max is not...
                    if (max >= 0 && (includedCount - first) >= (max - 1))
                    {
                        break;
                    }
                }

                results = tmp;
            }

            return(results);
        }
        public void PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results)
        {
            if (Log.IsDebugEnabled)
            {
                Log.Debug("find: " + _sourceQuery);
                queryParameters.LogParameters(session.Factory);
            }

            bool            hasLimit   = queryParameters.RowSelection != null && queryParameters.RowSelection.DefinesLimits;
            bool            needsLimit = hasLimit && Translators.Length > 1;
            QueryParameters queryParametersToUse;

            if (needsLimit)
            {
                Log.Warn("firstResult/maxResults specified on polymorphic query; applying in memory!");
                RowSelection selection = new RowSelection();
                selection.FetchSize  = queryParameters.RowSelection.FetchSize;
                selection.Timeout    = queryParameters.RowSelection.Timeout;
                queryParametersToUse = queryParameters.CreateCopyUsing(selection);
            }
            else
            {
                queryParametersToUse = queryParameters;
            }

            IList       combinedResults = results ?? new List <object>();
            IdentitySet distinction     = new IdentitySet();
            int         includedCount   = -1;

            for (int i = 0; i < Translators.Length; i++)
            {
                IList tmp = Translators[i].List(session, queryParametersToUse);
                if (needsLimit)
                {
                    // NOTE : firstRow is zero-based
                    int first = queryParameters.RowSelection.FirstRow == RowSelection.NoValue
                                                                                                ? 0
                                                                                                : queryParameters.RowSelection.FirstRow;

                    int max = queryParameters.RowSelection.MaxRows == RowSelection.NoValue
                                                                                        ? RowSelection.NoValue
                                                                                        : queryParameters.RowSelection.MaxRows;

                    int size = tmp.Count;
                    for (int x = 0; x < size; x++)
                    {
                        object result = tmp[x];
                        if (distinction.Add(result))
                        {
                            continue;
                        }
                        includedCount++;
                        if (includedCount < first)
                        {
                            continue;
                        }
                        combinedResults.Add(result);
                        if (max >= 0 && includedCount > max)
                        {
                            // break the outer loop !!!
                            return;
                        }
                    }
                }
                else
                {
                    ArrayHelper.AddAll(combinedResults, tmp);
                }
            }
        }
Exemple #11
0
        private static ApplicationCompositionSchema DoInitializeCompositionSchemas(ApplicationSchemaDefinition schema, ApplicationCompositionDefinition composition, IdentitySet checkedCompositions)
        {
            var relationship                 = composition.Relationship;
            var compositionApplication       = MetadataProvider.GetCompositionApplication(schema, relationship);
            var compositionResult            = new CompositionSchemas();
            var applicationCompositionSchema = composition.Schema;

            if (applicationCompositionSchema.Schemas != null)
            {
                return(applicationCompositionSchema);
            }
            compositionResult.Detail = GetDetailSchema(compositionApplication, applicationCompositionSchema);
            if (composition.Collection && applicationCompositionSchema is ApplicationCompositionCollectionSchema)
            {
                compositionResult.List  = GetListSchema(applicationCompositionSchema, compositionApplication);
                compositionResult.Print = GetPrintSchema(applicationCompositionSchema, compositionApplication, compositionResult.Detail, compositionResult.List);
                var collSchema = (ApplicationCompositionCollectionSchema)applicationCompositionSchema;
                collSchema.FetchFromServer = ShouldFetchFromServer(compositionResult.Detail, compositionResult.List);
            }
            //build eventual inner compositions schema data
            checkedCompositions.Add(composition.Relationship);
            if (compositionResult.Detail != null)
            {
                //sometimes,we don´t have a detail schema, just a list one
                foreach (var innerComposition in compositionResult.Detail.Compositions)
                {
                    if (!checkedCompositions.Contains(innerComposition.Relationship))
                    {
                        //to avod infinte loop
                        DoInitializeCompositionSchemas(schema, innerComposition, checkedCompositions);
                    }
                }
            }
            applicationCompositionSchema.Schemas = compositionResult;
            return(applicationCompositionSchema);
        }
 /// <summary>
 /// Get the redirect location of the specified participant.
 /// </summary>
 /// <param name="identity">The identity of the participant.</param>
 /// <param name="countryCode">The dynamic location of the participant.</param>
 /// <returns>The redirect location for the specified participant.</returns>
 private static Task <Uri> GetRedirectLocationOfParticipantAsync(IdentitySet identity, string countryCode)
 {
     // TODO: add redirect logic.
     return(Task.FromResult <Uri>(null));
 }
Exemple #13
0
        //Create Meet Now Online meeting and schedule it in atendees calendars
        static public async Task <OnlineMeeting> CreateOnlineMeeting(string meetingSubject, string organizerEmail, string[] atendees, DateTime startDateTime, DateTime endDateTime)
        {
            var graphClient = await CreateGraphClient();

            var requestUrl             = "https://graph.microsoft.com/beta/app/onlineMeetings";
            HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, requestUrl);

            message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

            await graphClient.AuthenticationProvider.AuthenticateRequestAsync(message);


            var participants = new Microsoft.Graph.MeetingParticipants
            {
                Organizer = new MeetingParticipantInfo
                {
                    Identity = new IdentitySet
                    {
                        User = new Identity
                        {
                            Id = await GetUserFromEmail(organizerEmail)
                        }
                    }
                }
            };

            var attendeeList = new List <MeetingParticipantInfo>();

            foreach (var atendeee in atendees)
            {
                var identity = new IdentitySet
                {
                    User = new Identity
                    {
                        Id = await GetUserFromEmail(organizerEmail)
                    }
                };


                attendeeList.Add(
                    new MeetingParticipantInfo
                {
                    Identity = identity
                });
            }

            participants.Attendees = attendeeList;

            OnlineMeeting onlineMeeting = new OnlineMeeting {
                Subject = meetingSubject, Participants = participants
            };

            //Remove audioConferencing property from JSON
            JObject jobt = (JObject)JToken.FromObject(onlineMeeting);

            jobt.Remove("audioConferencing");

            message.Content = new StringContent(jobt.ToString(), System.Text.Encoding.UTF8, "application/json");

            HttpResponseMessage response = await graphClient.HttpProvider.SendAsync(message);

            if (response.IsSuccessStatusCode)
            {
                var content = await response.Content.ReadAsStringAsync();

                var oData = graphClient.HttpProvider.Serializer.DeserializeObject <JObject>(content);

                OnlineMeeting meetingCreated = graphClient.HttpProvider.Serializer.DeserializeObject <OnlineMeeting>(oData.ToString());

                try
                {
                    var a = await ScheduleCalendarEvent(meetingSubject, meetingCreated.JoinUrl, startDateTime, endDateTime, organizerEmail, atendees);
                }
                catch (Exception)
                {
                    throw;
                }

                return(meetingCreated);
            }
            else
            {
                throw new ServiceException(
                          new Error
                {
                    Code    = response.StatusCode.ToString(),
                    Message = await response.Content.ReadAsStringAsync()
                }
                          );
            }
        }
Exemple #14
0
        public static System.Exception DigRootException(System.Exception e)
        {
            var exceptions = new IdentitySet();

            return(DoDig(e, exceptions));
        }
Exemple #15
0
        /// <summary>
        /// Add any number of vote fragments for a given voter, from a given post.
        /// </summary>
        /// <param name="partitions">A list of vote fragments.</param>
        /// <param name="voterName">The voter.</param>
        /// <param name="postID">The post the vote fragments are from.</param>
        /// <exception cref="ArgumentNullException"/>
        public void AddVoteEntries(IEnumerable <VotePartition> partitions, Identity identity)
        {
            if (partitions == null)
            {
                throw new ArgumentNullException(nameof(partitions));
            }
            if (identity == null)
            {
                throw new ArgumentNullException(nameof(identity));
            }

            if (!partitions.Any())
            {
                return;
            }

            // All existing partitions have this identity removed.
            bool changedVoters = RemoveVoterSupport(identity);
            bool addedAnyVotes = false;

            foreach (var partition in partitions)
            {
                AddTask(partition.Task);

                var votes = GetVoteEntries(partition.VoteType);

                // Add supporters to partitions
                if (votes.TryGetValue(partition, out var identitySet))
                {
                    changedVoters = identitySet.Add(identity) || changedVoters;
                }
                else
                {
                    votes[partition] = new IdentitySet {
                        identity
                    };
                    addedAnyVotes = true;
                }

                // Add partitions to supporters
                if (IdentityVotesLookup.TryGetValue(identity, out var identVotes))
                {
                    identVotes.Add(partition);
                }
                else
                {
                    IdentityVotesLookup.Add(identity, new List <VotePartition> {
                        partition
                    });
                }
            }

            if (addedAnyVotes)
            {
                OnPropertyChanged("Votes");
            }
            if (changedVoters)
            {
                OnPropertyChanged("Voters");
            }
        }
Exemple #16
0
        public static async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    meeting     = JsonConvert.DeserializeObject <Meeting>(requestBody);

            GraphServiceClient graphClient = GetAuthenticatedGraphClient();


            var participants     = new MeetingParticipants();
            var participantsInfo = new List <MeetingParticipantInfo>();

            var participantInfoPacient = new MeetingParticipantInfo();
            var identitySetUserPacient = new IdentitySet
            {
                User = new Identity()
            };
            var identityUserPacient = new Identity
            {
                DisplayName = meeting.PatientEmail
            };

            identitySetUserPacient.User = identityUserPacient;

            participantInfoPacient.Identity = identitySetUserPacient;

            /*var participantInfoDoctor = new MeetingParticipantInfo();
             * var identitySetUserDoctor = new IdentitySet
             * {
             *  User = new Identity()
             * };
             * var identityUserDoctor = new Identity
             * {
             *  DisplayName = meeting.DoctorEmail
             * };
             * identitySetUserDoctor.User = identityUserDoctor;
             *
             * participantInfoDoctor.Identity = identitySetUserDoctor;
             *
             * participantInfoDoctor.Identity = identitySetUserDoctor;*/

            participantsInfo.Add(participantInfoPacient);
            //participantsInfo.Add(participantInfoDoctor);
            participants.Attendees = participantsInfo;

            var onlineMeeting = new OnlineMeeting
            {
                StartDateTime = DateTimeOffset.Parse(meeting.StartDate),
                EndDateTime   = DateTimeOffset.Parse(meeting.EndDate),
                Participants  = new MeetingParticipants(),
                Subject       = meeting.Subject
            };


            var onlineMeeting1 = new OnlineMeeting
            {
                StartDateTime = DateTimeOffset.Parse("2019-07-12T21:30:34.2444915+00:00"),
                EndDateTime   = DateTimeOffset.Parse("2019-07-12T22:00:34.2464912+00:00"),
                Subject       = "User Token Meeting"
            };


            OnlineMeeting onlineMeetingReturned;

            try
            {
                onlineMeetingReturned = await graphClient.Me.OnlineMeetings.Request().AddAsync(onlineMeeting);
            }catch (Exception ex)
            {
                if (ex.Message.Contains("InvalidAuthenticationToken"))
                {
                    return(new BadRequestObjectResult("Token Expired"));
                }
                else
                {
                    return(new BadRequestResult());
                }
            }
            return(new OkObjectResult(onlineMeetingReturned));
        }