Exemplo n.º 1
0
        public static Boolean CompileSource(RemoteSource SourceInfo, string TrueCmd = "")
        {
            if (IBMi.IsConnected())
            {
                List <string> commands = new List <string>();
                string        type, command, filetemp = GetLocalFile("QTEMP", "JOBLOG", "JOBLOG"), name, library = "";

                if (SourceInfo != null)
                {
                    type    = SourceInfo.GetExtension().ToUpper();
                    command = IBMi.CurrentSystem.GetValue("DFT_" + type);
                    if (command.Trim() != "")
                    {
                        if (TrueCmd != "")
                        {
                            command = TrueCmd;
                        }
                        Editor.TheEditor.SetStatus("Compiling " + SourceInfo.GetName() + " with " + command + "...");

                        if (SourceInfo.GetFS() == FileSystem.IFS)
                        {
                            command += "_IFS";
                        }

                        command = IBMi.CurrentSystem.GetValue(command);
                        if (command.Trim() != "")
                        {
                            name = SourceInfo.GetName();
                            if (name.Length > 10)
                            {
                                name.Substring(0, 10);
                            }

                            switch (SourceInfo.GetFS())
                            {
                            case FileSystem.QSYS:
                                command = command.Replace("&OPENLIB", SourceInfo.GetLibrary());
                                command = command.Replace("&OPENSPF", SourceInfo.GetObject());
                                command = command.Replace("&OPENMBR", SourceInfo.GetName());
                                library = SourceInfo.GetLibrary();
                                break;

                            case FileSystem.IFS:
                                command = command.Replace("&FILENAME", name);
                                command = command.Replace("&FILEPATH", SourceInfo.GetRemoteFile());
                                command = command.Replace("&BUILDLIB", IBMi.CurrentSystem.GetValue("buildLib"));

                                library = IBMi.CurrentSystem.GetValue("buildLib");
                                IBMi.SetWorkingDir(IBMi.CurrentSystem.GetValue("homeDir"));
                                break;
                            }

                            if (library != "")
                            {
                                command = command.Replace("&CURLIB", IBMi.CurrentSystem.GetValue("curlib"));
                                IBMi.RemoteCommand($"CHGLIBL LIBL({ IBMi.CurrentSystem.GetValue("datalibl").Replace(',', ' ')}) CURLIB({ IBMi.CurrentSystem.GetValue("curlib") })");

                                if (!IBMi.RemoteCommand(command))
                                {
                                    Editor.TheEditor.SetStatus("Compile finished unsuccessfully.");
                                    if (command.ToUpper().Contains("*EVENTF"))
                                    {
                                        Editor.TheEditor.SetStatus("Fetching errors..");
                                        Editor.TheEditor.Invoke((MethodInvoker) delegate
                                        {
                                            Editor.TheEditor.AddTool(new ErrorListing(library, name), WeifenLuo.WinFormsUI.Docking.DockState.DockLeft, true);
                                        });
                                        Editor.TheEditor.SetStatus("Fetched errors.");
                                    }
                                    if (IBMi.CurrentSystem.GetValue("fetchJobLog") == "true")
                                    {
                                        UsingQTEMPFiles(new[] { "JOBLOG" });
                                        IBMi.RemoteCommand("RUNSQL SQL('CREATE TABLE QTEMP/JOBLOG AS (SELECT char(MESSAGE_TEXT) as a FROM TABLE(QSYS2.JOBLOG_INFO(''*'')) A WHERE MESSAGE_TYPE = ''DIAGNOSTIC'') WITH DATA') COMMIT(*NONE)");
                                        IBMi.DownloadFile(filetemp, "/QSYS.lib/QTEMP.lib/JOBLOG.file/JOBLOG.mbr");
                                    }
                                }
                                else
                                {
                                    Editor.TheEditor.SetStatus("Compile finished successfully.");
                                }
                            }
                            else
                            {
                                Editor.TheEditor.SetStatus("Build library not set. See Connection Settings.");
                            }
                        }
                    }
                }
                else
                {
                    Editor.TheEditor.SetStatus("Only remote members can be compiled.");
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        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());
        }