public void SendMessage(PShell.psmethods.PSAlert.AlertType AlertLevel, String Source, String Message) { int level = (int)GetLevel(AlertLevel) + (20 * 8); //Local4.(AlertLevel) string priority = String.Format(StringValue.PriorityFormat, level); string timestamp = DateTime.Now.ToString(StringValue.SyslogTimeFormat); string hostname = Dns.GetHostName(); string version = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); List <byte> msg = new List <byte>(); string msgstring = String.Format(StringValue.SyslogFormat, priority, timestamp, hostname, StringValue.psftitle.Replace(" ", ""), Source, Message); msg.AddRange(Encoding.ASCII.GetBytes(msgstring)); SendMessage(msg.ToArray()); }
private SyslogLevel GetLevel(PShell.psmethods.PSAlert.AlertType level) { SyslogLevel rtn = SyslogLevel.Information; bool found = false; int idx = 0; int[] sidx = { 1, 2, 3, 4, 6 }; do { SyslogLevel lvl = (SyslogLevel)sidx[idx]; if (lvl.ToString() == level.ToString()) { found = true; rtn = lvl; } idx++; } while (!found && idx < sidx.Length); return(rtn); }