Exemplo n.º 1
0
        public static void GeneratePendingRequestsCSV_MarkAsPaid_AndReturn(GridView gridview, bool markAsPaid = true)
        {
            string fileName = "PendingPayoutsRequestsExport_" + AppSettings.ServerTime.ToString("yyyy_MM_dd") + ".csv";

            try
            {
                string content = DBArchiverAPI.ExportToCSVString(
                    @"SELECT pr.PaymentAddress, pr.Amount, pr.Username, FORMAT(pr.RequestDate,'MM/dd/yyyy') AS [RequestDate], pr.PaymentProcessor FROM [PayoutRequests] AS pr " + GetPayoutRequestsSQLConditions() + " ORDER BY pr.[RequestDate] DESC");

                if (markAsPaid)
                {
                    MarkAllRequestsAsPaid();
                }

                HttpContext.Current.Response.Clear();
                HttpContext.Current.Response.Buffer = true;
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                HttpContext.Current.Response.Charset     = "";
                HttpContext.Current.Response.ContentType = "application/text";
                HttpContext.Current.Response.Output.Write(content);
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.End();
            }
            catch (Exception ex)
            {
                ErrorLogger.Log("Error while exporting CSV to file: " + ex.Message);
                throw new MsgException(ex.Message);
            }
        }
Exemplo n.º 2
0
    public static void GenerateAndReturn()
    {
        string fileName = "EmailExport_" + AppSettings.ServerTime.ToString("yyyy_MM_dd") + ".csv";

        try
        {
            string content = DBArchiverAPI.ExportToCSVString("SELECT firstname, secondname, username, email, country FROM users", false);

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Buffer = true;
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
            HttpContext.Current.Response.Charset     = "";
            HttpContext.Current.Response.ContentType = "application/text";
            HttpContext.Current.Response.Output.Write(content);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
        catch (Exception ex)
        {
            ErrorLogger.Log("Error while exporting CSV to file: " + ex.Message);
            throw new MsgException(ex.Message);
        }
    }