Beispiel #1
0
        public static bool Connect(bool OfflineMode = false)
        {
            bool result = false;

            try
            {
                FTPFile = IBMiUtils.GetLocalFile("QTEMP", "FTPLOG", DateTime.Now.ToString("MMddTHHmm"), "txt");
                FtpTrace.AddListener(new TextWriterTraceListener(FTPFile));
                FtpTrace.LogUserName = false;   // hide FTP user names
                FtpTrace.LogPassword = false;   // hide FTP passwords
                FtpTrace.LogIP       = false;   // hide FTP server IP addresses

                string password = Password.Decode(CurrentSystem.GetValue("password"));
                Client = new FtpClient(CurrentSystem.GetValue("system"), CurrentSystem.GetValue("username"), password);

                if (OfflineMode == false)
                {
                    Client.UploadDataType   = FtpDataType.ASCII;
                    Client.DownloadDataType = FtpDataType.ASCII;

                    //FTPES is configurable
                    if (IBMi.CurrentSystem.GetValue("useFTPES") == "true")
                    {
                        Client.EncryptionMode = FtpEncryptionMode.Explicit;
                    }

                    //Client.DataConnectionType = FtpDataConnectionType.AutoPassive; //THIS IS THE DEFAULT VALUE
                    Client.DataConnectionType = GetFtpDataConnectionType(CurrentSystem.GetValue("transferMode"));
                    Client.SocketKeepAlive    = true;

                    Client.ConnectTimeout = 5000;
                    Client.Connect();

                    //Change the user library list on connection
                    RemoteCommand($"CHGLIBL LIBL({ CurrentSystem.GetValue("datalibl").Replace(',', ' ')}) CURLIB({ CurrentSystem.GetValue("curlib") })");

                    System.Timers.Timer timer = new System.Timers.Timer();
                    timer.Interval = 60000;
                    timer.Elapsed += new ElapsedEventHandler(KeepAliveFunc);
                    timer.Start();
                }

                result = true;
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to connect to " + CurrentSystem.GetValue("system") + " - " + e.Message, "Cannot Connect", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(result);
        }
Beispiel #2
0
        public static void getErrors(string lib, string obj)
        {
            lib = lib.Trim().ToUpper();
            obj = obj.Trim().ToUpper();

            _Success = false;
            string filetemp = IBMiUtils.DownloadMember(lib, "EVFEVENT", obj);

            if (filetemp != "")
            {
                ErrorHandle.doName(lib.ToUpper() + '/' + obj.ToUpper());
                ErrorHandle.setLines(File.ReadAllLines(filetemp));
                _Success = true;
            }
        }
Beispiel #3
0
        public static void getErrors(string lib, string obj)
        {
            lib = lib.Trim().ToUpper();
            obj = obj.Trim().ToUpper();

            _Success = false;
            //string filetemp = IBMiUtils.DownloadMember(lib, "EVFEVENT", obj);
            string filetemp = IBMiUtils.DownloadMember(lib, "QBIFERR", obj,
                                                       new IBMDDMi.AllFieldsDDMCallbackAdapter());

            if (filetemp != "")
            {
                ErrorHandle.doName(lib.ToUpper() + '/' + obj.ToUpper());
                ErrorHandle.setLines(File.ReadAllLines(filetemp, Program.Encoding));

                _Success = true;
            }
        }
Beispiel #4
0
        public static void wrkErrors()
        {
            _FileIDs    = new Dictionary <int, string>();
            _Errors     = new Dictionary <int, List <LineError> >();
            _Expansions = new Dictionary <int, List <expRange> >();

            string err;
            int    sev;
            int    linenum, column, sqldiff;

            string[] pieces;
            string   curtype;

            foreach (string line in _Lines)
            {
                if (line == null)
                {
                    continue;
                }
                err     = line.PadRight(150);
                pieces  = err.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                curtype = err.Substring(0, 10).TrimEnd();
                _FileID = int.Parse(line.Substring(13, 3));
                switch (curtype)
                {
                case "FILEID":
                    if (_FileIDs.ContainsKey(_FileID))
                    {
                        //_FileIDs[_FileID] = pieces[5];
                    }
                    else
                    {
                        _FileIDs.Add(_FileID, pieces[5]);
                        _Errors.Add(_FileID, new List <LineError>());
                        _Expansions.Add(_FileID, new List <expRange>());
                    }
                    break;

                case "EXPANSION":
                    _Expansions[_FileID].Add(new expRange(int.Parse(pieces[6]), int.Parse(pieces[7])));
                    break;

                case "ERROR":
                    sev     = int.Parse(err.Substring(58, 2));
                    linenum = int.Parse(err.Substring(37, 6));
                    column  = int.Parse(err.Substring(33, 3));
                    sqldiff = 0;

                    if (sev >= 20)
                    {
                        foreach (expRange range in _Expansions[_FileID])
                        {
                            if (range.inRange(linenum))
                            {
                                sqldiff += range.getVal();
                            }
                        }
                    }

                    if (sqldiff > 0)
                    {
                        linenum -= sqldiff;
                    }

                    _Errors[_FileID].Add(new LineError(sev, linenum, column, err.Substring(65), err.Substring(48, 7)));
                    break;
                }
            }

            if (IBMi.CurrentSystem.GetValue("fetchJobLog") == "true")
            {
                string JobLog = IBMiUtils.GetLocalFile("QTEMP", "JOBLOG", "JOBLOG");
                _FileID = -1;
                _FileIDs.Add(_FileID, "Job Log");
                _Errors.Add(_FileID, new List <LineError>());
                foreach (string Line in File.ReadAllLines(JobLog))
                {
                    _Errors[_FileID].Add(new LineError(50, 0, 0, Line, ""));
                }
            }
        }
Beispiel #5
0
 public string Download()
 {
     return(IBMiUtils.DownloadSpoolFile(this.SPOOLED_FILE_NAME, this.FILE_NUMBER, this.JOB_NAME));
 }