示例#1
0
         static void Main(string[] args)
         {
             string result = string.Empty;
  
             StringConverter stringConverter = new StringConverterClass();
  
             // Define an AS400 system and connect to it
             AS400System system = new AS400System();
             system.Define("AS400");
             system.UserID = "USERNAME";
             system.Password = "******";
             system.IPAddress = "127.0.0.1";
             system.Connect(cwbcoServiceEnum.cwbcoServiceRemoteCmd);
  
             // Check the connection
             if (system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd) == 1)
             {
                 // Create a program object and link to a system                
                 cwbx.Program program = new cwbx.Program();
                 program.LibraryName = "LIBRARY";
                 program.ProgramName = "RPGPROG";
                 program.system = system;
  
                 // Sample parameter data
                 char chrValue = '1';
 				string strValue1 = "ABC";
 				string strValue2 = "DEF";
 				string outp = "";
  
                 // Create a collection of parameters associated with the program
                 ProgramParameters parameters = new ProgramParameters();
                 
 				parameters.Append("P1", cwbrcParameterTypeEnum.cwbrcInput, 1);
 				parameters["P1"].Value = chrValue;
 				
 				parameters.Append("P2"), cwbrcParameterTypeEnum.cwbrcInput, 3);
 				parameters["P2"].Value = strValue1;
 				
 				parameters.Append("P3"), cwbrcParameterTypeEnum.cwbrcInput, 3);
 				parameters["P3"].Value = strValue1;
 				
                 parameters.Append("P4", cwbrcParameterTypeEnum.cwbrcOutput, 3);
                 
  
                 outp = stringConverter.FromBytes(parameters["P4"].Value);
             }
  
             system.Disconnect(cwbcoServiceEnum.cwbcoServiceAll);
             Console.WriteLine(result);
             Console.ReadKey();
         }
示例#2
0
        public void SwitchUser(string newUser)
        {
            if (system.IsConnected(cwbcoServiceEnum.cwbcoServiceRemoteCmd) == 0)
            {
                Connect();
            }

            StringConverter stringConverter = new StringConverter();
            LongConverter   longConverter   = new LongConverter();

            ProgramParameters parameters = new ProgramParameters();

            parameters = new ProgramParameters();

            parameters.Append("UserID", cwbrcParameterTypeEnum.cwbrcInput, 10);
            stringConverter.Length     = 10;
            parameters["UserID"].Value = stringConverter.ToBytes(newUser.Trim().ToUpper());

            parameters.Append("Password", cwbrcParameterTypeEnum.cwbrcInput, 10);
            stringConverter.Length       = 10;
            parameters["Password"].Value = stringConverter.ToBytes("*NOPWDCHK");

            parameters.Append("Handle", cwbrcParameterTypeEnum.cwbrcOutput, 12);

            //Structure errorStucture = new Structure();
            //errorStucture.Fields.Append("bytesprov", 4);
            //errorStucture.Fields.Append("bytesavail", 4);
            //errorStucture.Fields.Append("messageid", 7);
            //errorStucture.Fields.Append("err", 1);
            //errorStucture.Fields.Append("messagedta", 32750);
            //stringConverter.Length = errorStucture.Length;
            //errorStucture.Bytes = stringConverter.ToBytes(string.Empty);
            //errorStucture.Fields["bytesavail"].Value = longConverter.ToBytes(errorStucture.Length);

            //parameters.Append("ErrorCode", cwbrcParameterTypeEnum.cwbrcInout, errorStucture.Length);
            //parameters["ErrorCode"].Value = errorStucture.Bytes;

            Call("QSYGETPH", "*LIBL", parameters);

            //errorStucture.Bytes = parameters["ErrorCode"].Value;

            //long bytesprov = longConverter.FromBytes(errorStucture.Fields["bytesprov"].Value);

            //long bytesavail = longConverter.FromBytes(errorStucture.Fields["bytesavail"].Value);

            //stringConverter.Length = 7;
            //string messageid = stringConverter.FromBytes(errorStucture.Fields["messageid"].Value).Trim();

            //stringConverter.Length = 1;
            //string err = stringConverter.FromBytes(errorStucture.Fields["err"].Value).Trim();

            //stringConverter.Length = 32750;
            //string messagedta = stringConverter.FromBytes(errorStucture.Fields["messagedta"].Value).Trim();

            byte[] handle = parameters["Handle"].Value;

            parameters = new ProgramParameters();
            parameters.Append("Handle", cwbrcParameterTypeEnum.cwbrcInput, 12);
            parameters["Handle"].Value = handle;

            Call("QWTSETP", "*LIBL", parameters);
        }