protected void removeButton_OnClick(object sender, EventArgs e)
        {
            AreYouSureText.Text = "Something went wrong when trying to remove the indiviual or team.";

            if (TeamOrIndividual.Value == "Team" && team != null)
            {
                if (InvolvedOrVisiting.Value == "Involved")
                {
                    WBTermCollection <WBTeam> involvedTeams = WorkBox.InvolvedTeams;
                    involvedTeams.Remove(team);

                    WorkBox.InvolvedTeams = involvedTeams;
                    WorkBox.AuditLogEntry("Removed team", "No longer involved: " + team.Name);
                    WorkBox.Update();
                }
                else
                {
                    WBTermCollection <WBTeam> visitingTeams = WorkBox.VisitingTeams;

                    visitingTeams.Remove(team);

                    WorkBox.VisitingTeams = visitingTeams;
                    WorkBox.AuditLogEntry("Removed team", "No longer visiting: " + team.Name);
                    WorkBox.Update();
                }

                CloseDialogAndRefresh();
            }

            if (TeamOrIndividual.Value == "Individual" && user != null)
            {
                if (InvolvedOrVisiting.Value == "Involved")
                {
                    List <SPUser> involvedUsers = WorkBox.InvolvedIndividuals;

                    involvedUsers = WBUtils.RemoveUser(involvedUsers, user);

                    WorkBox.InvolvedIndividuals = involvedUsers;
                    WorkBox.AuditLogEntry("Removed individual", "No longer involved: " + user.Name);
                    WorkBox.Update();
                }
                else
                {
                    List <SPUser> visitingUsers = WorkBox.VisitingIndividuals;
                    visitingUsers = WBUtils.RemoveUser(visitingUsers, user);
                    WorkBox.VisitingIndividuals = visitingUsers;
                    WorkBox.AuditLogEntry("Removed individual", "No longer visiting: " + user.Name);
                    WorkBox.Update();
                }

                CloseDialogAndRefresh();
            }

            DisposeWorkBox();
        }
Example #2
0
        protected void saveButton_OnClick(object sender, EventArgs e)
        {
            WorkBox.InvolvedIndividuals = InvolvedIndividualsControl.WBxGetMultiResolvedUsers(SPContext.Current.Web);
            WorkBox.VisitingIndividuals = VisitingIndividualsControl.WBxGetMultiResolvedUsers(SPContext.Current.Web);

            WorkBox.Update();

            DisposeWorkBox();

            CloseDialogAndRefresh();
        }
Example #3
0
        protected void changeOwnerButton_OnClick(object sender, EventArgs e)
        {
            // The event should only be processed if there is no other need to render the page again
            if (!pageRenderingRequired)
            {
                // Now to save the current value of the Involved Teams field:

                WorkBox.OwningTeam = new WBTeam(WorkBox.Teams, OwningTeamField.Text);

                WorkBox.AuditLogEntry("Changed owner", "Owning team: " + WorkBox.OwningTeam.Name);
                WorkBox.Update();

                DisposeWorkBox();

                CloseDialogAndRefresh();
            }
        }
Example #4
0
        protected void saveButton_OnClick(object sender, EventArgs e)
        {
            // The event should only be processed if there is no other need to render the page again
            if (!pageRenderingRequired)
            {
                // Now to save the current value of the Involved Teams field:

                WorkBox.InvolvedTeams = new WBTermCollection <WBTeam>(WorkBox.Teams, InvolvedTeamsField.Text);
                WorkBox.VisitingTeams = new WBTermCollection <WBTeam>(WorkBox.Teams, VisitingTeamsField.Text);

                WorkBox.Update();

                DisposeWorkBox();

                //returnFromDialogOK("The involved teams have been updated");
                CloseDialogAndRefresh();
            }
        }
        protected void saveButton_OnClick(object sender, EventArgs e)
        {
            try
            {
                bool digestOK = WorkBox.Web.ValidateFormDigest();

                if (digestOK)
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite elevatedSite = new SPSite(WorkBox.Site.ID))
                            using (SPWeb elevatedWorkBoxWeb = elevatedSite.OpenWeb(WorkBox.Web.ID))
                            {
                                elevatedSite.AllowUnsafeUpdates       = true;
                                elevatedWorkBoxWeb.AllowUnsafeUpdates = true;

                                WorkBox elevatedWorkBox    = new WorkBox(elevatedSite, elevatedWorkBoxWeb);
                                elevatedWorkBox.ShortTitle = WorkBoxShortTitle.Text;
                                elevatedWorkBox.Web.Title  = WorkBoxPrettyTitle.Text;
                                elevatedWorkBox.GenerateTitle();

                                if (showReferenceID)
                                {
                                    elevatedWorkBox.ReferenceID = ReferenceID.Text;
                                }

                                if (showReferenceDate)
                                {
                                    if (!ReferenceDate.IsDateEmpty)
                                    {
                                        elevatedWorkBox.ReferenceDate = ReferenceDate.SelectedDate;
                                    }
                                }

                                elevatedWorkBox.Update();
                            }
                    });
                }
            }
            catch (Exception exception)
            {
                WBUtils.SendErrorReport(SPContext.Current.Web, "Exception in EditWorkBoxPropertise.saveButton_OnClick()", "Something went wrong when saving: " + exception.Message + " ... " + exception.StackTrace);
                throw new NotImplementedException("Something went wrong when saving the properties changes");
            }

            WBFarm farm = WBFarm.Local;
            String cachedDetailsListUrl = farm.OpenWorkBoxesCachedDetailsListUrl;

            if (!String.IsNullOrEmpty(cachedDetailsListUrl))
            {
                using (SPSite cacheSite = new SPSite(cachedDetailsListUrl))
                    using (SPWeb cacheWeb = cacheSite.OpenWeb())
                    {
                        SPList cacheList = cacheWeb.GetList(cachedDetailsListUrl);

                        SPServiceContext   serviceContext = SPServiceContext.GetContext(cacheSite);
                        UserProfileManager profileManager = new UserProfileManager(serviceContext);

                        // Get the current user's user profile:
                        UserProfile profile = profileManager.GetUserProfile(true);

                        // We're using the 'now' plus one hour ticks as we're not really looking to update the last modified dates of other work boxes.
                        WBUser.CheckLastModifiedDatesAndTitlesOfRecentWorkBoxes(cacheSite, cacheList, profile, DateTime.Now.AddHours(1).Ticks);

                        WBUser.CheckTitlesOfFavouriteWorkBoxes(cacheSite, cacheList, profile);
                    }
            }

            returnFromDialogOK("");
        }
Example #6
0
        protected void inviteButton_OnClick(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(TeamsToInviteControl.Text))
            {
                InvolvedTeamsFieldMessage.Text = "You must enter at least one team to invite";
                return;
            }


            WBTermCollection <WBTeam> newTeams = new WBTermCollection <WBTeam>(teamsTaxonomy, TeamsToInviteControl.Text);

            String newTeamsString = newTeams.Names().Replace(";", ",");

            if (InviteType.SelectedValue == "Involved")
            {
                WBTermCollection <WBTeam> involvedTeams = WorkBox.InvolvedTeams;
                involvedTeams.Add(newTeams);
                WorkBox.InvolvedTeams = involvedTeams;
                WorkBox.AuditLogEntry("Invited teams", "Involved: " + newTeamsString);
                WorkBox.Update();
            }
            else
            {
                WBTermCollection <WBTeam> visitingTeams = WorkBox.VisitingTeams;
                visitingTeams.Add(newTeams);
                WorkBox.VisitingTeams = visitingTeams;
                WorkBox.AuditLogEntry("Invited teams", "Visiting: " + newTeamsString);
                WorkBox.Update();
            }

            if (SendInviteEmail.Checked)
            {
                String subjectTemplate = EmailSubject.Text;
                String bodyTemplate    = EmailBody.Text;

                if (SendAsOne.Checked)
                {
                    StringDictionary headers = new StringDictionary();

                    List <String> emailAddresses = new List <String>();

                    foreach (WBTeam team in newTeams)
                    {
                        foreach (SPUser user in team.MembersGroup(SPContext.Current.Site).Users)
                        {
                            if (!emailAddresses.Contains(user.Email))
                            {
                                emailAddresses.Add(user.Email);
                            }
                        }
                    }

                    headers.Add("to", String.Join(";", emailAddresses.ToArray()));
                    headers.Add("content-type", "text/html"); //This is the default type, so isn't neccessary.

                    if (CCToYou.Checked)
                    {
                        headers.Add("cc", SPContext.Current.Web.CurrentUser.Email);
                    }

                    String subject = WBUtils.ProcessEmailTemplate(WorkBox, subjectTemplate, false);
                    String body    = WBUtils.ProcessEmailTemplate(WorkBox, bodyTemplate, true);

                    headers.Add("subject", subject);

                    WBUtils.SendEmail(SPContext.Current.Web, headers, body);
                }
                else
                {
                    List <String> emailAddresses = new List <String>();

                    foreach (WBTeam team in newTeams)
                    {
                        foreach (SPUser user in team.MembersGroup(SPContext.Current.Site).Users)
                        {
                            // Check if we're emailed this person already:
                            if (!emailAddresses.Contains(user.Email))
                            {
                                emailAddresses.Add(user.Email);

                                StringDictionary headers = new StringDictionary();

                                headers.Add("to", user.Email);
                                headers.Add("content-type", "text/html"); //This is the default type, so isn't neccessary.

                                if (CCToYou.Checked)
                                {
                                    headers.Add("cc", SPContext.Current.Web.CurrentUser.Email);
                                }

                                String subject = WBUtils.ProcessEmailTemplate(WorkBox, null, user, subjectTemplate, false);
                                String body    = WBUtils.ProcessEmailTemplate(WorkBox, null, user, bodyTemplate, true);

                                headers.Add("subject", subject);

                                WBUtils.SendEmail(SPContext.Current.Web, headers, body);
                            }
                        }
                    }
                }
            }


            DisposeWorkBox();

            CloseDialogAndRefresh();
        }
        protected void inviteButton_OnClick(object sender, EventArgs e)
        {
            List <SPUser> newUsers = IndividualsToInviteControl.WBxGetMultiResolvedUsers(SPContext.Current.Web);

            if (newUsers.Count == 0)
            {
                IndividualsToInviteFieldMessage.Text = "You must enter at least one individual to invite.";
                return;
            }

            List <String> newUsersNames = new List <String>();

            foreach (SPUser user in newUsers)
            {
                newUsersNames.Add(user.Name);
            }
            String newUsersString = String.Join(", ", newUsersNames.ToArray());

            if (InviteType.SelectedValue == "Involved")
            {
                List <SPUser> involvedUsers = WorkBox.InvolvedIndividuals;
                involvedUsers.AddRange(newUsers);
                WorkBox.InvolvedIndividuals = involvedUsers;
                WorkBox.AuditLogEntry("Invited individuals", "Involved: " + newUsersString);
                WorkBox.Update();
            }
            else
            {
                List <SPUser> visitingUsers = WorkBox.VisitingIndividuals;
                visitingUsers.AddRange(newUsers);
                WorkBox.VisitingIndividuals = visitingUsers;
                WorkBox.AuditLogEntry("Invited individuals", "Visiting: " + newUsersString);
                WorkBox.Update();
            }

            if (SendInviteEmail.Checked)
            {
                String subjectTemplate = EmailSubject.Text;
                String bodyTemplate    = EmailBody.Text;

                if (SendAsOne.Checked)
                {
                    StringDictionary headers = new StringDictionary();

                    List <String> emailAddresses = new List <String>();
                    foreach (SPUser user in newUsers)
                    {
                        emailAddresses.Add(user.Email);
                    }

                    headers.Add("to", String.Join(";", emailAddresses.ToArray()));
                    headers.Add("content-type", "text/html"); //This is the default type, so isn't neccessary.

                    if (CCToYou.Checked)
                    {
                        headers.Add("cc", SPContext.Current.Web.CurrentUser.Email);
                    }

                    String subject = WBUtils.ProcessEmailTemplate(WorkBox, subjectTemplate, false);
                    String body    = WBUtils.ProcessEmailTemplate(WorkBox, bodyTemplate, true);

                    headers.Add("subject", subject);

                    WBUtils.SendEmail(SPContext.Current.Web, headers, body);
                }
                else
                {
                    foreach (SPUser user in newUsers)
                    {
                        StringDictionary headers = new StringDictionary();

                        headers.Add("to", user.Email);
                        headers.Add("content-type", "text/html"); //This is the default type, so isn't neccessary.

                        if (CCToYou.Checked)
                        {
                            headers.Add("cc", SPContext.Current.Web.CurrentUser.Email);
                        }

                        String subject = WBUtils.ProcessEmailTemplate(WorkBox, null, user, subjectTemplate, false);
                        String body    = WBUtils.ProcessEmailTemplate(WorkBox, null, user, bodyTemplate, true);

                        headers.Add("subject", subject);

                        WBUtils.SendEmail(SPContext.Current.Web, headers, body);
                    }
                }
            }


            DisposeWorkBox();

            CloseDialogAndRefresh();
        }