OutputFileServerDeviceProcessingScriptTemplate Field |
Default processing script template
Namespace: Seal.ModelAssembly: SealLibrary (in SealLibrary.dll) Version: 8.3.0.0+c4d725cbae26375217e6c77c92a07fffaea6377d
Syntaxpublic const string ProcessingScriptTemplate = "@using Renci.SshNet\r\n@using FluentFTP\r\n@using System.IO\r\n@using System.Security.Authentication\r\n@{\r\n //Upload the file to the server\r\n Report report = Model;\r\n ReportOutput output = report.OutputToExecute;\r\n var device = output.Device as OutputFileServerDevice;\r\n\r\n var resultFileName = (output.ZipResult ? Path.GetFileNameWithoutExtension(report.ResultFileName) + ".zip" : Path.GetFileNameWithoutExtension(report.ResultFileName) + Path.GetExtension(report.ResultFilePath));\r\n device.HandleZipOptions(report);\r\n\r\n //Put file\r\n var remotePath = output.FileServerFolderWithSeparators + resultFileName;\r\n\r\n if (device.Protocol == FileServerProtocol.FTP)\r\n {\r\n //Refer to https://github.com/robinrodricks/FluentFTP\r\n using (var client = new FtpClient()) {\r\n client.Host = device.HostName;\r\n client.Credentials.UserName = device.UserName;\r\n client.Credentials.Password = device.ClearPassword;\r\n\r\n client.Config.EncryptionMode = FtpEncryptionMode.Auto;\r\n client.Config.ValidateAnyCertificate = true;\r\n if (device.PortNumber == 0) {\r\n client.AutoConnect();\r\n }\r\n else {\r\n client.Port = device.PortNumber;\r\n //SSL Configuration can be defined here\r\n /*\r\n client.Config.EncryptionMode = FtpEncryptionMode.Explicit;\r\n client.Config.SslProtocols = SslProtocols.Tls12;\r\n client.ValidateCertificate += new FtpSslValidation(delegate (FluentFTP.Client.BaseClient.BaseFtpClient control, FtpSslValidationEventArgs e)\r\n {\r\n if (e.PolicyErrors != System.Net.Security.SslPolicyErrors.None) {\r\n e.Accept = false;\r\n }\r\n else {\r\n e.Accept = true;\r\n }\r\n });\r\n */\r\n client.Connect();\r\n }\r\n client.UploadFile(report.ResultFilePath, remotePath);\r\n client.Disconnect();\r\n }\r\n }\r\n else if (device.Protocol == FileServerProtocol.SFTP)\r\n {\r\n //Refer to https://github.com/sshnet/SSH.NET\r\n using (var sftp = new SftpClient(device.HostName, device.PortNumber, device.UserName, device.ClearPassword))\r\n {\r\n sftp.Connect();\r\n using (Stream fileStream = File.Create(report.ResultFilePath))\r\n {\r\n sftp.UploadFile(fileStream, remotePath);\r\n }\r\n sftp.Disconnect();\r\n }\r\n }\r\n else if (device.Protocol == FileServerProtocol.SCP)\r\n {\r\n //Refer to https://github.com/sshnet/SSH.NET\r\n using (var scp = new ScpClient(device.HostName, device.PortNumber, device.UserName, device.ClearPassword))\r\n {\r\n scp.Connect();\r\n using (Stream fileStream = File.Create(report.ResultFilePath))\r\n {\r\n scp.Upload(fileStream, remotePath);\r\n }\r\n scp.Disconnect();\r\n }\r\n }\r\n\r\n output.Information = report.Translate("Report result generated in '{0}'", remotePath);\r\n report.LogMessage("Report result generated in '{0}'", remotePath);\r\n}\r\n"
Field Value
String
See Also