public override void UploadFile(HttpPostedFileBase file) { ValidationErrors.Clear(); ProcessExcelPreFlightErrorMessages(file); if (ValidationErrors.Count != 0 || file == null) { return; } try { using (var fileServiceClient = new NeonISGFileServiceClient(Configuration.ActiveNeonFileServiceEndpoint)) { UploadCode = Guid.NewGuid().ToString().Substring(0, 6); var fileSuffix = file.FileName.Split('.').FirstOrDefault(); var defaultYearQuarter = UploadCode; if (!string.IsNullOrEmpty(fileSuffix)) { defaultYearQuarter = (fileSuffix.Length >= 7) ? fileSuffix.Substring(0, 7) : fileSuffix; } var extraColumns = new List<WebDataColumnBuilder> { new WebDataColumnBuilder(false, "DataLoaderId", typeof (int), "0"), new WebDataColumnBuilder(false, "DataLoaderDate", typeof (DateTime), DateTime.Now.ToString(CultureInfo.CurrentCulture)), new WebDataColumnBuilder(false, "YearQuater", typeof (string), defaultYearQuarter), new WebDataColumnBuilder(false, "CreatedBy", typeof (string), "ISG Web"), new WebDataColumnBuilder(false, "CreatedOn", typeof (DateTime), DateTime.Now.ToString(CultureInfo.CurrentCulture)), new WebDataColumnBuilder(false, "ModifiedBy", typeof (string), "ISG Web"), new WebDataColumnBuilder(false, "ModifiedOn", typeof (DateTime), DateTime.Now.ToString(CultureInfo.CurrentCulture)) }; var neonExtraColumns = Mapper.Map<List<WebDataColumnBuilder>,List<NeonFSDataColumnBuilder>>(extraColumns); neonExtraColumns.ForEach(x => x.DataTypeName = x.DataTypeName); var inputTables = new List<string>(); var neonUniverse = Mapper.Map<WebUniverse,NeonFSUniverse>(SelectedUniverse); neonUniverse.UniverseMaps.ForEach(x => inputTables.Add(x.InputTable.ToLower())); var neonMetaData = Mapper.Map<List<WebDataTableMetaData>, List<NeonFSDataTableMetaData>>(WebCache.IsgMetaData.Where(x => inputTables.Contains(x.Name.ToLower())).ToList()); fileServiceClient.UploadUniverseFile(neonExtraColumns, file.FileName, neonMetaData, neonUniverse, UploadCode, file.InputStream); } } catch (Exception ex) { ValidationErrors.Add(string.Format("System Exception: {0}", ex.Message)); } }
public override void UploadFile(HttpPostedFileBase file) { ValidationErrors.Clear(); ProcessExcelPreFlightErrorMessages(file); if (ValidationErrors.Count != 0 || file == null) { return; } try { using (var fileServiceClient = new NeonISGFileServiceClient(Configuration.ActiveNeonFileServiceEndpoint)) { var extraColumns = new List<WebDataColumnBuilder> { new WebDataColumnBuilder(false, "DataLoaderId", typeof (int), "0"), new WebDataColumnBuilder(false, "DataLoaderDate", typeof (DateTime), DateTime.Now.ToString(CultureInfo.CurrentCulture)), new WebDataColumnBuilder(false, "YearQuater", typeof (string), SelectYearQuarterListItemValue) }; UploadCode = Guid.NewGuid().ToString().Substring(0, 6); var neonExtraColumns = Mapper.Map<List<WebDataColumnBuilder>, List<NeonFSDataColumnBuilder>>(extraColumns); neonExtraColumns.ForEach(x => x.DataTypeName = x.DataTypeName); var neonMetaData = Mapper.Map<WebDataTableMetaData, NeonFSDataTableMetaData>(WebCache.IsgMetaData.FirstOrDefault(x => x.DatabaseType == WebISGDatabaseType.ISGInput && string.Equals(SelectedClient.InputTable, x.Name, StringComparison.CurrentCultureIgnoreCase))); fileServiceClient.UploadClientChangeFile(neonExtraColumns, file.FileName, neonMetaData, Configuration.ExcelSpreadSheetNameForImports, UploadCode, file.InputStream); } } catch (Exception ex) { ValidationErrors.Add(string.Format("System Exception: {0}", ex.Message)); } }