Esempio n. 1
0
        public static void SubtractTotal(string vote_id, string sbjt_mat, DynamicTableEntity e)
        {
            string partition_key = vote_id;
            string row_key       = e.RowKey;

            TallyInfo info = new TallyInfo(e);

            TableResult        result = Warehouse.TotalsTable.Execute(TableOperation.Retrieve(partition_key, row_key));
            DynamicTableEntity entity = (DynamicTableEntity)result.Result;

            if (entity != null)
            {
                //int tpt = (int)e[Consts.TPT_PROP_NAME].Int32Value;
                int tpt = info.tpt;

                entity[Consts.TPT_PROP_NAME].Int32Value -= tpt;
                Warehouse.TotalsTable.Execute(TableOperation.Replace(entity));

                Warehouse.TotalsPartitionPond.AddOrUpdate(partition_key, row_key, entity);
                TotalsDamper.Update(vote_id,
                                    new TallyInfo()
                {
                    sbjt_mat = sbjt_mat,
                    ansr_mat = info.ansr_mat,
                    tpt      = (int)entity[Consts.TPT_PROP_NAME].Int32Value
                });
            }
        }
Esempio n. 2
0
        public static void AddTotal(string vote_id, string sbjt_mat, TallyData tally_data)
        {
            string partition_key = vote_id;
            string row_key       = sbjt_mat + Consts.NAME_CONCAT + tally_data.mat;

            TableResult        result = Warehouse.TotalsTable.Execute(TableOperation.Retrieve(partition_key, row_key));
            DynamicTableEntity entity = (DynamicTableEntity)result.Result;

            if (entity != null)
            {
                entity[Consts.TPT_PROP_NAME].Int32Value += tally_data.tpt;
                Warehouse.TotalsTable.Execute(TableOperation.Replace(entity));
            }
            else
            {
                entity = new DynamicTableEntity(partition_key, row_key);
                entity[Consts.TPT_PROP_NAME] = new EntityProperty(tally_data.tpt);
                Warehouse.TotalsTable.Execute(TableOperation.Insert(entity));
            }
            Warehouse.TotalsPartitionPond.AddOrUpdate(partition_key, row_key, entity);
            TotalsDamper.Update(vote_id,
                                new TallyInfo()
            {
                sbjt_mat = sbjt_mat,
                ansr_mat = tally_data.mat,
                tpt      = (int)entity[Consts.TPT_PROP_NAME].Int32Value
            });
        }