예제 #1
0
        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();
        }
예제 #2
0
        protected override void CreateChildControls()
        {
            Literal literal = new Literal();
            string  html    = "";

            WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current);

            if (workBox == null)
            {
                return;
            }

            WBTermCollection <WBTeam> involvedTeams = workBox.InvolvedTeams;

            if (involvedTeams == null)
            {
                addErrorMessage("Couldn't find a involvedTeams for the field");
            }
            else
            {
                if (involvedTeams.Count > 0)
                {
                    if (TeamsRootSiteURL == null || TeamsRootSiteURL == "")
                    {
                        TeamsRootSiteURL = WBFarm.Local.TeamSitesSiteCollectionUrl;
                    }


                    try
                    {
                        using (SPSite teamsSite = new SPSite(TeamsRootSiteURL))
                        {
                            html += "<table cellpadding='5'>";
                            foreach (WBTeam team in involvedTeams)
                            {
                                html += "<tr><td><a href='" + team.TeamSiteUrl + "'>" + team.Name + "</a></td></tr>";
                            }
                            html += "</table>";
                        }
                    }
                    catch (Exception e)
                    {
                        html = "Exception was thrown " + e.StackTrace;
                    }
                }
                else
                {
                    html += "<i>(none)</i>";
                }
            }

            literal.Text = html;

            this.Controls.Add(literal);
        }
예제 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName);

            if (WorkBox.IsWebAWorkBox(SPContext.Current.Web))
            {
                workBox = new WorkBox(SPContext.Current);
                team    = workBox.OwningTeam;
                functionalAreasTaxonomy = workBox.FunctionalAreasTaxonomy;
            }
            else
            {
                team = WBTeam.GetFromTeamSite(SPContext.Current);
                if (team != null)
                {
                    teamsTaxonomy           = team.Taxonomy;
                    functionalAreasTaxonomy = WBTaxonomy.GetFunctionalAreas(teamsTaxonomy);
                }
            }

            if (team == null)
            {
                WBLogging.Debug("Couldn't find a suitable team !!");
                return;
            }

            masterLibraryHasVersions = manager.Libraries.ProtectedMasterLibrary.List.EnableVersioning;

            RecordsLibraryFolders.TreeNodePopulate += new TreeNodeEventHandler(RecordsLibraryFolders_TreeNodePopulate);
            // RecordsLibraryFolders.SelectedNodeChanged += new EventHandler(RecordsLibraryFolders_SelectedNodeChanged);

            RecordsLibraryFolders.PopulateNodesFromClient = true;
            RecordsLibraryFolders.EnableClientScript      = true;

            treeState = new WBLocationTreeState(SPContext.Current.Web, WBRecordsManager.VIEW_MODE__BROWSE_FOLDERS, WBRecordsType.PROTECTIVE_ZONE__PUBLIC);

            if (!IsPostBack)
            {
                WBTermCollection <WBTerm> functionalAreas = team.FunctionalArea(functionalAreasTaxonomy);

                ViewState["SortColumn"]    = WBColumn.DatePublished.InternalName;
                ViewState["SortDirection"] = "Descending";

                /*
                 * TreeViewLocationCollection collection = new TreeViewLocationCollection(manager, , "", functionalAreas);
                 *
                 * RecordsLibraryFolders.DataSource = collection;
                 * RecordsLibraryFolders.DataBind();
                 */

                manager.PopulateWithFunctionalAreas(treeState, RecordsLibraryFolders.Nodes, WBRecordsManager.VIEW_MODE__BROWSE_FOLDERS, functionalAreas);
            }
            else
            {
                SetSelectedPath();
                if (!String.IsNullOrEmpty(selectedPath))
                {
                    ProcessSelection(selectedPath);
                }
            }
        }
        private void renderPage()
        {
            // OK, so now we're finally in a position to load up the values of the page fields:

            SourceDocIcon.AlternateText = "Icon of document being publishing out.";
            SourceDocIcon.ImageUrl      = WBUtils.DocumentIcon32(sourceDocAsItem.Url);

            TitleField.Text = sourceFile.Title;

            ReadOnlyNameField.Text = sourceDocAsItem.Name;
            NameField.Text         = sourceDocAsItem.Name;
            OriginalFileName.Text  = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__ORIGINAL_FILENAME);

            DocumentFileNamingConvention.Text = documentRecordsType.DocumentNamingConvention.Replace("<", "&lt;").Replace(">", "&gt;");

            RecordsTypeUIControlValue.Value     = documentRecordsType.UIControlValue;
            PickRecordsTypeButton.OnClientClick = "WorkBoxFramework_pickANewRecordsType(WorkBoxFramework_PublishDoc_pickedANewRecordsType, '" + documentRecordsType.UIControlValue + "'); return false;";
            RecordsType.Text = documentRecordsType.FullPath.Replace("/", " / ");


            WBTermCollection <WBTerm> functionalAreas = sourceDocAsItem.WBxGetMultiTermColumn <WBTerm>(functionalAreasTaxonomy, WorkBox.COLUMN_NAME__FUNCTIONAL_AREA);

            functionalAreaFieldIsEditable = documentRecordsType.IsFunctionalAreaEditable;
            if (functionalAreaFieldIsEditable)
            {
                functionalAreasTaxonomy.InitialiseTaxonomyControl(FunctionalAreaField, WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, false, false, this);

                String functionalAreaValue = functionalAreas.UIControlValue;
                if (functionalAreaValue.Contains(";"))
                {
                    string[] allFunctionalValues = functionalAreaValue.Split(';');
                    functionalAreaValue = allFunctionalValues[0];
                }

                FunctionalAreaField.Text = functionalAreaValue;
            }
            else
            {
                ReadOnlyFunctionalAreaField.Text = functionalAreas.Names();
            }

            bool    userCanPublishToPublic = false;
            SPGroup publishersGroup        = WorkBox.OwningTeam.PublishersGroup(SPContext.Current.Site);

            if (publishersGroup != null)
            {
                if (publishersGroup.ContainsCurrentUser)
                {
                    userCanPublishToPublic = true;
                }
            }

            String selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED;

            if (userCanPublishToPublic)
            {
                if (destinationType.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__PUBLIC_WEB_SITE))
                {
                    WBLogging.Generic.Verbose("In PUBLIC: The destination type was: " + destinationType);
                    selectedZone = WBRecordsType.PROTECTIVE_ZONE__PUBLIC;
                }
                else if (destinationType.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__PUBLIC_EXTRANET))
                {
                    WBLogging.Generic.Verbose("In PUBLIC EXTRANET: The destination type was: " + destinationType);
                    selectedZone = WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET;
                }
                else
                {
                    WBLogging.Generic.Verbose("The destination type was: " + destinationType);
                    selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED;
                }
            }
            else
            {
                selectedZone = WBRecordsType.PROTECTIVE_ZONE__PROTECTED;
            }

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

            protectiveZoneList.Add(selectedZone);

            ProtectiveZone.DataSource = protectiveZoneList;
            ProtectiveZone.DataBind();

            ProtectiveZone.SelectedValue = selectedZone;


            if (showSubjectTags)
            {
                if (documentRecordsType.IsDocumentSubjectTagsRequired)
                {
                    SubjectTagsTitle.Text = "Subject Tags" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    SubjectTagsTitle.Text = "Subject Tags (optional)";
                }
                SubjectTagsDescription.Text = documentRecordsType.DocumentSubjectTagsDescription;

                subjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTagsField, WorkBox.COLUMN_NAME__SUBJECT_TAGS, true, true, this);
                WBTermCollection <WBTerm> subjectTags = sourceDocAsItem.WBxGetMultiTermColumn <WBTerm>(subjectTagsTaxonomy, WorkBox.COLUMN_NAME__SUBJECT_TAGS);
                SubjectTagsField.Text = subjectTags.WBxToString();
            }


            if (showReferenceID)
            {
                if (documentRecordsType.IsDocumentReferenceIDRequired)
                {
                    ReferenceIDTitle.Text = "Reference ID" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    ReferenceIDTitle.Text = "Reference ID (optional)";
                }
                ReferenceIDDescription.Text = documentRecordsType.DocumentReferenceIDDescription;
                ReferenceID.Text            = sourceDocAsItem.WBxGetColumnAsString(WorkBox.COLUMN_NAME__REFERENCE_ID);
            }

            if (showReferenceDate)
            {
                if (documentRecordsType.IsDocumentReferenceDateRequired)
                {
                    ReferenceDateTitle.Text = "Reference Date" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    ReferenceDateTitle.Text = "Reference Date (optional)";
                }
                ReferenceDateDescription.Text = documentRecordsType.DocumentReferenceDateDescription;
                if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__REFERENCE_DATE))
                {
                    ReferenceDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__REFERENCE_DATE];
                }
                else
                {
                    ReferenceDate.SelectedDate = DateTime.Now;
                }
            }

            if (showSeriesTag)
            {
                if (documentRecordsType.IsDocumentSeriesTagRequired)
                {
                    SeriesTagTitle.Text = "Series Tag" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    SeriesTagTitle.Text = "Series Tag (optional)";
                }
                SeriesTagDescription.Text = documentRecordsType.DocumentSeriesTagDescription;

                SeriesTagDropDownList.DataSource     = GetSeriesTagDataSource(documentRecordsType.DocumentSeriesTagParentTerm(seriesTagsTaxonomy));
                SeriesTagDropDownList.DataTextField  = "SeriesTagTermName";
                SeriesTagDropDownList.DataValueField = "SeriesTagTermUIControlValue";
                SeriesTagDropDownList.DataBind();

                if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SERIES_TAG))
                {
                    SeriesTagDropDownList.SelectedValue = sourceDocAsItem.WBxGetSingleTermColumn <WBTerm>(seriesTagsTaxonomy, WorkBox.COLUMN_NAME__SERIES_TAG).UIControlValue;
                }
            }

            if (showScanDate)
            {
                if (documentRecordsType.IsDocumentScanDateRequired)
                {
                    ScanDateTitle.Text = "Scan Date" + WBConstant.REQUIRED_ASTERISK;
                }
                else
                {
                    ScanDateTitle.Text = "Scan Date (optional)";
                }
                ScanDateDescription.Text = documentRecordsType.DocumentScanDateDescription;
                if (sourceDocAsItem.WBxColumnHasValue(WorkBox.COLUMN_NAME__SCAN_DATE))
                {
                    ScanDate.SelectedDate = (DateTime)sourceDocAsItem[WorkBox.COLUMN_NAME__SCAN_DATE];
                }
            }

            teamsTaxonomy.InitialiseTaxonomyControl(OwningTeamField, WorkBox.COLUMN_NAME__OWNING_TEAM, false);
            TaxonomyFieldValue owningTeamValue = sourceDocAsItem[WorkBox.COLUMN_NAME__OWNING_TEAM] as TaxonomyFieldValue;

            OwningTeamField.Text = owningTeamValue.WBxUIControlValue();

            teamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeamsField, WorkBox.COLUMN_NAME__INVOLVED_TEAMS, true);
            TaxonomyFieldValueCollection involvedTeamsValues = sourceDocAsItem[WorkBox.COLUMN_NAME__INVOLVED_TEAMS] as TaxonomyFieldValueCollection;

            InvolvedTeamsField.Text = involvedTeamsValues.WBxUIControlValue();


            if (functionalAreaFieldIsEditable)
            {
                FunctionalAreaField.Focus();
            }
            else
            {
                PickRecordsTypeButton.Focus();
            }
        }
예제 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WBLogging.Debug("In Page_Load");

            WBLogging.Debug("EventArgs type: " + e.GetType().Name);

            WBLogging.Debug("Request[\"__EVENTARGUMENT\"] = " + Request["__EVENTARGUMENT"]);


            manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName);

            if (!IsPostBack)
            {
                process         = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(Request.QueryString["PublishingProcessJSON"]);
                process.WorkBox = WorkBox;

                WBLogging.Debug("Created the WBProcessObject");

                newOrReplace   = Request.QueryString["NewOrReplace"];
                archiveOrLeave = Request.QueryString["ArchiveOrLeave"];
                if (newOrReplace == "New")
                {
                    process.ReplaceAction = WBPublishingProcess.REPLACE_ACTION__CREATE_NEW_SERIES;
                }
                else
                {
                    if (archiveOrLeave == "Archive")
                    {
                        process.ReplaceAction = WBPublishingProcess.REPLACE_ACTION__ARCHIVE_FROM_IZZI;
                    }
                    else
                    {
                        process.ReplaceAction = WBPublishingProcess.REPLACE_ACTION__LEAVE_ON_IZZI;
                    }
                }

                WBLogging.Debug("Captured replace action as: " + process.ReplaceAction);

                PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process);

                WBLogging.Debug("Serialized the WBProcessObject to hidden field");

                SelectedFolderPath.Text = "/";
            }
            else
            {
                process         = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(PublishingProcessJSON.Value);
                process.WorkBox = WorkBox;
            }

            LibraryLocations.TreeNodePopulate += new TreeNodeEventHandler(LibraryLocations_TreeNodePopulate);
            //LibraryLocations.SelectedNodeChanged += new EventHandler(LibraryLocations_SelectedNodeChanged);

            LibraryLocations.PopulateNodesFromClient = true;
            LibraryLocations.EnableClientScript      = true;

            String viewMode = process.IsReplaceActionToCreateNewSeries ? "New" : "Replace";

            treeState = new WBLocationTreeState(SPContext.Current.Web, viewMode, process.ProtectiveZone);

            if (!IsPostBack)
            {
                if (viewMode == "New")
                {
                    Description.Text = "Select the folder into which to publish the document";
                }
                else
                {
                    Description.Text = "Select the document to replace";
                }

                WBTermCollection <WBTerm> teamFunctionalAreas = WorkBox.OwningTeam.FunctionalArea(manager.FunctionalAreasTaxonomy);

                manager.PopulateWithFunctionalAreas(treeState, LibraryLocations.Nodes, viewMode, teamFunctionalAreas);
            }
            else
            {
                String selectedPath = manager.GetSelectedPath(Request);
                if (!String.IsNullOrEmpty(selectedPath))
                {
                    ProcessSelection(selectedPath);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            webPart = this.Parent as PickedDocumentsGroup;

            SPWebPartManager webPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page);

            Guid WebPartGuid = webPartManager.GetStorageKey(webPart);

            WebPartUniqueID = WebPartGuid.ToString().Replace("-", String.Empty);;

            //EditRelatedDocumentsButton.OnClientClick = "WorkBoxFramework_editRelatedDocuments(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + webPart.PickedDocumentsDetails + "\"); return false;";


            String[] detailsToSave = new String[5];

            detailsToSave[0] = WBUtils.ReplaceDelimiterCharacters(webPart.Title);
            detailsToSave[1] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupDescription);
            detailsToSave[2] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupSubjectTags);
            detailsToSave[3] = WBUtils.ReplaceDelimiterCharacters(webPart.DocumentsGroupCoverage);
            detailsToSave[4] = WBUtils.ReplaceDelimiterCharacters(webPart.PickedDocumentsDetails.WBxTrim());

            String currentDetails = String.Join(",", detailsToSave);

            WBLogging.Debug("Current details: " + currentDetails);

            if (IsPostBack)
            {
                if (NeedToSave.Value == "true")
                {
                    WBLogging.Debug("Trying to save value: " + NewDocumentsGroupDetails.Value);

                    string[] newDetails = NewDocumentsGroupDetails.Value.WBxTrim().Split(',');

                    if (newDetails.Length != 5)
                    {
                        WBLogging.Debug("The details sent to this page have the wrong structure: " + NewDocumentsGroupDetails.Value);
                        Description.Text = "(the web part has not yet been edited).";
                        return;
                    }


                    webPart.Title = WBUtils.PutBackDelimiterCharacters(newDetails[0]);
                    webPart.DocumentsGroupDescription = WBUtils.PutBackDelimiterCharacters(newDetails[1]);
                    webPart.DocumentsGroupSubjectTags = WBUtils.PutBackDelimiterCharacters(newDetails[2]);
                    webPart.DocumentsGroupCoverage    = WBUtils.PutBackDelimiterCharacters(newDetails[3]);
                    webPart.PickedDocumentsDetails    = WBUtils.PutBackDelimiterCharacters(newDetails[4]);

                    webPartManager.SaveChanges(WebPartGuid);

                    SPContext.Current.File.Update();
                    SPContext.Current.Web.Update();

                    currentDetails = NewDocumentsGroupDetails.Value.WBxTrim();

                    WBLogging.Debug("New current details: " + currentDetails);
                }
            }

            if (!String.IsNullOrEmpty(currentDetails) && !currentDetails.Contains(","))
            {
                WBLogging.Generic.Unexpected("The PickRelatedDocuments web part had an odd value: " + currentDetails);
                currentDetails = "";
            }

            if ((SPContext.Current.FormContext.FormMode == SPControlMode.Edit) ||
                (webPartManager.DisplayMode == WebPartManager.EditDisplayMode))
            {
                EditPanel.Visible = true;
                InEditMode        = true;
                EditDocumentsGroupButton.OnClientClick = "WorkBoxFramework_editDocumentsGroup(WBF_EditDialogCallback" + WebPartUniqueID + ", \"" + currentDetails + "\"); return false;";
            }
            else
            {
                EditPanel.Visible = false;
                EditDocumentsGroupButton.OnClientClick = "";
            }



            WBLogging.Debug("PickedDocumentsGroup currentDetails: " + currentDetails);


            Title.Text       = webPart.Title;
            Description.Text = WBUtils.MaybeAddParagraphTags(webPart.DocumentsGroupDescription);

            WBTermCollection <WBTerm> allSubjects = new WBTermCollection <WBTerm>(null, webPart.DocumentsGroupSubjectTags);

            SubjectTags.Text = allSubjects.Names();
            Coverage.Text    = webPart.DocumentsGroupCoverage;


            if (String.IsNullOrEmpty(webPart.PickedDocumentsDetails))
            {
                DocumentsList.Text = "<ul><li>(No documents picked)</li></ul>";
                DocumentsToView    = false;
                return;
            }

            String extranetRecordsLibraryURL = WBFWebPartsUtils.GetExtranetLibraryURL(SPContext.Current.Site);

            SPSite extranetRecordsSite    = null;
            SPWeb  extranetRecordsWeb     = null;
            SPList extranetRecordsLibrary = null;

            try
            {
                string[] documentsDetailsArray = webPart.PickedDocumentsDetails.Split(';');

                String publicRecordsLibraryURL = WBFWebPartsUtils.GetRecordsLibraryURL(SPContext.Current.Site);

                using (SPSite publicRecordsSite = new SPSite(publicRecordsLibraryURL))
                    using (SPWeb publicRecordsWeb = publicRecordsSite.OpenWeb())
                    {
                        SPList publicRecordsLibrary = publicRecordsWeb.GetList(publicRecordsLibraryURL);

                        String html = "<ul>\n";

                        foreach (string documentDetails in documentsDetailsArray)
                        {
                            string[] documentDetailsArray = documentDetails.Split('|');

                            if (documentDetailsArray.Length != 4)
                            {
                                WBLogging.Generic.Unexpected("Badly formatted document details in PickRelatedDocuments web part: " + currentDetails + " - Ignoring these details");
                                continue;
                            }

                            string zone     = documentDetailsArray[0];
                            string recordID = documentDetailsArray[1];
                            string sourceID = documentDetailsArray[2];
                            string filename = documentDetailsArray[3];

                            SPListItem item = null;

                            if (zone == "Public Extranet")
                            {
                                if (extranetRecordsLibrary == null)
                                {
                                    extranetRecordsSite    = new SPSite(extranetRecordsLibraryURL);
                                    extranetRecordsWeb     = extranetRecordsSite.OpenWeb();
                                    extranetRecordsLibrary = extranetRecordsWeb.GetList(extranetRecordsLibraryURL);
                                }

                                item = WBFWebPartsUtils.GetRecord(extranetRecordsSite, extranetRecordsWeb, extranetRecordsLibrary, zone, recordID);
                            }
                            else
                            {
                                item = WBFWebPartsUtils.GetRecord(publicRecordsSite, publicRecordsWeb, publicRecordsLibrary, zone, recordID);
                            }

                            if (item == null)
                            {
                                if (InEditMode)
                                {
                                    html += "<li><i>(Could not find document)</i></li>";
                                }
                            }
                            else
                            {
                                DocumentsToView = true;

                                string title = item.WBxGetAsString(WBColumn.Title);
                                if (String.IsNullOrEmpty(title))
                                {
                                    title = Path.GetFileNameWithoutExtension(item.Name);
                                }

                                string extension = Path.GetExtension(item.Name).Replace(".", "").ToUpper();

                                string additionalText = "";
                                long   fileLength     = (item.File.Length / 1024);
                                additionalText = ", " + fileLength + "KB";

                                if (item.WBxHasValue(WBColumn.ReferenceDate))
                                {
                                    DateTime referenceDate       = (DateTime)item.WBxGet(WBColumn.ReferenceDate);
                                    string   referenceDateString = string.Format("{0}-{1}-{2}",
                                                                                 referenceDate.Year.ToString("D4"),
                                                                                 referenceDate.Month.ToString("D2"),
                                                                                 referenceDate.Day.ToString("D2"));

                                    additionalText += ", " + referenceDateString;
                                }

                                html += String.Format("<li><img src=\"{0}\" alt=\"{1}\"/><a target=\"_blank\" href=\"{2}\">{1}</a> <span>({3})</span></li>",
                                                      WBUtils.DocumentIcon16(item.WBxGetAsString(WBColumn.Name)),
                                                      title,
                                                      item.WBxGetAsString(WBColumn.EncodedAbsoluteURL),
                                                      extension + additionalText);
                            }
                        }

                        html += "</ul>\n";

                        DocumentsList.Text = html;
                    }
            }
            catch (Exception exception)
            {
                if (InEditMode)
                {
                    DocumentsList.Text = "An error occurred: " + exception.Message;
                }
                else
                {
                    DocumentsToView = false;
                }
            }
            finally
            {
                if (extranetRecordsWeb != null)
                {
                    extranetRecordsWeb.Dispose();
                }
                if (extranetRecordsSite != null)
                {
                    extranetRecordsSite.Dispose();
                }
            }
        }
예제 #7
0
        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);
                }
            }
        }
예제 #8
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();
        }
예제 #9
0
        private void BuildListOfAllowedTerms()
        {
            WBFarm farm = WBFarm.Local;

            using (SPSite site = new SPSite(farm.ProtectedRecordsLibraryUrl))
            {
                WBTaxonomy subjectTagsTaxonomy = WBTaxonomy.GetSubjectTags(site);
                WBTaxonomy teamsTaxonomy       = WBTaxonomy.GetTeams(subjectTagsTaxonomy);

                Term   pageSeriesTagTerm   = subjectTagsTaxonomy.GetSelectedTermByPath(FullSubjectTagPath);
                WBTerm localPageSubjectTag = null;
                if (pageSeriesTagTerm != null)
                {
                    localPageSubjectTag = new WBTerm(subjectTagsTaxonomy, pageSeriesTagTerm);
                }

                if (localPageSubjectTag != null)
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        WBQuery query = new WBQuery();

                        //WBQueryClause subjectTagClause = new WBQueryClause(WBColumn.SubjectTags, WBQueryClause.Comparators.Equals, localPageSubjectTag);
                        //subjectTagClause.UseDescendants = true;
                        //query.AddClause(subjectTagClause);

                        if (webPart.OnlyLiveRecords)
                        {
                            WBQueryClause isLiveClause = new WBQueryClause(WBColumn.LiveOrArchived, WBQueryClause.Comparators.Equals, WBColumn.LIVE_OR_ARCHIVED__LIVE);
                            query.AddClause(isLiveClause);
                        }

                        WBTeam team = null;
                        if (!String.IsNullOrEmpty(webPart.FilterByOwningTeam))
                        {
                            team = teamsTaxonomy.GetSelectedTeam(webPart.FilterByOwningTeam);

                            if (team != null)
                            {
                                query.AddEqualsFilter(WBColumn.OwningTeam, team);
                            }
                        }


                        /*
                         * string protectiveZoneFilter = "Public"; // Request.QueryString["ProtectiveZone"];
                         * if (protectiveZoneFilter != null && protectiveZoneFilter != "")
                         * {
                         *  query.AddEqualsFilter(WBColumn.ProtectiveZone, protectiveZoneFilter);
                         * }
                         * */

                        query.AddViewColumn(WBColumn.Name);
                        query.AddViewColumn(WBColumn.SubjectTags);

                        SPList recordsLibrary = web.GetList(farm.ProtectedRecordsLibraryUrl); //"Documents"]; //farm.RecordsCenterRecordsLibraryName];

                        SPListItemCollection documents = recordsLibrary.WBxGetItems(site, query);

                        WBLogging.Debug("Got documents back");

                        WBLogging.Debug("Documents contains " + documents.Count + " items");

                        foreach (SPListItem document in documents)
                        {
                            WBTermCollection <WBTerm> subjectTags = document.WBxGetMultiTermColumn <WBTerm>(subjectTagsTaxonomy, WBColumn.SubjectTags.DisplayName);
                            foreach (WBTerm subjectTag in subjectTags)
                            {
                                string fullPath = subjectTag.FullPath;
                                if (allUsedTerms.Contains(fullPath))
                                {
                                    WBLogging.Debug("Already has term: " + fullPath + "  so not adding");
                                }
                                else
                                {
                                    WBLogging.Debug("Adding to list of allowed terms: " + fullPath);
                                    this.allUsedTerms.Add(fullPath);
                                    while (fullPath.Contains("/"))
                                    {
                                        int lastIndex = fullPath.LastIndexOf('/');
                                        fullPath = fullPath.Substring(0, lastIndex);
                                        if (allUsedTerms.Contains(fullPath))
                                        {
                                            WBLogging.Debug("Already has term: " + fullPath + "  so not adding");
                                            fullPath = "";
                                        }
                                        else
                                        {
                                            allUsedTerms.Add(fullPath);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    WBUtils.logMessage("pageSubjectTag was null");
                }
            }
        }
예제 #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                String currentUserLoginName = SPContext.Current.Web.CurrentUser.LoginName;

                WBTaxonomy teams           = WBTaxonomy.GetTeams(SPContext.Current.Site);
                WBTaxonomy functionalAreas = WBTaxonomy.GetFunctionalAreas(teams);
                WBTeam     team            = WBTeam.GetFromTeamSite(teams, SPContext.Current.Web);
                if (team == null)
                {
                    WorkBox workBox = WorkBox.GetIfWorkBox(SPContext.Current);
                    if (workBox != null)
                    {
                        team = workBox.OwningTeam;
                    }
                }

                // Check if this user has permission - checking basic team membership:
                if (team == null || !team.IsCurrentUserTeamMember())
                {
                    AccessDeniedPanel.Visible          = true;
                    UpdateRecordsMetadataPanel.Visible = false;
                    AccessDeniedReason.Text            = "You are not a member of this team";
                    return;
                }

                RecordID.Text = Request.QueryString["RecordID"];
                WBLogging.Debug("Record ID is found to be: " + RecordID.Text);

                using (WBRecordsManager manager = new WBRecordsManager(currentUserLoginName))
                {
                    WBRecord record = manager.Libraries.GetRecordByID(RecordID.Text);

                    record.CheckMetadata();

                    Filename.Text    = record.Name;
                    RecordTitle.Text = record.Title;

                    String location = "<unknown>";
                    if (record.FunctionalArea != null && record.FunctionalArea.Count > 0)
                    {
                        WBLogging.Debug("Found functional area = " + record.FunctionalArea);
                        WBTerm functionalArea = record.FunctionalArea[0];
                        location = functionalArea.FullPath;
                        WBLogging.Debug("location = " + location);

                        WBTermCollection <WBTerm> teamsFunctionalAreas = team.FunctionalArea(functionalAreas);

                        if (!teamsFunctionalAreas.Contains(functionalArea))
                        {
                            WBLogging.Debug("Team functional areas UIControlValue: " + teamsFunctionalAreas.UIControlValue);
                            WBLogging.Debug("Record's functional area UIControlValue: " + functionalArea);

                            AccessDeniedPanel.Visible          = true;
                            UpdateRecordsMetadataPanel.Visible = false;
                            AccessDeniedReason.Text            = "The team " + team.Name + " does not have permission to edit this functional area: " + functionalArea.Name;
                            return;
                        }
                    }
                    location += "/" + record.RecordsType.FullPath;

                    String folders = record.ProtectedMasterRecord.LibraryRelativePath.Replace(record.Name, "").Replace(location, "");

                    RecordsLocation.Text = "<b>" + location + "</b> " + folders;

                    String status = record.RecordSeriesStatus;
                    RecordSeriesStatus.Text = status;

                    String explainStatus = "";
                    if (status == "Latest")
                    {
                        if (record.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC)
                        {
                            explainStatus = "(live on the public website)";
                        }
                        else if (record.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET)
                        {
                            explainStatus = "(live on a public extranet website)";
                        }
                        else
                        {
                            explainStatus = "(live on izzi intranet)";
                        }
                    }
                    else if (status == "Retired")
                    {
                        explainStatus = "(visible on izzi intranet searches)";
                    }
                    else if (status == "Archived")
                    {
                        explainStatus = "(archived in the protected, master records library)";
                    }
                    ExplainStatus.Text = explainStatus;

                    RecordSeriesStatusChange.DataSource = new String[] { "", "Retire", "Archive" };
                    RecordSeriesStatusChange.DataBind();
                    RecordSeriesStatusChange.SelectedValue = "";

                    ProtectiveZone.DataSource = new String[] { WBRecordsType.PROTECTIVE_ZONE__PROTECTED, WBRecordsType.PROTECTIVE_ZONE__PUBLIC };
                    ProtectiveZone.DataBind();
                    ProtectiveZone.SelectedValue = record.ProtectiveZone;

                    manager.SubjectTagsTaxonomy.InitialiseTaxonomyControl(SubjectTags, WBColumn.SubjectTags.DisplayName, true);
                    SubjectTags.Text = record.SubjectTagsUIControlValue;

                    manager.TeamsTaxonomy.InitialiseTaxonomyControl(OwningTeam, WBColumn.OwningTeam.DisplayName, false);
                    OwningTeam.Text = record.OwningTeam.UIControlValue;

                    manager.TeamsTaxonomy.InitialiseTaxonomyControl(InvolvedTeams, WBColumn.InvolvedTeams.DisplayName, true);
                    InvolvedTeams.Text = record.InvolvedTeamsWithoutOwningTeamAsUIControlValue;
                }
            }
        }