示例#1
0
        public bool Run()
        {
            string code = editor.Document.TextContent;
            // check if we already have compiled this code before
            int hashCode = code.GetHashCode();

            if (database != null && this.hashCode == hashCode)
            {
                return(false);
            }
            this.hashCode = hashCode;
            java.io.StringReader reader = new java.io.StringReader(code);
            try
            {
                java.io.StringWriter writer = new java.io.StringWriter();
                try
                {
                    java.io.PrintWriter log = new java.io.PrintWriter(writer);
                    try
                    {
                        Database db;
                        db = JPortal.run(name, reader, log);
                        if (db != null)
                        {
                            database = db;
                        }
                    }
                    finally
                    {
                        log.flush();
                        log.close();
                    }
                    string   result = writer.ToString();
                    char[]   sep    = { '\n' };
                    string[] lines  = result.Split(sep);
                    for (int i = 0; i < lines.Length; i++)
                    {
                        string line = lines[i].Trim();
                        if (line.Length == 0)
                        {
                            continue;
                        }
                        form.LogInfo = line;
                    }
                }
                finally
                {
                    writer.close();
                }
            }
            finally
            {
                reader.close();
            }
            return(database != null);
        }
示例#2
0
 private void RunCompile(Source source)
 {
     source.Clear();
     java.io.StringWriter writer = new java.io.StringWriter();
     try
     {
         java.io.PrintWriter log = new java.io.PrintWriter(writer);
         try
         {
             string currDir = Directory.GetCurrentDirectory();
             try
             {
                 FileInfo info = new FileInfo(source.FileName);
                 LogVerbose = "Changing to " + info.DirectoryName;
                 Directory.SetCurrentDirectory(info.DirectoryName);
                 LogVerbose = "Compiling " + info.Name;
                 bbd.jportal.Database database = JPortal.run(info.FullName, log);
                 RunGenerators(database, log);
             }
             finally
             {
                 Directory.SetCurrentDirectory(currDir);
             }
         }
         finally
         {
             log.flush();
             log.close();
         }
         string   result = writer.ToString();
         char[]   sep    = { '\n' };
         string[] lines  = result.Split(sep);
         for (int i = 0; i < lines.Length; i++)
         {
             string line = lines[i].Trim();
             if (line.Length == 0)
             {
                 continue;
             }
             if (line.IndexOf("Code: ") == 0)
             {
                 source.Add(line.Substring(6).Trim());
             }
             else if (line.IndexOf("DDL: ") == 0)
             {
                 source.Add(line.Substring(5).Trim());
             }
             LogInfo = line;
         }
     }
     finally
     {
         writer.close();
     }
 }