Beispiel #1
0
        private void SurveyActions_Click(object sender, ActionEventArgs e)
        {
            switch (e.Action.CommandName)
            {
            case "DeleteResults":
                if (e.Action.CommandArgument == "Delete")
                {
                    SurveyResultsController.DropAll(ModuleId);
                    ModuleController.Instance.UpdateModuleSetting(ModuleId, "ResultsVersion", (ResultsVersion + 1).ToString());
                }
                break;

            case "ExportToCsv":
                try
                {
                    string csv = SurveyBusinessController.CSVExport(ModuleId, Localization.SharedResourceFile, Separator, TextQualifier);
                    Response.Clear();
                    Response.Charset = string.Empty;
                    Response.AddHeader("content-disposition", string.Format("attachment; filename=Survey_Results_{0}_{1:yyyy-MM-dd-hhmmss}.csv", ModuleId, DateTime.Now));
                    Response.ContentType = "application/octet-stream";
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    StringWriter   stringWriter   = new StringWriter();
                    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);
                    stringWriter.Write(csv);
                    Response.Write(stringWriter.ToString());
                    Response.End();
                }
                catch (Exception ex)
                {
                    Exceptions.ProcessModuleLoadException(this, ex);
                }
                break;

            default:
                break;
            }
        }