public bool ProcessWholesaler(int wrpid, string _filepath) { var result = false; importFileRows = 0; // Console.WriteLine("Enter wrpid : " + wrpid); /// Console.Write("Enter wrpid : "); //int wrpid = int.Parse(Console.ReadLine()); // int importTypeId = Getwholesaler_ID_By_wrpid(wrpid); //Console.WriteLine("Enter import File Name of -> "+ GetwholesalerNameByID(importTypeId)); //string _fileName = Console.ReadLine(); File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"], Environment.NewLine + _filepath); if (!File.Exists(_filepath)) { Console.WriteLine("\nFile not Exists"); File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"], Environment.NewLine + "File not Exists "); // Console.ReadLine(); return(false); } else { File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"], Environment.NewLine + "File Exists "); // return false; } FileInfo fi = new FileInfo(_filepath); string _fileName = Path.GetFileNameWithoutExtension(fi.FullName); // Create backup Folder if (!System.IO.Directory.Exists(fi.DirectoryName + @"\backup")) { System.IO.Directory.CreateDirectory(fi.DirectoryName + @"\backup"); } string wholesalerFile_backup = fi.DirectoryName + @"\backup\" + _fileName + "_" + DateTime.Now.ToString("dd-MMM-yyyy hh:mm:ss ").Replace("-", "_").Replace(":", "_") + fi.Extension; // string wholesalerFile_backup = fi.DirectoryName + @"\backup\" + _fileName + fi.Extension; // Delete from backup Folder if file Exists if (File.Exists(wholesalerFile_backup)) { File.Delete(wholesalerFile_backup); } _crudRepo = new CrudRepo(); if (_crudRepo.FileParsed(_filepath, fi.LastWriteTime)) { Console.WriteLine("\n Already Parsed this File"); File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"], Environment.NewLine + "Already Parsed this File"); //// Move file in backup Folder File.Move(_filepath, wholesalerFile_backup); // Console.ReadLine(); return(false); } if (wrpid == 7) { Console.WriteLine("Start Parsing :" + " - amerisource"); var amerisource = new AmerisourceProcessor(); var amerisourceEntries = amerisource.ProcessAmerisource(_filepath); importFileRows = amerisourceEntries.Count; if (amerisourceEntries.Any()) { result = _crudRepo.BulkAddAmerisource(amerisourceEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 143) { Console.WriteLine("Start Parsing :" + " - Anda"); var Anda = new AndaProcesor(); var AndaEntries = Anda.ProcessAnda(_filepath); importFileRows = AndaEntries.Count; if (AndaEntries.Any()) { result = _crudRepo.BulkAddAnda(AndaEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 116) { Console.WriteLine("Start Parsing :" + " - ASD"); var ASD = new ASDProcesor(); var ASDEntries = ASD.ProcessASD(_filepath); importFileRows = ASDEntries.Count; if (ASDEntries.Any()) { result = _crudRepo.BulkAddASD(ASDEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 14821) { Console.WriteLine("Start Parsing :" + " - biocare"); var biocare = new BioCareProcessor(); var biocareEntries = biocare.ProcessBioCare(_filepath); importFileRows = biocareEntries.Count; if (biocareEntries.Any()) { result = _crudRepo.BulkAddBioCare(biocareEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 9) { Console.WriteLine("Start Parsing :" + " - cardinal"); string filename = Path.GetFileName(_filepath); if (filename.Substring(0, 4) == "CSWJ") { var cardinal = new CardinalProcesor(); var cardinalEntries = cardinal.ProcessCardinal(_filepath); importFileRows = cardinalEntries.Count; if (cardinalEntries.Any()) { result = _crudRepo.BulkAddCardinal(cardinalEntries); } } else { var cardinal = new CardinalProcesorW(); var cardinalEntries = cardinal.ProcesorCardinalW(_filepath); importFileRows = cardinalEntries.Count; if (cardinalEntries.Any()) { result = _crudRepo.BulkAddCardinal_W(cardinalEntries); } } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 14695) { Console.WriteLine("Start Parsing :" + " - CardinalSPD"); var card = new CardinalSPDProcessor(); var cardEntries = card.ProcessCardinalSPD(_filepath); importFileRows = cardEntries.Count; if (cardEntries.Any()) { result = _crudRepo.BulkAddCardinalSPD(cardEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 27039) { Console.WriteLine("Start Parsing :" + " - CuraScript"); var cscr = new CuraScriptProcessor(); var cscrEntries = cscr.ProcessCuraScript(_filepath); importFileRows = cscrEntries.Count; if (cscrEntries.Any()) { result = _crudRepo.BulkAddCuraScript(cscrEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 147) { Console.WriteLine("Start Parsing :" + " - dakota"); var dakota = new DakotaProcessor(); var dakotaEntries = dakota.ProcessDakota(_filepath); importFileRows = dakotaEntries.Count; if (dakotaEntries.Any()) { result = _crudRepo.BulkAddDakota(dakotaEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 11) { Console.WriteLine("Start Parsing :" + " - HdSmith"); var hds = new HDSmithProcessor(); var hdsEntries = hds.ProcessHDSmith(_filepath); importFileRows = hdsEntries.Count; if (hdsEntries.Any()) { result = _crudRepo.BulkAddHdSmith(hdsEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 10) { Console.WriteLine("Start Parsing :" + " - Kinray"); var kinray = new KinrayProcessor(); var kinrayEntries = kinray.ProcessKinray(_filepath); importFileRows = kinrayEntries.Count; if (kinrayEntries.Any()) { result = _crudRepo.BulkAddKinray(kinrayEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 8) { Console.WriteLine("Start Parsing :" + " - Mckesson"); var mcKesson = new MckessonProcessor(); var mcKessonEntries = mcKesson.ProcessMckessons(_filepath); importFileRows = mcKessonEntries.Count; if (mcKessonEntries.Any()) { result = _crudRepo.BulkAddMCkesson(mcKessonEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 15945) { Console.WriteLine("Start Parsing :" + " - MckessonSP"); var mckp = new McKessonSPProcessor(); var mckpEntries = mckp.ProcessMcKessonSP(_filepath); importFileRows = mckpEntries.Count; if (mckpEntries.Any()) { result = _crudRepo.BulkAddMcKessonSP(mckpEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 29) { Console.WriteLine("Start Parsing :" + " - MorrisDickson"); var MorrisDickson = new MorrisDicksonProcesor(); var MorrisDicksonEntries = MorrisDickson.ProcessMorrisDickson(_filepath); importFileRows = MorrisDicksonEntries.Count; if (MorrisDicksonEntries.Any()) { result = _crudRepo.BulkAddMorrisDickson(MorrisDicksonEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 80) { Console.WriteLine("Start Parsing :" + " - NcMutual"); var ncmutual = new NcMutualProcessor(); var ncmutualEntries = ncmutual.ProcessNcMutual(_filepath); importFileRows = ncmutualEntries.Count; if (ncmutualEntries.Any()) { result = _crudRepo.BulkAddNcMutual(ncmutualEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 14691) { Console.WriteLine("Start Parsing :" + " - R&S Pharma"); var rns = new RnSProcessor(); var rnsEntries = rns.ProcessRnS(_filepath); importFileRows = rnsEntries.Count; if (rnsEntries.Any()) { result = _crudRepo.BulkAddRnS(rnsEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 6) { Console.WriteLine("Start Parsing :" + " - RDC"); var RDC = new RDCProcesor(); var RDCEntries = RDC.ProcessRDC(_filepath); importFileRows = RDCEntries.Count; if (RDCEntries.Any()) { result = _crudRepo.BulkAddRDC(RDCEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 36) { Console.WriteLine("Start Parsing :" + " - SmithDrugs"); var smiths = new SmithDrugsProcessor(); var smithDrugEntries = smiths.ProcessSmithDrugs(_filepath); importFileRows = smithDrugEntries.Count; if (smithDrugEntries.Any()) { result = _crudRepo.BulkAddSmithDrugs(smithDrugEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 57) { Console.WriteLine("Start Parsing :" + " - ValleyWholesale"); var ValleyWholesale = new ValleyWholesaleProcesor(); var ValleyWholesaleEntries = ValleyWholesale.ProcessValleyWholesale(_filepath); importFileRows = ValleyWholesaleEntries.Count; if (ValleyWholesaleEntries.Any()) { result = _crudRepo.BulkAddValleyWholesale(ValleyWholesaleEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (wrpid == 77) { Console.WriteLine("Start Parsing :" + " - ValueDrugs"); var vd = new ValueDrugsProcessor(); var valueDrugsEntries = vd.ProcessValueDrugs(_filepath); importFileRows = valueDrugsEntries.Count; if (valueDrugsEntries.Any()) { result = _crudRepo.BulkAddValueDrugs(valueDrugsEntries); } if (result) { InsertImportLog(wrpid, _filepath, importFileRows); } } if (result) { // Move file in backup Folder File.Move(_filepath, wholesalerFile_backup); Console.WriteLine("Parsing Completed Successfully"); //Console.WriteLine(importFileRows + " Rows Inserted "); File.AppendAllText(@"" + ConfigurationManager.AppSettings["reportlogfile"], Environment.NewLine + "Parsing Completed Successfully --- " + importFileRows + " Rows Inserted "); } else { Console.WriteLine("Parsing Failed"); } return(result); }