public async Task <ActionResult> Import(IFormFile file) { // The Import is commented out. // remove [System.Diagnostics.CodeAnalysis.SuppressMessage("Await.Warning", "CS1998:Await.Warning")] // if you make it working // or remove async to make this method sync method ViewBag.FileFormat = "Host"; //log.Info(string.Format("{0}: Import", Framework.Models.LoggingOptions.UI_Process_Started.ToString())); var dataStreamServiceResult = new Framework.Models.DataStreamServiceResult(file.FileName, file.ContentType, file.Length, file.OpenReadStream()); //dataStreamServiceResult.TempFilePath = Framework.Mvc.WebFormApplicationApplicationVariables.FileStorageRootFolder; var dataStreamServiceProvider = new Elmah.CoreCommonBLL.ElmahHostDataStreamService(); var collection = dataStreamServiceProvider.GetCollectionFromStream(dataStreamServiceResult); if (collection != null) { //var resultCollection = collection; //var result = Elmah.WcfContracts.IElmahHostService.BatchInsert(resultCollection); //ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_Success; } else { ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_NoRecordInSourceFile; } //log.Info(string.Format("{0}: Import", Framework.Models.LoggingOptions.UI_Process_Ended.ToString())); return(View()); }
public Framework.Models.DataStreamServiceResult BuildResult(TCollection input, Framework.Models.DataServiceTypes dataServiceType) { /* * if (dataServiceType == Framework.Models.DataServiceTypes.Csv) * { * Framework.Models.DataStreamServiceResult result = new Framework.Models.DataStreamServiceResult * { * DataServiceType = dataServiceType, * MIMEType = "text/csv", * FileExtension = ".csv" * }; * result.Result = BuildStreamOfLinqToCsv(input); * return result; * } * else */ if (dataServiceType == Framework.Models.DataServiceTypes.Excel2010) { Framework.Models.DataStreamServiceResult result = new Framework.Models.DataStreamServiceResult { DataServiceType = dataServiceType, MIMEType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", FileExtension = ".xlsx" }; result.Result = BuildStreamOfCloseXmlExcel2010(input); return(result); } else { throw new Exception(string.Format("Service Not Provided: {0}", dataServiceType)); } }
public async Task <ActionResult> Import(IFormFile file) { // The Import is commented out. // remove [System.Diagnostics.CodeAnalysis.SuppressMessage("Await.Warning", "CS1998:Await.Warning")] // if you make it working // or remove async to make this method sync method ViewBag.FileFormat = "ElmahApplication_Name,ErrorId,ElmahHost_Name,ElmahSource_Name,ElmahStatusCode_Name,ElmahType_Name,ElmahUser_Name,Application,Host,Type,Source,Message,User,StatusCode,TimeUtc,Sequence,AllXml"; //log.Info(string.Format("{0}: Import", Framework.Models.LoggingOptions.UI_Process_Started.ToString())); var dataStreamServiceResult = new Framework.Models.DataStreamServiceResult(file.FileName, file.ContentType, file.Length, file.OpenReadStream()); //dataStreamServiceResult.TempFilePath = Framework.Mvc.WebFormApplicationApplicationVariables.FileStorageRootFolder; var dataStreamServiceProvider = new Elmah.CoreCommonBLL.ELMAH_ErrorDataStreamService.Default(); var collection = dataStreamServiceProvider.GetCollectionFromStream(dataStreamServiceResult); if (collection != null) { //var resultCollection = new Elmah.DataSourceEntities.ELMAH_ErrorCollection(); //.CopyCollection<Elmah.DataSourceEntities.ELMAH_Error.DefaultCollection, Elmah.DataSourceEntities.ELMAH_ErrorCollection, Elmah.DataSourceEntities.ELMAH_Error.Default, Elmah.DataSourceEntities.ELMAH_Error>(collection, resultCollection); //var result = await Elmah.WcfContracts.IELMAH_ErrorService.BatchInsert(resultCollection); //ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_Success; } else { ViewBag.Message = Framework.Resx.UIStringResource.Data_Import_NoRecordInSourceFile; } //log.Info(string.Format("{0}: Import", Framework.Models.LoggingOptions.UI_Process_Ended.ToString())); return(View()); }
public TCollection GetCollectionFromStream(Framework.Models.DataStreamServiceResult input) { return(null); /* * TCollection collection; * if (input.DataServiceType == Framework.Models.DataServiceTypes.Csv) * { * collection = Framework.Services.LinqToCsvHelper.ReadFromStream<TCollection, TItem>(input.Result); * } * else * if (input.DataServiceType == Framework.Models.DataServiceTypes.Excel2010) * { * collection = Framework.Services.LinqToExcelHelper.Read<TCollection, TItem>(input); * } * else * { * collection = null; * } * * return collection; */ }