Exemplo n.º 1
0
        protected override void OnLoad(EventArgs e)
        {
            if (Request.QueryString["items"] != null && Request.QueryString["source"] != null && Request.QueryString["sourceurl"] != null)
            {
                string   source     = Request.QueryString["source"];
                string[] items      = Request.QueryString["items"].ToString().Split('|');
                string   currentWeb = Request.QueryString["sourceurl"].Replace("'", string.Empty);

                lblInstructions.Text = "You have selected the following documents to tag.<br><br>";
                source = source.Substring(1, source.Length - 2).ToLower();
                Guid sourceId = new Guid(source);

                SPWeb             web = SPContext.Current.Web;
                SPDocumentLibrary sourceDocLibrary = (SPDocumentLibrary)web.Lists[sourceId];
                listItems = new List <SPListItem>();

                //start at 1 due to items split containing a leading empty value
                for (int i = 1; i < items.Length; i++)
                {
                    SPListItem currentListItem = sourceDocLibrary.GetItemById(int.Parse(items[i]));
                    listItems.Add(currentListItem);
                    lblItems.Text += currentListItem.Name + "<br>";
                }
            }
        }
Exemplo n.º 2
0
        private void PopulateSelectedDocs()
        {
            string source = Request.QueryString["source"];

            source = source.Substring(1, source.Length - 2).ToLower();
            string[]          items            = Request.QueryString["items"].ToString().Split('|');
            Guid              sourceId         = new Guid(source);
            SPWeb             web              = SPContext.Current.Web;
            SPDocumentLibrary sourceDocLibrary = (SPDocumentLibrary)web.Lists[sourceId];

            //start at 1 due to items split containing a leading empty value
            for (int i = 1; i < items.Length; i++)
            {
                SPListItem currentListItem = sourceDocLibrary.GetItemById(int.Parse(items[i]));
                if (currentListItem.File != null)
                {
                    TreeNode tn = new TreeNode();
                    tn.ShowCheckBox = true;
                    tn.SelectAction = TreeNodeSelectAction.None;
                    tn.Checked      = true;
                    tn.Text         = currentListItem.File.Name;
                    tn.Value        = web.Url + "/" + currentListItem.File.Url;
                    tn.ImageUrl     = web.Url + "/_layouts/images/" + currentListItem.File.IconUrl;
                    treeViewSelectedDocs.Nodes.Add(tn);
                    tn = null;
                }
            }
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string listId = Request.Params["listId"];

            if (string.IsNullOrEmpty(listId))
            {
                return;
            }

            SPList list = SPContext.Current.Web.Lists.GetList(new Guid(listId), false);

            if (!list.IsDocumentLibrary())
            {
                return;
            }

            string pItemIds = Request.Params["itemIDs"];

            if (string.IsNullOrEmpty(pItemIds))
            {
                return;
            }

            SPDocumentLibrary library = (SPDocumentLibrary)list;

            string[] sItemIds = pItemIds.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            int[]    itemsIDs = new int[sItemIds.Length];
            for (int i = 0; i < sItemIds.Length; i++)
            {
                itemsIDs[i] = Convert.ToInt32(sItemIds[i]);
            }

            if (itemsIDs.Length > 0)
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    using (ZipFileBuilder builder = new ZipFileBuilder(ms))
                    {
                        foreach (int id in itemsIDs)
                        {
                            SPListItem item = library.GetItemById(id);
                            if (item.IsFolder())
                            {
                                AddFolder(builder, item.Folder, string.Empty);
                            }
                            else
                            {
                                AddFile(builder, item.File, string.Empty);
                            }
                        }

                        builder.Finish();
                        WriteStreamToResponse(ms);
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPLongOperation.Begin(delegate(SPLongOperation longOperation)
            {
                longOperation.TrailingHTML = "Please wait while your data is being exported...";
                try
                {
                    if (Request.QueryString["items"] != null && Request.QueryString["source"] != null && Request.QueryString["sourceurl"] != null)
                    {
                        string source     = Request.QueryString["source"];
                        string[] items    = Request.QueryString["items"].ToString().Split('|');
                        string currentWeb = Request.QueryString["sourceurl"].Replace("'", string.Empty);

                        source        = source.Substring(1, source.Length - 2).ToLower();
                        Guid sourceId = new Guid(source);

                        SPWeb web = SPContext.Current.Web;
                        SPDocumentLibrary sourceDocLibrary = (SPDocumentLibrary)web.Lists[sourceId];
                        SPFolder folder = null;
                        itemsToExport   = new List <SPListItem>();

                        //start at 1 due to items split containing a leading empty value
                        for (int i = 1; i < items.Length; i++)
                        {
                            SPListItem currentListItem = sourceDocLibrary.GetItemById(int.Parse(items[i]));
                            itemsToExport.Add(currentListItem);
                            folder = currentListItem.File.ParentFolder;
                        }

                        // build a memory stream of our file contents
                        MemoryStream exportStream = BuildStreamToExport(itemsToExport);
                        // save our export file to our doc libary
                        web.AllowUnsafeUpdates = true;
                        SaveFile(exportStream, folder);
                        web.AllowUnsafeUpdates = false;

                        //close the modal
                        //Response.Write(string.Format(CultureInfo.InvariantCulture, "<script type=\"text/javascript\">window.frameElement.commonModalDialogClose(1, '{0}');</script>", itemsToExport.Count));
                        //Response.Flush();
                        //Response.End();
                        if (SPContext.Current.IsPopUI)
                        {
                            longOperation.EndScript("window.frameElement.commitPopup();");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Instance.Error("Error while loading documents for metadata export.", ex, DiagnosticsCategories.eCaseWeb);
                }
            }
                                  );
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SPGroup publishersGroup = WorkBox.OwningTeam.PublishersGroup(SPContext.Current.Site);

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

            if (!IsPostBack)
            {
                if (Request.QueryString["selectedItemsIDsString"] != null && Request.QueryString["selectedListGUID"] != null)
                {
                    string   selectedListGUID = Request.QueryString["selectedListGUID"];
                    string[] selectedItemsIDs = Request.QueryString["selectedItemsIDsString"].ToString().Split('|');

                    WBUtils.logMessage("The list GUID was: " + selectedListGUID);
                    selectedListGUID = selectedListGUID.Substring(1, selectedListGUID.Length - 2).ToLower();

                    Guid sourceListGuid = new Guid(selectedListGUID);

                    ListGUID.Value = sourceListGuid.ToString();
                    ItemID.Value   = selectedItemsIDs[1].ToString();

                    WBUtils.logMessage("The ListGUID was: " + ListGUID.Value);
                    WBUtils.logMessage("The ItemID was: " + ItemID.Value);

                    SPDocumentLibrary sourceDocLib    = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid];
                    SPListItem        sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value));

                    SourceDocFileName.Text = sourceDocAsItem.Name;

                    SourceDocIcon.AlternateText = "Icon of document being publishing out.";
                    SourceDocIcon.ImageUrl      = SPUtility.ConcatUrls("/_layouts/images/",
                                                                       SPUtility.MapToIcon(WorkBox.Web,
                                                                                           SPUtility.ConcatUrls(WorkBox.Web.Url, sourceDocAsItem.Url), "", IconSize.Size32));

//                    foreach (SPList list in SPContext.Current.Web.Lists)
//                  {
//                    WBUtils.logMessage("Found list name = " + list.Title + " list ID = " + list.ID);
//              }
                }
                else
                {
                    ErrorMessageLabel.Text = "There was an error with the passed through values";
                }
            }
        }
Exemplo n.º 6
0
        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                SPSite theSite = SPContext.Current.Site;
                using (SPWeb rootWeb = theSite.OpenWeb())
                {
                    DocLibRecursive(rootWeb);
                }
            }

            try
            {
                if (Request.QueryString["items"] != null && Request.QueryString["source"] != null && Request.QueryString["sourceurl"] != null)
                {
                    string   source     = Request.QueryString["source"];
                    string[] items      = Request.QueryString["items"].ToString().Split('|');
                    string   currentWeb = Request.QueryString["sourceurl"].Replace("'", string.Empty);

                    lblItems.Text        = null;
                    lblInstructions.Text = "You have selected the following documents to copy.<br><br>";
                    source = source.Substring(1, source.Length - 2).ToLower();
                    Guid sourceId = new Guid(source);

                    SPWeb             web = SPContext.Current.Web;
                    SPDocumentLibrary sourceDocLibrary = (SPDocumentLibrary)web.Lists[sourceId];
                    listFiles = new List <SPFile>();

                    //start at 1 due to items split containing a leading empty value
                    for (int i = 1; i < items.Length; i++)
                    {
                        SPListItem currentListItem = sourceDocLibrary.GetItemById(int.Parse(items[i]));

                        if (currentListItem.File != null)
                        {
                            listFiles.Add(currentListItem.File);
                            lblItems.Text += currentListItem.File.Name + "<br />";
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Instance.Error("Error while loading documents for batch moving.", ex, DiagnosticsCategories.eCaseWeb);
            }
        }
        protected void publishButton_OnClick(object sender, EventArgs e)
        {
            WBLogging.Debug("In publishButton_OnClick()");

            Hashtable metadataProblems = checkMetadataState();

            string protectiveZone = "";


            if (metadataProblems.Count > 0)
            {
                RecordsTypeFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__RECORDS_TYPE].WBxToString();

                FunctionalAreaFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__FUNCTIONAL_AREA].WBxToString();
                ProtectiveZoneMessage.Text      = metadataProblems[WorkBox.COLUMN_NAME__PROTECTIVE_ZONE].WBxToString();

                //               SubjectTagsMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__SUBJECT_TAGS].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();
                ScanDateMessage.Text       = metadataProblems[WorkBox.COLUMN_NAME__SCAN_DATE].WBxToString();

                OwningTeamFieldMessage.Text    = metadataProblems[WorkBox.COLUMN_NAME__OWNING_TEAM].WBxToString();
                InvolvedTeamsFieldMessage.Text = metadataProblems[WorkBox.COLUMN_NAME__INVOLVED_TEAMS].WBxToString();

                pageRenderingRequired = true;
            }
            else
            {
                pageRenderingRequired = false;
            }

            if (pageRenderingRequired)
            {
                WBLogging.Debug("In publishButton_OnClick(): Page render required - not publishing at this point");
                renderPage();
            }
            else
            {
                WBLogging.Debug("In publishButton_OnClick(): No page render required - so moving to publish");

                // The event should only be processed if there is no other need to render the page again

                // First let's update the item with the new metadata values submitted:
                SPDocumentLibrary sourceDocLib    = (SPDocumentLibrary)SPContext.Current.Web.Lists[new Guid(ListGUID.Value)];
                SPListItem        sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value));

                WBDocument document = CaptureAsDocument(sourceDocAsItem, documentRecordsType);

                document.Update();

                /*
                 *
                 *   OK So now we actually publish out the document:
                 *
                 */


                SPFile sourceFile   = sourceDocAsItem.File;
                string errorMessage = "";

                string successMessage = "<h3>Successfully Published Out</h3> <table cellpadding='5'>";
                if (TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX))
                {
                    using (WorkBox workBox = new WorkBox(DestinationURL.Value))
                    {
                        string selectedFolderPath = Request.QueryString["SelectedFolderPath"];
                        if (string.IsNullOrEmpty(selectedFolderPath))
                        {
                            selectedFolderPath = "/";
                        }

                        string destinationRootFolderUrl = DestinationURL.Value + "/" + workBox.DocumentLibrary.RootFolder.Url + selectedFolderPath;

                        errorMessage = sourceFile.WBxCopyTo(destinationRootFolderUrl, new List <String>());

                        if (errorMessage == "")
                        {
                            successMessage += "<tr><td>Filename</td><td><b>" + sourceFile.Name + "</b></td></tr><tr><td>Published out to:</td><td><a href=\"" + destinationRootFolderUrl + "\"><b>" + destinationRootFolderUrl + "</b></a></td></tr>";
                        }
                    }
                }
                else
                {
                    // WBRecordsType recordsType = new WBRecordsType(recordsTypeTaxonomy, document[WBColumn.RecordsType].WBxToString());

                    using (WBRecordsManager manager = new WBRecordsManager(SPContext.Current.Web.CurrentUser.LoginName))
                    {
                        try
                        {
                            WBLogging.Debug("In publishButton_OnClick(): About to try to publish");

                            manager.PublishDocument(WorkBox, document);

                            WBLogging.Debug("In publishButton_OnClick(): Should have finished the publishing");

                            //recordsType.PublishDocument(document, sourceFile.OpenBinaryStream());

                            string fullClassPath = "Just a test"; //  WBUtils.NormalisePath(document.FunctionalArea.Names() + "/" + recordsType.FullPath);

                            successMessage += "<tr><td>Published out to location:</td><td>" + fullClassPath + "</td></tr>\n";


                            if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC)
                            {
                                successMessage += "<tr><td>To public records library</td><td><a href=\"http://stagingweb/publicrecords\">Our public library</a></td></tr>\n";
                            }

                            if (document.ProtectiveZone == WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET)
                            {
                                successMessage += "<tr><td>To public extranet records library</td><td><a href=\"http://stagingextranets/records\">Our public extranet library</a></td></tr>\n";
                            }

                            successMessage += "<tr><td>To internal records library</td><td><a href=\"http://sp.izzi/library/Pages/ViewByFunctionThenType.aspx\">Our internal library</a></td></tr>\n";
                        }
                        catch (Exception exception)
                        {
                            errorMessage = "An error occurred when trying to publish: " + exception.Message;
                            WBLogging.Generic.Unexpected(exception);
                        }
                    }
                }

/*
 *              WBFarm farm = WBFarm.Local;
 *              string destinationRootFolderUrl = farm.ProtectedRecordsLibraryUrl;
 *              List<String> filingPath = null;
 *
 *
 *              filingPath = documentRecordsType.FilingPathForItem(sourceDocAsItem);
 *
 *              string filingPathString = string.Join("/", filingPath.ToArray());
 *
 *              WBLogging.Generic.Verbose("The file is: " + sourceFile.Url);
 *              WBLogging.Generic.Verbose("The destination is: " + destinationRootFolderUrl);
 *              WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString);
 *
 *
 *              string errorMessage = sourceFile.WBxCopyTo(destinationRootFolderUrl, filingPath);
 *
 *              if (errorMessage == "")
 *              {
 *                  successMessage += "<tr><td>Filename</td><td><b>" + sourceFile.Name + "</b></td></tr><tr><td>Published out to:</td><td><a href=\"" + destinationRootFolderUrl + "\"><b>" + destinationRootFolderUrl + "</b></a></td></tr><tr><td>Filing path:</td><td><a href=\"" + destinationRootFolderUrl + "/" + filingPathString + "\"><b>" + filingPathString + "</b></td></tr>";
 *              }
 *
 *              WBLogging.Generic.Verbose("Protective zone was set to be: " + protectiveZone);
 *
 *
 *              if (!TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX)
 *                  && protectiveZone.Equals(WBRecordsType.PROTECTIVE_ZONE__PUBLIC))
 *              {
 *                  // OK so we're going to copy this to the public library as well:
 *              WBLogging.Generic.Verbose("The file is: " + sourceFile.Url);
 *              WBLogging.Generic.Verbose("The destination is: " + farm.PublicRecordsLibraryUrl);
 *              WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString);
 *
 *                  string errorMessagePublic = sourceFile.WBxCopyTo(farm.PublicRecordsLibraryUrl, filingPath);
 *
 *                  if (errorMessagePublic == "")
 *                  {
 *                      successMessage += "<tr><td colspan='2'><b>And also published to the public library.</b></td></tr>";
 *                  }
 *              }
 *
 *              if (!TheDestinationType.Value.Equals(WorkBox.PUBLISHING_OUT_DESTINATION_TYPE__WORK_BOX)
 *                  && protectiveZone.Equals(WBRecordsType.PROTECTIVE_ZONE__PUBLIC_EXTRANET))
 *              {
 *                  // OK so we're going to copy this to the public extranet library as well:
 *                  WBLogging.Generic.Verbose("The file is: " + sourceFile.Url);
 *                  WBLogging.Generic.Verbose("The destination is: " + farm.PublicExtranetRecordsLibraryUrl);
 *                  WBLogging.Generic.Verbose("The destination filing path is: " + filingPathString);
 *
 *                  string errorMessagePublicExtranet = sourceFile.WBxCopyTo(farm.PublicExtranetRecordsLibraryUrl, filingPath);
 *
 *                  if (errorMessagePublicExtranet == "")
 *                  {
 *                      successMessage += "<tr><td colspan='2'><b>And also published to the public extranet library.</b></td></tr>";
 *                  }
 *              }
 */
                successMessage += "</table>";

                if (errorMessage == "")
                {
                    //returnFromDialogOKAndRefresh();
                    GoToGenericOKPage("Publishing Out Success", successMessage);
                }
                else
                {
                    GoToGenericOKPage("Publishing Out Error", errorMessage);

                    //returnFromDialogOK("An error occurred during publishing: " + errorMessage);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            WBLogging.Generic.Verbose("In Page_Load for the public doc metadata dialog");

            // Creating the taxonomy objects for later use:
            recordsTypeTaxonomy     = WBTaxonomy.GetRecordsTypes(WorkBox.Site);
            teamsTaxonomy           = WBTaxonomy.GetTeams(recordsTypeTaxonomy);
            seriesTagsTaxonomy      = WBTaxonomy.GetSeriesTags(recordsTypeTaxonomy);
            subjectTagsTaxonomy     = WBTaxonomy.GetSubjectTags(recordsTypeTaxonomy);
            functionalAreasTaxonomy = WBTaxonomy.GetFunctionalAreas(recordsTypeTaxonomy);

            // If this is the initial call to the page then we need to load the basic details of the document we're publishing out:
            if (!IsPostBack)
            {
                ListGUID.Value = Request.QueryString["ListGUID"];
                ItemID.Value   = Request.QueryString["ItemID"];

                // The following variable has its name due to a strange compliation error with the name 'DestinationType'
                TheDestinationType.Value = Request.QueryString["DestinationType"];
                DestinationURL.Value     = Request.QueryString["DestinationURL"];
                DestinationTitle.Text    = Request.QueryString["DestinationTitle"] + " (" + Request.QueryString["DestinationType"] + ")";

                WBLogging.Generic.Verbose("DestinationType = " + TheDestinationType.Value);
                WBLogging.Generic.Verbose("DestinationURL = " + DestinationURL.Value);
            }

            // Now do a check that we do at this stage have the basic details of the document:
            if (ListGUID.Value == null || ListGUID.Value == "")
            {
                errorMessage += "ListGUID hasn't been set. ";
            }

            if (ItemID.Value == null || ItemID.Value == "")
            {
                errorMessage += "ItemID hasn't been set. ";
            }

            if (TheDestinationType.Value == null || TheDestinationType.Value == "")
            {
                errorMessage += "DestinationType hasn't been set. ";
            }

            if (errorMessage.Length > 0)
            {
                ErrorMessageLabel.Text = errorMessage;
                return;
            }

            // Let's clear out all of the error messages text fields:
            ErrorMessageLabel.Text          = "";
            RecordsTypeFieldMessage.Text    = "";
            FunctionalAreaFieldMessage.Text = "";
            ProtectiveZoneMessage.Text      = "";
            ReferenceIDMessage.Text         = "";
            ReferenceDateMessage.Text       = "";
            SeriesTagFieldMessage.Text      = "";
            ScanDateMessage.Text            = "";
            OwningTeamFieldMessage.Text     = "";
            InvolvedTeamsFieldMessage.Text  = "";


            //OK so we have the basic identity information for the document being published out so let's get the document item:

            Guid sourceListGuid            = new Guid(ListGUID.Value);
            SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid];

            sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value));
            sourceFile      = sourceDocAsItem.File;

            generatingFilename = WorkBox.RecordsType.GeneratePublishOutFilenames;

            // Now, if this is the first time we might need to load up the default metadata values for the document:
            if (!IsPostBack)
            {
                WorkBox.Web.AllowUnsafeUpdates = true;
                WorkBox.ApplyPublishOutDefaults(sourceDocAsItem);
                WorkBox.Web.AllowUnsafeUpdates = false;

                // Let's now re-load the item as it's name may have changed:
                sourceDocAsItem       = null;
                sourceDocAsItem       = sourceDocLib.GetItemById(int.Parse(ItemID.Value));
                sourceFile            = sourceDocAsItem.File;
                pageRenderingRequired = true;
            }
            else
            {
                WBLogging.Debug("Setting the subject tags: " + SubjectTagsField.Text);
                sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__SUBJECT_TAGS, SubjectTagsField.Text);


                // If this is a post back - then let's check if the records type has been modified:
                if (NewRecordsTypeUIControlValue.Value != "")
                {
                    WBLogging.Generic.Unexpected("The returned value was: " + NewRecordsTypeUIControlValue.Value);

                    WBRecordsType oldRecordsType = sourceDocAsItem.WBxGetSingleTermColumn <WBRecordsType>(recordsTypeTaxonomy, WorkBox.COLUMN_NAME__RECORDS_TYPE);
                    WBRecordsType newRecordsType = new WBRecordsType(recordsTypeTaxonomy, NewRecordsTypeUIControlValue.Value);

                    RecordsTypeUIControlValue.Value = NewRecordsTypeUIControlValue.Value;
                    RecordsType.Text      = newRecordsType.Name;
                    pageRenderingRequired = true;

                    // These are now being done in CaptureAsDocument()
                    // sourceDocAsItem.WBxSetSingleTermColumn(WorkBox.COLUMN_NAME__RECORDS_TYPE, NewRecordsTypeUIControlValue.Value);
                    // sourceDocAsItem.WBxSet(WBColumn.Title, this.TitleField.Text);

                    // This is now being done in CaptureAsDocument()
                    // WorkBox.GenerateFilename(newRecordsType, sourceDocAsItem);

                    // If either the old or new records type have an uneditable functional area, then we'll update it to the new default area.
                    if (!oldRecordsType.IsFunctionalAreaEditable || !newRecordsType.IsFunctionalAreaEditable)
                    {
                        WBLogging.Debug("Setting the functional area as it's not editable: " + newRecordsType.DefaultFunctionalAreaUIControlValue);
                        this.FunctionalAreaField.Text = newRecordsType.DefaultFunctionalAreaUIControlValue;
                        sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, newRecordsType.DefaultFunctionalAreaUIControlValue);
                    }

/* This is now being done in CaptureAsDocument()
 *                  else
 *                  {
 *                      WBLogging.Debug("Saving the current functional area selection: " + this.FunctionalAreaField.Text);
 *                      sourceDocAsItem.WBxSetMultiTermColumn(WorkBox.COLUMN_NAME__FUNCTIONAL_AREA, this.FunctionalAreaField.Text);
 *                  }
 */

                    WBDocument document = CaptureAsDocument(sourceDocAsItem, newRecordsType);
                    document.Update();

                    // Let's now re-load the item as it's name may have changed:
                    sourceDocAsItem = null;
                    sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value));
                    sourceFile      = sourceDocAsItem.File;
                }
                else
                {
                    // Otherwise we are in a normal post back call.
                    pageRenderingRequired = false;
                }
            }



            // Now load up some of the basic details:
            documentRecordsType = sourceDocAsItem.WBxGetSingleTermColumn <WBRecordsType>(recordsTypeTaxonomy, WorkBox.COLUMN_NAME__RECORDS_TYPE);

            destinationType = TheDestinationType.Value;

            // Which of the metadata fields are being used in the form (or will need to be processed in any postback) :
            showReferenceID   = documentRecordsType.DocumentReferenceIDRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN;
            showReferenceDate = documentRecordsType.DocumentReferenceDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN;
            showSubjectTags   = true; // documentRecordsType.DocumentSubjectTagsRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN;
            showSeriesTag     = documentRecordsType.DocumentSeriesTagRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN;
            showScanDate      = documentRecordsType.DocumentScanDateRequirement != WBRecordsType.METADATA_REQUIREMENT__HIDDEN;

            if (pageRenderingRequired)
            {
                renderPage();
            }
        }
Exemplo n.º 9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WBLogging.Generic.Verbose("In Page_Load for the self approval dialog");

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

            // If this is the initial call to the page then we need to load the basic details of the document we're publishing out:
            if (!IsPostBack)
            {
                process         = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(Request.QueryString["PublishingProcessJSON"]);
                process.WorkBox = WorkBox;

//                WBLogging.Debug("Created the WBProcessObject");

                PublishingProcessJSON.Value = WBUtils.SerializeToCompressedJSONForURI(process);

                //             WBLogging.Debug("Serialized the WBProcessObject to hidden field");
            }
            else
            {
                process         = WBUtils.DeserializeFromCompressedJSONInURI <WBPublishingProcess>(PublishingProcessJSON.Value);
                process.WorkBox = WorkBox;
            }



            // Let's clear out all of the error messages text fields:
            ErrorMessageLabel.Text = "";


            //OK so we have the basic identity information for the document being published out so let's get the document item:

            Guid sourceListGuid            = new Guid(process.ListGUID);
            SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid];

            sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(process.CurrentItemID));
            sourceFile      = sourceDocAsItem.File;

            WBDocument sourceDocument = new WBDocument(WorkBox, sourceDocAsItem);

            fileTypeInfo = manager.GetFileTypeInfo(sourceDocument.FileType);

            if (fileTypeInfo != null)
            {
                Dictionary <String, String> checkBoxDetails = manager.GetCheckBoxDetailsForDocumentType(fileTypeInfo.WBxGetAsString(WBColumn.DocumentType));
                foreach (String checkBoxCode in checkBoxDetails.Keys)
                {
                    CheckBoxes.Controls.Add(CreateCheckBoxDiv(checkBoxCode, checkBoxDetails[checkBoxCode]));
                }

                CheckBoxesCodes.Value = String.Join(";", checkBoxDetails.Keys.ToArray <string>());
            }

            if (!IsPostBack)
            {
                DocumentsBeingPublished.Text = process.GetStandardHTMLTableRows();

                String typeText = null;

                if (fileTypeInfo != null)
                {
                    typeText = fileTypeInfo.WBxGetAsString(WBColumn.DocumentType) + " (" + fileTypeInfo.WBxGetAsString(WBColumn.FileTypePrettyName) + ")";
                }
                if (String.IsNullOrEmpty(typeText))
                {
                    typeText = sourceDocument.FileType + " " + sourceDocument.Name;
                }
                DocumentType.Text = typeText;
                WBLogging.Debug("The file type of the record is: " + typeText);

                IAO.Text = "<none found>";
                if (!String.IsNullOrEmpty(process.OwningTeamsIAOAtTimeOfPublishing))
                {
                    SPUser owningTeamIAO = SPContext.Current.Web.WBxEnsureUserOrNull(process.OwningTeamsIAOAtTimeOfPublishing);
                    if (owningTeamIAO != null)
                    {
                        IAO.Text = owningTeamIAO.Name;
                    }
                }
            }
        }
        public SPFile GetFile(SPDocumentLibrary lib, int id)
        {
            SPListItem item = lib.GetItemById(id) ;

            return item.File;
        }
Exemplo n.º 11
0
        public String RenderClipboardItems(SPSite site)
        {
            UserProfile profile = GetUserProfile(site);
            Dictionary <String, List <int> > clipboardItems = new Dictionary <String, List <int> >();
            String clipboardAction = GetClipboard(profile, clipboardItems);

            if (clipboardItems.Count == 0)
            {
                return("<div class='wbf-clipboard-items'><p>Clipboard is empty</p></div>");
            }

            String html = "<div class='wbf-clipboard-items'>";

            String actionImageSrc = "";

            if (clipboardAction == CLIPBOARD_ACTION__CUT)
            {
                actionImageSrc = "/_layouts/images/cuths.png";
            }
            else
            {
                actionImageSrc = "/_layouts/images/copy16.gif";
            }

            foreach (String workBoxURL in clipboardItems.Keys)
            {
                List <int> ids = clipboardItems[workBoxURL];

                using (WorkBox clipboardWorkBox = new WorkBox(workBoxURL))
                {
                    html += "<div class='wbf-clipboard-from-work-box'><b>From:</b> <img src=\"/_layouts/images/WorkBoxFramework/work-box-16.png\"/> <b>" + clipboardWorkBox.Title + "</b> ";

                    SPDocumentLibrary documents = clipboardWorkBox.DocumentLibrary;

                    if (ids.Count > 0)
                    {
                        Dictionary <String, String> htmlFragmentsToOrder = new Dictionary <string, string>();

                        foreach (int id in ids)
                        {
                            String htmlFragment = "<div class='wbf-clipboard-item'><i>(could not find an item)</i></div>";

                            try
                            {
                                SPListItem item = documents.GetItemById(id);

                                SPFolder fromFolder   = null;
                                String   itemImageSrc = "";
                                if (item.Folder == null)
                                {
                                    fromFolder   = item.File.ParentFolder;
                                    itemImageSrc = WBUtils.DocumentIcon16(item.Name);
                                }
                                else
                                {
                                    fromFolder   = item.Folder.ParentFolder;
                                    itemImageSrc = "/_layouts/images/folder.gif";
                                }

                                htmlFragment  = "<div class='wbf-clipboard-item'>";
                                htmlFragment += "<img src=\"" + actionImageSrc + "\"/>  &nbsp; /" + fromFolder.Url + " &nbsp; <img src=\"" + itemImageSrc + "\"/> <b>" + item.Name + "</b>";
                                htmlFragment += "</div>\n";

                                htmlFragmentsToOrder.Add(fromFolder.Url + "/" + item.Name, htmlFragment);
                            }
                            catch (Exception itemException)
                            {
                                // Trying to add this to the end of the list of items found:
                                htmlFragmentsToOrder.Add("zzzzzzz", htmlFragment);

                                WBUtils.SendErrorReport(clipboardWorkBox.Web, "Error in RenderClipboardItems", "Exception : " + itemException + " \n\n " + itemException.StackTrace);
                            }
                        }

                        List <String> ordering = new List <String>(htmlFragmentsToOrder.Keys);
                        ordering.Sort();

                        foreach (String key in ordering)
                        {
                            html += htmlFragmentsToOrder[key];
                        }
                    }
                    else
                    {
                        html += "<p>Nothing from this work box</p>";
                    }

                    html += "</div>\n";
                }
            }

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

            return(html);
        }
Exemplo n.º 12
0
        public String PasteClipboard(WorkBox workBox, String folderPath)
        {
            Dictionary <String, List <int> > clipboardItems = new Dictionary <String, List <int> >();
            UserProfile userProfile = GetUserProfile(workBox.Site);

            String clipboardAction = "";

            try
            {
                clipboardAction = GetClipboard(userProfile, clipboardItems);

                SPFolder folder = workBox.DocumentLibrary.RootFolder;
                WBLogging.Generic.Unexpected("Folder path: ##" + folderPath + "##");
                if (folder == null)
                {
                    WBLogging.Generic.Unexpected("folder is null !!!");
                }

                folderPath = folderPath.WBxTrim();
                if (!String.IsNullOrEmpty(folderPath))
                {
                    folder = folder.WBxGetFolderPath(folderPath);
                }

                bool allowUnsafeUpdatesOriginalValue = workBox.Web.AllowUnsafeUpdates;
                workBox.Web.AllowUnsafeUpdates = true;

                foreach (String workBoxURL in clipboardItems.Keys)
                {
                    List <int> ids = clipboardItems[workBoxURL];

                    using (WorkBox clipboardWorkBox = new WorkBox(workBoxURL))
                    {
                        clipboardWorkBox.Web.AllowUnsafeUpdates = true;

                        SPDocumentLibrary documents = clipboardWorkBox.DocumentLibrary;

                        foreach (int id in ids)
                        {
                            SPListItem item = documents.GetItemById(id);

                            bool cutOriginal = (clipboardAction == WBUser.CLIPBOARD_ACTION__CUT);

                            try
                            {
                                WBUtils.CutOrCopyIntoFolder(workBox.Web, folder, item, cutOriginal);
                            }
                            catch (Exception docLevelException)
                            {
                                WBUtils.SendErrorReport(workBox.Web, "Error pasting a particular document in PasteClipboard", "Exception : " + docLevelException + " \n\n " + docLevelException.StackTrace);
                            }
                        }

                        clipboardWorkBox.Web.AllowUnsafeUpdates = false;
                    }
                }

                if (clipboardAction == CLIPBOARD_ACTION__CUT)
                {
                    // You cannot paste more than once items that have been cut:
                    ClearClipboard(userProfile);
                }

                workBox.Web.AllowUnsafeUpdates = allowUnsafeUpdatesOriginalValue;
            }
            catch (Exception exception)
            {
                WBUtils.SendErrorReport(workBox.Web, "Error in PasteClipboard", "Exception : " + exception + " \n\n " + exception.StackTrace);
                WBLogging.Generic.Unexpected("Clearing the user's clipboard in the hope that that will fix the error they are having.");
                ClearClipboard(userProfile);
            }


            return(clipboardAction);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // If this is the initial call to the page then we need to load the basic details of the document we're publishing out:
            if (!IsPostBack)
            {
                ListGUID.Value = Request.QueryString["ListGUID"];
                ItemID.Value   = Request.QueryString["ItemID"];

                // The following variable has its name due to a strange compliation error with the name 'DestinationType'
                TheDestinationType.Value = Request.QueryString["DestinationType"];
                DestinationURL.Value     = Request.QueryString["DestinationURL"];
                DestinationTitle.Text    = Request.QueryString["DestinationTitle"];

                if (!string.IsNullOrEmpty(ListGUID.Value))
                {
                    Guid sourceListGuid            = new Guid(ListGUID.Value);
                    SPDocumentLibrary sourceDocLib = (SPDocumentLibrary)WorkBox.Web.Lists[sourceListGuid];

                    SPListItem sourceDocAsItem = sourceDocLib.GetItemById(int.Parse(ItemID.Value));

                    if (sourceDocAsItem != null)
                    {
                        SourceDocIcon.AlternateText = "Icon of document being publishing out.";
                        SourceDocIcon.ImageUrl      = SPUtility.ConcatUrls("/_layouts/images/",
                                                                           SPUtility.MapToIcon(WorkBox.Web,
                                                                                               SPUtility.ConcatUrls(WorkBox.Web.Url, sourceDocAsItem.Url), "", IconSize.Size32));
                    }
                }

                using (WorkBox workBox = new WorkBox(DestinationURL.Value))
                {
                    SPFolder rootFolder = workBox.DocumentLibrary.RootFolder;

                    TreeViewFolderCollection collection = new TreeViewFolderCollection(rootFolder, "(root)");

                    WorkBoxFolders.DataSource = collection;
                    WorkBoxFolders.DataBind();
                }


                SelectedFolderPath.Text = "/";
            }


            // Now do a check that we do at this stage have the basic details of the document:
            if (ListGUID.Value == null || ListGUID.Value == "")
            {
                errorMessage += "ListGUID hasn't been set. ";
            }

            if (ItemID.Value == null || ItemID.Value == "")
            {
                errorMessage += "ItemID hasn't been set. ";
            }

            if (TheDestinationType.Value == null || TheDestinationType.Value == "")
            {
                errorMessage += "DestinationType hasn't been set. ";
            }

            if (errorMessage.Length > 0)
            {
                ErrorMessageLabel.Text = errorMessage;
                return;
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Reads the XML file from an item in a document library <see cref="SPDocumentLibrary" /> that is a file placeholder and deserializes its content to returned object.
        /// </summary>
        /// <typeparam name="type">The type of the an object containing working data retrieved from an XML file.</typeparam>
        /// <param name="library">The <see cref="SPDocumentLibrary" /> that is a placeholder of the file.</param>
        /// <param name="itemId">The item unique identifier. A 32-bit integer that identifies the item. The value of this parameter does
        /// not correspond to the index of the item within the collection of items for the list, but to the value of the <see cref="Microsoft.SharePoint.SPListItem.ID"/> property
        /// of the <see cref="Microsoft.SharePoint.SPListItem"/> class.
        /// </param>
        /// <returns>An object of <typeparamref name="type" /> containing working data retrieved from an XML file.</returns>
        public static type ReadXmlFile <type>(SPDocumentLibrary library, int itemId)
        {
            SPFile _file = library.GetItemById(itemId).File;

            return(File.ReadXmlFile <type>(_file));
        }