public static List <ILEObject[]> GetProgramReferences(string Lib, string Obj = "*ALL") { List <ILEObject[]> Items = new List <ILEObject[]>(); string Line, Library, Object, RefObj, RefLib, Type; Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); if (IBMi.IsConnected()) { if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } Editor.TheEditor.SetStatus("Fetching references for " + Lib + "/" + Obj + "..."); UsingQTEMPFiles(new[] { "REFS", "REFSB" }); IBMi.RemoteCommand("DSPPGMREF PGM(" + Lib + "/" + Obj + ") OUTPUT(*OUTFILE) OUTFILE(QTEMP/REFS)"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/REFSB AS (SELECT WHLIB, WHPNAM, WHFNAM, WHLNAM, WHOTYP FROM qtemp/refs) WITH DATA') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", "REFSB", "REFSB"); if (file != "") { foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Line = RealLine.PadRight(52); Library = Line.Substring(0, 10).Trim(); Object = Line.Substring(10, 10).Trim(); RefObj = Line.Substring(20, 11).Trim(); RefLib = Line.Substring(31, 11).Trim(); Type = Line.Substring(42, 10).Trim(); if (Library != "") { Items.Add(new[] { new ILEObject(Library, Object), new ILEObject(RefLib, RefObj, Type) }); } } } } else { return(null); } Editor.TheEditor.SetStatus("Fetched references for " + Lib + " / " + Obj + "."); } else { Editor.TheEditor.SetStatus("Cannot fetch references when offline."); return(null); } return(Items); }
public static Member[] GetMemberList(string Lib, string Obj) { List <Member> Members = new List <Member>(); Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } Editor.TheEditor.SetStatus("Fetching members for " + Lib + "/" + Obj + "..."); IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/MEMBERS) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/" + Obj + ") OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DSPFD FILE(" + Lib + "/" + Obj + ") TYPE(*MBR) OUTPUT(*OUTFILE) OUTFILE(QTEMP/MEMBERS)"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/" + Obj + " AS (SELECT MBFILE, MBNAME, MBMTXT, MBSEU2, char(MBMXRL) as MBMXRL FROM QTEMP/MEMBERS order by MBNAME) WITH DATA') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", Obj, Obj); string Line, Object, Name, Desc, Type, RcdLen; if (file != "") { Member NewMember; foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Line = RealLine.PadRight(90); Object = Line.Substring(0, 10).Trim(); Name = Line.Substring(10, 10).Trim(); Desc = Line.Substring(20, 50).Trim(); Type = Line.Substring(70, 10).Trim(); RcdLen = Line.Substring(80, 7).Trim(); if (Name != "") { NewMember = new Member("", Lib, Object, Name, Type, true, int.Parse(RcdLen) - 12); NewMember._Text = Desc; Members.Add(NewMember); MemberCache.AddMember(Lib + "/" + Object + "." + Name, Type); } } } } else { return(null); } Editor.TheEditor.SetStatus("Fetched members for " + Lib + " / " + Obj + "."); return(Members.ToArray()); }
public static SpoolFile[] GetSpoolListing(string Lib, string Obj) { if (IBMi.IsConnected()) { List <SpoolFile> Listing = new List <SpoolFile>(); List <string> commands = new List <string>(); string file = ""; if (Lib != "" && Obj != "") { Editor.TheEditor.SetStatus("Fetching spool file listing.. (can take a moment)"); UsingQTEMPFiles(new[] { "SPOOL" }); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/SPOOL AS (SELECT Char(SPOOLED_FILE_NAME) as a, Char(COALESCE(USER_DATA, '''')) as b, Char(JOB_NAME) as c, Char(STATUS) as d, Char(FILE_NUMBER) as e FROM TABLE(QSYS2.OUTPUT_QUEUE_ENTRIES(''" + Lib + "'', ''" + Obj + "'', ''*NO'')) A WHERE USER_NAME = ''" + IBMi.CurrentSystem.GetValue("username").ToUpper() + "'' ORDER BY CREATE_TIMESTAMP DESC FETCH FIRST 25 ROWS ONLY) WITH DATA') COMMIT(*NONE)"); file = DownloadMember("QTEMP", "SPOOL", "SPOOL"); Editor.TheEditor.SetStatus("Finished fetching spool file listing."); } if (file != "") { string Line, SpoolName, UserData, Job, Status, Number; foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Line = RealLine.PadRight(75); SpoolName = Line.Substring(0, 10).Trim(); UserData = Line.Substring(10, 10).Trim(); Job = Line.Substring(20, 28).Trim(); Status = Line.Substring(48, 15).Trim(); Number = Line.Substring(63, 11); if (SpoolName != "") { Listing.Add(new SpoolFile(SpoolName, UserData, Job, Status, int.Parse(Number))); } } } return(Listing.Count > 0 ? Listing.ToArray() : null); } else { return(null); } } else { return(null); } }
public static SpoolFile[] GetSpoolListing(string Lib, string Obj) { if (IBMi.IsConnected()) { List <SpoolFile> Listing = new List <SpoolFile>(); List <string> commands = new List <string>(); string file = ""; if (Lib != "" && Obj != "") { UsingQTEMPFiles(new[] { "SPOOL" }); Editor.TheEditor.SetStatus("Fetching spool file listing.. (can take a moment)"); file = DownloadMember("QTEMP", "SPOOL", "SPOOL"); Editor.TheEditor.SetStatus("Finished fetching spool file listing."); } if (file != "") { string Line, SpoolName, UserData, Job, Status, Number; foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Line = RealLine.PadRight(75); SpoolName = Line.Substring(0, 10).Trim(); UserData = Line.Substring(10, 10).Trim(); Job = Line.Substring(20, 28).Trim(); Status = Line.Substring(48, 15).Trim(); Number = Line.Substring(63, 11); if (SpoolName != "") { Listing.Add(new SpoolFile(SpoolName, UserData, Job, Status, int.Parse(Number))); } } } return(Listing.Count > 0 ? Listing.ToArray() : null); } else { return(null); } } else { return(null); } }
public static BindingEntry[] GetBindingDirectory(string Lib, string Obj) { if (IBMi.IsConnected()) { string Line = ""; BindingEntry Entry; List <BindingEntry> Entries = new List <BindingEntry>(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/BNDDIR) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/BNDDATA) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DSPBNDDIR BNDDIR(" + Lib + "/" + Obj + ") OUTPUT(*OUTFILE) OUTFILE(QTEMP/BNDDIR)"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/BNDDATA AS (SELECT BNOBNM, BNOBTP, BNOLNM, BNOACT, BNODAT, BNOTIM FROM qtemp/bnddir) WITH DATA ') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", "BNDDATA", "BNDDATA"); if (file != "") { foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Entry = new BindingEntry(); Line = RealLine.PadRight(50); Entry.BindingLib = Lib; Entry.BindingObj = Obj; Entry.Name = Line.Substring(0, 10).Trim(); Entry.Type = Line.Substring(10, 7).Trim(); Entry.Library = Line.Substring(17, 10).Trim(); Entry.Activation = Line.Substring(27, 10).Trim(); Entry.CreationDate = Line.Substring(37, 6).Trim(); Entry.CreationTime = Line.Substring(43, 6).Trim(); Entries.Add(Entry); } } } else { return(null); } return(Entries.ToArray()); } else { return(null); } }
public static ILEObject[] GetObjectList(string Lib, string Types = "*PGM *SRVPGM *MODULE") { string Line = ""; ILEObject Object; List <ILEObject> Objects = new List <ILEObject>(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/OBJLIST) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/DATA) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DSPOBJD OBJ(" + Lib + "/*ALL) OBJTYPE(" + Types + ") OUTPUT(*OUTFILE) OUTFILE(QTEMP/objlist)"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/DATA AS (SELECT ODOBNM, ODOBTP, ODOBAT, char(ODOBSZ) as ODOBSZ, ODOBTX, ODOBOW, ODSRCF, ODSRCL, ODSRCM FROM qtemp/objlist order by ODOBNM) WITH DATA') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", "DATA", "DATA"); if (file != "") { foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Object = new ILEObject(); Line = RealLine.PadRight(135); Object.Library = Lib; Object.Name = Line.Substring(0, 10).Trim(); Object.Type = Line.Substring(10, 8).Trim(); Object.Extension = Line.Substring(18, 10).Trim(); UInt32.TryParse(Line.Substring(28, 12).Trim(), out Object.SizeKB); Object.Text = Line.Substring(40, 50).Trim(); Object.Owner = Line.Substring(90, 10).Trim(); Object.SrcSpf = Line.Substring(100, 10).Trim(); Object.SrcLib = Line.Substring(110, 10).Trim(); Object.SrcMbr = Line.Substring(120, 10).Trim(); Objects.Add(Object); } } } else { return(null); } return(Objects.ToArray()); }
public static RemoteSource[] GetMemberList(string Lib, string Obj) { string Line, Object, Name, Desc, Type, RcdLen; List <RemoteSource> Members = new List <RemoteSource>(); RemoteSource NewMember; Lib = Lib.ToUpper(); Obj = Obj.ToUpper(); if (IBMi.IsConnected()) { if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } Editor.TheEditor.SetStatus("Fetching members for " + Lib + "/" + Obj + "..."); string TempName = 'M' + Obj; if (TempName.Length > 10) { TempName = TempName.Substring(0, 10); } UsingQTEMPFiles(new[] { TempName, Obj }); IBMi.RemoteCommand("DSPFD FILE(" + Lib + "/" + Obj + ") TYPE(*MBR) OUTPUT(*OUTFILE) OUTFILE(QTEMP/" + TempName + ")"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/" + Obj + " AS (SELECT MBFILE, MBNAME, MBMTXT, MBSEU2, char(MBMXRL) as MBMXRL FROM QTEMP/" + TempName + " order by MBNAME) WITH DATA') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", Obj, Obj); if (file != "") { foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { Line = RealLine.PadRight(90); Object = Line.Substring(0, 10).Trim(); Name = Line.Substring(10, 10).Trim(); Desc = Line.Substring(20, 50).Trim(); Type = Line.Substring(70, 10).Trim(); RcdLen = Line.Substring(80, 7).Trim(); if (Name != "") { NewMember = new RemoteSource("", Lib, Object, Name, Type, true, int.Parse(RcdLen) - 12); NewMember._Text = Desc; Members.Add(NewMember); MemberCache.AddMemberCache(Lib + "/" + Object + "." + Name, Type); } } } } else { return(null); } Editor.TheEditor.SetStatus("Fetched members for " + Lib + " / " + Obj + "."); } else { string DirPath = GetLocalDir(Lib, Obj); if (Directory.Exists(DirPath)) { foreach (string file in Directory.GetFiles(DirPath)) { Type = Path.GetExtension(file).ToUpper(); if (Type.StartsWith(".")) { Type = Type.Substring(1); } NewMember = new RemoteSource(file, Lib, Obj, Path.GetFileNameWithoutExtension(file), Type); NewMember._Text = ""; Members.Add(NewMember); } } else { return(null); } } return(Members.ToArray()); }
public static ILEObject[] GetSPFList(string Lib) { List <ILEObject> SPFList = new List <ILEObject>(); Lib = Lib.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } if (IBMi.IsConnected()) { string FileA = 'S' + Lib, FileB = "D" + Lib; if (FileA.Length > 10) { FileA = FileA.Substring(0, 10); } if (FileB.Length > 10) { FileB = FileB.Substring(0, 10); } UsingQTEMPFiles(new[] { FileA, FileB }); IBMi.RemoteCommand("DSPFD FILE(" + Lib + "/*ALL) TYPE(*ATR) OUTPUT(*OUTFILE) FILEATR(*PF) OUTFILE(QTEMP/" + FileA + ")"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/" + FileB + " AS (SELECT PHFILE, PHLIB FROM QTEMP/" + FileA + " WHERE PHDTAT = ''S'' order by PHFILE) WITH DATA') COMMIT(*NONE)"); Editor.TheEditor.SetStatus("Fetching source-physical files for " + Lib + "..."); string file = DownloadMember("QTEMP", FileB, FileB); if (file != "") { Boolean validName = true; string Line, Library, Object; ILEObject Obj; foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { validName = true; Line = RealLine.PadRight(31); Object = Line.Substring(0, 10).Trim(); Library = Line.Substring(10, 10).Trim(); Obj = new ILEObject(); Obj.Library = Library; Obj.Name = Object; foreach (string Name in IgnorePFs) { if (Obj.Name.StartsWith(Name)) { validName = false; } } if (validName) { SPFList.Add(Obj); } } } } else { return(null); } Editor.TheEditor.SetStatus("Fetched source-physical files for " + Lib + "."); } else { string DirPath = GetLocalDir(Lib); if (Directory.Exists(DirPath)) { foreach (string dir in Directory.GetDirectories(DirPath)) { SPFList.Add(new ILEObject { Library = Lib, Name = Path.GetDirectoryName(dir) }); } } else { return(null); } } return(SPFList.ToArray()); }
public static ILEObject[] GetObjectList(string Lib, string Types = "*PGM *SRVPGM *MODULE") { if (IBMi.IsConnected()) { string Line = ""; ILEObject Object; List <ILEObject> Objects = new List <ILEObject>(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } string FileA = 'O' + Lib, FileB = "T" + Lib; if (FileA.Length > 10) { FileA = FileA.Substring(0, 10); } if (FileB.Length > 10) { FileB = FileB.Substring(0, 10); } UsingQTEMPFiles(new[] { FileA, FileB }); IBMi.RemoteCommand("DSPOBJD OBJ(" + Lib + "/*ALL) OBJTYPE(" + Types + ") OUTPUT(*OUTFILE) OUTFILE(QTEMP/" + FileA + ")"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/" + FileB + " AS (SELECT ODOBNM, ODOBTP, ODOBAT, char(ODOBSZ) as ODOBSZ, ODOBTX, ODOBOW, ODSRCF, ODSRCL, ODSRCM FROM qtemp/" + FileA + " order by ODOBNM) WITH DATA') COMMIT(*NONE)"); string file = DownloadMember("QTEMP", FileB, FileB); if (file != "") { foreach (string RealLine in File.ReadAllLines(file, Program.Encoding)) { if (RealLine.Trim() != "") { Object = new ILEObject(); Line = RealLine.PadRight(135); Object.Library = Lib; Object.Name = Line.Substring(0, 10).Trim(); Object.Type = Line.Substring(10, 8).Trim(); Object.Extension = Line.Substring(18, 10).Trim(); UInt32.TryParse(Line.Substring(28, 12).Trim(), out Object.SizeKB); Object.Text = Line.Substring(40, 50).Trim(); Object.Owner = Line.Substring(90, 10).Trim(); Object.SrcSpf = Line.Substring(100, 10).Trim(); Object.SrcLib = Line.Substring(110, 10).Trim(); Object.SrcMbr = Line.Substring(120, 10).Trim(); Objects.Add(Object); } } } else { return(null); } return(Objects.ToArray()); } else { return(null); } }
public static SpoolFile[] GetSpoolListing(string Lib, string Obj) { if (IBMi.IsConnected()) { List <SpoolFile> Listing = new List <SpoolFile>(); List <string> commands = new List <string>(); string file = ""; if (Lib != "" && Obj != "") { Editor.TheEditor.SetStatus("Fetching spool file listing.. (can take a moment)"); UsingQTEMPFiles(new[] { "SPOOL" }); //IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/SPOOL AS (SELECT Char(SPOOLED_FILE_NAME) as a, Char(COALESCE(USER_DATA, '''')) as b, Char(JOB_NAME) as c, Char(STATUS) as d, Char(FILE_NUMBER) as e FROM TABLE(QSYS2.OUTPUT_QUEUE_ENTRIES(''" + Lib + "'', ''" + Obj + "'', ''*NO'')) A WHERE USER_NAME = ''" + IBMi.CurrentSystem.GetValue("username").ToUpper() + "'' ORDER BY CREATE_TIMESTAMP DESC FETCH FIRST 25 ROWS ONLY) WITH DATA') COMMIT(*NONE)"); IBMi.RemoteCommand("WRKSPLF OUTPUT(*PRINT) SELECT(" + IBMi.CurrentSystem.GetValue("username").ToUpper() + ") "); //IBMi.RemoteCommand("WRKSPLF OUTPUT(*PRINT) SELECT(ROOT) "); IBMi.RemoteCommand("DLTF QTEMP/SPOOL ", false); IBMi.RemoteCommand("CRTPF QTEMP/SPOOL RCDLEN(160)", false); IBMi.RemoteCommand("CPYSPLF FILE(QPRTSPLF) TOFILE(QTEMP/SPOOL) SPLNBR(*LAST) "); file = DownloadMember("QTEMP", "SPOOL", "SPOOL", new IBMDDMi.AllFieldsDDMCallbackAdapter()); Editor.TheEditor.SetStatus("Finished fetching spool file listing."); } if (file != "") { string Line, SpoolName, UserData, Job, Status, Number; bool readytogo = false; foreach (string RealLine in File.ReadAllLines(file, Program.Encoding)) { if (RealLine.Trim() != "") { //Line = RealLine.PadRight(75); //SpoolName = Line.Substring(0, 10).Trim(); //UserData = Line.Substring(10, 10).Trim(); //Job = Line.Substring(20, 28).Trim(); //Status = Line.Substring(48, 15).Trim(); //Number = Line.Substring(63, 11); // Only process AFTER we find 'File' if (RealLine.StartsWith(" File")) { readytogo = true; continue; } if (readytogo) { Line = RealLine.PadRight(125); if (!Line.Contains("E N D O F L I S T I N G") && !Line.Contains("(No spooled output files)")) { SpoolName = Line.Substring(0, 10).Trim(); UserData = Line.Substring(35, 10).Trim(); // Job form 000004/USER/QPADEV0 Job = Line.Substring(116, 6).Trim().PadLeft(6, '0') + "/" + Line.Substring(12, 10).Trim() + "/" + Line.Substring(105, 10).Trim(); Status = Line.Substring(45, 3).Trim(); Number = Line.Substring(101, 4).Trim(); if (SpoolName != "") { Listing.Add(new SpoolFile(SpoolName, UserData, Job, Status, int.Parse(Number))); } } } } } return(Listing.Count > 0 ? Listing.ToArray() : null); } else { return(null); } } else { return(null); } }
public static ILEObject[] GetSPFList(string Lib) { List <ILEObject> SPFList = new List <ILEObject>(); Lib = Lib.ToUpper(); if (Lib == "*CURLIB") { Lib = IBMi.CurrentSystem.GetValue("curlib"); } IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/SPFLIST) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DLTOBJ OBJ(QTEMP/DATA) OBJTYPE(*FILE)", false); IBMi.RemoteCommand("DSPFD FILE(" + Lib + "/*ALL) TYPE(*ATR) OUTPUT(*OUTFILE) FILEATR(*PF) OUTFILE(QTEMP/SPFLIST)"); IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/DATA AS (SELECT PHFILE, PHLIB FROM QTEMP/SPFLIST WHERE PHDTAT = ''S'' order by PHFILE) WITH DATA') COMMIT(*NONE)"); Editor.TheEditor.SetStatus("Fetching source-physical files for " + Lib + "..."); string file = DownloadMember("QTEMP", "DATA", "DATA"); if (file != "") { Boolean validName = true; string Line, Library, Object; ILEObject Obj; foreach (string RealLine in File.ReadAllLines(file)) { if (RealLine.Trim() != "") { validName = true; Line = RealLine.PadRight(31); Object = Line.Substring(0, 10).Trim(); Library = Line.Substring(10, 10).Trim(); Obj = new ILEObject(); Obj.Library = Library; Obj.Name = Object; foreach (string Name in IgnorePFs) { if (Obj.Name.StartsWith(Name)) { validName = false; } } if (validName) { SPFList.Add(Obj); } } } } else { return(null); } Editor.TheEditor.SetStatus("Fetched source-physical files for " + Lib + "."); return(SPFList.ToArray()); }