예제 #1
0
        private async Task ExcuteLoginTask()
        {
            if (DateTime.Now.Day == task.last_update_time.Day)
            {
                Log(task.id, GameAction.START_TASK, "检查到登录计划已经成功执行,将在24小时后执行");
                using (var db = new Db())
                    db.Database.ExecuteSqlCommand(
                        "update user_task set state=0,start_time=@p0 where id=@p1",
                        task.last_update_time.AddDays(1),
                        task.id);
                return;
            }
            var loginTask = new LoginTask()
            {
                id         = task.id,
                roleData   = roleData,
                device     = device,
                role       = role,
                task_data  = taskDatas,
                action     = (GameAction)task.current_action,
                excuteType = excuteType
            };

            if (await Context.ActorOf <LoginTaskActor>().Ask <bool>(loginTask))
            {
                Log(task.id, GameAction.START_TASK, "登录计划已经成功执行,将在24小时后执行");
                using (var db = new Db())
                    db.Database.ExecuteSqlCommand(
                        "update user_task set state=0,start_time=@p0 where id=@p1",
                        DateTime.Now.AddDays(1), task.id);
            }
        }
예제 #2
0
 protected async Task SaveActionData(LoginTask task, GameAction action, role_data data, DateTime?expireTime = null, Dictionary <string, string> taskData = null)
 {
     var saveActionDataTask = new SaveActionDataTask()
     {
         taskId      = task.id,
         action      = action,
         expiresTime = expireTime,
         roleData    = data ?? GetRoleData(task.serverApi, task.role.id, task.role.user_id),
         taskData    = taskData == null ? task.task_data : taskData,
     };
     await saveDataActor.Ask(saveActionDataTask);
 }
예제 #3
0
        public static ServerApi InitServerApi(LoginTask task)
        {
            var device = task.device;
            var data   = task.roleData;
            var role   = task.role;

            var serverApi = new ServerApi(device.platform_type == 1);

            serverApi.PlatfromInfos["version"]       = AppInfo.version;
            serverApi.PlatfromInfos["dataVer"]       = AppInfo.dataVer;
            serverApi.PlatfromInfos["dateVer"]       = AppInfo.dateVer;
            serverApi.PlatfromInfos["appVer"]        = AppInfo.appVer;
            serverApi.PlatfromInfos["ver"]           = AppInfo.appVer;
            serverApi.PlatfromInfos["deviceid"]      = device.deviceid;
            serverApi.PlatfromInfos["dp"]            = device.dp;
            serverApi.PlatfromInfos["idfa"]          = device.idfa;
            serverApi.PlatfromInfos["model"]         = device.model;
            serverApi.PlatfromInfos["os"]            = device.os;
            serverApi.PlatfromInfos["pf_ver"]        = device.pf_ver;
            serverApi.PlatfromInfos["platform_type"] = device.platform_type.ToString();
            serverApi.PlatfromInfos["ptype"]         = device.ptype;
            serverApi.PlatfromInfos["udid"]          = device.udid;
            if (data != null)
            {
                serverApi.PlatfromInfos["cookie"] = data.cookie;
                if (!string.IsNullOrEmpty(data.access_token))
                {
                    serverApi.PlatfromInfos["access_token"] = data.access_token;
                    serverApi.PlatfromInfos["access_key"]   = data.access_token;
                    serverApi.PlatfromInfos["expires"]      = data.access_token_expires.ToString();
                }
                if (!string.IsNullOrEmpty(data.usk))
                {
                    serverApi.PlatfromInfos["usk"]   = data.usk;
                    serverApi.PlatfromInfos["rgusk"] = data.usk;
                }
                if (!string.IsNullOrEmpty(data.rguid))
                {
                    serverApi.PlatfromInfos["rguid"] = data.rguid;
                }
                if (!string.IsNullOrEmpty(data.game_user_id))
                {
                    serverApi.PlatfromInfos["rguid"]   = data.rguid;
                    serverApi.PlatfromInfos["_userId"] = data.game_user_id;
                    serverApi.PlatfromInfos["userId"]  = data.game_user_id;
                    serverApi.PlatfromInfos["role_id"] = data.game_user_id;
                }
                if (!string.IsNullOrEmpty(data.nickname))
                {
                    serverApi.PlatfromInfos["nickname"] = data.nickname;
                    serverApi.PlatfromInfos["uname"]    = data.nickname;
                }
                if (!string.IsNullOrEmpty(data.bilibili_id))
                {
                    serverApi.PlatfromInfos["uid"] = data.bilibili_id;
                }

                if (data.quest_info != null)
                {
                    serverApi.userQuest = JsonConvert.DeserializeObject <List <HomeUserquest> >(data.quest_info);
                }

                if (data.svt_info != null)
                {
                    serverApi.userSvt = JsonConvert.DeserializeObject <List <ToploginUsersvt> >(data.svt_info);
                }

                if (data.deck_info != null)
                {
                    serverApi.userDeck = JsonConvert.DeserializeObject <List <ToploginUserdeck> >(data.deck_info);
                }

                if (data.user_game != null)
                {
                    serverApi.userGame = JsonConvert.DeserializeObject <HomeUsergame>(data.user_game);
                }
            }
            return(serverApi);
        }