Example #1
0
        private void callQCmdExec(string command)
        {
            string       programName = "QCmdExc";
            decimal      len         = ( decimal )command.Length;
            ProgParm     Parm1       = new ProgParm(new ProgParmType("Parm1", 0, FieldType.NewChar(( int )len)), DataDirection.InputOutput);
            ProgParm     Parm2       = new ProgParm(new ProgParmType("Parm2", 0, FieldType.NewPacked(15, 5)), DataDirection.InputOutput);
            As400Program execPgm     = new As400Program(myDatabase.Connection, programName);

            execPgm.AppendParm(Parm1);
            execPgm.AppendParm(Parm2);
            execPgm.ObjectToParm(Parm1, command as object);
            execPgm.ObjectToParm(Parm2, len as object);
            try
            {
                execPgm.Execute();
            }
            catch (dgException dgEx)
            {
                if (dgEx.Error != dgErrorNumber.dgEiCONNLOST)
                {
                    throw dgEx;
                }
                try
                {
                    myDatabase.Close();
                }
                catch (dgException)
                {
                }
            }
        }
Example #2
0
        private string setNewPassword(string user, string password, string newPass)
        {
            AdgConnection reseterConnection;

            try
            {
                reseterConnection = new AdgConnection("*PUBLIC/PassReseter");
                reseterConnection.Open();
            }
            catch (Exception e)
            {
                return(e.Message);
            }

            string       result      = string.Empty;
            string       programName = "RESETPW";
            ProgParm     userParm    = new ProgParm(new ProgParmType("UserName", 0, FieldType.NewChar(10)), DataDirection.InputOutput);
            ProgParm     oldPassParm = new ProgParm(new ProgParmType("OldPass", 0, FieldType.NewChar(128)), DataDirection.InputOutput);
            ProgParm     oldLenParm  = new ProgParm(new ProgParmType("OldLen", 0, FieldType.NewInteger(4)), DataDirection.InputOutput);
            ProgParm     newPassParm = new ProgParm(new ProgParmType("NewPass", 0, FieldType.NewChar(128)), DataDirection.InputOutput);
            ProgParm     newLenParm  = new ProgParm(new ProgParmType("NewLen", 0, FieldType.NewInteger(4)), DataDirection.InputOutput);
            ProgParm     resultParm  = new ProgParm(new ProgParmType("Result", 0, FieldType.NewChar(100)), DataDirection.InputOutput);
            As400Program execPgm     = new As400Program(reseterConnection, programName);

            execPgm.AppendParm(userParm);
            execPgm.AppendParm(oldPassParm);
            execPgm.AppendParm(oldLenParm);
            execPgm.AppendParm(newPassParm);
            execPgm.AppendParm(newLenParm);
            execPgm.AppendParm(resultParm);
            execPgm.ObjectToParm(userParm, user as object);
            execPgm.ObjectToParm(oldPassParm, password as object);
            execPgm.ObjectToParm(oldLenParm, password.Length as object);
            execPgm.ObjectToParm(newPassParm, newPass as object);
            execPgm.ObjectToParm(newLenParm, newPass.Length as object);
            execPgm.ObjectToParm(resultParm, result as object);
            try
            {
                execPgm.Execute();
                result = execPgm.ParmToObject(resultParm, typeof(string)) as string;
            }
            catch (dgException dgEx)
            {
                result = dgEx.Message;
            }
            reseterConnection.Close();
            return(result);
        }