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);
            }
        }
Exemple #2
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);
            }
        }