Beispiel #1
0
        protected void reopenWorkBoxButton_OnClick(object sender, EventArgs e)
        {
            WorkBox.Open(ReOpenComment.Text);

            DisposeWorkBox();

            CloseDialogAndRefresh();
        }
        private void processChangeRequest(WorkBox workBox)
        {
            WBLogging.Generic.Verbose("WorkBoxMetaDataItemChangeEventReceiver.processChangeRequest()");

            String currentStatus   = workBox.Status;
            String requestedChange = workBox.StatusChangeRequest;

            WBLogging.Generic.Verbose("WorkBoxMetaDataItemChangeEventReceiver.processChangeRequest(): Current status = " + currentStatus + " and requested change = " + requestedChange);

//           this.EventFiringEnabled = false;

            if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__CREATE))
            {
                workBox.Create();
            }
            else if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__OPEN))
            {
                workBox.Open();
            }
            else if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__CLOSE))
            {
                workBox.Close();
            }
            else if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__ARCHIVE))
            {
                workBox.Archive();
            }
            else if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__DELETE))
            {
                workBox.Delete();
            }
            else if (requestedChange.Equals(WorkBox.REQUEST_WORK_BOX_STATUS_CHANGE__REAPPLY_PERMISSIONS))
            {
                workBox.ReapplyPermissions();
                workBox.ClearStatusChangeRequest();
            }
            else
            {
                WBLogging.Generic.Verbose("WorkBoxMetaDataItemChangeEventReceiver.processChangeRequest(): No request for change so doing nothing");
            }

//           this.EventFiringEnabled = true;
        }
Beispiel #3
0
        private String uploadDocument(WBCollection collection, String fileToUpload, String localID, String folderPath, String title, String description, String scanDateString)
        {
            // First check if the work box has been created:
            using (WorkBox workBox = collection.FindOrCreateNewByLocalID(localID))
            {
                if (!workBox.IsOpen)
                {
                    workBox.Open();
                }
            }

            // Then re-load the work box to ensure we dont get security problems:
            using (WorkBox workBox = collection.FindOrCreateNewByLocalID(localID))
            {
                if (!System.IO.File.Exists(fileToUpload))
                {
                    return("File not found.");
                }

                try
                {
                    SPFolder folder = workBox.DocumentLibrary.RootFolder.WBxGetOrCreateFolderPath(folderPath);

                    // Prepare to upload
                    Boolean replaceExistingFiles = true;
                    String  fileName             = Path.GetFileName(fileToUpload);
                    String  extension            = Path.GetExtension(fileName);

                    String newFileName = title + extension;

                    FileStream fileStream = File.OpenRead(fileToUpload);

                    fileName = fileName.Replace('~', '-');
                    WBLogging.Migration.Verbose("fileName = " + fileName);
                    WBLogging.Migration.Verbose("newFileName = " + newFileName);
                    WBLogging.Migration.Verbose("folder.Name = " + folder.Name);
                    WBLogging.Migration.Verbose("folder.Url = " + folder.Url);
                    // Upload document

                    string uniqueName = workBox.Web.WBxMakeFilenameUnique(folder, newFileName);

                    SPFile spfile = folder.Files.Add(uniqueName, fileStream, replaceExistingFiles);
//                    folder.Update();


                    try
                    {
                        DateTime scanDate = Convert.ToDateTime(scanDateString);
                        spfile.Item[WorkBox.COLUMN_NAME__SCAN_DATE] = scanDate;

                        spfile.Update();
                    }
                    catch (Exception e)
                    {
                        WBLogging.Migration.Unexpected("Couldn't convert the date: " + scanDateString + " error was: " + e.Message);
                    }
                }
                catch (Exception e)
                {
                    WBLogging.Migration.Unexpected("An exception: " + e.Message);
                    return("An exception: " + e.Message);
                }

                return("Success.");
            }
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string localID = Request.QueryString["LocalID"];

            if (localID == null || localID == "")
            {
                localID = Request.QueryString["IASClientID"];
            }


            if (localID == null || localID == "")
            {
                ErrorMessage.Text = "Could not find the LocalID on the request parameters.";
                return;
            }

            bool   justFind       = false;
            string justFindString = Request.QueryString["JustFind"];

            if (justFindString != null && justFindString != "")
            {
                WBUtils.logMessage("Testing JustFind = " + justFindString);

                justFind = true.ToString().ToLower().Equals(justFindString.ToLower());

                WBUtils.logMessage("Testing justFind = " + justFind);
                WBUtils.logMessage("true.ToString() = " + true.ToString());
            }
            else
            {
                WBUtils.logMessage("No JustFind query parameter");
            }

            using (WBCollection collection = new WBCollection(SPContext.Current))
            {
                WorkBox workBox = collection.FindByLocalID(localID);

                if (workBox == null)
                {
                    WBUtils.logMessage(" workBox was NULL");
                }

                if (workBox == null && justFind)
                {
                    string html = "<h3>There is no work box with ID: " + localID + "</h3>\n";

                    html += "<a href=\"routing.aspx?LocalID=" + localID + "&justFind=false\">Click here to create a new work box with this ID</a>\n";

                    DoesNotExistYet.Text = html;
                }
                else
                {
                    using (SPLongOperation longOperation = new SPLongOperation(this.Page))
                    {
                        if (workBox == null)
                        {
                            longOperation.LeadingHTML  = "No documents found: creating new work box.";
                            longOperation.TrailingHTML = "This service user doesn't yet have a work box so it is being created.";
                        }
                        else
                        {
                            longOperation.LeadingHTML  = "Found service user's work box.";
                            longOperation.TrailingHTML = "Please wait while the work box is opened.";
                        }

                        longOperation.Begin();

                        collection.Site.AllowUnsafeUpdates = true;
                        collection.Web.AllowUnsafeUpdates  = true;
                        if (workBox == null)
                        {
                            workBox = collection.RequestNewWorkBox("", localID);
                        }

                        if (workBox.HasBeenCreated)
                        {
                            workBox.Web.AllowUnsafeUpdates = true;
                        }

                        if (!workBox.HasBeenOpened)
                        {
                            workBox.Open();
                        }

                        string workBoxUrl = workBox.Url;

                        workBox.Web.AllowUnsafeUpdates     = false;
                        collection.Web.AllowUnsafeUpdates  = false;
                        collection.Site.AllowUnsafeUpdates = false;

                        workBox.Dispose();

                        longOperation.End(workBoxUrl, SPRedirectFlags.Static, Context, "");
                    }
                }
            }
        }
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            WBLogging.Teams.Unexpected("In WBTeamSiteCalendarChangeEventReceiver(): Requesting a new team event");

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

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


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

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

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

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

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

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

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

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

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

                        workBox.Dispose();
                    }

            base.ItemAdded(properties);
        }
Beispiel #6
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);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// An item was added.
        /// </summary>
        public override void ItemAdded(SPItemEventProperties properties)
        {
            WBLogging.Teams.Unexpected("In WBLinkedCalendarUpdatesEventReceiver(): Requesting a new team event");

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

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

                        workBox.Dispose();
                    }

            base.ItemAdded(properties);
        }