EchoTex_Payroll/HRM.DA/Service/Common/NewRegularDataUploadService.cs
2024-10-14 10:01:49 +06:00

111 lines
3.3 KiB
C#

//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using Ease.CoreV35.Model;
//
//using System.Data;
//using System.Data.OleDb;
//using System.IO;
//using Ease.Excel;
//using Ease.Excel.Reader;
//namespace Payroll.Service
//{
//
// public class NewRegularDataUploadService : ServiceTemplate, IRegularDataUploadService
// {
// public NewRegularDataUploadService()
// { }
// #region Service Implementation
// public DataTable LoadData(string fileName, string sheetName)
// {
// DataTable dt = new DataTable(sheetName);
// try
// {
// using (FileStream fs = new FileStream(fileName, FileMode.Open))
// {
// XlsReader reader = new XlsReader(fs, true);
// dt = reader.Data.Tables[0].Copy();
// fs.Close();
// fs.Dispose();
// reader = null;
// }
// }
// catch (Exception e)
// {
// throw new ServiceException(e.Message, e);
// }
// return dt;
// }
// public DataTable LoadData(string fileName)
// {
// DataTable dt = new DataTable(fileName);
// try
// {
// using (FileStream fs = new FileStream(fileName, FileMode.Open))
// {
// XlsReader reader = new XlsReader(fs, true);
// dt = reader.Data.Tables[0].Copy();
// fs.Close();
// fs.Dispose();
// reader = null;
// }
// }
// catch (Exception e)
// {
// throw new ServiceException(e.Message, e);
// }
// return dt;
// }
// public DataTable LoadExcelData(string fileName, string sheetName)
// {
// string connectionString = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;", fileName);
// DataTable dt = new DataTable(sheetName);
// try
// {
// OleDbConnection connection = new OleDbConnection(connectionString);
// connection.Open();
// DataTable excelTable = connection.GetSchema("Tables");
// string tableName;
// if (excelTable.Rows.Count > 0)
// {
// tableName = Convert.ToString(excelTable.Rows[0]["TABLE_NAME"]);
// OleDbDataAdapter dataAdapter = new OleDbDataAdapter(string.Format("SELECT DISTINCT* FROM [{0}]", sheetName + "$"), connection);
// dataAdapter.Fill(dt);
// dataAdapter = null;
// }
// connection.Close();
// connection = null;
// }
// catch (Exception ex)
// {
// throw new Exception(ex.Message);
// }
// return dt;
// }
// #endregion
// protected override T CreateObject<T>(Ease.CoreV35.DataAccess.DataReader dr)
// {
// throw new NotImplementedException();
// }
// }
//}