private void api_processorganisations(object sender, DownloadStringCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { string json = (string)e.Result; ResponseOrganisationalUnits.OrganisationResponse Results = JsonConvert.DeserializeObject <ResponseOrganisationalUnits.OrganisationResponse>(json); mainForm.ClearOrganisations(); foreach (ResponseOrganisationalUnits.Item organisation in Results.items) { String OrgName = organisation.name[0].value; String OrgUUID = organisation.uuid; String OrgType = organisation.type[0].value; String OrgParent = ""; if (organisation.parents != null) { OrgParent = organisation.parents[0].uuid; } mainForm.AddOrganisation(OrgName, OrgUUID, OrgType, OrgParent); mainForm.AddOrganisationTree(OrgName, OrgUUID, OrgType, OrgParent); } mainForm.refreshOrganisationTree(); } else if (e.Cancelled) { mainForm.ShowMessage("cancelled"); mainForm.ResetRefreshButton(); } else if (e.Error != null) { mainForm.ShowMessage(e.Error.ToString()); mainForm.Debug("response", e.Error.ToString()); mainForm.ResetRefreshButton(); } mainForm.ProgressBar(false); }
private void api_countorganisations(object sender, DownloadStringCompletedEventArgs e) { if (!e.Cancelled && e.Error == null) { string json = (string)e.Result; ResponseOrganisationalUnits.OrganisationResponse Results = JsonConvert.DeserializeObject <ResponseOrganisationalUnits.OrganisationResponse>(json); var RequestURL = Properties.Settings.Default.WebserviceURL + Properties.Settings.Default.APIVersion + "/organisational-units?locale=en_GB&linkingStrategy=documentLinkingStrategy&pageSize=" + Results.count.ToString(); DoWebRequest(RequestURL, "api_processorganisations", "Get", null, "json"); } else if (e.Cancelled) { mainForm.ShowMessage("cancelled"); mainForm.ResetRefreshButton(); mainForm.ProgressBar(false); } else if (e.Error != null) { mainForm.ShowMessage(e.Error.ToString()); mainForm.Debug("response", e.Error.ToString()); mainForm.ResetRefreshButton(); mainForm.ProgressBar(false); } }