Example #1
0
        /// <summary>
        /// Put it in the cache
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool PersistToCache()
        {
            try
            {
                UpsertToLiveWorldCache();
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SystemWarnings);
                return(false);
            }

            return(true);
        }
Example #2
0
        public ActionResult Edit(long id, AddEditFloraViewModel vModel)
        {
            string          message    = string.Empty;
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IFlora obj = TemplateCache.Get <IFlora>(id);

            if (obj == null)
            {
                message = "That does not exist";
                return(RedirectToAction("Index", new { Message = message }));
            }

            obj.Name               = vModel.DataObject.Name;
            obj.HelpText           = vModel.DataObject.HelpText;
            obj.SunlightPreference = vModel.DataObject.SunlightPreference;
            obj.Coniferous         = vModel.DataObject.Coniferous;
            obj.AmountMultiplier   = vModel.DataObject.AmountMultiplier;
            obj.Rarity             = vModel.DataObject.Rarity;
            obj.PuissanceVariance  = vModel.DataObject.PuissanceVariance;
            obj.ElevationRange     = vModel.DataObject.ElevationRange;
            obj.TemperatureRange   = vModel.DataObject.TemperatureRange;
            obj.HumidityRange      = vModel.DataObject.HumidityRange;
            obj.Wood               = vModel.DataObject.Wood;
            obj.Flower             = vModel.DataObject.Flower;
            obj.Seed               = vModel.DataObject.Seed;
            obj.Leaf               = vModel.DataObject.Leaf;
            obj.Fruit              = vModel.DataObject.Fruit;
            obj.OccursIn           = vModel.DataObject.OccursIn;

            if (obj.Wood == null && obj.Flower == null && obj.Seed == null && obj.Leaf == null && obj.Fruit == null)
            {
                message = "At least one of the parts of this plant must be valid.";
            }

            if (string.IsNullOrWhiteSpace(message))
            {
                if (obj.Save(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - EditFlora[" + obj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                    message = "Edit Successful.";
                }
                else
                {
                    message = "Error; Edit failed.";
                }
            }

            return(RedirectToAction("Index", new { Message = message }));
        }
Example #3
0
        /// <summary>
        /// Put it in the cache
        /// </summary>
        /// <returns>success status</returns>
        public override bool PersistToCache()
        {
            try
            {
                PlayerDataCache.Add(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SystemWarnings);
                return(false);
            }

            return(true);
        }
Example #4
0
        /// <summary>
        /// Put it in the cache
        /// </summary>
        /// <returns>success status</returns>
        public virtual bool PersistToCache()
        {
            try
            {
                TemplateCache.Add(this);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex, LogChannels.SystemWarnings);
                return(false);
            }

            return(true);
        }
Example #5
0
        /// <summary>
        /// When base type and maintype want to be less ambigious
        /// </summary>
        /// <typeparam name="T">The base type (like ILocation)</typeparam>
        /// <param name="mainType">The inheriting type (like IRoom)</param>
        /// <returns>all the stuff and things</returns>
        public IEnumerable <T> GetAll <T>(Type mainType)
        {
            try
            {
                return(_globalCache.Where(keyValuePair => keyValuePair.Value.GetType().GetInterfaces().Contains(typeof(T)) && keyValuePair.Value.GetType() == mainType)
                       .Select(kvp => (T)kvp.Value));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(Enumerable.Empty <T>());
        }
Example #6
0
        public ActionResult AddWithRoom(AddPathwayWithRoomTemplateViewModel vModel)
        {
            ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

            IRoomTemplate origin  = TemplateCache.Get <IRoomTemplate>(vModel.Origin.Id);
            IRoomTemplate newRoom = vModel.Destination;

            newRoom.ParentLocation = origin.ParentLocation;

            string message = string.Empty;

            if (newRoom.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) != null)
            {
                IPathwayTemplate newObj = vModel.DataObject;
                newObj.Destination = newRoom;
                newObj.Origin      = origin;

                if (newObj.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                {
                    message = "Error; Creation failed.";
                }
                else
                {
                    if (vModel.CreateReciprocalPath)
                    {
                        PathwayTemplate reversePath = new PathwayTemplate
                        {
                            Name             = newObj.Name,
                            DegreesFromNorth = Utilities.ReverseDirection(newObj.DegreesFromNorth),
                            Origin           = newObj.Destination,
                            Destination      = newObj.Origin,
                            Model            = newObj.Model,
                            InclineGrade     = newObj.InclineGrade * -1
                        };

                        if (reversePath.Create(authedUser.GameAccount, authedUser.GetStaffRank(User)) == null)
                        {
                            message = "Reverse Path creation FAILED. Origin path creation SUCCESS.";
                        }
                    }

                    LoggingUtility.LogAdminCommandUsage("*WEB* - AddPathwayWithRoom[" + newObj.Id.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
            }
            else
            {
                message = "Error; Creation failed.";
            }
            return(RedirectToRoute("ModalErrorOrClose", new { Message = message }));
        }
Example #7
0
        /// <summary>
        /// fills a list of entities from the cache of a single type that match the birthmarks sent in
        /// </summary>
        /// <typeparam name="T">the system type for the entity</typeparam>
        /// <param name="keys">the keys to retrieve</param>
        /// <returns>a list of the entities from the cache</returns>
        public IEnumerable <T> GetMany <T>(IEnumerable <ICacheKey> keys)
        {
            try
            {
                return(_globalCache.Where(keyValuePair => keyValuePair.Value.GetType().GetInterfaces().Contains(typeof(T)) && keys.Any(key => key.KeyHash().Equals(keyValuePair.Key)))
                       .Select(kvp => (T)kvp.Value));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(Enumerable.Empty <T>());
        }
Example #8
0
        /// <summary>
        /// fills a list of entities from the cache of a single type that match the birthmarks sent in
        /// </summary>
        /// <typeparam name="T">the system type for the entity</typeparam>
        /// <param name="birthmarks">the birthmarks to retrieve</param>
        /// <returns>a list of the entities from the cache</returns>
        public IEnumerable <T> GetMany <T>(IEnumerable <string> birthmarks) where T : ILiveData
        {
            try
            {
                return(_globalCache.Where(keyValuePair => keyValuePair.Value.GetType().GetInterfaces().Contains(typeof(T)) && birthmarks.Contains(((T)keyValuePair.Value).BirthMark))
                       .Select(kvp => (T)kvp.Value));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(Enumerable.Empty <T>());
        }
Example #9
0
        /// <summary>
        /// Add it to the cache and save it to the file system
        /// </summary>
        /// <returns>the object with Id and other db fields set</returns>
        public virtual IKeyedData Create(IAccount creator, StaffRank rank)
        {
            DataAccess.FileSystem.TemplateData accessor = new DataAccess.FileSystem.TemplateData();

            try
            {
                if (Created != DateTime.MinValue)
                {
                    Save(creator, rank);
                }
                else
                {
                    //reset this guy's Id to the next one in the list
                    GetNextId();
                    Created     = DateTime.Now;
                    Creator     = creator;
                    CreatorRank = rank;

                    //Figure out automated approvals, always throw reviewonly in there
                    if (rank < StaffRank.Admin && ApprovalType != ContentApprovalType.ReviewOnly)
                    {
                        switch (ApprovalType)
                        {
                        case ContentApprovalType.None:
                            ApproveMe(creator, rank);
                            break;

                        case ContentApprovalType.Leader:
                            if (rank == StaffRank.Builder)
                            {
                                ApproveMe(creator, rank);
                            }

                            break;
                        }
                    }

                    PersistToCache();
                    accessor.WriteEntity(this);
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
                return(null);
            }

            return(this);
        }
Example #10
0
        public override void OnTestMethodInitialise(string testMethod, TestContext testContext = null)
        {
            TestMethodManager.CheckTestAlreadyInitialised(testMethod);

            try
            {
                TestMethodManager.Add(testMethod);
            }
            catch (System.Exception exp)
            {
                LoggingUtility?.Error($"Exception Msg: {exp.Message}, Exception StackTrace: {exp.StackTrace}, Inner Exception Msg: {exp.InnerException?.Message} Inner Exception Stack Trace: {exp.InnerException?.StackTrace}");
                Dispose(testMethod);
                throw;
            }
        }
Example #11
0
        /// <summary>
        /// fills a list of entities from the cache of a single type that match the birthmarks sent in
        /// </summary>
        /// <typeparam name="T">the system type for the entity</typeparam>
        /// <param name="birthmarks">the birthmarks to retrieve</param>
        /// <returns>a list of the entities from the cache</returns>
        public IEnumerable <T> GetMany <T>(IEnumerable <long> ids) where T : IKeyedData
        {
            try
            {
                return(_globalCache.Where(keyValuePair => keyValuePair.Value.GetType().GetInterfaces().Contains(typeof(T)) &&
                                          ids.Contains(((T)keyValuePair.Value).Id))
                       .Select(kvp => (T)kvp.Value));
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(Enumerable.Empty <T>());
        }
Example #12
0
        public static void LoadWordnet()
        {
            string wordNetPath = HttpContext.Current.Server.MapPath("/FileStore/wordnet/");

            if (!Directory.Exists(wordNetPath))
            {
                LoggingUtility.LogError(new FileNotFoundException("WordNet data not found."));
                return;
            }

            var engine = new WordNetEngine();

            engine.LoadFromDirectory(wordNetPath);
            WordNetHarness = engine;
        }
        private SendMessageApi GetDigipostApi(FakeResponseHandler fakeResponseHandler)
        {
            var httpClient = GetHttpClient(fakeResponseHandler);

            var serviceProvider = LoggingUtility.CreateServiceProviderAndSetUpLogging();

            var requestHelper = new RequestHelper(httpClient, serviceProvider.GetService <ILoggerFactory>())
            {
                HttpClient = httpClient
            };

            var digipostApi = new SendMessageApi(new SendRequestHelper(requestHelper), serviceProvider.GetService <ILoggerFactory>());

            return(digipostApi);
        }
Example #14
0
 public void CheckIfAdmin()
 {
     try
     {
         if (((Users)Session["User"]).Role != "Admin")
         {
             Response.Redirect("~/Pages/Logout.aspx");
         }
     }
     catch (Exception ex)
     {
         LoggingUtility.LogException(ex, "masterPgLoginValidation");
         Response.Redirect("~/Pages/Logout.aspx");
     }
 }
            public void Initializes_fields()
            {
                //Arrange
                var databehandler       = new Databehandler(DomainUtility.PostenOrganisasjonsnummer());
                var klientkonfigurasjon = new Klientkonfigurasjon(IntegrasjonsPunktLocalHostMiljø);

                //Act
                var serviceProvider         = LoggingUtility.CreateServiceProviderAndSetUpLogging();
                var sikkerDigitalPostKlient = new SikkerDigitalPostKlient(databehandler, klientkonfigurasjon, serviceProvider.GetService <ILoggerFactory>());

                //Assert
                Assert.Equal(klientkonfigurasjon, sikkerDigitalPostKlient.Klientkonfigurasjon);
                Assert.Equal(databehandler, sikkerDigitalPostKlient.Databehandler);
                Assert.IsType <RequestHelper>(sikkerDigitalPostKlient.RequestHelper);
            }
Example #16
0
        public ATLTask(string pgmID, string host, string port, string item, int qty)
        {
            this.item = item;
            this.qty  = qty;

            _logging = new LoggingUtility(pgmID, Level.Info, 30);

            PGM_ID        = pgmID;
            hostIP        = host;
            hostPort      = int.Parse(port);
            timer_CONNECT = Convert.ToInt32(ReadAppSettings("timer_Connect", true));
            timer_CHECK   = Convert.ToInt32(ReadAppSettings("timer_Check", true));
            timer_READ    = Convert.ToInt32(ReadAppSettings("timer_Read", true));
            timer_KA      = Convert.ToInt32(ReadAppSettings("timer_Ka", true));
        }
Example #17
0
        /// <summary>
        /// Archive a character
        /// </summary>
        /// <param name="entity">the thing to archive</param>
        public void ArchiveCharacter(IPlayerTemplate entity)
        {
            string dirName = BaseDirectory + entity.AccountHandle + "/" + CurrentDirectoryName + entity.Id + "/";

            if (!VerifyDirectory(dirName))
            {
                throw new Exception("Unable to locate or create current player directory.");
            }

            string entityFileName = GetCharacterFilename(entity);

            if (string.IsNullOrWhiteSpace(entityFileName))
            {
                return;
            }

            string fullFileName = dirName + entityFileName;

            if (!File.Exists(fullFileName))
            {
                return;
            }

            string archiveFileDirectory = BaseDirectory + entity.AccountHandle + "/" + ArchiveDirectoryName + entity.Id + "/" + DatedBackupDirectory;

            if (!VerifyDirectory(archiveFileDirectory))
            {
                throw new Exception("Unable to locate or create archive player directory.");
            }

            CullDirectoryCount(BaseDirectory + entity.AccountHandle + "/" + ArchiveDirectoryName + entity.Id + "/");

            try
            {
                string archiveFile = archiveFileDirectory + entityFileName;

                if (File.Exists(archiveFile))
                {
                    File.Delete(archiveFile);
                }

                File.Move(fullFileName, archiveFile);
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }
        }
Example #18
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(IData other)
        {
            if (other != default(IData))
            {
                try
                {
                    return(other.GetType() == this.GetType() && other.ID.Equals(this.ID));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #19
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(ILexica other)
        {
            if (other != default(ILexica))
            {
                try
                {
                    return(other.Phrase.Equals(Phrase) && other.Type == Type);
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #20
0
 /// <summary>
 /// Checks if a site collection is Active
 /// </summary>
 /// <param name="web">Site to be processed - can be root web or sub site</param>
 /// <param name="siteUrl">URL to the site collection</param>
 /// <returns>True if active, false if not</returns>
 public static bool IsSiteActiveTenant(this Web web, string siteUrl)
 {
     try
     {
         return(web.CheckIfSiteExistsInTenant(siteUrl, "Active"));
     }
     catch (Exception ex)
     {
         if (ex.Message.StartsWith("Cannot get site"))
         {
             return(false);
         }
         LoggingUtility.LogError("Error finding if site is active tenant.", ex, EventCategory.Site);
         throw;
     }
 }
Example #21
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(IAccount other)
        {
            if (other != default(IAccount))
            {
                try
                {
                    return(other.GetType() == GetType() && other.GlobalIdentityHandle.Equals(GlobalIdentityHandle));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #22
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(IDictataPhrase other)
        {
            if (other != default(IDictataPhrase))
            {
                try
                {
                    return(other.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) && other.Words.All(wordType => Words.Contains(wordType)));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #23
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(ICacheKey other)
        {
            if (other != default(ICacheKey))
            {
                try
                {
                    return(other.GetType() == GetType() && other.KeyHash().Equals(KeyHash()));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #24
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(ILexeme other)
        {
            if (other != default(ILexeme))
            {
                try
                {
                    return(other.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #25
0
        public ActionResult Index(string selectedLog)
        {
            var dashboardModel = new DashboardViewModel();

            dashboardModel.authedUser = UserManager.FindById(User.Identity.GetUserId());

            dashboardModel.ChannelNames = LoggingUtility.GetCurrentLogNames();

            if (!String.IsNullOrWhiteSpace(selectedLog))
            {
                dashboardModel.SelectedLogContent = LoggingUtility.GetCurrentLogContent(selectedLog);
                dashboardModel.SelectedLog        = selectedLog;
            }

            return(View(dashboardModel));
        }
Example #26
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(ILiveData other)
        {
            if (other != default(ILiveData))
            {
                try
                {
                    return(other.GetType() == GetType() && other.BirthMark.Equals(BirthMark));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
Example #27
0
        public override void OnTestCleanup()
        {
            try
            {
                if (TestContext.CurrentContext.Result.Outcome != ResultState.Success)
                {
                    TestContext.WriteLine(Generic.TestErrorMessage);

                    if (LoggingUtility == null || ConfigurationReader == null)
                    {
                        return;
                    }

                    var outputPath = !string.IsNullOrWhiteSpace(ConfigurationReader.GetConfigurationValue(Constants.Configuration.ConfigKeyOutputFileScreenshotsDirectory)) ? $"{ConfigurationReader.GetConfigurationValue(Constants.Configuration.ConfigKeyOutputFileScreenshotsDirectory)}" : $"{TestContext.CurrentContext.TestDirectory}{Constants.Configuration.ScreenshotsDirectory}";

                    if (((WebTestManager)TestManager).IsDriverNull)
                    {
                        return;
                    }

                    TestContext.WriteLine($"Attempting to capture screenshot to: {outputPath}");

                    var captureScreenShot = Driver.ScreenShotSaveFile(outputPath, TestContext.CurrentContext.Test.Name);

                    if (string.IsNullOrWhiteSpace(captureScreenShot))
                    {
                        return;
                    }

                    TestContext.AddTestAttachment(captureScreenShot);

                    LoggingUtility.Error(captureScreenShot);
                }
                else
                {
                    TestContext.WriteLine(Generic.TestSuccessMessage);
                }
            }
            catch (System.Exception ex)
            {
                HandleException(ex);
            }
            finally
            {
                TestManager.OnTestCleanup();
            }
        }
Example #28
0
        /// <summary>
        /// insert this into the db
        /// </summary>
        /// <returns>the object with ID and other db fields set</returns>
        public override IData Create()
        {
            var parms = new Dictionary <string, object>();

            Material returnValue = default(Material);
            var      sql         = new StringBuilder();

            sql.Append("insert into [dbo].[Material]([Name],[Conductive],[Magnetic],[Flammable]");
            sql.Append(",[Viscosity],[Density],[Mallebility],[Ductility],[Porosity],[SolidPoint],[GasPoint],[TemperatureRetention],[Resistance],[Composition])");
            sql.Append(" values(@Name,@Conductive,@Magnetic,@Flammable,@Viscosity,@Density,@Mallebility,@Ductility,@Porosity,@SolidPoint,@GasPoint,@TemperatureRetention,@Resistance,@Composition)");
            sql.Append(" select * from [dbo].[Material] where ID = Scope_Identity()");

            parms.Add("Name", Name);
            parms.Add("Conductive", Conductive);
            parms.Add("Magnetic", Magnetic);
            parms.Add("Flammable", Flammable);
            parms.Add("Viscosity", Viscosity);
            parms.Add("Density", Density);
            parms.Add("Mallebility", Mallebility);
            parms.Add("Ductility", Ductility);
            parms.Add("Porosity", Porosity);
            parms.Add("SolidPoint", SolidPoint);
            parms.Add("GasPoint", GasPoint);
            parms.Add("TemperatureRetention", TemperatureRetention);
            parms.Add("Resistance", SerializeResistances());
            parms.Add("Composition", SerializeCompositions());

            try
            {
                var ds = SqlWrapper.RunDataset(sql.ToString(), CommandType.Text, parms);

                if (ds.Rows != null)
                {
                    foreach (DataRow dr in ds.Rows)
                    {
                        Fill(dr);
                        returnValue = this;
                    }
                }
            }
            catch (Exception ex)
            {
                LoggingUtility.LogError(ex);
            }

            return(returnValue);
        }
Example #29
0
        public ActionResult Remove(long removeId = -1, string authorizeRemove = "", long unapproveId = -1, string authorizeUnapprove = "")
        {
            AddEditPathwayTemplateViewModel vModel = new AddEditPathwayTemplateViewModel
            {
                AuthedUser = UserManager.FindById(User.Identity.GetUserId())
            };

            if (!string.IsNullOrWhiteSpace(authorizeRemove) && removeId.ToString().Equals(authorizeRemove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(removeId);

                if (obj == null)
                {
                }
                else if (obj.Remove(authedUser.GameAccount, authedUser.GetStaffRank(User)))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - RemovePathway[" + removeId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
                else
                {
                }
            }
            else if (!string.IsNullOrWhiteSpace(authorizeUnapprove) && unapproveId.ToString().Equals(authorizeUnapprove))
            {
                ApplicationUser authedUser = UserManager.FindById(User.Identity.GetUserId());

                IPathwayTemplate obj = TemplateCache.Get <IPathwayTemplate>(unapproveId);

                if (obj == null)
                {
                }
                else if (obj.ChangeApprovalStatus(authedUser.GameAccount, authedUser.GetStaffRank(User), ApprovalState.Returned))
                {
                    LoggingUtility.LogAdminCommandUsage("*WEB* - UnapprovePathway[" + unapproveId.ToString() + "]", authedUser.GameAccount.GlobalIdentityHandle);
                }
                else
                {
                }
            }
            else
            {
            }

            return(View("~/Views/GameAdmin/Pathway/AddEdit.cshtml", vModel));
        }
Example #30
0
        /// <summary>
        /// Activates or deactivates a site collection or site scoped feature
        /// </summary>
        /// <param name="web">Web to be processed - can be root web or sub web</param>
        /// <param name="featureID">ID of the feature to activate/deactivate</param>
        /// <param name="activate">True to activate, false to deactivate the feature</param>
        private static void ProcessFeature(this Web web, Guid featureID, bool activate)
        {
            FeatureCollection clientSiteFeatures = web.Features;

            web.Context.Load(clientSiteFeatures);
            web.Context.ExecuteQuery();

            // The original number of active features...use this to track if the feature activation went OK
            int oldCount = clientSiteFeatures.Count();

            if (activate)
            {
                // GetById does not seem to work for site scoped features...if (clientSiteFeatures.GetById(featureID) == null)

                // FeatureDefinitionScope defines how the features have been deployed. All OOB features are farm deployed
                clientSiteFeatures.Add(featureID, true, FeatureDefinitionScope.Farm);
                web.Context.ExecuteQuery();

                // retry logic needed to make this more bulletproof :-(
                web.Context.Load(clientSiteFeatures);
                web.Context.ExecuteQuery();

                int tries        = 0;
                int currentCount = clientSiteFeatures.Count();
                while (currentCount <= oldCount && tries < 5)
                {
                    tries++;
                    clientSiteFeatures.Add(featureID, true, FeatureDefinitionScope.Farm);
                    web.Context.ExecuteQuery();
                    web.Context.Load(clientSiteFeatures);
                    web.Context.ExecuteQuery();
                    currentCount = clientSiteFeatures.Count();
                }
            }
            else
            {
                try
                {
                    clientSiteFeatures.Remove(featureID, false);
                    web.Context.ExecuteQuery();
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(string.Format(MSG_PROBLEM_REMOVING, featureID), ex, EventCategory.Features);
                }
            }
        }