예제 #1
0
        protected void btnSaveInfoChanges_Click(object sender, System.EventArgs e)
        {
            int index;
            index = int.Parse(hiddenClientInfoIndex.Value);

            // Set the correct element of the clientInfos array to the values from the text boxes
            if (index == clientInfos.Length)
            {
                // new addition
                // create a new ClientInfo object
                ClientInfo newClientInfo = new ClientInfo();
                newClientInfo.description = txtDesc.Text;
                newClientInfo.infoURL = txtUrl.Text;
                newClientInfo.infoURLName = txtInfoname.Text;

                ClientInfo[] enlargedClientInfos;
                enlargedClientInfos = new ClientInfo[index +1];
                for (int i=0; i<index; i++)
                {
                    enlargedClientInfos[i] = clientInfos[i];
                }
                // Add the new ClientInfo object
                enlargedClientInfos[index] = newClientInfo;

                // Set the clientInfos object to the new expanded object
                clientInfos = enlargedClientInfos;
            }
            else
            {
                // modify existing clientInfo
                clientInfos[index].description = txtDesc.Text;
                clientInfos[index].infoURL = txtUrl.Text;
                clientInfos[index].infoURLName = txtInfoname.Text;
            }

            //Save the LabClient object with the updated clientInfos array
            UpdateLabClientInfo(clientInfos);
        }
예제 #2
0
        /// <summary>
        /// Saves the LabClient with the ClienInfo array rewritten into a new order.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSaveOrderChanges_Click(object sender, System.EventArgs e)
        {
            ClientInfo[] newClientInfos = new ClientInfo[clientInfos.Length];
            for (int i=0; i < newClientInfos.Length; i++)
            {
                if (i<lbxChangeOrder.Items.Count)
                //Take the index out of the value in the list box, where it has been preserved.
                newClientInfos[i] = clientInfos[int.Parse(lbxChangeOrder.Items[i].Value)];
                else
                    newClientInfos[i]=clientInfos[i];
            }

            //Save the LabClient object with the updated clientInfos array
            UpdateLabClientInfo(newClientInfos);
        }
예제 #3
0
        /// <summary>
        /// This is the main database update routine.
        /// In order to update the ClientInfo structure in the Lab Client, it is necessary to 
        /// update the entire lab client.
        /// </summary>
        /// <param name="clientInfos"></param>
        private void UpdateLabClientInfo(ClientInfo[] clientInfos)
        {
            try
            {
                wrapper.ModifyLabClientWrapper(labClientID, labClients[0].clientName, labClients[0].version,
                    labClients[0].clientShortDescription, labClients[0].clientLongDescription, labClients[0].notes,
                    labClients[0].loaderScript, labClients[0].clientType, labClients[0].labServerIDs,
                    labClients[0].contactEmail, labClients[0].contactFirstName, labClients[0].contactLastName,
                    labClients[0].needsScheduling, labClients[0].needsESS, labClients[0].IsReentrant, clientInfos);
                // Create the javascript which will cause a page refresh event to fire on the popup's parent page
                string jScript;
                jScript = "<script language=javascript> window.opener.Form1.hiddenPopupOnSave.value='1';";
                // jScript += "window.close();";
                jScript += "</script>";
                Page.RegisterClientScriptBlock("postbackScript", jScript);
            }
            catch (Exception ex)
            {
                divErrorMessage.Visible = true;
                lblResponse.Visible = true;
                lblResponse.Text = "Cannot update Lab Client. " + ex.Message;
            }

            RefreshClientInfoRepeater();
            LoadListBox();
        }
예제 #4
0
        protected void WriteClientInfo(XmlWriter xmlWriter, ClientInfo info)
        {
            xmlWriter.WriteStartElement("clientInfo");
            if (info.infoURL != null)
            {
                xmlWriter.WriteAttributeString("infoUrl",info.infoURL);
            }
            if (info.infoURLName != null)
            {
                xmlWriter.WriteAttributeString("infoUrlName", info.infoURLName);
            }
            if (info.description != null)
            {
                xmlWriter.WriteAttributeString("description", info.description);
            }
            if (info.displayOrder != null)
            {
                xmlWriter.WriteAttributeString("displayOrder", info.displayOrder.ToString());
            }

            xmlWriter.WriteEndElement();
        }
예제 #5
0
        private void RemoveClientInfo(int index)
        {
            ClientInfo[] shrunkClientInfos;
            int offset;
            offset = 0;
            shrunkClientInfos = new ClientInfo[clientInfos.Length -1];
            for (int i=0; i < shrunkClientInfos.Length; i++)
            {
                if (i == index)
                {
                    offset += 1;
                }
                shrunkClientInfos[i] = clientInfos[i + offset];
            }

            // Set the clientInfos object to the new smaller object
            clientInfos = shrunkClientInfos;

            //Save the LabClient object with the updated clientInfos array
            UpdateLabClientInfo(shrunkClientInfos);
        }
예제 #6
0
        public int LoadLabClient(XmlQueryDoc xdoc, ref StringBuilder message)
        {
            string guid = xdoc.Query("/clientDescriptor/clientGuid");
            string type = xdoc.Query("/clientDescriptor/clientType");
            string name = xdoc.Query("/clientDescriptor/clientName");
            string version = xdoc.Query("/clientDescriptor/version");
            string shortDescription = xdoc.Query("/clientDescriptor/clientShortDescription");
            string longDescription = xdoc.Query("/clientDescriptor/clientLongDescription");
            string contactEmail = HttpUtility.HtmlDecode(xdoc.Query("/clientDescriptor/contactEmail"));
            string contactFirstName = xdoc.Query("/clientDescriptor/contactFirstName");
            string contactLastName = xdoc.Query("/clientDescriptor/contactLastName");
            string loaderScript = xdoc.Query("/clientDescriptor/loaderScript");
            string tmp = xdoc.Query("/clientDescriptor/needsScheduling");
            bool needsScheduling = Convert.ToBoolean(tmp);
            tmp = xdoc.Query("/clientDescriptor/needsESS");
            bool needsESS = Convert.ToBoolean(tmp);
            tmp = xdoc.Query("/clientDescriptor/isReentrant");
            bool isReentrant = Convert.ToBoolean(tmp);
            string notes = xdoc.Query("/clientDescriptor/notes");

            // Insert the Client, Qualifier is created internally
            int newClientId = AdministrativeAPI.AddLabClient(guid, name, version, shortDescription,
                longDescription, notes, loaderScript, type, null, contactEmail, contactFirstName, contactLastName, needsScheduling, needsESS, isReentrant, null);
            // parse the LabServer list
            ArrayList labServers = new ArrayList();
            XPathNodeIterator iter = xdoc.Select("/clientDescriptor/labServers/*");
            if (iter != null && iter.Count > 0)
            {
                while (iter.MoveNext())
                {
                    string lsGuid = iter.Current.GetAttribute("guid", ns);
                    int serverID = brokerDb.GetProcessAgentID(lsGuid);
                    if (serverID > 0)
                    {
                        labServers.Add(serverID);
                    }

                }
            }

            // deal with resources
            iter = xdoc.Select("/clientDescriptor/clientInfos/*");
            ArrayList clientItems = new ArrayList();
            if (iter != null && iter.Count > 0)
            {
                while (iter.MoveNext())
                {
                    ClientInfo clientInfo = new ClientInfo();
                    clientInfo.infoURL = iter.Current.GetAttribute("infoUrl", ns);
                    clientInfo.infoURLName = iter.Current.GetAttribute("infoUrlName", ns);
                    clientInfo.description = iter.Current.GetAttribute("description", ns);
                    clientInfo.displayOrder = Int32.Parse(iter.Current.GetAttribute("displayOrder", ns));
                    clientItems.Add(clientInfo);
                }
            }

            message.Append(" Registered a new LabClient. ");
            message.AppendLine(" GUID: " + guid + " -> " + name);

            if (labServers.Count > 0 || clientItems.Count > 0)
            {
                int[] servers = new int[labServers.Count];
                for (int j = 0; j < labServers.Count; j++)
                {
                    servers[j] = (int)labServers[j];
                }
                ClientInfo[] infos = new ClientInfo[clientItems.Count];
                for (int k = 0; k < clientItems.Count; k++)
                {
                    infos[k] = (ClientInfo)clientItems[k];
                }

                AdministrativeAPI.ModifyLabClient(newClientId, name, version, shortDescription,
                longDescription, notes, loaderScript, type, servers, contactEmail, contactFirstName,
                contactLastName, needsScheduling, needsESS, isReentrant, infos);
            }

            return newClientId;
        }
예제 #7
0
        public string writeClientXml(string nameSpace, string rootElement,
            Dictionary<string, object> keyValueDictionary,
             int[] servers, ClientInfo[] infos)
        {
            try
            {
                XmlWriterSettings settings = new XmlWriterSettings();
                settings.Indent = true;
                settings.OmitXmlDeclaration = true;
                settings.NewLineOnAttributes = true;
                settings.CheckCharacters = true;

                StringBuilder stringBuilder = new StringBuilder();
                XmlWriter xmlWriter = XmlWriter.Create(stringBuilder, settings);

                // write root element
                xmlWriter.WriteStartElement(rootElement);
                //xmlWriter.WriteAttributeString("xmlns", "ns", null, nameSpace);

                foreach (string s in keyValueDictionary.Keys)
                {
                    xmlWriter.WriteStartElement(s);
                    object value = new object();
                    keyValueDictionary.TryGetValue(s, out value);
                    xmlWriter.WriteString(value.ToString());
                    xmlWriter.WriteEndElement();
                }
                if(servers != null && servers.Length > 0){
                    xmlWriter.WriteStartElement("labServers");
                    for (int i = 0; i < servers.Length; i++)
                    {
                        ProcessAgent server = brokerDb.GetProcessAgent(servers[i]);
                        if (server != null)
                        {
                            xmlWriter.WriteStartElement("serverGuid");
                            xmlWriter.WriteString(server.agentGuid);
                            xmlWriter.WriteEndElement();
                        }

                    }
                    xmlWriter.WriteEndElement();

                }
                if (infos != null && infos.Length > 0)
                {
                    xmlWriter.WriteStartElement("clientResources");
                    foreach (ClientInfo i in infos)
                    {
                        WriteClientInfo(xmlWriter, i);
                    }
                    xmlWriter.WriteEndElement();

                }

                xmlWriter.WriteEndElement();
                xmlWriter.Flush();
                return stringBuilder.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
            }

            return null;
        }
예제 #8
0
        public static ClientInfo[] ListClientInfos(int clientID)
        {
            List<ClientInfo> infos = new List<ClientInfo>();
            DbConnection myConnection = FactoryDB.GetConnection();
            DbCommand myCommand = FactoryDB.CreateCommand("ClientInfo_Retrieve", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure ;

            myCommand.Parameters.Add(FactoryDB.CreateParameter("@labClientID", clientID,DbType.Int32));

            DbDataReader reader = null;

            try
            {
                myConnection.Open();
                reader = myCommand.ExecuteReader();
                // select client_info_id, info_URL, info_name, display_order, description
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        ClientInfo info = new ClientInfo();
                        info.clientID = clientID;
                        info.clientInfoID = reader.GetInt32(0);
                        info.infoURL = reader.GetString(1);
                        info.infoURLName = reader.GetString(2);
                        info.displayOrder = reader.GetInt32(3);
                        info.description = reader.GetString(4);
                        infos.Add(info);

                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("error: " + e.Message);
            }
            finally
            {
                myConnection.Close();
            }
            return infos.ToArray();
        }
예제 #9
0
        /*
        /// <summary>
        /// super user privilege
        /// </summary>
        /// <param name="labServerID"></param>
        /// <returns></returns>
        public string GenerateIncomingServerPasskeyWrapper(int labServerID)
        {
            int sessionGroupID =  Convert.ToInt32(Session["GroupID"]);
            string sessionGroupName = Session["GroupName"].ToString();
            if(sessionGroupName.CompareTo(Group.SUPERUSER)==0)
            {
                return Administration.Administration .GenerateIncomingServerPasskey (labServerID);
            }
            else
            {
                throw new AccessDeniedException ("Access denied generating incoming server passkey.");
            }
        }

        /// <summary>
        /// super user privilege
        /// </summary>
        /// <param name="labServerID"></param>
        /// <returns></returns>
        public string GetIncomingServerPasskeyWrapper(int labServerID)
        {
            int sessionGroupID = Convert.ToInt32(Session["GroupID"]);
            string sessionGroupName = Session["GroupName"].ToString();
            if(sessionGroupName.CompareTo(Group.SUPERUSER)==0)
            {
                return Administration.Administration .GetIncomingServerPasskey (labServerID);
            }
            else
            {
                throw new AccessDeniedException ("Access denied getting incoming server passkey.");
            }

        }

        /// <summary>
        /// super user privilege
        /// </summary>
        /// <param name="labServerID"></param>
        /// <param name="passkey"></param>
        public void RegisterOutgoingServerPasskeyWrapper(int labServerID, string passkey)
        {
            int sessionGroupID = Convert.ToInt32(Session["GroupID"]);
            string sessionGroupName = Session["GroupName"].ToString();
            if(sessionGroupName.CompareTo(Group.SUPERUSER)==0)
            {
                Administration.Administration .RegisterOutgoingServerPasskey (labServerID, passkey);
            }
            else
            {
                throw new AccessDeniedException ("Access denied registering outgoing server passkey.");
            }
        }

        /// <summary>
        /// super user privilege
        /// </summary>
        /// <param name="labServerID"></param>
        /// <returns></returns>
        public string GetOutgoingServerPasskeyWrapper(int labServerID)
        {
            int sessionGroupID = Convert.ToInt32(Session["GroupID"]);
            string sessionGroupName = Session["GroupName"].ToString();

            if(sessionGroupName.CompareTo(Group.SUPERUSER)==0)
            {
                return Administration.Administration .GetOutgoingServerPasskey (labServerID);
            }
            else
            {
                throw new AccessDeniedException ("Access denied getting outgoing server passkey.");
            }
        }
        */
        /// <summary>
        /// super user privilege
        /// </summary>
        /// <param name="clientGuid"></param>
        /// <param name="clientName"></param>
        /// <param name="version"></param>
        /// <param name="clientShortDescription"></param>
        /// <param name="clientLongDescription"></param>
        /// <param name="notes"></param>
        /// <param name="loaderScript"></param>
        /// <param name="labServerIDs"></param>
        /// <param name="contactEmail"></param>
        /// <param name="contactFirstName"></param>
        /// <param name="contactLastName"></param>
        /// <param name="clientInfos"></param>
        /// <returns></returns>
        public int AddLabClientWrapper(string clientGuid, string clientName, string version, string clientShortDescription, 
            string clientLongDescription, string notes, string loaderScript, string clientType, int[] labServerIDs, 
            string contactEmail, string contactFirstName, string contactLastName, 
            bool needsScheduling,bool needsESS,bool isReentrant, ClientInfo[] clientInfos)
        {
            int sessionGroupID = Convert.ToInt32(Session["GroupID"]);
            string sessionGroupName = Session["GroupName"].ToString();
            if(sessionGroupName.CompareTo(Group.SUPERUSER)==0)
            {
                return Administration.AdministrativeAPI .AddLabClient (clientGuid, clientName,  version, clientShortDescription,
                    clientLongDescription,  notes,  loaderScript,  clientType, labServerIDs, contactEmail, contactFirstName,
                    contactLastName,needsScheduling, needsESS, isReentrant, clientInfos);
            }
            else
            {
                throw new AccessDeniedException ("Access denied adding lab client.");
            }
        }
        /// <summary>
        /// This is the main database update routine.
        /// In order to update the ClientInfo structure in the Lab Client, it is necessary to 
        /// update the entire lab client.
        /// </summary>
        /// <param name="clientInfos"></param>
        private void UpdateLabClientInfo(ClientInfo[] clientInfos)
        {
            try
            {
                int count = 0;
                foreach (ClientInfo info in clientInfos)
                {
                    AdministrativeAPI.UpdateLabClientInfo(info.clientInfoID, info.clientID, info.infoURL, info.infoURLName, info.description, count);
                    count++;
                }
                // Create the javascript which will cause a page refresh event to fire on the popup's parent page
                string jScript;
                jScript = "<script language=javascript> window.opener.Form1.hiddenPopupOnSave.value='1';";
                // jScript += "window.close();";
                jScript += "</script>";
                Page.RegisterClientScriptBlock("postbackScript", jScript);
            }
            catch (Exception ex)
            {
                lblResponse.Visible = true;
                lblResponse.Text = "Cannot update Lab Client. " + ex.Message;
            }

            RefreshClientInfoRepeater();
            LoadListBox();
        }
        public int LoadLabClient(XmlQueryDoc xdoc, ref StringBuilder message)
        {
            string guid = xdoc.Query("/clientDescriptor/clientGuid");
            string type = xdoc.Query("/clientDescriptor/clientType");
            string name = xdoc.Query("/clientDescriptor/clientName");
            string version = xdoc.Query("/clientDescriptor/version");
            string shortDescription = xdoc.Query("/clientDescriptor/clientShortDescription");
            string longDescription = xdoc.Query("/clientDescriptor/clientLongDescription");
            string contactEmail = HttpUtility.HtmlDecode(xdoc.Query("/clientDescriptor/contactEmail"));
            string contactFirstName = xdoc.Query("/clientDescriptor/contactFirstName");
            string contactLastName = xdoc.Query("/clientDescriptor/contactLastName");
            string loaderScript = xdoc.Query("/clientDescriptor/loaderScript");
            string documentationURL = xdoc.Query("/clientDescriptor/documentationUrl");
            string tmp = xdoc.Query("/clientDescriptor/needsScheduling");
            bool needsScheduling = Convert.ToBoolean(tmp);
            tmp = xdoc.Query("/clientDescriptor/needsESS");
            bool needsESS = Convert.ToBoolean(tmp);
            tmp = xdoc.Query("/clientDescriptor/isReentrant");
            bool isReentrant = Convert.ToBoolean(tmp);
            string notes = xdoc.Query("/clientDescriptor/notes");

            // Insert the Client, Qualifier is created internally
            int newClientId = AdministrativeAPI.AddLabClient(guid, name, version, shortDescription,
                longDescription, type, loaderScript, documentationURL,
                contactEmail, contactFirstName, contactLastName,notes, needsESS, needsScheduling, isReentrant);

            // parse the LabServer list
            XPathNodeIterator iter = xdoc.Select("/clientDescriptor/labServers/*");
            if (iter != null && iter.Count > 0)
            {
                int order = 0;
                while (iter.MoveNext())
                {
                    string lsGuid = iter.Current.GetAttribute("guid", ns);
                    int serverID = brokerDb.GetProcessAgentID(lsGuid);
                    if (serverID > 0)
                    {
                        AdministrativeAPI.LabServerClient_Insert(serverID, newClientId, order);
                        order++;
                    }
                }
            }

            // deal with resources
            iter = xdoc.Select("/clientDescriptor/clientInfos/*");
            if (iter != null && iter.Count > 0)
            {
                while (iter.MoveNext())
                {
                    ClientInfo clientInfo = new ClientInfo();
                    clientInfo.infoURL = iter.Current.GetAttribute("infoUrl", ns);
                    clientInfo.infoURLName = iter.Current.GetAttribute("infoUrlName", ns);
                    clientInfo.description = iter.Current.GetAttribute("description", ns);
                    clientInfo.displayOrder = Int32.Parse(iter.Current.GetAttribute("displayOrder", ns));
                    AdministrativeAPI.InsertLabClientInfo(newClientId, clientInfo.infoURL, clientInfo.infoURLName,
                        clientInfo.description, clientInfo.displayOrder);
                }
            }

            message.Append(" Registered a new LabClient. ");
            message.AppendLine(" GUID: " + guid + " -> " + name);
            return newClientId;
        }
 /// <summary>
 /// Loads the fields in the Info Edit Box with information
 /// from the selected record, to prepare for editing.
 /// </summary>
 private void LoadFormFields(ClientInfo clientInfo)
 {
     txtDesc.Text = clientInfo.description;
     txtUrl.Text = clientInfo.infoURL;
     txtInfoname.Text = clientInfo.infoURLName;
     hdnClientInfoID.Value = clientInfo.ClientInfoID.ToString();
     hdnDisplayOrder.Value = clientInfo.displayOrder.ToString();
     btnSaveInfoChanges.Enabled = false;
 }
예제 #13
0
        /// <summary>
        /// The Save Button method.
        /// The index of the Lab Client dropdown will be used to determine whether 
        /// this is a new (0) or an existing (>0) Lab Client.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSaveChanges_Click(object sender, System.EventArgs e)
        {
            lblResponse.Visible = false;
            lblResponse.Text = "";

            if (txtVersion.Text == null || txtVersion.Text.Equals(""))
            {
                lblResponse.Text = Utilities.FormatWarningMessage("You must speecify a version for the client!");
                lblResponse.Visible = true;
                return;
            }
            if (txtClientGuid.Text == null || txtClientGuid.Text.Equals("") || txtClientGuid.Text.Length >50)
            {
                lblResponse.Text = Utilities.FormatWarningMessage("You must speecify a GUID for the client, the maximun number of characters is 50!");
                lblResponse.Visible = true;
                return;
            }
            if (txtLoaderScript.Text == null || txtLoaderScript.Text.Equals(""))
            {
                lblResponse.Text = Utilities.FormatWarningMessage("You must speecify a loader script for the client!");
                lblResponse.Visible = true;
                return;
            }
            int[] labServerIDs = new int[0];
            ClientInfo[] clientInfos;

            if ((txtDocURL.Text!=null)&&(txtDocURL.Text.Trim()!=""))
            {
                clientInfos = new ClientInfo[1];
                clientInfos[0].infoURL=txtDocURL.Text;
                clientInfos[0].infoURLName="Documentation";
                clientInfos[0].description="Link to documentation";
            }
            else
            {
                clientInfos = new ClientInfo[0];
            }

            ///////////////////////////////////////////////////////////////
            /// ADD a new Lab Client                                     //
            ///////////////////////////////////////////////////////////////
            if(ddlLabClient.SelectedIndex == 0)
            {
                // Add the Lab Client
                try
                {
                    // NEEDS TO BE CHANGED !!!!!!!!!!!!
                    labClientID = wrapper.AddLabClientWrapper(txtClientGuid.Text, txtLabClientName.Text, txtVersion.Text, txtShortDesc.Text,
                        txtLongDesc.Text, txtNotes.Text, txtLoaderScript.Text, ddlClientTypes.SelectedItem.Text,
                        labServerIDs, txtContactEmail.Text, txtContactFirstName.Text, txtContactLastName.Text,
                        cbxScheduling.Checked,cbxESS.Checked,cbxIsReentrant.Checked, clientInfos)	;
                }
                catch (AccessDeniedException ex)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatErrorMessage(ex.Message+". "+ex.GetBaseException());
                    return;
                }

                // If successful...
                if (labClientID != -1)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatConfirmationMessage("Lab Client " + txtLabClientName.Text + " has been added.");

                }
                else // cannot create lab client
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatErrorMessage("Cannot create Lab Client " + txtLabClientName.Text + ".");
                }

                // set dropdown to newly created Lab Client.
                InitializeDropDown();
                ddlLabClient.Items.FindByText(txtLabClientName.Text).Selected = true;
                // Prepare record for editing
                LoadFormFields();
                //Disable guid modification
                txtClientGuid.ReadOnly = true;
                txtClientGuid.Enabled = false;
                // Enable the button that pops up the Associated Lab Server edit page
                btnEditList.Visible = true;

            }
            else
            ///////////////////////////////////////////////////////////////
            /// MODIFY an existing Lab Client                            //
            ///////////////////////////////////////////////////////////////
            {
                // Save the index
                int savedSelectedIndex = ddlLabClient.SelectedIndex;

                // obtain information not edited in the text boxes from the array of LabClient objects
                labClientID = labClients[ddlLabClient.SelectedIndex - 1].clientID;
                labServerIDs = labClients[ddlLabClient.SelectedIndex -1].labServerIDs;
                if ((txtDocURL.Text!=null)&&(txtDocURL.Text.Trim()!=""))
                {
                    ArrayList clientInfoList = new ArrayList(labClients[ddlLabClient.SelectedIndex-1].clientInfos);
                    foreach (ClientInfo ci in clientInfoList)
                    {
                        if (ci.infoURLName.ToUpper().Equals("DOCUMENTATION"))
                        {
                            clientInfoList.Remove(ci);
                            break;
                        }
                    }
                    ClientInfo doc = new ClientInfo();
                    doc.infoURL=txtDocURL.Text;
                    doc.infoURLName="Documentation";
                    doc.description="Link to documentation";
                    clientInfoList.Add(doc);

                    //Convert array list to array
                    clientInfos = new ClientInfo[clientInfoList.Count];
                    for (int i =0;i<clientInfoList.Count;i++)
                        clientInfos[i]=(ClientInfo) clientInfoList[i];

                }
                else
                    clientInfos = labClients[ddlLabClient.SelectedIndex -1].clientInfos;

                // Modify the Lab Client Record
                try
                {
                    LabClient lc = labClients[ddlLabClient.SelectedIndex -1];

                    wrapper.ModifyLabClientWrapper(labClientID, txtLabClientName.Text, txtVersion.Text, txtShortDesc.Text,
                        txtLongDesc.Text, txtNotes.Text, txtLoaderScript.Text, ddlClientTypes.SelectedItem.Text,
                        labServerIDs, txtContactEmail.Text, txtContactFirstName.Text, txtContactLastName.Text,
                        cbxScheduling.Checked, cbxESS.Checked, cbxIsReentrant.Checked, clientInfos);

                    // Reload the Lab Client dropdown
                    InitializeDropDown();
                    ddlLabClient.SelectedIndex = savedSelectedIndex;
                    LoadFormFields();
                    //Disable guid modification
                    txtClientGuid.ReadOnly = true;
                    txtClientGuid.Enabled = false;
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatConfirmationMessage("Lab Client " + txtLabClientName.Text + " has been modified.");
                }
                catch (Exception ex)
                {
                    lblResponse.Visible = true;
                    lblResponse.Text = Utilities.FormatErrorMessage("Lab Client " + txtLabClientName.Text + " could not be modified." + ex.GetBaseException());
                }
            }
        }
예제 #14
0
        /// <summary>
        /// to retrieve lab client metadata for lab clients specified by array of lab client IDs 
        /// </summary>
        public static LabClient[] SelectLabClients( int[] clientIDs )
        {
            LabClient[] lc = new LabClient[clientIDs.Length];
            for (int i=0; i<clientIDs.Length ; i++)
            {
                lc[i] = new LabClient();
            }

            DbConnection myConnection = FactoryDB.GetConnection();
            DbCommand myCommand = FactoryDB.CreateCommand("RetrieveLabClient", myConnection);
            myCommand.CommandType = CommandType.StoredProcedure;
            myCommand.Parameters .Add(FactoryDB.CreateParameter(myCommand, "@labClientID",null, DbType.Int32));

            try
            {
                myConnection.Open ();

                for (int i =0; i < clientIDs.Length ; i++)
                {
                    myCommand.Parameters["@labClientID"].Value = clientIDs[i];

                    // get labclient info from table lab_clients
                    DbDataReader myReader = myCommand.ExecuteReader ();
                    while(myReader.Read ())
                    {
                        lc[i].clientID = clientIDs[i];

                        if(myReader["lab_client_name"] != System.DBNull.Value )
                            lc[i].clientName = (string) myReader["lab_client_name"];
                        if(myReader["short_description"] != System.DBNull.Value )
                            lc[i].clientShortDescription = (string) myReader["short_description"];
                        if(myReader["long_description"] != System.DBNull.Value )
                            lc[i].clientLongDescription = (string) myReader["long_description"];
                        if(myReader["version"] != System.DBNull.Value )
                            lc[i].version = (string) myReader["version"];
                        if(myReader["loader_script"] != System.DBNull.Value )
                            lc[i].loaderScript= (string) myReader["loader_script"];
                        if(myReader["description"] != System.DBNull.Value )
                            lc[i].clientType= (string) myReader["description"];
                        if(myReader["contact_email"] != System.DBNull .Value )
                            lc[i].contactEmail= (string) myReader["contact_email"];
                        if(myReader["contact_first_name"]!= System.DBNull.Value)
                            lc[i].contactFirstName = (string) myReader["contact_first_name"];
                        if(myReader["contact_last_name"]!= System.DBNull.Value)
                            lc[i].contactLastName = (string) myReader["contact_last_name"];
                        if(myReader["notes"]!= System.DBNull.Value)
                            lc[i].notes = (string) myReader["notes"];
                        lc[i].needsScheduling = Convert.ToBoolean(myReader["needsScheduling"]);
                        lc[i].needsESS = Convert.ToBoolean(myReader["needsESS"]);
                        lc[i].IsReentrant = Convert.ToBoolean(myReader["isReentrant"]);
                        if (myReader["Client_Guid"] != System.DBNull.Value)
                            lc[i].clientGuid = (string)myReader["Client_Guid"];
                        /*if(myReader["date_created"] != System.DBNull .Value )
                            lc[i].= (string) myReader["date_created"];*/

                        //added by Karim
                        //if(myReader["info_URL"] != System.DBNull .Value )
                        //	lc[i].infoURL= (string) myReader["info_URL"];

                    }
                    myReader.Close ();
                }
                //Retrieve  lab servers for a client

                ArrayList lsIDs = new ArrayList();

                DbCommand myCommand2 = FactoryDB.CreateCommand("RetrieveClientServerIDs", myConnection);
                myCommand2.CommandType = CommandType.StoredProcedure;
                myCommand2.Parameters .Add(FactoryDB.CreateParameter(myCommand2,"@labClientID",null,DbType.Int32));

                for (int i =0; i < clientIDs.Length ; i++)
                {
                    myCommand2.Parameters["@labClientID"].Value = clientIDs[i];
                    DbDataReader myReader2 = myCommand2.ExecuteReader ();

                    while(myReader2.Read ())
                    {
                        if(myReader2["agent_id"] != System.DBNull.Value )
                            lsIDs.Add(Convert.ToInt32(myReader2["agent_id"]));
                    }

                    myReader2.Close();

                    // Convert to an int array and add to the current LabClient object
                    lc[i].labServerIDs = Utilities.ArrayListToIntArray(lsIDs);
                    lsIDs.Clear();
                }

                //Retrieve info urls for a client

                ArrayList infoURLs = new ArrayList();

                myCommand2 = FactoryDB.CreateCommand("RetrieveClientInfo", myConnection);
                myCommand2.CommandType = CommandType.StoredProcedure;
                myCommand2.Parameters .Add(FactoryDB.CreateParameter(myCommand2,"@labClientID",null, DbType.Int32));

                for (int i =0; i < clientIDs.Length ; i++)
                {
                    myCommand2.Parameters["@labClientID"].Value = clientIDs[i];

                    DbDataReader myReader2 = myCommand2.ExecuteReader ();

                    while(myReader2.Read ())
                    {
                        ClientInfo c = new ClientInfo();
                        if(myReader2["info_url"] != System.DBNull.Value )
                            c.infoURL = (string) myReader2["info_url"];
                        if(myReader2["info_name"] != System.DBNull.Value )
                            c.infoURLName  = (string) myReader2["info_name"];
                        if(myReader2["client_info_id"] != System.DBNull.Value )
                            c.clientInfoID = Convert.ToInt32( myReader2["client_info_id"]);
                        if(myReader2["description"] != System.DBNull.Value )
                            c.description = ((string) myReader2["description"]);
                        if(myReader2["display_order"] != System.DBNull.Value )
                            c.displayOrder = (int) myReader2["display_order"];

                        infoURLs.Add(c);
                    }

                    myReader2.Close();

                    // Converting to a clientInfo array
                    lc[i].clientInfos = new ClientInfo [infoURLs.Count];
                    for (int j=0;j <infoURLs.Count ; j++)
                    {
                        lc[i].clientInfos[j] = (ClientInfo) (infoURLs[j]);
                    }
                    infoURLs.Clear();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Exception thrown SelectLabClients",ex);
            }
            finally
            {
                myConnection.Close ();
            }

            return lc;
        }
예제 #15
0
        /*
        /// <summary>
        /// Generates and installs a new passkey that will be used to authenticate web service calls made by the remote server identified by labServerID.
        /// The passkey returned must be conveyed out of band to the administrator of the remote server.
        /// </summary>
        /// <param name="labServerID">The ID of the (lab) server for which the passkey will be generated.</param>
        /// <returns>The passkey authenticating the remote server.</returns>
        /// <seealso cref="GetIncomingServerPasskey">GetIncomingServerPasskey</seealso>
        public static string GenerateIncomingServerPasskey(int labServerID)
        {
            // Random rand = new Random ();  // dynamic seeds
            // string key = rand.Next ().ToString ();

            // Changed from random number to a GUID - CF 1/21/2005
            string key = Guid.NewGuid().ToString("N");  // with no "-" in Guid string

            try
            {
                InternalAdminDB.UpdateLSIncomingPasskey (labServerID, key);
            }
            catch (Exception ex)
            {
                throw;
            }
            return key;
        }

        /// <summary>
        /// Retrieves a previously generated passkey to authenticate web service calls made by the remote server identified by labServerID.
        /// </summary>
        /// <param name="labServerID">The ID of the (lab) server for which the passkey will be retrieved.</param>
        /// <returns>The passkey authenticating the remote server.</returns>
        /// <seealso cref="GenerateIncomingServerPasskey">GenerateIncomingServerPasskey</seealso>
        public static string GetIncomingServerPasskey(int labServerID)
        {
            string incomingKey = "";
            try
            {
                incomingKey = InternalAdminDB.selectSBIncomingPasskey (labServerID);
            }
            catch(Exception ex)
            {
                throw;
            }
            return incomingKey;
        }

        /// <summary>
        /// Installs a per lab server passkey that authenticates this service broker.
        /// </summary>
        /// <param name="labServerID">The ID of the lab server for which the passkey will be installed.</param>
        /// <param name="passkey">The passkey or token that this Service Broker must present on each web service call to gain access to the lab server.</param>
        public static void RegisterOutgoingServerPasskey(int labServerID, string passkey)
        {
            try
            {
                InternalAdminDB.UpdateLSOutgoingPasskey (labServerID, passkey);
            }
            catch (Exception ex)
            {
                throw;
            }
        }

        /// <summary>
        /// Retrieve a previously registered passkey that this service broker must present on each web service call to gain access to the lab server identified by labServerID.
        /// </summary>
        /// <param name="labServerID">The ID of the (lab) server for which the passkey will be retrieved.</param>
        /// <returns>The passkey for the remote server.</returns>
        public static string GetOutgoingServerPasskey(int labServerID)
        {
            string outgoingKey = "";
            try
            {
                outgoingKey = InternalAdminDB.selectSBOutgoingPasskey (labServerID);
            }
            catch(Exception ex)
            {
                throw;
            }
            return outgoingKey;
        }
        */
        ///*********************** LAB CLIENTS **************************///
        /// <summary>
        /// Registers the client identified by ClientName with the Service Broker; after this call users can request the loading of this client to compose and execute experiments on the associated lab servers.
        /// </summary>
        /// <param name="guid">A string limited to 50 characters used for identification across domains, do not modifiy except at creation.</param>
        /// <param name="clientName">A name for the client application meaningful to humans; it is not required to be unique on the Service Broker.</param>
        /// <param name="version">The version number of the client software; each new version must receive a new clientID.</param>
        /// <param name="notes">An arbitrary piece of text that will be visible to students using the client.</param>
        /// <param name="loaderScript">An HTML fragment that will be embedded on a Service Broker generated page executed by the user's web browser to launch the client.</param>
        /// <param name="clientShortDescription">A brief description of the client suitable for listing in a GUI.</param>
        /// <param name="clientLongDescription">A longer more descriptive text explaining the purpose of the client.</param>
        /// <param name="clientType">A string identifying the client type.</param>
        /// <param name="labServerIDs">An array of labServerIDs specifying the ordered list of lab servers accessed by this client.</param>
        /// <param name="contactEmail">The email address of the party responsible for the maintenance of the client.</param>
        /// <param name="contactFirstName">The first name of the party responsible for the maintenance of the client.</param>
        /// <param name="contactLastName">The last name of the party responsible for the maintenance of the client.</param>
        ///<param name="clientInfos">An array of ClientInfo structures containing multiple instances of information associated with this clientID. Information such as the client name and the URL of an information page are maintained. It this value is NULL, the previous value will not be changed.</param>
        /// <returns>The unique clientID which identifies the client software internally to the Service Broker. >0 was successfully registered; -1 otherwise</returns>
        public static int AddLabClient(string guid, string clientName, string version, string clientShortDescription, string clientLongDescription, string notes, string loaderScript, string clientType, int[] labServerIDs, string contactEmail, string contactFirstName, string contactLastName, bool needsScheduling, bool needsESS, bool isReentrant, ClientInfo[] clientInfos)
        {
            LabClient lc = new LabClient ();
            lc.clientGuid = guid;
            lc.clientName = clientName;
            lc.version = version;
            lc.notes=notes;
            lc.clientShortDescription=clientShortDescription;
            lc.clientLongDescription=clientLongDescription;
            lc.loaderScript=loaderScript;
            lc.labServerIDs = labServerIDs;
            lc.contactEmail = contactEmail;
            lc.contactFirstName = contactFirstName;
            lc.contactLastName = contactLastName;
            lc.needsScheduling = needsScheduling;
            lc.needsESS = needsESS;
            lc.IsReentrant = isReentrant;
            lc.clientInfos=clientInfos;
            lc.clientType= clientType;

            try
            {
                //Insert the lab client into the database
                lc.clientID = InternalAdminDB.InsertLabClient (lc);

                try
                {
                    //Add the lab client to the Qualifiers & Qualifiers Hierarchy Table
                    Authorization.AuthorizationAPI .AddQualifier (lc.clientID, Authorization.Qualifier .labClientQualifierTypeID, lc.clientName, Qualifier.ROOT);
                }
                catch (Exception ex)
                {
                    // rollback lab client insertion
                    InternalAdminDB.DeleteLabClients(new int[]{lc.clientID});

                    throw;
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return lc.clientID;
        }
예제 #16
0
        /// <summary>
        /// Modifies the information pertaining to the client registered under the ID clientID.
        /// </summary>
        /// <param name="clientID">The unique ID which identifies the lab client whose information will be removed.</param>
        /// <param name="clientName">A name for the client application meaningful to humans; it is not required to be unique on the Service Broker instance, but probably should be; if NULL, the the previous value will not be changed.</param>
        /// <param name="version">The version number of the client software; if NULL, the previous value will not be changed.</param>
        /// <param name="clientShortDescription">A brief description of the client suitable for listing in a GUI; if NULL, then the previous value will not be changed.</param>
        /// <param name="clientLongDescription">A longer more descriptive text explaining the purpose of the client; if NULL, then the previous value will not be changed.</param>
        /// <param name="notes">An arbitrary piece of text that will be visible to students using the client; if NULL, then the previous value will not be changed.</param>
        /// <param name="loaderScript">An HTML fragment that will be enbedded on the Service Broker generated page executed by the user's web browser to launch the client; if  NULL, then the previous value will not be changed.</param>
        /// <param name="clientType">A string identifying the client type.</param>
        /// <param name="labServerIDs">An array of labServerIDs specifying the ordered list of lab servers accessed by this client; if NULL, then the previous value will not be changed.</param>
        /// <param name="contactEmail">The email address of the party responsible for the maintenance of the client; if NULL, the previous value will not be changed.</param>
        /// <param name="contactFirstName">The first name of the party responsible for the maintenance of the client; if NULL, the previous value will not be changed.</param>
        /// <param name="contactLastName">The last name of the party responsible for the maintenance of the client; if NULL, the previous value will not be changed.</param>
        /// <param name="clientInfos">An array of ClientInfo structures containing multiple instances of information associated with this clientID. Information such as the client name and the URL of the information page are maintained. If this value is Null, the previous value will not be changed.</param>
        public static void ModifyLabClient(int clientID, string clientName, string version, string clientShortDescription, string clientLongDescription, string notes, string loaderScript, string clientType, int[] labServerIDs, string contactEmail, string contactFirstName, string contactLastName, bool needsScheduling, bool needsESS, bool isReentrant, ClientInfo[] clientInfos)
        {
            LabClient lc = new LabClient ();
            lc.clientID = clientID;
            lc.clientName = clientName;
            lc.version = version;
            lc.clientShortDescription = clientShortDescription;
            lc.clientLongDescription = clientLongDescription;
            lc.notes = notes;
            lc.loaderScript = loaderScript;
            lc.clientType = clientType;
            lc.labServerIDs = labServerIDs;
            lc.contactEmail = contactEmail;
            lc.contactFirstName = contactFirstName;
            lc.contactLastName = contactLastName;
            lc.needsScheduling = needsScheduling;
            lc.needsESS = needsESS;
            lc.IsReentrant = isReentrant;
            lc.clientInfos=clientInfos;

            try
            {
                InternalAdminDB.UpdateLabClient (lc);
            }
            catch(Exception e)
            {
                throw;
            }
        }