Exemplo n.º 1
0
        /// <summary>
        /// CDKeyCache
        /// </summary>
        public static void DoCDKeyCache()
        {
            var cdkSet = new ShareCacheStruct <CDKeyCache>();

            TraceLog.WriteInfo("Do CDKeyCache table start...");
            int count = 0;

            try
            {
                var    dbProvider = DbConnectionProvider.CreateDbProvider(DbConfig.MERGE);
                string sql        = "SELECT CDKey,UsedTime FROM CDKeyCache";
                using (IDataReader reader = dbProvider.ExecuteReader(CommandType.Text, sql))
                {
                    while (reader.Read())
                    {
                        CDKeyCache cdk = new CDKeyCache();
                        cdk.CDKey    = reader["CDKey"].ToString();
                        cdk.UsedTime = reader["UsedTime"].ToDateTime();
                        if (cdkSet.FindKey(cdk.CDKey) == null)
                        {
                            //cdkSet.Add(cdk);
                            count++;
                        }
                    }
                    //cdkSet.Update();
                }
            }
            catch (Exception ex)
            {
                TraceLog.WriteError("Do CDKeyCache table error Exception: {0} .", ex);
                return;
            }


            TraceLog.WriteInfo("Do CDKeyCache table successful : {0} .", count);
        }
Exemplo n.º 2
0
        public override bool TakeAction()
        {
            receipt = ReceiveCdKeyResult.OK;

            //if (GetEventAward.IsReceivedCDK)
            //{
            //    receipt = ReceiveCdKeyResult.Had;
            //    return true;
            //}
            var acc = new ShareCacheStruct <Config_CdKey>().Find(t => t.Key == _CDKey);

            if (acc == null)
            {
                receipt = ReceiveCdKeyResult.Invalid;
                return(true);
            }
            var cdkscache = new ShareCacheStruct <CDKeyCache>();

            if (cdkscache.FindKey(_CDKey) != null)
            {
                receipt = ReceiveCdKeyResult.Received;
                return(true);
            }
            if (GetEventAward.ReceivedCDKTypeList.Find(t => t == acc.Type) != 0)
            {
                receipt = ReceiveCdKeyResult.Had;
                return(true);
            }

            CDKeyCache cdk = new CDKeyCache()
            {
                CDKey    = _CDKey,
                UsedTime = DateTime.Now
            };

            GetEventAward.IsReceivedCDK = true;
            GetEventAward.ReceivedCDKTypeList.Add(acc.Type);

            cdkscache.Add(cdk);
            cdkscache.Update();

            List <ItemData> itemlist = new List <ItemData>();

            itemlist.Add(new ItemData()
            {
                ID = acc.AAwardID, Num = acc.AAwardN
            });
            itemlist.Add(new ItemData()
            {
                ID = acc.BAwardID, Num = acc.BAwardN
            });
            itemlist.Add(new ItemData()
            {
                ID = acc.CAwardID, Num = acc.CAwardN
            });
            itemlist.Add(new ItemData()
            {
                ID = acc.DAwardID, Num = acc.DAwardN
            });

            UserHelper.RewardsItems(Current.UserId, itemlist);

            return(true);
        }