Exemplo n.º 1
0
        public static async Task <bool> CheckCommonCoroutines()
        {
            if (ObjectCacheManager.ShouldUpdateObjectCollection)
            {
                ObjectCacheManager.UpdateCache();
            }

            if (StyxWoW.Me.IsDead || StyxWoW.Me.IsGhost)
            {
                await DeathBehavior.ExecuteCoroutine();

                return(true);
            }


            if (await CombatBehavior.ExecuteBehavior())
            {
                return(true);
            }

            if (await VendoringBehavior())
            {
                return(true);
            }

            if (await LootBehavior.ExecuteBehavior())
            {
                return(true);
            }



            return(false);
        }
        protected IAsyncResult ExecuteSelect(
            IOrganizationService client,
            QueryBase query,
            AsyncCallback asyncCallback,
            object asyncState)
        {
            Request.Query = query;

            if (Owner.CacheParameters.Enabled)
            {
                string cacheKey = GetCacheKey(query);

                // try load from cache
                IEnumerable selectResult = ObjectCacheManager.GetInstance().Get(cacheKey) as IEnumerable;

                if (selectResult != null)
                {
                    Tracing.FrameworkInformation("CrmDataSourceView", "ExecuteSelect", "Found in cache: {0}", cacheKey);
                    Tracing.FrameworkInformation("CrmDataSourceView", "ExecuteSelect", "End");

                    return(new SynchronousAsyncSelectResult(selectResult, asyncCallback, asyncState));
                }
            }

            _execute = new Func <QueryBase, EntityCollection>(client.RetrieveMultiple);
            return(_execute.BeginInvoke(query, asyncCallback, asyncState));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Resets the cached dependencies.
 /// </summary>
 public static void Reset()
 {
     _provider = new Lazy <CrmConfigurationProvider>(CreateProvider);
     OrganizationService.Reset();
     ObjectCacheManager.Reset();
     LockManager.Reset();
 }
        /// <summary>
        /// Удаляет сущность с именем entityName из кеша
        /// </summary>
        /// <param name="xrmServiceContext"></param>
        /// <param name="entityName"></param>
        public static void ClearXrmCache(this XrmServiceContext xrmServiceContext, string entityName)
        {
            var dependency = String.Format("xrm:dependency:entity:{0}", entityName).ToLower();
            var cache      = ObjectCacheManager.GetInstance(null);

            cache.Remove(dependency);
        }
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }


            if (_entryId != 0)
            {
                if (StyxWoW.Me.CurrentTarget != null)
                {
                    if (StyxWoW.Me.CurrentTarget.Entry == _entryId)
                    {
                        IsDone = true;
                        return(false);
                    }
                }

                var _units = ObjectCacheManager.GetWoWUnits(_entryId);
                if (_units.Count > 0)
                {
                    TreeRoot.StatusText = String.Format("Behavior Targeting Unit {0}", _units[0].Name);
                    _units[0].RefWoWUnit.Target();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }
            else
            {
                var _units = ObjectCacheManager.GetUnitsNearPoint(_location, 5f);
                if (_units.Count > 0)
                {
                    if (StyxWoW.Me.CurrentTarget != null)
                    {
                        if (StyxWoW.Me.CurrentTarget.Entry == _units[0].Entry)
                        {
                            IsDone = true;
                            return(false);
                        }
                    }

                    TreeRoot.StatusText = String.Format("Behavior Targeting Unit {0}", _units[0].Name);
                    _units[0].RefWoWUnit.Target();
                    await CommonCoroutines.SleepForRandomUiInteractionTime();

                    return(true);
                }
            }


            return(false);
        }
Exemplo n.º 6
0
        protected IAsyncResult ExecuteSelect(
            IOrganizationService client,
            QueryBase query,
            Fetch fetch,
            AsyncCallback asyncCallback,
            object asyncState)
        {
            string cacheKey = string.Empty;

            if (query != null)
            {
                Request.Query = query;
                cacheKey      = GetCacheKey(query);
            }
            else if (fetch != null)
            {
                Fetch.Entity = fetch.Entity;
                cacheKey     = GetCacheKey(fetch.ToFetchExpression());
            }

            if (Owner.CacheParameters.Enabled)
            {
                // try load from cache
                IEnumerable selectResult = ObjectCacheManager.GetInstance().Get(cacheKey) as IEnumerable;

                if (selectResult != null)
                {
                    ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Found in cache: {0}", cacheKey));
                    ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

                    return(new SynchronousAsyncSelectResult(selectResult, asyncCallback, asyncState));
                }
            }

            if (Owner.IsSingleSource)
            {
                _executeSingle = new Func <Fetch, Entity>(f => client.RetrieveSingle(f));
                return(_executeSingle.BeginInvoke(fetch, asyncCallback, asyncState));
            }
            else
            {
                if (fetch != null)
                {
                    _executeFetchMultiple = new Func <Fetch, EntityCollection>(f => client.RetrieveMultiple(f));
                    return(_executeFetchMultiple.BeginInvoke(fetch, asyncCallback, asyncState));
                }
            }

            _execute = new Func <QueryBase, EntityCollection>(client.RetrieveMultiple);
            return(_execute.BeginInvoke(query, asyncCallback, asyncState));
        }
Exemplo n.º 7
0
        private static bool ValidateCombatObject()
        {
            if (ObjectCacheManager.ShouldUpdateObjectCollection)
            {
                ObjectCacheManager.UpdateCache();
            }

            if (!TargetManager.ShouldKill)
            {
                ResetCombat();
                return(false);
            }

            if (TargetManager.CombatObject == null)
            {
                TargetManager.UpdateCombatTarget();
                if (TargetManager.CombatObject == null)
                {
                    ResetCombat();
                    return(false);
                }
            }

            if (!TargetManager.CombatObject.ValidForCombat)
            {
                GarrisonBase.Debug("EngageObject no longer valid for combat!");
                TargetManager.UpdateCombatTarget();


                //Clear and update lootable object
                TargetManager.LootableObject = null;
                LootBehavior.ResetLoot();
                TargetManager.UpdateLootableTarget();

                ResetCombat();
                return(false);
            }

            if (TargetManager.CombatObject.IsEvadeRunningBack)
            {
                GarrisonBase.Debug("EngageObject is evading!");
                TargetManager.CombatObject.IgnoredTimer = WaitTimer.TenSeconds;
                TargetManager.CombatObject.IgnoredTimer.Reset();
                return(false);
            }

            return(true);
        }
        /// <summary>
        /// Sets the challenge text for a particular ID.
        /// </summary>
        /// <param name="challengeId">The ID of the challenge with which this text should be associated.</param>
        /// <param name="text">The text to store along with the challenge ID.</param>
        /// <param name="expiration">The expiration date fo the challenge.</param>
        internal static void SetChallengeText(Guid challengeId, string text, DateTime expiration, string objectCacheName)
        {
            var key = GetChallengeCacheKey(challengeId);

            if (text == null)
            {
                ObjectCacheManager.GetInstance(objectCacheName).Remove(key);
            }
            else
            {
                var policy = new CacheItemPolicy {
                    Priority = CacheItemPriority.NotRemovable
                };
                ObjectCacheManager.GetInstance(objectCacheName).Insert(key, text, policy);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Invalidates the entire cache
        /// </summary>
        public static void InvalidateAllCache()
        {
            var serviceCaches = GetServiceCaches();

            foreach (var organizationServiceCache in serviceCaches)
            {
                organizationServiceCache.Remove(new OrganizationServiceCachePluginMessage {
                    Category = CacheItemCategory.All
                });
            }

            var objectCaches = GetObjectCaches();

            foreach (var cache in objectCaches)
            {
                ObjectCacheManager.RemoveAll(cache);
            }
        }
Exemplo n.º 10
0
        public override void Start()
        {
            Debug("BotEvent OnStart");
            HbRelogApi = new HBRelogApi();
            CacheStaticLookUp.InitalizedCache = false;
            BehaviorManager.Reset();
            Common.ResetCommonBehaviors();
            ObjectCacheManager.ResetCache(true);
            TargetManager.Reset();
            GarrisonManager.Reset();
            QuestHelper.QuestLog.Clear();
            LuaEvents.ResetFrameVariables();

            if (!LuaEvents.LuaEventsAttached)
            {
                LuaEvents.AttachLuaEventHandlers();
            }
        }
Exemplo n.º 11
0
        private static bool ValidateLootObject()
        {
            if (ObjectCacheManager.ShouldUpdateObjectCollection)
            {
                ObjectCacheManager.UpdateCache();
            }

            if (!TargetManager.ShouldLoot)
            {
                return(false);
            }

            if (TargetManager.LootableObject == null || !TargetManager.LootableObject.IsValid)
            {
                if (TargetManager.LootableObject != null)
                {
                    TargetManager.LootableObject.ShouldLoot = false;
                }


                TargetManager.UpdateLootableTarget();
                if (TargetManager.LootableObject == null)
                {
                    ResetLoot();
                    return(false);
                }
            }

            if (!TargetManager.LootableObject.ValidForLooting)
            {
                GarrisonBase.Debug("LootObject no longer valid for looting {0}", TargetManager.LootableObject.Name);

                IgnoreLootableObject();

                TargetManager.UpdateLootableTarget();

                ResetLoot();
                return(false);
            }

            return(true);
        }
Exemplo n.º 12
0
        public override async Task <bool> BehaviorRoutine()
        {
            if (await base.BehaviorRoutine())
            {
                return(true);
            }
            if (IsDone)
            {
                return(false);
            }

            if (_shouldCheckMapId && Player.MapId == _destinationMapId)
            {
                GarrisonBase.Debug("UseFlightPath is finished due to matching map ids");
                IsDone = true;
                if (_currentMapId == 1153 || _currentMapId == 1159 || _currentMapId == 1331 || _currentMapId == 1330)
                {
                    //Reset Cache (Garrison was last location)
                    ObjectCacheManager.ResetCache();
                    TargetManager.Reset();
                }
                return(false);
            }

            if (TaxiFlightHelper.TaxiNodes.Count > 0 && _selectedTaxiNode == null && await CheckFlightNodes())
            {
                return(true);
            }

            if (await VerifyFlightNpc())
            {
                return(true);
            }

            if (await UseFlightPath())
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        public static string GetCrmEntitySetSchemaMap(this Type crmDataContextType, string crmEntityName)
        {
            return(ObjectCacheManager.Get("microsoft.xrm.portal:entity-schema-map:json:{0}:{1}".FormatWith(crmDataContextType.FullName, crmEntityName), cache =>
            {
                EntitySetInfo entitySetInfo;

                if (!OrganizationServiceContextInfo.TryGet(crmDataContextType, crmEntityName, out entitySetInfo) ||
                    entitySetInfo.Entity == null ||
                    entitySetInfo.Entity.EntityLogicalName == null)
                {
                    throw new InvalidOperationException(@"Unable to retrieve entity set information for entity name ""{0}"".".FormatWith(crmEntityName));
                }

                var properties = entitySetInfo.Entity.AttributesByLogicalName.Values;

                var schemaMap = properties.ToDictionary(info => info.CrmPropertyAttribute.LogicalName, info => info.Property.Name);

                var json = schemaMap.SerializeByJson(new Type[] { });

                return json;
            }));
        }
Exemplo n.º 14
0
        public override bool TryAssert(OrganizationServiceContext context, Entity entity, CrmEntityRight right, CrmEntityCacheDependencyTrace dependencies)
        {
            var info = CacheInfoFactory.GetCacheInfo(context, entity, right);

            if (!info.IsCacheable)
            {
                return(UnderlyingProvider.TryAssert(context, entity, right, dependencies));
            }

            Stopwatch stopwatch = null;

            return(ObjectCacheManager.Get(info.Key,
                                          cache =>
            {
                stopwatch = Stopwatch.StartNew();

                var value = UnderlyingProvider.TryAssert(context, entity, right, dependencies);

                stopwatch.Stop();

                return value;
            },
                                          (cache, value) =>
            {
                if (dependencies.IsCacheable)
                {
                    cache.Insert(info.Key, value, dependencies);

                    if (stopwatch != null)
                    {
                        cache.AddCacheItemTelemetry(info.Key, new CacheItemTelemetry {
                            Duration = stopwatch.Elapsed
                        });
                    }
                }
            }));
        }
Exemplo n.º 15
0
        protected override IEnumerable EndExecuteSelect(IAsyncResult asyncResult)
        {
            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Begin");

            if (_client == null)
            {
                ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End: _client=null");

                return(null);
            }

            IEnumerable selectResult = null;
            int         rowsAffected = 0;

            try
            {
                SynchronousAsyncSelectResult syncResult = asyncResult as SynchronousAsyncSelectResult;

                if (syncResult != null)
                {
                    ADXTrace.Instance.TraceInfo(TraceCategory.Application, "syncResult");

                    selectResult = syncResult.SelectResult;
                }
                else
                {
                    ADXTrace.Instance.TraceInfo(TraceCategory.Application, "EndExecute");

                    if (!Owner.IsSingleSource)
                    {
                        var response = _execute != null?_execute.EndInvoke(asyncResult) : _executeFetchMultiple.EndInvoke(asyncResult);

                        if (response != null)
                        {
                            var entities = response.Entities;
                            rowsAffected = entities.Count;
                            selectResult = ExecuteSelect(entities).ToList();

                            if (Owner.CacheParameters.Enabled)
                            {
                                IEnumerable <string> dependencies;
                                string cacheKey;
                                if (Request.Query != null)
                                {
                                    dependencies = GetCacheDependencies(Request.Query, selectResult);
                                    cacheKey     = GetCacheKey(Request.Query);
                                }
                                else
                                {
                                    dependencies = GetCacheDependencies(Fetch, selectResult, Owner.IsSingleSource);
                                    cacheKey     = GetCacheKey(Request.Query);
                                }

                                // insert into cache
                                ObjectCacheManager.GetInstance().Insert(cacheKey, selectResult, dependencies);
                            }
                        }
                    }
                    else
                    {
                        var entity = _executeSingle.EndInvoke(asyncResult);
                        if (entity != null)
                        {
                            selectResult = ExecuteSelect(new [] { entity }).ToList();
                            if (Owner.CacheParameters.Enabled)
                            {
                                var dependencies = GetCacheDependencies(Fetch, selectResult, Owner.IsSingleSource);
                                var cacheKey     = GetCacheKey(Fetch.ToFetchExpression());

                                // insert into cache
                                ObjectCacheManager.GetInstance().Insert(cacheKey, selectResult, dependencies);
                            }
                        }
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("{0}\n\n{1}", ex.Detail.InnerXml, ex.ToString()));
            }
            catch (Exception e)
            {
                ADXTrace.Instance.TraceError(TraceCategory.Application, string.Format("Exception: {0}", e.ToString()));

                // raise post-event with exception
                CrmDataSourceStatusEventArgs selectedExceptionArgs = new CrmDataSourceStatusEventArgs(0, e);
                OnSelected(selectedExceptionArgs);

                if (!selectedExceptionArgs.ExceptionHandled)
                {
                    throw;
                }

                return(selectResult);
            }
            finally
            {
                _client = null;
            }

            // raise post-event
            CrmDataSourceStatusEventArgs selectedArgs = new CrmDataSourceStatusEventArgs(rowsAffected, null);

            OnSelected(selectedArgs);

            ADXTrace.Instance.TraceInfo(TraceCategory.Application, "End");

            return(string.IsNullOrEmpty(Owner.StaticEntityWrapperTypeName) ? selectResult : CreateEntities(selectResult));
        }
Exemplo n.º 16
0
        internal static bool CanInteractWithUnit(uint id)
        {
            var unit = ObjectCacheManager.GetWoWUnits(id).FirstOrDefault();

            return(unit != null && unit.IsValid && unit.RefWoWUnit.CanInteract);
        }
Exemplo n.º 17
0
        internal static BehaviorArray GetDailyQuestArray(uint questid, bool alliance)
        {
            switch (questid)
            {
            case 38175:
            case 38188:
            {
                var questNpcId    = alliance ? 77377 : 79815;
                var warmillBunker = GarrisonManager.Buildings[BuildingType.WarMillDwarvenBunker];
                var questPickup   = new BehaviorQuestPickup(questid, warmillBunker.SpecialMovementPoints[1], questNpcId);
                var questTurnin   = new BehaviorQuestTurnin(questid, warmillBunker.SpecialMovementPoints[1], questNpcId, BaseSettings.CurrentSettings.DailyWarMillQuestSettings.RewardIndex);
                var barray        = new BehaviorArray(new Behavior[]
                    {
                        questPickup,
                        questTurnin,
                    });
                barray.Criteria += () => BaseSettings.CurrentSettings.BehaviorQuests &&
                                   BaseSettings.CurrentSettings.DailyWarMillQuestSettings.Enabled &&
                                   BaseSettings.CurrentSettings.DailyWarMillQuestSettings.RewardIndex > -1 &&
                                   !LuaCommands.IsQuestFlaggedCompleted(questid.ToString());

                barray.Criteria += () =>
                {
                    var items = Player.Inventory.GetBagItemsById(113681).Where(i => i.StackCount > 24).ToList();
                    return(items.Count > 0);
                };

                return(barray);
            }

            case 37270:
            {
                var alchemyLab = GarrisonManager.Buildings[BuildingType.AlchemyLab];

                var questPickup = new BehaviorQuestPickup(
                    questid,
                    alchemyLab.EntranceMovementPoint,
                    0,
                    true,
                    BaseSettings.CurrentSettings.DailyAlchemyLabQuestSettings.RewardIndex);

                //Use special method of getting the interaction object since it varies on which follower is assigned!
                questPickup.GetInteractionObject = i =>
                {
                    var validObjects =
                        ObjectCacheManager.GetUnitsNearPoint(alchemyLab.EntranceMovementPoint, 30f, false)
                        .Where(u => u.QuestGiverStatus == QuestGiverStatus.AvailableRepeatable && !ObjectCacheManager.QuestNpcIds.Contains(u.Entry))
                        .ToList();

                    return(validObjects.Count > 0 ? validObjects[0] : null);
                };

                var barray = new BehaviorArray(new Behavior[]
                    {
                        questPickup,
                    });
                barray.Criteria += () => BaseSettings.CurrentSettings.BehaviorQuests &&
                                   BaseSettings.CurrentSettings.DailyAlchemyLabQuestSettings.Enabled &&
                                   BaseSettings.CurrentSettings.DailyAlchemyLabQuestSettings.RewardIndex > -1 &&
                                   !LuaCommands.IsQuestFlaggedCompleted(questid.ToString());

                return(barray);
            }
            }

            return(null);
        }
Exemplo n.º 18
0
        internal static bool UnitHasQuestGiverStatus(uint id, QuestGiverStatus status)
        {
            var unit = ObjectCacheManager.GetWoWUnits(id).FirstOrDefault();

            return(unit != null && unit.IsValid && unit.RefWoWUnit.QuestGiverStatus == status);
        }
Exemplo n.º 19
0
        protected override IEnumerable ExecuteSelect(DataSourceSelectArguments arguments)
        {
            Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "Begin");

            if (CanSort)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Sort);
            }

            if (CanPage)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.Page);
            }

            if (CanRetrieveTotalRowCount)
            {
                arguments.AddSupportedCapabilities(DataSourceCapabilities.RetrieveTotalRowCount);
            }

            // merge SelectParameters
            IOrderedDictionary parameters = SelectParameters.GetValues(Context, Owner);

            string sortExpression = GetNonNullOrEmpty(
                arguments.SortExpression,
                parameters[_sortExpressionParameterName] as string,
                SortExpression);
            string entityName = GetNonNullOrEmpty(
                parameters[_entityNameParameterName] as string,
                EntityName);
            string attributeName = GetNonNullOrEmpty(
                parameters[_attributeNameParameterName] as string,
                AttributeName);

            var metadataFlags = MetadataFlags;

            if (parameters.Contains(_metadataFlagsParameterName))
            {
                metadataFlags = (parameters[_metadataFlagsParameterName] as string).ToEnum <EntityFilters>();
            }

            var entityFlags = EntityFlags;

            if (parameters.Contains(_entityFlagsParameterName))
            {
                entityFlags = (parameters[_entityFlagsParameterName] as string).ToEnum <EntityFilters>();
            }

            // raise pre-event
            CrmMetadataDataSourceSelectingEventArgs selectingArgs = new CrmMetadataDataSourceSelectingEventArgs(
                Owner,
                arguments,
                entityName,
                attributeName,
                metadataFlags,
                entityFlags,
                sortExpression);

            OnSelecting(selectingArgs);

            if (selectingArgs.Cancel)
            {
                Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "Cancel");
                return(null);
            }

            // merge event results
            arguments.RaiseUnsupportedCapabilitiesError(this);
            sortExpression = selectingArgs.SortExpression;
            entityName     = selectingArgs.EntityName;
            attributeName  = selectingArgs.AttributeName;
            metadataFlags  = selectingArgs.MetadataFlags;
            entityFlags    = selectingArgs.EntityFlags;

            if (CancelSelectOnNullParameter && string.IsNullOrEmpty(entityName) && string.IsNullOrEmpty(attributeName))
            {
                Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "CancelSelectOnNullParameter");
                return(null);
            }

            IEnumerable result       = null;
            int         rowsAffected = 0;

            try
            {
                if (Owner.CacheParameters.Enabled)
                {
                    var cacheKey = GetCacheKey(metadataFlags, entityFlags, entityName, attributeName, sortExpression);

                    result = ObjectCacheManager.Get(cacheKey,
                                                    cache =>
                    {
                        var metadata = ExecuteSelect(entityName, attributeName, sortExpression, entityFlags, metadataFlags, out rowsAffected);
                        return(metadata);
                    },
                                                    (cache, metadata) =>
                    {
                        if (metadata != null)
                        {
                            var dependencies = GetCacheDependencies(metadata);
                            cache.Insert(cacheKey, metadata, dependencies);
                        }
                    });
                }
                else
                {
                    result = ExecuteSelect(entityName, attributeName, sortExpression, entityFlags, metadataFlags, out rowsAffected);
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                Tracing.FrameworkError("CrmMetadataDataSourceView", "ExecuteSelect", "{0}\n\n{1}", ex.Detail.InnerXml, ex);
            }
            catch (Exception e)
            {
                Tracing.FrameworkError("CrmMetadataDataSourceView", "ExecuteSelect", "Exception: {0}", e);

                // raise post-event with exception
                CrmMetadataDataSourceStatusEventArgs selectedExceptionArgs = new CrmMetadataDataSourceStatusEventArgs(0, e);
                OnSelected(selectedExceptionArgs);

                if (!selectedExceptionArgs.ExceptionHandled)
                {
                    throw;
                }

                return(result);
            }

            // raise post-event
            CrmMetadataDataSourceStatusEventArgs selectedArgs = new CrmMetadataDataSourceStatusEventArgs(rowsAffected, null);

            OnSelected(selectedArgs);

            Tracing.FrameworkInformation("CrmMetadataDataSourceView", "ExecuteSelect", "End");

            return(result);
        }
Exemplo n.º 20
0
        internal static bool ObjectNotValidOrNotFound(uint id)
        {
            var obj = ObjectCacheManager.GetWoWObject(id);

            return(obj == null || !obj.IsValid);
        }
 /// <summary>
 /// Gets the challenge text for a particular ID.
 /// </summary>
 /// <param name="challengeId">The ID of the challenge text to retrieve.</param>
 /// <returns>
 /// The text associated with the specified ID; null if no text exists.
 /// </returns>
 public static string GetChallengeText(Guid challengeId, string objectCacheName)
 {
     return(ObjectCacheManager.GetInstance(objectCacheName).Get(GetChallengeCacheKey(challengeId)) as string);
 }
Exemplo n.º 22
0
 private ObjectCache GetCache()
 {
     return(ObjectCacheManager.GetInstance(ObjectCacheName));
 }
Exemplo n.º 23
0
        internal static bool CanAttackUnit(uint id)
        {
            var unit = ObjectCacheManager.GetWoWUnits(id).FirstOrDefault();

            return(unit != null && unit.IsValid && unit.RefWoWUnit.Attackable);
        }
Exemplo n.º 24
0
        public static async Task <bool> RootLogic()
        {
            if (!CacheStaticLookUp.InitalizedCache)
            {
                CacheStaticLookUp.Update();
                ObjectCacheManager.Initalize();
                TargetManager.Initalize();
                Movement.IgnoreTaxiCheck = false;

                //Simple Check if garrison can be accessed!
                if (Player.Level < 90 || Player.Inventory.GarrisonHearthstone == null)
                {
                    GarrisonBase.Log("No access to garrison!");
                    TreeRoot.Stop("No Access to Garrison");
                    return(false);
                }
            }

            if (await Common.CheckCommonCoroutines())
            {
                return(true);
            }

            //Do we need to hearth or fly to our garrison?
            if (await Common.PreChecks.BehaviorRoutine())
            {
                return(true);
            }

            //Disable and reload UI if master plan is enabled..
            //if (await Common.PreChecks.CheckAddons()) return true;

            //We need "open" the garrison up and initalize it.. (so we don't get errors trying to inject!)
            if (await Common.PreChecks.InitalizeGarrisonManager())
            {
                return(true);
            }

            ////Inject our lua addon code for mission success function
            //if (!LuaEvents.LuaAddonInjected)
            //{
            //    if (LuaCommands.TestLuaInjectionCode())
            //    {//Prevent multiple injections by checking simple function return!
            //        LuaEvents.LuaAddonInjected = true;
            //    }
            //    else
            //    {
            //        await LuaEvents.InjectLuaAddon();
            //        return true;
            //    }
            //}



            if (!InitalizedBehaviorList)
            {
                InitalizeBehaviorsList();
            }

            //Check for next behavior
            if (CurrentBehavior == null)
            {
                while (Behaviors.Count > 0)
                {
                    if (!Behaviors[0].CheckCriteria())
                    {
                        Behaviors.RemoveAt(0);
                    }
                    else
                    {
                        CurrentBehavior = Behaviors[0];
                        CurrentBehavior.Initalize();
                        break;
                    }
                }
            }



            if (CurrentBehavior != null)
            {
                //Check for any switch behaviors.. (override current behavior temporarly)
                if (SwitchBehaviors.Count > 0 && SwitchBehavior == null)
                {
                    while (SwitchBehaviors.Count > 0)
                    {
                        if (!SwitchBehaviors[0].CheckCriteria())
                        {
                            SwitchBehaviors.RemoveAt(0);
                        }
                        else
                        {
                            SwitchBehavior = SwitchBehaviors[0];
                            break;
                        }
                    }
                }

                if (SwitchBehavior != null && CurrentBehavior != SwitchBehavior)
                {
                    GarrisonBase.Debug("Switching behaviors to {0}", SwitchBehavior.Type);
                    CurrentBehavior = SwitchBehavior;
                    CurrentBehavior.Initalize();
                }

                bool x = await CurrentBehavior.BehaviorRoutine();

                if (x && !CurrentBehavior.IsDone)
                {
                    return(true);
                }

                GarrisonBase.Debug(
                    !x ? "Finishing Behavior {0} because it returned false!"
                        : "Finishing Behavior {0} because IsDone is true", CurrentBehavior.Type);

                if (!CurrentBehavior.Disposed)
                {
                    CurrentBehavior.Dispose();
                }

                if (SwitchBehavior != null && CurrentBehavior.Equals(SwitchBehavior))
                {
                    CurrentBehavior = Behaviors[0];
                    CurrentBehavior.Initalize();

                    SwitchBehaviors.RemoveAt(0);
                    SwitchBehavior = null;
                }
                else
                {
                    Behaviors.RemoveAt(0);
                    CurrentBehavior = null;
                }


                return(true);
            }

            //if (Common.PreChecks.DisabledMasterPlanAddon)
            //{
            //    Common.PreChecks.ShouldCheckAddons = false;
            //    LuaCommands.EnableAddon("MasterPlan");
            //    LuaCommands.ReloadUI();
            //    Common.PreChecks.DisabledMasterPlanAddon = false;
            //    await Coroutine.Wait(6000, () => StyxWoW.IsInGame);
            //    return true;
            //}



            TreeRoot.StatusText = "GarrisonBase is finished!";
            TreeRoot.Stop();
            return(false);
        }
        protected override IEnumerable EndExecuteSelect(IAsyncResult asyncResult)
        {
            Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "Begin");

            if (_client == null)
            {
                Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "End: _client=null");

                return(null);
            }

            IEnumerable selectResult = null;
            int         rowsAffected = 0;

            try
            {
                SynchronousAsyncSelectResult syncResult = asyncResult as SynchronousAsyncSelectResult;

                if (syncResult != null)
                {
                    Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "syncResult");

                    selectResult = syncResult.SelectResult;
                }
                else
                {
                    Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "EndExecute");

                    var response = _execute.EndInvoke(asyncResult);

                    if (response != null)
                    {
                        var entities = response.Entities;
                        rowsAffected = entities.Count;
                        selectResult = ExecuteSelect(entities).ToList();

                        if (Owner.CacheParameters.Enabled)
                        {
                            var dependencies = GetCacheDependencies(Request.Query, selectResult);

                            string cacheKey = GetCacheKey(Request.Query);

                            // insert into cache
                            ObjectCacheManager.GetInstance().Insert(cacheKey, selectResult, dependencies);
                        }
                    }
                }
            }
            catch (System.Web.Services.Protocols.SoapException ex)
            {
                Tracing.FrameworkError("CrmDataSourceView", "EndExecuteSelect", "{0}\n\n{1}", ex.Detail.InnerXml, ex);
            }
            catch (Exception e)
            {
                Tracing.FrameworkError("CrmDataSourceView", "EndExecuteSelect", "Exception: {0}", e);

                // raise post-event with exception
                CrmDataSourceStatusEventArgs selectedExceptionArgs = new CrmDataSourceStatusEventArgs(0, e);
                OnSelected(selectedExceptionArgs);

                if (!selectedExceptionArgs.ExceptionHandled)
                {
                    throw;
                }

                return(selectResult);
            }
            finally
            {
                _client = null;
            }

            // raise post-event
            CrmDataSourceStatusEventArgs selectedArgs = new CrmDataSourceStatusEventArgs(rowsAffected, null);

            OnSelected(selectedArgs);

            Tracing.FrameworkInformation("CrmDataSourceView", "EndExecuteSelect", "End");

            return(string.IsNullOrEmpty(Owner.StaticEntityWrapperTypeName) ? selectResult : CreateEntities(selectResult));
        }