public static SystemSupport Parse(XmlQueryDoc xdoc)
 {
     SystemSupport ss = new SystemSupport();
     try
     {
         ss.agentGuid = xdoc.Query("/systemSupport/agentGuid");
         ss.bugEmail = xdoc.Query("/systemSupport/bugEmail");
         ss.contactEmail = xdoc.Query("/systemSupport/contactEmail");
         ss.infoUrl = xdoc.Query("/systemSupport/infoUrl");
         ss.description = xdoc.Query("/systemSupport/description");
         ss.location = xdoc.Query("/systemSupport/location");
         return ss;
     }
     catch (Exception e)
     {
         ;
     }
     return null;
 }
Example #2
0
        public SystemSupport RetrieveSystemSupport(string guid)
        {
            SystemSupport  ss = null;
            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

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

            // populate parameters
            cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@guid",guid, DbType.AnsiString,50));

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

                // from the dataReader
                while (dataReader.Read())
                {
                    ss = new SystemSupport();
                    if (!dataReader.IsDBNull(0))
                        ss.agentGuid = dataReader.GetString(0);
                    else ss.agentGuid = null;
                    if (!dataReader.IsDBNull(1))
                        ss.contactEmail = dataReader.GetString(1);
                    else ss.contactEmail = null;
                    if (!dataReader.IsDBNull(2))
                        ss.bugEmail = dataReader.GetString(2);
                    else ss.contactEmail = null;
                    if (!dataReader.IsDBNull(3))
                        ss.infoUrl = dataReader.GetString(3);
                    else ss.infoUrl = null;
                    if (!dataReader.IsDBNull(4))
                        ss.description = dataReader.GetString(4);
                    else ss.description = null;
                    if (!dataReader.IsDBNull(5))
                        ss.location = dataReader.GetString(5);
                    else ss.location = null;
                }
            }
            catch (DbException e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                // close the sql connection
                connection.Close();
            }

            return ss;
        }
Example #3
0
        /// <summary>
        /// Loads a new ProcessAgent into the database, without any Ident coupons, creates Qualifier.
        /// </summary>
        /// <param name="xdoc"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public ProcessAgentInfo LoadProcessAgent(XmlQueryDoc xdoc, ref StringBuilder message)
        {
            ProcessAgent pa = new ProcessAgent();
            pa.agentGuid = xdoc.Query("/processAgentDescriptor/agentGuid");
            pa.type = xdoc.Query("/processAgentDescriptor/type");
            pa.agentName = xdoc.Query("/processAgentDescriptor/agentName");
            pa.domainGuid = xdoc.Query("/processAgentDescriptor/domainGuid");
            pa.codeBaseUrl = xdoc.Query("/processAgentDescriptor/codeBaseUrl");
            pa.webServiceUrl = xdoc.Query("/processAgentDescriptor/webServiceUrl");
            int newID = brokerDb.InsertProcessAgent(pa, null, null);

            SystemSupport systemSupport = new SystemSupport();
            systemSupport.agentGuid = xdoc.Query("/processAgentDescriptor/systemSupport/agentGuid");
            systemSupport.bugEmail = xdoc.Query("/processAgentDescriptor/systemSupport/bugEmail");
            systemSupport.contactEmail = xdoc.Query("/processAgentDescriptor/systemSupport/contactEmail");
            systemSupport.infoUrl = xdoc.Query("/processAgentDescriptor/systemSupport/infoUrl");
            systemSupport.description = xdoc.Query("/processAgentDescriptor/systemSupport/desciption");
            systemSupport.location = xdoc.Query("/processAgentDescriptor/systemSupport/loction");
            if (systemSupport != null && systemSupport.agentGuid.CompareTo(pa.agentGuid) == 0)
            {
                brokerDb.SaveSystemSupport(systemSupport.agentGuid, systemSupport.contactEmail, systemSupport.bugEmail,
                    systemSupport.infoUrl, systemSupport.description, systemSupport.location);
            }

            // deal with resources later, need to decode resource Names
            XPathNodeIterator pathIter = xdoc.Select("/processAgentDescriptor/resources/*");
            if (pathIter != null && pathIter.Count > 0)
            {
                while (pathIter.MoveNext())
                {
                    string key = pathIter.Current.GetAttribute("key", ns);
                    string value = pathIter.Current.GetAttribute("value", ns);
                    // Create ResourceMapping
                    ResourceMappingKey mapKey = new ResourceMappingKey(ResourceMappingTypes.PROCESS_AGENT, newID);

                    // create values
                    ResourceMappingValue[] values = new ResourceMappingValue[2];
                    values[0] = new ResourceMappingValue(ResourceMappingTypes.RESOURCE_TYPE, key);
                    values[1] = new ResourceMappingValue(ResourceMappingTypes.STRING, value);
                    ResourceMapping newMapping = brokerDb.AddResourceMapping(mapKey, values);
                }
            }
            message.AppendLine("Registered a new " + pa.type + ": " + newID + ": "
                    + pa.agentName + " -> " + pa.codeBaseUrl);
            //Add Qualifiers
            if (pa.type.Equals(ProcessAgentType.LAB_SCHEDULING_SERVER))
            {
                int lssQualID = AuthorizationAPI.AddQualifier(newID, Qualifier.labSchedulingQualifierTypeID,
                    pa.agentName, Qualifier.ROOT);

            }
            else if (pa.type.Equals(ProcessAgentType.LAB_SERVER))
            {
                int lsQualID = AuthorizationAPI.AddQualifier(newID, Qualifier.labServerQualifierTypeID, pa.agentName, Qualifier.ROOT);
                string lssGuid = xdoc.Query("/processAgentDescriptor/lssGuid");
                if (lssGuid != null && lssGuid.Length > 0)
                {
                    int lssForLsId = brokerDb.GetProcessAgentID(lssGuid);
                    if (lssForLsId > 0)
                    {
                        brokerDb.AssociateLSS(newID, lssForLsId);
                    }
                }
            }
            return brokerDb.GetProcessAgentInfo(pa.agentGuid);
        }
Example #4
0
        public string CreateProcessAgentDescriptor(int agentId, ProcessAgent agent, SystemSupport ss)
        {
            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);

            if (agent != null)
            {
                // write root element
                xmlWriter.WriteStartElement("processAgentDescriptor");
                //xmlWriter.WriteAttributeString("xmlns", "ns", null, nameSpace);

                xmlWriter.WriteElementString("agentGuid", agent.agentGuid);
                xmlWriter.WriteElementString("type", agent.type);
                xmlWriter.WriteElementString("agentName", agent.agentName);
                xmlWriter.WriteElementString("domainGuid", agent.domainGuid);
                xmlWriter.WriteElementString("codeBaseUrl", agent.codeBaseUrl);
                xmlWriter.WriteElementString("webServiceUrl", agent.webServiceUrl);
                if (ss != null)
                    xmlWriter.WriteRaw(ss.ToXML());
                if(agent.type.Equals(ProcessAgentType.LAB_SERVER)){
                    int lssId = brokerDb.FindProcessAgentIdForAgent(agentId, ProcessAgentType.LAB_SCHEDULING_SERVER);
                    if(lssId > 0){
                        ProcessAgent lss = brokerDb.GetProcessAgent(lssId);
                        if(lss != null){

                            xmlWriter.WriteElementString("lssGuid",lss.agentGuid);
                        }
                    }
                }

                Hashtable resourceTags = brokerDb.GetResourceStringTags(agentId, 1);
                if (resourceTags != null && resourceTags.Count > 0)
                {
                    xmlWriter.WriteStartElement("resources");
                    foreach (string s in resourceTags.Keys)
                    {
                        xmlWriter.WriteStartElement("resource");
                        xmlWriter.WriteAttributeString("key", s);
                        xmlWriter.WriteAttributeString("value",((IntTag)resourceTags[s]).tag);
                        xmlWriter.WriteEndElement();
                    }
                    xmlWriter.WriteEndElement();

                }
                xmlWriter.WriteEndElement();
                xmlWriter.Flush();
            }
            return stringBuilder.ToString(); ;
        }