private void UnstuckIfNeeded(WowPoint playerLoc, DoActionType currentAction) { if (currentAction == DoActionType.Move) { unstuckDictionary.Add(DateTime.UtcNow, playerLoc); if (unstuckDictionary.Count >= 2) { if (unstuckDictionary.Count > 100) // sufficiently big value (until this method is called once per second) { unstuckDictionary.Remove(unstuckDictionary.Keys.First()); } KeyValuePair <DateTime, WowPoint> last = unstuckDictionary.Last(); KeyValuePair <DateTime, WowPoint> first = unstuckDictionary.LastOrDefault(l => (last.Key - l.Key).TotalSeconds >= 5); if (!first.Equals(default(KeyValuePair <DateTime, WowPoint>))) { if (last.Value.Distance(first.Value) < 1f) { this.LogPrint($"We are stuck at {playerLoc}. Trying to unstuck..."); game.Jump(); } } } } else { unstuckDictionary.Clear(); } }
/// <summary> /// 检测操作权限(检测被操作资源是否属于操作者) /// </summary> /// <param name="actionType">操作类型</param> /// <param name="operatorAgencyID">操作者所属机构主键ID</param> /// <param name="resourceID">被操作资源主键ID</param> public ServiceInvokeDTO CheckPermission(DoActionType actionType, int operatorAgencyID, int resourceID) { log.Debug(Constant.DEBUG_START); ServiceInvokeDTO result = null; try { switch (actionType) { case DoActionType.UpdateAdmin: case DoActionType.DeleteAdmin: case DoActionType.DeleteAdminInBatch: result = CheckAdminPermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateChapter: case DoActionType.UpChapter: case DoActionType.DownChapter: case DoActionType.DeleteChapter: case DoActionType.DeleteChapterInBatch: result = CheckChaperPermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateSingle: case DoActionType.DeleteSingle: case DoActionType.DeleteSingleInBatch: result = CheckSinglePermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateMultiple: case DoActionType.DeleteMultiple: case DoActionType.DeleteMultipleInBatch: result = CheckMultiplePermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateJudge: case DoActionType.DeleteJudge: case DoActionType.DeleteJudgeInBatch: result = CheckJudgePermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateUncertain: case DoActionType.DeleteUncertain: case DoActionType.DeleteUncertainInBatch: result = CheckUncertainPermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateUncertainSubChoice: case DoActionType.UpUncertainSubChoice: case DoActionType.DownUncertainSubChoice: case DoActionType.DeleteUncertainSubChoice: case DoActionType.DeleteUncertainSubChoiceInBatch: result = CheckUncertainSubChoicePermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateFenLu: case DoActionType.DeleteFenLu: case DoActionType.DeleteFenLuInBatch: result = CheckFenLuPermission(operatorAgencyID, resourceID); break; case DoActionType.UpdateNumberBlank: case DoActionType.DeleteNumberBlank: case DoActionType.DeleteNumberBlankInBatch: result = CheckNumberBlankPermission(operatorAgencyID, resourceID); break; default: break; } } catch (Exception ex) { log.Error(ex); result = new ServiceInvokeDTO(InvokeCode.SYS_INNER_ERROR); } log.Debug(Constant.DEBUG_END); return result; }