Ejemplo n.º 1
0
        public void ExportToFileCsv()
        {
            Response.Clear();
            var query = eqService.GetQuery();

            if (!query.IsEmpty)
            {
                var sql = eqService.BuildQuery(query);
                eqService.Paging.Enabled = false;
                DataSet dataset = eqService.GetDataSetBySql(sql);
                if (dataset != null)
                {
                    Response.ContentType = "text/csv";
                    Response.AddHeader("Content-Disposition",
                                       string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncode("report.csv")));
                    DbExport.ExportToCsv(dataset, Response.Output, CsvFormats.Default);
                }
                else
                {
                    ErrorResponse("Empty dataset");
                }
            }
            else
            {
                ErrorResponse("Empty query");
            }
        }
Ejemplo n.º 2
0
        public void ExportToFileExcel()
        {
            Response.Clear();
            var query = _eqService.GetQuery();

            if (!query.IsEmpty)
            {
                var sql = _eqService.BuildQuery(query);
                _eqService.Paging.Enabled = false;
                var dataset = _eqService.GetDataSetBySql(sql);
                if (dataset != null)
                {
                    Response.ContentType = "application/vnd.ms-excel";
                    Response.AddHeader("Content-Disposition",
                                       string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncode("report.xls")));
                    DbExport.ExportToExcelHtml(dataset, Response.Output, ExcelFormats.Default);
                }
                else
                {
                    ErrorResponse("Empty dataset");
                }
            }
            else
            {
                ErrorResponse("Empty query");
            }
        }
Ejemplo n.º 3
0
        public void Purge()
        {
            // Очистка экспортированного чертежа от блоков образмеривания которые были удалены из панелей после копирования
            ObjectIdGraph graph = new ObjectIdGraph();

            foreach (var panelBtr in PanelsBtrExport)
            {
                ObjectIdGraphNode node = new ObjectIdGraphNode(panelBtr.IdBtrExport);
                graph.AddNode(node);
            }
            DbExport.Purge(graph);
        }
    protected void ExportResultToCSV(string fileName)
    {
        ResultDS.SelectCommand = SqlTextBox.Text;
        DataView view = (DataView)ResultDS.Select(DataSourceSelectArguments.Empty);

        if (view == null)
        {
            return;
        }
        Response.Clear();
        Response.ContentType = "text/csv";
        Response.AddHeader("Content-Disposition",
                           string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncodeUnicode(fileName)));
        DbExport.ExportToCsv(view.Table, Response.Output, CsvFormats.Default);
        Response.End();
    }
    protected void ExportResultToExcel(string fileName)
    {
        ResultDS.SelectCommand = SqlTextBox.Text;
        DataView view = (DataView)ResultDS.Select(DataSourceSelectArguments.Empty);

        if (view == null)
        {
            return;
        }
        this.EnableViewState = false;
        Response.Clear();
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition",
                           string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncodeUnicode(fileName)));
        DbExport.ExportToExcelHtml(view.Table, Response.Output, ExcelFormats.Default);
        Response.End();
    }
Ejemplo n.º 6
0
        /// <summary>
        /// Writes information to CSV file.
        /// </summary>
        /// <returns></returns>
        private void ExportToFileCsv(string sql)
        {
            HttpContext.Response.Clear();

            if (!string.IsNullOrEmpty(sql))
            {
                using (var connection = eqService.ConnectionResolver()){
                    connection.Open();
                    var command = connection.CreateCommand();

                    command.CommandText = sql;
                    command.CommandType = CommandType.Text;

                    var dataset = command.ExecuteReader();

                    if (dataset != null)
                    {
                        HttpContext.Response.ContentType = "text/csv";;
                        HttpContext.Response.Headers.Add("Content-Disposition",
                                                         string.Format("attachment; filename=\"{0}\"", UrlEncoder.Default.Encode("report.csv")));
                        StreamWriter dataStream = new StreamWriter(HttpContext.Response.Body);
                        DbExport.ExportToCsv(dataset, dataStream, CsvFormats.Default);
                    }
                    else
                    {
                        ErrorResponse("Empty dataset");
                    }

                    eqService.ConnectionResolver().Close();
                }
            }
            else
            {
                ErrorResponse("Empty query");
            }
        }
Ejemplo n.º 7
0
		private void OnItemChanged(DataRowView rowView, DbExport.Common.Interfaces.Status status)
		{
			rowView.Delete();
		}