Esempio n. 1
0
        private static string createAction(string vote_id, string user_name, ActionData mat_data)
        {
            int    next_id = NextIdStore.Next(Warehouse.PapersTable, vote_id);
            string row_key = Consts.ACTION_ID_CHAR + next_id.ToString("D" + Consts.ACTION_ID_DIGITS);

            DynamicTableEntity entity = new DynamicTableEntity(vote_id, row_key);

            entity[Consts.MAT_PROP_NAME]  = new EntityProperty(mat_data.mat);
            entity[Consts.WHO_PROP_NAME]  = new EntityProperty(user_name);
            entity[Consts.TIME_PROP_NAME] = new EntityProperty(DateTimeOffset.UtcNow);

            if (mat_data.value != null)
            {
                entity[Consts.VALUE_PROP_NAME] = new EntityProperty(mat_data.value);
            }
            if (mat_data.type != null)
            {
                entity[Consts.TYPE_PROP_NAME] = new EntityProperty(mat_data.type);
            }
            if (mat_data.pare != null)
            {
                entity[Consts.PARE_PROP_NAME] = new EntityProperty(mat_data.pare);
            }

            string hp = PaperPond.Get(vote_id).AddMat(entity);                          // If put this line after inserting into db, when cache miss and the roll is initialized from db, the mat will be added twice.

            Warehouse.PapersTable.Execute(TableOperation.Insert(entity));

            return(hp);
        }
Esempio n. 2
0
        public override void ExecuteResult(ControllerContext context)
        {
            TextWriter writer = context.HttpContext.Response.Output;

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

            roll.Write(writer);
        }
Esempio n. 3
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");
        }