private void init_filedata(string inpath) { try { lst_filedata = new List <STFileData>(); STFileData item; files = Directory.GetFiles(inpath); // путь к папке foreach (string path in files) { item = new STFileData(); item.filename = Path.GetFileName(path); item.status = 0; if (is_loaded(item.filename)) { item.status = 2; } lst_filedata.Add(item); // checkedListBoxFiles.Items.Add(filename, true); } if (files.Length > 0) { init_list(); } } catch (Exception ex) { MessageBox.Show(ex.TargetSite + " " + ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void StartProc(object sender, DoWorkEventArgs e) { string msg = null; try { foreach (STFileData file in lst_filedata) { if (file.status == 0 || (file.status == 2 && reloadflag)) { curr_file = file; if (!read_file(curr_file.filename, out msg)) { log.LogLine(msg); lst_filedata = change_status_file(file.filename, 1, msg); } else if (!load_file(sender, e, out msg)) { log.LogLine(msg); } } } if (moveflag) { MoveFiles(); } } catch (Exception ex) { MessageBox.Show(ex.TargetSite + " " + ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void AddItemToList(STFileData data) { ListViewItem item; item = new ListViewItem(data.filename, data.status); item.SubItems.Add(data.text); listViewData.Items.Add(item); }
private List <STFileData> change_status_file(string filename, int status, string text) { List <STFileData> ret = new List <STFileData>(); STFileData item; foreach (STFileData file in lst_filedata) { if (file.filename != filename) { ret.Add(file); } else { item = new STFileData(); item.filename = file.filename; item.status = status; item.text = text; ret.Add(item); } } return(ret); }
private void StartProc(object sender, DoWorkEventArgs e) { string msg = null; try { cr = 0; foreach (STFileData file in lst_filedata) { if (file.status == 0 || (file.status == 2 && reloadflag)) { curr_file = file; //c_date = getfiledate(curr_file.filename); switch (m_app.Code) { case 300: { List <STRowAssistDataCsv> container1 = new List <STRowAssistDataCsv>(); if (clAssist.ReadFile(file.filename, out container1, out msg) != 0) { log.LogLine(msg); lst_filedata = change_status_file(file.filename, 1, msg); } else if (load_file1(sender, e, container1, file.filename, out msg) != 0) { log.LogLine(msg); } } break; case 305: { List <BGPBmobileRow> container3 = new List <BGPBmobileRow>(); if (clBGPBmobile.ReadFile(file.filename, out container3, out msg) != 0) { log.LogLine(msg); lst_filedata = change_status_file(file.filename, 1, msg); } else if (load_file3(sender, e, container3, out msg) != 0) { log.LogLine(msg); } } break; case 306: { JFile jfile = new JFile(); if (clUP.ReadFile(file.filename, out jfile, out msg) != 0) { log.LogLine(msg); lst_filedata = change_status_file(file.filename, 1, msg); } else if (load_file2(sender, e, jfile, file.filename, out msg) != 0) { log.LogLine(msg); } } break; } } cr++; } if (moveflag) { MoveFiles(m_app.PathIN, m_app.PathArch); } } catch (Exception ex) { MessageBox.Show(ex.TargetSite + " " + ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }