简体   繁体   English

c#无法在Unisys Mainframe Windows Share上创建EBCDIC文件

[英]c# Cannot create EBCDIC file on Unisys Mainframe Windows Share

I am attempting to upload data generated by users on asp.net site to a Unisys mainframe. 我试图将用户在asp.net站点上生成的数据上传到Unisys大型机。 My client decided that they want me to load the data directly onto a Unisys Mainframe windows share instead of using FTP to upload the file. 我的客户决定他们要我将数据直接加载到Unisys Mainframe窗口共享上,而不是使用FTP上传文件。 FTP typically does the conversion between ASCII and EBCDIC. FTP通常在ASCII和EBCDIC之间进行转换。

The problem is that the mainframe sees the file as ASCII regardless of whether I've encoded the file contents as EBCDIC. 问题在于,无论我是否已将文件内容编码为EBCDIC,大型机都将文件视为ASCII。

The test code is here: 测试代码在这里:

        string dataToWrite = "ACHR0000000000575TEST EBCDICPAYEE             8899007500038159 0000001000160330 ".ToUpper();
        Encoding ebcdic = Encoding.GetEncoding("IBM037");

        List<byte> bytes = new List<byte>();
        bytes.AddRange(Encoding.Convert(Encoding.ASCII, ebcdic, Encoding.ASCII.GetBytes(dataToWrite)));


        using (var unc = new UNCAccessWithCredentials())
        {
            // get access to the reconciliation file share using credentials in the config
            string path = @"\\xxx\RECONDEV";
            unc.NetUseWithCredentials(path, "XXX","", "XXX");
            string fileName = Path.Combine(path, "ACH");
            using (var binWriter = new BinaryWriter(File.OpenWrite(fileName)))
            {
                binWriter.Write(bytes.ToArray());
                binWriter.Flush();
                binWriter.Close();
            }
        }

Questions 问题
1) Should I create the file as ASCII and then have the mainframe job call a utility to convert the file EBCDIC? 1)我是否应该将文件创建为ASCII,然后让大型机作业调用实用程序来转换文件EBCDIC? If so, what is the name of the utility? 如果是这样,该实用程序的名称是什么? The mainframe ops don't know of one. 大型机操作系统并不知道。

2) Is there some way to actually create an EBCDIC file within .net? 2)有没有办法在.net中实际创建EBCDIC文件? The EBCDIC encoding is working but I believe the file types are different and I have not been able to find out anything. EBCDIC编码正常工作,但是我认为文件类型不同,而且我无法找到任何内容。

I literally haven't done anything with a mainframe in 2 decades so I am out of my depth. 实际上,在过去的20年中,我没有对大型机做任何事情,所以我的想法太深了。

Thanks in advance. 提前致谢。 Chris 克里斯

Just FYI, a consultant suggested we use a utility called MCPCopy to copy and convert the files from an ASCII stream to EBCDIC as we copied the file to the mainframe share. 仅供参考,一位顾问建议我们使用名为MCPCopy的实用程序将文件从ASCII流复制并转换为EBCDIC,因为我们将文件复制到大型机共享。 The utility can be installed as part of the NXExtend. 该实用程序可以作为NXExtend的一部分安装。 The command line used by the ASP.Net site is: ASP.Net站点使用的命令行为:

c:\\Windows\\MCPCopy.exe {SourceFile} {DestinationFile} /Y /Z:SR /D:80 c:\\ Windows \\ MCPCopy.exe {SourceFile} {DestinationFile} / Y / Z:SR / D:80

Hope this helps 希望这可以帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM