internal void InterceptRSSEvtRequest(TheRequestData pRequest) { if (pRequest == null) { return; } try { TheStorageMirror <TheEventLogData> tEventLog = TheCDEngines.GetStorageMirror("EventLog") as TheStorageMirror <TheEventLogData>; if (tEventLog != null) { CreateEvtLogFeed(pRequest, tEventLog?.TheValues.OrderByDescending(s => s.cdeCTIM).ThenByDescending(s => s.cdeCTIM.Millisecond).ToList(), 200); } else { TheRSSGenerator.CreateRSS(pRequest, new List <TheEventLogData>() { new TheEventLogData() { EventName = "No Eventlog on this Node" } }, 1); } } catch { //ignored } }
public static void CreateEvtLogFeed(TheRequestData pRequest, List <TheEventLogData> pLogData, int MaxCnt) { if (pRequest.RequestUri != null && !string.IsNullOrEmpty(pRequest.RequestUri.Query) && pRequest.RequestUri.Query.Length > 1) { var QParts = TheCommonUtils.ParseQueryString(pRequest.RequestUri.Query); //.Split('='); //if (QParts.ContainsKey("SID") && (!TheScopeManager.IsValidScopeID(TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"])) || QParts.ContainsKey("NID"))) //{ // pRequest.SessionState.SScopeID = TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"]); // Guid tTarget = Guid.Empty; // if (QParts.ContainsKey("NID")) // tTarget = TheCommonUtils.CGuid(QParts["NID"]); // TheHttpService.cdeStreamFile(pRequest, true, 300, tTarget); // if (pRequest.ResponseBuffer == null) // TheRSSGenerator.CreateRSS(pRequest, new List<TheEventLogData>() { new TheEventLogData() { EventName = "Relay did not answer" } }, 1); // return; //} } if (pLogData != null) { TheRSSGenerator.CreateRSS(pRequest, pLogData, 200); } else { TheRSSGenerator.CreateRSS(pRequest, new List <TheEventLogData>() { new TheEventLogData() { EventName = "No Eventlog on this Node" } }, 1); } }
internal static void CreateRSS(TheRequestData pRequest, List <TheEventLogData> pLog, int MaxCnt) { try { using (MemoryStream tW = new MemoryStream()) { TheRSSGenerator gen = new TheRSSGenerator(tW) { Title = TheBaseAssets.MyServiceHostInfo.ApplicationTitle + " - Event Feed", Description = "All Events coming from the Rules Event Log", LastBuildDate = DateTimeOffset.Now, Link = TheBaseAssets.MyServiceHostInfo.SiteName, PubDate = DateTimeOffset.Now }; //gen.Category = "Home-Automation"; gen.WriteStartDocument(); gen.WriteStartChannel(); int cnt = 0; foreach (TheEventLogData tEntry in pLog) { gen.WriteItem( tEntry.EventName, TheBaseAssets.MyServiceHostInfo.SiteName + "/" + TheBaseAssets.MyServiceHostInfo.PortalPage, //"url to the item page", string.Format("{0} occured at {1} on stations {2}. {3}", tEntry.EventName, tEntry.EventTime, tEntry.StationName, tEntry.EventString), // "the description of the item", tEntry.StationName, // "the author", tEntry.EventTrigger, // "the category", "", //"comments", tEntry.cdeMID.ToString(), //"the guid", tEntry.EventTime, // DateTimeOffset.Now, tEntry.StationName, //"the source", "", //"enclosure URL", "", //"enclosure length", "" //"enclosure type" ); if (MaxCnt > 0 && cnt > MaxCnt) { break; } cnt++; } gen.WriteEndChannel(); gen.WriteEndDocument(); gen.Close(); pRequest.ResponseBuffer = tW.ToArray(); } pRequest.StatusCode = 200; pRequest.ResponseMimeType = "application/rss+xml"; pRequest.DontCompress = true; } catch { // do something with the error } }
internal static void CreateRSS(TheRequestData pRequest, List <TheEventLogEntry> pLog, int MaxCnt) { try { using (MemoryStream tW = new MemoryStream()) { TheRSSGenerator gen = new TheRSSGenerator(tW) { Title = TheBaseAssets.MyServiceHostInfo.ApplicationTitle + " - System Log Feed", Description = "Last Events of the System Log", LastBuildDate = DateTimeOffset.Now, Link = TheBaseAssets.MyServiceHostInfo.SiteName, PubDate = DateTimeOffset.Now }; gen.WriteStartDocument(); gen.WriteStartChannel(); int cnt = 0; foreach (TheEventLogEntry tEntry in pLog) { gen.WriteItem( tEntry.Message.TXT, TheBaseAssets.MyServiceHostInfo.SiteName + "/" + TheBaseAssets.MyServiceHostInfo.PortalPage, //"url to the item page", tEntry.Message.PLS, // "the description of the item", tEntry.Message.ENG, // "the author", tEntry.Message.ENG, //"the category", "", //"comments", tEntry.cdeMID.ToString(), //"the guid", tEntry.cdeCTIM, // DateTimeOffset.Now, tEntry.Message.ENG, //"the source", "", //"enclosure URL", "", //"enclosure length", "" //"enclosure type" ); if (MaxCnt > 0 && cnt > MaxCnt) { break; } cnt++; } gen.WriteEndChannel(); gen.WriteEndDocument(); gen.Close(); pRequest.ResponseBuffer = tW.ToArray(); } pRequest.StatusCode = 200; pRequest.ResponseMimeType = "application/rss+xml"; pRequest.DontCompress = true; } catch { // do something with the error } }
public static void CreateSysLogFeed(TheRequestData pRequest, int MaxCnt) { if (pRequest.RequestUri != null && !string.IsNullOrEmpty(pRequest.RequestUri.Query) && pRequest.RequestUri.Query.Length > 1) { var QParts = TheCommonUtils.ParseQueryString(pRequest.RequestUri.Query); //.Split('='); //if (QParts.ContainsKey("SID") && (!TheScopeManager.IsValidScopeID(TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"])) || QParts.ContainsKey("NID"))) //{ // pRequest.SessionState.SScopeID = TheScopeManager.GetScrambledScopeIDFromEasyID(QParts["SID"]); // Guid tTarget = Guid.Empty; // if (QParts.ContainsKey("NID")) // tTarget = TheCommonUtils.CGuid(QParts["NID"]); // Communication.HttpService.TheHttpService.cdeStreamFile(pRequest, true, 10, tTarget); // if (pRequest.ResponseBuffer == null) // TheRSSGenerator.CreateRSS(pRequest, new List<TheEventLogData>() { new TheEventLogData() { EventName = "Relay did not answer" } }, 1); // return; //} } TheStorageMirror <TheEventLogEntry> tEventLog = TheCDEngines.GetStorageMirror($"{typeof(TheEventLogEntry)}") as TheStorageMirror <TheEventLogEntry>; TheRSSGenerator.CreateRSS(pRequest, tEventLog.TheValues.OrderByDescending(s => s.cdeCTIM).ThenByDescending(s => s.cdeCTIM.Millisecond).ToList(), MaxCnt); }