currently, doing log analyzer personal project. issue here new c# , have performance issue tool.
everytime device(ios) interacted, output syslog library , comes in output handler.
public void outputhandler(object sendingprocess, datareceivedeventargs outline, iossyslogger form, string uuid) { string currentpath = system.environment.currentdirectory; bool exit = false; if (exit == true) return; try { form.begininvoke(new action(() => { form.insertlogtext = outline.data; })); using (system.io.streamwriter file = new system.io.streamwriter(currentpath + @"\syslog" + uuid + ".txt", true)) { file.writeline(outline.data); } } catch { return ; } //*most of logic outputing log should dealt output handler } then, write outline.data data grid view. concern need able search , filter through data gridview.
curently using visibility = false search filtering ( if row not match given filter specification set row visibility =false)
this requires program traverse entire datagridview check whether condition met.
will there better way filter , search within ? (when have thousands of lines of row, takes @ least 20 seconds process it) below code filtering, , searching through results function.
private void searchresult(string term) { if (term != null) { int = 0; while (i < datagridview1.rows.count - 1) { if (datagridview1.rows[i].cells[3] == null) { i++; continue; } if (datagridview1.rows[i].visible == false) { i++; continue; } else if (datagridview1.rows[i].cells[2].value.tostring().contains(term) || datagridview1.rows[i].cells[3].value.tostring().contains(term) || datagridview1.rows[i].cells[4].value.tostring().contains(term)) { string multirow = datagridview1.rows[i].cells[5].value.tostring(); int count = convert.toint32(multirow); if (count > 0) { int z = 0; (z = 0; z <= count; z++) { datagridview1.rows[i + z].visible = true; } = + z; } else { datagridview1.rows[i].visible = true; i++; } } else { datagridview1.rows[i].visible = false; i++; } } } } public filteringthelist(){
for (int = 0; < datagridview1.rows.count - 1; i++) { datagridview1.rows[i].visible = false; int count1,count2,count3=0; count1 = 1; count2 = 1; count3 = 1; int z = 0; foreach (keyvaluepair<string, string> entry in totalselected) { if (entry.value == "devicename" && datagridview1.rows[i].cells[1].value != null) { if (datagridview1.rows[i].cells[1].value.tostring().trim().equals(entry.key.trim())) { string multirow1 = datagridview1.rows[i].cells[5].value.tostring(); int counts = convert.toint32(multirow1); if (counts > 0) { (z = 0; z < counts; z++) { datagridview1.rows[i + z].visible = true; } } else { datagridview1.rows[i].visible = true; } } else if (devicename.checkeditems.count > 1&&count1!= devicename.checkeditems.count) { count1++; continue; } else { datagridview1.rows[i].visible = false; break; } } else if (entry.value == "process" && datagridview1.rows[i].cells[2].value != null) { if (datagridview1.rows[i].cells[2].value.tostring().trim().equals(entry.key.trim())) { string multirow1 = datagridview1.rows[i].cells[5].value.tostring(); int counts = convert.toint32(multirow1); if (counts > 0) { (z = 0; z < counts; z++) { datagridview1.rows[i + z].visible = true; } } else { datagridview1.rows[i].visible = true; } } else if (processlistname.checkeditems.count > 1 && count2 != processlistname.checkeditems.count) { count2++; continue; } else { datagridview1.rows[i].visible = false; break; } } else if (entry.value == "loglevel" && datagridview1.rows[i].cells[3].value != null) { if (datagridview1.rows[i].cells[3].value.tostring().trim().contains(entry.key.trim())) { string multirow1 = datagridview1.rows[i].cells[5].value.tostring(); int counts = convert.toint32(multirow1); if (counts > 0) { (z = 0; z < counts; z++) { datagridview1.rows[i + z].visible = true; } } else { datagridview1.rows[i].visible = true; } continue; } else if (loglevelcheckbox.checkeditems.count > 1 && count3 != loglevelcheckbox.checkeditems.count) { count3++; continue; } else { datagridview1.rows[i].visible = false; break; } } // entry.value or entry.key } string multirow = datagridview1.rows[i].cells[5].value.tostring(); int count = convert.toint32(multirow); if (count > 0&& datagridview1.rows[i].visible==false) { (int k = 0; k <= count; k++) { datagridview1.rows[i + k].visible = false; } } = + z; }
the performance problem because datagridview redrawing @ each modification.
don't fill datagridview directly data. rather create datatable , bind datagridview bindingsource.
then use "filter" property of binding source view extracts of datatable in datagridview. "filter" property string content similar of sql clause.
Comments
Post a Comment