public string CSVExport(int moduleID, string resourceFile, Separator separator, TextQualifier textQualifier) { StringBuilder csvBuilder = new StringBuilder(); csvBuilder.Append(string.Format("{0}SurveyID{0}{1}{0}Question{0}{1}{0}Question Type{0}{1}{0}Statistical{0}{1}{0}Answer{0}{1}{0}Votes{0}{1}{0}Correct Answer{0}{1}{0}UserID{0}{1}{0}IP Address{0}{1}{0}GUID{0}{1}{0}Date{0}\r\n", GetTextQualifierCharacter(textQualifier), GetSeparatorCharacter(separator))); List <SurveysExportInfo> surveys = SurveysExportController.GetAll(moduleID); foreach (SurveysExportInfo survey in surveys) { csvBuilder.Append(string.Format("{0}{2}{0}{1}{0}{3}{0}{1}{0}{4}{0}{1}{0}{5}{0}{1}{0}{6}{0}{1}{0}{7}{0}{1}{0}{8}{0}{1}{0}{9}{0}{1}{0}{10}{0}{1}{0}{11}{0}{1}{0}{12:yyyy-MM-dd hh:mm:ss}{0}\r\n", GetTextQualifierCharacter(textQualifier), GetSeparatorCharacter(separator), survey.SurveyID, survey.Question, Localization.GetString(string.Format("QuestionType.{0}.Text", Enum.GetName(typeof(QuestionType), survey.OptionType), resourceFile)), survey.IsStatistical, (survey.OptionType == QuestionType.Text ? EscapeTextQualifier(survey.TextAnswer, textQualifier) : survey.OptionName), survey.Votes, survey.IsCorrect, survey.UserID, survey.IPAddress, survey.ResultUserID, survey.CreatedDate)); } return(csvBuilder.ToString()); }
public string CSVExport(int moduleID, string resourceFile) { StringBuilder csvBuilder = new StringBuilder(); csvBuilder.Append("SurveyID; Question; Question Type; Statistical; Answer; Votes; Correct Answer; UserID; IP Address; GUID; Date\r\n"); List <SurveysExportInfo> surveys = SurveysExportController.GetAll(moduleID); foreach (SurveysExportInfo survey in surveys) { csvBuilder.Append(string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10:yyyy-MM-dd hh:mm:ss}\r\n", survey.SurveyID, survey.Question, Localization.GetString(string.Format("QuestionType.{0}.Text", Enum.GetName(typeof(QuestionType), survey.OptionType), resourceFile)), survey.IsStatistical, (survey.OptionType == QuestionType.Text ? survey.TextAnswer : survey.OptionName), survey.Votes, survey.IsCorrect, survey.UserID, survey.IPAddress, survey.ResultUserID, survey.CreatedDate)); } return(csvBuilder.ToString()); }