public void Execute(OnLoadFileDelegate UpdateProgressBar) { try { if (filePath == "") { loadStatus = LoadStatus.FileNameIsEmpty; throw new Exception("Путь к файлу не указан"); } int sector = int.Parse(Math.Ceiling((double)(100 / File.ReadAllLines(filePath).Length)).ToString()); var file = File.Open(filePath, FileMode.Open, FileAccess.Read); string text; using (var sr = new StreamReader(file)) { int currentProgress = 0; while ((text = sr.ReadLine()) != "") { var enterpriceParts = text.Split('|'); enterpriseList.Add(new Enterprise() { Name = enterpriceParts[0], PropertyType = enterpriceParts[1], LandArea = int.Parse(enterpriceParts[2]), EmployeeQty = int.Parse(enterpriceParts[3]) }); currentProgress += sector; UpdateProgressBar(currentProgress); Thread.Sleep(1000); } } loadStatus = LoadStatus.Success; } catch (FileNotFoundException e) { enterpriseList = null; loadStatus = LoadStatus.FileNotExists; LogUtility.ErrorLog(e); } catch (Exception e) { loadStatus = LoadStatus.GeneralError; LogUtility.ErrorLog(e); } }
public void SetAfterRowConvert(OnLoadFileDelegate onAfterRowConvert) { throw new NotImplementedException(); }
//Метод установки значения делегата public void SetAfterRowConvert(OnLoadFileDelegate onAfterRowConvert) { this.onAfterRowConvert = onAfterRowConvert; }
//Метод установки значения делегата SET public void SetOfDeligate(OnLoadFileDelegate onAfterRowConvert) { this.onAfterRowRead = onAfterRowConvert; }
public void SetDelegate(OnLoadFileDelegate del) { throw new NotImplementedException(); }
public void SetDelegate(OnLoadFileDelegate del) => OnLoadFile = del;
public MaterialNewLoader_laba4(string fileName) { dataFileName = fileName; materials = new List <Material>(); onAfterRowWasRead = null; }
//методы доступа к делегату сеттер public void SetAfterRowWasRead(OnLoadFileDelegate onAfterRowWasRead) { this.onAfterRowWasRead = onAfterRowWasRead; }