protected void Page_Load(object sender, System.EventArgs e)
        {
            ticketing = new BrokerDB();
            if (Session["UserID"] == null)
                Response.Redirect("../login.aspx");

            //only superusers can view this page
            if (!Session["GroupName"].ToString().Equals(Group.SUPERUSER))
                Response.Redirect("../home.aspx");

            // Set the popup buttons' "CausesValidation" property.
            // For any button that is related to a popup, you have to set the CausesValidation
            // propery to false, otherwise
            // any RequiredFieldValidator control will cause the onclick event to be
            // comandeered by a routine in ASP.NET's WebValidationUI.js file.
            // The result would be that the custom onclick for the popup would not fire.

            //btnEditList.CausesValidation = false;
            btnAddEditResources.CausesValidation = false;
            btnRemove.CausesValidation = false;
            btnMetadata.CausesValidation = false;

            // This button enables the popup to fire an event on the caller when the Save button is hit.
            btnRefresh.CausesValidation = false;

            // "Are you sure" javascript for Remove button
            StringBuilder jScript = new StringBuilder();
            jScript.Append( "javascript:if(confirm('Are you sure you want to remove this Lab Client? ");
            jScript.Append(" Removing the client will also delete all past experiments  and clientItems!");
            jScript.Append(" Deleting a ClientID should only be done prior to any user experiments being run.");
            jScript.Append( "')== false) return false;");
            btnRemove.Attributes.Add("onclick",jScript.ToString());

            // This is a hidden input tag. The associatedLabServers popup changes its value using a window.opener call in javascript,
            // then the GetPostBackEventReference fires the event associated with the btnRefresh button.
            // The result is that the LabServer repeater (repLabServers) is refreshed when the Save button is clicked
            // on the popup.
            hiddenPopupOnSave.Attributes.Add("onpropertychange", Page.GetPostBackEventReference(btnRefresh));

            if (!Page.IsPostBack)
            {
                hdnEssID.Value = zero;
                hdnNeedsEss.Value = zero;
                hdnLabServerID.Value = zero;
                hdnUssID.Value = zero;
                hdnNeedsUss.Value = zero;

                // Load Lab Client dropdown
                InitializeClientDropDown();

                //Put in client types
                ddlClientTypes.Items.Add(new ListItem("--- Select a Client Type ---", zero));
                string[] clientTypes = InternalAdminDB.SelectLabClientTypes();
                foreach (string cType in clientTypes)
                {
                    ddlClientTypes.Items.Add(new ListItem(cType));
                }

                ddlLabServer.Items.Add(new ListItem("--- Select a Lab Server ---", zero));
                IntTag[] lsTags = ticketing.GetProcessAgentTagsByType(new int[] { (int)ProcessAgentType.AgentType.BATCH_LAB_SERVER, (int)ProcessAgentType.AgentType.LAB_SERVER });
                foreach (IntTag ls in lsTags)
                {
                    ListItem li = new ListItem(ls.tag, ls.id.ToString());
                    ddlLabServer.Items.Add(li);
                }

                //Put in availabe USS
                ListItem liHeaderUss = new ListItem("---Select User Side Scheduling Server---", zero);
                ddlAssociatedUSS.Items.Add(liHeaderUss);
                IntTag[] usses = ticketing.GetProcessAgentTagsByType(ProcessAgentType.SCHEDULING_SERVER, ProcessAgentDB.ServiceGuid);
                foreach (IntTag uss in usses)
                {
                    ListItem li = new ListItem(uss.tag, uss.id.ToString());
                    ddlAssociatedUSS.Items.Add(li);
                }
                //Put in availabe ESS
                ListItem liHeaderEss = new ListItem("---Select Experiment Storage Server---", "0");
                ddlAssociatedESS.Items.Add(liHeaderEss);
                IntTag[] esses = ticketing.GetProcessAgentTagsByType(ProcessAgentType.EXPERIMENT_STORAGE_SERVER, ProcessAgentDB.ServiceGuid);
                foreach (IntTag ess in esses)
                {
                    ListItem li = new ListItem(ess.tag, ess.id.ToString());
                    ddlAssociatedESS.Items.Add(li);
                }

                // Disable the "Edit Lab Servers" button at first
                //btnEditList.Visible = false;
                txtLabServer.ReadOnly = true;
                txtLabServer.BackColor = disabled;
                txtLsUrl.ReadOnly = true;
                txtLsUrl.BackColor = disabled;
                txtAssociatedESS.ReadOnly = true;
                txtAssociatedESS.BackColor = disabled;
                txtAssociatedUSS.ReadOnly = true;
                txtAssociatedUSS.BackColor = disabled;
                ClearFormFields();
                // Reset error/confirmation message
                lblResponse.Text = "";
                lblResponse.Visible = false;

            }
            else if (Request.Params["refresh"] != null)
            {
                string tst = Request.Params["refresh"];
                int cid = Int32.Parse(Request.Params["refresh"]);
                ListItem theItem = ddlLabClient.Items.FindByValue(cid.ToString());
                if (theItem != null)
                {
                    theItem.Selected = true;
                    LoadFormFields();
                }
            }
        }
Exemple #2
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            ticketing = new BrokerDB();
            if (Session["UserID"]==null)
                Response.Redirect("../login.aspx");

            //only superusers can view this page
            if (!Session["GroupName"].ToString().Equals(Group.SUPERUSER))
                Response.Redirect("../home.aspx");

            labClientIDs = wrapper.ListLabClientIDsWrapper();
            labClients = wrapper.GetLabClientsWrapper(labClientIDs);

            // Set the popup buttons' "CausesValidation" property.
            // For any button that is related to a popup, you have to set the CausesValidation
            // propery to false, otherwise
            // any RequiredFieldValidator control will cause the onclick event to be
            // comandeered by a routine in ASP.NET's WebValidationUI.js file.
            // The result would be that the custom onclick for the popup would not fire.

            btnEditList.CausesValidation = false;
            btnAddEditResources.CausesValidation = false;
            btnRemove.CausesValidation = false;

            // This button enables the popup to fire an event on the caller when the Save button is hit.
            btnRefresh.CausesValidation = false;

            // "Are you sure" javascript for Remove button
            btnRemove.Attributes.Add("onclick", "javascript:if(confirm('Are you sure you want to remove this Lab Client?')== false) return false;");

            // This is a hidden input tag. The associatedLabServers popup changes its value using a window.opener call in javascript,
            // then the GetPostBackEventReference fires the event associated with the btnRefresh button.
            // The result is that the LabServer repeater (repLabServers) is refreshed when the Save button is clicked
            // on the popup.
            hiddenPopupOnSave.Attributes.Add("onpropertychange", Page.GetPostBackEventReference(btnRefresh));

            if(!Page.IsPostBack )
            {
                Session.Remove("ClientUssMappingID");
                Session.Remove("ClientEssMappingID");

                // Load Lab Client dropdown
                ddlLabClient.Items.Add(new ListItem(" --- select Lab Client --- ", "0"));

                foreach (LabClient lc in labClients)
                {

                    ddlLabClient.Items.Add(new ListItem(lc.clientName,lc.clientID.ToString()));

                }
                //Put in availabe USS
                ListItem liHeaderUss = new ListItem("---Select User Side Scheduling Server---", "0");
                ddlAssociatedUSS.Items.Add(liHeaderUss);
                IntTag[] usses = ticketing.GetProcessAgentTagsByType(ProcessAgentType.SCHEDULING_SERVER,ProcessAgentDB.ServiceGuid);
                foreach (IntTag uss in usses)
                {
                    ListItem li = new ListItem(uss.tag, uss.id.ToString());
                    ddlAssociatedUSS.Items.Add(li);
                }
                //Put in availabe ESS
                ListItem liHeaderEss = new ListItem("---Select Experiment Storage Server---", "0");
                ddlAssociatedESS.Items.Add(liHeaderEss);
                IntTag[] esses = ticketing.GetProcessAgentTagsByType(ProcessAgentType.EXPERIMENT_STORAGE_SERVER, ProcessAgentDB.ServiceGuid);
                foreach (IntTag ess in esses)
                {
                    ListItem li = new ListItem(ess.tag, ess.id.ToString());
                    ddlAssociatedESS.Items.Add(li);
                }

                //Put in client types
                string[] clientTypes = InternalAdminDB.SelectLabClientTypes();

                foreach (string cType in clientTypes)
                {
                    ListItem li = new ListItem(cType);
                    ddlClientTypes.Items.Add(li);
                }

                // Disable the "Edit Lab Servers" button at first
                btnEditList.Visible = false;

                ddlAssociatedESS.Enabled = false;
                ddlAssociatedUSS.Enabled = false;

                btnRegisterUSS.Visible = false;
                btnRegisterESS.Visible = false;
                btnDissociateUSS.Visible = false;
                btnDissociateESS.Visible = false;

                // Reset error/confirmation message
                lblResponse.Text = "";
                lblResponse.Visible = false;

            }
        }