Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# AS400 RPG程序不返回任何内容_C#_Ibm Midrange - Fatal编程技术网

C# AS400 RPG程序不返回任何内容

C# AS400 RPG程序不返回任何内容,c#,ibm-midrange,C#,Ibm Midrange,我有以下代码。程序刚刚退出,调用没有返回值。有什么想法吗 AS400System system = new AS400System(); system.Define(ConfigurationManager.AppSettings["AS400Server"]); system.UserID = ConfigurationManager.AppSettings["AS400User"]; system.Password = ConfigurationManager.AppSettings["AS

我有以下代码。程序刚刚退出,调用没有返回值。有什么想法吗

AS400System system = new AS400System();
system.Define(ConfigurationManager.AppSettings["AS400Server"]);
system.UserID = ConfigurationManager.AppSettings["AS400User"];
system.Password = ConfigurationManager.AppSettings["AS400Password"];
system.IPAddress = "10.98.1.21";
system.Connect(cwbcoServiceEnum.cwbcoServiceRemoteCmd);



if(system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd) == 1) {
    Program program = new Program();
    program.LibraryName = "P2PTST";
    program.ProgramName = "AUI0XFR";
    program.system = system;
    program.system.Signon();

    string paramStatus = "A";
    Int64 paramStockItem = Int64.Parse(t.EtagNumber);
    Guid paramGuid = Guid.NewGuid();
    string paramReturn;

    StringConverter stringConverter = new StringConverter();
    ProgramParameters parameters = new ProgramParameters();
    parameters.Append("ApiIGuid", cwbrcParameterTypeEnum.cwbrcInout, 38);
    parameters.Append("StockItemNumber", cwbrcParameterTypeEnum.cwbrcInout, 20);
    parameters.Append("ItemStatus", cwbrcParameterTypeEnum.cwbrcInout, 1);
    parameters.Append("ReturnCode", cwbrcParameterTypeEnum.cwbrcInout, 7);

    parameters["ApiIGuid"].Value = stringConverter.ToBytes(paramGuid.ToString().PadRight(38, ' '));
    parameters["StockItemNumber"].Value = stringConverter.ToBytes(paramStockItem.ToString().PadRight(20, ' '));
    parameters["ItemStatus"].Value = stringConverter.ToBytes(paramStatus.ToString());

    try{
        program.Call(parameters);
        paramReturn = stringConverter.FromBytes(parameters["ReturnCode"].Value);

        system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
    }
    catch (Exception ex)
    {
       Console.WriteLine(ex);
    }
}

我们刚刚讨论了这个问题,也遇到了同样的问题,所以决定创建并使用存储过程在.NET中实现这一点。因为我们关心的是让400端分发代码来创建存储过程,所以在PC端创建过程的速度非常快,然后是我们的远程命令,所以400端不需要额外的更改

我的环境是Win7 x64,运行VS2012 C#、CAX V7.1,并导入IBM.Data.DB2.iSeries和System.Data

我需要参数的系统数据。这对于恢复数据至关重要

我向400发送两个参数,filesetID和一个名称。我得到一个号码和一个uuid。 (但他们都是角色!)

它看起来像这样:

    public void RemoteCmd(ref PicMeta pm)
    {
    iDB2Connection cn;
        try
        {
            using (cn = new iDB2Connection("DataSource=<servername/IP>; UserID="<user>"; Password="<pass>";"))
            {
                cn.Open();
                using (iDB2Command cm = cn.CreateCommand())
                {
                    //Place a try/catch here, so it will create the procedure the first time, or any time it has been removed from the 400.  If already set, it will fail, and you'll go directly to the remote command.  
                    try
                    {
                         //Here we create a procedure and execute or continue.
                         cm.CommandText = "CREATE PROCEDURE LIBRARY.SP_PICGETID(INOUT FSET CHAR (1 ), INOUT UNIT CHAR (6 ), INOUT NEXTID CHAR (3 ), INOUT UUID CHAR (36 ))  LANGUAGE RPGLE NOT DETERMINISTIC NO SQL CALLED ON NULL INPUT EXTERNAL NAME LIBRARY.PICGETID PARAMETER STYLE GENERAL";
                         cm.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        Console.Out.WriteLine(ex.Message);
                    }

                    //Continue - create and call the command     
                    //ParameterDirection needs "using System.Data;"
                    cm.CommandTimeout = 0;
                    cm.CommandType = System.Data.CommandType.StoredProcedure;
                    cm.CommandText = "LIBRARY.SP_PICGETID";

                    iDB2Parameter p = new iDB2Parameter();
                    p.ParameterName = "FSET";
                    p.Direction = ParameterDirection.Input;
                    p.iDB2DbType = iDB2DbType.iDB2Char;
                    p.Size = 1;
                    p.iDB2Value = pm.fileset;
                    cm.Parameters.Add(p);

                    p = new iDB2Parameter();
                    p.ParameterName = "UNIT";
                    p.Direction = ParameterDirection.Input;
                    p.iDB2DbType = iDB2DbType.iDB2Char;
                    p.Size = 6;
                    p.iDB2Value = pm.unit;
                    cm.Parameters.Add(p);

                    p = new iDB2Parameter();
                    p.ParameterName = "NEXTID";
                    p.Direction = ParameterDirection.InputOutput;
                    p.iDB2DbType = iDB2DbType.iDB2Char;
                    p.Size = 3;
                    p.iDB2Value = "";
                    cm.Parameters.Add(p);

                    p = new iDB2Parameter();
                    p.ParameterName = "GUUID";
                    p.Direction = ParameterDirection.InputOutput;
                    p.iDB2DbType = iDB2DbType.iDB2Char;
                    p.Size = 36;
                    p.iDB2Value = "";
                    cm.Parameters.Add(p);

                    cm.ExecuteNonQuery();

                    iDB2ParameterCollection pc = cm.Parameters;

                    //We get our Out parameters here 
                    pm.nextid = pc["NEXTID"].Value.ToString();
                    pm.uuid = pc["GUUID"].Value.ToString();
                }
                cn.Close();
            }
        }
        catch (Exception e)
        {
            Console.Out.WriteLine(e.Message);
        }
        return;
    }
public void RemoteCmd(参考PicMeta-pm)
{
IDB2连接cn;
尝试
{
使用(cn=新IDB2连接(“数据源=;用户ID=”“;密码=”“;”))
{
cn.Open();
使用(iDB2Command cm=cn.CreateCommand())
{
//在此处放置一个try/catch,这样它将在第一次创建过程,或者在任何时候从400中删除该过程。如果已经设置,它将失败,您将直接转到远程命令。
尝试
{
//这里我们创建一个过程并执行或继续。
cm.CommandText=“CREATE PROCEDURE LIBRARY.SP_PICGETID(INOUT-FSET-CHAR(1)、INOUT-UNIT-CHAR(6)、INOUT-NEXTID-CHAR(3)、INOUT-UUID-CHAR(36))语言RPGLE不确定对空输入外部名称库调用SQL。PICGETID参数样式常规”;
cm.ExecuteNonQuery();
}
捕获(例外情况除外)
{
控制台输出写入线(例如消息);
}
//继续-创建并调用命令
//ParameterDirection需要“使用System.Data;”
cm.CommandTimeout=0;
cm.CommandType=System.Data.CommandType.StoredProcess;
cm.CommandText=“LIBRARY.SP_PICGETID”;
IDB2参数p=新的IDB2参数();
p、 ParameterName=“FSET”;
p、 方向=参数方向。输入;
p、 iDB2DbType=iDB2DbType.iDB2Char;
p、 尺寸=1;
p、 IDB2值=pm.fileset;
cm.参数添加(p);
p=新的IDB2参数();
p、 ParameterName=“单位”;
p、 方向=参数方向。输入;
p、 iDB2DbType=iDB2DbType.iDB2Char;
p、 尺寸=6;
p、 IDB2值=pm.单位;
cm.参数添加(p);
p=新的IDB2参数();
p、 ParameterName=“NEXTID”;
p、 方向=参数Direction.InputOutput;
p、 iDB2DbType=iDB2DbType.iDB2Char;
p、 尺寸=3;
p、 IDB2值=”;
cm.参数添加(p);
p=新的IDB2参数();
p、 ParameterName=“GUUID”;
p、 方向=参数Direction.InputOutput;
p、 iDB2DbType=iDB2DbType.iDB2Char;
p、 尺寸=36;
p、 IDB2值=”;
cm.参数添加(p);
cm.ExecuteNonQuery();
IDB2参数集合pc=cm.参数;
//我们在这里得到我们的参数
pm.nextid=pc[“nextid”].Value.ToString();
pm.uuid=pc[“GUUID”].Value.ToString();
}
cn.Close();
}
}
捕获(例外e)
{
控制台输出写入线(e.Message);
}
返回;
}

希望这有帮助

您是否查看了IBM i端以了解那里发生了什么?system.isConnected没有其他功能。你确定你已经接通了吗?