public int[] AddAttributes(long experimentId, int sequenceNum, RecordAttribute[] attributes) { int[] attributeIDs = new int[attributes.Length]; Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId, opHeader.coupon.passkey); try { Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.STORE_RECORDS); attributeIDs = experimentsAPI.AddAttributes(experimentId, retrievedTicket.issuerGuid, sequenceNum, attributes); return attributeIDs; } catch { throw; } }
/// <summary> /// Adds the specified RecordAttributes to an ExperimentRecord /// </summary> /// <param name="experimentId">the ID of the Experiment whose ExperimentRecord is to receive the new attributes</param> /// <param name="sequenceNum">the sequence number of the ExperimentRecord to receive the new attributes</param> /// <param name="attributes">the attributes to be added</param> /// <returns>an array of the IDs of the newly added attributes</returns> public int[] AddAttributes(long experimentId, string sbGuid, int sequenceNum, RecordAttribute[] attributes) { DbConnection myConnection = FactoryDB.GetConnection(); DbCommand myCommand = FactoryDB.CreateCommand("AddRecordAttribute", myConnection); myCommand.CommandType = CommandType.StoredProcedure; int[] attIDs = new int[attributes.Length]; try { myConnection.Open(); if (attributes != null) { myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@experimentId", experimentId, DbType.Int64)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@issuerGuid", sbGuid, DbType.AnsiString,50)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@sequenceNo", sequenceNum, DbType.Int32)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeName", null,DbType.AnsiString)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeValue", null, DbType.AnsiString)); int i = 0; foreach (RecordAttribute a in attributes) { myCommand.Parameters["@attributeName"].Value = a.name; myCommand.Parameters["@attributeValue"].Value = a.value; attIDs[i] = Convert.ToInt32(myCommand.ExecuteScalar()); i = i + 1; } } return attIDs; } catch { throw; } finally { myConnection.Close(); } }
public int AddRecord(long experimentId,string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes) { int seqNo = -1; Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId, opHeader.coupon.passkey); try { Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.STORE_RECORDS); seqNo = experimentsAPI.AddRecord(experimentId, retrievedTicket.issuerGuid, submitter, type, xmlSearchable, contents, attributes); return seqNo; } catch (Exception ex) { Utilities.WriteLog("AddRecord: " + ex.Message); throw; } }
/// <summary> /// Saves the record on the experiment's ESS /// </summary> /// <param name="experimentID"></param> /// <param name="submitter"></param> /// <param name="type"></param> /// <param name="contents"></param> /// <param name="xmlSearchable"></param> /// <param name="attributes"></param> /// <returns>experiment Sequence number or -1 if the record may not be saved</returns> public static int SaveExperimentRecord(long experimentID, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes) { int seqNum = -1; ExperimentStorageProxy essProxy = GetEssProxy(experimentID); if (essProxy != null) { seqNum = essProxy.AddRecord(experimentID, submitter, type, xmlSearchable, contents, attributes); } return seqNum; }
/// <summary> /// Authenticates users permissions to save a record and forwards the request to the ESS /// </summary> /// <param name="loginUserID"></param> /// <param name="sessionGroupID"></param> /// <param name="experimentID"></param> /// <param name="submitter"></param> /// <param name="recordType"></param> /// <param name="contents"></param> /// <param name="xmlSearchable"></param> /// <param name="attributes"></param> public void SaveExperimentRecordWrapper(int loginUserID, int sessionGroupID, long experimentID, string submitter, string recordType, bool xmlSearchable, string contents, RecordAttribute[] attributes) { //int loginUserID = Convert.ToInt32(Session["UserID"]); //int sessionGroupID = Convert.ToInt32(Session["GroupID"]); //string sessionGroupName = Session["GroupName"].ToString(); int userID = InternalDataDB.SelectExperimentOwner (experimentID); int effectiveGroupID = InternalDataDB.SelectExperimentGroup(experimentID); bool haveAccess = false; //superUser or owner check if(IsSuperuserGroup(sessionGroupID) ||(loginUserID==userID)) { haveAccess = true; } else { //writeExperiment check // get qualifier ID of experimentID int qualifierID = Authorization.AuthorizationAPI .GetQualifierID ((int) experimentID, Qualifier .experimentQualifierTypeID ); if (Authorization.AuthorizationAPI .CheckAuthorization (loginUserID, Function .writeExperimentFunctionType , qualifierID)) { haveAccess = true; } } if (haveAccess) { DataStorage.DataStorageAPI.SaveExperimentRecord(experimentID, submitter, recordType, xmlSearchable, contents, attributes); } else { throw new AccessDeniedException ("Access denied saving experimentSpecification."); } }
public static int SaveExperimentRecord(long experimentID, string submitter, string recordType, bool xmlSearchable, string contents, RecordAttribute[] attributes) { return InternalDataDB.SaveExperimentRecord(experimentID, submitter, recordType, xmlSearchable, contents, attributes); }
//, recordCreatorName /// <summary> /// Adds a new ExperimentRecord to a pre-existing Experiment object /// </summary> /// <param name="experimentId">the ID of the Experiment to receive the new ExperimentRecord</param> /// <param name="type">a string that designates the type of record</param> /// <param name="xmlSearchable">true if the contents field can be searched to find attributes to match Criterion conditions</param> /// <param name="contents">the payload of the record</param> /// <param name="attributes">an array of attributes/values pairs to be attached to the record for search purposes</param> /// <returns>the sequence number of the newly added ExperimentRecord</returns> public int AddRecord(long experimentId, string sbGuid, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes) { DbConnection myConnection = FactoryDB.GetConnection(); DbCommand myCommand = FactoryDB.CreateCommand("AddExperimentRecord", myConnection); DbTransaction tran = null; myCommand.CommandType = CommandType.StoredProcedure; ////Get the Service Broker record from the database //ProcessAgentInfo[] paInfo = dbTicketing.GetProcessAgentInfos(ProcessAgentType.SERVICE_BROKER); ////Get the Service Broker name - This is the sponsor of the "ADMINISTER EXPERIMENT" ticket //string sponsorGuid = paInfo[0].agentGuid; //myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@sponsorGuid", sponsorGuid)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@experimentId", experimentId, DbType.Int64)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@issuerGuid", sbGuid, DbType.AnsiString,50)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@submitter", submitter, DbType.String,256)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@type", type, DbType.AnsiString,100)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@xmlSearchable", xmlSearchable, DbType.Boolean)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@contents", contents, DbType.String)); //NOTE: TEMPORARY PARAMETER //myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@submitterName", "Service Broker")); //myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@submitterName", recordCreatorName)); try { myConnection.Open(); tran = myConnection.BeginTransaction(); myCommand.Transaction = tran; int sequenceNo = Convert.ToInt32(myCommand.ExecuteScalar()); if (sequenceNo == -1) return -1; if (attributes != null) { myCommand.Parameters.Clear(); myCommand.CommandText = "AddRecordAttribute"; myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@experimentId", experimentId, DbType.Int64)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@issuerGuid", sbGuid, DbType.AnsiString,50)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@sequenceNo", sequenceNo, DbType.Int32)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeName", null, DbType.String,256)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeValue", null, DbType.String,256)); foreach (RecordAttribute a in attributes) { myCommand.Parameters["@attributeName"].Value = a.name; myCommand.Parameters["@attributeValue"].Value = a.value; myCommand.ExecuteNonQuery(); } } tran.Commit(); return sequenceNo; } catch { try { tran.Rollback(); } catch { throw; } throw; } finally { myConnection.Close(); } }
/// <summary> /// Retrieves the IDs of the specified RecordAttributes of an ExperimentRecord /// </summary> /// <param name="experimentId">the ID of the Experiment containing the ExperimentRecord whose attributes are to be retrieved</param> /// <param name="sequenceNum">the sequence number of the ExperimentRecord whose attributes are to be retrieved</param> /// <param name="attributeName">the name of the attributes to be retrieved (a record may possess multiple attributes with the same name)</param> /// <returns>an array of the IDs of the requested RecordAttributes</returns> public RecordAttribute[] GetRecordAttributes(long experimentId, string sbGuid, int sequenceNum, string attributeName) { DbConnection myConnection = FactoryDB.GetConnection(); DbCommand myCommand = FactoryDB.CreateCommand("RetrieveRecordAttributeByName", myConnection); myCommand.CommandType = CommandType.StoredProcedure; ArrayList attList = new ArrayList(); try { myConnection.Open(); if (attributeName != null) { myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@experimentId", experimentId, DbType.Int32)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@issuerGuid", sbGuid, DbType.AnsiString,50)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@sequenceNo", sequenceNum, DbType.Int32)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand, "@attributeName", attributeName, DbType.String,256)); DbDataReader myReader = myCommand.ExecuteReader(); while (myReader.Read()) { RecordAttribute att = new RecordAttribute(); // if(myReader["attribute_name"] != System.DBNull.Value ) // att.name = (string) myReader["attribute_name"]; att.name = attributeName; if (myReader["attribute_value"] != System.DBNull.Value) att.value = (string)myReader["attribute_value"]; attList.Add(att); } myReader.Close(); } RecordAttribute[] attributes = new RecordAttribute[attList.Count]; int[] attributeIDs = new int[attList.Count]; for (int i = 0; i < attList.Count; i++) { attributes[i] = (RecordAttribute)attList[i]; } return attributes; } catch { throw; } finally { myConnection.Close(); } }
/// <remarks/> public void AddAttributesAsync(long experimentId, int sequenceNum, RecordAttribute[] attributes) { this.AddAttributesAsync(experimentId, sequenceNum, attributes, null); }
/// <remarks/> public System.IAsyncResult BeginAddRecord(long experimentId, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("AddRecord", new object[] { experimentId, submitter, type, xmlSearchable, contents, attributes}, callback, asyncState); }
/// <remarks/> public System.IAsyncResult BeginAddAttributes(long experimentId, int sequenceNum, RecordAttribute[] attributes, System.AsyncCallback callback, object asyncState) { return this.BeginInvoke("AddAttributes", new object[] { experimentId, sequenceNum, attributes}, callback, asyncState); }
/// <remarks/> public void AddRecordAsync(long experimentId, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes, object userState) { if ((this.AddRecordOperationCompleted == null)) { this.AddRecordOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddRecordOperationCompleted); } this.InvokeAsync("AddRecord", new object[] { experimentId, submitter, type, xmlSearchable, contents, attributes}, this.AddRecordOperationCompleted, userState); }
/// <remarks/> public void AddRecordAsync(long experimentId, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes) { this.AddRecordAsync(experimentId, submitter, type, xmlSearchable, contents, attributes, null); }
public int AddRecord(long experimentId, string submitter, string type, bool xmlSearchable, string contents, RecordAttribute[] attributes) { object[] results = this.Invoke("AddRecord", new object[] { experimentId, submitter, type, xmlSearchable, contents, attributes}); return ((int)(results[0])); }
/// <remarks/> public void AddAttributesAsync(long experimentId, int sequenceNum, RecordAttribute[] attributes, object userState) { if ((this.AddAttributesOperationCompleted == null)) { this.AddAttributesOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddAttributesOperationCompleted); } this.InvokeAsync("AddAttributes", new object[] { experimentId, sequenceNum, attributes}, this.AddAttributesOperationCompleted, userState); }
/// <summary> /// Retrieves the specified RecordAttributes of an ExperimentRecord /// </summary> /// <param name="experimentId">the ID of the Experiment containing the ExperimentRecord whose attributes are to be retrieved</param> /// <param name="sequenceNum">the sequence number of the ExperimentRecord whose attributes are to be retrieved</param> /// <param name="attributeIDs">the IDs of the attributes to be retrieved; null gets all RecordAttributes</param> /// <returns>an array of the requested RecordAttributes</returns> public RecordAttribute[] GetRecordAttributes(long experimentId, string sbGuid, int sequenceNum, int[] attributeIDs) { DbConnection myConnection = FactoryDB.GetConnection(); DbCommand myCommand = FactoryDB.CreateCommand("RetrieveRecordAttributeByID", myConnection); myCommand.CommandType = CommandType.StoredProcedure; RecordAttribute[] attributes = new RecordAttribute[attributeIDs.Length]; try { myConnection.Open(); if (attributes != null) { myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@experimentId", experimentId, DbType.Int64)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@issuerGuid", sbGuid, DbType.AnsiString,50)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@sequenceNo", sequenceNum, DbType.Int32)); myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeID", null, DbType.Int32)); for (int i = 0; i < attributeIDs.Length; i++) { myCommand.Parameters["@attributeID"].Value = attributeIDs[i]; DbDataReader myReader = myCommand.ExecuteReader(); RecordAttribute att = new RecordAttribute(); while (myReader.Read()) { if (myReader["attribute_name"] != System.DBNull.Value) att.name = (string)myReader["attribute_name"]; if (myReader["attribute_value"] != System.DBNull.Value) att.value = (string)myReader["attribute_value"]; } attributes[i] = att; myReader.Close(); } } return attributes; } catch { throw; } finally { myConnection.Close(); } }
public RecordAttribute[] GetRecordAttributes(long experimentId, int sequenceNum, int[] attributeIds) { RecordAttribute[] recordAttributes = new RecordAttribute[attributeIds.Length]; Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId, opHeader.coupon.passkey); string ticketType = TicketTypes.RETRIEVE_RECORDS; try { Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, ticketType); recordAttributes = experimentsAPI.GetRecordAttributes(experimentId, retrievedTicket.issuerGuid, sequenceNum, attributeIds); return recordAttributes; } catch { throw; } }
public int[] AddAttributes(long experimentId, int sequenceNum, RecordAttribute[] attributes) { object[] results = this.Invoke("AddAttributes", new object[] { experimentId, sequenceNum, attributes}); return ((int[])(results[0])); }