public List <string> GetTableNames() { List <string> names = new List <string>(); Epi.SurveyManagerServiceV4.SurveyInfoResponse Response = new Epi.SurveyManagerServiceV4.SurveyInfoResponse(); try { var Client = Epi.Core.ServiceClient.ServiceClient.GetClientV4(); Response = Client.GetAllSurveysByOrgKey(OrgId.ToString()); } catch (Exception ex) { WebSurveyOptions dialog1 = new WebSurveyOptions(); DialogResult result1 = dialog1.ShowDialog(); if (result1 == System.Windows.Forms.DialogResult.OK) { var Client = Epi.Core.ServiceClient.ServiceClient.GetClientV4(); Response = Client.GetAllSurveysByOrgKey(OrgId.ToString()); } } // List<SurveyManagerServiceV4.SurveyInfoDTO> DTOList = Response.SurveyInfoList.OrderBy(o => o.SurveyName).ToList(); foreach (var items in Response.SurveyInfoList) { // names.Add(items.SurveyId + "_" + items.SurveyName); names.Add(items.SurveyName + "_" + items.SurveyId); } //if (expired) //{ // Epi.Windows.MsgBox.ShowError("Your certificate file has expired. Please ask your Epi Info administrator for a new certificate file."); // return names; //} //if (certInfo != null) //{ // using (SqlConnection connection = new SqlConnection(certInfo.ConnectionString)) // { // connection.Open(); // string commandString = "select o.Organization, m.SurveyId, m.SurveyName, m.DateCreated from surveymetadata m inner join organization o on m.OrganizationId = o.OrganizationId where o.OrganizationId = '" + certInfo.OrganizationId + "'"; // using (SqlCommand command = new SqlCommand(commandString, connection)) // { // using (SqlDataReader reader = command.ExecuteReader()) // { // while (reader.Read()) // { // string name = reader.GetFieldValue<string>(2) + " (" + reader.GetFieldValue<DateTime>(3) + ")" + " {{" + reader.GetFieldValue<Guid>(1) + "}}"; // names.Add(name); // } // } // } // } //} return(names); }
public async Task <DataTable> GetDataTableAsync(string collectionName) { DataTable dataTable = new DataTable("Table1"); if (expired) { return(dataTable); } var SurveyId = collectionName.Split('_').Last(); string json = ""; try { var Client = Epi.Core.ServiceClient.ServiceClient.GetClientV4(); json = Client.GetJsonResponseAll(SurveyId, "", ""); } catch (Exception ex) { WebSurveyOptions dialog1 = new WebSurveyOptions(); DialogResult result1 = dialog1.ShowDialog(); if (result1 == System.Windows.Forms.DialogResult.OK) { //OrgKey OrgKeyDialog = new OrgKey(this.CurrentView.WebSurveyId, false, SharedStrings.WEBFORM_ORG_KEY_SUCCESSFUL, SharedStrings.WEBFORM_ORG_KEY_REPUBLISH); //DialogResult result2 = OrgKeyDialog.ShowDialog(); //if (result2 == System.Windows.Forms.DialogResult.OK) //{ // this.OrganizationKey = OrgKeyDialog.OrganizationKey; // if (!string.IsNullOrWhiteSpace(OrganizationKey)) // { // SetSurveyInfo(); // QuickSurveyInfoUpdate(); // } //} } } var msg = JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(json); foreach (var item in msg) { dataTable = GetDataTableFromJson(dataTable, JsonConvert.SerializeObject(item));; } //string surveyId = collectionName.Substring(collectionName.IndexOf("{{") + 2, 36); //using (SqlConnection connection = new SqlConnection(certInfo.ConnectionString)) //{ // await connection.OpenAsync(); // string commandString = "select ResponseJson from SurveyResponse where ResponseJson is not null and surveyid = '" + surveyId + "'"; // using (SqlCommand command = new SqlCommand(commandString, connection)) // { // using (SqlDataReader reader = await command.ExecuteReaderAsync()) // { // while (await reader.ReadAsync()) // { // string json = reader.GetFieldValue<string>(0); // dataTable = GetDataTableFromJson(dataTable, json); // } // } // } //} return(dataTable); }