/// <summary> /// Deletes a single experiment, checks for ESS, deletes from the ESS if needed, deletes Qualifier and the experiment administrative info. /// This does not check for authorization the experiment ID should be authorized for deletion before this is called. /// </summary> /// <param name="experimentID"></param> /// <returns></returns> public static bool DeleteExperiment(long experimentID) { bool deleted = false; ExperimentSummary summary = InternalDataDB.SelectExperimentSummary(experimentID); if (summary.HasEss) { ProcessAgentDB ticketing = new ProcessAgentDB(); // Retrieve the ESS Status info and update as needed //This uses a generic ReadRecords ticket created for the ESS ProcessAgentInfo ess = ticketing.GetProcessAgentInfo(summary.essGuid); if ((ess != null) && !ess.retired) { ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); essProxy.Url = ess.webServiceUrl; essProxy.AgentAuthHeaderValue = new AgentAuthHeader(); essProxy.AgentAuthHeaderValue.coupon = ess.identOut; essProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; essProxy.DeleteExperiment(experimentID); } } int qualID = Authorization.AuthorizationAPI.GetQualifierID((int)experimentID, Qualifier.experimentQualifierTypeID); if (qualID > 0) Authorization.AuthorizationAPI.RemoveQualifiers(new int[] { qualID }); deleted = InternalDataDB.DeleteExperiment(experimentID); return deleted; }
/// <summary> /// Method that does the actual make reservation for the user. /// makes the basis of the parameters from the message and the application database /// </summary> /// <param name="userName"> the user who is scheduling for the lab; must be registered with the service broker</param> /// <param name="groupName">the group name authorized to do a lab</param> /// <param name="labServerGuid">lab server which holds the lab that does the actual scheduling</param> /// <param name="clientGuid">Guid of the lab being registered for</param> /// <param name="start">Start time of a particular period scheduled for</param> /// <param name="end">End time of a particular period being scheduled for</param> /// <returns>returns a message string that the application bases on for to give the feedback to the user</returns> public static string MakeReservation(string userName, string groupName, string labServerGuid, string clientGuid, DateTime start, DateTime end) { string lsGuid = null; int status = -1; string message = null; if (ProcessAgentDB.ServiceAgent != null && ProcessAgentDB.ServiceAgent.domainGuid != null) { ProcessAgentDB paDb = new ProcessAgentDB(); ProcessAgentInfo domainServer = paDb.GetProcessAgentInfo(ProcessAgentDB.ServiceAgent.domainGuid); InteractiveSBProxy isbProxy = new InteractiveSBProxy(); isbProxy.AgentAuthHeaderValue = new AgentAuthHeader(); isbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; isbProxy.AgentAuthHeaderValue.coupon = domainServer.identOut; isbProxy.Url = domainServer.ServiceUrl; string[] types = new string[] { TicketTypes.SCHEDULE_SESSION }; Coupon opCoupon = isbProxy.RequestAuthorization(types, 600, userName, groupName, labServerGuid, clientGuid); if (opCoupon != null) { TicketIssuerProxy ticketProxy = new TicketIssuerProxy(); ticketProxy.AgentAuthHeaderValue = new AgentAuthHeader(); ticketProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; ticketProxy.AgentAuthHeaderValue.coupon = domainServer.identOut; ticketProxy.Url = domainServer.ServiceUrl; //the method call below is one which does not returns a null value //in otherwards the ticket value is not created. Ticket ticketSMS = ticketProxy.RedeemTicket(opCoupon, TicketTypes.SCHEDULE_SESSION, ProcessAgentDB.ServiceGuid); if (ticketSMS != null) { if (ticketSMS.payload != null || ticketSMS.payload.Length > 0) { XmlQueryDoc xdoc = new XmlQueryDoc(ticketSMS.payload); string ussURL = xdoc.Query("ScheduleSessionPayload/ussURL"); UserSchedulingProxy ussProxy = new UserSchedulingProxy(); ussProxy.OperationAuthHeaderValue = new OperationAuthHeader(); ussProxy.OperationAuthHeaderValue.coupon = opCoupon; ussProxy.Url = ussURL; TimePeriod[] times = ussProxy.RetrieveAvailableTimePeriods(ProcessAgentDB.ServiceAgent.domainGuid, groupName, labServerGuid, clientGuid, start, end); // Logic to check for final time DateTime resStart = start; DateTime resEnd = end; message = ussProxy.AddReservation(ProcessAgentDB.ServiceAgent.domainGuid, userName, groupName, labServerGuid, clientGuid, resStart, resEnd); } } } else { message = "coupon is null"; } } else { message = "This service is not part of a domain, please contact the administrator!"; } return message; }
// Provider Registration methods - issued by the provider public static string RegisterClientServices(int sbId, Coupon lssCoupon, int lssId, Coupon lsCoupon, int lsId, Coupon clientCoupon, int clientId) { bool error = false; StringBuilder message = new StringBuilder(); string lsDescriptor = null; string lssDescriptor = null; string clientDescriptor = null; ProcessAgentInfo remoteSB; ProcessAgentDB db = new ProcessAgentDB(); ResourceDescriptorFactory factory = ResourceDescriptorFactory.Instance(); try { // Check for enough information to perform the register lsDescriptor = factory.CreateProcessAgentDescriptor(lsId); if(lssId > 0) lssDescriptor = factory.CreateProcessAgentDescriptor(lssId); clientDescriptor = factory.CreateClientDescriptor(clientId); // What tickets do we need, create them string guid = Utilities.MakeGuid(); ServiceDescription[] values = null; if (lssDescriptor != null) { // Order is important values = new ServiceDescription[3]; values[0] = new ServiceDescription(lssDescriptor, lssCoupon, null); values[1] = new ServiceDescription(lsDescriptor, lsCoupon, null); values[2] = new ServiceDescription(clientDescriptor, clientCoupon, null); } else { values = new ServiceDescription[2]; values[0] = new ServiceDescription(lsDescriptor, lsCoupon, null); values[1] = new ServiceDescription(clientDescriptor, clientCoupon, null); } // get the remote sb Proxy remoteSB = db.GetProcessAgentInfo(sbId); if (remoteSB == null || remoteSB.retired) { throw new Exception("The remote service broker is not registered or is retired"); } ProcessAgentProxy sbProxy = new ProcessAgentProxy(); sbProxy.Url = remoteSB.webServiceUrl; sbProxy.AgentAuthHeaderValue = new AgentAuthHeader(); sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut; sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; sbProxy.Register(guid, values); message.AppendLine("RegisterClientServices: " + remoteSB.webServiceUrl + " \t" + guid + " \t" + "success"); } catch (Exception ex) { Utilities.WriteLog("Error in cross-Register: " + ex.Message); message.AppendLine("Error in cross-Register: " + ex.Message); //throw; } return message.ToString(); }
public static string RegisterGroupCredentials(int sbId) { StringBuilder message = new StringBuilder(); ProcessAgentInfo remoteSB = null; ProcessAgentDB db = new ProcessAgentDB(); ResourceDescriptorFactory factory = ResourceDescriptorFactory.Instance(); string guid = Utilities.MakeGuid(); ServiceDescription[] values = null; // get the remote sb Proxy remoteSB = db.GetProcessAgentInfo(sbId); if (remoteSB == null || remoteSB.retired) { throw new Exception("The remote service broker is not registered or is retired"); } ProcessAgentProxy sbProxy = new ProcessAgentProxy(); sbProxy.Url = remoteSB.webServiceUrl; sbProxy.AgentAuthHeaderValue = new AgentAuthHeader(); sbProxy.AgentAuthHeaderValue.coupon = remoteSB.identOut; sbProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid; sbProxy.Register(guid, values); message.AppendLine("RegisterGroupCredentials: " + remoteSB.webServiceUrl + " \t" + guid + " \t" + "success"); return message.ToString(); }
public static ProcessAgentInfo[] GetLabServersForClient(int clientID) { List<ProcessAgentInfo> servers = null; DbConnection myConnection = FactoryDB.GetConnection(); DbCommand myCommand = FactoryDB.CreateCommand("LabServerClient_RetrieveServerIDs", myConnection); myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(FactoryDB.CreateParameter( "@labClientID", clientID, DbType.Int32)); DbDataReader reader = null; try { myConnection.Open(); reader = myCommand.ExecuteReader(); if (reader != null && reader.HasRows) { servers = new List<ProcessAgentInfo>(); ProcessAgentDB paDB = new ProcessAgentDB(); while (reader.Read()) { int serverID = reader.GetInt32(0); ProcessAgentInfo pai = paDB.GetProcessAgentInfo(serverID); if (pai != null && !pai.retired) { servers.Add(pai); } } } } catch(Exception ex) { throw new Exception("Exception thrown in getLabServersForClient: " + ex.Message, ex); } finally { myConnection.Close(); } if (servers != null) return servers.ToArray(); else return null; }
public static ExperimentSummary RetrieveExperimentSummary(long experimentID) { ExperimentSummary summary = InternalDataDB.SelectExperimentSummary(experimentID); if (summary.HasEss && ((summary.status | StorageStatus.CLOSED) == 0)) { ProcessAgentDB ticketing = new ProcessAgentDB(); // Retrieve the ESS Status info and update as needed //This uses a generic ReadRecords ticket created for the ESS ProcessAgentInfo ess = ticketing.GetProcessAgentInfo(summary.essGuid); if ((ess != null) && !ess.retired) { ExperimentStorageProxy essProxy = new ExperimentStorageProxy(); essProxy.Url = ess.webServiceUrl; essProxy.OperationAuthHeaderValue = new OperationAuthHeader(); essProxy.OperationAuthHeaderValue.coupon = ess.identOut; StorageStatus status = essProxy.GetExperimentStatus(experimentID); bool needsUpdate = false; if (status != null) { if (summary.closeTime != status.closeTime) { summary.closeTime = status.closeTime; needsUpdate = true; } if (summary.recordCount != status.recordCount) { summary.recordCount = status.recordCount; needsUpdate = true; } if (summary.status != status.status) { summary.status = status.status; needsUpdate = true; } } if (needsUpdate) { InternalDataDB.UpdateExperimentStatus(status); } } } return summary; }
/// <summary> /// This only registers the ProviderInfo systemSupport block(s) /// </summary> /// <param name="registerGuid"></param> /// <param name="info"></param> protected virtual void register(string registerGuid, ServiceDescription[] info) { StringBuilder message = new StringBuilder(); ProcessAgentDB dbTicketing = new ProcessAgentDB(); message.AppendLine("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; } if (sd.serviceProviderInfo != null && sd.serviceProviderInfo.Length > 0) { 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); } } } } } } } } } }