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; }
/// <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); }
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; }