private static ReportRecord BuildReportRecord(string strContent) { var items = strContent.Split(','); var reportRecord = new ReportRecord() { Timestamp = items[0], Scenario = items[1], Connections = Convert.ToInt32(items[2]), Sends = Convert.ToInt32(items[3]), SendTPuts = Convert.ToInt64(items[4]), RecvTPuts = Convert.ToInt64(items[5]), Reference = items[6] }; return(reportRecord); }
public static int Unit(this ReportRecord reportRecord) { var scenario = reportRecord.Scenario; var dashIndex = scenario.IndexOf('_'); if (dashIndex != -1) { var s = scenario.Substring(0, dashIndex); var unitEndIndex = s.LastIndexOf('t'); // find "unit" from last index if (unitEndIndex != -1 && unitEndIndex + 1 < s.Length) { var unit = s.Substring(unitEndIndex + 1, s.Length - unitEndIndex - 1); return(Convert.ToInt32(unit)); } } return(0); }
public int InsertRecord(string table, ReportRecord stat) { var ts = stat.Timestamp; var id = Convert.ToInt64(ts); var dt = Utils.ConvertFromTimestamp(ts); var dbId = $"{id}{stat.Scenario}"; if (stat.HasConnectionStat) { return(InsertConnStatRecord( table, dbId, dt, stat.Scenario, stat.Unit(), stat.Connections, stat.Sends, stat.SendTPuts, stat.RecvTPuts, stat.Reference, stat.DroppedConnections, stat.ReconnCost99Percent, stat.LifeSpan99Percent, stat.Offline99Percent, stat.Others)); } else { return(InsertCommonRecord( table, dbId, dt, stat.Scenario, stat.Unit(), stat.Connections, stat.Sends, stat.SendTPuts, stat.RecvTPuts, stat.Reference)); } }
private static ReportRecord BuildReportRecord(string strContent) { ReportRecord reportRecord = null; var items = strContent.Split(','); reportRecord = new ReportRecord() { Timestamp = items[0], Scenario = items[1], Connections = Convert.ToInt32(items[2]), Sends = Convert.ToInt32(items[3]), SendTPuts = Convert.ToInt64(items[4]), RecvTPuts = Convert.ToInt64(items[5]), Reference = items[6] }; if (items.Length >= 11) { reportRecord.DroppedConnections = Convert.ToInt32(items[7]); reportRecord.ReconnCost99Percent = Convert.ToInt32(items[8]); reportRecord.LifeSpan99Percent = Convert.ToInt32(items[9]); reportRecord.Offline99Percent = Convert.ToInt32(items[10]); if (items.Length > 11) { var othersBuilder = new StringBuilder(); for (var i = 11; i < items.Length; i++) { if (i == 11) { othersBuilder.Append(items[i]); } else { othersBuilder.Append("|").Append(items[i]); } } reportRecord.Others = othersBuilder.ToString(); } reportRecord.HasConnectionStat = true; } return(reportRecord); }
private static ReportRecord BuildReportRecord(string strContent) { ReportRecord reportRecord = null; var items = strContent.Split(','); reportRecord = new ReportRecord() { Timestamp = items[0], Scenario = items[1], Connections = Convert.ToInt32(items[2]), Sends = Convert.ToInt32(items[3]), SendTPuts = Convert.ToInt64(items[4]), RecvTPuts = Convert.ToInt64(items[5]), Reference = items[6] }; if (items.Length == 9) { reportRecord.DroppedConnections = Convert.ToInt32(items[7]); reportRecord.ReconnCost99Percent = Convert.ToInt32(items[8]); reportRecord.HasConnectionStat = true; } return(reportRecord); }