public static ProcModel MapProc(string[] _procJsonCell) { string[] procJsonCell = _procJsonCell; ProcModel proc = new ProcModel(); proc.UID = procJsonCell[0]; proc.PID = procJsonCell[1]; proc.PPID = procJsonCell[2]; proc.C = procJsonCell[3]; proc.STIME = procJsonCell[4]; proc.TTY = procJsonCell[5]; if (procJsonCell.Length > 6) { proc.TIME = procJsonCell[6]; } if (procJsonCell.Length > 8) { proc.CMD = procJsonCell[7] + " " + procJsonCell[8]; } else if (procJsonCell.Length > 7) { proc.CMD = procJsonCell[7]; } return(proc); }
public static List <ProcModel> MapProcJson(string _procJson) { string procJson = _procJson; procJson = System.Text.RegularExpressions.Regex.Replace(_procJson, @"\s{2,}", " ").Replace("\"", ""); string[] rowDivider = new String[] { "\\n" }; string[] procJsonRow = new string[] { }; procJsonRow = procJson.Split(rowDivider, StringSplitOptions.None).ToArray(); List <ProcModel> procs = new List <ProcModel>() { }; foreach (string rowJson in procJsonRow) { if (rowJson != null && rowJson != "") { string[] procJsonCell = new string[] { }; string[] cellDivider = new String[] { " " }; procJsonCell = rowJson.Split(cellDivider, StringSplitOptions.None).ToArray(); ProcModel proc = MapProc(procJsonCell); procs.Add(proc); } } return(procs); }
public static ProcModel MapProc(string[] _procJsonCell) { string[] procJsonCell = _procJsonCell; ProcModel proc = new ProcModel(); proc.UID = procJsonCell[0]; proc.PID = procJsonCell[1]; proc.PPID = procJsonCell[2]; proc.C = procJsonCell[3]; proc.STIME = procJsonCell[4]; proc.TTY = procJsonCell[5]; if (procJsonCell.Length > 6) { proc.TIME = procJsonCell[6]; } if (procJsonCell.Length > 8) { proc.CMD = procJsonCell[7] + " " + procJsonCell[8]; } else if (procJsonCell.Length > 7) { proc.CMD = procJsonCell[7]; } return proc; }