private Rejection EvaluateSpec(IRejectWithReason spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null) { try { if (spec.RejectionReason.IsNullOrWhiteSpace()) { throw new InvalidOperationException("[Need Rejection Text]"); } var generalSpecification = spec as IDecisionEngineSpecification; if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase)) { return(new Rejection(spec.RejectionReason, generalSpecification.Type)); } } catch (Exception e) { e.Data.Add("report", remoteEpisode.Release.ToJson()); e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); _logger.ErrorException("Couldn't evaluate decision on " + remoteEpisode.Release.Title, e); return(new Rejection(String.Format("{0}: {1}", spec.GetType().Name, e.Message))); } return(null); }
private string EvaluateSpec(IRejectWithReason spec, LocalEpisode localEpisode) { try { if (string.IsNullOrWhiteSpace(spec.RejectionReason)) { throw new InvalidOperationException("[Need Rejection Text]"); } var generalSpecification = spec as IImportDecisionEngineSpecification; if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(localEpisode)) { return(spec.RejectionReason); } } catch (Exception e) { //e.Data.Add("report", remoteEpisode.Report.ToJson()); //e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); _logger.ErrorException("Couldn't evaluate decision on " + localEpisode.Path, e); return(string.Format("{0}: {1}", spec.GetType().Name, e.Message)); } return(null); }
private string EvaluateSpec(IRejectWithReason spec, RemoteEpisode remoteEpisode, SearchCriteriaBase searchCriteriaBase = null) { try { if (string.IsNullOrWhiteSpace(spec.RejectionReason)) { throw new InvalidOperationException("[Need Rejection Text]"); } var generalSpecification = spec as IDecisionEngineSpecification; if (generalSpecification != null && !generalSpecification.IsSatisfiedBy(remoteEpisode, searchCriteriaBase)) { return spec.RejectionReason; } } catch (Exception e) { e.Data.Add("report", remoteEpisode.Release.ToJson()); e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); _logger.ErrorException("Couldn't evaluate decision on " + remoteEpisode.Release.Title, e); return string.Format("{0}: {1}", spec.GetType().Name, e.Message); } return null; }