private void BulkInsert(string UploadFilePath, string Instance) { try { DataAccessLayer.DataAccessLayer DBLayer = new DataAccessLayer.DataAccessLayer(); int MaxCnt = System.Convert.ToInt32(ConfigurationManager.AppSettings[BusinessConstants.UPLOAD_ROWS_CNT].ToString()); DataTable Dt = new DataTable(); Dt.Columns.Add(BusinessConstants.CONFIRMIT_CARD_NUMBER, typeof(long)); Dt.Columns.Add(BusinessConstants.CONFIRMIT_CLASS, typeof(string)); Dt.Columns.Add(BusinessConstants.CONFIRMIT_STATUS, typeof(string)); Dt.Columns.Add(BusinessConstants.CONFIRMIT_DATETIME, typeof(System.DateTime)); using (System.IO.StreamReader ReadFile = new System.IO.StreamReader(UploadFilePath)) { int CurIndex = 0; string line; while ((line = ReadFile.ReadLine()) != null) { string[] RowValues = line.Split(new char[] { ',' }); if (!string.IsNullOrEmpty(RowValues[0]) && !string.IsNullOrEmpty(RowValues[1]) && !string.IsNullOrEmpty(RowValues[2]) && !string.IsNullOrEmpty(RowValues[3])) { DataRow Dr = Dt.NewRow(); Dr[BusinessConstants.CONFIRMIT_CARD_NUMBER] = System.Convert.ToInt64(RowValues[0]); Dr[BusinessConstants.CONFIRMIT_CLASS] = RowValues[1].ToString(); Dr[BusinessConstants.CONFIRMIT_STATUS] = RowValues[2].ToString(); Dt.Rows.Add(Dr); } CurIndex++; if (CurIndex == MaxCnt || ReadFile.EndOfStream) { bool IsLastbatch = false; if (ReadFile.EndOfStream) { IsLastbatch = true; } SICTLogger.WriteWarning(UploadBusiness.CLASS_NAME, "BulkInsert", "Bulk Copy Initiated for current index" + CurIndex); DBLayer.BulkCopy(Dt, IsLastbatch); if (IsLastbatch) { DBLayer.OnSqlRowsCopied(null, null); } CurIndex = 0; Dt.Clear(); } } } Task.Factory.StartNew <ReturnValue>(() => new CacheFileBusiness().CreateCacheFileforTargetVsCompletesCharts(Instance)); } catch (System.Exception Ex) { SICTLogger.WriteException(UploadBusiness.CLASS_NAME, "BulkInsert", Ex); } }