예제 #1
0
        private void CallNewProcessor(HttpListenerContext ctx)
        {
            HttpCall call = new HttpCall(ctx);

            try
            {
                prc(this, call);
            }
            catch (Exception e)
            {
                call.Response.StatusCode = 500;
                call.Write(e.GetType().Name + ": " + e.Message);
            }
            finally
            {
                call.Close();
            }
        }
예제 #2
0
        public static void WriteResource(string path, HttpCall call)
        {
#if DEBUG
            if (EXTERNAL_RESOURCES)
            {
                call.Write(File.ReadAllBytes(Path.Combine(sfpath, path)));
                return;
            }
#endif
            byte[] data;
            if (Res.TryGetValue(path, out data))
            {
                call.Write(data, 0, data.Length);
            }
            else
            {
                throw new Exception("Resource not found");
            }
        }
예제 #3
0
        public static void WriteTemplate(string template, HttpCall call, params object[] para)
        {
#if DEBUG
            if (EXTERNAL_RESOURCES)
            {
                InitResources();
            }
#endif
            Templater t;
            if (Templs.TryGetValue(template, out t))
            {
                call.Write(t.Process(para));
            }
#if DEBUG
            else
            {
                throw new Exception("No template found for: " + template);
            }
#endif
        }
예제 #4
0
 public ZipDownload(HttpCall call)
 {
     this.call = call;
     temp      = new FileStream(temppath = Path.GetTempPath() + Guid.NewGuid().ToString() + ".zip", FileMode.Create, FileAccess.ReadWrite);
     z         = new ZipArchive(temp, ZipArchiveMode.Create, true, Encoding.UTF8);
 }