protected void Page_Load(object sender, System.EventArgs e) { LabDB dbManager = new LabDB(); if (!IsPostBack) { // Query values from the request //clearSessionInfo(); hdnExpId.Value = Request.QueryString["expid"]; hdnCoupon.Value = Request.QueryString["coupon_id"]; hdnPasscode.Value = Request.QueryString["passkey"]; hdnIssuer.Value = Request.QueryString["issuer_guid"]; hdnSbUrl.Value = Request.QueryString["sb_url"]; string expLen = Request.QueryString["explen"]; string timeUnit = Request.QueryString["tu"]; if (timeUnit != null && timeUnit.Length > 0) hdnTimeUnit.Value = timeUnit; string userName = null; string userIdStr = null; int tz = 0; if (Session["userTZ"] != null) tz = Convert.ToInt32(Session["userTZ"]); if (Session["sbUrl"] != null) { String returnURL = (string)Session["sbUrl"]; } //// this should be the RedeemSession & Experiment Coupon data if (!(Session["opPasscode"] != null && Session["opPasscode"] != "" && Session["opCouponID"] != null && Session["opCouponID"] != "" && Session["opIssuer"] != null && Session["opIssuer"] != "")) { Logger.WriteLine("BEEstartAll: " + "AccessDenied missing credentials"); Response.Redirect("AccessDenied.aspx?text=missing+credentials.", true); } Coupon expCoupon = new Coupon(Session["opIssuer"].ToString(), Convert.ToInt64(Session["opCouponID"]), Session["opPasscode"].ToString()); //Check the database for ticket and coupon, if not found Redeem Ticket from // issuer and store in database. //This ticket should include group, experiment id and be valid for this moment in time?? Ticket expTicket = dbManager.RetrieveAndVerify(expCoupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { if (expTicket.IsExpired()) { Response.Redirect("AccessDenied.aspx?text=The ExperimentExecution+ticket+has+expired.", true); } Session["exCoupon"] = expCoupon; ////Parse experiment payload, only get what is needed string payload = expTicket.payload; XmlQueryDoc expDoc = new XmlQueryDoc(payload); string expIdStr = expDoc.Query("ExecuteExperimentPayload/experimentID"); hdnExpId.Value = expIdStr; string tzStr = expDoc.Query("ExecuteExperimentPayload/userTZ"); //string userIdStr = expDoc.Query("ExecuteExperimentPayload/userID"); string groupName = expDoc.Query("ExecuteExperimentPayload/groupName"); Session["groupName"] = groupName; string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid"); Session["brokerGUID"] = sbStr; string startStr = expDoc.Query("ExecuteExperimentPayload/startExecution"); string durStr = expDoc.Query("ExecuteExperimentPayload/duration"); writeExpLength(startStr,durStr); if ((tzStr != null) && (tzStr.Length > 0)) { Session["userTZ"] = tzStr; } } } }
protected void Page_Load(object sender, System.EventArgs e) { LabDB dbManager = new LabDB(); int appID = 0; long expID = 0; LabTask task = null; // Query values from the request string appKey = Request.QueryString["app"]; string coupon_Id = Request.QueryString["coupon_id"]; string passkey = Request.QueryString["passkey"]; string issuerGUID = Request.QueryString["issuer_guid"]; string returnTarget = Request.QueryString["sb_url"]; if ((returnTarget != null) && (returnTarget.Length > 0)) Session["returnURL"] = returnTarget; Logger.WriteLine("LVPortal: " + Request.Url.ToString()); // this should be the Experiment Coupon data if (!(passkey != null && passkey != "" && coupon_Id != null && coupon_Id != "" && issuerGUID != null && issuerGUID != "")) { Logger.WriteLine("LVPortal: " + "AccessDenied missing Experiment credentials"); Response.Redirect("AccessDenied.aspx?text=missing+Experiment+credentials.", true); } long expCoupId = Convert.ToInt64(coupon_Id); Coupon expCoupon = new Coupon(issuerGUID, expCoupId, passkey); //Check the database for ticket and coupon, if not found Redeem Ticket from // issuer and store in database. //This ticket should include group, experiment id and be valid for this moment in time?? Ticket expTicket = dbManager.RetrieveAndVerify(expCoupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { if (expTicket.IsExpired()) { Response.Redirect("AccessDenied.aspx?text=The ExperimentExecution+ticket+has+expired.", true); } ////Parse experiment payload, only get what is needed string payload = expTicket.payload; XmlQueryDoc expDoc = new XmlQueryDoc(payload); string tzStr = expDoc.Query("ExecuteExperimentPayload/userTZ"); if ((tzStr != null) && (tzStr.Length > 0)) Session["userTZ"] = tzStr; string groupName = expDoc.Query("ExecuteExperimentPayload/groupName"); Session["groupName"] = groupName; string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid"); Session["brokerGUID"] = sbStr; //Get Lab specific info for this URL or group LabAppInfo appInfo = null; // Experiment is specified by 'app=appKey' if (appKey != null && appKey.Length > 0) { appInfo = dbManager.GetLabApp(appKey); } else // Have to use groupName & Servicebroker THIS REQUIRES groups & permissions are set in database { // This is no longer the case as the USS handles groups and permissions appInfo = dbManager.GetLabAppForGroup(groupName, sbStr); } if (appInfo == null) { Response.Redirect("AccessDenied.aspx?text=Unable+to+find+application+information,+please+notify+your+administrator.", true); } // Use taskFactory to create a new task, return an existing reentrant task or null if there is an error LabViewTaskFactory factory = new LabViewTaskFactory(); task = factory.CreateLabTask(appInfo, expCoupon, expTicket); if (task != null) { //Useful for debugging overloads the use of a field in the banner //Session["GroupName"] = "TaskID: " + task.taskID.ToString(); //Utilities.WriteLog("TaskXML: " + task.taskID + " \t" + task.data); //Construct the information to be passed to the target page TimeSpan taskDur = task.endTime - task.startTime; string vipayload = task.constructSessionPayload(appInfo, task.startTime, taskDur.Ticks / TimeSpan.TicksPerSecond, task.taskID, returnTarget, null, null); //Utilities.WriteLog("sessionPayload: " + payload); //Store Session information Session["payload"] = vipayload; if (appInfo.rev != null && appInfo.rev.Length > 0) { Session["lvversion"] = appInfo.rev; } else { Session.Remove("lvversion"); } //redirect to Presentation page... Response.Redirect(appInfo.page, true); } else { Response.Redirect("AccessDenied.aspx?text=Unable+to+launch++application,+please+notify+your+administrator.", true); } } }
protected void Page_Load(object sender, System.EventArgs e) { LabDB dbManager = new LabDB(); if (!IsPostBack) { // Query values from the request //clearSessionInfo(); hdnAppkey.Value = Request.QueryString["app"]; hdnCoupon.Value = Request.QueryString["coupon_id"]; hdnPasscode.Value = Request.QueryString["passkey"]; hdnIssuer.Value = Request.QueryString["issuer_guid"]; hdnSbUrl.Value = Request.QueryString["sb_url"]; if (hdnSbUrl.Value != null && hdnSbUrl.Value.Length > 0) Session["sbUrl"] = hdnSbUrl.Value; else Session.Remove("sbUrl"); string userName = null; string userIdStr = null; int tz = 0; if (Session["userTZ"] != null) tz = Convert.ToInt32(Session["userTZ"]); // this should be the RedeemSession & Experiment Coupon data if (!(hdnPasscode.Value != null && hdnPasscode.Value != "" && hdnCoupon.Value != null && hdnCoupon.Value != "" && hdnIssuer.Value != null && hdnIssuer.Value != "")) { Logger.WriteLine("BEEanaylsis: " + "AccessDenied missing credentials"); Response.Redirect("AccessDenied.aspx?text=missing+credentials.", true); } Coupon expCoupon = new Coupon(hdnIssuer.Value, Convert.ToInt64(hdnCoupon.Value), hdnPasscode.Value); //Check the database for ticket and coupon, if not found Redeem Ticket from // issuer and store in database. //This ticket should include group, experiment id and be valid for this moment in time?? Ticket expTicket = dbManager.RetrieveAndVerify(expCoupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { if (expTicket.IsExpired()) { Response.Redirect("AccessDenied.aspx?text=The ExperimentExecution+ticket+has+expired.", true); } Session["exCoupon"] = expCoupon; ////Parse experiment payload, only get what is needed string payload = expTicket.payload; XmlQueryDoc expDoc = new XmlQueryDoc(payload); string expIdStr = expDoc.Query("ExecuteExperimentPayload/experimentID"); string tzStr = expDoc.Query("ExecuteExperimentPayload/userTZ"); //string userIdStr = expDoc.Query("ExecuteExperimentPayload/userID"); string groupName = expDoc.Query("ExecuteExperimentPayload/groupName"); Session["groupName"] = groupName; string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid"); Session["brokerGUID"] = sbStr; if ((tzStr != null) && (tzStr.Length > 0)) { Session["userTZ"] = tzStr; } LabAppInfo clientInfo = dbManager.GetLabApp(hdnAppkey.Value); if (clientInfo == null) { throw new Exception("Client does not exist!"); } long experimentID = Convert.ToInt64(expIdStr); InteractiveSBProxy sbProxy = new InteractiveSBProxy(); ProcessAgentInfo sbInfo = dbManager.GetProcessAgentInfo(hdnIssuer.Value); if (sbInfo != null) { sbProxy.OperationAuthHeaderValue = new OperationAuthHeader(); sbProxy.OperationAuthHeaderValue.coupon = expCoupon; sbProxy.Url = sbInfo.webServiceUrl; // Use the extraInfo field to provide the target ClientGUID List<Criterion> cri = new List<Criterion>(); if (clientInfo.extraInfo != null && clientInfo.extraInfo.Length > 0) cri.Add(new Criterion("clientguid", "=", clientInfo.extraInfo)); ExperimentSummary[] expSum = sbProxy.RetrieveExperimentSummary(cri.ToArray()); listSummaries(expSum); } } } }
protected void Page_Load(object sender, System.EventArgs e) { LabDB dbManager = new LabDB(); int appID = 0; long expID = 0; LabTask task = null; string pageURL = null; // Query values from the request string appKey = Request.QueryString["app"]; string coupon_Id = Request.QueryString["coupon_id"]; string passkey = Request.QueryString["passkey"]; string issuerGUID = Request.QueryString["issuer_guid"]; string returnTarget = Request.QueryString["sb_url"]; if ((returnTarget != null) && (returnTarget.Length > 0)) Session["returnURL"] = returnTarget; Logger.WriteLine("BEElab: " + Request.Url.ToString()); // this should be the Experiment Coupon data if (!(passkey != null && passkey != "" && coupon_Id != null && coupon_Id != "" && issuerGUID != null && issuerGUID != "")) { Logger.WriteLine("BEElab: " + "AccessDenied missing Experiment credentials"); Response.Redirect("AccessDenied.aspx?text=missing+Experiment+credentials.", true); } long expCoupId = Convert.ToInt64(coupon_Id); Coupon expCoupon = new Coupon(issuerGUID, expCoupId, passkey); //Check the database for ticket and coupon, if not found Redeem Ticket from // issuer and store in database. //This ticket should include group, experiment id and be valid for this moment in time?? Ticket expTicket = dbManager.RetrieveAndVerify(expCoupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { if (expTicket.IsExpired()) { Response.Redirect("AccessDenied.aspx?text=The ExperimentExecution+ticket+has+expired.", true); } ////Parse experiment payload, only get what is needed string payload = expTicket.payload; XmlQueryDoc expDoc = new XmlQueryDoc(payload); string tzStr = expDoc.Query("ExecuteExperimentPayload/userTZ"); if ((tzStr != null) && (tzStr.Length > 0)) Session["userTZ"] = tzStr; string groupName = expDoc.Query("ExecuteExperimentPayload/groupName"); Session["groupName"] = groupName; string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid"); string essUrl = expDoc.Query("ExecuteExperimentPayload/essWebAddress"); expID = Convert.ToInt64(expDoc.Query("ExecuteExperimentPayload/experimentID")); Session["brokerGUID"] = sbStr; //Get Lab specific info for this URL or group LabAppInfo appInfo = null; // Experiment is specified by 'app=appKey' if (appKey != null && appKey.Length > 0) { appInfo = dbManager.GetLabApp(appKey); } else // Have to use groupName & Servicebroker THIS REQUIRES groups & permissions are set in database { // This is no longer the case as the USS handles groups and permissions appInfo = dbManager.GetLabAppForGroup(groupName, sbStr); } if (appInfo == null) { Response.Redirect("AccessDenied.aspx?text=Unable+to+find+application+information,+please+notify+your+administrator.", true); } // Check to see if an experiment with this ID is already running // Check for an existing task for this experiment // If found redirect to the graph page, do not abort running controller program LabTask.eStatus status = dbManager.ExperimentStatus(expID, sbStr); if (status == LabTask.eStatus.NotFound) { // Check for existing tasks that may be using resources // For now only close other instances of the lab List<LabTask> curTasks = TaskProcessor.Instance.GetTasks(appInfo.appID); if (curTasks != null && curTasks.Count > 0) { foreach (LabTask t in curTasks) { DataSourceManager dsManager = TaskProcessor.Instance.GetDataManager(t.taskID); if (dsManager != null) { // Need to close existing data Sources TaskProcessor.Instance.Remove(t); t.Close(); } } } // Create a new Experiment task // Use taskFactory to create a new task LabTaskFactory factory = new LabTaskFactory(); task = factory.CreateLabTask(appInfo, expCoupon, expTicket); if (task != null) { string filePath = "c:\\logs\\Campbell\\LoggerNet"; string fileName = "CECI-CR10X_final_storage_1.dat"; // Stop the controller and flush the data file //Flush the File FileInfo fInfo = new FileInfo(filePath +"\\" + fileName); using (FileStream inFile = fInfo.Open(FileMode.Truncate)) { } string pushChannel = ChecksumUtil.ToMD5Hash("BEElab" + expID); //Add BEElab specific attributes BeeEventHandler bEvt = new BeeEventHandler(expCoupon,expID,essUrl, "data",ProcessAgentDB.ServiceGuid); bEvt.PusherChannel = pushChannel; DataSourceManager dsManager = TaskProcessor.Instance.GetDataManager(task.taskID); FileWatcherDataSource fds = new FileWatcherDataSource(); fds.Path = filePath; fds.Filter = fileName; fds.AddFileSystemEventHandler(bEvt.OnChanged); dsManager.AddDataSource(fds); fds.Start(); //Useful for debugging overloads the use of a field in the banner //Session["GroupName"] = "TaskID: " + task.taskID.ToString(); //Utilities.WriteLog("TaskXML: " + task.taskID + " \t" + task.data); ////Construct the information to be passed to the target page //TimeSpan taskDur = task.endTime - task.startTime; //string vipayload = LabTask.constructSessionPayload(appInfo, // task.startTime, taskDur.Ticks / TimeSpan.TicksPerSecond, task.taskID, // returnTarget, null, null); ////Utilities.WriteLog("sessionPayload: " + payload); ////Store Session information //Session["payload"] = vipayload; //if (appInfo.rev != null && appInfo.rev.Length > 0) //{ // Session["lvversion"] = appInfo.rev; //} //else //{ // Session.Remove("lvversion"); //} //set Presentation page tp appPage pageURL = appInfo.page; } else { Response.Redirect("AccessDenied.aspx?text=Unable+to+launch++application,+please+notify+your+administrator.", true); } } else { // An existing Experiment task = TaskProcessor.Instance.GetTask(expID, sbStr); if (task.data != null) { XmlQueryDoc taskDoc = new XmlQueryDoc(task.data); pageURL = taskDoc.Query("task/application"); } if (pageURL == null || pageURL.Length == 0) { pageURL = appInfo.page; } } } if(pageURL != null && pageURL.Length >0){ StringBuilder buf = new StringBuilder(pageURL + "?expid=" + expID); Session["opCouponID"] = coupon_Id; Session["opPasscode"] = passkey; Session["opIssuer"] = issuerGUID; buf.Append("&coupon_id=" + coupon_Id); buf.Append("&passkey=" + passkey); buf.Append("&issuer_guid=" + issuerGUID); buf.Append("&sb_url=" + returnTarget ); Response.Redirect(buf.ToString(), true); } else{ Response.Redirect("AccessDenied.aspx?text=Unable+to+launch++application,+please+notify+your+administrator.", true); } }
protected void Page_Load(object sender, System.EventArgs e) { LabDB dbManager = new LabDB(); int appID = 0; long expID = 0; LabTask task = null; string expLen = null; string pageURL = null; bool useTaskDuration = true; // Query values from the request if (!IsPostBack) { string appKey = Request.QueryString["app"]; string coupon_Id = Request.QueryString["coupon_id"]; string passkey = Request.QueryString["passkey"]; string issuerGUID = Request.QueryString["issuer_guid"]; string returnTarget = Request.QueryString["sb_url"]; expLen = Request.QueryString["explen"]; if ((returnTarget != null) && (returnTarget.Length > 0)) Session["sbUrl"] = returnTarget; Logger.WriteLine("BEElab: " + Request.Url.ToString()); // this should be the Experiment Coupon data if (!(passkey != null && passkey != "" && coupon_Id != null && coupon_Id != "" && issuerGUID != null && issuerGUID != "")) { Logger.WriteLine("BEElab: " + "AccessDenied missing Experiment credentials"); Response.Redirect("AccessDenied.aspx?text=missing+Experiment+credentials.", true); } long expCoupId = Convert.ToInt64(coupon_Id); Coupon expCoupon = new Coupon(issuerGUID, expCoupId, passkey); //Check the database for ticket and coupon, if not found Redeem Ticket from // issuer and store in database. //This ticket should include group, experiment id and be valid for this moment in time?? Ticket expTicket = dbManager.RetrieveAndVerify(expCoupon, TicketTypes.EXECUTE_EXPERIMENT); if (expTicket != null) { if (expTicket.IsExpired()) { Response.Redirect("AccessDenied.aspx?text=The ExperimentExecution+ticket+has+expired.", true); } Session[""] = issuerGUID; Session[""] = expCoupId; Session[""] = passkey; ////Parse experiment payload, only get what is needed string payload = expTicket.payload; XmlQueryDoc expDoc = new XmlQueryDoc(payload); string tzStr = expDoc.Query("ExecuteExperimentPayload/userTZ"); if ((tzStr != null) && (tzStr.Length > 0)) Session["userTZ"] = tzStr; string groupName = expDoc.Query("ExecuteExperimentPayload/groupName"); Session["groupName"] = groupName; string sbStr = expDoc.Query("ExecuteExperimentPayload/sbGuid"); string essUrl = expDoc.Query("ExecuteExperimentPayload/essWebAddress"); expID = Convert.ToInt64(expDoc.Query("ExecuteExperimentPayload/experimentID")); Session["brokerGUID"] = sbStr; //Get Lab specific info for this URL or group LabAppInfo appInfo = null; // Experiment is specified by 'app=appKey' if (appKey != null && appKey.Length > 0) { appInfo = dbManager.GetLabApp(appKey); } // This is no longer the case as the USS handles groups and permissions //else // Have to use groupName & Servicebroker THIS REQUIRES groups & permissions are set in database //{ // appInfo = dbManager.GetLabAppForGroup(groupName, sbStr); //} if (appInfo == null) { Response.Redirect("AccessDenied.aspx?text=Unable+to+find+application+information,+please+notify+your+administrator.", true); } // Check to see if an experiment with this ID is already running // Check for an existing task for this experiment // If found redirect to the graph page, do not abort running controller program LabTask.eStatus status = dbManager.ExperimentStatus(expID, sbStr); if (status == LabTask.eStatus.NotFound) { // Check for existing tasks that may be using resources // For now only close other instances of the lab List<LabTask> curTasks = TaskProcessor.Instance.GetTasks(appInfo.appID); if (curTasks != null && curTasks.Count > 0) { foreach (LabTask t in curTasks) { //ToDo: check if the tasks should all be closed DataSourceManager dsManager = TaskProcessor.Instance.GetDataManager(t.taskID); if (dsManager != null) { // Need to close existing data Sources TaskProcessor.Instance.Remove(t); t.Close(); } } } // Create a new Experiment task // Use taskFactory to create a new task BeeAPI factory = new BeeAPI(); task = factory.CreateLabTask(appInfo, expTicket); if (task != null) { if (task.storage != null && task.storage.Length > 0) { DataSourceManager dsManager = new DataSourceManager(task); FileWatcherDataSource fds = factory.CreateBeeDataSource(expCoupon, task, "data", true); dsManager.AddDataSource(fds); fds.Start(); TaskProcessor.Instance.AddDataManager(task.taskID, dsManager); } TaskProcessor.Instance.Add(new BeeTask(task)); //set Presentation page tp appPage pageURL = appInfo.page; } else { Response.Redirect("AccessDenied.aspx?text=Unable+to+launch++application,+please+notify+your+administrator.", true); } } else { // An existing Experiment task = dbManager.GetTask(expID, sbStr); if (task.Status == LabTask.eStatus.Scheduled) { pageURL = appInfo.appURL; } else if (task.Status == LabTask.eStatus.Running) { pageURL = ProcessAgentDB.ServiceAgent.codeBaseUrl + @"/BEEgraph.aspx"; } else if (task.Status == LabTask.eStatus.Aborted || task.Status == LabTask.eStatus.Closed || task.Status == LabTask.eStatus.Completed || task.Status == LabTask.eStatus.Expired) { Response.Redirect("AccessDenied.aspx?text=The+requested+experiment+is+no+longer+running.", true); } } } if (pageURL != null && pageURL.Length > 0) { StringBuilder buf = new StringBuilder(pageURL + "?expid=" + expID); Session["opCouponID"] = coupon_Id; Session["opPasscode"] = passkey; Session["opIssuer"] = issuerGUID; buf.Append("&coupon_id=" + coupon_Id); buf.Append("&passkey=" + passkey); buf.Append("&issuer_guid=" + issuerGUID); buf.Append("&sb_url=" + returnTarget); if(expLen != null && expLen.Length > 0) buf.Append("&explen=" + expLen); //if (useTaskDuration) //{ // TimeSpan taskDur = task.endTime.Subtract(DateTime.UtcNow); // int hours = Convert.ToInt32(taskDur.TotalHours); // buf.Append("&explen=" + hours); //} Response.Redirect(buf.ToString(), true); } else { Response.Redirect("AccessDenied.aspx?text=Unable+to+launch++application,+please+notify+your+administrator.", true); } } }