Mirth Connect Filename sent needs original file name and date sent - filenames

I have tried a few different things when sending filename.
It seems like it does not like using
$OriginalFilename)$(date.get('yyyy-MM-dd').
It wants to add date after file extention.
Is it possible in Mirth to even do this?
Thank you in advance:)

Add this in your message transformer. (can be either source or destination side)
var newfilename = sourceMap.get('originalFilename').replace('.txt','') + DateUtil.getCurrentDate('yyyy-MM-dd') + '.txt';
channelMap.put('newfilename',newfilename);
After that, just put ${newfilename} in for the destination file name.

Related

VB.net download file via ftpwebrequest -> directory topic?

I need to download a file from a FTP Server.
The path and the file name is
ftp://10.17.20.60/ata0b/OpconData/StationData/Station.dat
When i want to see all Files in the StationData directory i use
Dim request As Net.FtpWebRequest = Net.FtpWebRequest.Create("ftp://10.17.20.60/%2F/ata0b/OpconData/StationData/")
request.Method = Net.WebRequestMethods.Ftp.ListDirectory
request.Credentials = New Net.NetworkCredential(form1.txtFTPUser.Text, form1.txtFTPPasswort.Text)
Dim response As Net.FtpWebResponse = request.GetResponse()
With this i get the content of the directory. Of course i see the Station.dat file. I was able to make it work since i use the %2F parameter to change the directory to ata0b.
So far so good!
Now i want to download the Station.dat file. But i always get an error (550) File unavailable (e.g., file not found, no access) at the last line in code below.
My code looks like this:
'Create Request To Download File'
Dim wrDownload As FtpWebRequest = WebRequest.Create("ftp://10.17.20.60/%2F/ata0b/OpconData/StationData/Station.dat")
'Specify That You Want To Download A File'
wrDownload.Method = WebRequestMethods.Ftp.DownloadFile
'Specify Username & Password'
wrDownload.Credentials = New NetworkCredential("opconadmin", "OpconAdmin")
'Response Object'
Dim rDownloadResponse As FtpWebResponse = wrDownload.GetResponse()
What's my failure? In my point of view the file must be at the given path. I really hope somebody can give me a hint.
BR
Steffen
The error means what it says.But let me explain why this might occur :
1 • The file might be unavailable/not present on the server
2 • You might face 'Security Problem on file' issue .
There could be other causes like server timeout or other..
However,you need to find out what the error message really is.TO do this, you can use a TRY-CATCH statement. E.g.
Try
'YOur code here
Catch e as WebException
Msgbox(e.Message) 'you can use e.tostring for more details
After you find out what exactly is the problem,then you'ld be able to solve it.Take a look at these :
http://www.dreamincode.net/forums/topic/76361-file-upload-to-server/
https://nickstips.wordpress.com/2010/10/25/c-ftp-upload-error-the-remote-server-returned-an-error-550-file-unavailable-e-g-file-not-found-no-access/
https://forums.asp.net/t/1777881.aspx
But one thing i'ld like to suggest is to check whether you have any Permission/Security issues or not.And after you get the exact error message,it may(or may not) turn out to be that you don't have enough disk space.However,try my solution and leave a reply for further assistance.
UPDATE
Try replacing the FTP link with this : ftp://10.17.20.60//ata0b/OpconData/StationData/Station.da

BizTalk 2010 Dynamic FTP Send Port Output Directory and File Name Issue

I have a rather complex requirement - that I have to drop a very specifically named file in an FTP location, and the trick here is that I would often have to drop it into a new location and with a new file name each time (both directory name and file name depending on the year, month, date and time). Obviously, for this purpose I chose to use a Dynamic Send Port, which I have configured using a MessageAssignment Shape.
A file will be generated each day. I need to drop it in a remote location in this form:
sample-servername-stage/default/file/ftp/PaymentReports/YYYY/MM_[MonthName]/PaymentReportYYYYMMDD_HHMISS
For example, for a file posted on March, 2 2016 at 6:45pm, we would have:
sample-servername-stage/default/file/ftp/PaymentReports/2016/03_March/PaymentReport20160302_184500
Here's the code I have in the MessageAssignment Shape:
FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address) = "ftp://sample-servername-stage:721";
FTPSendPort1(Microsoft.XLANGs.BaseTypes.TransportType) = "FTP";
Output(FTP.CommandLogFileName) = "D:\\BiztalkLogs\\FTPLog\\DynamicFTPLog.txt";
Output(FTP.UserName) = "sampleUsername";
Output(FTP.Password) = "samplePassword";
Output(FTP.BeforePut) = "MKD " + Variable_1 + ";CWD " + Variable_1;
FTPSendport1 - name of the Dynamic Send Port.
Output - name of the Output message.
Variable_1 - variable where I will store the directory name to be created.
Here are the biggest issues:
I need to check if a directory already exists - the year, then navigate in and check if the month already exists. If they exist I simply go in there and drop the file. If not, I create it and drop the file in there.
I need to name the file with the date time specifics in the format shown above. In addition to the code shown above, I have tried a number of things including setting FILE.ReceivedFileName, FTP.ReceivedFileName properties etc. Nothing seems to work. This may be because I cannot use the macro %SourceFileName% anywhere. Because of this it keeps dropping the file into the location with a GUID name instead of the one I set. It behaves as though it completely skips/overlooks the command where I set the file name.
I'm thoroughly confused at this point. I'm not sure of how I can mix checking conditions (if the folders already exist etc.) with FTP commands, and especially not sure of how to do this within an orchestration.
The file naming is done in the address property where you provide the FTP URL. In fact you can even use macros in there. Try that:
FTPSendPort1(Microsoft.XLANGs.BaseTypes.Address) = "ftp://sample-servername-stage:721/SomeFolder/SomeFileName_%datetime%.xml"
For you other problem of checking if folders exists on the FTP and creating them, I think you'll have to write a custom pipeline component.

PhpBB attachment files

In the phpbb_attachments table of the database, we can find link between file on server and real name.
Example :
Physical filename = 2_8f375562c92996d3272ea0b43947b0e7
Real_filename = blah.jpg
Then if I try to open the file 2_8f375562c92996d3272ea0b43947b0e7 which is stored on server (by renaming with .jpg), its content is not the real image : the image is like "encrypted" !
Is there an attachment content encryption when storing attachment on server ?
If so, how to manually see the real content of an attachment?
There is a script in the phpBB knowledge base that you can use to back up all attachments with their original file name - https://www.phpbb.com/kb/article/backing-up-attachments-with-their-original-filenames/

How do i download a file with CA-VO

I'd like to download a file using HTTP. How do I do it?
I have investigated this further and have re-ordered my suggestions from last week as a result:
The class 'CHttp' in VO's 'Internet' library has a method GetFile (the VO 2.5 "what's new" has a brief description on page 10). I've not tried it, though. You'll probably want something like this:
local oSession as CHttp
local lSuccess as logic
oSession := CHttp{}
oSession:ConnectRemote("foo.example.com") // Server domain name
lSuccess := oSession:GetFile("bar/baz.pdf",; // Remote filename
"c:\temp\baz.pdf",; // Local filename
lFailIfAlreadyExists)
oSession:CloseRemote()
// If lSuccess, the file should be downloaded to cLocalFileName.
// I don't know whether the filename arguments should use / or \ for directory separators.
I think another way is to use the Windows ShellExecute function to invoke an external program which downloads the file. I found an example of ShellExecute here. I haven't tried this as I don't have a VO compiler (or help file!) available to me at the moment. I'm not sure whether this is a good way or not, and I don't know whether it's safe from people trying to run a malicious command by supplying a sneaky filename. But I think the following might work. It assumes you have the program curl.exe (see: curl) on your path, which is used for downloading the file. You may need the fully path of curl.exe instead. I'm not sure where the file will be saved by default (I think you can specify a working directory in the parameter labelled lpDirectory)
local cParameters as string
local cURL:="http://www.example.com/interesting.htm" as string
local cLocalFile:="savefile.html" as string
cParameters := "-o "+cLocalFile+" "+cURL
ShellExecute(NULL /*Window handle*/,;
String2PSZ("open"),;
String2PSZ("curl.exe"),;
String2PSZ(cParameters),;
NULL_PTR /* lpDirectory */,;
SW_SHOWNORMAL)
See also the MSDN page for ShellExecute.
There appears to be a method App:Run(cCommand) which can be used to start external applications

NSAppleScriptErrorNumber = -1708

I am trying to attach a Image to Mail application using Applescript. But on 10.5 I am getting
NSAppleScriptErrorNumber = -1708 error. What is this error means?
Can anybody guide me with this?
Regards,
Sowmya
I wrote an applescript that tells you what the error codes mean. Get it here. Look in post #9 for the most recent version I posted.
As Philip Regan says. More info needed.
But I suspect its your construction of the file paths.
I have used NSAppleScript in the past to attach files to mail. If I remember right. My app gathered the files path as a Unix type path string.
i.e /Users/UserName/Documents/myFile.ext.
And in the NSApplescript script string I use "POSIX file \"%#\") as alias"
NSString *scriptString= [NSString stringWithFormat:#"set theMailname to (POSIX file \"%#\") as alias\ntell application \"Mail\"\nset newMessage to make new outgoing message with properties{visible:true,subject:\"%#\", content:\"%#\"}\ntell newMessage\nset visible to false\n\nmake new to recipient at end of to recipients with properties {address:\"%#\"}\n set theAddressFrom to \"%#\"\ntell content\nmake new attachment with properties {file name:theMailname} at after the last paragraph\nend tell\n save \nend tell\nend tell",fileStore,subject,body,theAddressTo,theAddressFrom];
fileStore being the unix type path of the file that is converted to an Alias.