public FormMainWindow() { InitializeComponent(); StrKonfigFile = Path.GetDirectoryName(Application.ExecutablePath) + "\\data\\cfg.JSON"; mklivestatus = new MK_Livestatus(); MKLivestatusList = new List <MK_Livestatus> (); }
public string FormatMKLiveData(MK_Livestatus mkl, string strData, out Color itemColor) { int iOut; string strOut = ""; itemColor = SystemColors.Window; switch (mkl.LivefieldTypeID) { case E_MK_LiveStatusObjectTypes.Boolean: if (int.TryParse(strData, out iOut)) { strOut = iOut != 0 ? "JA" : "NEIN"; } break; case E_MK_LiveStatusObjectTypes.Time: int.TryParse(strData, out iOut); DateTimeOffset dto1 = UnixDateTime.FromUnixTimeSeconds(iOut); strOut = dto1.LocalDateTime.ToString(); break; // OK Warn Crit Unkn case E_MK_LiveStatusObjectTypes.NagiosState: int.TryParse(strData, out iOut); if (mkl.LivefieldTable == E_MK_LivestatusTables.Hosts) { strOut = Enum.GetName(typeof(E_MK_LiveStatusNagiosStateHost), iOut); itemColor = GetColorCode(itemColor, iOut); } if (mkl.LivefieldTable == E_MK_LivestatusTables.Services) { strOut = Enum.GetName(typeof(E_MK_LiveStatusNagiosStateService), iOut); itemColor = GetColorCode(itemColor, iOut, false); } break; // Hard | Soft case E_MK_LiveStatusObjectTypes.NagiosStateType: int.TryParse(strData, out iOut); strOut = Enum.GetName(typeof(E_MK_LiveStatusNagiosStateType), iOut); break; case E_MK_LiveStatusObjectTypes.CheckType: int.TryParse(strData, out iOut); strOut = Enum.GetName(typeof(E_MK_LiveStatusNagiosCheckType), iOut); break; case E_MK_LiveStatusObjectTypes.CommentType: int.TryParse(strData, out iOut); strOut = Enum.GetName(typeof(E_MK_LivestatusCommentType), iOut); break; case E_MK_LiveStatusObjectTypes.None: case E_MK_LiveStatusObjectTypes.Dict: case E_MK_LiveStatusObjectTypes.Float: case E_MK_LiveStatusObjectTypes.Float2Vector: case E_MK_LiveStatusObjectTypes.Float3Vector: case E_MK_LiveStatusObjectTypes.Integer: case E_MK_LiveStatusObjectTypes.List: case E_MK_LiveStatusObjectTypes.String: default: return(strData); } return(strOut); }