예제 #1
0
        /// <summary>
        /// Modified ExecuteExperimentExecutionRecipe inorder to better support interactive applets. 
        /// </summary>
        /// <param name="labServer"></param>
        /// <param name="client"></param>
        /// <param name="startExecution"></param>
        /// <param name="duration"></param>
        /// <param name="userTZ"></param>
        /// <param name="userID"></param>
        /// <param name="groupID"></param>
        /// <param name="groupName"></param>
        /// <returns></returns> added silly bool should be changed
        public IDictionary<string, string> ExecuteExperimentExecutionRecipe(ProcessAgentInfo labServer, LabClient client,
            DateTime startExecution, long duration, int userTZ, int userID, int groupID, string groupName, bool silly)
        {
            BrokerDB brokerDB;
            Coupon coupon;
            // refactored out
            ExecuteExperimentExecutionRecipe(labServer, ref client, ref startExecution, duration, userTZ, userID, groupID, groupName, out brokerDB, out coupon);

            //
            IDictionary<string,string> ht = new Dictionary<string,string>();
            ht["passkey"] = coupon.passkey;
            ht["coupon_id"] = coupon.couponId.ToString();
            ht["issuer_guid"] = brokerDB.GetIssuerGuid();
            //return the appended url
            return ht;
        }
예제 #2
0
        private static void ExecuteExperimentExecutionRecipe(ProcessAgentInfo labServer, ref LabClient client, ref DateTime startExecution, long duration, int userTZ, int userID, int groupID, string groupName, out BrokerDB brokerDB, out Coupon coupon)
        {
            int essId = 0;
            ProcessAgentInfo essAgent = null;

            long ticketDuration = 7200; //Default to 2 hours
            //   Add a 10 minutes to ESS ticket duration ( in seconds ) to extend beyond experiment expiration
            if (duration != -1)
            {
                //ticketDuration = duration + 60; // For testing only add a minute
                ticketDuration = duration + 600; // Add 10 minutes beyond the experiment end
            }
            else
            {
                ticketDuration = -1;
            }

            // Authorization wrapper
            AuthorizationWrapperClass wrapper = new AuthorizationWrapperClass();

            // create ticket issuer and payload factory
            brokerDB = new BrokerDB();
            TicketLoadFactory factory = TicketLoadFactory.Instance();

            if (client.needsESS)
            {
                essId = brokerDB.FindProcessAgentIdForClient(client.clientID, ProcessAgentType.EXPERIMENT_STORAGE_SERVER);

            }

            // 1. Create Coupon for ExperimentCollection
            coupon = brokerDB.CreateCoupon();

            //
            // 2. create ServiceBroker experiment record and get corresponding experiment id
            // This checks authorization.
            long experimentID = wrapper.CreateExperimentWrapper(StorageStatus.INITIALIZED,
                userID, groupID, labServer.agentId, client.clientID,
                essId, startExecution, duration);

            // Store a record of the Experiment Collection Coupon
            DataStorageAPI.InsertExperimentCoupon(experimentID, coupon.couponId);
            string essWebAddress = null;

            // If a ESS is specified Create the ESS Tickets, this should only happen if a resource is mapped
            if (essId > 0)
            {
                //3.A create ESS administer experiment ticket, Add 10 minutes to duration
                // This must be created before the ESS experiment records may be created
                essAgent = brokerDB.GetProcessAgentInfo(essId);
                if ((essAgent != null) && !essAgent.retired)
                {
                    brokerDB.AddTicket(coupon,
                           TicketTypes.ADMINISTER_EXPERIMENT, essAgent.AgentGuid, brokerDB.GetIssuerGuid(), ticketDuration, factory.createAdministerExperimentPayload(experimentID, essAgent.webServiceUrl));

                    //3.B create store record ticket
                    brokerDB.AddTicket(coupon,
                           TicketTypes.STORE_RECORDS, essAgent.agentGuid, labServer.agentGuid, ticketDuration, factory.StoreRecordsPayload(true, experimentID, essAgent.webServiceUrl));

                    //3.C create retrieve experiment ticket, retrieve Experiment Records never expires, unless experiment deleted
                    //    This should be changed to a long but finite period once eadExisting Expermint is in place.
                    brokerDB.AddTicket(coupon,
                           TicketTypes.RETRIEVE_RECORDS, essAgent.agentGuid, brokerDB.GetIssuerGuid(), -1, factory.RetrieveRecordsPayload(experimentID, essAgent.webServiceUrl));

                    // 3.D Create the ESS Experiment Records
                    ExperimentStorageProxy ess = new ExperimentStorageProxy();
                    ess.AgentAuthHeaderValue = new AgentAuthHeader();
                    ess.AgentAuthHeaderValue.coupon = essAgent.identOut;
                    ess.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                    ess.Url = essAgent.webServiceUrl;
                    essWebAddress = essAgent.webServiceUrl;

                    // Call the ESS to create the ESS Records and open the experiment
                    StorageStatus status = ess.OpenExperiment(experimentID, ticketDuration);
                    if (status != null)
                        DataStorageAPI.UpdateExperimentStatus(status);
                }
            }

            //
            // 4. create the execution ticket for the experiment
            //

            // 4.A create payload
            string payload = factory.createExecuteExperimentPayload(essWebAddress, startExecution, duration,
                userTZ, groupName, brokerDB.GetIssuerGuid(), experimentID);

            // 4.B create experiment execution ticket.
            brokerDB.AddTicket(coupon,
                      TicketTypes.EXECUTE_EXPERIMENT, labServer.agentGuid, labServer.agentGuid, ticketDuration, payload);

            // 4.C Create sessionRedemption Ticket
            string sessionPayload = factory.createRedeemSessionPayload(userID, groupID, client.clientID);
            brokerDB.AddTicket(coupon,
                      TicketTypes.REDEEM_SESSION, brokerDB.GetIssuerGuid(), brokerDB.GetIssuerGuid(), ticketDuration, sessionPayload);
        }
예제 #3
0
        public void DeleteAdminURL(ProcessAgentInfo processAgentInfo, string url, string ticketType)
        {
            if (!TicketTypes.TicketTypeExists(ticketType))
                throw new Exception("\"" + ticketType + "\" is not a valid ticket type.");
            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            try
            {
                connection.Open();
                DeleteAdminURL(connection, processAgentInfo.AgentId, url, ticketType);
            }

            catch (DbException e)
            {
                writeEx(e);
                throw;
            }

            finally
            {
                connection.Close();
            }
        }
예제 #4
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="labServer"></param>
        /// <param name="client"></param>
        /// <param name="startExecution"></param>
        /// <param name="duration"></param>
        /// <param name="userTZ"></param>
        /// <param name="userID"></param>
        /// <param name="groupID"></param>
        /// <param name="groupName"></param>
        /// <returns>The redirect url where the user should be redirected, with the coupon appended to it</returns>
        public string ExecuteExperimentExecutionRecipe(ProcessAgentInfo labServer, LabClient client,
            DateTime startExecution, long duration, int userTZ, int userID, int groupID, string groupName)
        {
            BrokerDB brokerDB;
            Coupon coupon;
            // refactored out
            ExecuteExperimentExecutionRecipe(labServer, ref client, ref startExecution, duration, userTZ, userID, groupID, groupName, out brokerDB, out coupon);

            // construct the redirect query
            StringBuilder url = new StringBuilder(client.loaderScript.Trim());
            if (url.ToString().IndexOf("?") == -1)
                url.Append('?');
            else
                url.Append('&');
            url.Append("coupon_id=" + coupon.couponId + "&passkey=" + coupon.passkey
                + "&issuer_guid=" + brokerDB.GetIssuerGuid());

            //return the appended url
            return url.ToString();
        }
예제 #5
0
        protected ProcessAgentInfo readAgentInfo(DbDataReader dataReader)
        {
            long idIn = -1;
            long idOut = -1;
            string passIn = null;
            string passOut = null;
            ProcessAgentInfo info = new ProcessAgentInfo();
            info.agentId = dataReader.GetInt32(0);
            info.agentGuid = dataReader.GetString(1);
            if (!DBNull.Value.Equals(dataReader.GetValue(2)))
                info.agentName = dataReader.GetString(2);
            info.agentType = (ProcessAgentType.AgentType) dataReader.GetInt32(3);
            if (!DBNull.Value.Equals(dataReader.GetValue(4)))
                info.codeBaseUrl = dataReader.GetString(4);
            info.webServiceUrl = dataReader.GetString(5);
            if (!DBNull.Value.Equals(dataReader.GetValue(6)))
                info.domainGuid = dataReader.GetString(6);
             if (!DBNull.Value.Equals(dataReader.GetValue(7)))
                info.issuerGuid = dataReader.GetString(7);
            if (!DBNull.Value.Equals(dataReader.GetValue(8)))
                idIn = dataReader.GetInt64(8);
            if (!DBNull.Value.Equals(dataReader.GetValue(9)))
                passIn = dataReader.GetString(9);
            if (!DBNull.Value.Equals(dataReader.GetValue(10)))
                idOut =dataReader.GetInt64(10);
            if (!DBNull.Value.Equals(dataReader.GetValue(11)))
                passOut = dataReader.GetString(11);
            if (!DBNull.Value.Equals(dataReader.GetValue(12)))
                info.retired = dataReader.GetBoolean(12);
            if (info.issuerGuid != null)
            {
                if (idIn > 0)
                {
                    Coupon couponIn = new Coupon();
                    couponIn.couponId = idIn;
                    couponIn.issuerGuid = info.issuerGuid;
                    couponIn.passkey = passIn;
                    info.identIn = couponIn;
                }
                else
                {
                    info.identIn = null;
                }
                if (idOut > 0)
                {

                    Coupon couponOut = new Coupon();
                    couponOut.couponId = idOut;
                    couponOut.issuerGuid = info.issuerGuid;
                    couponOut.passkey = passOut;
                    info.identOut = couponOut;
                }
                else
                {
                    info.identOut = null;
                }
            }
            return info;
        }
예제 #6
0
        /// <summary>
        /// Retrieve agentInfos given an array of agent IDs.
        /// </summary>
        /// <param name="IDs"></param>
        /// <returns>Retrieved Coupon, or null if the ticket cannot be found</returns>
        public ProcessAgentInfo[] GetProcessAgentInfos(int[] ids)
        {
            ProcessAgentInfo[] agents = new ProcessAgentInfo[ids.Length];

            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            // create sql command
            // command executes the "RetrieveCoupon" stored procedure
            DbCommand cmd = FactoryDB.CreateCommand("GetProcessAgentInfoByID", connection);
            cmd.CommandType = CommandType.StoredProcedure;

            // populate parameters
            DbParameter idParam = FactoryDB.CreateParameter(cmd,"@id",null,DbType.Int64);
            cmd.Parameters.Add(idParam);

            // read the result
            DbDataReader dataReader = null;
            try
            {
                connection.Open();
                for(int i=0;i<ids.Length;i++)
                {
                    idParam.Value = ids[i];
                    dataReader = cmd.ExecuteReader();

                    // from the dataReader
                    while (dataReader.Read())
                    {
                        agents[i] = readAgentInfo(dataReader);
                    }

                    dataReader.Close();
                }
            }
            catch(DbException e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                // close the sql connection
                connection.Close();
            }
            return agents;
        }
예제 #7
0
        /// <summary>
        /// Retrieve agentInfos given a string agent type.
        /// </summary>
        /// <param name="type">the type of agent</param>
        /// <returns>Retrieved Coupon, or null if the ticket cannot be found</returns>
        public ProcessAgentInfo[] GetProcessAgentInfos(string type)
        {
            ArrayList list = new ArrayList();
            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();
            try
            {
                // create sql command
                // command executes the "RetrieveCoupon" stored procedure
                DbCommand cmd = FactoryDB.CreateCommand("GetProcessAgentInfoByType", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                // populate parameters
                cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@agentType",type, DbType.AnsiString, 100));

                // read the result
                DbDataReader dataReader = null;
                connection.Open();
                dataReader = cmd.ExecuteReader();

                // from the dataReader

                ProcessAgentInfo info = null;
                while (dataReader.Read())
                {
                    info = readAgentInfo(dataReader);
                    list.Add(info);
                }
            }
            catch (DbException e)
            {
                Console.WriteLine(e);
                throw;
            }

            finally
            {
                // close the sql connection
                connection.Close();
            }

            ProcessAgentInfo dummy = new ProcessAgentInfo();
            ProcessAgentInfo[] infos = (ProcessAgentInfo[])list.ToArray(dummy.GetType());
            return infos;
        }
예제 #8
0
 public void Add(string key, ProcessAgentInfo info)
 {
     Add(key + ":agentGuid", info.agentGuid);
     Add(key + ":agentName", info.agentName);
     Add(key + ":codebase", info.codeBaseUrl);
     Add(key + ":serviceUrl", info.webServiceUrl);
 }
예제 #9
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            int groupID = 0;
            int authID = -1;
            Coupon opCoupon = null;
            string groupName = null;
            lblResponse.Visible = false;

            userTZ = Convert.ToInt32(Session["UserTZ"]);
            culture = DateUtil.ParseCulture(Request.Headers["Accept-Language"]);
            lc = null;
            if (!IsPostBack)
            {
                // retrieve parameters from URL
                couponId = Request.QueryString["coupon_id"];
                passkey = Request.QueryString["passkey"];
                issuerGuid = Request.QueryString["issuer_guid"];
                if (couponId != null && passkey != null && issuerGuid != null)
                {
                    opCoupon = new Coupon(issuerGuid, Int64.Parse(couponId), passkey);
                    Ticket authExperimentTicket = issuer.RetrieveTicket(opCoupon,
                        TicketTypes.CREATE_EXPERIMENT, ProcessAgentDB.ServiceGuid);
                    if (authExperimentTicket != null)
                    {
                        XmlQueryDoc authDoc = new XmlQueryDoc(authExperimentTicket.payload);
                        string auth = authDoc.Query("CreateExperimentPayload/authID");
                        if (auth != null && auth.Length > 0)
                        {
                            authID = Int32.Parse(auth);

                        }
                        string grpName = authDoc.Query("CreateExperimentPayload/groupName");
                        if (grpName != null && groupName.Length > 0)
                        {
                            Session["GroupName"] = grpName;
                            int grpID = AdministrativeAPI.GetGroupID(grpName);
                            if (grpID > 0)
                                Session["GroupID"] = groupID;
                        }
                        string userName = authDoc.Query("CreateExperimentPayload/userName");
                        if (userName != null && userName.Length > 0)
                        {
                            Session["UserName"] = userName;
                            int userID = AdministrativeAPI.GetUserID(userName,authID);
                            if (userID > 0)
                                Session["UserID"] = userID;
                        }
                        string clientGuid = authDoc.Query("CreateExperimentPayload/clientGuid");
                        if (clientGuid != null && clientGuid.Length > 0)
                        {
                            Session["ClientGuid"] = clientGuid;
                            int clientID = AdministrativeAPI.GetLabClientID(clientGuid);
                            if (clientID > 0)
                                Session["ClientID"] = clientID;
                        }
                    }
                }
                pReenter.Visible = false;
                btnReenter.Visible = false;
                auto = Request.QueryString["auto"];
                if (auto != null && auto.Length > 0)
                {
                    if (auto.ToLower().Contains("t"))
                    {
                        autoLaunch = true;
                    }
                }
            }
            if (Session["ClientID"] != null && Session["ClientID"].ToString().Length > 0)
            {
                lc = wrapper.GetLabClientsWrapper(new int[] { Convert.ToInt32(Session["ClientID"]) })[0];
            }
            if (Session["GroupID"] != null && Session["GroupID"].ToString().Length > 0)
            {
                groupID = Convert.ToInt32(Session["GroupID"]);
            }
            if (groupID > 0 && lc != null)
            {
                setEffectiveGroup(groupID, lc.clientID);
            }
            if (Session["GroupName"] != null && Session["GroupName"].ToString().Length > 0)
            {
                groupName = Session["GroupName"].ToString();
                lblGroupNameTitle.Text = groupName;
            }

            if (lc != null)
            {
                labServer = getLabServer(lc.clientID, effectiveGroupID);
                clientInfos = AdministrativeAPI.ListClientInfos(lc.clientID);
                if (lc.clientType == LabClient.INTERACTIVE_APPLET || lc.clientType == LabClient.INTERACTIVE_HTML_REDIRECT)
                {
                    if (lc.needsScheduling)
                    {
                        Ticket allowExperimentExecutionTicket = null;
                        if (opCoupon != null)
                        {
                            // First check for an Allow Execution Ticket
                            allowExperimentExecutionTicket = issuer.RetrieveTicket(
                                opCoupon, TicketTypes.ALLOW_EXPERIMENT_EXECUTION);
                        }
                        if (allowExperimentExecutionTicket == null)
                        {
                            // Try for a reservation
                            int ussId = issuer.FindProcessAgentIdForClient(lc.clientID, ProcessAgentType.SCHEDULING_SERVER);
                            if (ussId > 0)
                            {
                                ProcessAgent uss = issuer.GetProcessAgent(ussId);
                                // check for current reservation

                                //create a collection & redeemTicket
                                string redeemPayload = TicketLoadFactory.Instance().createRedeemReservationPayload(DateTime.UtcNow,
                                    DateTime.UtcNow, Session["UserName"].ToString(), Convert.ToInt32(Session["UserID"]),
                                    groupName, lc.clientGuid);
                                if (opCoupon == null)
                                    opCoupon = issuer.CreateCoupon();

                                issuer.AddTicket(opCoupon, TicketTypes.REDEEM_RESERVATION, uss.agentGuid,
                                    ProcessAgentDB.ServiceGuid, 600, redeemPayload);

                                UserSchedulingProxy ussProxy = new UserSchedulingProxy();
                                OperationAuthHeader op = new OperationAuthHeader();
                                op.coupon = opCoupon;
                                ussProxy.Url = uss.webServiceUrl;
                                ussProxy.OperationAuthHeaderValue = op;
                                Reservation reservation = ussProxy.RedeemReservation(ProcessAgentDB.ServiceGuid,
                                    Session["UserName"].ToString(), labServer.agentGuid, lc.clientGuid);
                                if (reservation != null)
                                {
                                    // Find efective group
                                    setEffectiveGroup(groupID, lc.clientID);

                                    // create the allowExecution Ticket
                                    DateTime start = reservation.Start;
                                    long duration = reservation.Duration;
                                    string payload = TicketLoadFactory.Instance().createAllowExperimentExecutionPayload(
                                        start, duration, effectiveGroupName,lc.clientGuid);
                                    DateTime tmpTime = start.AddTicks(duration * TimeSpan.TicksPerSecond);
                                    DateTime utcNow = DateTime.UtcNow;
                                    long ticketDuration = (tmpTime.Ticks - utcNow.Ticks) / TimeSpan.TicksPerSecond;
                                    allowExperimentExecutionTicket = issuer.AddTicket(opCoupon, TicketTypes.ALLOW_EXPERIMENT_EXECUTION,
                                            ProcessAgentDB.ServiceGuid, ProcessAgentDB.ServiceGuid, ticketDuration, payload);
                                }
                            }
                        }
                        if (allowExperimentExecutionTicket != null)
                        {
                            XmlDocument payload = new XmlDocument();
                            payload.LoadXml(allowExperimentExecutionTicket.payload);
                            startExecution = DateUtil.ParseUtc(payload.GetElementsByTagName("startExecution")[0].InnerText);
                            duration = Int64.Parse(payload.GetElementsByTagName("duration")[0].InnerText);

                            Session["StartExecution"] = DateUtil.ToUtcString(startExecution);
                            Session["Duration"] = duration;

                            // Display reenter button if experiment is reentrant & a current experiment exists
                            if (lc.IsReentrant)
                            {

                                long[] ids = InternalDataDB.RetrieveActiveExperimentIDs(Convert.ToInt32(Session["UserID"]),
                                    effectiveGroupID, labServer.agentId, lc.clientID);
                                if (ids.Length > 0)
                                {
                                    btnLaunchLab.Text = "Launch New Experiment";
                                   btnLaunchLab.OnClientClick = "javascript:return confirm('Are you sure you want to start a new experiment?\\n If you proceed the currently running experimnent will be closed.');";
                                    btnLaunchLab.Visible = true;
                                    pLaunch.Visible = true;
                                    pReenter.Visible = true;
                                    btnReenter.Visible = true;
                                    btnReenter.CommandArgument = ids[0].ToString();
                                }
                                else
                                {

                                    //pReenter.Visible = false;
                                    //btnReenter.Visible = false;
                                    btnLaunchLab.Text = "Launch Lab";
                                    btnLaunchLab.OnClientClick="";
                                    if (autoLaunch)
                                    {
                                        launchLabClient(lc.clientID);
                                    }
                                    else
                                    {
                                        pLaunch.Visible = true;
                                        btnLaunchLab.Visible = true;
                                    }
                                }
                            }
                            else
                            {
                                pLaunch.Visible = true;
                                btnLaunchLab.Visible = true;
                                btnLaunchLab.OnClientClick = "";
                                if (autoLaunch)
                                {
                                    launchLabClient(lc.clientID);
                                }
                            }
                        }
                        else
                        {
                            pLaunch.Visible = false;
                            btnLaunchLab.Visible = false;
                        }
                    }
                    else
                    {
                        pLaunch.Visible = true;
                        btnLaunchLab.Visible = true;
                        if (autoLaunch)
                        {
                            launchLabClient(lc.clientID);
                        }
                    }
                }
                else if (lc.clientType == LabClient.BATCH_APPLET || lc.clientType == LabClient.BATCH_HTML_REDIRECT)
                {
                    pLaunch.Visible = true;
                    btnLaunchLab.Visible = true;
                    if (autoLaunch)
                    {
                        launchLabClient(lc.clientID);
                    }

                }
                btnSchedule.Visible = lc.needsScheduling;
                lblClientName.Text = lc.clientName;
                lblVersion.Text = lc.version;
                lblLongDescription.Text = lc.clientLongDescription;
                if (lc.notes != null && lc.notes.Length > 0)
                {
                    pNotes.Visible = true;
                    lblNotes.Text = lc.notes;
                }
                else
                {
                    pNotes.Visible = false;
                    lblNotes.Text = null;
                }
                if (lc.contactEmail != null && lc.contactEmail.Length > 0)
                {
                    pEmail.Visible = true;
                    string emailCmd = "mailto:" + lc.contactEmail;
                    lblEmail.Text = "<a href=" + emailCmd + ">" + lc.contactEmail + "</a>";
                }
                else
                {
                    pEmail.Visible = false;
                    lblEmail.Text = null;
                }
                if (lc.documentationURL != null && lc.documentationURL.Length > 0)
                {
                    pDocURL.Visible = true;
                    lblDocURL.Text = "<a href=" + lc.documentationURL + ">" + lc.documentationURL + "</a>";
                }
                else
                {
                    pDocURL.Visible = false;
                    lblDocURL.Text = null;
                }

                btnLaunchLab.Command += new CommandEventHandler(this.btnLaunchLab_Click);
                btnLaunchLab.CommandArgument = lc.clientID.ToString();

                int count = 0;

                if (clientInfos != null && clientInfos.Length > 0)
                {
                    //repClientInfos.DataSource = clientInfos;
                    //repClientInfos.DataBind();
                    foreach (ClientInfo ci in clientInfos)
                    {
                        System.Web.UI.WebControls.Button b = new System.Web.UI.WebControls.Button();
                        b.Visible = true;
                        b.CssClass = "button";
                        b.Text = ci.infoURLName;
                        b.CommandArgument = ci.infoURL;
                        b.CommandName = ci.infoURLName;
                        b.ToolTip = ci.description;
                        b.Command += new CommandEventHandler(this.HelpButton_Click);
                        repClientInfos.Controls.Add(b);
                        repClientInfos.Controls.Add(new LiteralControl("&nbsp;&nbsp;"));
                    }
                }
            }
            else
            {
                // No LabClient
                btnSchedule.Visible = false;
                pLaunch.Visible = false;
                btnLaunchLab.Visible = false;
                string msg = "There are no labs assigned to group: " + Session["GroupName"].ToString() + "!";
                lblResponse.Text = Utilities.FormatErrorMessage(msg);
                lblResponse.Visible = true;
            }
            // System_Messages block

            SystemMessage[] groupMessages = null;
            SystemMessage[] serverMessages = null;
            groupMessages = AdministrativeAPI.SelectSystemMessagesForGroup(Convert.ToInt32(Session["GroupID"]));
            if (lc != null && labServer != null && labServer.agentId > 0)
            {
                serverMessages = wrapper.GetSystemMessagesWrapper(SystemMessage.LAB, 0, 0, labServer.agentId);
            }
            if ((groupMessages == null || groupMessages.Length == 0) && (serverMessages == null || serverMessages.Length == 0))
            {

                lblGroupNameSystemMessage.Text = "No Messages at this time!";
                lblGroupNameSystemMessage.Visible = true;
                lblServerSystemMessage.Visible = false;
            }
            else
            {
                if (groupMessages != null && groupMessages.Length > 0)
                {
                    lblGroupNameSystemMessage.Text = "Group Messages:";
                    lblGroupNameSystemMessage.Visible = true;
                    repGroupMessage.DataSource = groupMessages;
                    repGroupMessage.DataBind();
                }
                else
                {
                    lblGroupNameSystemMessage.Visible = false;
                }

                if (serverMessages != null && serverMessages.Length > 0)
                {
                    lblServerSystemMessage.Text = "Client/Server Messages:";
                    lblServerSystemMessage.Visible = true;
                    repServerMessage.DataSource = serverMessages;
                    repServerMessage.DataBind();
                }
                else
                {
                    lblServerSystemMessage.Visible = false;
                }
            }
        }