Exemple #1
0
 public void ConnectToSite(SPSite site)
 {
     _site = site;
     _recordsTypesTaxonomy    = WBTaxonomy.GetRecordsTypes(site);
     _functionalAreasTaxonomy = WBTaxonomy.GetFunctionalAreas(_recordsTypesTaxonomy);
     _subjectTagsTaxonomy     = WBTaxonomy.GetSubjectTags(_recordsTypesTaxonomy);
     _teamsTaxonomy           = WBTaxonomy.GetTeams(_recordsTypesTaxonomy);
 }
Exemple #2
0
        public static void SyncAllTeams(SPSite site)
        {
            WBTaxonomy teams = WBTaxonomy.GetTeams(site);

            WBLogging.Teams.Verbose("Syncing all teams within the TermSet: " + teams.TermSet.Name);

            WBFarm farm = WBFarm.Local;

            using (SPSite teamsSite = new SPSite(farm.TeamSitesSiteCollectionUrl))
            {
                SyncAllSubTeams(teams, teams.TermSet.Terms, teamsSite, site);
            }
        }
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            WBLogging.Teams.Unexpected("In WBTeamSiteCalendarChangeEventReceiver(): Requesting a new team event");

            using (WBCollection collection = new WBCollection("http://workboxportals/projects"))
                using (SPSite teamsSite = new SPSite(properties.WebUrl))
                    using (SPWeb teamsWeb = teamsSite.OpenWeb())
                    {
                        WBTaxonomy teams = WBTaxonomy.GetTeams(collection.Site);
                        WBTeam     team  = WBTeam.GetFromTeamSite(teams, teamsWeb);

                        if (team == null)
                        {
                            WBLogging.Teams.Unexpected("Didn't find a team for this calender creation event!!!");
                        }
                        else
                        {
                            WBLogging.Teams.Unexpected("Found team: " + team.Name + " | " + team.TeamSiteUrl);
                        }


                        DateTime eventDate = DateTime.Now;
                        if (properties.ListItem["EventDate"] == null)
                        {
                            if (properties.AfterProperties["EventDate"] == null)
                            {
                                WBLogging.Teams.Unexpected("Both ListItem and AfterProperties have null for 'EventDate' !!");
                            }
                            else
                            {
                                eventDate = (DateTime)properties.AfterProperties["EventDate"];
                            }
                        }
                        else
                        {
                            eventDate = (DateTime)properties.ListItem["EventDate"];
                        }

                        DateTime endDate = DateTime.Now.AddHours(1);
                        if (properties.ListItem["EndDate"] == null)
                        {
                            if (properties.AfterProperties["EndDate"] == null)
                            {
                                WBLogging.Teams.Unexpected("Both ListItem and AfterProperties have null for 'EndDate' !!");
                            }
                            else
                            {
                                endDate = (DateTime)properties.AfterProperties["EndDate"];
                            }
                        }
                        else
                        {
                            endDate = (DateTime)properties.ListItem["EndDate"];
                        }

                        WBLogging.Teams.Unexpected(" Start End times are: " + eventDate + " and " + endDate);

                        String title = properties.ListItem["Title"].WBxToString();

                        WBLogging.Teams.Unexpected(" Title is: " + title);

                        String description = "Changed"; // properties.ListItem["Description"].WBxToString();

                        WBLogging.Teams.Unexpected(" description is: " + description);

                        WorkBox workBox = collection.RequestNewEventWorkBox(
                            properties.List.DefaultViewUrl,
                            properties.List.ID,
                            properties.ListItemId,
                            title,
                            description,
                            eventDate,
                            endDate,
                            team,
                            null,
                            "Meeting");

                        workBox.Open("Opening work box triggered by new event in a calendar.");

                        workBox.Dispose();
                    }

            base.ItemAdded(properties);
        }
Exemple #4
0
 public static WBTeam GetFromTeamSite(SPContext context)
 {
     return(GetFromTeamSite(WBTaxonomy.GetTeams(context.Site), context.Web));
 }
Exemple #5
0
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            WBLogging.Teams.Unexpected("In WBLinkedCalendarUpdatesEventReceiver(): Requesting a new team event");

            if (properties.List == null)
            {
                WBLogging.Teams.Unexpected("The properties.List value was null!");
                return;
            }
            else
            {
                WBLogging.Teams.Unexpected("Calendar item added to list: " + properties.List.DefaultViewUrl);
            }

            String workBoxCollectionURL = properties.List.WBxGetProperty(WorkBox.LIST_PROPERTY__LINKED_CALENDAR__WORK_BOX_COLLECTION);
            String defaultTemplateTitle = properties.List.WBxGetProperty(WorkBox.LIST_PROPERTY__LINKED_CALENDAR__DEFAULT_TEMPLATE_TITLE);

            if (String.IsNullOrEmpty(workBoxCollectionURL) || String.IsNullOrEmpty(defaultTemplateTitle))
            {
                WBLogging.Teams.Unexpected("The linked calendar configuration properties were blank: " + workBoxCollectionURL + " | " + defaultTemplateTitle);
                return;
            }

            using (WBCollection collection = new WBCollection(workBoxCollectionURL))
                using (SPSite calendarSite = new SPSite(properties.WebUrl))
                    using (SPWeb calendarWeb = calendarSite.OpenWeb())
                    {
                        WorkBox onWorkBox = WorkBox.GetIfWorkBox(calendarSite, calendarWeb);

                        WBTaxonomy teams           = WBTaxonomy.GetTeams(collection.Site);
                        WBTeam     eventOwningTeam = WBTeam.GetFromTeamSite(teams, calendarWeb);

                        if (eventOwningTeam == null && onWorkBox != null)
                        {
                            eventOwningTeam = onWorkBox.OwningTeam;
                        }

                        if (eventOwningTeam == null)
                        {
                            WBLogging.Teams.Unexpected("Didn't find an eventOwningTeam for this calender creation event!!!");
                        }
                        else
                        {
                            WBLogging.Teams.Unexpected("Found team: " + eventOwningTeam.Name + " | " + eventOwningTeam.TeamSiteUrl);
                        }


                        DateTime eventDate = DateTime.Now;
                        if (properties.ListItem["EventDate"] == null)
                        {
                            if (properties.AfterProperties["EventDate"] == null)
                            {
                                WBLogging.Teams.Unexpected("Both ListItem and AfterProperties have null for 'EventDate' !!");
                            }
                            else
                            {
                                eventDate = (DateTime)properties.AfterProperties["EventDate"];
                            }
                        }
                        else
                        {
                            eventDate = (DateTime)properties.ListItem["EventDate"];
                        }

                        DateTime endDate = DateTime.Now.AddHours(1);
                        if (properties.ListItem["EndDate"] == null)
                        {
                            if (properties.AfterProperties["EndDate"] == null)
                            {
                                WBLogging.Teams.Unexpected("Both ListItem and AfterProperties have null for 'EndDate' !!");
                            }
                            else
                            {
                                endDate = (DateTime)properties.AfterProperties["EndDate"];
                            }
                        }
                        else
                        {
                            endDate = (DateTime)properties.ListItem["EndDate"];
                        }

                        WBLogging.Teams.Unexpected(" Start End times are: " + eventDate + " and " + endDate);

                        String title = properties.ListItem["Title"].WBxToString();

                        WBLogging.Teams.Unexpected(" Title is: " + title);

                        String description = "Changed"; // properties.ListItem["Description"].WBxToString();

                        WBLogging.Teams.Unexpected(" description is: " + description);

                        String calendarURL = calendarSite.Url + properties.List.DefaultViewUrl;

                        WorkBox workBox = collection.RequestNewEventWorkBox(
                            calendarURL,
                            properties.List.ID,
                            properties.ListItemId,
                            title,
                            description,
                            eventDate,
                            endDate,
                            eventOwningTeam,
                            null,
                            defaultTemplateTitle);

                        workBox.Open("Opening work box triggered by new event in a calendar.");

                        workBox.Dispose();
                    }

            base.ItemAdded(properties);
        }