public bool scanFolderUpload(string folderPath, out string errorFileName, string errorFolderPath, string successFolderPath) { String[] FileNameList = Directory.GetFiles(folderPath); bool flag = true; string nameMapping = string.Empty; string sql = "select * from temp_table_mapping"; DataTable dtTemp = ExecuteSQL.ExecuteQuery(sql); Dictionary <string, string> fieldMapping = new Dictionary <string, string>(); string filename = string.Empty; string tablename = string.Empty; foreach (DataRow dr in dtTemp.AsEnumerable()) { if (dr.Field <string>("myTable") != null) { fieldMapping.Add(dr.Field <string>("myTable"), dr.Field <string>("tableName")); } } StringBuilder sb = new StringBuilder(); foreach (string file in FileNameList) { filename = System.IO.Path.GetFileNameWithoutExtension(file); //TableMigration dts = new TableMigration(); AutoMappingMethod am = new AutoMappingMethod(); foreach (string temp in fieldMapping.Keys) { if (filename.Contains(temp)) { if (filename.StartsWith("ro_type")) { if (!am.RecurciveForDataMappings(temp, file, fieldMapping)) { moveFileFromOneToOther(file, errorFolderPath); sb.Append(file + ";"); } else { moveFileFromOneToOther(file, successFolderPath); } break; } else { if (filename.StartsWith("ro")) { if (!am.RecurciveForDataMappings(temp, file, fieldMapping)) { moveFileFromOneToOther(file, errorFolderPath); sb.Append(file + ";"); flag = false; } else { moveFileFromOneToOther(file, successFolderPath); } //dts.getDataFromDifferentTable("ro", file, fieldMapping); } else { if (filename.Contains("ro") && !filename.StartsWith(temp)) { continue; } else { if (!am.RecurciveForDataMappings(temp, file, fieldMapping)) { moveFileFromOneToOther(file, errorFolderPath); sb.Append(file + ";"); flag = false; } else { moveFileFromOneToOther(file, successFolderPath); } break; } } } } } } errorFileName = sb.ToString(); return(flag); }
public bool scanFolderUpload(string folderPath) { String[] FileNameList = Directory.GetFiles(folderPath); bool flag = true; string nameMapping = string.Empty; string sql = "select * from temp_table_mapping"; DataTable dtTemp = ExecuteSQL.ExecuteQuery(sql); Dictionary <string, string> fieldMapping = new Dictionary <string, string>(); string filename = string.Empty; foreach (DataRow dr in dtTemp.AsEnumerable()) { if (dr.Field <string>("myTable") != null) { fieldMapping.Add(dr.Field <string>("myTable"), dr.Field <string>("tableName")); } } foreach (string file in FileNameList) { filename = System.IO.Path.GetFileNameWithoutExtension(file); //TableMigration dts = new TableMigration(); AutoMappingMethod dts = new AutoMappingMethod(); foreach (string temp in fieldMapping.Keys) { if (filename.Contains(temp)) { if (filename.StartsWith("ro_type")) { dts.RecurciveForDataMappings("ro_type", file, fieldMapping); break; } else { if (filename.StartsWith("ro")) { dts.RecurciveForDataMappings("ro", file, fieldMapping); } else { if (filename.Contains("ro") && !filename.StartsWith(temp)) { continue; } else { dts.RecurciveForDataMappings(temp, file, fieldMapping); break; } } } } } } return(flag); }