Пример #1
0
        /// <summary>
        /// Parses the appInfo and experiment ticket, inserts the task into the database and
        /// creates a dataManager and dataSources defined in the appInfo.
        /// </summary>
        /// <param name="appInfo"></param>
        /// <param name="expCoupon"></param>
        /// <param name="expTicket"></param>
        /// <returns></returns>
        public virtual LabTask CreateLabTask(LabAppInfo appInfo, Coupon expCoupon, Ticket expTicket)
        {
            LabTask labTask = CreateLabTask(appInfo, expTicket);

            if (((labTask.storage != null) && (labTask.storage.Length > 0)))
            {
                // Create DataSourceManager to manage dataSources
                DataSourceManager dsManager = new DataSourceManager();

                // set up an experiment storage handler
                ExperimentStorageProxy ess = new ExperimentStorageProxy();
                ess.OperationAuthHeaderValue = new OperationAuthHeader();
                ess.OperationAuthHeaderValue.coupon = expCoupon;
                ess.Url = labTask.storage;
                dsManager.essProxy = ess;
                dsManager.ExperimentID = labTask.experimentID;
                dsManager.AppKey = appInfo.appKey;
                // Note these dataSources are written to by the application and sent to the ESS
                if ((appInfo.dataSources != null) && (appInfo.dataSources.Length > 0))
                {
                    string[] sources = appInfo.dataSources.Split(',');
                    // Use the experimentID as the storage parameter
                    foreach (string s in sources)
                    {
                       // dsManager.AddDataSource(createDataSource(s));
                    }
                }
                TaskProcessor.Instance.AddDataManager(labTask.taskID, dsManager);
            }
            TaskProcessor.Instance.Add(labTask);
            return labTask;
        }
Пример #2
0
 public FileWatcherDataSource CreateBeeDataSource(Coupon expCoupon, LabTask task, string recordType, bool flushFile)
 {
     string outputDir = ConfigurationManager.AppSettings["chamberOutputDir"];
     string outputFile = ConfigurationManager.AppSettings["chamberOutputFile"];
     string filePath = outputDir + @"\" + outputFile;
     // Stop the controller and flush the data file
     if (flushFile)
     {
         //Flush the File
         FileInfo fInfo = new FileInfo(filePath);
         using (FileStream inFile = fInfo.Open(FileMode.Truncate)) { }
     }
     string pushChannel = ChecksumUtil.ToMD5Hash("BEElab" + task.experimentID);
     //Add BEElab specific attributes
     BeeEventHandler bEvt = new BeeEventHandler(expCoupon, task.experimentID, task.storage,
         recordType, ProcessAgentDB.ServiceGuid);
     bEvt.PusherChannel = pushChannel;
     //DataSourceManager dsManager = TaskProcessor.Instance.GetDataManager(task.taskID);
     FileWatcherDataSource fds = new FileWatcherDataSource();
     fds.Path = outputDir;
     fds.Filter = outputFile;
     fds.AddFileSystemEventHandler(bEvt.OnChanged);
     //dsManager.AddDataSource(fds);
     //fds.Start();
     return fds;
 }
Пример #3
0
 public BeeEventHandler(Coupon opCoupon, long experimentId,
     string essUrl, string recordType, string submitter)
 {
     this.opCoupon = opCoupon;
     this.experimentID = experimentId;
     this.essUrl = essUrl;
     this.recordType = recordType;
     this.submitter = submitter;
 }
Пример #4
0
        protected void btnGetTimeOfDay_Click(object sender, EventArgs e)
        {
            Coupon opCoupon = new Coupon(issuerGuid, Int64.Parse(couponId), passkey);

            lsOpHeader.coupon = opCoupon;
            todInterface.OperationAuthHeaderValue = lsOpHeader;

            string time = todInterface.ReturnTimeOfDay();
            lblGetTimeOfDay.Text = time;
        }
Пример #5
0
        // Create DataSourceManager to manage dataSources
        public DataSourceManager CreateDataSourceManager(LabTask task, Coupon expCoupon)
        {
            DataSourceManager dsManager = new DataSourceManager();

                // set up an experiment storage handler
                ExperimentStorageProxy ess = new ExperimentStorageProxy();
                ess.OperationAuthHeaderValue = new OperationAuthHeader();
                ess.OperationAuthHeaderValue.coupon = expCoupon;
                ess.Url = task.storage;
                dsManager.essProxy = ess;
                dsManager.ExperimentID = task.experimentID;
                //dsManager.AppKey = task.labAppID.;
                return dsManager;
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="id"></param>
 /// <param name="guid">The globally unique identifier for the service, this may not be modified.</param>
 /// <param name="name"></param>
 /// <param name="type"></param>
 /// <param name="codeBase"></param>
 /// <param name="servicePage"></param>
 /// <param name="inCoupon">The coupon for incoming messages from the processagent to the local service</param>
 /// <param name="outCoupon">The coupon for messages from the local service to this processAgent</param>
 public ProcessAgentInfo(int id, string guid, string name, int type,
     string domainGuid, string codeBase, string servicePage,
     string issuerGuid, Coupon inCoupon, Coupon outCoupon)
 {
     agentId = id;
     agentGuid = guid;
     agentName = name;
     agentType = (ProcessAgentType.AgentType) type;
     this.domainGuid = domainGuid;
     codeBaseUrl = codeBase;
     webServiceUrl = servicePage;
     this.issuerGuid = issuerGuid;
     identIn = inCoupon;
     identOut = outCoupon;
 }
Пример #7
0
        public override LabTask CreateLabTask(LabAppInfo appInfo, Coupon expCoupon, Ticket expTicket)
        {

            long experimentID = -1;
            LabTask task = null;

            //Parse experiment payload 	
            string payload = expTicket.payload;
            XmlQueryDoc expDoc = new XmlQueryDoc(payload);

            string experimentStr = expDoc.Query("ExecuteExperimentPayload/experimentID");
            if ((experimentStr != null) && (experimentStr.Length > 0))
            {
                experimentID = Convert.ToInt64(experimentStr);
            }
            string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid");



            // Check to see if an experiment with this ID is already running
            LabDB dbManager = new LabDB();
            LabTask.eStatus status = dbManager.ExperimentStatus(experimentID, sbStr);
            if (status == LabTask.eStatus.NotFound)
            {
                // Check for an existing experiment using the same resources, if found Close it

                //Create the new Task
                if(appInfo.rev.Contains("8.2")){
                   task = iLabs.LabView.LV82.LabViewTask.CreateLabTask(appInfo,expCoupon,expTicket);
                }
                else{
                     task = iLabs.LabView.LV86.LabViewTask.CreateLabTask(appInfo,expCoupon,expTicket);
                }
            }

            else
            {
                task =  TaskProcessor.Instance.GetTask(experimentID);

            }
            return task;
        }
Пример #8
0
        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;
            }
        }
        protected void goButton_Click(object sender, System.EventArgs e)
        {
            LabDB labDB = new LabDB();

            // Update Task data for graph page. Note XmlQueryDocs are read-only
            LabTask task = labDB.GetTask(Convert.ToInt64(hdnExpId.Value), Session["opIssuer"].ToString());
            if (task != null)
            {
                Coupon opCoupon = new Coupon(task.issuerGUID, task.couponID, Session["opPasscode"].ToString());
               ExperimentStorageProxy essProxy = new ExperimentStorageProxy();
               essProxy.OperationAuthHeaderValue = new OperationAuthHeader();
               essProxy.OperationAuthHeaderValue.coupon = opCoupon;
               essProxy.Url = task.storage;
               essProxy.AddRecord(task.experimentID, "BEElab", "profile", false, hdnProfile.Value, null);
               essProxy.AddRecord(task.experimentID, "BEElab", "climateProfile", false, hdnClimateProfile.Value, null);
               essProxy.AddRecord(task.experimentID, "BEElab", "sunLamp", false, hdnSunLamp.Value, null);

               // send The CR1000 programs
               sendProfile(ConfigurationManager.AppSettings["climateController"],
                   hdnProfile.Value, hdnSunProfile, ConfigurationManager.AppSettings["climateServer"]);
               sendFile(ConfigurationManager.AppSettings["chamberController"],
                  ConfigurationManager.AppSettings["chamberFile"],
                  ConfigurationManager.AppSettings["chamberServer"]);
                StringBuilder buf = new StringBuilder("BEEgraph.aspx?expid=");

                sendEwsCientProfile(hdnClientProfile.Value,hdnExpLength.Value);
                buf.Append(task.experimentID);
                task.Status = LabTask.eStatus.Running;
                TaskProcessor.Instance.Modify(task);
                labDB.SetTaskStatus(task.taskID, (int) LabTask.eStatus.Running);
                Session["opCouponID"] = hdnCoupon.Value;
                Session["opIssuer"] = hdnIssuer.Value;
                Session["opPasscode"] = hdnPasscode.Value;
                Response.Redirect(buf.ToString(), true);
            }
            else
            {
                throw new Exception("Task was not found.");
            }
        }
Пример #10
0
        public bool AddBlobToRecord(long blobId, long experimentId, int sequenceNum)
        {
            bool blobAdded = false;

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

            string ticketType = TicketTypes.STORE_RECORDS;

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, ticketType);

                blobAdded = blobsAPI.AddBlobToRecord(blobId, experimentId, retrievedTicket.issuerGuid, sequenceNum);
                return blobAdded;
            }

            catch
            {
                throw;
            }
        }
Пример #11
0
        protected void btnRequestBlobAccess_Click(object sender, EventArgs e)
        {
            Coupon opCoupon = new Coupon(issuerGuid, Int64.Parse(couponId), passkey);

            lsOpHeader.coupon = opCoupon;
            todInterface.OperationAuthHeaderValue = lsOpHeader;

            long experimentId = todInterface.GetExperimentId();
            long blobId = todInterface.GetBlobId();

            essOpHeader.coupon = opCoupon;
            //blobStorage.OperationAuthHeaderValue = essOpHeader;
            essInterface.OperationAuthHeaderValue = essOpHeader;

            //string blobUrl = blobStorage.RequestBlobAccess(blobId, "http", 30);
            string blobUrl = essInterface.RequestBlobAccess(blobId, "http", 30);

            Image1.Visible = true;
            Image1.ImageUrl = blobUrl;

            Label1.Text = lblGetTimeOfDay.Text;
        }
Пример #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // retrieve parameters from URL
                couponId = Request.QueryString["coupon_id"];
                passkey = Request.QueryString["passkey"];
                issuerGuid = Request.QueryString["issuer_guid"];
                sbUrl = Request.QueryString["sb_url"];
                labUrl= ConfigurationManager.AppSettings["labUrl"];

                if (passkey != null && couponId != null && issuerGuid != null)
                {
                    try
                    {
                        //set execution coupon and ticket type
                        Coupon executionCoupon = new Coupon(issuerGuid, Int64.Parse(couponId), passkey);
                        string type = TicketTypes.EXECUTE_EXPERIMENT;

                        // retrieve the ticket and verify it
                        Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(executionCoupon, type);

                    }

                    catch
                    {
                        Response.Redirect("Default.aspx" + "?sb_url=" + sbUrl);
                    }
                    Response.Redirect(labUrl + "?passkey=" + passkey + "&sbUrl=" + sbUrl);

                }

                else
                {
                    Response.Redirect("Default.aspx" + "?sb_url=" + sbUrl);
                }
            }
        }
Пример #13
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="coupon"></param>
        /// <param name="type"></param>
        /// <param name="redeemerGuid"></param>
        /// <param name="sponsorGuid"></param>
        /// <param name="expiration"></param>
        /// <param name="payload"></param>
        /// <returns>The added Ticket, or null of the ticket cannot be added</returns>
        public Ticket AddTicket(Coupon coupon, 
            string type, string redeemerGuid, string sponsorGuid, long expiration, string payload)
        {
            Ticket ticket = null;
            // create sql connection
            DbConnection connection = FactoryDB.GetConnection();

            try
            {
                connection.Open();
                if (AuthenticateIssuedCoupon(connection, coupon))
                {
                    ticket = InsertIssuedTicket(connection, coupon.couponId, redeemerGuid, sponsorGuid,
                        type, expiration, payload);
                }
            }

            finally
            {
                connection.Close();
            }

            return ticket;
        }
Пример #14
0
        public int GetBlobStatus(long blobId)
        {
            int status = -1;

            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);
                status = blobsAPI.GetBlobStatus(blobId);
                return status;
            }
            catch
            {
                throw;
            }
        }
Пример #15
0
        public bool RequestBlobStorage(long blobId, string blobUrl)
        {
            Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId,
                 opHeader.coupon.passkey);

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.STORE_RECORDS);

                try
                {
                    return blobsAPI.RequestBlobStorage(blobId, blobUrl);
                }

                catch
                {
                    return false;
                }
            }
            catch
            {
                throw;
            }
        }
Пример #16
0
        public string[] GetSupportedChecksumAlgorithms()
        {
            string[] checksumAlgorithms = null;

            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);
                checksumAlgorithms = blobsAPI.GetSupportedChecksumAlgorithms();

                return checksumAlgorithms;
            }

            catch
            {
                throw;
            }
        }
Пример #17
0
        public string[] GetSupportedBlobImportProtocols()
        {
            string[] protocols = null;

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

                protocols = blobsAPI.GetSupportedBlobImportProtocols();
                return protocols;
            }

            catch
            {
                throw;
            }
        }
Пример #18
0
        public ExperimentRecord[] GetRecords(long experimentId, Criterion[] target )
        {
            ExperimentRecord[] expRecords = null;

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

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);
                expRecords = experimentsAPI.GetRecords(experimentId, retrievedTicket.issuerGuid, target);

                return expRecords;
            }

            catch (Exception ex)
            {
                Utilities.WriteLog("GetRecord: " + ex.Message);
                throw;
            }
        }
Пример #19
0
        public RecordAttribute[] GetRecordAttributesByName(long experimentId, int sequenceNum, string attributeName)
        {
            RecordAttribute[] recordAttributes = null;

            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, attributeName);

                return recordAttributes;
            }

            catch
            {
                throw;
            }
        }
Пример #20
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;
            }
        }
Пример #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // retrieve parameters from URL
            string couponId = Request.QueryString["coupon_id"];
            string passkey = Request.QueryString["passkey"];
            string issuerGuid = Request.QueryString["issuer_guid"];
            string sbUrl = Request.QueryString["sb_url"];

            if (passkey != null && couponId != null && issuerGuid != null)
            {
                //set execution coupon and ticket type
                Coupon executionCoupon = new Coupon(issuerGuid, Int64.Parse(couponId), passkey);
                string type = TicketTypes.EXECUTE_EXPERIMENT;

                // retrieve the ticket and verify it
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(executionCoupon, type);

                XmlDocument payload = new XmlDocument();
                payload.LoadXml(retrievedTicket.payload);

                long experimentId = Int64.Parse(payload.GetElementsByTagName("experimentID")[0].InnerText);

                string weblabDeustoUrl = ConfigurationManager.AppSettings["weblabdeusto_url"];
                WebLabDeusto.WebLabDeustoClient client = new WebLabDeusto.WebLabDeustoClient(weblabDeustoUrl);

                if (RESERVATION_IDS.ContainsKey(experimentId))
                {
                    string newUrl = client.CreateClient(RESERVATION_IDS[experimentId]);
                    LoadWebLab(newUrl);
                }
                else
                {
                    string username       = ConfigurationManager.AppSettings["weblabdeusto_username"];
                    string password       = ConfigurationManager.AppSettings["weblabdeusto_password"];
                    string experimentName = ConfigurationManager.AppSettings["weblabdeusto_exp_name"];
                    string categoryName   = ConfigurationManager.AppSettings["weblabdeusto_exp_category"];

                    Dictionary<string, object> consumerData = new Dictionary<string, object>();

                    consumerData["external_user"] = Convert.ToString(experimentId); // Could be group ID
                    consumerData["user_agent"]    = Request.UserAgent;
                    consumerData["referer"]       = Request.UrlReferrer.ToString();
                    consumerData["from_ip"]       = Request.UserHostAddress;

                    if (ConfigurationManager.AppSettings["weblabdeusto_priority"] != null)
                        consumerData["priority"] = Convert.ToInt32(ConfigurationManager.AppSettings["weblabdeusto_priority"]);

                    if (ConfigurationManager.AppSettings["weblabdeusto_time_allowed"] != null)
                        consumerData["time_allowed"] = Convert.ToInt32(ConfigurationManager.AppSettings["weblabdeusto_time_allowed"]);

                    if (ConfigurationManager.AppSettings["weblabdeusto_initialization_in_accounting"] != null)
                        consumerData["initialization_in_accounting"] = Convert.ToBoolean(ConfigurationManager.AppSettings["weblabdeusto_initialization_in_accounting"]);

                    WebLabDeusto.SessionId sessid = client.Login(username, password);
                    WebLabDeusto.Reservation reservation = client.ReserveExperiment(sessid, experimentName, categoryName, consumerData);

                    RESERVATION_IDS.Add(experimentId, reservation);

                    string newUrl = client.CreateClient(reservation);

                    LoadWebLab(newUrl);
                }
            }
            else
            {
                Response.Redirect("Default.aspx" + "?sb_url=" + sbUrl);
            }
        }
 /// <remarks/>
 public void AgentCloseExperimentAsync(Coupon coupon, long experimentId, object userState)
 {
     if ((this.AgentCloseExperimentOperationCompleted == null)) {
         this.AgentCloseExperimentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnAgentCloseExperimentOperationCompleted);
     }
     this.InvokeAsync("AgentCloseExperiment", new object[] {
                 coupon,
                 experimentId}, this.AgentCloseExperimentOperationCompleted, userState);
 }
Пример #23
0
        public StorageStatus SetExperimentStatus(long experimentId, int statusCode)
        {
            StorageStatus status = new StorageStatus();
            Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId,
                 opHeader.coupon.passkey);

            try
            {
                Ticket retrievedTicket = null;
                try
                {
                    retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.ADMINISTER_EXPERIMENT);
                }
                catch (TicketExpiredException expEx)
                {
                    if (statusCode < StorageStatus.CLOSED)
                        throw;
                }
                catch (TicketNotFoundException nfEx)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    throw;
                }

                if ((statusCode & StorageStatus.CLOSED) == StorageStatus.CLOSED)
                    {
                        status = experimentsAPI.GetExperimentStatus(experimentId, opCoupon.issuerGuid);
                        if((status.status & StorageStatus.CLOSED) != StorageStatus.CLOSED)
                            experimentsAPI.CloseExperiment(experimentId, opCoupon.issuerGuid, statusCode);
                        status = experimentsAPI.GetExperimentStatus(experimentId, opCoupon.issuerGuid);
                    }
                    else
                    {
                        status = experimentsAPI.SetExperimentStatus(experimentId, opCoupon.issuerGuid, statusCode);
                    }

                return status;
            }
            catch(Exception ex)
            {
                Utilities.WriteLog("SetExperimentStatuus: " + ex.Message);
                throw;
            }
        }
Пример #24
0
        public Blob[] GetBlobsForRecord(long experimentId, int sequenceNum)
        {
            Blob[] b = null;

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

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);
                b = blobsAPI.GetBlobsForRecord(experimentId, retrievedTicket.issuerGuid, sequenceNum);

                return b;
            }
            catch
            {
                throw;
            }
        }
 /// <remarks/>
 public void AgentCloseExperimentAsync(Coupon coupon, long experimentId)
 {
     this.AgentCloseExperimentAsync(coupon, experimentId, null);
 }
Пример #26
0
        public Experiment GetExperiment(long experimentId)
        {
            Experiment exp = new Experiment();

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

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);
                exp = experimentsAPI.GetExperiment(experimentId, retrievedTicket.issuerGuid);

                return exp;
            }

            catch (Exception ex)
            {
                Utilities.WriteLog("GetExperiment: " + ex.Message);
                throw;
            }
        }
 /// <remarks/>
 public System.IAsyncResult BeginAgentCloseExperiment(Coupon coupon, long experimentId, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("AgentCloseExperiment", new object[] {
                 coupon,
                 experimentId}, callback, asyncState);
 }
Пример #28
0
        public StorageStatus GetExperimentStatus(long experimentId)
        {
            StorageStatus status = new StorageStatus();
            Coupon opCoupon = new Coupon(opHeader.coupon.issuerGuid, opHeader.coupon.couponId,
                 opHeader.coupon.passkey);
            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);

                    status = experimentsAPI.GetExperimentStatus(experimentId, opCoupon.issuerGuid);

                return status;
            }
            catch
            {
                throw;
            }
        }
Пример #29
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            culture = DateUtil.ParseCulture(Request.Headers["Accept-Language"]);
            serviceBrokerGuid = Session["serviceBrokerGuid"].ToString();
            groupName = Session["groupName"].ToString();
            clientGuid = Session["clientGuid"].ToString();
            labServerGuid = Session["labServerGuid"].ToString();
            labClientName = Session["labClientName"].ToString();
            labClientVersion = Session["labClientVersion"].ToString();
            userName = Session["userName"].ToString();
            lssURL = Session["lssURL"].ToString();
            lssGuid = Session["lssGuid"].ToString();
            userTZ = Convert.ToInt32(Session["userTZ"]);
            coupon = (Coupon) Session["coupon"];

            if (IsPostBack){
                if(Session["startTime"]!= null)
                   startTime = (DateTime)Session["startTime"] ;
                if(Session["endTime"]!= null)
                    endTime = (DateTime)Session["endTime"];
                if (Session["minAllowTime"] != null)
                {
                    minRequiredTime = TimeSpan.FromMinutes((int)Session["minAllowTime"]);
                }
                else
                {
                    minRequiredTime = TimeSpan.FromMinutes(1);
                }
                if (Session["maxAllowTime"] != null)
                {
                    maxAllowTime = TimeSpan.FromMinutes((int)Session["maxAllowTime"]);
                }
                else
                {
                    maxAllowTime = TimeSpan.FromMinutes(42);
                }
            }

            else{
                string value1 = Request.QueryString["start"];
                string value2 = Request.QueryString["end"];
                startTime = DateUtil.ParseUtc(value1);
                Session["startTime"] = startTime;
                endTime = DateUtil.ParseUtc(value2);
                Session["endTime"] = endTime;
                int[] policyIDs = USSSchedulingAPI.ListUSSPolicyIDsByGroupAndExperiment(groupName, serviceBrokerGuid, clientGuid, labServerGuid);
                for (int i = 0; i < policyIDs.Length; i++)
                {
                    USSPolicy pol = USSSchedulingAPI.GetUSSPolicies(new int[] { policyIDs[i] })[0];
                    string maxstr = PolicyParser.getProperty(pol.rule, "Maximum reservable time");
                    if (maxstr != null)
                    {
                        maxAllowTime = TimeSpan.FromMinutes(Int32.Parse(maxstr));
                        Session["maxAllowTime"] = (int) maxAllowTime.TotalMinutes; ;
                    }
                    string minstr = PolicyParser.getProperty(pol.rule, "Minimum time required");
                    if (minstr != null)
                    {
                        minRequiredTime = TimeSpan.FromMinutes(Int32.Parse(minstr));
                        Session["minAllowTime"] = (int) minRequiredTime.TotalMinutes;
                    }
                    lblUssPolicy.Text = "Minimum time required: " + minRequiredTime + "<br />Maximum time allowed: " + maxAllowTime;
                }
                lblTimezone.Text = "Times are GMT " + userTZ / 60.0;
            }
            getTimePeriods();
        }
Пример #30
0
        public int GetIdleTime(long experimentId)
        {
            int idleTime = -1;

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

            try
            {
                Ticket retrievedTicket = dbTicketing.RetrieveAndVerify(opCoupon, TicketTypes.RETRIEVE_RECORDS);

                idleTime = experimentsAPI.GetIdleTime(experimentId, retrievedTicket.issuerGuid);

                return idleTime;
            }

            catch
            {
                throw;
            }
        }