void ReportThings(SQLLib sql, string MachineID, string Method, VulpesSMARTInfo ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot, List <int> UpdatedAttribs = null) { bool Critical = Method.ToLower() == "error" ? true : false; string ID = (Method.ToLower() == "error" ? "ERROR\\\\" : "") + MachineID + "\\\\" + ar.PNPDeviceID; bool ReportToAdmin = RepElementRoot.ReportToAdmin.Value; bool ReportToClient = RepElementRoot.ReportToClient.Value; bool UrgentForAdmin = RepElementRoot.UrgentForAdmin.Value; bool UrgentForClient = RepElementRoot.UrgentForClient.Value; if (AlreadyReported.ContainsKey(ID) == true) { if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0) { ReportToAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0) { ReportToClient = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0) { UrgentForAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0) { UrgentForClient = false; } } if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false) { return; } ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) | (ReportToClient == true ? ReportingFlags.ReportToClient : 0) | (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) | (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0); ReportingSMART sm = new ReportingSMART(); sm.App = ar; sm.UpdatedAttribs = UpdatedAttribs; ReportingProcessor.ReportSMART(sql, MachineID, Method, sm, Flags, Critical); if (AlreadyReported.ContainsKey(ID) == true) { AlreadyReported[ID] |= (Int64)Flags; } else { AlreadyReported.Add(ID, (Int64)Flags); } }
void ReportThings(SQLLib sql, string MachineID, string Method, StartupItem ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot) { string ID = MachineID + "\\\\" + ar.Key + "\\\\" + ar.Location; if (string.IsNullOrWhiteSpace(ar.HKCUUser) == false) { ID += "\\\\" + ar.HKCUUser; } bool ReportToAdmin = RepElementRoot.ReportToAdmin.Value; bool ReportToClient = RepElementRoot.ReportToClient.Value; bool UrgentForAdmin = RepElementRoot.UrgentForAdmin.Value; bool UrgentForClient = RepElementRoot.UrgentForClient.Value; if (AlreadyReported.ContainsKey(ID) == true) { if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0) { ReportToAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0) { ReportToClient = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0) { UrgentForAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0) { UrgentForClient = false; } } if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false) { return; } ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) | (ReportToClient == true ? ReportingFlags.ReportToClient : 0) | (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) | (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0); ReportingProcessor.ReportStartup(sql, MachineID, Method, ar, Flags); if (AlreadyReported.ContainsKey(ID) == true) { AlreadyReported[ID] |= (Int64)Flags; } else { AlreadyReported.Add(ID, (Int64)Flags); } }
void ReportThings(SQLLib sql, string MachineID, string Method, SimpleTaskResult ar, ref Dictionary <string, Int64> AlreadyReported, ReportingPolicyElement RepElementRoot) { string ID = MachineID + "\\" + Method; bool ReportToAdmin = RepElementRoot.ReportToAdmin.Value; bool ReportToClient = RepElementRoot.ReportToClient.Value; bool UrgentForAdmin = RepElementRoot.UrgentForAdmin.Value; bool UrgentForClient = RepElementRoot.UrgentForClient.Value; if (AlreadyReported.ContainsKey(ID) == true) { if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToAdmin) != 0) { ReportToAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.ReportToClient) != 0) { ReportToClient = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForAdmin) != 0) { UrgentForAdmin = false; } if ((AlreadyReported[ID] & (Int64)ReportingFlags.UrgentForClient) != 0) { UrgentForClient = false; } } if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false) { return; } ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) | (ReportToClient == true ? ReportingFlags.ReportToClient : 0) | (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) | (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0); ReportingProcessor.ReportSimpleTaskCompletion(sql, MachineID, Method, ar, Flags); if (AlreadyReported.ContainsKey(ID) == true) { AlreadyReported[ID] |= (Int64)Flags; } else { AlreadyReported.Add(ID, (Int64)Flags); } }
void ReportingThread(object EventDataListO) { try { using (SQLLib sql = SQLTest.ConnectSQL("Fox SDC Server for EventLog Data")) { if (sql == null) { FoxEventLog.WriteEventLog("Cannot connect to SQL Server for Event Log Data Reporting!", System.Diagnostics.EventLogEntryType.Error); return; } List <EventLogReportFull> EventDataList = (List <EventLogReportFull>)EventDataListO; if (EventDataList.Count == 0) { return; } List <PolicyObject> Pol = Policies.GetPolicyForComputerInternal(sql, EventDataList[0].MachineID); Dictionary <string, Int64> AlreadyReported = new Dictionary <string, long>(); foreach (PolicyObject PolO in Pol) { if (PolO.Type != PolicyIDs.ReportingPolicy) { continue; } ReportingPolicyElement RepElementRoot = JsonConvert.DeserializeObject <ReportingPolicyElement>(Policies.GetPolicy(sql, PolO.ID).Data); if (RepElementRoot.Type != ReportingPolicyType.EventLog) { continue; } if (RepElementRoot.ReportToAdmin == null) { RepElementRoot.ReportToAdmin = false; } if (RepElementRoot.ReportToClient == null) { RepElementRoot.ReportToClient = false; } if (RepElementRoot.UrgentForAdmin == null) { RepElementRoot.UrgentForAdmin = false; } if (RepElementRoot.UrgentForClient == null) { RepElementRoot.UrgentForClient = false; } if (RepElementRoot.ReportToAdmin == false && RepElementRoot.ReportToClient == false && RepElementRoot.UrgentForAdmin == false && RepElementRoot.UrgentForClient == false) { continue; } foreach (string Element in RepElementRoot.ReportingElements) { ReportingPolicyElementEventLog evrep = JsonConvert.DeserializeObject <ReportingPolicyElementEventLog>(Element); if (evrep.Book == null) { evrep.Book = new List <string>(); } if (evrep.CategoryNumbers == null) { evrep.CategoryNumbers = new List <int>(); } if (evrep.EventLogTypes == null) { evrep.EventLogTypes = new List <int>(); } if (evrep.Sources == null) { evrep.Sources = new List <string>(); } if (evrep.Book.Count == 0 && evrep.CategoryNumbers.Count == 0 && evrep.EventLogTypes.Count == 0 && evrep.Sources.Count == 0) { continue; } foreach (EventLogReportFull EV in EventDataList) { if (evrep.Book.Count != 0) { bool Match = false; foreach (string Book in evrep.Book) { if (Book.ToLower() == EV.EventLog.ToLower()) { Match = true; break; } } if (Match == false) { continue; } } if (evrep.Sources.Count != 0) { bool Match = false; foreach (string Source in evrep.Sources) { if (Source.ToLower() == EV.Source.ToLower()) { Match = true; break; } } if (Match == false) { continue; } } if (evrep.EventLogTypes.Count != 0) { bool Match = false; foreach (int EVLType in evrep.EventLogTypes) { if (EVLType == EV.EventLogType) { Match = true; break; } } if (Match == false) { continue; } } if (evrep.CategoryNumbers.Count != 0) { bool Match = false; foreach (int Cat in evrep.CategoryNumbers) { if (Cat == (EV.InstanceID & 0x3FFFFFFF)) { Match = true; break; } } if (Match == false) { continue; } } if (evrep.IncludeExclude == 1) //include { if (evrep.IncludeExcludeTexts != null) { bool Match = false; foreach (string s in evrep.IncludeExcludeTexts) { if (EV.Message.ToLower().Contains(s.ToLower()) == true) { Match = true; break; } } if (Match == false) { continue; } } } if (evrep.IncludeExclude == 2) //exclude { if (evrep.IncludeExcludeTexts != null) { bool Match = true; foreach (string s in evrep.IncludeExcludeTexts) { if (EV.Message.ToLower().Contains(s.ToLower()) == true) { Match = false; break; } } if (Match == false) { continue; } } } bool ReportToAdmin = RepElementRoot.ReportToAdmin.Value; bool ReportToClient = RepElementRoot.ReportToClient.Value; bool UrgentForAdmin = RepElementRoot.UrgentForAdmin.Value; bool UrgentForClient = RepElementRoot.UrgentForClient.Value; if (AlreadyReported.ContainsKey(EV.LogID) == true) { if ((AlreadyReported[EV.LogID] & (Int64)ReportingFlags.ReportToAdmin) != 0) { ReportToAdmin = false; } if ((AlreadyReported[EV.LogID] & (Int64)ReportingFlags.ReportToClient) != 0) { ReportToClient = false; } if ((AlreadyReported[EV.LogID] & (Int64)ReportingFlags.UrgentForAdmin) != 0) { UrgentForAdmin = false; } if ((AlreadyReported[EV.LogID] & (Int64)ReportingFlags.UrgentForClient) != 0) { UrgentForClient = false; } } if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false) { continue; } ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) | (ReportToClient == true ? ReportingFlags.ReportToClient : 0) | (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) | (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0); switch ((EventLogEntryType)EV.EventLogType) { case 0: case EventLogEntryType.Information: Flags = (ReportingFlags)((Int64)Flags | ((Int64)ReportingStatusPictureEnum.Info << (int)ReportingFlags.IconFlagsShift)); break; case EventLogEntryType.Warning: Flags = (ReportingFlags)((Int64)Flags | ((Int64)ReportingStatusPictureEnum.Exclamation << (int)ReportingFlags.IconFlagsShift)); break; case EventLogEntryType.Error: Flags = (ReportingFlags)((Int64)Flags | ((Int64)ReportingStatusPictureEnum.Stop << (int)ReportingFlags.IconFlagsShift)); break; case EventLogEntryType.SuccessAudit: Flags = (ReportingFlags)((Int64)Flags | ((Int64)ReportingStatusPictureEnum.Key << (int)ReportingFlags.IconFlagsShift)); break; case EventLogEntryType.FailureAudit: Flags = (ReportingFlags)((Int64)Flags | ((Int64)ReportingStatusPictureEnum.NoKey << (int)ReportingFlags.IconFlagsShift)); break; } ReportingProcessor.ReportEventLog(sql, EV.MachineID, EV, Flags); if (AlreadyReported.ContainsKey(EV.LogID) == true) { AlreadyReported[EV.LogID] |= (Int64)Flags; } else { AlreadyReported.Add(EV.LogID, (Int64)Flags); } } } } } } catch (Exception ee) { FoxEventLog.WriteEventLog("SEH in Event Data Reporting " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error); } }
internal static extern int WerSetFlags(ReportingFlags flags);
public static void ReportSMART(SQLLib sql, string MachineID, string Method, ReportingSMART AR, ReportingFlags Flags, bool Critical) { Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported); AR.Action = Method; sql.InsertMultiData("Reporting", new SQLData("MachineID", MachineID), new SQLData("Type", Critical == false ? ReportingPolicyType.SMART : ReportingPolicyType.SMARTCritical), new SQLData("Data", JsonConvert.SerializeObject(AR)), new SQLData("Flags", Flags)); }
public static void ReportAddRemoveApps(SQLLib sql, string MachineID, string Method, AddRemoveApp AR, ReportingFlags Flags) { Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported); ReportingAddRemovePrograms a = new ReportingAddRemovePrograms(); a.Action = Method; a.App = AR; sql.InsertMultiData("Reporting", new SQLData("MachineID", MachineID), new SQLData("Type", ReportingPolicyType.AddRemovePrograms), new SQLData("Data", JsonConvert.SerializeObject(a)), new SQLData("Flags", Flags)); }
public static void ReportDiskData(SQLLib sql, string MachineID, string Disk, Int64 NotifyValue, Int64 Is, Int64 TotalSZ, ReportingFlags Flags) { Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported); ReportingDiskData rep = new ReportingDiskData(); rep.Disk = Disk; rep.Is = Is; rep.NotifyValue = NotifyValue; rep.TotalSZ = TotalSZ; sql.InsertMultiData("Reporting", new SQLData("MachineID", MachineID), new SQLData("Type", ReportingPolicyType.Disk), new SQLData("Data", JsonConvert.SerializeObject(rep)), new SQLData("Flags", Flags)); }
public static void ReportEventLog(SQLLib sql, string MachineID, EventLogReportFull EV, ReportingFlags Flags) { Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported); sql.InsertMultiData("Reporting", new SQLData("MachineID", MachineID), new SQLData("Type", ReportingPolicyType.EventLog), new SQLData("Data", JsonConvert.SerializeObject(EV)), new SQLData("Flags", Flags)); }
public static void ReportSimpleTaskCompletion(SQLLib sql, string MachineID, string Method, SimpleTaskResult AR, ReportingFlags Flags) { Flags &= ~(ReportingFlags.AdminReported | ReportingFlags.ClientReported | ReportingFlags.UrgentAdminReported | ReportingFlags.UrgentClientReported); ReportingSimpleTaskCompletion a = new ReportingSimpleTaskCompletion(); a.Action = Method; a.App = AR; sql.InsertMultiData("Reporting", new SQLData("MachineID", MachineID), new SQLData("Type", ReportingPolicyType.SimpleTaskCompleted), new SQLData("Data", JsonConvert.SerializeObject(a)), new SQLData("Flags", Flags)); }
void ReportingThread(object DiskDataListO) { try { using (SQLLib sql = SQLTest.ConnectSQL("Fox SDC Server for DiskData")) { if (sql == null) { FoxEventLog.WriteEventLog("Cannot connect to SQL Server for Disk Data Reporting!", System.Diagnostics.EventLogEntryType.Error); return; } ListDiskDataReport DiskDataList = (ListDiskDataReport)DiskDataListO; List <PolicyObject> Pol = Policies.GetPolicyForComputerInternal(sql, DiskDataList.MachineID); Dictionary <string, Int64> AlreadyReported = new Dictionary <string, long>(); foreach (PolicyObject PolO in Pol) { if (PolO.Type != PolicyIDs.ReportingPolicy) { continue; } ReportingPolicyElement RepElementRoot = JsonConvert.DeserializeObject <ReportingPolicyElement>(Policies.GetPolicy(sql, PolO.ID).Data); if (RepElementRoot.Type != ReportingPolicyType.Disk) { continue; } foreach (string Element in RepElementRoot.ReportingElements) { ReportingPolicyElementDisk diskrep = JsonConvert.DeserializeObject <ReportingPolicyElementDisk>(Element); if (diskrep.DriveLetter == null) { continue; } if (diskrep.DriveLetter.Length != 1) { continue; } foreach (DiskDataReport DD in DiskDataList.Items) { string Drive = diskrep.DriveLetter; if (diskrep.DriveLetter == "$") { ComputerData d = Computers.GetComputerDetail(sql, DiskDataList.MachineID); if (d != null) { if (string.IsNullOrWhiteSpace(d.SystemRoot) == false) { Drive = d.SystemRoot.Substring(0, 1); } } } if (string.IsNullOrWhiteSpace(DD.DriveLetter) == true) { continue; } if (DD.DriveLetter.ToLower().Substring(0, 1) != Drive.ToLower()) { continue; } Int64 SZLimit; if (diskrep.Method == 1) { SZLimit = (Int64)((100m / (decimal)DD.Capacity) * (decimal)diskrep.MinimumSize); } else { SZLimit = diskrep.MinimumSize; } if (DD.FreeSpace < SZLimit) { bool ReportToAdmin = RepElementRoot.ReportToAdmin.Value; bool ReportToClient = RepElementRoot.ReportToClient.Value; bool UrgentForAdmin = RepElementRoot.UrgentForAdmin.Value; bool UrgentForClient = RepElementRoot.UrgentForClient.Value; if (AlreadyReported.ContainsKey(DD.DriveLetter) == true) { if ((AlreadyReported[DD.DriveLetter] & (Int64)ReportingFlags.ReportToAdmin) != 0) { ReportToAdmin = false; } if ((AlreadyReported[DD.DriveLetter] & (Int64)ReportingFlags.ReportToClient) != 0) { ReportToClient = false; } if ((AlreadyReported[DD.DriveLetter] & (Int64)ReportingFlags.UrgentForAdmin) != 0) { UrgentForAdmin = false; } if ((AlreadyReported[DD.DriveLetter] & (Int64)ReportingFlags.UrgentForClient) != 0) { UrgentForClient = false; } } if (ReportToAdmin == false && ReportToClient == false && UrgentForAdmin == false && UrgentForClient == false) { continue; } ReportingFlags Flags = (ReportToAdmin == true ? ReportingFlags.ReportToAdmin : 0) | (ReportToClient == true ? ReportingFlags.ReportToClient : 0) | (UrgentForAdmin == true ? ReportingFlags.UrgentForAdmin : 0) | (UrgentForClient == true ? ReportingFlags.UrgentForClient : 0); ReportingProcessor.ReportDiskData(sql, DiskDataList.MachineID, DD.DriveLetter, SZLimit, DD.FreeSpace, DD.Capacity, Flags); if (AlreadyReported.ContainsKey(DD.DriveLetter) == true) { AlreadyReported[DD.DriveLetter] |= (Int64)Flags; } else { AlreadyReported.Add(DD.DriveLetter, (Int64)Flags); } } } } } } } catch (Exception ee) { FoxEventLog.WriteEventLog("SEH in Disk Data Reporting " + ee.ToString(), System.Diagnostics.EventLogEntryType.Error); } }