Ejemplo n.º 1
0
        public override void ExecuteResult(ControllerContext context)
        {
            TextWriter writer = context.HttpContext.Response.Output;

            PaperRoll roll = PaperPond.Get(this.voteId);

            roll.Write(writer);
        }
Ejemplo n.º 2
0
 private static void removedCallback(string key, Object value, CacheItemRemovedReason reason)
 {
     if (reason == CacheItemRemovedReason.Expired)
     {
         PaperRoll obj = (PaperRoll)value;
         //insertNew(key, obj.VoteId);
     }
 }
Ejemplo n.º 3
0
        private static PaperRoll insertNew(string key, string vote_id)
        {
            PaperRoll obj = new PaperRoll(vote_id);                     // if concurrency happens, this will be done more than once.

            HttpRuntime.Cache.Insert(key, obj, null, DateTime.Now.AddSeconds(Consts.DEFAULT_CACHE_SECONDS),
                                     Cache.NoSlidingExpiration, CacheItemPriority.Default, removedCallback);

            // expires after some time for multi-node synchronization (unreliable).
            return(obj);
        }
Ejemplo n.º 4
0
        public static PaperRoll Get(string vote_id)
        {
            string key = "PaperPond." + vote_id;

            PaperRoll obj = (PaperRoll)HttpRuntime.Cache.Get(key);

            if (obj == null)
            {
                obj = insertNew(key, vote_id);
            }

            return(obj);
        }
Ejemplo n.º 5
0
        public ActionResult VotePage(string vote_id)
        {
            // Todo: non-existent vote.
            PaperRoll roll = PaperPond.Get(vote_id);

            string title = roll.GetSetting("headings-title");

            if (title == null)
            {
                title = "新投票";
            }

            ViewBag.Title = title /* + " | www.fotous.net"*/;
            // Razor will do html encode to prevent xss attack.

            return(View("VotePage"));
            //return File("/Views/vote.html", "text/html");
        }