Exemplo n.º 1
0
        public string GenerateExportFile(string exportType, DataTable dtExportData, ExportModel exportObj, List <string[]> columnInfo)
        {
            string fileName = exportObj.fileName;

            //IdentityAnalogue ia = new IdentityAnalogue();
            try
            {
                string xlsFileName = exportObj.xlsFileName;
                string csvFileName = exportObj.csvFileName;
                string zipFileName = exportObj.zipFileName;

                switch (exportType)
                {
                case "EXCEL":
                    ExportExcel(xlsFileName, dtExportData, columnInfo);
                    fileName += ".xls";
                    break;

                case "CSV":
                    ExportCsv(csvFileName, dtExportData, columnInfo);
                    fileName += ".csv";
                    break;

                case "CSV COMPRESS":
                    ExportCsvCompress(zipFileName, csvFileName, dtExportData, columnInfo);
                    fileName += ".zip";
                    break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(fileName);
        }
Exemplo n.º 2
0
        public string GenerateExportFile(string exportType, DataTable dtExportData, ExportModel exportObj, Hashtable columnInfo)
        {
            string fileName = exportObj.fileName;

            //IdentityAnalogue ia = new IdentityAnalogue();
            try
            {
                //string userName = ConfigurationManager.AppSettings["ImpersonateUserName"];
                //string password = ConfigurationManager.AppSettings["ImpersonatePassWord"];
                //if (ia.ImpersonateValidUser(userName, "", password))
                //{
                string xlsFileName = exportObj.xlsFileName;
                string csvFileName = exportObj.csvFileName;
                string zipFileName = exportObj.zipFileName;

                //if (!Directory.Exists(exportObj.virtualPath))
                //{
                //    Directory.CreateDirectory(exportObj.virtualPath);
                //}

                switch (exportType)
                {
                case "EXCEL":
                    ExportExcel(xlsFileName, dtExportData, columnInfo);
                    fileName += ".xls";
                    break;

                case "CSV":
                    ExportCsv(csvFileName, dtExportData, columnInfo);
                    fileName += ".csv";
                    break;

                case "CSV COMPRESS":
                    ExportCsvCompress(zipFileName, csvFileName, dtExportData, columnInfo);
                    fileName += ".zip";
                    break;
                }
                //}
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(fileName);
        }