protected void Page_Load(object sender, EventArgs e) { webPart = this.Parent as RelatedMeetings; if (webPart.MeetingsWorkBoxCollectionURL == null || webPart.MeetingsWorkBoxCollectionURL == "") { CreateNewMeetingLink.Text = "(Web part not configured yet)"; return; } using (WorkBox workBox = new WorkBox(SPContext.Current)) { if (workBox.LinkedWorkBoxesList == null) { CreateNewMeetingLink.Text = "(Work Box doesn't have a related items list)"; return; } DataTable dataTable = createDataTable(); addRelatedWorkBoxesToDataTable(workBox.LinkedWorkBoxesList, dataTable); RelatedMeetings.DataSource = dataTable; RelatedMeetings.DataBind(); using (WBCollection collection = new WBCollection(webPart.MeetingsWorkBoxCollectionURL)) { string createNewURL = collection.GetUrlForNewDialog(workBox, WorkBox.RELATION_TYPE__CHILD); string createNewText = "Create New Meeting"; // collection.CreateNewWorkBoxText; CreateNewMeetingLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 600, 500);\">" + createNewText + "</a>"; } } }
void PopulateControls() { if (!IsPostBack) { WBCollection collection = new WBCollection(SPContext.Current); WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site); teams.InitialiseTaxonomyControl(SystemAdminTeams, "Select the System Admin Teams", true); SystemAdminTeams.Text = collection.SystemAdminTeams.UIControlValue; teams.InitialiseTaxonomyControl(BusinessAdminTeams, "Select the Business Admin Teams", true); BusinessAdminTeams.Text = collection.BusinessAdminTeams.UIControlValue; NameOfAllWorkBoxesList.Text = collection.ListName; if (collection.EventReceiversAdded) { EventReceiverStatus.Text = "<i>(Event receiver <b>has</b> been added)</i>"; } GenerateUniqueIds.Checked = collection.GenerateUniqueIDs; WorkBoxCollectionUniqueIdPrefix.Text = collection.UniqueIDPrefix; NumberOfDigitsInIds.Text = collection.NumberOfDigitsInIDs.ToString(); InitialIdOffset.Text = collection.InitialIDOffset.ToString(); CanAnyoneCreate.Checked = collection.CanAnyoneCreate; SysadminOpen.Text = collection.OpenPermissionLevelForSystemAdmin; AdminOpen.Text = collection.OpenPermissionLevelForBusinessAdmin; OwnerOpen.Text = collection.OpenPermissionLevelForOwner; InvolvedOpen.Text = collection.OpenPermissionLevelForInvolved; VisitorsOpen.Text = collection.OpenPermissionLevelForVisitors; EveryoneOpen.Text = collection.OpenPermissionLevelForEveryone; SysadminClosed.Text = collection.ClosedPermissionLevelForSystemAdmin; AdminClosed.Text = collection.ClosedPermissionLevelForBusinessAdmin; OwnerClosed.Text = collection.ClosedPermissionLevelForOwner; InvolvedClosed.Text = collection.ClosedPermissionLevelForInvolved; VisitorsClosed.Text = collection.ClosedPermissionLevelForVisitors; EveryoneClosed.Text = collection.ClosedPermissionLevelForEveryone; UseFolderAccessGroupsPattern.Checked = collection.UseFolderAccessGroupsPattern; FolderAccessGroupsPrefix.Text = collection.FolderAccessGroupsPrefix; FolderAccessGroupsFolderNames.Text = collection.FolderAccessGroupsFolderNames; FolderAccessGroupPermissionLevel.Text = collection.FolderAccessGroupPermissionLevel; AllFoldersAccessGroupPermissionLevel.Text = collection.AllFoldersAccessGroupPermissionLevel; NewWorkBoxDialogUrl.Text = collection.UrlForNewWorkBoxDialog; CreateNewWorkBoxText.Text = collection.CreateNewWorkBoxText; teams.InitialiseTaxonomyControl(DefaultOwningTeam, "Select the Default Owning Team", false); DefaultOwningTeam.Text = collection.DefaultOwningTeamUIControlValue; UsesLinkedCalendars.Checked = collection.UsesLinkedCalendars; ReturnUrl.Value = Request.QueryString["ReturnUrl"]; } }
private SPListItemCollection getResultsForWorkBoxCollection(string workBoxCollectionURL, WBTeam team, WBRecordsType recordsType) { WBUtils.logMessage("Getting results for WBCollection: " + workBoxCollectionURL); using (WBCollection collection = new WBCollection(workBoxCollectionURL)) { return(collection.QueryFilteredBy(team, recordsType, true)); } }
protected void Page_Load(object sender, EventArgs e) { collection = new WBCollection(SPContext.Current); if (!IsPostBack) { WorkBoxesInCollectionListName.Text = collection.ListName; } }
protected void Page_Load(object sender, EventArgs e) { actions = new Dictionary <String, WBAction>(); List <String> actionKeys = WBAction.GetKeysForEditableRibbonTabButtons(); foreach (string key in actionKeys) { actions.Add(key, new WBAction(key)); } Table table = new Table(); table.Width = Unit.Percentage(100); TableRow headers = new TableRow(); headers.WBxAddTableHeaderCell("Label"); headers.WBxAddTableHeaderCell("Icon"); headers.WBxAddTableHeaderCell("Is Enabled?"); headers.WBxAddTableHeaderCell("Allow Owners?"); headers.WBxAddTableHeaderCell("Allow Involved?"); headers.WBxAddTableHeaderCell("Allow Visitors?"); headers.WBxAddTableHeaderCell("Is Modal?"); headers.WBxAddTableHeaderCell("Show Close?"); headers.WBxAddTableHeaderCell("Allow Maximise?"); headers.WBxAddTableHeaderCell("Action URL"); headers.WBxAddTableHeaderCell("Width"); headers.WBxAddTableHeaderCell("Height"); headers.WBxAddTableHeaderCell("Revert To Defaults?"); table.Rows.Add(headers); foreach (WBAction action in actions.Values) { table.Rows.Add(action.CreateEditableTableRow()); } EditActionsTable.Controls.Add(table); if (!IsPostBack) { using (WBCollection collection = new WBCollection(SPContext.Current)) { foreach (WBAction action in actions.Values) { string propertyValue = collection.Web.WBxGetProperty(action.PropertyKey); action.SetFromPropertyValue(propertyValue); action.SetControlValues(); } } ReturnUrl.Value = Request.QueryString["ReturnUrl"]; } }
public override void ItemAdded(SPItemEventProperties properties) { WBLogging.Generic.HighLevel("WorkBoxMetaDataItemChangeEventReceiver.ItemAdded()"); WBCollection collection = new WBCollection(properties.ListItem); using (WorkBox workBox = new WorkBox(collection, properties.ListItem)) { processChangeRequest(workBox); } base.ItemAdded(properties); }
private String addWorkBoxResults(WBCollection collection, SPListItemCollection workBoxResults) { if (workBoxResults == null || workBoxResults.Count == 0) { return(""); } // String html = "<table cellpadding=\"2\">\n"; String html = ""; foreach (SPListItem item in workBoxResults) { using (WorkBox workBox = new WorkBox(collection, item)) { bool include = false; if (ShowAllUserCanVisit && workBox.CurrentUserCanVisit()) { include = true; } else if (ShowAllUserInvolved && workBox.CurrentUserIsInvolved()) { include = true; } else if (workBox.CurrentUserIsOwner()) { include = true; } if (include) { html += string.Format("<tr class=\"wbf-work-box\"><td><img src=\"{0}\"/></td><td><a href=\"{1}\">{2}</a></td><td><a href=\"{3}\">{4}</a></td><td>{5}</td></tr>\n", "/_layouts/images/WorkBoxFramework/work-box-16.png", workBox.Url, workBox.Title, workBox.OwningTeam.TeamSiteUrl, workBox.OwningTeam.Name, workBox.DateCreated.ToString("d")); } } } // html += "</table>\n"; return(html); }
private void addWorkBoxResultsToCombinedData(WBCollection collection, SPListItemCollection workBoxResults, DataTable combinedData) { if (workBoxResults == null) { return; } foreach (SPListItem item in workBoxResults) { using (WorkBox workBox = new WorkBox(collection, item)) { if (workBox.Status == WorkBox.WORK_BOX_STATUS__OPEN) { combinedData.Rows.Add("/_layouts/images/WorkBoxFramework/work-box-16.png", workBox.Title, workBox.Url, workBox.RecordsType.Name, workBox.DateCreated, workBox.Status); } } } }
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); }
private String uploadAndCreate(String workBoxCollectionURL, String filePath) { string progress = "<table>\n"; List <string[]> uploadData = parseCSV(filePath); int total = uploadData.Count; int count = 0; using (WBCollection collection = new WBCollection(workBoxCollectionURL)) { string localID, title, description, rights, dateString, fileToUpload, folderPath; foreach (string[] dataRow in uploadData) { count++; // Skip the first row as this contains the titles for the columsn, not data. if (count == 1) { continue; } fileToUpload = dataRow[0]; localID = dataRow[1]; folderPath = dataRow[2]; title = dataRow[3]; description = dataRow[4]; rights = dataRow[5]; dateString = dataRow[6].Replace(" 00:00", ""); WBLogging.Migration.Verbose(string.Format("Uploading {0} of {1} : with filename: {2}", count, total, fileToUpload)); string success = uploadDocument(collection, fileToUpload, localID, folderPath, title, description, dateString); WBLogging.Migration.Verbose("Success status: " + success); progress += "<tr><td>" + success + "</td><td>" + dataRow[0] + "</td></tr>\n"; } } progress += "</table>\n"; return(progress); }
protected void Page_Load(object sender, EventArgs e) { if (webPart.WorkBoxCollectionURL == null || webPart.WorkBoxCollectionURL.Equals("")) { WebPartContent.Text = "<i>(You still have to configure the web part)</i>"; } else { using (WBCollection collection = new WBCollection(workBoxCollectionUrl)) { // using (SPWeb workBoxCollectionWeb = workBoxCollectionSite.OpenWeb()) // { // Let's first populate the web parts title to initially reflect the pointed to work box collection title. webPart.TitleUrl = workBoxCollectionUrl; if (webPart.Title.Equals("") || webPart.Title.Equals("List Work Boxes Web Part")) { webPart.Title = collection.Web.Title; } SPList allWorkBoxesList = collection.List; if (allWorkBoxesList != null) { WBUtils.logMessage("Did pick up the list which has title: " + allWorkBoxesList.Title); SPWeb teamSiteWeb = SPContext.Current.Web; populatePlaceHolder(teamSiteWeb, collection, allWorkBoxesList); } else { WBUtils.logMessage("Could not find the all work boxes list."); } // } } } }
DataView GetTemplatesDataSource(WBCollection collection, WBRecordsType recordsType) { // Create a table to store data for the DropDownList control. DataTable dataTable = new DataTable(); // Define the columns of the table. dataTable.Columns.Add(new DataColumn("WorkBoxTemplateTextField", typeof(String))); dataTable.Columns.Add(new DataColumn("WorkBoxTemplateValueField", typeof(String))); List <WBTemplate> templates = collection.ActiveTemplates(recordsType); foreach (WBTemplate template in templates) { dataTable.Rows.Add(CreateRow(template.Title, template.ID.ToString(), dataTable)); } // Create a DataView from the DataTable to act as the data source // for the DropDownList control. DataView dataView = new DataView(dataTable); return(dataView); }
protected void SaveChangesButton_OnClick(object sender, EventArgs e) { using (WBCollection collection = new WBCollection(SPContext.Current)) { foreach (WBAction action in actions.Values) { action.CaptureControlValues(); collection.SetAction(action); // collection.Web.WBxSetProperty(action.PropertyKey, action.PropertyValue); } collection.Update(); } if (String.IsNullOrEmpty(ReturnUrl.Value)) { SPUtility.Redirect("settings.aspx", SPRedirectFlags.RelativeToLayoutsPage, Context); } else { SPUtility.Redirect(ReturnUrl.Value, SPRedirectFlags.Static, Context); } }
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, ""); } } } }
private void populatePlaceHolder(SPWeb teamSiteWeb, WBCollection collection, SPList workBoxesList) { string html = ""; if (teamSiteWeb != null) { Object valueObj = teamSiteWeb.AllProperties[WorkBox.TEAM_SITE_PROPERTY__TERM_GUID]; if (valueObj != null) { teamsTermGuid = valueObj.ToString(); // html += "<b>The team Guid = " + teamsGuid + "</b>"; } else { WBUtils.logMessage("The site to term mapping appears to be missing so web part wont filter by team."); // html += "<b>The site to term mapping appears to be missing.</b>"; } } else { WBUtils.logMessage("Wasn't able to find the teamSiteWeb."); html += "<b>Wasn't able to find team</b>"; } // THIS SHOULD BE DONE IN CSS!!!! html += "<table cellpadding='5'>\n"; if (groupByWorkBoxTemplate) { SPList workBoxTemplates = null; workBoxTemplates = collection.TemplatesList; if (workBoxTemplates == null) { WBUtils.logMessage("Couldn't find the Work Box Templates list"); } int maxID = 0; foreach (SPListItem template in workBoxTemplates.Items) { if (template.ID > maxID) { maxID = template.ID; } } WBUtils.logMessage("Found work box template max ID to be = " + maxID); List <List <SPListItem> > groupedByTemplates = new List <List <SPListItem> >(maxID + 1); for (int i = 0; i <= maxID; i++) { groupedByTemplates.Add(new List <SPListItem>()); } int id = -1; List <SPListItem> subList = null; string lookupValueString = ""; foreach (SPListItem workBoxMetadataItem in workBoxesList.Items) { if (!includeThisWorkBox(workBoxMetadataItem)) { continue; } lookupValueString = workBoxMetadataItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__WORK_BOX_TEMPLATE); if (lookupValueString != "") { SPFieldLookupValue linkedType = new SPFieldLookupValue(lookupValueString); id = linkedType.LookupId; WBUtils.logMessage("Working with ID = " + id); subList = groupedByTemplates[id]; if (subList == null) { WBUtils.logMessage("Should never get here = " + id); subList = new List <SPListItem>(); groupedByTemplates.Insert(id, subList); } subList.Add(workBoxMetadataItem); } else { WBUtils.logMessage("Couldn't find the type for work box: " + workBoxMetadataItem.Title); } } foreach (SPListItem typeToOutput in workBoxTemplates.Items) { WBUtils.logMessage("Iterating through ID = " + typeToOutput.ID); List <SPListItem> subListToOutput = groupedByTemplates[typeToOutput.ID]; if (subListToOutput != null && (subListToOutput.Count > 0 || showEmptyWorkBoxesTypes)) { WBUtils.logMessage("SubList contains " + subListToOutput.Count); html += "<tr><td colspan=4><b>" + typeToOutput.Title + "</b></td></tr>"; html += makeTableRowsOfWorkBoxes(subListToOutput); } } } else { List <SPListItem> workBoxes = new List <SPListItem>(); foreach (SPListItem workBoxMetadataItem in workBoxesList.Items) { if (!includeThisWorkBox(workBoxMetadataItem)) { continue; } workBoxes.Add(workBoxMetadataItem); } html += makeTableRowsOfWorkBoxes(workBoxes); } html += "</table>\n"; // html += "<script type=\"text/javascript\">var parameters='?WorkBoxCollectionURL="; // html += Uri.EscapeDataString(webPart.WorkBoxCollectionURL) + "&TeamsGuid=" + teamsGuid; // html += "'</script>"; // html += "<script type=\"text/javascript\">var workBoxCollectionRoot='" + webPart.WorkBoxCollectionURL + "';"; // html += "var parameters = '?teamsTermGuid=" + teamsGuid + "&workBoxCollectionUrl=" + Uri.EscapeDataString(webPart.WorkBoxCollectionURL) + "';"; // html += "</script>"; WebPartContent.Text = html; }
protected void okButton_OnClick(object sender, EventArgs e) { String errorMessage = "No error occurred"; try { WBCollection collection = new WBCollection(SPContext.Current); WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site); collection.SystemAdminTeams = new WBTermCollection <WBTeam>(teams, SystemAdminTeams.Text); collection.BusinessAdminTeams = new WBTermCollection <WBTeam>(teams, BusinessAdminTeams.Text); // OK so first make sure that the event receiver is attached to the correct list collection.ListName = NameOfAllWorkBoxesList.Text; // OK so now to save the various other settings values: collection.UniqueIDPrefix = WorkBoxCollectionUniqueIdPrefix.Text; collection.GenerateUniqueIDs = GenerateUniqueIds.Checked; collection.NumberOfDigitsInIDs = Convert.ToInt32(NumberOfDigitsInIds.Text); collection.InitialIDOffset = Convert.ToInt32(InitialIdOffset.Text); collection.CanAnyoneCreate = CanAnyoneCreate.Checked; collection.OpenPermissionLevelForSystemAdmin = SysadminOpen.Text; collection.OpenPermissionLevelForBusinessAdmin = AdminOpen.Text; collection.OpenPermissionLevelForOwner = OwnerOpen.Text; collection.OpenPermissionLevelForInvolved = InvolvedOpen.Text; collection.OpenPermissionLevelForVisitors = VisitorsOpen.Text; collection.OpenPermissionLevelForEveryone = EveryoneOpen.Text; collection.ClosedPermissionLevelForSystemAdmin = SysadminClosed.Text; collection.ClosedPermissionLevelForBusinessAdmin = AdminClosed.Text; collection.ClosedPermissionLevelForOwner = OwnerClosed.Text; collection.ClosedPermissionLevelForInvolved = InvolvedClosed.Text; collection.ClosedPermissionLevelForVisitors = VisitorsClosed.Text; collection.ClosedPermissionLevelForEveryone = EveryoneClosed.Text; collection.UseFolderAccessGroupsPattern = UseFolderAccessGroupsPattern.Checked; collection.FolderAccessGroupsPrefix = FolderAccessGroupsPrefix.Text; collection.FolderAccessGroupsFolderNames = FolderAccessGroupsFolderNames.Text; collection.FolderAccessGroupPermissionLevel = FolderAccessGroupPermissionLevel.Text; collection.AllFoldersAccessGroupPermissionLevel = AllFoldersAccessGroupPermissionLevel.Text; collection.UrlForNewWorkBoxDialog = NewWorkBoxDialogUrl.Text; collection.CreateNewWorkBoxText = CreateNewWorkBoxText.Text; collection.DefaultOwningTeamUIControlValue = DefaultOwningTeam.Text; collection.UsesLinkedCalendars = UsesLinkedCalendars.Checked; collection.Update(); } catch (Exception exception) { WBLogging.WorkBoxCollections.Unexpected(exception.StackTrace); SPUtility.TransferToErrorPage("An exception occurred : " + exception.StackTrace, "Return to site settings page", "/_layouts/settings.aspx"); } if (String.IsNullOrEmpty(ReturnUrl.Value)) { SPUtility.Redirect("settings.aspx", SPRedirectFlags.RelativeToLayoutsPage, Context); } else { SPUtility.Redirect(ReturnUrl.Value, SPRedirectFlags.Static, Context); } }
public WBTemplate(WBCollection collection, SPListItem item) { _collection = collection; _id = item.ID; _item = item; }
public WBTemplate(WBCollection collection, int id) { _collection = collection; _id = id; _item = collection.TemplatesList.GetItemById(id); }
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; }
private void RefreshBoundData() { if (!String.IsNullOrEmpty(SelectedRecordsTypeGUID)) { WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes); WBRecordsType recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID)); String recordsTypePath = recordsType.FullPath; //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1); recordsTypePath = recordsTypePath.Replace("/", " / "); SelectionTitle.Text = recordsTypePath; SelectionDescription.Text = recordsType.Description; WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); WBFarm farm = WBFarm.Local; using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl)) { // using (SPWeb web = site.OpenWeb()) // { WBQuery query = new WBQuery(); WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType); recordsTypeClause.UseDescendants = false; query.AddClause(recordsTypeClause); if (team != null) { query.AddEqualsFilter(WBColumn.InvolvedTeams, team); } string statusFilter = SelectedWorkBoxStatusFilter; if (statusFilter == null || statusFilter == "") statusFilter = "Open"; if (statusFilter != "All") { query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter); } FilterOpenStatus.CssClass = "wbf-unselected-filter"; FilterClosedStatus.CssClass = "wbf-unselected-filter"; FilterAllStatus.CssClass = "wbf-unselected-filter"; if (statusFilter == "Open") FilterOpenStatus.CssClass = "wbf-selected-filter"; if (statusFilter == "Closed") FilterClosedStatus.CssClass = "wbf-selected-filter"; if (statusFilter == "All") FilterAllStatus.CssClass = "wbf-selected-filter"; query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); //query.AddViewColumn(WBColumn.OwningTeam); // query.AddViewColumn(WBColumn.FunctionalArea); query.AddViewColumn(WBColumn.ReferenceDate); //query.AddViewColumn(WBColumn.ReferenceID); //query.AddViewColumn(WBColumn.SeriesTag); // query.AddViewColumn(WBColumn.InvolvedTeams); query.AddViewColumn(WBColumn.WorkBoxStatus); if (sortColumn != null) query.OrderBy(sortColumn, ascending); DataTable dataTable = collection.Query(query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.Columns.Clear(); SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending)); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending)); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, sortColumn, ascending)); SelectedWorkBoxes.DataBind(); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } else { CreateNewWorkBoxLink.Text = ""; } // } } } else { WBUtils.logMessage("SelectedRecordsTypeGUID was empty"); } }
private string addWorkBoxesForRecordsClass(WBTaxonomy recordsTypes, TermCollection recordsTypesTerms) { if (recordsTypesTerms.Count == 0) { return(""); } string finalHtml = ""; bool containsWorkBoxesForMe = false; foreach (Term recordsTypeTerm in recordsTypesTerms) { WBRecordsType recordsType = new WBRecordsType(recordsTypes, recordsTypeTerm); string html = ""; string workBoxesHtml = ""; containsWorkBoxesForMe = false; html = "<tr><td colspan=\"5\" class=\"wbf-records-type\">\n" + recordsType.Name + "</td></tr>\n"; // html += "<li class=\"wbf-records-type\">" + recordsType.Name; // html += "\n"; string workBoxCollectionURL = recordsType.WorkBoxCollectionUrl; WBUtils.logMessage("The work box collection url = " + workBoxCollectionURL); if (workBoxCollectionURL != "") { bool originalAccessDeniedCatchValue = SPSecurity.CatchAccessDeniedException; SPSecurity.CatchAccessDeniedException = false; try { using (WBCollection collection = new WBCollection(workBoxCollectionURL)) { SPListItemCollection workBoxResults = collection.QueryFilteredBy(recordsType, WorkBox.WORK_BOX_STATUS__OPEN, false); if (workBoxResults != null && workBoxResults.Count > 0) { containsWorkBoxesForMe = true; workBoxesHtml = addWorkBoxResults(collection, workBoxResults); } } } catch (UnauthorizedAccessException e) { WBUtils.logMessage("UnauthorizedAccessException thrown for user trying to access: " + workBoxCollectionURL + " Exception was: " + e.Message); // Let's just hide this for the moment as the user doesn't have access to here anyway. workBoxesHtml = ""; } catch (Exception e) { workBoxesHtml = "<i>Exception occured when trying to get results from the work box collection at: " + workBoxCollectionURL + " Exception was: " + e.Message + "</i>"; } finally { SPSecurity.CatchAccessDeniedException = originalAccessDeniedCatchValue; } } if (containsWorkBoxesForMe || ShowAllRecordsTypes) { html += workBoxesHtml; //html += "</li>\n"; finalHtml += html; } } if (finalHtml != "" || ShowAllRecordsTypes) { // finalHtml = "<ul class=\"wbf-my-work-boxes-list wbf-records-types\">\n" + finalHtml + "</ul>\n"; } return(finalHtml); }
private void RefreshBoundData() { if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE) { FilterOpenStatus.Enabled = true; FilterClosedStatus.Enabled = true; FilterAllStatus.Enabled = true; } else { FilterOpenStatus.Enabled = false; FilterClosedStatus.Enabled = false; FilterAllStatus.Enabled = false; ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ClearHighlightedRecordsTypes", "$('a.ms-navitem').css('font-weight', 'normal');", true); } WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes); WBQuery query = new WBQuery(); query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); //query.AddViewColumn(WBColumn.OwningTeam); // query.AddViewColumn(WBColumn.FunctionalArea); //query.AddViewColumn(WBColumn.ReferenceDate); //query.AddViewColumn(WBColumn.ReferenceID); //query.AddViewColumn(WBColumn.SeriesTag); // query.AddViewColumn(WBColumn.InvolvedTeams); query.AddViewColumn(WBColumn.WorkBoxStatus); checkSortState(); if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } SelectedWorkBoxes.Columns.Clear(); SelectedWorkBoxes.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); SelectedWorkBoxes.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending, "")); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending)); // SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending)); switch (SelectedWorkBoxView) { case VIEW__RECENTLY_CREATED: { query.AddViewColumn(WBColumn.WorkBoxDateCreated); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateCreated, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__RECENTLY_MODIFIED: { query.AddViewColumn(WBColumn.WorkBoxDateLastModified); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastModified, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__RECENTLY_VISITED: { query.AddViewColumn(WBColumn.WorkBoxDateLastVisited); //query.AddViewColumn(WBColumn.RecordsType); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxDateLastVisited, HorizontalAlign.Center, sortColumn, ascending)); //SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.RecordsType, HorizontalAlign.Center, sortColumn, ascending)); break; } case VIEW__SELECTED_RECORDS_TYPE: { query.AddViewColumn(WBColumn.ReferenceDate); SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); break; } } SelectedWorkBoxes.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, HorizontalAlign.Center, sortColumn, ascending)); WBRecordsType recordsType = null; WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); if (team != null) { switch (SelectedInvolvementFilter) { case FILTER_INVOLVEMENT__OWNS: { WBLogging.Debug("Adding a filter for OwningTeam"); query.AddEqualsFilter(WBColumn.OwningTeam, team); break; } case FILTER_INVOLVEMENT__INVOLVED: { WBLogging.Debug("Adding a filter for InvolvedTeams"); query.AddEqualsFilter(WBColumn.InvolvedTeams, team); break; } case FILTER_INVOLVEMENT__VISITING: { WBLogging.Debug("Adding a filter for VisitingTeams"); query.AddEqualsFilter(WBColumn.VisitingTeams, team); break; } } } if (SelectedWorkBoxView == VIEW__SELECTED_RECORDS_TYPE) { if (SelectedRecordsTypeGUID != "") { recordsType = recordsTypes.GetRecordsType(new Guid(SelectedRecordsTypeGUID)); } else if (!IsPostBack && !String.IsNullOrEmpty(webPart.InitialRecordsType)) { string initialRecordsTypePath = webPart.InitialRecordsType.Replace(" / ", "/").Trim(); recordsType = recordsTypes.GetSelectedRecordsType(initialRecordsTypePath); } if (recordsType != null) { String recordsTypePath = recordsType.FullPath; //recordsTypePath = recordsTypePath.Substring(1, recordsTypePath.Length - 1); recordsTypePath = recordsTypePath.Replace("/", " / "); SelectionTitle.Text = recordsTypePath; SelectionDescription.Text = recordsType.Description; WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType); recordsTypeClause.UseDescendants = false; query.AddClause(recordsTypeClause); string statusFilter = SelectedWorkBoxStatusFilter; if (statusFilter != "All") { query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter); } try { using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl)) { DataTable dataTable = collection.Query(query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.DataBind(); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } else { CreateNewWorkBoxLink.Text = ""; } } } catch (Exception exception) { SelectedWorkBoxes.DataSource = null; SelectedWorkBoxes.DataBind(); SelectionDescription.Text = SelectionDescription.Text + "<p><em>(An exception occured when trying to query the work boxes for this records type!)</em></p>"; CreateNewWorkBoxLink.Text = ""; WBLogging.RecordsTypes.Unexpected("Exception occurred on a team site when trying to query the work boxes of records type: " + recordsTypePath, exception); } } else { WBUtils.logMessage("SelectedRecordsTypeGUID was empty"); } } else { String cachedDetailsListUrl = WBFarm.Local.OpenWorkBoxesCachedDetailsListUrl; // OK so this is a general 'recent' query using (SPWeb cacheWeb = SPContext.Current.Site.OpenWeb(cachedDetailsListUrl)) { SPList cacheList = cacheWeb.GetList(cachedDetailsListUrl); DataTable dataTable = cacheList.WBxGetDataTable(SPContext.Current.Site, query); SelectedWorkBoxes.DataSource = dataTable; SelectedWorkBoxes.DataBind(); CreateNewWorkBoxLink.Text = ""; SelectionTitle.Text = SelectedWorkBoxView + " Work Boxes"; SelectionDescription.Text = "Select a category from left hand tree navigation to list work boxes of that type."; } } // OK so now to check that the right filters are highlighted: ViewRecentlyCreated.CssClass = ""; ViewRecentlyModified.CssClass = ""; ViewRecentlyVisited.CssClass = ""; if (SelectedWorkBoxView == VIEW__RECENTLY_CREATED) { ViewRecentlyCreated.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxView == VIEW__RECENTLY_MODIFIED) { ViewRecentlyModified.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxView == VIEW__RECENTLY_VISITED) { ViewRecentlyVisited.CssClass = "wbf-filter-selected"; } FilterByOwns.CssClass = ""; FilterByInvolved.CssClass = ""; FilterByVisiting.CssClass = ""; if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__OWNS) { FilterByOwns.CssClass = "wbf-filter-selected"; } if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__INVOLVED) { FilterByInvolved.CssClass = "wbf-filter-selected"; } if (SelectedInvolvementFilter == FILTER_INVOLVEMENT__VISITING) { FilterByVisiting.CssClass = "wbf-filter-selected"; } FilterOpenStatus.CssClass = ""; FilterClosedStatus.CssClass = ""; FilterAllStatus.CssClass = ""; if (SelectedWorkBoxStatusFilter == "Open") { FilterOpenStatus.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxStatusFilter == "Closed") { FilterClosedStatus.CssClass = "wbf-filter-selected"; } if (SelectedWorkBoxStatusFilter == "All") { FilterAllStatus.CssClass = "wbf-filter-selected"; } }
protected void Page_Load(object sender, EventArgs e) { // Get the selected parameters: string recordsTypeGUID = Request.Params["recordsTypeGUID"]; string selectedWorkBoxCollectionURL = Request.Params["workBoxCollectionURL"]; string includeDocumentsFlag = Request.Params["includeDocuments"]; WBTaxonomy teams = WBTaxonomy.GetTeams(SPContext.Current.Site); WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(teams); WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current); if (recordsTypeGUID == null || recordsTypeGUID == "" || selectedWorkBoxCollectionURL == null || selectedWorkBoxCollectionURL == "" || team == null ) { InformationText.Text = "<span>Make a selection from the left to see work boxes of that type.</span>"; } else { Guid teamsTermGuid = team.Id; string teamsGUID = team.Id.ToString(); // Process the parameters: bool includeDocumentRecords = false; if (includeDocumentsFlag != null && includeDocumentsFlag != "") { includeDocumentRecords = includeDocumentsFlag.Equals(true.ToString()); } WBRecordsType recordsType = null; Guid selectedRecordsTypeTermGUID = new Guid(recordsTypeGUID); recordsType = recordsTypes.GetRecordsType(selectedRecordsTypeTermGUID); string infoText = "<div class='wbf-view-selected-records-type'>You have selected to view: <span 'wbf-records-type-name'>" + recordsType.Name + "</span></div>\n"; if (recordsType.Description != "") { infoText += "<div class='wbf-records-type-description'>" + recordsType.Description + "</div>"; } InformationText.Text = infoText; WBUtils.logMessage("Found the records type info: " + recordsType.Name); DataTable combinedData = createCombinedDataTable(); if (includeDocumentRecords) { WBUtils.logMessage("Records Library IS being included in search"); WBFarm farm = WBFarm.Local; // SPListItemCollection docResults = getResultsForList(farm.RecordsCenterUrl, farm.RecordsCenterRecordsLibraryName, team, recordsType); // addDocResultsToCombinedData(farm.RecordsCenterUrl, docResults, combinedData); } else { WBUtils.logMessage("Records Library is not being included in search"); } if (selectedWorkBoxCollectionURL != "") { using (WBCollection collection = new WBCollection(selectedWorkBoxCollectionURL)) { WBUtils.logMessage("A work box colleciton IS being included in search: " + selectedWorkBoxCollectionURL); SPListItemCollection workBoxResults = collection.QueryFilteredBy(team, recordsType, true); WBUtils.logMessage("Got back from query this num of results: " + workBoxResults.Count); addWorkBoxResultsToCombinedData(collection, workBoxResults, combinedData); if (recordsType.CanCurrentUserCreateWorkBoxForTeam(collection, team)) { string createNewURL = collection.GetUrlForNewDialog(recordsType, team); string createNewText = recordsType.CreateNewWorkBoxText; CreateNewWorkBoxLink.Text = "<a href=\"#\" onclick=\"javascript: WorkBoxFramework_commandAction('" + createNewURL + "', 730, 800);\">" + createNewText + "</a>"; } } } else { WBUtils.logMessage("No work box colleciton is being included in search"); } ShowCombinedResults.DataSource = combinedData; ShowCombinedResults.DataBind(); } }
private String uploadDocument(WBCollection collection, String fileToUpload, String localID, String folderPath, String title, String description, String scanDateString) { // First check if the work box has been created: using (WorkBox workBox = collection.FindOrCreateNewByLocalID(localID)) { if (!workBox.IsOpen) { workBox.Open(); } } // Then re-load the work box to ensure we dont get security problems: using (WorkBox workBox = collection.FindOrCreateNewByLocalID(localID)) { if (!System.IO.File.Exists(fileToUpload)) { return("File not found."); } try { SPFolder folder = workBox.DocumentLibrary.RootFolder.WBxGetOrCreateFolderPath(folderPath); // Prepare to upload Boolean replaceExistingFiles = true; String fileName = Path.GetFileName(fileToUpload); String extension = Path.GetExtension(fileName); String newFileName = title + extension; FileStream fileStream = File.OpenRead(fileToUpload); fileName = fileName.Replace('~', '-'); WBLogging.Migration.Verbose("fileName = " + fileName); WBLogging.Migration.Verbose("newFileName = " + newFileName); WBLogging.Migration.Verbose("folder.Name = " + folder.Name); WBLogging.Migration.Verbose("folder.Url = " + folder.Url); // Upload document string uniqueName = workBox.Web.WBxMakeFilenameUnique(folder, newFileName); SPFile spfile = folder.Files.Add(uniqueName, fileStream, replaceExistingFiles); // folder.Update(); try { DateTime scanDate = Convert.ToDateTime(scanDateString); spfile.Item[WorkBox.COLUMN_NAME__SCAN_DATE] = scanDate; spfile.Update(); } catch (Exception e) { WBLogging.Migration.Unexpected("Couldn't convert the date: " + scanDateString + " error was: " + e.Message); } } catch (Exception e) { WBLogging.Migration.Unexpected("An exception: " + e.Message); return("An exception: " + e.Message); } return("Success."); } }
/// <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); }
private void RefreshBoundData() { if (SelectedNodePath != "") { SelectedRecordsType.Text = SelectedNodePath.Replace("Records Types/", "").Replace("/", " / "); WBTaxonomy recordsTypes = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site); WBTaxonomy teams = WBTaxonomy.GetTeams(recordsTypes); WBRecordsType recordsType = recordsTypes.GetSelectedRecordsType(SelectedNodePath); SelectedRecordsTypeDescription.Text = recordsType.Description; WBTeam team = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web); WBFarm farm = WBFarm.Local; using (WBCollection collection = new WBCollection(recordsType.WorkBoxCollectionUrl)) { // using (SPWeb web = site.OpenWeb()) // { WBQuery query = new WBQuery(); WBQueryClause recordsTypeClause = new WBQueryClause(WBColumn.RecordsType, WBQueryClause.Comparators.Equals, recordsType); recordsTypeClause.UseDescendants = true; query.AddClause(recordsTypeClause); if (team != null) { query.AddEqualsFilter(WBColumn.InvolvedTeams, team); } string statusFilter = Request.QueryString["Status"]; if (statusFilter != null && statusFilter != "") { query.AddEqualsFilter(WBColumn.WorkBoxStatus, statusFilter); } query.AddViewColumn(WBColumn.Title); query.AddViewColumn(WBColumn.WorkBoxURL); query.AddViewColumn(WBColumn.OwningTeam); // query.AddViewColumn(WBColumn.FunctionalArea); query.AddViewColumn(WBColumn.ReferenceDate); query.AddViewColumn(WBColumn.ReferenceID); query.AddViewColumn(WBColumn.SeriesTag); // query.AddViewColumn(WBColumn.InvolvedTeams); query.AddViewColumn(WBColumn.WorkBoxStatus); if (sortColumn != null) { query.OrderBy(sortColumn, ascending); } DataTable dataTable = collection.Query(query); ShowResults.DataSource = dataTable; ShowResults.Columns.Clear(); ShowResults.Columns.Add(WBUtils.FixedIconTemplateField(WorkBox.ICON_16_IMAGE_URL, WBColumn.WorkBoxURL)); ShowResults.Columns.Add(WBUtils.HyperLinkField(WBColumn.Title, WBColumn.WorkBoxURL, sortColumn, ascending)); ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.OwningTeam, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.FunctionalArea, sortColumn, ascending)); ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceDate, HorizontalAlign.Center, sortColumn, ascending)); ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.ReferenceID, sortColumn, ascending)); ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.SeriesTag, sortColumn, ascending)); // ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.InvolvedTeams, sortColumn, ascending)); ShowResults.Columns.Add(WBUtils.BoundField(WBColumn.WorkBoxStatus, sortColumn, ascending)); ShowResults.DataBind(); // } } } else { WBUtils.logMessage("SelectedNodePath was empty"); } }
/// <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); }