コード例 #1
0
        private void DoHelper(HttpContext context)
        {
            context.Response.Cache.VaryByParams["ts"] = true;

            DoCacheMagic(context, 10);

            string   sBody  = WebControlHelper.GetManifestResourceStream("Carrotware.Web.UI.Controls.carrotHelp.js");
            DateTime timeAM = DateTime.Now.Date.AddHours(6);              // 6AM
            DateTime timePM = DateTime.Now.Date.AddHours(12);             // 6PM

            sBody = sBody.Replace("[[TIMESTAMP]]", DateTime.UtcNow.ToString("u"));

            sBody = sBody.Replace("[[SHORTDATEPATTERN]]", WebControlHelper.ShortDatePattern);
            sBody = sBody.Replace("[[SHORTTIMEPATTERN]]", WebControlHelper.ShortTimePattern);
            sBody = sBody.Replace("[[SHORTDATEFORMATPATTERN]]", WebControlHelper.ShortDateFormatPattern);
            sBody = sBody.Replace("[[SHORTDATETIMEFORMATPATTERN]]", WebControlHelper.ShortDateTimeFormatPattern);

            sBody = sBody.Replace("[[AM_TIMEPATTERN]]", timeAM.ToString("tt"));
            sBody = sBody.Replace("[[PM_TIMEPATTERN]]", timePM.ToString("tt"));

            context.Response.ContentType = "text/javascript";

            var byteArray = Encoding.UTF8.GetBytes(sBody);

            using (MemoryStream memStream = new MemoryStream(byteArray)) {
                memStream.WriteTo(context.Response.OutputStream);
            }

            context.ApplicationInstance.CompleteRequest();
            context.Response.End();
        }
コード例 #2
0
 public string GetManifestResourceStream(string resource)
 {
     return(WebControlHelper.GetManifestResourceStream(resource));
 }