protected override void register(string registerGuid, ServiceDescription[] info)
        {
            StringBuilder message = new StringBuilder();
            message.AppendLine("Service " + ProcessAgentDB.ServiceAgent.codeBaseUrl + " recieved a 'Register' webService call.");

            if (info == null)
            {
                //message.AppendLine("Register called without any ServiceDescriptions");
                throw new ArgumentNullException("Register called without any ServiceDescriptions");
            }

            try
            {
                base.register(registerGuid, info);
            }
            catch (Exception e)
            {
                message.AppendLine("Error in base.register" + Utilities.DumpException(e));
                throw new Exception(message.ToString(), e);
            }
            bool hasProvider = false;
            bool hasConsumer = false;
            string ns = "";

            int lssID = 0;
            int lsID = 0;
            ProcessAgentInfo ls = null;
            ProcessAgentInfo lss = null;
            ProcessAgentInfo uss = null;
            LabClient labClient = null;
            GroupCredential credential = null;
            try
            {
                ResourceDescriptorFactory rFactory = ResourceDescriptorFactory.Instance();
                string jobGuid = registerGuid;
                message.AppendLine(" Register called at " + DateTime.UtcNow + " UTC \t registerGUID: " + registerGuid);
                ProcessAgent sourceAgent = brokerDB.GetProcessAgent(agentAuthHeader.agentGuid);
                message.AppendLine("Source Agent: " + sourceAgent.agentName);

                for (int i = 0; i < info.Length; i++)
                {

                    Coupon coupon = null;
                    if (info[i].coupon != null)
                    {
                        coupon = info[i].coupon;
                    }
                    if (info[i].serviceProviderInfo != null && info[i].serviceProviderInfo.Length > 0)
                    {
                        // ProviderInfo is simple add to database and create qualifier
                        if (!hasProvider)
                        {
                            message.AppendLine("Provider Info:");
                            hasProvider = true;
                        }
                        XmlQueryDoc xdoc = new XmlQueryDoc(info[i].serviceProviderInfo);
                        string descriptorType = xdoc.GetTopName();
                        if (descriptorType.Equals("processAgentDescriptor"))
                        {
                            string paGuid = xdoc.Query("/processAgentDescriptor/agentGuid");
                            string paType = xdoc.Query("/processAgentDescriptor/type");
                            if (paType.Equals(ProcessAgentType.LAB_SCHEDULING_SERVER))
                            {
                                lssID = brokerDB.GetProcessAgentID(paGuid);
                                if (lssID > 0)
                                {
                                    // Already in database
                                    //message.AppendLine("Reference to existing LSS: " + lssID + " GUID: " + paGuid);

                                }
                                else
                                {
                                    lss = rFactory.LoadProcessAgent(xdoc, ref message);
                                    lssID = lss.agentId;
                                }
                            }
                            else if (paType.Equals(ProcessAgentType.LAB_SERVER))
                            {
                                lsID = brokerDB.GetProcessAgentID(paGuid);
                                if (lsID > 0)
                                {
                                    // Already in database
                                    //message.AppendLine("Reference to existing LS: " + lsID + " GUID: " + paGuid);

                                }
                                else
                                {
                                    ls = rFactory.LoadProcessAgent(xdoc, ref message);
                                    lsID = ls.agentId;
                                }
                                int myLssID = brokerDB.FindProcessAgentIdForAgent(lsID, ProcessAgentType.LAB_SCHEDULING_SERVER);
                                if ((lssID > 0) && (myLssID <= 0) && (lssID != myLssID))
                                {
                                    brokerDB.AssociateLSS(lsID, lssID);
                                }
                            }
                        }
                        else if (descriptorType.Equals("clientDescriptor"))
                        {
                            int clientId = -1;
                            string clientGuid = xdoc.Query("/clientDescriptor/clientGuid");
                            clientId = AdministrativeAPI.GetLabClientID(clientGuid);
                            if (clientId > 0)
                            {
                                // Already in database
                                message.Append(" Attempt to Register a LabClient that is already in the database. ");
                                message.AppendLine(" GUID: " + clientGuid);
                            }
                            else
                            {
                                // LabServer should already be in the Database, once multiple LS supported may need work
                                // LS is specified in clientDescriptor
                                int clientID = rFactory.LoadLabClient(xdoc, ref message);
                                message.AppendLine("Adding LabClient: GUID " + clientGuid);
                            }
                        }
                        else if (descriptorType.Equals("systemSupport"))
                        {
                            // Already handled in base.register

                        }
                        // Add Relationships: LSS, LS Client
                    } // end of ServiceProvider
                    if (info[i].consumerInfo != null && info[i].consumerInfo.Length > 0)
                    {
                          // requestSystemSupport Handled by base register & there is no xml dcument
                        if (info[i].consumerInfo.CompareTo("requestSystemSupport") != 0)
                        {
                            message.AppendLine("Consumer Info: " + info[i].consumerInfo);
                            //if (!hasConsumer)
                            //    message.AppendLine("Consumer Info: " + info[i].consumerInfo);
                            hasConsumer = true;
                            XmlQueryDoc xdoc = new XmlQueryDoc(info[i].consumerInfo);
                            string descriptorType = xdoc.GetTopName();
                            if (descriptorType.Equals("processAgentDescriptor"))
                            {
                                string paGuid = xdoc.Query("/processAgentDescriptor/agentGuid");
                                ProcessAgentInfo paInfo = brokerDB.GetProcessAgentInfo(paGuid);
                                if (paInfo == null)
                                {
                                    // Not in database
                                    paInfo = rFactory.LoadProcessAgent(xdoc, ref message);
                                    message.Append("Loaded new ");
                                }
                                else
                                {
                                    message.Append("Reference to existing ");
                                    if (paInfo.retired)
                                    {
                                        throw new Exception("The ProcessAgent is retired");
                                    }
                                }

                                if (paInfo.agentType == ProcessAgentType.AgentType.LAB_SCHEDULING_SERVER)
                                {
                                    lss = paInfo;
                                    message.AppendLine("LSS: " + paGuid);
                                }
                                else if (paInfo.agentType == ProcessAgentType.AgentType.LAB_SERVER)
                                {
                                    ls = paInfo;
                                    message.AppendLine("LS: " + paGuid);
                                }
                                else if (paInfo.agentType == ProcessAgentType.AgentType.SCHEDULING_SERVER)
                                {
                                    uss = paInfo;
                                    message.AppendLine("USS: " + paGuid);
                                    if (lss != null)
                                    {
                                        if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid))
                                        {
                                            message.AppendLine("Registering USSinfo on LSS: " + lss.agentName);
                                            LabSchedulingProxy lssProxy = new LabSchedulingProxy();
                                            lssProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                            lssProxy.AgentAuthHeaderValue.coupon = lss.identOut;
                                            lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                            lssProxy.Url = lss.webServiceUrl;
                                            lssProxy.AddUSSInfo(uss.agentGuid, uss.agentName, uss.webServiceUrl, coupon);
                                        }
                                        else
                                        {
                                            message.AppendLine("LSS is not from this domain");
                                        }
                                    }
                                }

                            }
                            else if (descriptorType.Equals("clientDescriptor"))
                            {
                                int newClientId = -1;
                                string clientGuid = xdoc.Query("/clientDescriptor/clientGuid");
                                int clientId = AdministrativeAPI.GetLabClientID(clientGuid);
                                if (clientId > 0)
                                {
                                    // Already in database
                                    message.Append(" Attempt to Register a LabClient that is already in the database. ");
                                    message.AppendLine(" GUID: " + clientGuid);
                                }
                                else
                                {
                                    clientId = rFactory.LoadLabClient(xdoc, ref message);
                                    message.AppendLine("Adding Lab Client GUID: " + clientGuid);
                                }
                            }
                            else if (descriptorType.Equals("credentialDescriptor"))
                            {
                                credential = rFactory.ParseCredential(xdoc, ref message);
                                if (lss != null)
                                {
                                    if (lss.domainGuid.Equals(ProcessAgentDB.ServiceGuid))
                                    {
                                        message.AppendLine("Registering Group Credentials on LSS: " + lss.agentName);
                                        message.AppendLine("Group:  " + credential.groupName + " DomainServer: " + credential.domainServerName);
                                        LabSchedulingProxy lssProxy = new LabSchedulingProxy();
                                        lssProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                        lssProxy.AgentAuthHeaderValue.coupon = lss.identOut;
                                        lssProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                        lssProxy.Url = lss.webServiceUrl;
                                        lssProxy.AddCredentialSet(credential.domainGuid, credential.domainServerName, credential.groupName, credential.ussGuid);
                                    }
                                    else
                                    {
                                        message.AppendLine("LSS is not from this domain");
                                    }
                                }
                            }
                        }
                    }
                } // End of info loop
            } // End of Try
            catch (Exception ex)
            {
                message.Append("Exception in Register: " + Utilities.DumpException(ex));

                throw new Exception(message.ToString(),ex);
            }
            finally
            {
                // Send a mail Message
                StringBuilder sb = new StringBuilder();

                MailMessage mail = new MailMessage();
                mail.To = ConfigurationManager.AppSettings["supportMailAddress"];
                //mail.To = "*****@*****.**";
                mail.From = ConfigurationManager.AppSettings["genericFromMailAddress"];
                mail.Subject = "Register called on " + ProcessAgentDB.ServiceAgent.agentName;
                mail.Body = message.ToString();
                SmtpMail.SmtpServer = "127.0.0.1";

                try
                {
                    SmtpMail.Send(mail);
                }
                catch (Exception ex)
                {
                    // Report detailed SMTP Errors
                    StringBuilder smtpErrorMsg = new StringBuilder();
                    smtpErrorMsg.Append("Exception: " + ex.Message);
                    //check the InnerException
                    if (ex.InnerException != null)
                        smtpErrorMsg.Append("<br>Inner Exceptions:");
                    while (ex.InnerException != null)
                    {
                        smtpErrorMsg.Append("<br>" + ex.InnerException.Message);
                        ex = ex.InnerException;
                    }
                    Logger.WriteLine(smtpErrorMsg.ToString());
                }
            }
        }
        protected virtual void register(string registerGuid, ServiceDescription[] info)
        {
            StringBuilder message = new StringBuilder("Register called on " + ProcessAgentDB.ServiceAgent.codeBaseUrl);

            if (info != null && info.Length > 0)
            {
                foreach (ServiceDescription sd in info)
                {
                    Coupon coupon = null;
                    if (sd.coupon != null)
                    {
                        coupon = sd.coupon;
                    }
                    XmlQueryDoc xdoc = new XmlQueryDoc(sd.serviceProviderInfo);
                    string descriptorType = xdoc.GetTopName();
                    if (descriptorType.Equals("systemSupport"))
                    {
                        SystemSupport ss = SystemSupport.Parse(xdoc);
                        if (ss.agentGuid != null && ss.agentGuid.Length > 0)
                        {
                            int id = dbTicketing.GetProcessAgentID(ss.agentGuid);
                            if (id > 0)
                            {
                                dbTicketing.SaveSystemSupport(ss.agentGuid, ss.contactEmail, ss.bugEmail,
                                    ss.infoUrl, ss.description, ss.location);
                                if (sd.consumerInfo != null && sd.consumerInfo.CompareTo("requestSystemSupport") == 0)
                                {
                                    ProcessAgentInfo paInfo = dbTicketing.GetProcessAgentInfo(ss.agentGuid);
                                    if (paInfo != null)
                                    {
                                        SystemSupport mySS = dbTicketing.RetrieveSystemSupport(ProcessAgentDB.ServiceGuid);
                                        if (mySS != null)
                                        {
                                            ServiceDescription[] values = new ServiceDescription[1];
                                            values[0] = new ServiceDescription(mySS.ToXML(), null, null);
                                            ProcessAgentProxy proxy = new ProcessAgentProxy();
                                            proxy.Url = paInfo.webServiceUrl;
                                            proxy.AgentAuthHeaderValue = new AgentAuthHeader();
                                            proxy.AgentAuthHeaderValue.coupon = paInfo.identOut;
                                            proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                                            proxy.Register(registerGuid, values);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }