/// <summary> /// Clones the event and adds it (if necessary) to the project, then runs all enabled filters against it. Returns a string that is null if there was no error, or an error code such as "FILTER ERROR" if there was an error. /// </summary> /// <param name="p">Project to insert the event into.</param> /// <param name="eventOriginal">Event to clone and insert. The event object is not changed by this method.</param> /// <returns>Returns a string that is null if there was no error, or an error code such as "FILTER ERROR" if there was an error.</returns> private SubmitResult InsertIntoProject(Project p, Event eventOriginal) { try { Event ev = JsonConvert.DeserializeObject <Event>(JsonConvert.SerializeObject(eventOriginal)); using (FilterEngine fe = new FilterEngine(p.Name)) { BasicEventTimer bet = fe.AddEventAndRunEnabledFilters(ev); if (Settings.data.verboseSubmitLogging) { Util.SubmitLog(p.Name, "Event " + ev.EventId + " Submission Succeeded\r\n" + bet.ToString("\r\n")); } } PushManager.Notify(p.Name, ev); return(SubmitResult.OK); } catch (FilterException ex) { string timing = "\r\n" + ex.timer.ToString("\r\n"); Util.SubmitLog(p.Name, "Event Submission Failed with FilterException" + timing + "\r\n" + ex.ToString()); Logger.Debug(ex, "FilterEngine Error" + timing); Emailer.SendError(Context, "FilterEngine Error" + timing, ex); return(SubmitResult.FilterError); } catch (Exception ex) { Util.SubmitLog(p.Name, "Event Submission Failed with Exception\r\n" + ex.ToString()); Logger.Debug(ex, "Unhandled exception thrown when inserting event into project \"" + p.Name + "\"."); Emailer.SendError(Context, "Unhandled exception thrown when inserting event into project \"" + p.Name + "\".", ex); return(SubmitResult.FatalError); } }