private void APISave()
        {
            var functions = new codeResources.functions();

            try
            {
                jsonSaveResponse = functions.APIRequest("PUT", savePOSTdata, "user/" + storage.userID + "/summary/" + response.contents[response.contents.FindIndex(x => x.workspaceID == storage.currentWorkspaceID && x.summaryNumber == summaryNumber)].ID);
            }
            catch
            {
                // Work arround if the user is trying to save a summary with a different number on a date that is already in-use
                jsonSaveResponse = functions.APIRequest("PUT", savePOSTdata, "user/" + storage.userID + "/summary/" + response.contents[response.contents.FindIndex(x => x.workspaceID == storage.currentWorkspaceID && x.date == dateBox.Value.ToString("yyyy-MM-dd"))].ID);
            }
        }
Example #2
0
        private void checkConnection()
        {
            var functions = new codeResources.functions();

            if (functions.CheckForInternetConnection(storage.inUseDomain))
            {
                POSTdata     = "oldpasswd=" + functions.Hash(currentPasswordBox.Text) + "&newpasswd=" + functions.Hash(newPasswordBox.Text);
                jsonResponse = functions.APIRequest("PUT", POSTdata, "user/" + storage.userID + "/changepassword");
            }
            else
            {
                shouldAbort = true;
                MessageBox.Show(GlobalStrings.ConnectionToServerLost, GlobalStrings.ConnectionLost, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public Document CreateDocument(int workspaceID)
        {
            try
            {
                workspaceResponse = JsonConvert.DeserializeObject <workspaceServerResponse>(func.APIRequest("GET", null, "workspace/" + workspaceID));
                if (workspaceResponse.status)
                {
                    if (workspaceResponse.contents[0].hours != null)
                    {
                        userResponse = JsonConvert.DeserializeObject <userServerResponse>(func.APIRequest("GET", null, "user"));
                        if (userResponse.status)
                        {
                            classResponse = JsonConvert.DeserializeObject <classServerResponse>(func.APIRequest("GET", null, "class"));
                            if (classResponse.status)
                            {
                                workspaceHoursResponse = JsonConvert.DeserializeObject <workspaceHoursServerResponse>(func.APIRequest("GET", null, "workspace/" + workspaceID + "/summarizedHours"));
                                if (workspaceHoursResponse.status)
                                {
                                    // Create a new MigraDoc document.
                                    _document             = new Document();
                                    _document.Info.Title  = GenerateReportStrings.DocumentType + " - " + workspaceResponse.contents[0].workspaceName;
                                    _document.Info.Author = storage.displayName + " (Summaries)";

                                    DefineStyles();

                                    foreach (hours item in workspaceResponse.contents[0].hours)
                                    {
                                        CreatePage(classResponse.contents[classResponse.contents.FindIndex(x => x.classID == item.classID)].className);
                                        FillContent(item.classID);
                                    }

                                    return(_document);
                                }
                                else
                                {
                                    throw new Exception(GlobalStrings.Error + ": " + workspaceHoursResponse.errors);
                                }
                            }
                            else
                            {
                                throw new Exception(GlobalStrings.Error + ": " + classResponse.errors);
                            }
                        }
                        else
                        {
                            throw new Exception(GlobalStrings.Error + ": " + userResponse.errors);
                        }
                    }
                    else
                    {
                        throw new Exception(GlobalStrings.Error + ": " + GenerateReportStrings.NoClassesAssociated);
                    }
                }
                else
                {
                    throw new Exception(GlobalStrings.Error + ": " + workspaceResponse.errors);
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message + "\n" + ex.StackTrace, ex.InnerException);
            }
        }
        private void APICreateSummary()
        {
            var functions = new codeResources.functions();

            jsonSaveResponse = functions.APIRequest("POST", savePOSTdata, "user/" + storage.userID + "/workspace/" + storage.currentWorkspaceID + "/summary");
        }