Example #1
0
        public ExperimentRecord GetRecord(long experimentId, int sequenceNum)
        {
            ExperimentRecord expRecord = new ExperimentRecord();

            Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId,
                 opHeader.coupon.passkey);

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);
                expRecord = experimentsAPI.GetRecord(experimentId, retrievedTicket.issuerGuid, sequenceNum);

                return expRecord;
            }

            catch (Exception ex)
            {
                Utilities.WriteLog("GetRecord: " + ex.Message);
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// Retrieves an experiment's ResultReport from the ESS
        /// </summary>
        /// <param name="experimentID"></param>
        /// <param name="roles"></param>
        /// <returns>THe ResultStatus or an empty report with status set, when the experiment has not terminated that have not</returns>
        public static ResultReport GetResultReport(int experimentID)
        {
            ResultReport report = null;
            BrokerDB brokerDB = new BrokerDB();
            try
            {
                ExperimentAdminInfo expInfo = InternalDataDB.SelectExperimentAdminInfo(experimentID);
                if (expInfo == null || expInfo.experimentID <= 0)
                {
                    //experiment does not exist
                    throw new SoapException("Invalid experiment ID. ", SoapException.ServerFaultCode);
                }
                else
                {
                    ProcessAgentInfo ess = brokerDB.GetProcessAgentInfo(expInfo.essID);
                    if(ess.retired){
                        throw new Exception("The requested ESS has been retired");
                    }
                    ExperimentStorageProxy essProxy = new ExperimentStorageProxy();
                    essProxy.AgentAuthHeaderValue = new AgentAuthHeader();
                    essProxy.AgentAuthHeaderValue.agentGuid = ProcessAgentDB.ServiceGuid;
                    essProxy.AgentAuthHeaderValue.coupon = ess.identOut;
                    essProxy.Url = ess.webServiceUrl;

                    Coupon opCoupon = brokerDB.GetEssOpCoupon(expInfo.experimentID, TicketTypes.RETRIEVE_RECORDS, 60, ess.agentGuid);
                    OperationAuthHeader opHeader = new OperationAuthHeader();
                    opHeader.coupon = opCoupon;
                    essProxy.OperationAuthHeaderValue = opHeader;
                    if ((expInfo.status & StorageStatus.CLOSED) == 0)
                    {
                        ProcessAgentInfo lsInfo = brokerDB.GetProcessAgentInfo(expInfo.agentID);
                        if (lsInfo != null)
                        {
                            if(lsInfo.retired){
                                throw new Exception("The requested batch LabServer has ben retired.");
                            }
                            BatchLSProxy batchLS_Proxy = new BatchLSProxy();
                            batchLS_Proxy.AuthHeaderValue = new AuthHeader();
                            batchLS_Proxy.AuthHeaderValue.identifier = ProcessAgentDB.ServiceGuid;
                            batchLS_Proxy.AuthHeaderValue.passKey = lsInfo.identOut.passkey;
                            batchLS_Proxy.Url = lsInfo.webServiceUrl;
                            // retrieve resultReport from labServer

                            LabExperimentStatus expStatus = batchLS_Proxy.GetExperimentStatus(experimentID);
                            if (expStatus != null)
                            {
                                if ((expStatus.statusReport.statusCode >= 3) && (expStatus.statusReport.statusCode != 6))
                                {
                                    report = batchLS_Proxy.RetrieveResult(experimentID);
                                        if (report != null)
                                        {
                                            ExperimentRecord theRecord = null;
                                            List<ExperimentRecord> recordList = new List<ExperimentRecord>();
                                            if (report.experimentResults != null && report.experimentResults.Length > 0)
                                            {
                                                theRecord = new ExperimentRecord();
                                                theRecord.submitter = lsInfo.agentGuid;
                                                theRecord.type = BatchRecordType.RESULT;
                                                theRecord.contents = report.experimentResults;
                                                theRecord.xmlSearchable = false;
                                                recordList.Add(theRecord);
                                            }
                                            if (report.errorMessage != null && report.errorMessage.Length > 0)
                                            {
                                                theRecord = new ExperimentRecord();
                                                theRecord.submitter = lsInfo.agentGuid;
                                                theRecord.type = BatchRecordType.EXECUTION_ERROR;
                                                theRecord.contents = report.errorMessage;
                                                theRecord.xmlSearchable = false;
                                                recordList.Add(theRecord);
                                            }
                                            if (report.warningMessages != null && report.warningMessages.Length > 0)
                                            {
                                                foreach (string s in report.warningMessages)
                                                {
                                                    if (s.Length > 0)
                                                    {
                                                        theRecord = new ExperimentRecord();
                                                        theRecord.submitter = lsInfo.agentGuid;
                                                        theRecord.type = BatchRecordType.EXECUTION_WARNING;
                                                        theRecord.contents = s;
                                                        theRecord.xmlSearchable = false;
                                                        recordList.Add(theRecord);
                                                    }
                                                }
                                            }
                                            if (report.xmlResultExtension != null && report.xmlResultExtension.Length > 0)
                                            {
                                                theRecord = new ExperimentRecord();
                                                theRecord.submitter = lsInfo.agentGuid;
                                                theRecord.type = BatchRecordType.RESULT_EXTENSION;
                                                theRecord.contents = report.xmlResultExtension;
                                                theRecord.xmlSearchable = true;
                                                recordList.Add(theRecord);
                                            }
                                            if (report.xmlBlobExtension != null && report.xmlBlobExtension.Length > 0)
                                            {
                                                theRecord = new ExperimentRecord();
                                                theRecord.submitter = lsInfo.agentGuid;
                                                theRecord.type = BatchRecordType.BLOB_EXTENSION;
                                                theRecord.contents = report.xmlBlobExtension;
                                                theRecord.xmlSearchable = true;
                                                recordList.Add(theRecord);
                                            }
                                            if (recordList.Count > 0)
                                            {
                                                essProxy.AddRecords(experimentID, recordList.ToArray());
                                            }
                                            StorageStatus sStatus = essProxy.SetExperimentStatus(experimentID, report.statusCode | StorageStatus.CLOSED);
                                            DataStorageAPI.UpdateExperimentStatus(sStatus);
                                        }
                                    }
                                }

                        }
                    }
                    else
                    {
                        report = new ResultReport();
                        ExperimentRecord[] records = essProxy.GetRecords(experimentID, null);
                        if (records != null)
                        {
                            List<String> execWarnings = new List<String>();
                            foreach (ExperimentRecord rec in records)
                            {
                                if (rec.type.CompareTo(BatchRecordType.EXECUTION_ERROR) == 0)
                                {
                                    report.errorMessage = rec.contents;
                                }

                                else if (rec.type.CompareTo(BatchRecordType.BLOB_EXTENSION) == 0)
                                {
                                    report.xmlBlobExtension = rec.contents;
                                }
                                else if (rec.type.CompareTo(BatchRecordType.RESULT_EXTENSION) == 0)
                                {
                                    report.xmlResultExtension = rec.contents;
                                }
                                else if (rec.type.CompareTo(BatchRecordType.EXECUTION_WARNING) == 0)
                                {
                                    execWarnings.Add(rec.contents);
                                }
                                else if (rec.type.CompareTo(BatchRecordType.RESULT) == 0)
                                {
                                    report.experimentResults = rec.contents;
                                }

                            }
                            if (execWarnings.Count > 0)
                            {
                                report.warningMessages = execWarnings.ToArray();
                            }
                        }
                        report.statusCode = expInfo.status & StorageStatus.BATCH_MASK;
                    }
                }
            }
            catch (Exception ex)
            {
                throw new SoapException(ex.Message + ". " + ex.GetBaseException(), SoapException.ServerFaultCode, ex);
            }
            return report;
        }
Example #3
0
        public int AddRecords(long experimentId, ExperimentRecord[] records)
        {
            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);
                foreach (ExperimentRecord rec in records)
                {
                    seqNo = experimentsAPI.AddRecord(experimentId, retrievedTicket.issuerGuid, rec.submitter, rec.type,
                        rec.xmlSearchable, rec.contents, null);
                }

                return seqNo;
            }

            catch (Exception ex)
            {
                Utilities.WriteLog("AddRecord: " + ex.Message);
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Returns the specified ExperimentRecord
        /// </summary>
        /// <param name="experimentId">the ID of the Experiment whose record is to be retrieved</param>
        /// <param name="sequenceNum">the sequence number of the record to be retrieved</param>
        /// <returns>the specified ExperimentRecord</returns>
        public ExperimentRecord GetRecord(long experimentId, string sbGuid, int sequenceNum)
        {
            ExperimentRecord expRecord = new ExperimentRecord();

            DbConnection myConnection = FactoryDB.GetConnection();
            DbCommand myCommand = FactoryDB.CreateCommand("RetrieveExperimentRecord", myConnection);
            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", sequenceNum, DbType.Int32));

            try
            {
                myConnection.Open();

                // get experiment record information from table experiment_records
                DbDataReader myReader = myCommand.ExecuteReader();

                while (myReader.Read())
                {
                    if (myReader["record_type"] != System.DBNull.Value)
                        expRecord.type = (string)myReader["record_type"];

                    //Note: Temporary parameter
                    //if(myReader["sponsor_GUID"] != System.DBNull.Value )
                    //	expRecord.sponsorGuid = (string) myReader["sponsor_GUID"];

                    if (myReader["submitter"] != System.DBNull.Value)
                        expRecord.submitter = (string)myReader["submitter"];

                    //if (myReader["submitter_name"] != System.DBNull.Value)
                    //    expRecord.  submitterName = (string)myReader["submitter_name"];

                    if (myReader["contents"] != System.DBNull.Value)
                        expRecord.contents = (string)myReader["contents"];

                    if (myReader["time_stamp"] != System.DBNull.Value)
                        expRecord.timestamp = DateUtil.SpecifyUTC((DateTime)myReader["time_stamp"]);

                    if (myReader["is_xml_searchable"] != System.DBNull.Value)
                        expRecord.xmlSearchable = (bool)myReader["is_xml_searchable"];

                    if (myReader["sequence_no"] != System.DBNull.Value)
                        expRecord.sequenceNum = (int)myReader["sequence_no"];
                }

                myReader.Close();

            }
            catch
            {
                throw;
            }
            finally
            {
                myConnection.Close();
            }

            return expRecord;
        }
 protected StringBuilder processRecords(ExperimentRecord[] records, string indices)
 {
     bool useIndex = false;
     StringBuilder buf = new StringBuilder();
     int[] indexes = null;
     char[] delim = ",".ToCharArray();
     if (indices != null && indices.Length > 0)
     {
         useIndex = true;
         string[] idxStr = indices.Split(delim);
         List<int> idx = new List<int>();
         foreach (string s in idxStr)
         {
             idx.Add(Convert.ToInt32(s));
         }
         idx.Sort();
         indexes = idx.ToArray();
     }
     if (records.Length > 0)
     {
         foreach (ExperimentRecord rec in records)
         {
             buf.Append(rec.sequenceNum.ToString());
             if (useIndex)
             {
                 string[] values = null;
                 values = rec.contents.Split(delim);
                 buf.Append("," + values[0]);
                 for (int i = 0; i < indexes.Length; i++)
                 {
                     // May need an offset
                     buf.Append("," + values[indexes[i]]);
                 }
                 buf.AppendLine();
             }
             else
             {
                 buf.AppendLine("," + rec.contents);
             }
         }
     }
     return buf;
 }
Example #6
0
        /// <summary>
        /// Returns the specified ExperimentRecord sequence numbers
        /// </summary>
        /// <param name="experimentId">the ID of the Experiment whose record is to be retrieved</param>
        /// <param name="sequenceNum">the sequence number of the record to be retrieved</param>
        /// <returns>the specified ExperimentRecord</returns>
        public ExperimentRecord[] GetRecords(long experimentId, string sbGuid, Criterion[] criteria)
        {
            List<ExperimentRecord> records = new List<ExperimentRecord>();
            ExperimentRecord expRecord = null;
            if (criteria != null && criteria.Length > 0)
            {
                bool hasFields = false;
                bool hasAttributes = false;
                StringBuilder sql = new StringBuilder();
                StringBuilder attributes = new StringBuilder();

                for (int i = 0; i < criteria.Length; i++)
                {
                    switch (criteria[i].attribute.ToLower())
                    {
                        //these criterion are based on fields.
                        case "record_type":
                        case "contents":
                        case "submitter_name":
                            if (hasFields)
                                sql.Append(" AND ");
                            sql.Append(criteria[i].ToSQL());
                            hasFields = true;
                            break;
                        default: // it's an attribute
                            if (hasAttributes)
                                attributes.Append(" AND ");
                            attributes.Append("(attribute_name = '" + criteria[i].attribute + "' ");
                            attributes.Append(" AND attribute_value ");
                            attributes.Append(criteria[i].predicate);
                            attributes.Append(" '" + criteria[i].value + "')");
                            hasAttributes = true;
                            break;
                    }
                }
                DbConnection myConnection = FactoryDB.GetConnection();
                DbCommand myCommand = FactoryDB.CreateCommand("RetrieveExperimentRecordsCriteria", myConnection);
                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));
                if (hasFields)
                    myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@fieldQuery", sql.ToString(), DbType.AnsiString,2000));
                else
                    myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@fieldQuery", null, DbType.AnsiString,2000));
                if (hasAttributes)
                    myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeQuery", attributes.ToString(), DbType.AnsiString,2000));
                else
                    myCommand.Parameters.Add(FactoryDB.CreateParameter(myCommand,"@attributeQuery", null, DbType.AnsiString,2000));
                try
                {
                    myConnection.Open();

                    // get experiment record information from table experiment_records
                    DbDataReader myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        expRecord = new ExperimentRecord();
                        if (myReader["record_type"] != System.DBNull.Value)
                            expRecord.type = (string)myReader["record_type"];

                        if (myReader["submitter_Name"] != System.DBNull.Value)
                            expRecord.submitter = (string)myReader["submitter_Name"];

                        if (myReader["contents"] != System.DBNull.Value)
                            expRecord.contents = (string)myReader["contents"];

                        if (myReader["time_stamp"] != System.DBNull.Value)
                            expRecord.timestamp = DateUtil.SpecifyUTC((DateTime)myReader["time_stamp"]);

                        if (myReader["is_xml_searchable"] != System.DBNull.Value)
                            expRecord.xmlSearchable = (bool)myReader["is_xml_searchable"];

                        if (myReader["sequence_no"] != System.DBNull.Value)
                            expRecord.sequenceNum = (int)myReader["sequence_no"];
                        records.Add(expRecord);
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    myConnection.Close();
                }
            }
            else
            { // get all the sequence numbers
                DbConnection myConnection = FactoryDB.GetConnection();
                DbCommand myCommand = FactoryDB.CreateCommand("RetrieveExperimentRecords", myConnection);
                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));

                try
                {
                    myConnection.Open();

                    // get experiment record information from table experiment_records
                    DbDataReader myReader = myCommand.ExecuteReader();

                    while (myReader.Read())
                    {
                        expRecord = new ExperimentRecord();

                        if (myReader["sequence_no"] != System.DBNull.Value)
                            expRecord.sequenceNum = (int)myReader["sequence_no"];

                        if (myReader["record_type"] != System.DBNull.Value)
                            expRecord.type = (string)myReader["record_type"];

                        if (myReader["submitter_Name"] != System.DBNull.Value)
                            expRecord.submitter = (string)myReader["submitter_Name"];

                        if (myReader["contents"] != System.DBNull.Value)
                            expRecord.contents = (string)myReader["contents"];

                        if (myReader["time_stamp"] != System.DBNull.Value)
                            expRecord.timestamp = DateUtil.SpecifyUTC((DateTime)myReader["time_stamp"]);

                        if (myReader["is_xml_searchable"] != System.DBNull.Value)
                            expRecord.xmlSearchable = (bool)myReader["is_xml_searchable"];

                        records.Add(expRecord);
                    }

                    myReader.Close();

                }
                catch
                {
                    throw;
                }
                finally
                {
                    myConnection.Close();
                }
            }
            return records.ToArray(); ;
        }
Example #7
0
        /// <summary>
        /// Returns the specified Experiment including the array of associated ExperimentRecords
        /// </summary>
        /// <param name="experimentId">the ID of the Experiment to be retrieved</param>
        /// <returns>the specified Experiment</returns>
        public Experiment GetExperiment(long experimentId, string sbGuid)
        {
            Experiment exp = new Experiment();
            exp.experimentId = experimentId;
            int recordCt = 0;

            DbConnection myConnection = FactoryDB.GetConnection();
            DbCommand myCommand = FactoryDB.CreateCommand("RetrieveExperiment", myConnection);
            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));
            try
            {
                myConnection.Open();

                // get experiment record information from table experiments
                DbDataReader myReader = myCommand.ExecuteReader();

                int count = 0;

                while (myReader.Read())
                {
                    count++;
                    //if (myReader["creator_name"] != System.DBNull.Value)
                    //    exp.creatorName = (string)myReader["creator_name"];

                    if (myReader["Issuer_Guid"] != System.DBNull.Value)
                        exp.issuerGuid = (string)myReader["Issuer_Guid"];

                    if (myReader["current_sequence_no"] != System.DBNull.Value)
                        recordCt = Convert.ToInt32(myReader["current_sequence_no"]);
                }
                myReader.Close();

                if (count == 0)
                    return null;

                //Retrieve records for an experiment

                ExperimentRecord[] expRecs = new ExperimentRecord[recordCt];

                DbCommand myCommand2 = FactoryDB.CreateCommand("RetrieveRecordsForExperiment", myConnection);
                myCommand2.CommandType = CommandType.StoredProcedure;
                myCommand2.Parameters.Add(FactoryDB.CreateParameter(myCommand2,"@experimentId", experimentId, DbType.Int64));
                myCommand2.Parameters.Add(FactoryDB.CreateParameter(myCommand2,"@issuerGuid", sbGuid, DbType.AnsiString,50));
                DbDataReader myReader2 = myCommand2.ExecuteReader();

                int i = 0;
                //Not calling GetExperimentRecords as this is more efficient
                while (myReader2.Read())
                {
                    ExperimentRecord expRecord = new ExperimentRecord();

                    if (myReader2["sequence_no"] != System.DBNull.Value)
                        expRecord.sequenceNum = Convert.ToInt32(myReader2["sequence_no"]);

                    if (myReader2["record_type"] != System.DBNull.Value)
                        expRecord.type = (string)myReader2["record_type"];

                    if (myReader2["submitter_name"] != System.DBNull.Value)
                        expRecord.submitter = (string)myReader2["submitter_name"];

                    //if (myReader2["sponsor_GUID"] != System.DBNull.Value)
                    //   expRecord.sponsorGuid = (string)myReader2["sponsor_GUID"];

                    //if (myReader2["submitter_name"] != System.DBNull.Value)
                    //    expRecord.submitterName = (string)myReader2["submitter_name"];

                    if (myReader2["contents"] != System.DBNull.Value)
                        expRecord.contents = (string)myReader2["contents"];

                    if (myReader2["time_stamp"] != System.DBNull.Value)
                        expRecord.timestamp = DateUtil.SpecifyUTC((DateTime)myReader2["time_stamp"]);

                    if (myReader2["is_xml_searchable"] != System.DBNull.Value)
                        expRecord.xmlSearchable = (bool)myReader2["is_xml_searchable"];

                    if (recordCt > 0)
                        expRecs[i] = expRecord;
                    i++;
                }

                myReader2.Close();
                exp.records = expRecs;

            }
            catch
            {
                throw;
            }
            finally
            {
                myConnection.Close();
            }

            return exp;
        }
        protected void processRecords(ExperimentRecord[] records)
        {
            bool hasRecords = false;
            if (records != null && records.Length > 0)
            {
                StringBuilder buf = new StringBuilder();
                char[] delim = ",".ToCharArray();
                buf.AppendLine("<script type=\"text/javascript\">");
                buf.Append(" window.sampleData = [");
                //if (records.Length > 0)
                //{

                //int i = 1;
                DateTime epoc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                //for(int i =0; i < 100;i++){
                //    ExperimentRecord rec = records[i];
                DateTime tStamp = new DateTime();
                foreach (ExperimentRecord rec in records)
                {
                    if (hasRecords)
                    {
                        buf.AppendLine(",");
                    }
                    else
                    {
                        buf.AppendLine();
                        hasRecords = true;
                    }
                    //string content = rec.contents;
                    //string[] values = content.Split(delim, 3);
                    //buf.Append("[" + values[0] + "," + values[1] + "," + values[2] + "]");
                    buf.Append("[" + rec.contents + "]");
                }

                buf.AppendLine();
                buf.AppendLine("];");
                buf.AppendLine("</script>");
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "graphData", buf.ToString(), false);
            }
        }
        protected void processRecordsOrig(ExperimentRecord[] records)
        {
            bool hasRecords = false;
               StringBuilder buf = new StringBuilder();
            char[] delim = ",".ToCharArray();
            buf.AppendLine("<script type=\"text/javascript\">");
            buf.Append(" window.sampleData = [");
            if (records.Length > 0)
            {

                //int i = 1;
                DateTime epoc = new DateTime(1970,1,1,0,0,0,DateTimeKind.Utc);
                //for(int i =0; i < 100;i++){
                //    ExperimentRecord rec = records[i];
                foreach(ExperimentRecord rec in records){
                    string content = rec.contents;
                    string[] values = content.Split(delim, 5);
                    DateTime tStamp = new DateTime(0L, DateTimeKind.Utc);
                    tStamp = tStamp.AddYears(Convert.ToInt32(values[1]) - 1);
                    tStamp = tStamp.AddDays(Convert.ToDouble(values[2]) - 1.0);
                    string hhmm = values[3].PadLeft(4, '0');
                    tStamp = tStamp.AddHours(Convert.ToDouble(hhmm.Substring(0, 2)));
                    tStamp = tStamp.AddMinutes(Convert.ToDouble(hhmm.Substring(2, 2)));

                    if(hasRecords){
                        buf.AppendLine(",");
                    }
                    else{
                        buf.AppendLine();
                        hasRecords = true;
                    }
                    buf.Append("[" + rec.sequenceNum.ToString() + ",'" + DateUtil.ToUtcString(tStamp) + "'," + values[4] + "]");
                }

            }
            buf.AppendLine();
            buf.AppendLine("];");
            buf.AppendLine("</script>");
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "graphData", buf.ToString() , false);
        }
        protected void processProfile(ExperimentRecord[] records)
        {
            bool hasProfile = false;
            StringBuilder buf = new StringBuilder();
            char[] delim = ",".ToCharArray();
            buf.AppendLine("<script type=\"text/javascript\">");
            //TODO: Add ChannelName here as window
            buf.AppendLine(" window.profileData = [");
            if (records.Length > 0)
            {

                //DateTime epoc = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

                // This a simple solution it expects that there will be an even number of values
                foreach (ExperimentRecord rec in records)
                {
                   // TODO: Change to new profile format
                    string content = rec.contents;
                    string[] values = content.Split(delim);
                    int i = 0;
                    while( i< values.Length){
                        if(i> 0)
                            buf.Append(",");
                        buf.Append("[" + values[i++]);
                        buf.Append("," + values[i++] + "]");
                    }

                    if (hasProfile)
                    {
                        buf.AppendLine(",");
                    }
                    else
                    {
                        buf.AppendLine();
                        hasProfile = true;
                    }
                }

            }
            buf.AppendLine();
            buf.AppendLine("];");
            buf.AppendLine("</script>");

            //Page.ClientScript.RegisterStartupScript(this.GetType(), "profileData", buf.ToString(), false);
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "profileData", buf.ToString(), false);
        }
 /// <remarks/>
 public System.IAsyncResult BeginAddRecords(long experimentId, ExperimentRecord[] records, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("AddRecords", new object[] {
                 experimentId,
                 records}, callback, asyncState);
 }
 /// <remarks/>
 public void AddRecordsAsync(long experimentId, ExperimentRecord[] records, object userState)
 {
     if ((this.AddRecordsOperationCompleted == null)) {
         this.AddRecordsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAddRecordsOperationCompleted);
     }
     this.InvokeAsync("AddRecords", new object[] {
                 experimentId,
                 records}, this.AddRecordsOperationCompleted, userState);
 }
 /// <remarks/>
 public void AddRecordsAsync(long experimentId, ExperimentRecord[] records)
 {
     this.AddRecordsAsync(experimentId, records, null);
 }
 public int AddRecords(long experimentId, ExperimentRecord[] records)
 {
     object[] results = this.Invoke("AddRecords", new object[] {
                 experimentId,
                 records});
     return ((int)(results[0]));
 }