public List <CPos> FindUnitPath(CPos source, CPos target, Actor self, Actor ignoreActor, BlockedByActor check)
        {
            using (new PerfSample("Pathfinder"))
            {
                var key = "FindUnitPath" + self.ActorID + source.X + source.Y + target.X + target.Y;

                // Only cache path when transient actors are ignored, otherwise there is no guarantee that the path
                // is still valid at the next check.
                if (check == BlockedByActor.None)
                {
                    var cachedPath = cacheStorage.Retrieve(key);
                    if (cachedPath != null)
                    {
                        return(cachedPath);
                    }
                }

                var pb = pathFinder.FindUnitPath(source, target, self, ignoreActor, check);

                if (check == BlockedByActor.None)
                {
                    cacheStorage.Store(key, pb);
                }

                return(pb);
            }
        }
Beispiel #2
0
        public IEnumerable <Affiliate> GetAffiliates(AffiliateRequest request = null)
        {
            const string cacheKey = "UserService.Affiliates";

            request = request ?? new AffiliateRequest();

            return(request.UseCache ? _cacheStorage.Retrieve(cacheKey, () => GetAffiliatesInternal(request)) : GetAffiliatesInternal(request));
        }
Beispiel #3
0
        /// <summary>
        /// Loadds activity by team membership.
        /// </summary>
        private void LoadActivity()
        {
            var results = new List <Activity>();

            if (_cache.Retrieve <List <HRR.Core.Domain.Interfaces.IActivity> >(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_ActivityFeed") == null)
            {
            }
            var list = new ActivityServices().GetByMaxRows(10);

            if (((Person)SecurityContextManager.Current.CurrentUser).RoleID < (int)SecurityRole.EXECUTIVE_MANAGEMENT)
            {
                if (((Person)SecurityContextManager.Current.CurrentUser).Memberships != null && ((Person)SecurityContextManager.Current.CurrentUser).Memberships.Count > 0)
                {
                    foreach (var t in ((Person)SecurityContextManager.Current.CurrentUser).Memberships)
                    {
                        foreach (var m in list)
                        {
                            foreach (var p in m.PerformedForRef.Memberships)
                            {
                                if (p.TeamID == t.TeamID && p.HasAccess)
                                {
                                    results.Add(m);
                                }
                                break;
                            }
                            foreach (var p in m.PerformedByRef.Memberships)
                            {
                                if (p.PersonID == SecurityContextManager.Current.CurrentUser.ID && p.TeamID == t.TeamID && p.HasAccess)
                                {
                                    results.Add(m);
                                }
                                break;
                            }
                        }
                    }
                }
            }
            else
            {
                results = list.ToList <Activity>();
            }
            if (results.Count() < 1)
            {
                divActivity.Visible = true;
            }
            else
            {
                divActivity.Visible = false;
            }
            dlComments.DataSource = results.OrderByDescending(o => o.DateCreated);
            dlComments.DataBind();
        }
Beispiel #4
0
        public IList <IAlert> LoadAlerts(ICacheStorage cache, IHRRSecurityContext security)
        {
            var list = new List <HRR.Core.Domain.Interfaces.IAlert>();

            if (cache.Retrieve <List <HRR.Core.Domain.Interfaces.IAlert> >(security.CurrentAccount.ID.ToString() + "_AlertsFeed") == null)
            {
                list = new AlertServices().GetAlertsByDueDate(DateTime.Now.AddDays(21)).ToList <HRR.Core.Domain.Interfaces.IAlert>();
                cache.Store(security.CurrentAccount.ID.ToString() + "_AlertsFeed", list);
            }
            else
            {
                list = cache.Retrieve <List <HRR.Core.Domain.Interfaces.IAlert> >(security.CurrentAccount.ID.ToString() + "_AlertsFeed");
            }
            return(list);
        }
Beispiel #5
0
        private IEnumerable <ProductTitle> FindAllProductTitles()
        {
            lock (_getAllProductTitlesLock)
            {
                IEnumerable <ProductTitle> allProductTitles = _cacheStorage.Retrieve <IEnumerable <ProductTitle> >(CacheKeys.AllProductTitles.ToString());

                if (allProductTitles == null)
                {
                    allProductTitles = _productTitleRepository.FindAll().ToList();

                    _cacheStorage.Store(CacheKeys.AllProductTitles.ToString(), allProductTitles);
                }

                return(allProductTitles);
            }
        }
Beispiel #6
0
        public void AfterScenario()
        {
            var user = _cacheStorage.Retrieve <PersistenceModel.User>("User");

            _userService.Delete(user.UserID);
            _unitOfWork.Save();
        }
        public IEnumerable <Affiliate> GetAffiliates(AffiliateRequest request)
        {
            request = request ?? new AffiliateRequest();

            var cacheKey = string.Format("{0}.{1}", CacheKeyBase, request.ToString());

            return(request.UseCache ? _cacheStorage.Retrieve(cacheKey, () => GetAffiliatesInternal(request)) : GetAffiliatesInternal(request));
        }
Beispiel #8
0
        private IEnumerable <ProductDetailDto> FindAllProductTitles()
        {
            lock (_getAllProductTitlesLock)
            {
                IEnumerable <ProductDetailDto> allProductTitles;

                allProductTitles =
                    _cachStorage.Retrieve <IEnumerable <ProductDetailDto> >(CacheKeys.AllProductTitles.ToString());

                if (allProductTitles == null)
                {
                    allProductTitles = _presentationRepository.FindByType <ProductDetailDto>();
                    _cachStorage.Store(CacheKeys.AllProductTitles.ToString(), allProductTitles);
                }

                return(allProductTitles);
            }
        }
Beispiel #9
0
        public bool IsContentUrl(string permalink)
        {
            var url = permalink;

            if (!url.StartsWith("/"))
            {
                url = "/" + url;
            }

            var items = _cacheStorage.Retrieve("Cms.SiteContent", () =>
            {
                var contents = _cmsRepository.GetAll <SiteContent>().Where(s => s.SiteContentStatusID == (int)ContentStatus.Published).ToList();

                return(contents.Where(s => s.IsPublished() && (s.IsContentPage() || s.IsFile())).ToList());
            });

            return(items.Any(s => s.Permalink == url));
        }
Beispiel #10
0
        private void LoadTemplates()
        {
            PagedDataSource pd = new PagedDataSource();

            //string result = "";
            //using (var client = new WebClient())
            //{
            //    client.Headers[HttpRequestHeader.ContentType] = "application/json";
            //    client.Headers[HttpRequestHeader.Accept] = "application/json";
            //    result = client.DownloadString(ConfigurationManager.AppSettings["BASEURL"] + "/api/Evaluation/GetEvaluationTemplates?accountID=" + SecurityContextManager.Current.CurrentUser.AccountID.ToString());

            //}

            var list = new List <PerformanceEvaluationTemplate>();

            if (_cache.Retrieve <List <PerformanceEvaluationTemplate> >(SecurityContextManager.Current.CurrentUser.AccountID.ToString() + "_EvaluationTemplateList") == null)
            {
                list = new PerformanceEvaluationServices().GetTemplates(SecurityContextManager.Current.CurrentUser.AccountID).OrderBy(o => o.DateCreated).ToList <PerformanceEvaluationTemplate>();
                _cache.Store(SecurityContextManager
                             .Current
                             .CurrentUser.AccountID.ToString() + "_EvaluationTemplateList", list);
            }
            else
            {
                list = _cache.Retrieve <List <PerformanceEvaluationTemplate> >(SecurityContextManager
                                                                               .Current
                                                                               .CurrentUser.AccountID.ToString() + "_EvaluationTemplateList");
            }

            pd.DataSource       = list;
            pd.AllowPaging      = true;
            pd.PageSize         = 20;
            pd.CurrentPageIndex = CurrentPage;
            lblCurrentPage.Text = "Page: "
                                  + (CurrentPage + 1).ToString()
                                  + " of "
                                  + pd.PageCount.ToString();
            cmdPrev.Enabled = !pd.IsFirstPage;
            cmdNext.Enabled = !pd.IsLastPage;

            dlEvaluationTemplates.DataSource = list;
            dlEvaluationTemplates.DataBind();
        }
        public List <CPos> FindUnitPath(CPos source, CPos target, Actor self, Actor ignoreActor)
        {
            using (new PerfSample("Pathfinder"))
            {
                var key        = "FindUnitPath" + self.ActorID + source.X + source.Y + target.X + target.Y;
                var cachedPath = cacheStorage.Retrieve(key);

                if (cachedPath != null)
                {
                    return(cachedPath);
                }

                var pb = pathFinder.FindUnitPath(source, target, self, ignoreActor);

                cacheStorage.Store(key, pb);

                return(pb);
            }
        }
Beispiel #12
0
        public TContext Create()
        {
            if (!_cacheStorage.ContainsKey(_dataContextKey))
            {
                var context = CreateContext();
                _cacheStorage.Store(_dataContextKey, context);
            }

            return(_cacheStorage.Retrieve <TContext>(_dataContextKey));
        }
Beispiel #13
0
        private void LoadPeople()
        {
            var list = new List <Department>();

            if (_cache.Retrieve <List <Department> >(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_DepartmentsList") == null)
            {
                list = new DepartmentServices().GetAll().ToList <Department>();
                _cache.Store(SecurityContextManager
                             .Current
                             .CurrentUser.ID.ToString() + "_DepartmentsList", list);
            }
            else
            {
                list = _cache.Retrieve <List <Department> >(SecurityContextManager
                                                            .Current
                                                            .CurrentUser.ID.ToString() + "_DepartmentsList");
            }
            dlPeople.DataSource = list;
            dlPeople.DataBind();
        }
Beispiel #14
0
        public Model.Survey GetSurvey(SurveyRequest request)
        {
            if (!request.CacheForUser || request.UserID <= 0 || string.IsNullOrEmpty(request.SurveyName) || !request.IncludeResponse)
            {
                return(GetSurveyInternal(request));
            }

            var cacheKey = string.Format("Survey.{0}.{1}", request.SurveyName, request.UserID);

            return(_cacheStorage.Retrieve(cacheKey, () => GetSurveyInternal(request)));
        }
        public IList <Product> GetAllProductsIn(int categoryId)
        {
            string          storageKey = string.Format("products_in_category_id_{0}", categoryId);
            IList <Product> products   = _cacheStorage.Retrieve <List <Product> >(storageKey); //(List<Product>) HttpContext.Current.Cache.Get(storageKey);

            if (products == null)
            {
                products = _productRepository.GetAllProductsIn(categoryId);
                _cacheStorage.Store(storageKey, products);
            }
            return(products);
        }
        public IList <Customer> GetAllCustomers()
        {
            IList <Customer> customers;
            string           storageKey = "GetAllCustomers";

            customers = _cacheStorage.Retrieve <List <Customer> >(storageKey);
            if (customers == null)
            {
                customers = _customerRepository.GetCustomers();
                _cacheStorage.Store(storageKey, customers);
            }
            return(customers);
        }
Beispiel #17
0
        public IList <Product> GetAllProductsIn(int categoryId)
        {
            IList <Product> products;
            string          storageKey = string.Format("products_in_category_id_{0}", categoryId);

            products = _cacheStorage.Retrieve <List <Product> >(storageKey);
            if (products == null)
            {
                products = _productRepository.GetAllProductsIn(categoryId);
                _cacheStorage.Store(storageKey, products);
            }
            return(products);
        }
Beispiel #18
0
        public static void PerformWork(ICacheStorage cacheStorage)
        {
            string key = "key";
            object o   = cacheStorage.Retrieve <object>(key);

            if (o == null)
            {
                //simulate database lookup
                o = new object();
                cacheStorage.Store(key, o);
            }
            //perform some work on object o...
        }
Beispiel #19
0
        public GetCustomersResponse GetAllCustomers()
        {
            string key = "GetAllCustomers";
            GetCustomersResponse response = _cacheStorage.Retrieve <GetCustomersResponse>(key);

            if (response == null)
            {
                int cacheDurationSeconds = _configurationRepository.GetConfigurationValue <int>("ShortCacheDuration");
                response = _innerCustomerService.GetAllCustomers();
                _cacheStorage.Store(key, response, TimeSpan.FromSeconds(cacheDurationSeconds));
            }
            return(response);
        }
Beispiel #20
0
        public IList <Cliente> GetAllClientes()
        {
            IList <Cliente> clientes;
            string          storageKey = "GetAllClientes";

            clientes = _cacheStorage.Retrieve <List <Cliente> >(storageKey);
            if (clientes == null)
            {
                clientes = _clienteRepository.GetClientes();
                _cacheStorage.Store(storageKey, clientes);
            }

            return(clientes);
        }
Beispiel #21
0
        public ActionResult GetUserById(int id)
        {
            User   user       = null;
            string storageKey = string.Format("user_id_{0}", id);

            user = _cache.Retrieve <User>(storageKey);

            if (user == null)
            {
                user = _userRepo.GetUserById(id);
                _cache.Store(storageKey, user);
            }

            return(View(user));;
        }
        public static List<Applications> GetApplicationsBySiteId(int siteId, ICacheStorage adapter)
        {
            String storageKey = String.Format("Applications_{0}", siteId);
               List<Applications> applicationsList = adapter.Retrieve<List<Applications>>(storageKey);

               if (applicationsList == null)
               {
               var ds = DalApplications.GetApplicationListBySiteId(siteId);
               applicationsList = BindModel.GetApplications(ds.Tables[0]);
               if (applicationsList != null && applicationsList.Count != 0)
                   adapter.Store(storageKey, applicationsList);
               return applicationsList;
               }
               return applicationsList;
        }
Beispiel #23
0
        private void LoadPeople(bool status)
        {
            PagedDataSource pd = new PagedDataSource();

            var list = new List <Person>();

            if (_cache.Retrieve <List <Person> >(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_DepartmentsList") == null)
            {
                list = new PersonServices().GetByAccountID(SecurityContextManager.Current.CurrentAccount.ID).OrderBy(o => o.LastName).ToList <Person>();
                _cache.Store(SecurityContextManager
                             .Current
                             .CurrentUser.AccountID.ToString() + "_DepartmentsList", list);
            }
            else
            {
                list = _cache.Retrieve <List <Person> >(SecurityContextManager
                                                        .Current
                                                        .CurrentUser.AccountID.ToString() + "_DepartmentsList");
            }

            list = list.Where(o => o.IsActive == status).ToList <Person>();

            pd.DataSource       = list;
            pd.AllowPaging      = true;
            pd.PageSize         = 20;
            pd.CurrentPageIndex = CurrentPage;
            lblCurrentPage.Text = "Page: "
                                  + (CurrentPage + 1).ToString()
                                  + " of "
                                  + pd.PageCount.ToString();
            cmdPrev.Enabled = !pd.IsFirstPage;
            cmdNext.Enabled = !pd.IsLastPage;

            dlPeople.DataSource = pd;
            dlPeople.DataBind();
        }
Beispiel #24
0
        //缓存处理
        public IList <Product> GetAllProducts(int categoryId)
        {
            IList <Product> products;
            string          storageKey = "ProductsByCategoryId " + categoryId;

            products = _cacheStorage.Retrieve <List <Product> >(storageKey);
            if (products == null)
            {
                products = _productRepository.GetAllProducts(categoryId);
                _cacheStorage.Store(storageKey, products);
            }


            return(products);
        }
        public static List<Photos> GetPhotoListByGalleryId(int galleryId, ICacheStorage adapter)
        {
            String storageKey = String.Format("Gallery_Photo_{0}", galleryId);
            List<Photos> photosList = adapter.Retrieve<List<Photos>>(storageKey);

            if (photosList == null)
            {
                var ds = DalPhotoGallery.GetPhotoListByGalleryId(galleryId);
                photosList = BindModel.GetPhotosForGallery(ds.Tables[0]);
                if (photosList != null && photosList.Count != 0)
                    adapter.Store(storageKey, photosList);
                return photosList;
            }
            return photosList;
        }
Beispiel #26
0
        public static List<Permissions> GetPermissionsByUser(String empNo, ICacheStorage adapter)
        {
            String storageKey = String.Format("Permission_{0}", empNo);
            List<Permissions> pList = adapter.Retrieve<List<Permissions>>(storageKey);

            if (pList == null)
            {
                var ds = DalAdmin.GetPermissionByUser(empNo);
                pList = BindModel.GetPermissions(ds.Tables[0]);
                if (pList != null && pList.Count != 0)
                    adapter.Store(storageKey, pList);
                return pList;
            }
            return pList;
        }
Beispiel #27
0
        public IList <Product> GetAllProductsIn(int categoryId)
        {
            IList <Product> products;
            string          storageKey = $"products_in_category_id_{categoryId}";

            //products = (List<Product>)HttpContext.Current.Cache.Get(storageKey);
            products = _cacheStorage.Retrieve <List <Product> >(storageKey);

            if (products == null)
            {
                products = _productRepository.GetAllProductsIn(categoryId);
                //HttpContext.Current.Cache.Insert(storageKey, products);
                _cacheStorage.Store(storageKey, products);
            }
            return(products);
        }
        public static List<Gallery> GetGalleryListBySiteId(int siteId, ICacheStorage adapter)
        {
            String storageKey = String.Format("Gallery_{0}", siteId);
            List<Gallery> galleryList = adapter.Retrieve<List<Gallery>>(storageKey);

            if (galleryList == null)
            {
                var ds = DalPhotoGallery.GetGalleryListBySiteId(siteId);

                galleryList = BindModel.GetGalleryWithoutPhoto(ds.Tables[0]);
                if (galleryList != null && galleryList.Count != 0)
                    adapter.Store(storageKey, galleryList);
                return galleryList;
            }
            return galleryList;
        }
Beispiel #29
0
        public static List<Menu> GetMenu(int siteId, ICacheStorage adapter)
        {
            String storageKey = String.Format("Menu_Site_{0}", siteId);
            List<Menu> menuToDisplay = adapter.Retrieve<List<Menu>>(storageKey);

            if (menuToDisplay == null)
            {
                List<Menu> menuList = BindModel.GetMenu(DalMenu.GetActiveMenuByUser(siteId));
                if(menuList!=null)
                {
                    adapter.Store(storageKey, menuList);
                }
                return menuList;
            }
            return menuToDisplay;
        }
Beispiel #30
0
        public static List<Marquee> GetMarquee(int siteId, ICacheStorage adapter)
        {
            String storageKey = String.Format("Marquee_Site_{0}", siteId);
            List<Marquee> marqueeToDisplay = adapter.Retrieve<List<Marquee>>(storageKey);

            if (marqueeToDisplay == null)
            {
                List<Marquee> marqueeList = BindModel.GetMarquee(DalMenu.GetActiveMarqueeBySite(siteId));
                if (marqueeList != null)
                {
                    adapter.Store(storageKey, marqueeList);
                }
                return marqueeList;
            }
            return marqueeToDisplay;
        }
Beispiel #31
0
        public IQueryable <T> GetItems(ICacheStorage cacheStorage)
        {
            ClearExpiredPointers();

            var items = new List <T>();

            foreach (var pointer in pointers)
            {
                var t = cacheStorage.Retrieve <T>(pointer.Key);
                if (t != null)
                {
                    items.Add(t);
                }
            }

            return(items.AsQueryable());
        }
Beispiel #32
0
        public static List<Sites> GetActiveSites(ICacheStorage adapter)
        {
            String storageKey = String.Format("All_Sites");
            List<Sites> sites = adapter.Retrieve<List<Sites>>(storageKey);

            if (sites == null)
            {
                 sites= BindModel.GetAllSites(DalMenu.GetActiveSites());
                if (sites != null)
                {
                    adapter.Store(storageKey, sites);
                }
                //else
                //{
                //    adapter.Store(storageKey, String.Empty);
                //}
                return sites;
            }
            return sites;
        }
Beispiel #33
0
        public void ExecuteRuleSet(RulesetRequest request)
        {
            //if (request == null || string.IsNullOrEmpty(request.Name) || request.Entity == null) return;

            var cacheKey = string.Format("Rules_{0}", request.Name);

            var ruleSet = _cacheStorage.Retrieve(cacheKey, () =>
            {
                var extRuleService = new ExternalRuleSetService();

                return(extRuleService.GetRuleSet(new RuleSetInfo {
                    Name = request.Name
                }));
            });

            if (ruleSet == null)
            {
                throw new ApplicationException("Could not retrieve rule set for rule name: " + request.Name);
            }

            var entity         = request.GetEntity();
            var ruleValidation = new RuleValidation(entity.GetType(), null);

            if (ruleSet.Validate(ruleValidation))
            {
                var ruleExecution = new RuleExecution(ruleValidation, entity);

                ruleSet.Execute(ruleExecution);
            }
            else
            {
                var sb = new StringBuilder();

                foreach (var error in ruleValidation.Errors)
                {
                    sb.AppendLine(string.Format("{0}:{1}", error.ErrorNumber, error.ErrorText));
                }

                throw new ApplicationException(sb.ToString());
            }
        }
Beispiel #34
0
        public UserContext(IHttpContextAccessor HttpContextAccessor, IUserService UserService, ICacheStorage CacheStorage)
        {
            HttpContext HttpContext = HttpContextAccessor.HttpContext;

            this.HttpContext = HttpContext;

            string UserId = HttpContext.User.Identity.GetUserId();

            if (!String.IsNullOrEmpty(UserId))
            {
                string CacheKey = CacheKeys.ArtifexUser.UserEntity + UserId;
                this.CurrentUser = CacheStorage.Retrieve <ArtifexUser>(CacheKey);
                if (this.CurrentUser == null)
                {
                    this.CurrentUser = UserService.GetUserById(Convert.ToInt32(UserId));
                    CacheStorage.Store(CacheKey, this.CurrentUser);
                }
                if (this.CurrentUser == null)
                {
                    throw new UnauthorizedAccessException();
                }
            }
        }
Beispiel #35
0
 public T Retrieve <T>(string storageKey)
 {
     return(_cache.Retrieve <T>(storageKey));
 }
Beispiel #36
0
 public IEnumerable <Configuration> GetConfigurations(ConfigurationRequest request)
 {
     return(request.UseCache ? _cacheStorage.Retrieve("AppService.Configurations", () => GetConfigurationsInternal(request))
                             : GetConfigurationsInternal(request));
 }
Beispiel #37
0
        public void LoadComments()
        {
            if (SecurityContextManager.Current.CurrentTeamID != null)
            {
                // _cache.Remove(SecurityContextManager.Current.CurrentAccount.ID.ToString() + "_CommentsFeed");
                var list = new List <Comment>();
                if (_cache.Retrieve <List <Comment> >(SecurityContextManager.Current.CurrentUser.ID.ToString() + "_CommentsFeed") == null)
                {
                    list = new CommentServices().GetByTeamID((int)SecurityContextManager.Current.CurrentTeamID).ToList <Comment>();
                    _cache.Store(SecurityContextManager
                                 .Current
                                 .CurrentUser.ID.ToString() + "_CommentsFeed", list);
                }
                else
                {
                    list = _cache.Retrieve <List <Comment> >(SecurityContextManager
                                                             .Current
                                                             .CurrentUser.ID.ToString() + "_CommentsFeed");
                }
                var team = new TeamServices().GetByID((int)SecurityContextManager.Current.CurrentTeamID);

                //var page = (HRR.Website.Comments)this.Parent.Page;
                switch (ddlSort.SelectedValue)
                {
                case "0":
                    list = list.OrderByDescending(o => o.DateCreated).ToList <Comment>();
                    break;

                case "1":
                    list = list.OrderBy(o => o.EnteredByRef.LastName).ToList <Comment>();
                    break;

                case "2":
                    list = list.OrderBy(o => o.EnteredForRef.LastName).ToList <Comment>();
                    break;

                case "3":
                    list = list.OrderBy(o => o.Category.Name).ToList <Comment>();
                    break;

                case "4":
                    list = list.OrderBy(o => o.CommentType).ToList <Comment>();
                    break;

                default:
                    list = list.OrderByDescending(o => o.DateCreated).ToList <Comment>();
                    break;
                }
                bool ismanager = false;

                if (SecurityContextManager.Current.CurrentURL.Contains("All"))
                {
                    foreach (var m in team.Members)
                    {
                        if (m.PersonID == SecurityContextManager.Current.CurrentUser.ID)
                        {
                            if (m.IsManager)
                            {
                                ismanager = true;
                            }
                        }
                    }
                    var results = new List <Comment>();
                    var temp    = new List <Comment>();
                    var temp2   = new List <Comment>();
                    if (!ismanager)
                    {
                        temp = list;
                        temp.RemoveAll(o => (o.CommentType == -1 &&
                                             o.EnteredBy != SecurityContextManager.Current.CurrentUser.ID) && (o.CommentType == -1 &&
                                                                                                               o.EnteredFor != SecurityContextManager.Current.CurrentUser.ID));
                        results.AddRange(temp);

                        temp2 = list;
                        temp2.RemoveAll(o => (o.CommentType == -1 &&
                                              o.EnteredFor != SecurityContextManager.Current.CurrentUser.ID));
                        results.AddRange(temp2);
                    }
                    else
                    {
                        results = list;
                    }
                    dlComments.DataSource = results.Distinct();
                    dlComments.DataBind();

                    #region Oldstuff
                    //var team = new List<TeamMember>();
                    //foreach (var t in ((Person)SecurityContextManager.Current.CurrentUser).Memberships)
                    //{
                    //    foreach (var m in t.TeamRef.Members)
                    //    {
                    //        if (SecurityContextManager.Current.CurrentUser.ID == m.PersonID)
                    //        {
                    //            if (m.IsManager)
                    //                ismanager = true;
                    //        }

                    //        team.Add(m);
                    //    }
                    //}
                    //((Person)SecurityContextManager.Current.CurrentUser).DepartmentRef.People;
                    //var comments = new List<Comment>();
                    //foreach (var member in team.Distinct())
                    //{
                    //if (member.PersonID == SecurityContextManager.Current.CurrentUser.ID && member.IsManager)
                    //{
                    //    var mine = from l in list
                    //               where l.EnteredBy == member.PersonRef.ID ||
                    //               l.EnteredFor == member.PersonRef.ID
                    //               orderby l.DateCreated descending
                    //               select l;
                    //    comments.AddRange(mine);
                    //}
                    //else
                    //{
                    //    var mine = from l in list
                    //               where
                    //               (l.CommentType == -1 && (l.EnteredBy == SecurityContextManager.Current.CurrentUser.ID || l.EnteredFor == SecurityContextManager.Current.CurrentUser.ID))
                    //               orderby l.DateCreated descending
                    //               select l;
                    //    comments.AddRange(mine);

                    //    mine = from i in list
                    //           where
                    //           (i.EnteredBy == member.PersonRef.ID ||
                    //               i.EnteredFor == member.PersonRef.ID) &&
                    //               i.CommentType != -1
                    //           orderby i.DateCreated descending
                    //           select i;
                    //    comments.AddRange(mine);
                    //}
                    //    var mine = from l in list
                    //               where l.EnteredBy == member.PersonRef.ID ||
                    //               l.EnteredFor == member.PersonRef.ID
                    //               orderby l.DateCreated descending
                    //               select l;
                    //    comments.AddRange(mine);
                    //}
                    //var results = new List<Comment>();
                    //var temp = new List<Comment>();
                    //var temp2 = new List<Comment>();
                    //if (!ismanager)
                    //{

                    //    temp = comments;
                    //    temp.RemoveAll(o => (o.CommentType == -1 &&
                    //        o.EnteredBy != SecurityContextManager.Current.CurrentUser.ID));
                    //    temp2 = comments;
                    //    temp2.RemoveAll(o => (o.CommentType == -1 &&
                    //        o.EnteredFor != SecurityContextManager.Current.CurrentUser.ID));
                    //}
                    //results.AddRange(temp);
                    //results.AddRange(temp2);
                    //dlComments.DataSource = results.Distinct().OrderByDescending(o => o.DateCreated);
                    //dlComments.DataBind();
                    #endregion
                }
                else if (SecurityContextManager.Current.CurrentURL.Contains("Flagged"))
                {
                    if (((Person)SecurityContextManager.Current.CurrentUser).RoleID < (int)SecurityRole.ADMIN)
                    {
                        Response.Redirect("/Comments/Mine");
                    }
                    dlComments.DataSource = new CommentServices().GetFlaggedByTeamID((int)SecurityContextManager.Current.CurrentTeamID);
                    dlComments.DataBind();
                }
                else if (SecurityContextManager.Current.CurrentURL.Contains("Mine"))
                {
                    var mine = from l in list
                               where l.EnteredBy == SecurityContextManager.Current.CurrentUser.ID ||
                               l.EnteredFor == SecurityContextManager.Current.CurrentUser.ID
                               select l;
                    dlComments.DataSource = mine;
                    dlComments.DataBind();
                }
                else if (SecurityContextManager.Current.CurrentURL.Contains("Profile"))
                {
                    switch (((Person)SecurityContextManager.Current.CurrentUser).RoleID)
                    {
                    case (int)SecurityRole.ADMIN:
                    case (int)SecurityRole.EXECUTIVE_MANAGEMENT:
                        var mine = from l in list
                                   where l.EnteredBy == SecurityContextManager.Current.CurrentProfile.ID ||
                                   l.EnteredFor == SecurityContextManager.Current.CurrentProfile.ID
                                   select l;
                        dlComments.DataSource = mine;
                        dlComments.DataBind();
                        break;

                    case (int)SecurityRole.MANAGER:
                        var t        = ((Person)SecurityContextManager.Current.CurrentUser).DepartmentRef.People;
                        var comments = new List <Comment>();
                        foreach (var member in t)
                        {
                            mine = from l in list
                                   where l.EnteredBy == member.ID ||
                                   l.EnteredFor == member.ID
                                   select l;
                            comments.AddRange(mine);
                        }
                        dlComments.DataSource = comments.Distinct();
                        dlComments.DataBind();
                        break;

                    default:
                        mine = from l in list
                               where l.EnteredBy == SecurityContextManager.Current.CurrentUser.ID ||
                               l.EnteredFor == SecurityContextManager.Current.CurrentUser.ID
                               select l;
                        dlComments.DataSource = mine;
                        dlComments.DataBind();
                        break;
                    }
                }
                else
                {
                    dlComments.DataSource = list;
                    dlComments.DataBind();
                }
            }
            else
            {
                dlComments.DataSource = null;
                dlComments.DataBind();
            }
        }