protected void Page_Load(object sender, EventArgs e) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { WBTeam owningTeam = workBox.OwningTeam; if (owningTeam == null) { LinkToOwner = "#"; } else { LinkToOwner = owningTeam.TeamSiteUrl; // Only need to set the text to the owning team's name if the text hasn't been set already: if (TextForLink == "") { TextForLink = owningTeam.Name; } WBUtils.logMessage("Found URL: " + LinkToOwner); } // This wont do anything because the web and site come from context, but still: workBox.Dispose(); } }
protected void DisposeWorkBox() { if (_workBox != null && !hasBeenDisposed) { _workBox.Dispose(); _workBox = null; hasBeenDisposed = true; } }
protected void Page_Unload(object sender, EventArgs e) { if (manager != null) { manager.Dispose(); manager = null; } if (workBox != null) { workBox.Dispose(); workBox = null; } }
protected override void CreateChildControls() { Label timeRemaining = new Label(); this.Controls.Add(timeRemaining); timeRemaining.CssClass = "wbf-time-to-auto-close"; try { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { DateTime endTime = workBox.calculateAutoCloseDate(); if (endTime.Year == WBRecordsType.YEAR_REPRESENTING_A_PERMANENT_DATE) { timeRemaining.Text = "This work box will not auto close."; } else { if (endTime < DateTime.Now) { timeRemaining.Text = "No time remaining before auto close."; } else { TimeSpan timeSpan = endTime - DateTime.Now; timeRemaining.Text = String.Format("{0} Days {1} Hours {2} Minutes", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes); } } workBox.Dispose(); } else { timeRemaining.Text = "You can only use this web part on a work box."; } } catch (Exception e) { WBLogging.Generic.Unexpected("Error: " + e.Message); timeRemaining.Text = "An error occurred"; } }
protected void Page_Load(object sender, EventArgs e) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { LinkToHome = workBox.Web.Url; if (TextForLink == "") { TextForLink = workBox.Web.Title; } // This wont do anything because the web and site come from context, but still: workBox.Dispose(); } }
protected void Page_Load(object sender, EventArgs e) { String redirectionURL = ""; String settingsPage = Request.QueryString["SettingsPage"]; String returnUrl = Request.QueryString["ReturnUrl"]; if (String.IsNullOrEmpty(settingsPage)) { settingsPage = "WorkBoxCollectionSettingsPage.aspx"; } // By default we will assume that we're either on the WBC or even that we are creating the WBC for the first time: redirectionURL = SPContext.Current.Web.Url + "/_layouts/WorkBoxFramework/" + settingsPage; // But if we are on a work box then we'll need to redirect to the wb collection's URL: WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox != null) { redirectionURL = workBox.Collection.Url + "/_layouts/WorkBoxFramework/" + settingsPage; // This will dispose of the WBCollection object too. workBox.Dispose(); } else { // Maybe we're on one of the container sites so the parent site will be the WBCollection: SPWeb parent = SPContext.Current.Web.ParentWeb; if (parent != null) { if (WBCollection.IsWebAWBCollection(parent)) { redirectionURL = parent.Url + "/_layouts/WorkBoxFramework/" + settingsPage; } parent.Dispose(); } } redirectionURL = redirectionURL + "?ReturnUrl=" + returnUrl; SPUtility.Redirect(redirectionURL, SPRedirectFlags.Static, Context); }
protected override void Render(HtmlTextWriter writer) { WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current); if (workBox == null) { errorLiteral.Text = "<i>(You can only use this web part in a work box)</i>"; } else { WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy seriesTags = WBTaxonomy.GetSeriesTags(recordsTypes); WBTerm thisSeries = workBox.SeriesTag(seriesTags); WBQuery query = new WBQuery(); query.AddEqualsFilter(WBColumn.RecordsType, workBox.RecordsType); if (FilterBySeriesTag) { query.AddEqualsFilter(WBColumn.SeriesTag, workBox.SeriesTag(seriesTags)); } if (FilterByReferenceID) { query.AddEqualsFilter(WBColumn.ReferenceID, workBox.ReferenceID); } // if (FilterByOwningTeam) // query.AddEqualsFilter(WBColumn.OwningTeam, workBox.OwningTeam); if (sortColumn != null) { WBLogging.Debug("Sorting in Render with sortColumn: " + sortColumn.DisplayName); } else { WBLogging.Debug("Sorting Render - sortColumn was null"); } if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); query.AddViewColumn(WBColumn.ReferenceDate); query.AddViewColumn(WBColumn.WorkBoxStatus); WBColumn testIfIsThisWorkBox = new WBColumn("IfIsThisWorkBox", WBColumn.DataTypes.VirtualConditional); testIfIsThisWorkBox.TestColumnInternalName = WBColumn.Title.InternalName; testIfIsThisWorkBox.TestColumnValue = workBox.Title; testIfIsThisWorkBox.ValueIfEqual = "===>"; query.AddViewColumn(testIfIsThisWorkBox); DataTable dataTable = workBox.Collection.Query(query); gridView.DataSource = new DataView(dataTable); BoundField testIfIsThisWorkBoxField = WBUtils.BoundField(testIfIsThisWorkBox, HorizontalAlign.Center, sortColumn, ascending); testIfIsThisWorkBoxField.HeaderText = " "; gridView.Columns.Add(testIfIsThisWorkBoxField); gridView.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); gridView.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, sortColumn, ascending)); gridView.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending)); gridView.DataBind(); if (ShowCreateNewLink) { string createNewText = workBox.RecordsType.CreateNewWorkBoxText; string createNewURL = workBox.Collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__DYNAMIC); createNewLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500); \">" + createNewText + "</a>"; } workBox.Dispose(); } base.Render(writer); }
protected void Page_Load(object sender, EventArgs e) { string localID = Request.QueryString["LocalID"]; if (localID == null || localID == "") { localID = Request.QueryString["IASClientID"]; } if (localID == null || localID == "") { ErrorMessage.Text = "Could not find the LocalID on the request parameters."; return; } bool justFind = false; string justFindString = Request.QueryString["JustFind"]; if (justFindString != null && justFindString != "") { WBUtils.logMessage("Testing JustFind = " + justFindString); justFind = true.ToString().ToLower().Equals(justFindString.ToLower()); WBUtils.logMessage("Testing justFind = " + justFind); WBUtils.logMessage("true.ToString() = " + true.ToString()); } else { WBUtils.logMessage("No JustFind query parameter"); } using (WBCollection collection = new WBCollection(SPContext.Current)) { WorkBox workBox = collection.FindByLocalID(localID); if (workBox == null) { WBUtils.logMessage(" workBox was NULL"); } if (workBox == null && justFind) { string html = "<h3>There is no work box with ID: " + localID + "</h3>\n"; html += "<a href=\"routing.aspx?LocalID=" + localID + "&justFind=false\">Click here to create a new work box with this ID</a>\n"; DoesNotExistYet.Text = html; } else { using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { if (workBox == null) { longOperation.LeadingHTML = "No documents found: creating new work box."; longOperation.TrailingHTML = "This service user doesn't yet have a work box so it is being created."; } else { longOperation.LeadingHTML = "Found service user's work box."; longOperation.TrailingHTML = "Please wait while the work box is opened."; } longOperation.Begin(); collection.Site.AllowUnsafeUpdates = true; collection.Web.AllowUnsafeUpdates = true; if (workBox == null) { workBox = collection.RequestNewWorkBox("", localID); } if (workBox.HasBeenCreated) { workBox.Web.AllowUnsafeUpdates = true; } if (!workBox.HasBeenOpened) { workBox.Open(); } string workBoxUrl = workBox.Url; workBox.Web.AllowUnsafeUpdates = false; collection.Web.AllowUnsafeUpdates = false; collection.Site.AllowUnsafeUpdates = false; workBox.Dispose(); longOperation.End(workBoxUrl, SPRedirectFlags.Static, Context, ""); } } } }
/// <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); }
protected void createNewButton_OnClick(object sender, EventArgs e) { Hashtable metadataProblems = checkMetadataState(); if (metadataProblems.Count > 0) { RecordsTypeFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__RECORDS_TYPE].WBxToString(); FunctionalAreaFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__FUNCTIONAL_AREA].WBxToString(); WorkBoxShortTitleMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__WORK_BOX_SHORT_TITLE].WBxToString(); ReferenceIDMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_ID].WBxToString();; ReferenceDateMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__REFERENCE_DATE].WBxToString();; SeriesTagFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SERIES_TAG].WBxToString(); OwningTeamFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__OWNING_TEAM].WBxToString(); InvolvedTeamsFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__INVOLVED_TEAMS].WBxToString(); pageRenderingRequired = true; } else { pageRenderingRequired = false; } // The event should only be processed if there is no other need to render the page again if (pageRenderingRequired) { renderPage(); } else { WBCollection collection = new WBCollection(WorkBoxCollectionUrl.Value); collection.Web.AllowUnsafeUpdates = true; WBUtils.logMessage("OK so we've set to allow unsafe updates of the WorkBoxCollectionWeb"); string selectedWorkBoxTemplateValue = WorkBoxTemplateID.Value; if (selectedWorkBoxTemplateValue == "") { selectedWorkBoxTemplateValue = WorkBoxTemplates.SelectedValue; } int templateID = Convert.ToInt32(selectedWorkBoxTemplateValue); WBTemplate template = collection.GetTypeByID(templateID); WBTeam owningTeam = new WBTeam(teams, OwningTeamUIControlValue.Value); WBTermCollection <WBTeam> involvedTeams = new WBTermCollection <WBTeam>(teams, InvolvedTeamsField.Text); Hashtable extraValues = null; extraValues = new Hashtable(); if (ReferenceID.Text != "") { extraValues.Add(WorkBox.COLUMN_NAME__REFERENCE_ID, ReferenceID.Text); } if (!ReferenceDate.IsDateEmpty) { extraValues.Add(WorkBox.COLUMN_NAME__REFERENCE_DATE, ReferenceDate.SelectedDate); } if (SeriesTagDropDownList.SelectedValue != "") { extraValues.Add(WorkBox.COLUMN_NAME__SERIES_TAG, SeriesTagDropDownList.SelectedValue); } if (functionalAreaFieldIsEditable) { extraValues.Add(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, FunctionalAreaField.Text); } else { extraValues.Add(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, workBoxRecordsType.DefaultFunctionalArea(functionalAreas).UIControlValue); } WBLogging.Generic.Unexpected("Owning team has values: " + owningTeam.Name + " " + owningTeam.Id); WorkBox newWorkBox = collection.RequestNewWorkBox(WorkBoxShortTitle.Text, "", template, owningTeam, involvedTeams, extraValues); if (newWorkBox == null) { string pageTitle = Uri.EscapeDataString("Failed to create new work box"); string pageText = Uri.EscapeDataString("Your request to create a new work box was not successful."); string redirectUrl = "WorkBoxFramework/GenericOKPage.aspx"; string queryString = "pageTitle=" + pageTitle + "&pageText=" + pageText; SPUtility.Redirect(redirectUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } collection.Web.AllowUnsafeUpdates = false; using (SPLongOperation longOperation = new SPLongOperation(this.Page)) { longOperation.LeadingHTML = "Creating your new work box."; longOperation.TrailingHTML = "Please wait while the work box is being created."; longOperation.Begin(); newWorkBox.Open("Requested via NewWorkBox.aspx."); if (relatedWorkBox != null) { switch (RelationType.Value) { case WorkBox.RELATION_TYPE__DYNAMIC: break; case WorkBox.RELATION_TYPE__MANUAL_LINK: { relatedWorkBox.LinkToWorkBox(newWorkBox, WorkBox.RELATION_TYPE__MANUAL_LINK); break; } case WorkBox.RELATION_TYPE__CHILD: { relatedWorkBox.LinkToWorkBox(newWorkBox, WorkBox.RELATION_TYPE__CHILD); newWorkBox.LinkToWorkBox(relatedWorkBox, WorkBox.RELATION_TYPE__PARENT); break; } default: { WBUtils.shouldThrowError("Did not recognise the relation type: " + RelationType.Value); break; } } relatedWorkBox.Dispose(); } collection.Dispose(); string html = "<h1>Successfully created</h1><p>Your new work box has been successfully created.</p>"; html += String.Format("<p>Go to your new work box: <a href=\"#\" onclick=\"javascript: dialogReturnOKAndRedirect('{0}');\">{1}</a></p>", newWorkBox.Url, newWorkBox.Title); string pageTitle = Uri.EscapeDataString("Created new work box"); string pageText = Uri.EscapeDataString(html); string okPageUrl = "WorkBoxFramework/GenericOKPage.aspx"; string refreshQueryString = "?recordsTypeGUID=" + newWorkBox.RecordsType.Id.ToString(); newWorkBox.Dispose(); string queryString = "pageTitle=" + pageTitle + "&pageText=" + pageText + "&refreshQueryString=" + refreshQueryString; longOperation.End(okPageUrl, SPRedirectFlags.RelativeToLayoutsPage, Context, queryString); } } }
private void renderPage() { if (pageRendered) { return; } WBLogging.Generic.Unexpected("Rendering 'New Work Box' page"); WBCollection collection = new WBCollection(WorkBoxCollectionUrl.Value); CreateNewWorkBoxText.Text = workBoxRecordsType.CreateNewWorkBoxText; RecordsType.Text = workBoxRecordsType.FullPath.Replace("/", " / "); string namingConvention = workBoxRecordsType.WorkBoxNamingConvention; string uniqueIDprefix = workBoxRecordsType.WorkBoxUniqueIDPrefix; if (uniqueIDprefix != "") { namingConvention = namingConvention.Replace("<Unique ID Prefix>", uniqueIDprefix); namingConvention = namingConvention.Replace("<UID Prefix>", uniqueIDprefix); } WorkBoxNamingConvention.Text = namingConvention.Replace("<", "<").Replace(">", ">"); DataView templates = GetTemplatesDataSource(collection, workBoxRecordsType); if (templates.Count == 0) { NoTemplatesError.Text = "There are no templates for this work box records type!"; onlyOneWorkBoxTemplate = true; } else { if (templates.Count == 1) { DataRow theTemplate = templates.Table.Rows[0]; onlyOneWorkBoxTemplate = true; WorkBoxTemplate.Text = theTemplate["WorkBoxTemplateTextField"].WBxToString(); WorkBoxTemplateID.Value = theTemplate["WorkBoxTemplateValueField"].WBxToString(); } else { onlyOneWorkBoxTemplate = false; WorkBoxTemplates.DataSource = templates; WorkBoxTemplates.DataTextField = "WorkBoxTemplateTextField"; WorkBoxTemplates.DataValueField = "WorkBoxTemplateValueField"; WorkBoxTemplates.DataBind(); WBTemplate defaultTemplate = collection.DefaultTemplate(workBoxRecordsType); if (defaultTemplate != null) { WorkBoxTemplates.SelectedValue = defaultTemplate.ID.ToString(); } // We're going to use the fact that this hidden field is blank to assume // that there was more than one value: WorkBoxTemplateID.Value = ""; } } if (functionalAreaFieldIsEditable) { functionalAreas.InitialiseTaxonomyControl(FunctionalAreaField, WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, true, true, null); if (!IsPostBack && functionalAreaInitialValue != null) { FunctionalAreaField.Text = functionalAreaInitialValue; } } else { ReadOnlyFunctionalAreaField.Text = workBoxRecordsType.DefaultFunctionalArea(functionalAreas).Names(); } // teams.InitialiseTaxonomyControl(OwningTeamField, WorkBox.COLUMN_NAME__OWNING_TEAM, false); teams.InitialiseTaxonomyControl(InvolvedTeamsField, WorkBox.COLUMN_NAME__INVOLVED_TEAMS, true); showShortTitle = workBoxRecordsType.WorkBoxShortTitleRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; if (showShortTitle) { if (workBoxRecordsType.IsWorkBoxShortTitleRequired) { ShortTitleTitle.Text = "Short Title" + WBConstant.REQUIRED_ASTERISK; } else { ShortTitleTitle.Text = "Short Title (optional)"; } ShortTitleDescription.Text = workBoxRecordsType.WorkBoxShortTitleDescription; } showReferenceID = workBoxRecordsType.WorkBoxReferenceIDRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; if (showReferenceID) { if (workBoxRecordsType.IsWorkBoxReferenceIDRequired) { ReferenceIDTitle.Text = "Reference ID" + WBConstant.REQUIRED_ASTERISK; } else { ReferenceIDTitle.Text = "Reference ID (optional)"; } ReferenceIDDescription.Text = workBoxRecordsType.WorkBoxReferenceIDDescription; // ReferenceID.Text = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__REFERENCE_ID); } showReferenceDate = workBoxRecordsType.WorkBoxReferenceDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; if (showReferenceDate) { // Setting the local to a value that should make the date format DD/MM/YYYY // ReferenceDate.LocaleId = 2057; if (workBoxRecordsType.IsWorkBoxReferenceDateRequired) { ReferenceDateTitle.Text = "Reference Date" + WBConstant.REQUIRED_ASTERISK; } else { ReferenceDateTitle.Text = "Reference Date (optional)"; } ReferenceDateDescription.Text = workBoxRecordsType.WorkBoxReferenceDateDescription; /* * if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__REFERENCE_DATE)) * { * ReferenceDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__REFERENCE_DATE]; * } * else * { * } * */ } showSeriesTag = workBoxRecordsType.WorkBoxSeriesTagRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN; if (showSeriesTag) { if (workBoxRecordsType.IsWorkBoxSeriesTagRequired) { SeriesTagTitle.Text = "Series Tag" + WBConstant.REQUIRED_ASTERISK; } else { SeriesTagTitle.Text = "Series Tag (optional)"; } SeriesTagDescription.Text = workBoxRecordsType.DocumentSeriesTagDescription; SeriesTagDropDownList.DataSource = GetSeriesTagsDataSource(workBoxRecordsType.WorkBoxSeriesTagParentTerm(seriesTags)); SeriesTagDropDownList.DataTextField = "SeriesTagTermName"; SeriesTagDropDownList.DataValueField = "SeriesTagTermUIControlValue"; SeriesTagDropDownList.DataBind(); if (!IsPostBack && seriesTagInitialValue != "") { if (SeriesTagDropDownList.Items.FindByValue(seriesTagInitialValue) != null) { SeriesTagDropDownList.SelectedValue = seriesTagInitialValue; } } } ErrorMessageLabel.Text = errorMessage; if (functionalAreaFieldIsEditable) { FunctionalAreaField.Focus(); } else { if (!onlyOneWorkBoxTemplate) { WorkBoxTemplates.Focus(); } else { if (showShortTitle) { WorkBoxShortTitle.Focus(); } else { // Just to have the focus somewhere: InvolvedTeamsField.Focus(); } } } if (relatedWorkBox != null) { relatedWorkBox.Dispose(); } collection.Dispose(); pageRendered = true; }
/// <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); }