Exemplo n.º 1
0
        private void ExecuteAwardSwag()
        {
            if (!CanSwag)
            {
                MessageBox.Show("All swagged out");
                SwagText = "All swagged out";
            }
            else
            {
                if (_swagOMeterAwardEngine.CanSwag)
                {
                    _swagOMeterAwardEngine.AwardSwag();

                    _awardedSwag     = _swagOMeterAwardEngine.AwardedSwag;
                    _winningAttendee = _swagOMeterAwardEngine.WinningAttendee;

                    CanSwag = _swagOMeterAwardEngine.CanSwag;

                    if (!CanSwag)
                    {
                        SwagText = "All Swagged Out!";
                    }

                    ResetDisplayText();
                    ChangeResponseButtons(true);
                }
            }
        }
Exemplo n.º 2
0
        public static IWinner Create(SwagBase swag, AttendeeBase attendee)
        {
            var winner = new Winner {
                AwardedSwag = swag, WinningAttendee = attendee
            };

            return(winner);
        }
Exemplo n.º 3
0
        private void ExecuteAttendeeDoesNotWantSwag()
        {
            _swagOMeterAwardEngine.AttendeeDoesNotWantSwag();

            _winningAttendee = null;
            _awardedSwag     = null;

            CheckCanSwag();
            ResetDisplayText();

            ChangeResponseButtons(false);
        }
        private bool IsAttendeeAndSwagComboValid(AttendeeBase attendeeToCheck, SwagBase swagToCheck)
        {
            var swagCanBeAwarded = !_badSwagCombinations.Any(bs => bs.AwardedSwag.Thing == swagToCheck.Thing &&
                                                             bs.WinningAttendee.Name == attendeeToCheck.Name);

            if (!swagCanBeAwarded)
            {
                _attendees.Add(attendeeToCheck);
                _swag.Add(swagToCheck);
            }

            return(swagCanBeAwarded);
        }
Exemplo n.º 5
0
 public void UpdateAttendee(AttendeeBase attendee, int userId)
 {
     Requires.NotNull(attendee);
     Requires.NotNull(attendee.ConferenceId);
     Requires.NotNull(attendee.UserId);
     attendee.LastModifiedByUserID = userId;
     attendee.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         var rep = context.GetRepository <AttendeeBase>();
         rep.Update("SET Status=@0, ReceiveNotifications=@1, CreatedByUserID=@2, CreatedOnDate=@3, LastModifiedByUserID=@4, LastModifiedOnDate=@5, Company=@6 WHERE ConferenceId=@7 AND UserId=@8",
                    attendee.Status, attendee.ReceiveNotifications, attendee.CreatedByUserID, attendee.CreatedOnDate, attendee.LastModifiedByUserID, attendee.LastModifiedOnDate, attendee.Company, attendee.ConferenceId, attendee.UserId);
     }
 }
Exemplo n.º 6
0
        public IEnumerable <string> GetUsers(string match, int count)
        {
#if MEETING_TIMES
            MeetingTimes times = new MeetingTimes();

            MeetingTimeSlot timeSlot = new MeetingTimeSlot();
            timeSlot.Start = new TimeDesc("2015-10-08", "1:00:00", "GMT Standard Time");
            timeSlot.End   = new TimeDesc("2015-10-08", "23:00:00", "GMT Standard Time");

            AttendeeBase att1 = new AttendeeBase();
//            att1.EmailAddress.Address = "*****@*****.**";
            att1.EmailAddress.Address = "*****@*****.**";

            AttendeeBase att2 = new AttendeeBase();
            att2.EmailAddress.Address = "*****@*****.**";

            times.TimeConstraint.Timeslots.Add(timeSlot);
            times.LocationConstraint = new LocationConstraint();

            times.Attendees.Add(att1);
//            times.Attendees.Add(att2);

            var    httpProxy = new HttpUtilSync(Constants.OfficeResourceId);
            String uri       = "https://outlook.office365.com/api/beta/me/findmeetingtimes";

            var res = httpProxy.PostItem2 <MeetingTimes, MeetingTimeCandidates>(uri, times);

            return(null);
#else
            string uri = BaseUri + "users";
            uri += '?';     // we always have at least api version parameter

            if (string.IsNullOrEmpty(match) == false)
            {
                uri = AddFilters(uri, match,
                                 "userPrincipalName",
                                 "displayName",
                                 "givenName" /*, "surName"*/);

                uri += '&';
            }

            uri += ApiVersion;

            var users = new HttpUtilSync(Constants.AadServiceResourceId)
                        .GetItems <UserHttp>(uri, count);

            return(users.Select(x => x.UserPrincipalName));
#endif
        }
Exemplo n.º 7
0
        public IEnumerable<string> GetUsers(string match, int count)
        {
            #if MEETING_TIMES
            MeetingTimes times = new MeetingTimes();

            MeetingTimeSlot timeSlot = new MeetingTimeSlot();
            timeSlot.Start = new TimeDesc("2015-10-08", "1:00:00", "GMT Standard Time");
            timeSlot.End = new TimeDesc("2015-10-08", "23:00:00", "GMT Standard Time");

            AttendeeBase att1 = new AttendeeBase();
            //            att1.EmailAddress.Address = "*****@*****.**";
            att1.EmailAddress.Address = "*****@*****.**";

            AttendeeBase att2 = new AttendeeBase();
            att2.EmailAddress.Address = "*****@*****.**";

            times.TimeConstraint.Timeslots.Add(timeSlot);
            times.LocationConstraint = new LocationConstraint();

            times.Attendees.Add(att1);
            //            times.Attendees.Add(att2);

            var httpProxy = new HttpUtilSync(Constants.OfficeResourceId);
            String uri = "https://outlook.office365.com/api/beta/me/findmeetingtimes";

            var res = httpProxy.PostItem2<MeetingTimes, MeetingTimeCandidates>(uri, times);

            return null;
            #else
            string uri = BaseUri + "users";
            uri += '?';     // we always have at least api version parameter

            if (string.IsNullOrEmpty(match) == false)
            {
                uri = AddFilters(uri, match,
                            "userPrincipalName",
                            "displayName",
                            "givenName"/*, "surName"*/);

                uri += '&';
            }

            uri += ApiVersion;

            var users = new HttpUtilSync(Constants.AadServiceResourceId)
                    .GetItems<UserHttp>(uri, count);

            return users.Select(x => x.UserPrincipalName);
            #endif
        }
        public static void CheckAttendee(int portalId, AttendeeBase attendee)
        {
            var conference = ConferenceRepository.Instance.GetConference(portalId, attendee.ConferenceId);

            if (conference.AttendeeRole > 0)
            {
                if (attendee.Status >= (int)AttendeeStatus.Confirmed)
                {
                    EnsureUserRole(portalId, attendee.UserId, conference.AttendeeRole);
                }
                else
                {
                    DenyUserRole(portalId, attendee.UserId, conference.AttendeeRole);
                }
            }
        }
Exemplo n.º 9
0
 public void AddAttendee(AttendeeBase attendee, int userId)
 {
     Requires.NotNull(attendee);
     Requires.NotNull(attendee.ConferenceId);
     Requires.NotNull(attendee.UserId);
     attendee.CreatedByUserID      = userId;
     attendee.CreatedOnDate        = DateTime.Now;
     attendee.LastModifiedByUserID = userId;
     attendee.LastModifiedOnDate   = DateTime.Now;
     using (var context = DataContext.Instance())
     {
         context.Execute(System.Data.CommandType.Text,
                         "IF NOT EXISTS (SELECT * FROM {databaseOwner}{objectQualifier}Connect_Conference_Attendees " +
                         "WHERE ConferenceId=@0 AND UserId=@1) " +
                         "INSERT INTO {databaseOwner}{objectQualifier}Connect_Conference_Attendees (ConferenceId, UserId, Status, ReceiveNotifications, CreatedByUserID, CreatedOnDate, LastModifiedByUserID, LastModifiedOnDate, Company) " +
                         "SELECT @0, @1, @2, @3, @4, @5, @6, @7, @8", attendee.ConferenceId, attendee.UserId, attendee.Status, attendee.ReceiveNotifications, attendee.CreatedByUserID, attendee.CreatedOnDate, attendee.LastModifiedByUserID, attendee.LastModifiedOnDate, attendee.Company);
     }
 }
        private AttendeeBase GetAttendee()
        {
            var          randomNumberGenerator = new Random();
            AttendeeBase winningAttendee       = null;
            var          attendeeNotSelected   = true;

            while (attendeeNotSelected)
            {
                var index = randomNumberGenerator.Next(0, _attendees.Count);
                winningAttendee = _attendees[index];

                attendeeNotSelected = false;
            }

            _attendees.Remove(winningAttendee);

            CheckCanSwag();

            return(winningAttendee);
        }
        private IWinner GetWinner()
        {
            AttendeeBase winningAttendee = null;
            SwagBase     swag            = null;

            var swagAwarded = false;

            while (!swagAwarded)
            {
                winningAttendee = GetAttendee();
                swag            = GetSwag();

                swagAwarded = IsAttendeeAndSwagComboValid(winningAttendee, swag);
            }

            var winner = Winner.Create(swag, winningAttendee);

            _winners.Add(winner);

            return(winner);
        }
Exemplo n.º 12
0
        public HttpResponseMessage ChangeStatus(int conferenceId, [FromBody] ChangeStatusDTO newStatus)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (newStatus.Status > 1)
                {
                    return(AccessViolation("Only management can increase your status this far"));
                }
                if (newStatus.UserId != UserInfo.UserID)
                {
                    return(AccessViolation("Only management can change status for other users"));
                }
            }
            var attendee = AttendeeRepository.Instance.GetAttendee(conferenceId, newStatus.UserId);

            if (attendee == null)
            {
                var a = new AttendeeBase()
                {
                    ConferenceId = conferenceId, UserId = newStatus.UserId, ReceiveNotifications = true, Status = newStatus.Status
                };
                AttendeeRepository.Instance.AddAttendee(a, UserInfo.UserID);
                Connect.Conference.Core.Controllers.DnnRoleController.CheckAttendee(PortalSettings.PortalId, a);
                return(Request.CreateResponse(HttpStatusCode.OK, AttendeeRepository.Instance.GetAttendee(conferenceId, a.UserId)));
            }
            else if (newStatus.Status == -1)
            {
                AttendeeRepository.Instance.DeleteAttendee(conferenceId, newStatus.UserId);
                Connect.Conference.Core.Controllers.DnnRoleController.RemoveAttendee(PortalSettings.PortalId, conferenceId, newStatus.UserId);
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            else
            {
                attendee.Status = newStatus.Status;
                AttendeeRepository.Instance.UpdateAttendee(attendee, UserInfo.UserID);
                Connect.Conference.Core.Controllers.DnnRoleController.CheckAttendee(PortalSettings.PortalId, attendee);
                return(Request.CreateResponse(HttpStatusCode.OK, attendee));
            }
        }
Exemplo n.º 13
0
 public void DeleteAttendee(AttendeeBase attendee)
 {
     DeleteAttendee(attendee.ConferenceId, attendee.UserId);
 }
Exemplo n.º 14
0
        public ActionResult Edit(int conferenceId, int attendeeId, AttendeeDTO attendee)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != attendeeId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            AttendeeBase recordToUpdate = null;
            var          existingRecord = _repository.GetAttendee(conferenceId, attendeeId);
            var          modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new AttendeeBase()
                {
                    ConferenceId = conferenceId, UserId = attendeeId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetAttendeeBase();
            }
            recordToUpdate.ReceiveNotifications = attendee.ReceiveNotifications;
            recordToUpdate.Company = attendee.Company;
            if (modeAdd)
            {
                _repository.AddAttendee(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateAttendee(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = UserController.GetUserById(PortalSettings.PortalId, attendeeId);

            if (dnnUser == null)
            {
                // create the user
                dnnUser = new UserInfo()
                {
                    PortalID = PortalSettings.PortalId, Username = attendee.Email, Email = attendee.Email, FirstName = attendee.FirstName, LastName = attendee.LastName, DisplayName = attendee.DisplayName
                };
                UserController.CreateUser(ref dnnUser);
            }
            dnnUser.FirstName         = attendee.FirstName.Trim();
            dnnUser.Profile.FirstName = attendee.FirstName.Trim();
            dnnUser.LastName          = attendee.LastName.Trim();
            dnnUser.Profile.LastName  = attendee.LastName.Trim();
            dnnUser.DisplayName       = attendee.DisplayName.Trim();
            dnnUser.Email             = attendee.Email.Trim();
            // Handle the picture
            if (attendee.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, attendee.ProfilePic.filename);
                if (file != null)
                {
                    dnnUser.Profile.Photo = file.FileId.ToString();
                    var portalId = dnnUser.IsSuperUser ? -1 : PortalSettings.PortalId;
                    FixDnnController.SetUserProfileProperty(portalId, dnnUser.UserID, "Photo", file.FileId.ToString());
                }
            }
            if (!string.IsNullOrEmpty(attendee.Company))
            {
                dnnUser.Profile.SetProfileProperty("Company", attendee.Company);
                var portalId = dnnUser.IsSuperUser ? -1 : PortalSettings.PortalId;
                FixDnnController.SetUserProfileProperty(portalId, dnnUser.UserID, "Company", attendee.Company);
            }
            UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            // DotNetNuke.Common.Utilities.DataCache.ClearCache();
            if (GetRouteParameter() == "home")
            {
                return(ReturnRoute("Home", "Index", "refreshcache=1"));
            }
            else
            {
                return(ReturnRoute(attendee.ConferenceId, View("View", _repository.GetAttendee(attendee.ConferenceId, attendee.UserId))));
            }
        }
Exemplo n.º 15
0
        public ActionResult Edit(int conferenceId, int attendeeId, AttendeeDTO attendee)
        {
            if (!ConferenceModuleContext.Security.CanManage)
            {
                if (User.UserID != attendeeId)
                {
                    ConferenceModuleContext.ThrowAccessViolation();
                }
            }
            AttendeeBase recordToUpdate = null;
            var          existingRecord = _repository.GetAttendee(conferenceId, attendeeId);
            var          modeAdd        = false;

            if (existingRecord == null)
            {
                recordToUpdate = new AttendeeBase()
                {
                    ConferenceId = conferenceId, UserId = attendeeId
                };
                modeAdd = true;
            }
            else
            {
                recordToUpdate = existingRecord.GetAttendeeBase();
            }
            recordToUpdate.ReceiveNotifications = attendee.ReceiveNotifications;
            recordToUpdate.Company = attendee.Company;
            if (modeAdd)
            {
                _repository.AddAttendee(recordToUpdate, User.UserID);
            }
            else
            {
                _repository.UpdateAttendee(recordToUpdate, User.UserID);
            }
            // Now the DNN side of things
            var dnnUser = DotNetNuke.Entities.Users.UserController.GetUserById(PortalSettings.PortalId, attendeeId);

            if (dnnUser == null)
            {
                // create the user
                dnnUser = new UserInfo()
                {
                    PortalID = PortalSettings.PortalId, Username = attendee.Email, Email = attendee.Email, FirstName = attendee.FirstName, LastName = attendee.LastName, DisplayName = attendee.DisplayName
                };
                UserController.CreateUser(ref dnnUser);
            }
            dnnUser.FirstName   = attendee.FirstName.Trim();
            dnnUser.LastName    = attendee.LastName.Trim();
            dnnUser.DisplayName = attendee.DisplayName.Trim();
            dnnUser.Email       = attendee.Email.Trim();
            // Handle the picture
            if (attendee.ProfilePic.filename != "")
            {
                IFileInfo file          = null;
                var       userFolder    = FolderManager.Instance.GetUserFolder(dnnUser);
                var       folderManager = FolderManager.Instance;
                file = FileManager.Instance.GetFile(userFolder, attendee.ProfilePic.filename);
                dnnUser.Profile.Photo = file.FileId.ToString();
                if (file != null & attendee.ProfilePic.crop.points != null)
                {
                    System.IO.MemoryStream sizedContent = null;
                    using (var content = FileManager.Instance.GetFileContent(file))
                    {
                        sizedContent = ImageUtils.CreateImage(content, attendee.ProfilePic.crop.points, attendee.ProfilePic.crop.zoom, 200, file.Extension);
                    }
                    FileManager.Instance.AddFile(userFolder, file.FileName, sizedContent, true, false, file.ContentType);
                    sizedContent.Dispose();
                    ImageUtils.CreateThumbnails(file.FileId);
                }
            }
            if (!string.IsNullOrEmpty(attendee.Company))
            {
                dnnUser.Profile.SetProfileProperty("Company", attendee.Company);
            }
            UserController.UpdateUser(PortalSettings.PortalId, dnnUser);
            DotNetNuke.Entities.Profile.ProfileController.UpdateUserProfile(dnnUser);
            return(ReturnRoute(attendee.ConferenceId, View("View", _repository.GetAttendee(attendee.ConferenceId, attendee.UserId))));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Gets the user available times.
        /// </summary>
        /// <param name="ssoToken">The sso access token used to make request against graph apis.</param>
        /// <param name="constraints">The time constraint for finding free times.</param>
        /// <param name="organizer">The organizer the ssoToken belongs to.</param>
        /// <param name="azureADSettings">The Azure AD application settings.</param>
        /// <param name="maxTimeSlots">The maximum number of time slots to return.</param>
        /// <param name="emailAddresses">Emails.</param>
        /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns>
        public static async Task<Dictionary<string, List<TimeBlock>>> GetAvailableTimeSlotsAsync(string ssoToken, IEnumerable<TimeSlot> constraints, AgentAvailability organizer, AzureADSettings azureADSettings, int? maxTimeSlots = null, IEnumerable<string> emailAddresses = null)
        {
            // setup graph client
            var authProvider = CreateOnBehalfOfProvider(azureADSettings, new[] { "Calendars.Read" });
            GraphServiceClient graphServiceClient = new GraphServiceClient(authProvider);

            // define the time constraints
            var timeConstaint = new TimeConstraint
            {
                ActivityDomain = ActivityDomain.Work,
                TimeSlots = constraints,
            };

            // add the attendees
            var attendees = new List<AttendeeBase>();
            foreach (var address in emailAddresses)
            {
                var attendee = new AttendeeBase
                {
                    Type = AttendeeType.Required,
                    EmailAddress = new EmailAddress
                    {
                        Address = address,
                    },
                };

                attendees.Add(attendee);
            }

            bool isMe = emailAddresses.Count() == 0;

            try
            {
                // perform the graph call for find meeting times
                var result = await graphServiceClient.Me.FindMeetingTimes(timeConstraint: timeConstaint, maxCandidates: maxTimeSlots, attendees: attendees, isOrganizerOptional: !isMe, minimumAttendeePercentage: 10)
                    .Request()
                    .WithUserAssertion(new UserAssertion(ssoToken))
                    .PostAsync();

                // return an empty collection if EmptySuggestionsReason returned
                if (!result.EmptySuggestionsReason.Equals(string.Empty))
                {
                    return new Dictionary<string, List<TimeBlock>>();
                }

                // pivot the results from timeblock centric to user centric
                Dictionary<string, List<TimeBlock>> dictionary = new Dictionary<string, List<TimeBlock>>();
                foreach (var timeslot in result.MeetingTimeSuggestions.ToList())
                {
                    if (isMe)
                    {
                        if (timeslot.OrganizerAvailability != FreeBusyStatus.Free)
                        {
                            continue;
                        }

                        if (!dictionary.ContainsKey(organizer.Emailaddress))
                        {
                            dictionary.Add(organizer.Emailaddress, new List<TimeBlock>());
                        }

                        dictionary[organizer.Emailaddress].Add(new TimeBlock()
                        {
                            StartDateTime = timeslot.MeetingTimeSlot.Start.ToDateTimeOffset().ToUniversalTime(),
                            EndDateTime = timeslot.MeetingTimeSlot.End.ToDateTimeOffset().ToUniversalTime(),
                        });
                    }
                    else
                    {
                        foreach (var agent in timeslot.AttendeeAvailability)
                        {
                            if (agent.Availability.GetValueOrDefault(FreeBusyStatus.Unknown) != FreeBusyStatus.Free)
                            {
                                continue;
                            }

                            if (!dictionary.ContainsKey(agent.Attendee.EmailAddress.Address))
                            {
                                dictionary.Add(agent.Attendee.EmailAddress.Address, new List<TimeBlock>());
                            }

                            dictionary[agent.Attendee.EmailAddress.Address].Add(new TimeBlock()
                            {
                                StartDateTime = timeslot.MeetingTimeSlot.Start.ToDateTimeOffset().ToUniversalTime(),
                                EndDateTime = timeslot.MeetingTimeSlot.End.ToDateTimeOffset().ToUniversalTime(),
                            });
                        }
                    }
                }

                return dictionary;
            }
            catch (Exception)
            {
                return new Dictionary<string, List<TimeBlock>>();
            }
        }