Exemplo n.º 1
0
        // 更新 UserAccount 資料
        private bool UpdateUserAccount()
        {
            bool ret = false;

            try
            {
                List <UserAccount> accountList = db.GetSql().Queryable <UserAccount>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Update User Account , Total Count: {accountList.Count}");

                for (int idx = 0; idx < accountList.Count; idx++)
                {
                    UserAccount info = accountList[idx];

                    redis.GetRedis((int)Connect.RedisDB.emRedisDB_User).HashSet($"UserAccount_" + info.Email, hashTransfer.TransToHashEntryArray(info));

                    SaveLog($"[Info] Update User Account , User: {info.Email}");
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Update User Account Catch Error, Msg:{ex.Message}");
            }

            return(ret);
        }
Exemplo n.º 2
0
        // 更新 RideData 資料
        private bool UpdateRideData()
        {
            bool ret = false;

            try
            {
                List <RideData> rideList = db.GetSql().Queryable <RideData>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Update Ride Data , Total Count: {rideList.Count}");

                for (int idx = 0; idx < rideList.Count; idx++)
                {
                    RideData info = rideList[idx];

                    redis.GetRedis((int)Connect.RedisDB.emRedisDB_Ride).HashSet($"RideData_" + info.MemberID, hashTransfer.TransToHashEntryArray(info));

                    SaveLog($"[Info] Update Ride Data, User: {info.MemberID}");
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Update Ride Data Catch Error, Msg:{ex.Message}");
            }

            return(ret);
        }
Exemplo n.º 3
0
        // 檢查 TeamBulletin 資料
        private bool CheckTeamBulletin()
        {
            bool ret = false;

            try
            {
                List <TeamBulletin> bulletinList = db.GetSql().Queryable <TeamBulletin>().With(SqlSugar.SqlWith.RowLock).ToList();

                SaveLog($"[Info] Check Team Bulletin , Total Count: {bulletinList.Count}");

                for (int idx = 0; idx < bulletinList.Count; idx++)
                {
                    TeamBulletin info = bulletinList[idx];

                    DateTime createDate = DateTime.Parse(info.CreateDate);
                    DateTime curDate    = DateTime.UtcNow;
                    DateTime limitDate  = createDate.AddDays(info.Day);

                    // 超過時間
                    if (curDate > limitDate)
                    {
                        // 刪除DB的資料
                        if (db.GetSql().Deleteable <TeamBulletin>().With(SqlSugar.SqlWith.TabLockX).Where(it => it.BulletinID == info.BulletinID).ExecuteCommand() > 0)
                        {
                            // 刪除Redis中的資料
                            if (redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).KeyExists($"TeamBulletin_" + info.BulletinID))
                            {
                                redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).KeyDelete($"TeamBulletin_" + info.BulletinID);

                                redis.GetRedis((int)Connect.RedisDB.emRedisDB_Team).HashDelete($"BulletinIdList_" + info.TeamID, info.BulletinID);

                                SaveLog($"[Info] Check Team Bulletin , Delete Bulletin: {info.BulletinID}");
                            }
                            else
                            {
                                SaveLog($"[Error] Check Team Bulletin , Delete Bulletin: {info.BulletinID} Fail, Can Not Find Redis Data");
                            }
                        }
                        else
                        {
                            SaveLog($"[Error] Check Team Bulletin , Delete Bulletin: {info.BulletinID} From DB Fail");
                        }
                    }
                }

                ret = true;
            }
            catch (Exception ex)
            {
                SaveLog($"[Error] Check Team Bulletin Catch Error, Msg:{ex.Message}");
            }


            return(ret);
        }