/// <summary> /// /// </summary> /// <param name="username"></param> /// <param name="groupName"></param> /// <param name="labClientName"></param> /// <param name="labClientVersion"></param> /// <returns>The redirect url where the user should be redirected, with the coupon appended to it</returns> public string ExecuteExerimentSchedulingRecipe(ProcessAgent uss, ProcessAgent lss, string username, int userID, string groupName, string labServerGuid, LabClient labClient, long duration, int userTZ) { try { BrokerDB issuer = new BrokerDB(); TicketLoadFactory factory = TicketLoadFactory.Instance(); string ticketType = TicketTypes.SCHEDULE_SESSION; //the uss is the redeemer of the scheduling ticket //string redeemerId = uss.agentGuid; //the SB is the sponsor of the scheduling ticket //string sponsorId = issuer.GetIssuerGuid(); string payload1 = factory.createScheduleSessionPayload(username, userID, groupName, issuer.GetIssuerGuid(), labServerGuid, labClient.clientGuid, labClient.clientName, labClient.version, uss.webServiceUrl, userTZ); string payload2 = factory.createRequestReservationPayload(); Coupon schedulingCoupon = issuer.CreateTicket(TicketTypes.SCHEDULE_SESSION, uss.agentGuid, issuer.GetIssuerGuid(), duration, payload1); issuer.AddTicket(schedulingCoupon, TicketTypes.REQUEST_RESERVATION, lss.agentGuid, uss.agentGuid, duration, payload2); // // construct the redirection url // string issuerGuid = schedulingCoupon.issuerGuid; string passkey = schedulingCoupon.passkey; string couponId = schedulingCoupon.couponId.ToString(); // obtain the reservation URL from the admin URLs table string schedulingUrl = issuer.RetrieveAdminURL(uss.agentGuid, TicketTypes.SCHEDULE_SESSION).Url; schedulingUrl += "?coupon_id=" + couponId + "&issuer_guid=" + issuerGuid + "&passkey=" + passkey; return schedulingUrl; } catch { throw; } }
public virtual int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, string extra, Coupon inCoupon, Coupon outCoupon) { int status = 0; if (dbTicketing.AuthenticateAgentHeader(agentAuthHeader)) { status = dbTicketing.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra); } return status; }
public override int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, Coupon inCoupon, Coupon outCoupon, string extra) { int status = 0; ProcessAgentInfo paiOld = GetProcessAgentInfo(agent.agentGuid); try { status = base.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra); } catch (Exception ex) { throw new Exception("ISB: ", ex); } if (paiOld != null) { if (agent.codeBaseUrl.CompareTo(paiOld.codeBaseUrl) != 0) { ModifyAdminUrls(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); ModifyResourceInfoURL(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); if (paiOld.agentType == ProcessAgentType.AgentType.LAB_SERVER) { ModifyClientScripts(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); } } } //Notify all ProcessAgents about the change ProcessAgentInfo[] domainServices = GetProcessAgentInfos(); ProcessAgentProxy proxy = null; foreach (ProcessAgentInfo pi in domainServices) { // Do not send if retired this service or the service being modified since this is if (!pi.retired && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0) && (pi.agentGuid.CompareTo(agent.agentGuid) != 0)) { proxy = new ProcessAgentProxy(); proxy.AgentAuthHeaderValue = new AgentAuthHeader(); proxy.AgentAuthHeaderValue.coupon = pi.identOut; proxy.Url = pi.webServiceUrl; proxy.ModifyDomainCredentials(originalGuid, agent, extra, inCoupon, outCoupon); } } return status; }
public DomainCredentials() { agent = null; inCoupon = null; outCoupon = null; }
/// <summary> /// Modifies the information related to the specified service the service's Guid must exist and the typ of service may not be modified, /// in and out coupons may be changed. /// </summary> /// <param name="service"></param> /// <param name="inIdentCoupon"></param> /// <param name="outIdentCoupon"></param> /// <returns></returns> public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; try { status = base.ModifyProcessAgent(originalGuid, agent, extra); } catch (Exception ex) { throw new Exception("USS: ", ex); } if (agent.type == ProcessAgentType.SERVICE_BROKER || agent.type == ProcessAgentType.REMOTE_SERVICE_BROKER) { //Check for SB names in credential sets ModifyCredentialSetServiceBroker(originalGuid, agent.agentGuid, agent.agentName); } if (agent.type == ProcessAgentType.LAB_SERVER) { // Labserver Names in Experiment info's ModifyExperimentLabServer(agent.agentGuid, agent.agentName); } if (agent.type == ProcessAgentType.LAB_SCHEDULING_SERVER) { // LSS path, & name in LSS_Info ModifyLSSInfo(agent.agentGuid, agent.agentName, agent.webServiceUrl); } return status; }
/// <summary> /// Copies the standard agent select results into a ProcessAgent object /// </summary> /// <param name="dataReader"></param> /// <returns></returns> protected ProcessAgent readProcessAgent(DbDataReader dataReader) { ProcessAgent agent = new ProcessAgent(); long id = dataReader.GetInt32(0); agent.agentGuid = dataReader.GetString(1); agent.agentName = dataReader.GetString(2); // get process agent type if (!DBNull.Value.Equals(dataReader.GetValue(3))) agent.type = dataReader.GetString(3); // get the description if (!DBNull.Value.Equals(dataReader.GetValue(4))) agent.domainGuid = dataReader.GetString(4); // Get CodeBase if (!DBNull.Value.Equals(dataReader.GetValue(5))) agent.codeBaseUrl = dataReader.GetString(5); // get Webservice_URL if (!DBNull.Value.Equals(dataReader.GetValue(6))) agent.webServiceUrl = dataReader.GetString(6); return agent; }
public virtual int ModifyDomainCredentials(string originalGuid, ProcessAgent service, Coupon inCoupon, Coupon outCoupon, string extra) { int status = 0; bool error = false; StringBuilder buf = new StringBuilder(); Coupon couponIn = null; Coupon couponOut = null; if (service.domainGuid == null) { error = true; buf.Append(" The domain is not set."); } if (inCoupon == null || inCoupon.issuerGuid == null || (inCoupon.issuerGuid.CompareTo(service.domainGuid) != 0)) { error = true; buf.Append(" The inCoupon is not valid."); } else { couponIn = GetCoupon(inCoupon.couponId, inCoupon.issuerGuid); if (couponIn == null) { InsertCoupon(inCoupon); } else if (couponIn.passkey.CompareTo(inCoupon.passkey) != 0) { error = true; buf.Append(" inCoupon conflits with coupon in database."); } } if (outCoupon == null || outCoupon.issuerGuid == null || (outCoupon.issuerGuid.CompareTo(service.domainGuid) != 0)) { error = true; buf.Append(" The outCoupon is not valid."); } else { couponOut = GetCoupon(outCoupon.couponId, outCoupon.issuerGuid); if (couponOut == null) { InsertCoupon(outCoupon); } else if (couponOut.passkey.CompareTo(outCoupon.passkey) != 0) { error = true; buf.Append(" outCoupon conflits with coupon in database."); } } if (error) { throw new Exception(buf.ToString()); } status = ModifyProcessAgent(originalGuid, service, extra); SetIdentInCouponID(service.agentGuid, inCoupon.couponId); SetIdentOutCouponID(service.agentGuid, outCoupon.couponId); return status; }
/// <summary> /// Retrieve all the process agents of a given type from the database /// </summary> /// <returns>Array of objects that represent the retrieved static process agents</returns> public ProcessAgent[] GetProcessAgentsByType(string agentType) { ArrayList list = new ArrayList(); ProcessAgent agent = null; // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command // command executes the "RetrieveProcessAgentDescriptors" stored procedure DbCommand cmd = connection.CreateCommand(); cmd.CommandText = "GetProcessAgentsByType"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(FactoryDB.CreateParameter(cmd,"@agentType",agentType, DbType.AnsiString, 100)); // execute the command DbDataReader dataReader = null; try { connection.Open(); dataReader = cmd.ExecuteReader(); // add the agent to the list while (dataReader.Read()) { agent = readProcessAgent(dataReader); list.Add(agent); } } catch (DbException e) { writeEx(e); throw; } finally { connection.Close(); } ProcessAgent dummy = new ProcessAgent(); ProcessAgent[] agents = (ProcessAgent[])list.ToArray(dummy.GetType()); return agents; }
public override int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, string extra, Coupon inCoupon, Coupon outCoupon) { int status = 0; if (brokerDB.AuthenticateAgentHeader(agentAuthHeader)) { status = brokerDB.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra); //Notify all ProcessAgents about the change ProcessAgentInfo[] domainServices = brokerDB.GetProcessAgentInfos(); ProcessAgentProxy proxy = null; foreach (ProcessAgentInfo pi in domainServices) { // Do not send if retired this service or the service being modified since this is if (!pi.retired && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0) && (pi.agentGuid.CompareTo(agent.agentGuid) != 0)) { proxy = new ProcessAgentProxy(); proxy.AgentAuthHeaderValue = new AgentAuthHeader(); proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; proxy.AgentAuthHeaderValue.coupon = pi.identOut; proxy.Url = pi.webServiceUrl; status += proxy.ModifyDomainCredentials(originalGuid, agent, extra, inCoupon, outCoupon); } } } return status; }
/// <summary> /// Install the Domain credentials on this static process agent /// </summary> /// <param name="initialPasskey"></param> /// <param name="agent" Description="used to provide the service address of the the agent not stored on the agent"></param> /// <param name="agentIdentCoupon" Description="For messages from the PA_Service"></param> /// <param name="serviceBroker" Description="service information stored on PA_Service"></param> /// <param name="sbIdentCoupon" Description="For messages from the SB"></param> protected override ProcessAgent installDomainCredentials(ProcessAgent service, Coupon inIdentCoupon, Coupon outIdentCoupon) { // if the remote process agent is a Service Broker, register it as a remote service broker if (service.type.Equals(ProcessAgentType.SERVICE_BROKER)) { service.type = ProcessAgentType.REMOTE_SERVICE_BROKER; } //else{ return base.installDomainCredentials(service, inIdentCoupon, outIdentCoupon); }
public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; UserSchedulingDB dbManager = new UserSchedulingDB(); if (dbManager.AuthenticateAgentHeader(agentAuthHeader)) { status = dbManager.ModifyProcessAgent(originalGuid, agent, extra); } return status; }
public override int ModifyDomainCredentials(string originalGuid, ProcessAgent agent, string extra, Coupon inCoupon, Coupon outCoupon) { int status = 0; UserSchedulingDB dbManager = new UserSchedulingDB(); if (dbManager.AuthenticateAgentHeader(agentAuthHeader)) { try { status = dbManager.ModifyDomainCredentials(originalGuid, agent, inCoupon, outCoupon, extra); } catch (Exception ex) { throw new Exception("USS: ", ex); } } return status; }
public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; if (dbTicketing.AuthenticateAgentHeader(agentAuthHeader)) { DBManager dbManager = new DBManager(); status = dbManager.ModifyProcessAgent(originalGuid, agent, extra); } return status; }
protected virtual ProcessAgent installDomainCredentials(ProcessAgent service, Coupon inIdentCoupon, Coupon outIdentCoupon) { ProcessAgent agent = null; try { if (ProcessAgentDB.ServiceAgent == null) { throw new Exception("The target ProcessAgent has not been configured, please contact the administrator."); } if (service.type.Equals(ProcessAgentType.SERVICE_BROKER)) { int[] ids = dbTicketing.GetProcessAgentIDsByType((int)ProcessAgentType.AgentType.SERVICE_BROKER); if (ids != null && ids.Length > 0) { throw new Exception("There is already a domain ServiceBroker assigned to this Service!"); } else { int id = dbTicketing.InsertProcessAgent(service, inIdentCoupon, outIdentCoupon); if (id > 0) { dbTicketing.SetDomainGuid(service.agentGuid); ProcessAgentDB.RefreshServiceAgent(); Utilities.WriteLog("InstallDomainCredentials: " + service.codeBaseUrl); agent = ProcessAgentDB.ServiceAgent; } else { Utilities.WriteLog("Error InstallDomainCredentials: " + service.codeBaseUrl); throw new Exception("Error Installing DomainCredentials on: " + ProcessAgentDB.ServiceAgent.codeBaseUrl); } } } else { int[] ids = dbTicketing.GetProcessAgentIDsByType((int)ProcessAgentType.AgentType.SERVICE_BROKER); if (ids == null || ids.Length == 0) { throw new Exception("This Service is not part of a domain and may not be accessed"); } else { int pid = dbTicketing.InsertProcessAgent(service, inIdentCoupon, outIdentCoupon); if (pid > 0) { Utilities.WriteLog("InstallDomainCredentials: " + service.codeBaseUrl); agent = ProcessAgentDB.ServiceAgent; } else { Utilities.WriteLog("Error InstallDomainCredentials: " + service.codeBaseUrl); throw new Exception("Error Installing DomainCredentials on: " + ProcessAgentDB.ServiceAgent.codeBaseUrl); } } } } catch (Exception e) { Utilities.WriteLog("Error on InstallDomainCredentials: " + Utilities.DumpException(e)); throw; } return agent; }
public virtual int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; if (dbTicketing.AuthenticateAgentHeader(agentAuthHeader)) { status = dbTicketing.ModifyProcessAgent(originalGuid, agent, extra); } return status; }
/// <summary> /// Loads the static varable serviceAgent with the processAgent's ProcessAgent data. /// </summary> /// <returns></returns> public static bool RefreshServiceAgent() { ProcessAgentDB padb = new ProcessAgentDB(); ProcessAgent tmp = padb.GetSelfProcessAgent(); serviceAgent = tmp; return (tmp != null); }
/// <summary> /// Retrieve all process agent records from the database /// </summary> /// <param name="guid">The Guid id of the static process agent</param> /// <returns>Object that represents the retrieved static process agent</returns> public ProcessAgent[] GetProcessAgents() { // create sql connection DbConnection connection = FactoryDB.GetConnection(); // create sql command // command executes the "RetrieveProcessAgentDescriptor" stored procedure DbCommand cmd = connection.CreateCommand(); cmd.CommandText= "GetProcessAgents"; cmd.CommandType = CommandType.StoredProcedure; // execute the command DbDataReader dataReader = null; try { connection.Open(); dataReader = cmd.ExecuteReader(); } catch (DbException e) { writeEx(e); throw; } ArrayList list = new ArrayList(); ProcessAgent agent = null; while (dataReader.Read()) { agent = readProcessAgent(dataReader); list.Add(agent); } connection.Close(); ProcessAgent dummy = new ProcessAgent(); ProcessAgent[] agents = (ProcessAgent[])list.ToArray(dummy.GetType()); return agents; }
public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; if (brokerDB.AuthenticateAgentHeader(agentAuthHeader)) { status = brokerDB.ModifyProcessAgent(originalGuid, agent, extra); } return status; }
public int InsertProcessAgent(ProcessAgent paIdent, Coupon inCoupon, Coupon outCoupon) { return InsertProcessAgent(paIdent.agentGuid, paIdent.agentName, paIdent.type, paIdent.domainGuid, paIdent.codeBaseUrl, paIdent.webServiceUrl, inCoupon, outCoupon); }
public void Add(string key, ProcessAgent info) { Add(key + ":agentGuid", info.agentGuid); Add(key + ":agentName", info.agentName); Add(key + ":codebase", info.codeBaseUrl); Add(key + ":serviceUrl", info.webServiceUrl); }
public virtual int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; int id = GetProcessAgentID(originalGuid); if (id > 1) { status = UpdateProcessAgent(id, agent.agentGuid, agent.agentName, agent.type, agent.domainGuid, agent.codeBaseUrl, agent.webServiceUrl); if (extra != null && extra.Length > 0) { try { SystemSupport systemSupport = SystemSupport.Parse(extra); if (systemSupport != null && systemSupport.agentGuid.CompareTo(agent.agentGuid) == 0) { SaveSystemSupport(systemSupport.agentGuid, systemSupport.contactEmail, systemSupport.bugEmail, systemSupport.infoUrl, systemSupport.description, systemSupport.location); } } catch (Exception e) { Utilities.WriteLog("InstallDomainCredentials: Error on systemSupport - " + e.Message); } } } return status; }
protected void btnModify_Click(object sender, System.EventArgs e) { bool error = false; StringBuilder message = new StringBuilder(); try { if (ProcessAgentDB.ServiceAgent != null) { string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid; if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0)) { error = true; message.Append(" You must enter a Service Name<br/>"); } try { if (!checkGuid()) { error = true; message.Append("There is an unspecified error with the GUID string.<br/>"); } } catch (Exception ex) { error = true; message.Append("GUID Error: "); message.Append(ex.Message); message.Append("<br/>"); } if (!(txtOutPasskey.Text != null && txtOutPasskey.Text.Length > 0)) { error = true; message.Append(" You must enter a default passkey<br/>"); } if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0)) { error = true; message.Append(" You must enter the base URL for the Web Site<br/>"); } else if (txtCodebaseUrl.Text.Contains("localhost")) { error = true; message.Append(" You must not use localhost in a codebase URL, if you must test on the local machine please use '127.0.0.1'.<br/>"); } if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0)) { error = true; message.Append(" You must enter the web Ssrvice URL for the Web Site<br/>"); } else if (txtServiceUrl.Text.Contains("localhost")) { error = true; message.Append(" You must not use localhost in a web service URL, if you must test only on the local machine please use '127.0.0.1'.<br/>"); } else { // Test for valid webService URL ProcessAgentProxy paProxy = new ProcessAgentProxy(); paProxy.Url = txtServiceUrl.Text.Trim(); try { DateTime serTime = paProxy.GetServiceTime(); } catch { error = true; message.Append(" There is an error with the web service URL: " + txtServiceUrl.Text.Trim() + " Please check that it is valid and the web service is configured correctly.<br/>"); } } if (error) { lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; return; } if (ProcessAgentDB.ServiceAgent.domainGuid != null) { ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid); ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid); if ((sb != null) && !sb.retired) { ProcessAgentProxy psProxy = new ProcessAgentProxy(); AgentAuthHeader header = new AgentAuthHeader(); header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid; header.coupon = sb.identOut; psProxy.AgentAuthHeaderValue = header; psProxy.Url = sb.webServiceUrl; ProcessAgent pa = new ProcessAgent(); pa.agentGuid = txtServiceGuid.Text; pa.agentName = txtServiceName.Text; pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid; pa.codeBaseUrl = txtCodebaseUrl.Text; pa.webServiceUrl = txtServiceUrl.Text; pa.type = AgentType; //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType, // pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); //message.Append("Local information has been saved. "); int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null); message.Append("The changes have been sent to the ServiceBroker"); if (returnValue > 0) { dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType, pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); message.Append(".<br />Local information has been saved. "); lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString()); lblResponse.Visible = true; } else { message.Append(", but did not process correctly!"); message.Append("<br />Local information has not been saved. "); lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; } } } else { string tmpGuid = null; if (AgentType == ProcessAgentType.SERVICE_BROKER) { tmpGuid = ProcessAgentDB.ServiceAgent.agentGuid; AuthorityUpdateSelf(txtServiceName.Text,ProcessAgentDB.ServiceAgent.agentGuid, txtCodebaseUrl.Text.Trim(), txtDescription.Text, txtContactInfo.Text, txtBugEmail.Text, txtLocation.Text); } dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType, tmpGuid, txtCodebaseUrl.Text.Trim(), txtServiceUrl.Text.Trim()); dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text, txtInfoUrl.Text, txtDescription.Text, txtLocation.Text); } ProcessAgentDB.RefreshServiceAgent(); // if (txtOutPasskey.Text.CompareTo(ConfigurationManager.AppSettings["defaultPasskey"]) != 0) // { // ConfigurationManager.AppSettings.Set("defaultPasskey", txtOutPasskey.Text); // } } } catch (Exception ex) { Exception ex2 = new Exception("Error in selfRegistration.modify()", ex); Logger.WriteLine(Utilities.DumpException(ex2)); throw ex2; } }
public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; status = base.ModifyProcessAgent(originalGuid, agent, extra); if (agent.type == ProcessAgentType.LAB_SERVER) { // Labserver Names in Experiment info's // Labserver Names in LS_Resource if (DBManager.ModifyExperimentLabServer(originalGuid, agent.agentGuid, agent.agentName)) status++; } if (agent.type == ProcessAgentType.SCHEDULING_SERVER) { // USS path, & name in USS_Info int ussId = DBManager.ListUSSInfoID(agent.agentGuid); if (ussId > 0) { USSInfo[] uss = DBManager.GetUSSInfos(new int[] { ussId }); if (uss != null && uss.Length > 0) status += DBManager.ModifyUSSInfo(ussId, agent.agentGuid, agent.agentName, agent.webServiceUrl, uss[0].couponId, uss[0].domainGuid); } } if (agent.type == ProcessAgentType.SERVICE_BROKER || agent.type == ProcessAgentType.REMOTE_SERVICE_BROKER) { status += DBManager.ModifyCredentialSetServiceBroker(originalGuid, agent.agentGuid, agent.agentName); } return status; }
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(); ; }
protected void btnModify_Click(object sender, System.EventArgs e) { bool error = false; StringBuilder message = new StringBuilder(); try { if (ProcessAgentDB.ServiceAgent != null) { string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid; if (!(txtServiceName.Text != null && txtServiceName.Text.Length > 0)) { error = true; message.Append(" You must enter a Service Name<br/>"); } try { if (!checkGuid()) { error = true; message.Append("There is an unspecified error with the GUID string.<br/>"); } } catch (Exception ex) { error = true; message.Append("GUID Error: "); message.Append(ex.Message); message.Append("<br/>"); } if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Length > 0)) { error = true; message.Append(" You must enter the base URL for the Web Site<br/>"); } if (!(txtServiceUrl.Text != null && txtServiceUrl.Text.Length > 0)) { error = true; message.Append(" You must enter full URL of the Web Service page<br/>"); } if (error) { lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; return; } if (ProcessAgentDB.ServiceAgent.domainGuid != null) { ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid); ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid); if ((sb != null) && !sb.retired) { ProcessAgentProxy psProxy = new ProcessAgentProxy(); AgentAuthHeader header = new AgentAuthHeader(); header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid; header.coupon = sb.identOut; psProxy.AgentAuthHeaderValue = header; psProxy.Url = sb.webServiceUrl; ProcessAgent pa = new ProcessAgent(); pa.agentGuid = txtServiceGuid.Text; pa.agentName = txtServiceName.Text; pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid; pa.codeBaseUrl = txtCodebaseUrl.Text; pa.webServiceUrl = txtServiceUrl.Text; pa.type = AgentType; //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType, // pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); //message.Append("Local information has been saved. "); int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null); message.Append("The changes have been sent to the ServiceBroker"); if (returnValue > 0) { dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, AgentType, pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); message.Append(".<br />Local information has been saved. "); lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString()); lblResponse.Visible = true; } else { message.Append(", but did not process correctly!"); message.Append("<br />Local information has not been saved. "); lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; } } } else { dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, AgentType, null, txtCodebaseUrl.Text, txtServiceUrl.Text); dbTicketing.SaveSystemSupport(ProcessAgentDB.ServiceAgent.agentGuid, txtContactInfo.Text, txtBugEmail.Text, txtInfoUrl.Text, txtDescription.Text, txtLocation.Text); } } } catch (Exception ex) { Exception ex2 = new Exception("Error in selfRegistration.modify()", ex); Utilities.WriteLog(Utilities.DumpException(ex2)); throw ex2; } }
/// <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 DomainCredentials(ProcessAgent processAgent,Coupon inCoupon, Coupon outCoupon) { agent = processAgent; this.inCoupon = inCoupon; this.outCoupon = outCoupon; }
protected void modifyService(object sender, System.EventArgs e) { bool error = false; StringBuilder message = new StringBuilder(); try { if (ProcessAgentDB.ServiceAgent != null) { string originalGuid = ProcessAgentDB.ServiceAgent.agentGuid; if (!(txtServiceName.Text != null && txtServiceName.Text.Trim().Length > 0)) { error = true; message.Append(" You must enter a Service Name<br/>"); } if (!(txtCodebaseUrl.Text != null && txtCodebaseUrl.Text.Trim().Length > 0)) { error = true; message.Append(" You must enter the base URL for the Web Site<br/>"); } if (!(txtWebServiceUrl.Text != null && txtWebServiceUrl.Text.Trim().Length > 0)) { error = true; message.Append(" You must enter full URL of the Web Service page<br/>"); } if (error) { lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; return; } if ((txtServiceName.Text.Trim().CompareTo(bakServiceName.Value) == 0) && (txtCodebaseUrl.Text.Trim().CompareTo(bakCodebase.Value) == 0) && (txtWebServiceUrl.Text.Trim().CompareTo(bakServiceUrl.Value) == 0)) { lblResponse.Text = Utilities.FormatWarningMessage("No user editable fields have been changed, modify aborted!"); lblResponse.Visible = true; return; } if (ProcessAgentDB.ServiceAgent.domainGuid != null) { ProcessAgentInfo originalAgent = dbTicketing.GetProcessAgentInfo(originalGuid); ProcessAgentInfo sb = dbTicketing.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid); if ((sb != null) && !sb.retired) { ProcessAgentProxy psProxy = new ProcessAgentProxy(); AgentAuthHeader header = new AgentAuthHeader(); header.agentGuid = ProcessAgentDB.ServiceAgent.agentGuid; header.coupon = sb.identOut; psProxy.AgentAuthHeaderValue = header; psProxy.Url = sb.webServiceUrl; ProcessAgent pa = new ProcessAgent(); pa.agentGuid = txtServiceGUID.Text.Trim(); pa.agentName = txtServiceName.Text.Trim(); pa.domainGuid = ProcessAgentDB.ServiceAgent.domainGuid; pa.codeBaseUrl = txtCodebaseUrl.Text.Trim(); pa.webServiceUrl = txtWebServiceUrl.Text.Trim(); pa.type = agentType; //dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType, // pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); //message.Append("Local information has been saved. "); int returnValue = psProxy.ModifyProcessAgent(originalGuid, pa, null); message.Append("The changes have been sent to the ServiceBroker"); if (returnValue > 0) { dbTicketing.SelfRegisterProcessAgent(pa.agentGuid, pa.agentName, agentType, pa.domainGuid, pa.codeBaseUrl, pa.webServiceUrl); bakServiceName.Value = pa.agentName; bakCodebase.Value = pa.codeBaseUrl; bakServiceUrl.Value = pa.webServiceUrl; message.Append(".<br />Local information has been saved. "); lblResponse.Text = Utilities.FormatConfirmationMessage(message.ToString()); lblResponse.Visible = true; } else { message.Append(", but did not process correctly!"); message.Append("<br />Local information has not been saved. "); lblResponse.Text = Utilities.FormatErrorMessage(message.ToString()); lblResponse.Visible = true; } } } else { dbTicketing.SelfRegisterProcessAgent(ProcessAgentDB.ServiceAgent.agentGuid, txtServiceName.Text, agentType, null, txtCodebaseUrl.Text, txtWebServiceUrl.Text); } } } catch (Exception ex) { Exception ex2 = new Exception("Error in selfRegistration.modify()",ex); Utilities.WriteLog(Utilities.DumpException(ex2)); throw ex2; } }
public override int ModifyProcessAgent(string originalGuid, ProcessAgent agent, string extra) { int status = 0; ProcessAgentInfo paiOld = GetProcessAgentInfo(originalGuid); if (paiOld != null) { try { status = UpdateProcessAgent(paiOld.agentId, agent.agentGuid, agent.agentName, agent.type, agent.domainGuid, agent.codeBaseUrl, agent.webServiceUrl); } catch (Exception ex) { throw new Exception("ISB: ", ex); } if (agent.codeBaseUrl.CompareTo(paiOld.codeBaseUrl) != 0) { status += ModifyAdminUrls(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); status += ModifyResourceInfoURL(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); if (paiOld.agentType == ProcessAgentType.AgentType.LAB_SERVER) { status += ModifyClientScripts(paiOld.agentId, paiOld.codeBaseUrl, agent.codeBaseUrl); } } if (agent.agentName.CompareTo(paiOld.agentName) != 0) { // need to update Qualifier Names AuthorizationAPI.ModifyQualifierName(Qualifier.ToTypeID(agent.type), paiOld.agentId, agent.agentName); int[] resourceMapIds = GetResourceMappingIdsByValue(ResourceMappingTypes.PROCESS_AGENT, paiOld.agentId); foreach (int id in resourceMapIds) { ResourceMapping map = ResourceMapManager.GetMap(id); AuthorizationAPI.ModifyQualifierName(Qualifier.resourceMappingQualifierTypeID, id, ResourceMappingToString(map)); } } //Notify all ProcessAgents about the change ProcessAgentInfo[] domainServices = GetProcessAgentInfos(); ProcessAgentProxy proxy = null; foreach (ProcessAgentInfo pi in domainServices) { // Do not send if retired this service or the service being modified since this is if (!pi.retired && (pi.agentType != ProcessAgentType.AgentType.BATCH_LAB_SERVER) && (pi.agentGuid.CompareTo(ProcessAgentDB.ServiceGuid) != 0) && (pi.agentGuid.CompareTo(agent.agentGuid) != 0)) { proxy = new ProcessAgentProxy(); proxy.AgentAuthHeaderValue = new AgentAuthHeader(); proxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; proxy.AgentAuthHeaderValue.coupon = pi.identOut; proxy.Url = pi.webServiceUrl; try { status += proxy.ModifyProcessAgent(originalGuid, agent, extra); } catch (Exception ex) { Exception ex2 = new Exception("ModifyProcessAgent: " + pi.webServiceUrl, ex); throw ex2; } } } } return status; }
public ProcessAgent InstallDomainCredentials(ProcessAgent service, Coupon inIdentCoupon, Coupon outIdentCoupon) { if (!initAuthHeader.initPasskey.Equals(ConfigurationManager.AppSettings["defaultPasskey"])) { throw new Exception("The proper authorization to install the domain credentials, has not been provided."); } return installDomainCredentials(service, inIdentCoupon, outIdentCoupon); }