/// <summary> /// Checks for a condition and displays a message if the condition is false. /// </summary> /// <param name="edc">The <see cref="Entities"/> object.</param> /// <param name="condition"> <c>true</c> to prevent a message being displayed; otherwise, false.</param> /// <param name="source">The source of the assertion.</param> /// <param name="message">The message to log.</param> public static void Assert(Entities edc, bool condition, string source, string message) { if (condition) { return; } ActivityLogCT.WriteEntry(edc, source, message); }
/// <summary> /// Writes an entry with the given message text and application-defined event identifier to the event log list. /// </summary> /// <param name="entities">Provides LINQ (Language Integrated Query) access to, and change tracking for, /// the lists and document libraries of a Windows SharePoint Services "14" Web site.</param> /// <param name="source">The source denominator of the message.</param> /// <param name="message">The string to write to the event log.</param> public static void WriteEntry(Entities entities, string source, string message) { if (entities == null) { EventLog.WriteEntry("CAS.SmartFActory", "Cannot open \"Event Log List\" list", EventLogEntryType.Error, 114); return; } ActivityLogCT log = new ActivityLogCT(source, message, TraceLevel.Error, "ActivityLogCT"); entities.ActivityLog.InsertOnSubmit(log); entities.SubmitChangesSilently(Microsoft.SharePoint.Linq.RefreshMode.OverwriteCurrentValues); }
/// <summary> /// Reports the action result. /// </summary> /// <param name="url">The _url.</param> public void ReportActionResult(string url) { if (this.Count == 0) { return; } try { using (Entities _edc = new Entities(url)) { foreach (string _msg in this) { ActivityLogCT _entry = new ActivityLogCT() { Title = "ReportActionResult", Body = _msg, Expires = DateTime.Now + new TimeSpan(2, 0, 0, 0) }; _edc.ActivityLog.InsertOnSubmit(_entry); } _edc.SubmitChanges(); } } catch (Exception) { } }
/// <summary> /// Writes an entry with the given message text and application-defined event identifier to the event log list. /// </summary> /// <param name="source">The source denominator of the message.</param> /// <param name="message">The string to write to the event log.</param> /// <param name="url">The URL.</param> public static void WriteEntry(string source, string message, string url) { using (Entities edc = new Entities(url)) ActivityLogCT.WriteEntry(edc, source, message); }