Esempio n. 1
0
        /// <summary>
        /// Выбор файла для передачи
        /// </summary>
        /// <param name="path">Путь к файлу</param>
        /// <param name="filename">Имя файла</param>
        /// <param name="conectionstring">Строка соединения с БД для формирования таблицы</param>
        /// <returns></returns>
        public async Task <Stream> SelectDonloadsFile(string path, string filename, string conectionstring = null, DataSet dataSet = null)
        {
            var sqlconnect = new SqlConnectionType();
            var xlsx       = new ReportExcel();

            switch (filename)
            {
            case "Требования.xlsx":
                if (File.Exists(Path.Combine(path, filename)))
                {
                    return
                        (await Task.Factory.StartNew <Stream>(
                             () => DonloadFile(Path.Combine(path, filename))));
                }
                return(null);

            case "Бдк.xlsx":
                xlsx.ReportSave(path, "Бдк", "Бдк", sqlconnect.ReportQbe(conectionstring, ((ServiceWcf)sqlconnect.SelectFullParametrSqlReader(conectionstring, ModelSqlFullService.ProcedureSelectParametr, typeof(ServiceWcf), ModelSqlFullService.ParamCommand("6"))).ServiceWcfCommand.Command));
                if (File.Exists(Path.Combine(path, filename)))
                {
                    return
                        (await Task.Factory.StartNew <Stream>(
                             () => DonloadFile(Path.Combine(path, filename))));
                }
                xlsx.Dispose();
                return(null);

            case "Истребование.xlsx":
                xlsx.ReportSave(path, "Истребование", "Не доделки по документам", sqlconnect.ReportQbe(conectionstring, ((ServiceWcf)sqlconnect.SelectFullParametrSqlReader(conectionstring, ModelSqlFullService.ProcedureSelectParametr, typeof(ServiceWcf), ModelSqlFullService.ParamCommand("18"))).ServiceWcfCommand.Command));
                if (File.Exists(Path.Combine(path, filename)))
                {
                    return
                        (await Task.Factory.StartNew <Stream>(
                             () => DonloadFile(Path.Combine(path, filename))));
                }
                xlsx.Dispose();
                return(null);

            case "Камеральный №5.xlsx":
                xlsx.ReportSave(path, "Камеральный №5", "Отчет", dataSet);
                if (File.Exists(Path.Combine(path, filename)))
                {
                    return
                        (await Task.Factory.StartNew <Stream>(
                             () => DonloadFile(Path.Combine(path, filename))));
                }
                xlsx.Dispose();
                return(null);

            default:
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Запрос на выгрузку данных в таблицу XLSX по заданной выборки View
        /// </summary>
        /// <param name="sqlSelect">Sql запрос</param>
        /// <param name="nameFile">Наименование файла</param>
        /// <param name="nameReport">Наименование отчета</param>
        /// <param name="pathSaveReport">Путь сохранения отчета</param>
        /// <returns></returns>
        public Stream GenerateStreamToSqlViewFile(string sqlSelect, string nameFile, string nameReport, string pathSaveReport)
        {
            var sqlConnect     = new SqlConnectionType();
            var xlsx           = new ReportExcel();
            var tableTelephone = sqlConnect.ReportQbe(ConnectionString, sqlSelect);

            xlsx.ReportSave(pathSaveReport, nameFile, nameReport, tableTelephone);
            return(xlsx.DownloadFile(Path.Combine(pathSaveReport, $"{nameFile}.xlsx")));
        }
        /// <summary>
        /// Отчет для СТО выгрузка
        /// </summary>
        /// <param name="pathSaveReport">Путь сохранения</param>
        /// <param name="analysisEpo">Выбранный анализ</param>
        /// <returns></returns>
        private byte[] CreateReportEpo(string pathSaveReport, AnalysisEpoAndInventarka analysisEpo)
        {
            var xlsx           = new ReportExcel();
            var sqlConnect     = new SqlConnectionType();
            var reportAnalysis = sqlConnect.ReportQbe(ConnectionString, analysisEpo.ViewReport);

            xlsx.ReportAddListFile(analysisEpo.NameListXlsx, reportAnalysis);
            Dispose(true);
            xlsx.SaveAsFileXlsx(Path.Combine(pathSaveReport, analysisEpo.NameFileXlsx));
            return(xlsx.ReadFileByte(Path.Combine(pathSaveReport, analysisEpo.NameFileXlsx)));
        }
        /// <summary>
        /// Полный анализ данных ЭПО с инвентаризацией запросы можно расширять
        /// </summary>
        /// <param name="pathSaveReport"></param>
        /// <param name="idReport">Уникальные номера отчетов ЭПО</param>
        /// <returns></returns>
        public Stream CreateFullReportEpo(string pathSaveReport, int[] idReport)
        {
            var xlsx          = new ReportExcel();
            var sqlConnect    = new SqlConnectionType();
            var modelsReports = Inventory.AnalysisEpoAndInventarkas.Where(id => idReport.Contains(id.Id));

            foreach (var modelReport in modelsReports)
            {
                var reportAnalysis = sqlConnect.ReportQbe(ConnectionString, modelReport.ViewReport);
                xlsx.ReportAddListFile(modelReport.NameListXlsx, reportAnalysis);
            }
            Dispose(true);
            xlsx.SaveAsFileXlsx(Path.Combine(pathSaveReport, "Полный анализ данных.xlsx"));
            return(xlsx.DownloadFile(Path.Combine(pathSaveReport, "Полный анализ данных.xlsx")));
        }