protected async override Task <ProcessResult> OnPolling(PollerJobParameters parameters, string workingFolder) { String format = parameters.All.GetOrDefault(JobKeys.ThumbnailFormat)?.ToLower() ?? "png"; ImageFormat imageFormat; switch (format) { case "png": imageFormat = ImageFormat.Png; break; case "bmp": imageFormat = ImageFormat.Bmp; break; default: imageFormat = ImageFormat.Png; break; } Logger.DebugFormat("Conversion for jobId {0} in format {1} starting", parameters.JobId, format); string pathToFile = await DownloadBlob(parameters.TenantId, parameters.JobId, parameters.FileName, workingFolder).ConfigureAwait(false); using (SolidEdgeDocument document = SolidEdgeDocument.Open(pathToFile)) { Logger.Debug(String.Format("ClassId: '{0}'", document.ClassId)); Logger.Debug(String.Format("CreatedVersion: '{0}'", document.CreatedVersion)); Logger.Debug(String.Format("LastSavedVersion: '{0}'", document.LastSavedVersion)); Logger.Debug(String.Format("Created: '{0}'", document.Created)); Logger.Debug(String.Format("LastModified: '{0}'", document.LastModified)); Logger.Debug(String.Format("Status: '{0}'", document.Status)); String thumbFileName = Path.ChangeExtension(pathToFile, "." + format); using (Bitmap bitmap = document.GetThumbnail()) { bitmap.Save(thumbFileName, imageFormat); } if (File.Exists(thumbFileName)) { await AddFormatToDocumentFromFile( parameters.TenantId, parameters.JobId, new DocumentFormat(DocumentFormats.RasterImage), thumbFileName, new Dictionary <string, object>()); Logger.DebugFormat("Conversion of {0} in format {1} done", parameters.JobId, format); return(ProcessResult.Ok); } } return(ProcessResult.Fail("Unable to extract thumbnail")); }
public static int Main(string[] args) { try { Native.DisableWindowsErrorReporting(); Int32 exitCode; if (args.Length > 0) { var autoExecution = FindArgument(args, "/autoRestart:"); if ("true".Equals(autoExecution, StringComparison.OrdinalIgnoreCase)) { SetupAutoRestart(); } String dsBaseAddress = FindArgument(args, "/dsuris:"); String queueName = FindArgument(args, "/queue:"); String handle = FindArgument(args, "/handle:", "Default"); if (String.IsNullOrEmpty(dsBaseAddress) || String.IsNullOrEmpty(queueName)) { Console.WriteLine("Error in parameters: dsuris={0} queue={1}", dsBaseAddress, queueName); Console.ReadKey(); return(-1); } exitCode = SingleJobStart(dsBaseAddress, queueName, handle); if (exitCode > 0) { ReStart(); } return(exitCode); } Console.WriteLine("Wrong command line. This utilities expetcs following parameters:"); Console.WriteLine("/dsuris:http://localhost:5123 - List of addresses (comma separated) of document store uris."); Console.WriteLine("/queue:tika - Name of the queue"); Console.WriteLine("/handle:xxxxx - Optional, a string that identify this worker"); Console.ReadKey(); return(0); } catch (Exception ex) { var fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_lastError.txt"); File.WriteAllText(fileName, ex.ToString()); throw; } }
internal DocumentImportTask LoadTask(string pathToFile) { try { var asJson = File.ReadAllText(pathToFile) .Replace("%CURRENT_DIR%", Path.GetDirectoryName(pathToFile).Replace("\\", "/")); var task = JsonConvert.DeserializeObject <DocumentImportTask>(asJson, PocoSerializationSettings.Default); task.PathToTaskFile = pathToFile; task.FileTimestamp = File.GetLastWriteTimeUtc(pathToFile); return(task); } catch (Exception ex) { Logger.ErrorFormat(ex, "failed to deserialize {0}", pathToFile); return(null); } }
private static int Main(string[] args) { var lastErrorFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_lastError.txt"); if (File.Exists(lastErrorFileName)) { File.Delete(lastErrorFileName); } try { MongoRegistration.RegisterMongoConversions( "NEventStore.Persistence.MongoDB" ); MongoFlatMapper.EnableFlatMapping(true); CommandsExtensions.EnableDiagnostics = true; Native.DisableWindowsErrorReporting(); MongoFlatMapper.EnableFlatMapping(true); //before any chanche that the driver scan any type. Int32 executionExitCode; if (args.Length == 1 && (args[0] == "install" || args[0] == "uninstall")) { executionExitCode = (Int32)StartForInstallOrUninstall(); } else { executionExitCode = (Int32)StandardDocumentStoreStart(); } return(executionExitCode); } catch (Exception ex) { File.WriteAllText(lastErrorFileName, ex.ToString()); throw; } }