Beispiel #1
0
        public void WriteSuccessLog()
        {
            if (_successZoneId == null || _successX == null || _successY == null)
            {
                Logger.Error("invalid success info in " + myTarget + " " + myMissionInProgress);
                return;
            }

            if (myMissionInProgress.isTestMode)
            {
                if (_successTime == null)
                {
                    _successTime = DateTime.Now;
                }

                var si = new SuccessLogInfo()
                {
                    guid            = myMissionInProgress.missionGuid,
                    locationEid     = myMissionInProgress.myLocation.LocationEid,
                    missionCategory = myMissionInProgress.myMission.missionCategory,
                    targetType      = TargetType,
                    x         = (int)_successX,
                    y         = (int)_successY,
                    zoneId    = (int)_successZoneId,
                    eventTime = ((DateTime)_successTime).AddSeconds(myTarget.displayOrder + 5) //fake time
                };


                MissionResolveTester.EnqueSuccesLogInfo(si);
                return;
            }


            WriteSuccessLog((int)_successZoneId, (int)_successX, (int)_successY, myMissionInProgress.missionGuid, TargetType, myMissionInProgress.myLocation.LocationEid, myMissionInProgress.myMission.missionCategory);
        }
Beispiel #2
0
        public void HandleRequest(IRequest request)
        {
            var zoneId = request.Data.GetOrDefault(k.zone, -1);

            if (zoneId == -1)
            {
                Logger.Error("No #zone defined.");
                return;
            }

            var characterId = request.Data.GetOrDefault <int>(k.characterID);

            var testCharacter = characterId == 0 ? null : Character.Get(characterId);

            var missionLevel = request.Data.GetOrDefault(k.level, 4);

            var resolveTest = new MissionResolveTester(_missionProcessor, zoneId);

            var displayOnly = request.Data.GetOrDefault <int>("display") == 1;
            var writeResult = !displayOnly;

            var maxAttempts = request.Data.GetOrDefault("attempts", 100);

            var singleLocation = request.Data.GetOrDefault <int>("single") == 1;

            if (writeResult)
            {
                var deletedMissionResolveRecords =
                    Db.Query().CommandText("DELETE dbo.missiontolocation WHERE locationid IN (SELECT id FROM dbo.missionlocations WHERE zoneid=@zoneId)")
                    .SetParameter("@zoneId", zoneId)
                    .ExecuteNonQuery();

                Logger.Info(deletedMissionResolveRecords + " deleted from missiontolocation.");

                var deletedMissionTargetsLog =
                    Db.Query().CommandText("delete missiontargetslog where zoneid=@zoneId").SetParameter("@zoneId", zoneId).ExecuteNonQuery();

                Logger.Info(deletedMissionTargetsLog + " deleted from missiontargetslog.");
            }

            var mainTask = Task.Run(() => resolveTest.RunTestParallel(testCharacter, missionLevel, maxAttempts, writeResult, singleLocation))
                           .ContinueWith((t) =>
            {
                MissionResolveTester.isTestMode = false;
                Message.Builder.FromRequest(request).WithOk().Send();
            });

            mainTask.Wait();
        }