We are looking at different ways to update a VSAM file.
One of the things that we would like to do is to stop writing any new cobol code.
We were wondering is it possible to download a VSAM file from the Main Frame to a Windows Server, then use a C# program to edit it, then transfer it back to the Main frame?
Has anyone tried this?
And yes we are moving away from the use of VSAM, but it takes time.
There are plenty of other options for updating a VSAM file other than a COBOL program.
Transferring the file and and back again seems a perverse and error prone way to update a simple VSAM file. Most VSAM files contain a mix of character, integer and packed decimal data, C# plain cannot handle mainframe packed decimal and any attempt to translate EBDCIC to ASCII during file transfer will corrupt the packed decimal and binary values, so, you will need to manipulate raw EBCDIC characters.
Obviously you can write a COBOL program! (seems perverse not to!)
You could also write a C, C++, Java or PL/1 program all of which run on the mainframe, all of which have VSAM support.
You could extract to a sequential file update with a script (zsh, Rexx, PERL etc. etc.) and reload. (Your site may have an add-in that allows direct update from Rexx).
Most largish mainframe sites have an add on utility like File-Aid, Startool or Ditto which allow direct editing of VSAM files.
The MS way would be to use Biztalk Microsoft Host Integration Server to access VSAM.
There might be other non-MS drivers, which I am not aware of - maybe via DB2 Windows drivers.
Related
**
Hello
**
I'm creating a scheduling app that takes in 2 MS-Project .mpp files (master and updated) and converts the data into SQLite tables then compares them both and displays the results and allows you to write the changes you make back to the master file. I had issues with Microsoft Interop because I don't own Microsoft Project. Is MPXJ a viable solution? The documentation I've read on it doesn't have many examples. If so how would I read it in and read it back? Were using MS-project 2016
I know nothing of MPXJ, so sorry if I overlook a more straightforward answer. It sounds to me like another way of looking at your problem is you want to:
1. Parse a MS Project file (and then do it again) and store results in memory
2. Do some data manipulation and calculations of the in-memory project data
3. Put that data into a database
I think you're stuck at step 1 because without MS Project, you lack a parser; correct? There are other ways to parse a project file. The simplest may be to have your users first convert the files to a more open format (e.g. XML) when they save them from their instances of MS Project. Lacking that, there are certainly libraries out there that can parse a Project file. Try taking a look at Gantt Project, https://sourceforge.net/projects/ganttproject/ . Being open source, you could look at that parser as a starting point; I'm not a license expert, but you may even be able to re-use the code from there.
Good luck!
Does anyone know if its possible to read ascii the files that Btrieve Maintenance Utility creates during its recover process using C#
We create sequence files using the following command on windows
for %%f in (*.xq?) DO BUTIL -recover %%f %%f.seq
I know these files are Ascii files but when i open them in notepad++ it's almost impossible to make something of it
If i look at the documentation of it,i can't figure out how i need to read these files using C#
Those aren't regular ASCII files. They are byte images of the record. For strings, they come through as ASCII but numbers don't come through as human readable text. You would have to parse the individual bytes within each line and would need record structure.
If you know the record structure, you might be able to parse the data into a structure but not every Btrieve data type is directly accessible through C#.
A better option is to use the Btrieve / PSQL client, read the actual data file, and extract it using a proper Btrieve / PSQL / Actian interface (like ODBC, OLEDB, Managed Provider, even the Btrieve API).
I have a situation where the only way to generate a certain datafile is to print it manually to FILE: under Windows and save it in a file for further processing.
I would really like to have a small stand-alone program which embeds this binary printer driver so I can run it from a batch file and have it generate that binary file for me, as we can then fully automate the "save file in Visio, 'print' it and upload it to the final destination and trigger a remote test".
Is this possible with a suitable Windows SDK? I am a Java programmer, so I do not know Visual Studio and the possibilities with MSDN - yet! - but I'd appreciate pointers.
EDIT: I have the installation files for that printer driver, both 32 and 64 bit. Older versions may include a 16 bit driver.
EDIT: The "print to FILE:" functionality is just what was recommended by the documentation. I have played a little bit with using the LPR-protocol to see what it can do. I'd still prefer the "invoke small binary" approach.
The general problem which you formulate is difficult to solve. Mostly a printer driver consists from some well known components like Print Monitor, Print Processor etc. which are well documented in Windows Driver Kit http://msdn.microsoft.com/en-us/library/ff560885%28v=VS.85%29.aspx. Some years ago I wrote a Print Monitor. It worked many years at a customer. So I know exactly what I writing about. A Print Monitor is nothing more as a DLL with well documented functions. The same is about most other printer components. Those DLLs will be loaded and called from Spooler. If you have a modern printer driver it has no components which run in kernel mode. So one can load most of DLLs from which consist every printer driver and call corresponding function.
You are interesting for using one concert printer driver. So the first what one should do is to examine how this driver is implemented. If you find out which component do the job which you need, you will be probably able to load this DLL in your process and produce output which you need. It is possible that you post an URL where I could download this driver?
UPDATED: I though a little more about your requirements. It seems to me you can goes with the way suggested by developer of the printer driver. If the driver can print to a local port FILE, then it can print in any printer port. So you can give src of a Port Monitor Server driver from C:\WinDDK\7600.16385.1\src\print\monitors\localmon (see also http://msdn.microsoft.com/en-us/library/ff556478%28v=VS.85%29.aspx, http://msdn.microsoft.com/en-us/library/ff549405%28v=VS.85%29.aspx and http://msdn.microsoft.com/en-us/library/ff563806%28v=VS.85%29.aspx). (I is a windows 32/64 DLL, not a real driver) and makes small modification. Instead of saving results to a file you can dispatch the results to your application. It will be work with 100% without any tricks. If you will have some problem to understand localmon I can give you some tips. It is really not complex. The main changes which you have to do is to modify LcmStartDocPort LcmWritePort LcmReadPort LcmEndDocPort functions from localmon.c. Some easy thing which is distinguish Port DLL from a typical DLL, that instead of exporting all DLL's functions it export only one InitializePrintMonitor2 with pointers to all other functions.
UPDATED 2: One more tip for usage of "Local Port" monitor. If goes in printer configuration, then choose "Add Port...", select "Local Port" and click "New Port..." you can type any file name like "C:\temp\my.bin". Then all what you print through a printer will be printed in this file without any user iteration. The name can be any win32 file name (UNC names or Named pipes are also allowed). With this way you can realize some scenarios without any programming with DDK.
UPDATED 3: I looked at the printer driver from different sides and looked one more time in the API in DDK. Now I want recommend you to choose the easiest way, and the way which will be full supported from the driver manufacturer. I suggest following:
You install a printer with the driver which you need and choose as the output port a Local Port with a fixed file name (see Update 2). I named here the destination filename as C:\TEMP\Output.afp. So you receive exactly the same situation like recommend you driver manufacturer. Fixed file name is absolutely the same as FILE: port. So if you print to the printer you receive in Output.afp file in the C:\TEMP directory. To be sure the end of writing you can use ReadDirectoryChangesW or FindNextChangeNotification / FindFirstChangeNotification functions with dwNotifyFilter equal to FILE_NOTIFY_CHANGE_LAST_WRITE. Then you receive notification after last write-time of the file. It means after the end of writing and after FileClose and after the cache is sufficiently flushed. So the file Output.afp is not locked and you can really safe read the results.
For printing of simple documents you can use WritePrinter function (see http://msdn.microsoft.com/en-us/library/dd162959%28VS.85%29.aspx and remark in the documentation http://msdn.microsoft.com/en-us/library/dd145226%28VS.85%29.aspx). Writing of complex files with bitmaps, color and different fonts you have to use typical GDI API like one this in Windows (see http://msdn.microsoft.com/en-us/library/dd162865%28v=VS.85%29.aspx).
This solution looks not very spectacular like writing a printer driver component or a simulation of spooler environment for printer driver, but it will work, will safe work and will be full supported from the driver manufacturer.
(It's been 10 years since I did anything like this, but I don't think the overall concepts have changed all that much:)
What you want to do is implement a custom print processor. A print processor is the piece of code that takes the output that the printer driver generates and transports it to the output device. Print processors are implemented as regular user-mode DLLs. You should be able to find everything you need, including samples, in the Windows DDK.
A while ago we made a commercial application which captured print streams from any windows application and converted the result to XML and tiff images
We did make a prototype with the DDK, but ended up buying a SDK for the print capturing
The SDK was from BlackIce. Although it wasn´t a free SDK, the distribution of the runtimes were royalty free.
Implementation was done with Visual C (unmanaged) and VB6.
The printer driver had to be installed on the server/PC that drove the printing process.
I remember that the tricky part was to control the printer settings in runtime (keep the tiffs compressed, output directory for the files, paper size:A4 or Letter and other settings that were defined in the DEVMODE print control structure).
UPDATE: (Your comment to #Oleg about MO:DCA P triggered my memory. Although it is not about a printer driver...)
For our commercial product, we also had to make a customization to convert MO:DCA (AFP) documents to tiffs and XML.
This SDK had to be able to extract both images and ascii text to enable later conversions
Conversion where then made in batch from AFP documents in one folder to XML and tiffs.
We chose to convert the AFP file after it had been printed (not during print).
The SDK is SnowBound RasterMaster and is available in different flavours (we used the Windows API with ActiveX, and I see now that it is available for Java)
So if your requirement is to convert an AFP document to someting else (extract images and extract ascii text) you could try out the software from SnowBound. Make sure you also get the Optional Feature to be able to extract ASCII text from the MO DCA documents.
This software SDK is more expensive, but it did the job.
They offer a trial version here.
At the moment i have one missing link in your explanation, so let me rephrase what i understood:
You have a special printer driver on your windows system, that is configured to print into a file.
You like to have a simple batch program that can give something to this printer driver to output a binary file.
You have a toolchain where this file can be further processed.
Now my missing part is, what do you want to give to your little batch script, so that it produces your binary file? Do you have a Visio file which should be automatically printed through this driver?
If yes, you should take a look into this little batch script. It is able to take any file with a registered file extension and send it to the default printer with its default settings. By using these settings you are able to change the printer settings within your windows system from a batch file to make your special driver the default one and putting the output into a file.
So if i understood you correctly i didn't had the complete solution but i think a good starting point to accomplish your task.
Update
Ok, after reading your comment, i fully understood what you like to achieve. To get this to work you have to follow Per Larsens advice to write your own driver with the windows ddk (or to be more precise the Windows Driver Kit [WDK]) and encapsulate the already existing driver.
So in short and simple: Your driver signs up as new printer driver. When it is called it gets all the raw bytes from the application. Passes it into the driver that can generate your datafile. Get the output from that driver back and do with it whatever you like.
Some samples to get started can also be found in MSDN as overview or more precisely here.
But just to say it right beforehand: This is not an easy or simple task and the effort is quite high. Maybe trying to manipulate the driver settings of your special driver through the already given batches or a simple application (written with AutoIt) can also solve your problem, by just interacting (automatically) with the settings of the driver.
I can live with "When a user prints any file to this particular Windows printer, then automatically capture the bytes that would have been sent to the printer".
In that case, you want something like RedMon, which redirects the bytes which would have gone to the printer into the input for another program.
Just to reiterate, probably the simplest capture method is using a new Local Port configured as a filename. You can to monitor the output file as previously discussed to catch the output.
Otherwise, you want to write your own port monitor - not a printer driver or a print processor. All a port monitor does is receive the already rendered data from the printer driver, and sends it to the output device. So writing your own port monitor will allow you to go in and change the output port associated with the existing printer driver to be your own output port, and your port monitor can simply write the data to a file, probably one with a unique filename in a dedicated directory.
Printer drivers are far too complicated for what you want to do, and while a print processor could also capture the output data, you'd probably get entangled in some scantily documented system issues you won't want to have to figure out.
The LocalMon sample in the Windows Driver Kit is THE starting point for writing a port monitor. However, it manages all the system local ports and is quite a bit more complex than you need. In fact, much of it is just likely to confuse you. I'd recommend you start with LocalMon, and compare it to the Redmon source, which is much simpler because it manages a dedicated port. Beware that the Redmon source was taken from localmon long ago and appears to have a few bugs, so use Redmon as a reference and pare back the LocalMon code to what's needed to just write the output to a file.
You don't embed drivers in executables- drivers are for the operating system to communicate with the hardware.
You print via the Operating system.
Your 'batch' needs to select the correct printer, and print...
I am developing an application and I would like to be able to search the whole drive for a regular expression. I would prefer to do this in c# but I can call other languages. Is there any easy way to just seek through all the binary data on a drive from begining to end?
Here's an implementation of grep in C#
http://dotnet.jku.at/applications/Grep/Src.aspx
You can modify to follow subdirectories -- it works off of an array of filenames.
AFAIK there is no simple way to do this on raw binary data (You would need direct disk control).
If file-basis is enough enumerating all files, opening them for binary shared reading (catch the exceptions for the ones that are system protected) and then looking for the data should be straightforward. However this will be quite slow as enumerating and opening all files will take some time.
I don't think C# can read all files / data for the drive the OS is on, since the OS locks some files.
You could use the System.IO namespace to enumerate all files, and then scan them individually byte by byte, this obviously would take a long time.
Do you really want to do this ? How are you going to search:
.doc
.xls
.pdf
.html
etc.? Each file type will represent the string you're searching for in different ways.
This article shows how to read data directly from the disk. Everything they do from C++ could be done from C# using PInvoke.
I have a table with a binary column which stores files of a number of different possible filetypes (PDF, BMP, JPEG, WAV, MP3, DOC, MPEG, AVI etc.), but no columns that store either the name or the type of the original file. Is there any easy way for me to process these rows and determine the type of each file stored in the binary column? Preferably it would be a utility that only reads the file headers, so that I don't have to fully extract each file to determine its type.
Clarification: I know that the approach here involves reading just the beginning of each file. I'm looking for a good resource (aka links) that can do this for me without too much fuss. Thanks.
Also, just C#/.NET on Windows, please. I'm not using Linux and can't use Cygwin (doesn't work on Windows CE, among other reasons).
you can use these tools to find the file format.
File Analyser
http://www.softpedia.com/get/Programming/Other-Programming-Files/File-Analyzer.shtml
What Format
http://www.jozy.nl/whatfmt.html
PE file format analyser
http://peid.has.it/
This website may be helpful for you.
http://mark0.net/onlinetrid.aspx
Note:
i have included the download links to make sure that you are getting the right tool name and information.
please verify the source before you download them.
i have used a tool in the past i think it is File Analyser, which will tell you the closest match.
happy tooling.
This is not a complete answer, but a place to start would be a "magic numbers" library. This examines the first few bytes of a file to determine a "magic number", which is compared against a known list of them. This is (at least part) of how the file command on Linux systems works.
Someone else asked a similar question and posted the code used to do exactly this. You should be able to take what is posted here, and slightly modify it so that it pulls from your database.
https://stackoverflow.com/questions/58510
In addition to that, it looks like someone has written a library based off of magic numbers to do this, however, it looks like the site requires registration, and some form of alternate access in order to download this lirbary. The documentation is avaliable for free without registration, that may be helpful.
http://software.topcoder.com/catalog/c_component.jsp?comp=13249160&ver=2
The easiest way I know is to use file command that it is also available in Windows with Cygwin .
A lot of filetypes have well defined headers that begin the file. You could check the first few bytes to check to see how the file begins.
Easiest way to do this would be through access to a *nix (or cygwin) system that has the 'file' command:
$ file visitors.*
visitors.html: HTML document text
visitors.png: PNG image data, 5360 x 2819, 8-bit colormap, non-interlaced
You could write a C# application that piped the first X bytes of each binary column to the file command (using - as the file name)
You need to use some p/invoke interop code to call the SHGetFileInfo method from the Win32 API. This article may also help.