Beispiel #1
0
 private void stopBtn_Click(object sender, System.EventArgs e)
 {
     if (sessionData != null && sessionData.SessionState != SessionData.SessionStates.Stopped)
     {
         sessionData.Stop();
         sessions.Add(sessionData);
         if (Globals.UserId > -1)
         {
             _ = Extensions.HttpPostAsync(Properties.Settings.Default.logSessionRequestUri, new Dictionary <string, string>()
             {
                 { "userId", Globals.UserId.ToString() },
                 { "session", JsonConvert.SerializeObject(sessionData) }
             });
         }
         if (statisticsForm != null)
         {
             statisticsForm.RefreshData(sessions);
         }
     }
 }
Beispiel #2
0
        private async void LoginBtn_Click(object sender, EventArgs e)
        {
            using (var form = new LoginForm())
            {
                var result = form.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    loginBtn.Hide();
                    tasksComboBox.Show();
                    Globals.UserId = form.UserId;
                    var responseJson = await Extensions.HttpPostAsync(Properties.Settings.Default.getTasksRequestUri, new Dictionary <string, string>()
                    {
                        { "userId", Globals.UserId.ToString() }
                    });

                    if (!String.IsNullOrWhiteSpace(responseJson))
                    {
                        var tasks = JsonConvert.DeserializeObject <List <HttpResponses.TaskResponse> >(responseJson);
                        foreach (var task in tasks)
                        {
                            tasksComboBox.Items.Add(task.title);
                        }
                        if (tasksComboBox.Items.Count > 0)
                        {
                            tasksComboBox.SelectedIndex = 0;
                        }
                    }

                    responseJson = await Extensions.HttpPostAsync(Properties.Settings.Default.getSessionsRequestUri, new Dictionary <string, string>()
                    {
                        { "userId", Globals.UserId.ToString() }
                    });

                    if (!String.IsNullOrWhiteSpace(responseJson))
                    {
                        sessions = JsonConvert.DeserializeObject <List <SessionData> >(responseJson);
                        statisticsForm?.RefreshData(sessions);
                    }
                }
            }
        }