Ejemplo n.º 1
0
        public Session(APISession apiSession)
        {
            Spectrums = new List <Spectrum>();
            Clear();

            IPAddress   = apiSession.IPAddress;
            Name        = apiSession.Name;
            SessionFile = "";
            Comment     = apiSession.Comment;
            Livetime    = (float)apiSession.Livetime;
            Detector    = JsonConvert.DeserializeObject <Detector>(apiSession.DetectorData);
        }
Ejemplo n.º 2
0
        private void btnOk_Click(object sender, EventArgs e)
        {
            if (gridSessions.SelectedRows.Count < 1)
            {
                MessageBox.Show("You must select a session first");
                return;
            }

            string name      = gridSessions.SelectedRows[0].Cells["ColumnName"].Value.ToString();
            int    specCount = Convert.ToInt32(gridSessions.SelectedRows[0].Cells["ColumnSpectrumCount"].Value);

            string url      = tbAddress.Text.Trim();
            string username = tbUsername.Text.Trim();
            string password = tbPassword.Text;

            HttpWebRequest request     = (HttpWebRequest)WebRequest.Create(url + "/sessions/" + name);
            string         credentials = Convert.ToBase64String(ASCIIEncoding.ASCII.GetBytes(username + ":" + password));

            request.Headers.Add("Authorization", "Basic " + credentials);
            request.Timeout = 20000;
            request.Method  = WebRequestMethods.Http.Get;
            request.Accept  = "application/json";

            string         data;
            HttpStatusCode code = Utils.GetResponseData(request, out data);

            if (code != HttpStatusCode.OK)
            {
                lblStatus.Text = code.ToString() + ": " + data;
                return;
            }

            SelectedSession       = JsonConvert.DeserializeObject <APISession>(data);
            SelectedSpectrumCount = specCount;

            DialogResult = DialogResult.OK;
            Close();
        }