protected void Page_Load(object sender, EventArgs e) { HeaderActions.ActionPerformed += HeaderActions_ActionPerformed; MessagesWriter.ShowABTestScheduleInformation(ABTest, TestStatus); MessagesWriter.ShowMissingVariantsTranslationsWarning(ABTest); ScriptHelper.RegisterDialogScript(Page); InitializeSelectors(); InitSmartTip(); // Hide summary and table if the test has not been started yet if ((ABTest.ABTestOpenFrom > DateTime.Now) || (ABTest.ABTestOpenFrom == DateTimeHelper.ZERO_TIME)) { Summary.Visible = false; gridElem.Visible = false; return; } // Display test winner if there is one var winner = GetTestWinner(); if (winner != null) { DisplayWinnerInformation(winner); SetWinnerTooltip(); } EnsureVariantsStatisticsData(); if (DataAvailable()) { // Add class to the report because graph with data requires special positioning // Show all information after graph do postback if (RequestHelper.IsPostBack()) { Summary.Visible = true; gridElem.Visible = true; gridElem.GridView.AddCssClass("rows-middle-vertical-align"); // Hide NoDataFound panel pnlNoData.Visible = false; } } else { // Hide summary and table Summary.Visible = false; gridElem.Visible = false; // Show NoDataFound panel pnlNoData.Visible = true; return; } LoadSummaryBox(); InitializeGraph(); InitializeGrid(); SetImprovementColumnCaption(); ShowInvalidFilterCombinationImage(); }
/* * * The user needs to set a reference to HydraJsonClient project * He can open it as a project in the solution, and set a reference to it * or add a reference to HydraJsonClient.dll * * */ static void Main(string[] args) { /** * The following parameters should be gotten from args or extracted from "hyra.ini", but for simplicity, they are hard coded in this example */ int network_id = 2; // network id int [] scenario_ids = { 2 }; // scenarios ids string user_name = "root"; string password = ""; //user password string server_addrs = "http://127.0.0.1:8080/json/"; string sessionid = null; /* * if session id is provided, it will be used to connect to the server otherwsie, it will use user_name and password to connectto the server and get sessionid * */ // intialize hydraNetworkExporter class with connection parameters NetworkExporter hydraNetworkExporter = new NetworkExporter(server_addrs, user_name, password, sessionid); // export the network with its id and scenarioa ids Network network = hydraNetworkExporter.exportNetworkWithData(network_id, scenario_ids); //it returned an object of Network class which contains all the network components and data and the user has access to all of them MessagesWriter.writeMessage("\nNetwork: " + network.name + " is exported\nNo of nodes: " + network.nodes.Length + "\nNo of links: " + network.links.Length); }
/* * send request to Hydra server and receive the respond using string which represent function name and its arguments * */ public string callServer(string request) { string result = ""; try { httpWebRequest = (HttpWebRequest)WebRequest.Create(webAddr); httpWebRequest.KeepAlive = false; httpWebRequest.Timeout = System.Threading.Timeout.Infinite; httpWebRequest.ProtocolVersion = HttpVersion.Version10; httpWebRequest.Method = "POST"; addCookie(); httpWebRequest.Headers.Add("session_id", user.sessonid); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { streamWriter.Write(request); streamWriter.Flush(); } var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse(); if (cookies == null && string.IsNullOrEmpty(user.sessonid)) { this.getCokkie(httpResponse); } using (var streamReader = new StreamReader(httpResponse.GetResponseStream())) { result = streamReader.ReadToEnd(); } } catch (System.Net.WebException ex) { string errormessage = ""; try { using (var streamReader = new StreamReader(ex.Response.GetResponseStream())) { errormessage = streamReader.ReadToEnd(); MessagesWriter.writeErrorMessage(ex.Message + "\nDetailed server response: " + errormessage, "", ""); } } catch (System.NullReferenceException ex2) { MessagesWriter.writeErrorMessage("No connection can be established "); } } catch (System.NullReferenceException ex) { MessagesWriter.writeErrorMessage(ex.Message, "", ""); } catch (Exception ex) { MessagesWriter.writeErrorMessage(ex.Message, "", ""); } return(result); }
void getUser() { string res = callServer(user.getLoginParameters()); JavaScriptSerializer js = new JavaScriptSerializer(); try { MessagesWriter.writeMessage("res: " + res); hydra_user uses = js.Deserialize <hydra_user>(res); user.sessonid = uses.session_id; } catch (System.Exception ex) { } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Controls.Add(DocumentManager as CMSDocumentManager); MessagesWriter.ShowABTestScheduleInformation(ABTest, TestStatus); MessagesWriter.ShowMissingVariantsTranslationsWarning(ABTest); RegisterScripts(); InitializeSelectors(); SetSelectorValues(); EnsureVariantsStatisticsData(); // Display test winner if there is one var winner = GetTestWinner(); if (winner != null) { DisplayWinnerInformation(winner); } else { ShowPromoteWinnerInfoMessage(); } // Hide summary and table if the test has not been started yet if (ABTestStatusEvaluator.ABTestNotStarted(TestStatus)) { Filter.Visible = false; Report.Visible = false; Summary.Visible = false; } else if (DataAvailable(VariantsStatisticsData.Values, drpSuccessMetric.SelectedValue)) { // Show all information after graph do postback if (RequestHelper.IsPostBack()) { Summary.Visible = true; Report.Visible = true; // Hide NoDataFound panel pnlNoData.Visible = false; } } else { // -> Test is executed, but no results are present // Hide summary Summary.Visible = false; // Show report and NoDataFound panel Report.Visible = true; pnlNoData.Visible = true; } LoadSummaryBox(); InitializeGraph(); InitializeGrid(); SetImprovementColumnCaption(); ShowInvalidFilterCombinationWarning(); }