public override string GetHtml() { var html = string.Empty; ///////////////////// // fetch data sets ///////////////////// var queryResultsLocal = Queries.GetLongestFocusOnProgram(_date); var durInMin = (queryResultsLocal == null) ? 0 : queryResultsLocal.DurationInSec / 60.0; if (queryResultsLocal == null || durInMin <= _minFocusTime) { html += VisHelper.NotEnoughData(string.Format(CultureInfo.InvariantCulture, "We either don't have enough data or you didn't focus on a single program for more than {0} minutes on this day.", _minFocusTime)); return(html); } ///////////////////// // HTML ///////////////////// html += "<p style='text-align: center; margin-top:-0.7em;'><strong style='font-size:2.5em; color:" + Shared.Settings.RetrospectionColorHex + ";'>" + Math.Round(durInMin, 0) + "</strong> min</p>"; html += string.Format(CultureInfo.InvariantCulture, "<p style='text-align: center; margin-top:-0.7em;'>in {0}<br />from {1} to {2}</p>", ProcessNameHelper.GetFileDescription(queryResultsLocal.Process), queryResultsLocal.From.ToShortTimeString(), queryResultsLocal.To.ToShortTimeString()); return(html); }
public NetstatEntry(Guid logsetHash, int worker, BsonDocument netstatEntryDocument, BsonDocument transportReservationDocument, DateTime?fileLastModified) { LogsetHash = logsetHash; Worker = worker; FileLastModified = fileLastModified; Line = BsonDocumentHelper.GetInt("line", netstatEntryDocument); ProcessName = BsonDocumentHelper.GetString("process", netstatEntryDocument); ComponentName = BsonDocumentHelper.GetString("component", netstatEntryDocument); Protocol = BsonDocumentHelper.GetString("protocol", transportReservationDocument); LocalAddress = BsonDocumentHelper.GetString("local_address", transportReservationDocument); LocalPort = BsonDocumentHelper.GetNullableInt("local_port", transportReservationDocument); ForeignAddress = BsonDocumentHelper.GetString("foreign_address", transportReservationDocument); ForeignPort = BsonDocumentHelper.GetNullableInt("foreign_port", transportReservationDocument); TcpState = BsonDocumentHelper.GetString("tcp_state", transportReservationDocument); IsKnownTableauServerProcess = ProcessNameHelper.IsKnownTableauServerProcess(ProcessName); EntryHash = HashHelper.GenerateHashGuid(LogsetHash.ToString(), Worker, Line, ProcessName, ComponentName, Protocol, LocalAddress, LocalPort, ForeignAddress, ForeignPort, TcpState); }
public NetstatActiveConnection(NetstatDocumentEntry entry, string worker, DateTime?fileLastModified) { Line = entry.Line; ProcessName = entry.ProcessName; ProcessId = entry.ProcessId; ComponentName = entry.ComponentName; Protocol = entry.Protocol; LocalAddress = entry.LocalAddress; LocalPort = entry.LocalPort; ForeignAddress = entry.ForeignAddress; ForeignPort = entry.ForeignPort; TcpState = entry.TcpState; RecvQ = entry.RecvQ; SendQ = entry.SendQ; IsKnownTableauServerProcess = ProcessNameHelper.IsKnownTableauServerProcess(ProcessName); Worker = worker; FileLastModified = fileLastModified; }
public NetstatActiveConnection(Guid logsetHash, string worker, BsonDocument activeConnectionsDocument, DateTime?fileLastModified) { LogsetHash = logsetHash; Worker = worker; FileLastModified = fileLastModified; Line = BsonDocumentHelper.GetInt("line", activeConnectionsDocument); ProcessName = BsonDocumentHelper.GetString("process", activeConnectionsDocument); ProcessId = BsonDocumentHelper.GetNullableInt("pid", activeConnectionsDocument); ComponentName = BsonDocumentHelper.GetString("component", activeConnectionsDocument); Protocol = BsonDocumentHelper.GetString("protocol", activeConnectionsDocument); LocalAddress = BsonDocumentHelper.GetString("local_address", activeConnectionsDocument); LocalPort = BsonDocumentHelper.GetNullableInt("local_port", activeConnectionsDocument); ForeignAddress = BsonDocumentHelper.GetString("foreign_address", activeConnectionsDocument); ForeignPort = BsonDocumentHelper.GetNullableInt("foreign_port", activeConnectionsDocument); TcpState = BsonDocumentHelper.GetString("tcp_state", activeConnectionsDocument); RecvQ = BsonDocumentHelper.GetNullableInt("recv_q", activeConnectionsDocument); SendQ = BsonDocumentHelper.GetNullableInt("send_q", activeConnectionsDocument); IsKnownTableauServerProcess = ProcessNameHelper.IsKnownTableauServerProcess(ProcessName); EntryHash = HashHelper.GenerateHashGuid(LogsetHash.ToString(), Worker, Line, ProcessName, ComponentName, Protocol, LocalAddress, LocalPort, ForeignAddress, ForeignPort, TcpState); }
private string FormatProcesses(string process) { return(string.IsNullOrEmpty(process) ? string.Empty : ProcessNameHelper.GetFileDescription(process).Replace("'", "") + ", "); }
public override string GetHtml() { var html = string.Empty; ///////////////////// // fetch data sets ///////////////////// var prodResponses = Queries.GetUserProductivityTimelineData(_date, _type, true); var programsUsed = Queries.GetTopProgramsUsedWithTimes(_date, _type, maxNumberOfTopPrograms); if (prodResponses.Count < 3 || programsUsed.Count < 1) { html += VisHelper.NotEnoughData(_notEnoughDataMsg); return(html); } ///////////////////// // prepare data sets ///////////////////// // create & initialize dictionary var dict = new Dictionary <string, MyPair>(); foreach (var p in programsUsed) { if (dict.ContainsKey(p.Key)) { continue; } dict.Add(p.Key, new MyPair(0, 0)); } // populate dictionary for (var i = 1; i < prodResponses.Count; i++) { // only count if PerceivedProductivity was either unproductive (1-3) or productive (5-7) var perceivedProductivity = prodResponses[i].Item2; if (perceivedProductivity > 7 || perceivedProductivity < 1 || perceivedProductivity == 4) { continue; } var intStart = prodResponses[i - 1].Item1; var intEnd = prodResponses[i].Item1; foreach (var program in programsUsed) { foreach (var pItem in program.Value) { if (pItem.From > intStart && pItem.To < intEnd) { if (perceivedProductivity <= 3 && perceivedProductivity >= 1) { dict[program.Key].Unproductive += pItem.DurInMins; } // prodResponses[i].Item2 = 4 is neutral else if (perceivedProductivity >= 5 && perceivedProductivity <= 7) { dict[program.Key].Productive += pItem.DurInMins; } } } } } ///////////////////// // visualize data sets ///////////////////// var totalProductive = dict.Sum(i => i.Value.Productive); var totalUnproductive = dict.Sum(i => i.Value.Unproductive); // check if enough data is available if (totalProductive == 0 && totalUnproductive == 0) { html += VisHelper.NotEnoughData(_notEnoughDataMsg); return(html); } // create blank table html += string.Format(CultureInfo.InvariantCulture, "<table id='{0}'>", VisHelper.CreateChartHtmlTitle(Title)); html += "<thead><tr><th>Program</th><th>Productive</th><th>Unproductive</th></tr></thead>"; html += "<tbody>"; foreach (var p in dict) { var programUnproductive = (totalUnproductive == 0) ? 0 : Math.Round(100.0 / totalUnproductive * p.Value.Unproductive, 0); var programProductive = (totalProductive == 0) ? 0 : Math.Round(100.0 / totalProductive * p.Value.Productive, 0); html += "<tr>"; html += "<td>" + ProcessNameHelper.GetFileDescription(p.Key) + "</td>"; html += "<td style='color:green;'>" + programProductive + "%</td>"; html += "<td style='color:red;'>" + programUnproductive + "%</td>"; html += "</tr>"; } html += "</tbody>"; html += "</table>"; ///////////////////// // create & add javascript //////////////////// var js = "<script type='text/javascript'>" + "var tf = new TableFilter('" + VisHelper.CreateChartHtmlTitle(Title) + "', { base_path: '/', " + "col_widths:[ '12.4em', '6.25em', '6.25em'], " // fixed columns sizes + "col_0: 'none', col_1: 'none', col_2: 'none', " + "alternate_rows: true, " // styling options + "grid_layout: true, grid_width: '25.6em', grid_height: '18em', grid_cont_css_class: 'grd-main-cont', grid_tblHead_cont_css_class: 'grd-head-cont', " // styling & behavior of the table //+ "extensions: [{name: 'sort', types: [ 'string', 'number', 'number'] }], " + "}); " // no content options + "tf.init(); " + "</script>"; html += " " + js; return(html); }