Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string relatedWorkBoxUrl     = "";
            string recordsTypeGUIDString = "";

            // Set the reference date control to match the locally set locale:
            ReferenceDate.LocaleId = SPContext.Current.Web.Locale.LCID;

            recordsTypes    = WBTaxonomy.GetRecordsTypes(SPContext.Current.Site);
            teams           = WBTaxonomy.GetTeams(recordsTypes);
            seriesTags      = WBTaxonomy.GetSeriesTags(recordsTypes);
            functionalAreas = WBTaxonomy.GetFunctionalAreas(recordsTypes);

            if (!IsPostBack)
            {
                WorkBoxCollectionUrl.Value = Request.QueryString["workBoxCollectionUrl"];
                pageRenderingRequired      = true;

                recordsTypeGUIDString = Request.QueryString["recordsTypeGUID"];
                RecordsTypeGUID.Value = recordsTypeGUIDString;

                if (recordsTypeGUIDString != "")
                {
                    workBoxRecordsType = recordsTypes.GetRecordsType(new Guid(recordsTypeGUIDString));
                }
                else
                {
                    WBLogging.Generic.Unexpected("The records type GUID appears to be blank in initial call to page!");
                }


                // Now to setup some default intiail values:

                ReferenceDate.SelectedDate = DateTime.Now;

                functionalAreaFieldIsEditable = workBoxRecordsType.IsFunctionalAreaEditable;

                string owningTeamGuidString = Request.QueryString["owningTeamGUID"];
                WBTeam owningTeam           = null;

                if (owningTeamGuidString != null && !owningTeamGuidString.Equals(""))
                {
                    owningTeam = teams.GetTeam(new Guid(owningTeamGuidString));

                    OwningTeamField.Text           = owningTeam.Name; //  UIControlValue;
                    OwningTeamUIControlValue.Value = owningTeam.UIControlValue;

                    InvolvedTeamsField.Text = owningTeam.UIControlValue;
                }

                relatedWorkBoxUrl       = Request.QueryString["relatedWorkBoxURL"];
                RelatedWorkBoxUrl.Value = relatedWorkBoxUrl;
                RelationType.Value      = Request.QueryString["relationType"];
                if (relatedWorkBoxUrl != null && relatedWorkBoxUrl != "")
                {
                    relatedWorkBox = new WorkBox(relatedWorkBoxUrl);

                    ReferenceID.Text = relatedWorkBox.ReferenceID;

                    WBTerm seriesTag = relatedWorkBox.SeriesTag(seriesTags);
                    if (seriesTag != null)
                    {
                        seriesTagInitialValue = seriesTag.UIControlValue;
                    }

                    owningTeam                     = relatedWorkBox.OwningTeam;
                    OwningTeamField.Text           = owningTeam.Name; //  UIControlValue;
                    OwningTeamUIControlValue.Value = owningTeam.UIControlValue;
                    InvolvedTeamsField.Text        = relatedWorkBox.InvolvedTeams.UIControlValue;
                }


                // Now let's setup the initial value for the functional area:
                if (functionalAreaFieldIsEditable)
                {
                    functionalAreaInitialValue = workBoxRecordsType.DefaultFunctionalAreaUIControlValue;

                    if (functionalAreaInitialValue == null || functionalAreaInitialValue == "")
                    {
                        if (owningTeam != null)
                        {
                            functionalAreaInitialValue = owningTeam.FunctionalArea(functionalAreas).UIControlValue;
                        }
                    }
                }
                else
                {
                    functionalAreaInitialValue = workBoxRecordsType.DefaultFunctionalAreaUIControlValue;
                }
            }
            else
            {
                WBUtils.logMessage("In the postback with workBoxCollectionUrl = " + WorkBoxCollectionUrl.Value);
                pageRenderingRequired = false;

                relatedWorkBoxUrl = RelatedWorkBoxUrl.Value;

                recordsTypeGUIDString = RecordsTypeGUID.Value;

                if (recordsTypeGUIDString != "")
                {
                    workBoxRecordsType = recordsTypes.GetRecordsType(new Guid(recordsTypeGUIDString));
                }
                else
                {
                    WBLogging.Generic.Unexpected("The records type GUID appears to be blank in postback!");
                }
            }



            if (pageRenderingRequired)
            {
                renderPage();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            DialogTitle.Text = "An Error Occurred";

            if (!WorkBox.CurrentUserIsOwner() && !WorkBox.CurrentUserIsBusinessAdmin() && !WorkBox.CurrentUserIsSystemAdmin())
            {
                AreYouSureText.Text  = "Only owners or admin can remove teams or individuals from having access to a work box.";
                RemoveButton.Enabled = false;
                return;
            }

            if (!IsPostBack)
            {
                TeamOrIndividual.Value   = Request.QueryString["TeamOrIndividual"];
                InvolvedOrVisiting.Value = Request.QueryString["InvolvedOrVisiting"];

                if (TeamOrIndividual.Value == "Team")
                {
                    GUIDOfTeamToRemove.Value = Request.QueryString["GUIDOfTeamToRemove"];
                }

                if (TeamOrIndividual.Value == "Individual")
                {
                    LoginNameOfUserToRemove.Value = Request.QueryString["LoginNameOfUserToRemove"];
                }

                CancelButton.Focus();
            }

            if (String.IsNullOrEmpty(TeamOrIndividual.Value))
            {
                AreYouSureText.Text = "Error in the parameters sent to this dialog.";
                return;
            }

            AreYouSureText.Text = "Odd error in the parameters sent to this dialog.";

            if (TeamOrIndividual.Value == "Team" && !String.IsNullOrEmpty(GUIDOfTeamToRemove.Value))
            {
                teams = WBTaxonomy.GetTeams(SPContext.Current.Site);

                team = teams.GetTeam(new Guid(GUIDOfTeamToRemove.Value));

                if (!IsPostBack)
                {
                    if (InvolvedOrVisiting.Value == "Involved")
                    {
                        DialogTitle.Text            = "Remove Involved Team";
                        AreYouSureText.Text         = "Are you sure you want to remove the following team from being involved with this work box?";
                        NameOfTeamOrIndividual.Text = "Removing involved team: <b>" + team.Name + "</b>";
                    }
                    else
                    {
                        DialogTitle.Text            = "Remove Visiting Team";
                        AreYouSureText.Text         = "Are you sure you want to remove the following team from being able to visit this work box?";
                        NameOfTeamOrIndividual.Text = "Removing visiting team: <b>" + team.Name + "</b>";
                    }
                }
            }

            if (TeamOrIndividual.Value == "Individual" && !String.IsNullOrEmpty(LoginNameOfUserToRemove.Value))
            {
                user = WorkBox.Web.WBxEnsureUserOrNull(LoginNameOfUserToRemove.Value);

                if (!IsPostBack)
                {
                    if (InvolvedOrVisiting.Value == "Involved")
                    {
                        DialogTitle.Text            = "Remove Involved Individual";
                        AreYouSureText.Text         = "Are you sure you want to remove the following individual from being involved with this work box?";
                        NameOfTeamOrIndividual.Text = "Removing involved individual: <b>" + user.Name + "</b>";
                    }
                    else
                    {
                        DialogTitle.Text            = "Remove Visiting Individual";
                        AreYouSureText.Text         = "Are you sure you want to remove the following individual from being able to visit this work box?";
                        NameOfTeamOrIndividual.Text = "Removing visiting individual: <b>" + user.Name + "</b>";
                    }
                }
            }

            if (!IsPostBack)
            {
                DisposeWorkBox();
            }
        }