コード例 #1
0
        static void Main(string[] args)
        {
            try
            {
                if (args != null)
                {
                    if (args.Count() > 0)
                    {
                        Ambiente Ambiente = new Ambiente();
                        DispFile DispFile = new DispFile(Ambiente);

                        DispFile.Open(args[0]);
                    }
                }
            }
            catch (Exception ex)
            {
                DateTime agora = DateTime.Now;

                FileStream   fs1    = new FileStream(string.Format(@"{0}\Log\{1}-{2}-{3}-{4}-{5}-{6}.txt", AppDomain.CurrentDomain.BaseDirectory, agora.Year, agora.Month, agora.Day, agora.Hour, agora.Minute, agora.Millisecond), FileMode.OpenOrCreate, FileAccess.Write);
                StreamWriter writer = new StreamWriter(fs1);
                writer.Write(ex.Message);
                writer.Close();
            }
        }
コード例 #2
0
        public String Call(String ClassName, String FunctionName, params String[] Parameters)
        {
            Disp.ParsingModel.DClass    CurrentClass    = null;
            Disp.ParsingModel.DFunction CurrentFunction = null;

            foreach (Disp.ParsingModel.DClass Classe in this.Ambiente.userClasses)
            {
                if (Classe.ClassName.Equals(ClassName))
                {
                    CurrentClass = Classe;
                    break;
                }
            }

            foreach (Disp.ParsingModel.DFunction Function in CurrentClass.Functions)
            {
                if (Function.FunctionName.Equals(FunctionName))
                {
                    CurrentFunction = Function;
                    break;
                }
            }

            DispFile df   = new DispFile(this.Ambiente);
            MetaData meta = new MetaData(df);

            foreach (String Command in CurrentFunction.FunctionLines)
            {
                df.RunLine(Command, meta, 0);
            }
            return(string.Empty);
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: marckdx/disp-script
 static void Main(string[] args)
 {
     if (args.Count() > 0)
     {
         try
         {
             DispFile df = new DispFile(null);
             df.Compile(args[0]);
         }
         catch (Exception ex)
         {
             Console.Write(ex.Message);
         }
     }
 }
コード例 #4
0
        public string Compile(string script)
        {
            DispFile file = new DispFile(this.Ambiente);

            return(file.Compile(string.Format("{0}\\{1}", this.Ambiente.CurrentFolder, script)));
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: marckdx/disp-script
        static void Main()
        {
            TcpListener listener = new TcpListener(80);

            listener.Start();

            while (true)
            {
                Console.WriteLine("Waiting for connection");

                TcpClient    client = listener.AcceptTcpClient();
                StreamReader sr     = new StreamReader(client.GetStream());
                StreamWriter sw     = new StreamWriter(client.GetStream());

                try
                {
                    String request = sr.ReadLine();

                    Console.WriteLine(request);

                    String[] tokens = request.Split(' ');
                    String   page   = tokens[1].Remove(0, 1);

                    if (Directory.Exists(page))
                    {
                        sw.WriteLine("HTTP/1.0 200 OK\n");

                        string[] fileEntries = Directory.GetFiles(page);
                        foreach (string fileName in fileEntries)
                        {
                            sw.WriteLine(String.Format("<br><a href=\"{0}\">{1}</a>", fileName.Replace(page, String.Empty), fileName.Replace(page, String.Empty)));
                        }
                        string[] subdirectoryEntries = Directory.GetDirectories(page);
                        foreach (string subdirectory in subdirectoryEntries)
                        {
                            sw.WriteLine(String.Format("<br><a href=\"{0}\">{1}</a>", subdirectory.Replace(page, String.Empty), subdirectory.Replace(page, String.Empty)));
                        }

                        sw.Flush();
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(page))
                        {
                            page = "index.html";
                        }

                        if (File.Exists(page))
                        {
                            if (page.EndsWith(".ds"))
                            {
                                Ambiente Ambiente = new Ambiente();
                                DispFile DispFile = new DispFile(Ambiente);

                                sw.WriteLine("HTTP/1.0 200 OK\n");
                                String result = DispFile.Open(page);
                                sw.WriteLine(result);
                                sw.Flush();
                            }
                            else
                            {
                                StreamReader file = new StreamReader(page);
                                sw.WriteLine("HTTP/1.0 200 OK\n");

                                sw.WriteLine("<!-- This page was rendered using RhenServer Beta for Disp -->");

                                String data = file.ReadLine();

                                while (data != null)
                                {
                                    sw.WriteLine(data);
                                    sw.Flush();
                                    data = file.ReadLine();
                                }
                            }
                        }
                        else
                        {
                            sw.WriteLine("HTTP/1.0 404 OK\n");
                            sw.WriteLine("<h1>Page not found</h1>");
                            sw.WriteLine("<p>RhenServer Beta</p>");
                            sw.Flush();
                        }
                    }
                }
                catch (Exception ex)
                {
                    sw.WriteLine("HTTP/1.0 404 OK\n");
                    sw.WriteLine(String.Format("<h1>{0}</h1>", ex.StackTrace));
                    sw.Flush();
                }

                client.Close();
            }
        }