private bool CanExportItems(object parameters) { if (string.IsNullOrWhiteSpace(ExportPath)) { // There's no path to export files to return(false); } if (!System.IO.Path.HasExtension(ExportPath)) { // The export path doesn't have an extension return(false); } var invalidCharacters = System.IO.Path.GetInvalidPathChars(); if (ExportPath.Any(character => { return(invalidCharacters.Contains(character)); })) { // The export path contains characters that are not // allowed in a path return(false); } bool acceptedFileType = false; foreach (var t in FileTypes) { string ending = t.Split('|')[1]; ending = ending.Substring(1); // Take the '*' character off the ending if (ExportPath.EndsWith(ending)) { // The export path ends with an acceptable // file type extension acceptedFileType = true; break; } } return(acceptedFileType); }
public override void Execute(IEmailItem emailItem = null, int?lastExitCode = null) { ExitCode = (int)ExitCodeEnum.CommandNotRun; if (!AppliesTo(emailItem, lastExitCode)) { return; } string exportFileName = string.Empty; if (Export) { if (string.IsNullOrEmpty(ExportPath)) { ExportPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); } var invalidPathChars = Path.GetInvalidPathChars(); ExportPath = new string(ExportPath.Where(x => !invalidPathChars.Contains(x)).ToArray()); if (string.IsNullOrEmpty(EmlFileName)) { var messageId = emailItem.Message.MessageId; EmlFileName = !string.IsNullOrEmpty(messageId) ? string.Format("{0}.eml", messageId) : string.Format("{0}.eml", Guid.NewGuid()); } EmlFileName = new string(EmlFileName.Where(x => !invalidPathChars.Contains(x)).ToArray()); exportFileName = Path.Combine(ExportPath, EmlFileName); if (null != emailItem && !emailItem.IsExported) { Logger.Debug(@"[GenericTransportAgent] Exporting EML file to ""{1}""...", EmlFileName); emailItem.Save(exportFileName); } } if (!string.IsNullOrEmpty(Cmd)) { var process = new Process { StartInfo = { FileName = Cmd, }, }; if (!string.IsNullOrEmpty(Args)) { if (Args.Contains("$emlfile$")) { Args = Args.Replace("$emlfile$", exportFileName); } process.StartInfo.Arguments = Args; } Logger.Debug(@"[GenericTransportAgent] Running command ""{1}"" (args: ""{2}"")...", Cmd, Args); process.Start(); process.WaitForExit(Timeout); if (!process.HasExited) { Logger.Debug(@"[GenericTransportAgent] - Command did not exit successfully..."); process.Kill(); ExitCode = (int)ExitCodeEnum.CommandTimedOut; } else { ExitCode = process.ExitCode; Logger.Debug(@"[GenericTransportAgent] - Command did exit successfully, exit code {1}...", ExitCode); } } if (null == Handlers || Handlers.Count <= 0) { return; } foreach (var handler in Handlers) { handler.Execute(emailItem, ExitCode); } }
public override int GetHashCode() { int hash = 1; if (BatchSize != 0) { hash ^= BatchSize.GetHashCode(); } if (NumVisualizations != 0) { hash ^= NumVisualizations.GetHashCode(); } if (NumExamples != 0) { hash ^= NumExamples.GetHashCode(); } if (EvalIntervalSecs != 0) { hash ^= EvalIntervalSecs.GetHashCode(); } if (MaxEvals != 0) { hash ^= MaxEvals.GetHashCode(); } if (SaveGraph != false) { hash ^= SaveGraph.GetHashCode(); } if (VisualizationExportDir.Length != 0) { hash ^= VisualizationExportDir.GetHashCode(); } if (EvalMaster.Length != 0) { hash ^= EvalMaster.GetHashCode(); } hash ^= metricsSet_.GetHashCode(); if (ExportPath.Length != 0) { hash ^= ExportPath.GetHashCode(); } if (IgnoreGroundtruth != false) { hash ^= IgnoreGroundtruth.GetHashCode(); } if (UseMovingAverages != false) { hash ^= UseMovingAverages.GetHashCode(); } if (EvalInstanceMasks != false) { hash ^= EvalInstanceMasks.GetHashCode(); } if (MinScoreThreshold != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(MinScoreThreshold); } if (MaxNumBoxesToVisualize != 0) { hash ^= MaxNumBoxesToVisualize.GetHashCode(); } if (SkipScores != false) { hash ^= SkipScores.GetHashCode(); } if (SkipLabels != false) { hash ^= SkipLabels.GetHashCode(); } if (VisualizeGroundtruthBoxes != false) { hash ^= VisualizeGroundtruthBoxes.GetHashCode(); } if (GroundtruthBoxVisualizationColor.Length != 0) { hash ^= GroundtruthBoxVisualizationColor.GetHashCode(); } if (KeepImageIdForVisualizationExport != false) { hash ^= KeepImageIdForVisualizationExport.GetHashCode(); } if (RetainOriginalImages != false) { hash ^= RetainOriginalImages.GetHashCode(); } if (IncludeMetricsPerCategory != false) { hash ^= IncludeMetricsPerCategory.GetHashCode(); } if (RecallLowerBound != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(RecallLowerBound); } if (RecallUpperBound != 0F) { hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(RecallUpperBound); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
// Override object.GetHashCode public override int GetHashCode() { return(Name.GetHashCode() ^ ExportPath.GetHashCode() ^ SaveFile.GetHashCode()); }