Ejemplo n.º 1
0
        private void APICalls()
        {
            var functions = new functions();

            if (functions.CheckForInternetConnection(storage.inUseDomain))
            {
                jsonWorkspace = functions.APIRequest("GET", null, "workspace");
                workspaces    = JsonConvert.DeserializeObject <workspacesServerResponse>(jsonWorkspace);
                // this should get all the user's summaries, independently of the workspace
                jsonResponse = functions.APIRequest("GET", null, "user/" + storage.userID + "/workspace/0/summary");
            }
            else
            {
                shouldAbortLoad = true;
                MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void deleteSummary_Click(object sender, EventArgs e)
        {
            if (workspaceResponse.contents[workspaceResponse.contents.FindIndex(x => x.workspaceName == workspaceName)].write)
            {
                try
                {
                    if (dataGrid.SelectedRows.Count > 0 || dataGrid.SelectedCells.Count > 0)
                    {
                        DialogResult boxResponse = MessageBox.Show(summariesListStrings.DeleteSummaryQuestion, summariesListStrings.DeleteSummary, MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (boxResponse == DialogResult.Yes)
                        {
                            int             selectedrowindex = dataGrid.SelectedCells[0].RowIndex;
                            DataGridViewRow selectedRow      = dataGrid.Rows[selectedrowindex];
                            int             selectedSummary  = Convert.ToInt32(selectedRow.Cells["summaryNumber"].Value);

                            string jsonResponse = functions.APIRequest("DELETE", null, "user/" + storage.userID + "/summary/" + response.contents[response.contents.FindIndex(x => x.summaryNumber == selectedSummary && x.workspaceID == storage.currentWorkspaceID)].ID);

                            simpleServerResponse serverResponse;

                            serverResponse = JsonConvert.DeserializeObject <simpleServerResponse>(jsonResponse);

                            if (serverResponse.status)
                            {
                                summariesList_Load(sender, e);
                            }
                            else
                            {
                                if (serverResponse.errors == null || serverResponse.errors.Length < 1)
                                {
                                    MessageBox.Show(summariesListStrings.RowNotExistLong, summariesListStrings.RowDoesNotExist, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                    summariesList_Load(sender, e);
                                }
                                else
                                {
                                    MessageBox.Show(GlobalStrings.Error + ": " + serverResponse.errors + "\n" + jsonResponse, GlobalStrings.CriticalError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    functions functions = new functions();
                    if (!functions.CheckForInternetConnection(storage.inUseDomain))
                    {
                        MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        MessageBox.Show(GlobalStrings.Error + ": " + ex.Message + "\n" + ex.StackTrace + "\n" + ex.Source, GlobalStrings.CriticalError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show(summariesListStrings.ReadOnlyWorkspace, summariesListStrings.ReadOnly, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 3
0
        private void getInformation()
        {
            var functions = new functions();

            if (functions.CheckForInternetConnection(storage.inUseDomain))
            {
                jsonResponse = functions.APIRequest("POST", POSTdata, "login");
            }
            else
            {
                shouldAbort = true;
                MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
        private void requestSummaryList()
        {
            var functions = new functions();

            if (functions.CheckForInternetConnection(storage.inUseDomain))
            {
                jsonResponse = functions.APIRequest("GET", null, "user/" + storage.userID + "/workspace/" + storage.currentWorkspaceID + "/summary");
            }
            else
            {
                shouldAbort = true;
                MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 5
0
        private void main_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                Directory.Delete(@"" + Path.GetTempPath() + "summariesTemp", true); // Deletes temp files
            }
            catch { }
            var functions = new functions();

            try
            {
                functions.APIRequest("GET", null, "logout");
            }
            catch { }
            Application.Exit();
        }
Ejemplo n.º 6
0
 public void getClass()
 {
     classRequest = functions.APIRequest("GET", null, "class");
 }
        public Document CreateDocument(int?userID = null, int?classID = null, int?workspaceID = null)
        {
            if (userID == null || classID == null || workspaceID == null)
            {
                userID        = storage.userID;
                classID       = storage.classID;
                classID_g     = storage.classID;
                workspaceID   = storage.currentWorkspaceID;
                studentName_g = storage.displayName;
            }
            else
            {
                if (userID < 1 || classID < 0 || workspaceID < 0)
                {
                    throw new Exception("The userID, classID and workspaceID parameters have to be greater than 0. No document was generated.");
                }
                else
                {
                    userResponse = JsonConvert.DeserializeObject <userServerResponse>(func.APIRequest("GET", null, "user/" + userID));
                    if (userResponse.status)
                    {
                        classID_g     = userResponse.contents[0].classID;
                        studentName_g = userResponse.contents[0].displayName;
                    }
                    else
                    {
                        throw new Exception(GlobalStrings.Error + ": " + userResponse.errors);
                    }
                }
            }

            try
            {
                summariesResponse = JsonConvert.DeserializeObject <summariesServerResponse>(func.APIRequest("GET", null, "user/" + userID + "/workspace/" + workspaceID + "/summary"));
                if (summariesResponse.status)
                {
                    classResponse = JsonConvert.DeserializeObject <classServerResponse>(func.APIRequest("GET", null, "class/" + classID));
                    if (classResponse.status)
                    {
                        workspaceResponse = JsonConvert.DeserializeObject <workspaceServerResponse>(func.APIRequest("GET", null, "workspace/" + workspaceID));
                        if (workspaceResponse.status)
                        {
                            // Create a new MigraDoc document.
                            _document             = new Document();
                            _document.Info.Title  = GenerateSummaryExportStrings.DocumentType + " - " + studentName_g;
                            _document.Info.Author = storage.displayName + " (Summaries)";

                            DefineStyles();
                            CreatePage();
                            FillContent();

                            return(_document);
                        }
                        else
                        {
                            throw new Exception(GlobalStrings.Error + ": " + workspaceResponse.errors);
                        }
                    }
                    else
                    {
                        throw new Exception(GlobalStrings.Error + ": " + classResponse.errors);
                    }
                }
                else
                {
                    throw new Exception(GlobalStrings.Error + ": " + summariesResponse.errors);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message, ex.InnerException);
            }
        }