public CSVThread(String Path, ILoggerInterface Logger, Salesforce.Salesforce Sfdc) { Header = new Dictionary <int, string>(); Columns = new List <string>(); Columns = new List <string>(); Row = new Dictionary <string, string>(); startLine = new Dictionary <int, int>(); sfdcs = new List <Salesforce.Salesforce>(); MinimumThreadSize = 1000; isInProgress = false; _Processed = 0; this.Logger = Logger; if (!File.Exists(Path)) { throw new FileNotFoundException("File to parse: {0} not found!", Path); } this.Path = Path; CSV = new StreamReader(Path); Size = File.ReadLines(Path).Count() - 1; //do not count header line Cores = (Size > MinimumThreadSize) ? Environment.ProcessorCount : 1; //get Header sfdcs.Add(Sfdc); GetHeader(); }
public CSVThread(String Path, ILoggerInterface Logger, Salesforce.Salesforce Sfdc) { Cores = Environment.ProcessorCount; Header = new Dictionary <string, List <string> >(); Columns = new List <string>(); Columns = new List <string>(); Row = new Dictionary <string, string>(); Relations = new Dictionary <string, List <string> >(); startLine = new Dictionary <int, int>(); sfdcs = new List <Salesforce.Salesforce>(); this.Logger = Logger; if (!File.Exists(Path)) { throw new FileNotFoundException("File to parse: {0} not found!", Path); } this.Path = Path; CSV = new StreamReader(Path); Size = File.ReadLines(Path).Count() - 1; //do not count header file Console.WriteLine("Number of rows to process: {0}", Size); //get Header sfdcs.Add(Sfdc); GetHeader(); sfdcs[0].BatchSize = Sfdc.BatchSize = Relations.Count; //configure batch size according to number of relations //clone salesforce instances for (int i = 0; i < Cores - 1; i++) { sfdcs.Add((Salesforce.Salesforce)Sfdc.Clone()); } //prepare progress bar var options = new ProgressBarOptions { ForegroundColor = ConsoleColor.Yellow, ForegroundColorDone = ConsoleColor.DarkGreen, BackgroundColor = ConsoleColor.DarkGray, BackgroundCharacter = '\u2593' }; StatusBar = new ProgressBar(Size, "", options); //prepare copies of files for threads PrepareFileToParse(); }