/// <summary>
        /// This Function Will return all the AccountCODE
        /// </summary>
        /// <returns></returns>
        public List <L_AccountCode> GetAccountCodes()
        {
            try
            {
                var accountCodeKey  = CacheKey.CDS_ACCOUNTCODE;
                var accountCodeList = new List <L_AccountCode>();

                if (StaticCache.Exist(accountCodeKey))
                {
                    accountCodeList = (List <L_AccountCode>)StaticCache.Get(accountCodeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lAccountRepo =
                            new L_AccountCodeRepository(new EFRepository <L_AccountCode>(), unitOfWork);

                        //Returning List Of Demo Lead
                        accountCodeList = lAccountRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(accountCodeKey, accountCodeList);
                    }
                }

                return(accountCodeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Example #2
0
        /// <summary>
        /// This Function will Return All Trustee Type
        /// </summary>
        /// <returns></returns>
        public List <L_TrusteeTypeValue> GetTrusteeType()
        {
            try
            {
                var trusteeTypeKey  = CacheKey.CDS_TRUSTEETYPEVALUES;
                var trusteeTypeList = new List <L_TrusteeTypeValue>();

                if (StaticCache.Exist(trusteeTypeKey))
                {
                    trusteeTypeList = (List <L_TrusteeTypeValue>)StaticCache.Get(trusteeTypeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lTrusteeTypeRepo =
                            new L_TrusteeTypeValueRepository(new EFRepository <L_TrusteeTypeValue>(), unitOfWork);

                        //Returning List Of Demo Lead
                        trusteeTypeList = lTrusteeTypeRepo.All().ToList();

                        StaticCache.Max(trusteeTypeKey, trusteeTypeList);
                    }
                }

                return(trusteeTypeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the net worth euros values
        /// </summary>
        /// <returns></returns>
        public List <L_NetWorthEuros> GetNetWorthEurosValues()
        {
            try
            {
                var netWorthKey  = CacheKey.CDS_NETWORTHEUROS;
                var netWorthList = new List <L_NetWorthEuros>();

                if (StaticCache.Exist(netWorthKey))
                {
                    netWorthList = (List <L_NetWorthEuros>)StaticCache.Get(netWorthKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lNetWorthEurosRepo =
                            new L_NetWorthEurosRepository(new EFRepository <L_NetWorthEuros>(), unitOfWork);

                        //Returning list of net worth euros look up values
                        netWorthList = lNetWorthEurosRepo.All().ToList();

                        StaticCache.Max(netWorthKey, netWorthList);
                    }
                }

                return(netWorthList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the TicketSize
        /// </summary>
        /// <returns></returns>
        public List <L_TicketSize> GetTickets()
        {
            try
            {
                var ticketSizeKey  = CacheKey.CDS_TICKETSIZES;
                var ticketSizeList = new List <L_TicketSize>();

                if (StaticCache.Exist(ticketSizeKey))
                {
                    ticketSizeList = (List <L_TicketSize>)StaticCache.Get(ticketSizeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lTicketSizeRepo =
                            new L_TicketSizeRepository(new EFRepository <L_TicketSize>(), unitOfWork);

                        //Returning List Of Demo Lead
                        ticketSizeList = lTicketSizeRepo.All().ToList();

                        StaticCache.Max(ticketSizeKey, ticketSizeList);
                    }
                }

                return(ticketSizeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Example #5
0
        public static string Get(string lanKey)
        {
            var lanCache = new StaticCache();
            LanguageEntity lan = lanCache.Get(lanKey, m =>
            {
                m.When(LanguageService.SignalLanguageUpdate);

                if (LanService == null)
                    return new LanguageEntity { LanKey = lanKey, LanValue = lanKey };
                var language = LanService.Get(lanKey, GetCurrentLanID());
                if (language == null)
                {
                    string lanValue = lanKey;
                    string lanType = "UnKnown";
                    string module = "Unknown";
                    if (lanKey.Contains("@"))
                    {
                        lanValue = lanKey.Split('@')[1];
                        lanType = "EntityProperty";
                        module = lanKey.Split('@')[0];
                    }
                    language = new LanguageEntity
                    {
                        LanID = GetCurrentLanID(),
                        LanValue = lanValue,
                        LanKey = lanKey,
                        LanType = lanType,
                        Module = module
                    };
                    LanService.Add(language);
                }
                return language;
            });
            return lan.LanValue;
        }
        /// <summary>
        /// This Function Will return all the liquid assets values
        /// </summary>
        /// <returns></returns>
        public List <L_LiquidAssetsValue> GetLiquidAssetsValues()
        {
            try
            {
                var liquidAssetKey  = CacheKey.CDS_LIQUIDASSETS;
                var liquidAssetList = new List <L_LiquidAssetsValue>();

                if (StaticCache.Exist(liquidAssetKey))
                {
                    liquidAssetList = (List <L_LiquidAssetsValue>)StaticCache.Get(liquidAssetKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lLiquidAssetsRepo =
                            new L_LiquidAssetsValueRepository(new EFRepository <L_LiquidAssetsValue>(), unitOfWork);

                        //Returning list of liquid assets values
                        liquidAssetList = lLiquidAssetsRepo.All().ToList();

                        StaticCache.Max(liquidAssetKey, liquidAssetList);
                    }
                }

                return(liquidAssetList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the net worth euros values
        /// </summary>
        /// <returns></returns>
        public List <L_TradingExperience> GetTradingExpValues()
        {
            try
            {
                var tradingExpKey  = CacheKey.CDS_TRADINGEXPS;
                var tradingExpList = new List <L_TradingExperience>();

                if (StaticCache.Exist(tradingExpKey))
                {
                    tradingExpList = (List <L_TradingExperience>)StaticCache.Get(tradingExpKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lTradingExpRepo =
                            new L_TradingExperienceRepository(new EFRepository <L_TradingExperience>(), unitOfWork);

                        //Returning list of trading exp look up values
                        tradingExpList = lTradingExpRepo.All().ToList();

                        StaticCache.Max(tradingExpKey, tradingExpList);
                    }
                }

                return(tradingExpList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the estimated annual income values
        /// </summary>
        /// <returns></returns>
        public List <L_AnnualIncomeValue> GetEstimatedAnnualIncomeValues()
        {
            try
            {
                var annualIncomeKey  = CacheKey.CDS_ANNUALINCOME;
                var annualIncomeList = new List <L_AnnualIncomeValue>();

                if (StaticCache.Exist(annualIncomeKey))
                {
                    annualIncomeList = (List <L_AnnualIncomeValue>)StaticCache.Get(annualIncomeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lAnnualIncomeRepo =
                            new L_AnnualIncomeValueRepository(new EFRepository <L_AnnualIncomeValue>(), unitOfWork);

                        //Returning list of annual income values
                        annualIncomeList = lAnnualIncomeRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(annualIncomeKey, annualIncomeList);
                    }
                }

                return(annualIncomeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all initialInvestment
        /// </summary>
        /// <returns></returns>
        public List <L_InitialInvestment> GetInitialInvestment()
        {
            try
            {
                var initialInvestmentKey  = CacheKey.CDS_INITIALINVESTMENTS;
                var initialInvestmentList = new List <L_InitialInvestment>();

                if (StaticCache.Exist(initialInvestmentKey))
                {
                    initialInvestmentList = (List <L_InitialInvestment>)StaticCache.Get(initialInvestmentKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var initialInvestmentRepo =
                            new L_InitialInvestmentRepository(new EFRepository <L_InitialInvestment>(), unitOfWork);

                        initialInvestmentList = initialInvestmentRepo.All().ToList();

                        StaticCache.Max(initialInvestmentKey, initialInvestmentList);
                    }
                }

                return(initialInvestmentList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
Example #10
0
        /// <summary>
        /// This Function Will return all the ID Info types
        /// </summary>
        /// <returns></returns>
        public List <L_IDInformationType> GetIdInfoType()
        {
            try
            {
                var idInformationKey  = CacheKey.CDS_ID_INFORMATION;
                var idInformationList = new List <L_IDInformationType>();

                if (StaticCache.Exist(idInformationKey))
                {
                    idInformationList = (List <L_IDInformationType>)StaticCache.Get(idInformationKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lIdInfoTypeRepo =
                            new L_IDInformationTypeRepository(new EFRepository <L_IDInformationType>(), unitOfWork);

                        //Returning list of ID info type values
                        idInformationList = lIdInfoTypeRepo.All().ToList();

                        StaticCache.Max(idInformationKey, idInformationList);
                    }
                }
                return(idInformationList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function Will return all the receiving banks
        /// </summary>
        /// <returns></returns>
        public List <L_RecievingBank> GetReceivingBankInfo()
        {
            try
            {
                var idInformationKey  = CacheKey.CDS_RECEVING_BANK_INFORMATION;
                var receivingBankList = new List <L_RecievingBank>();

                if (StaticCache.Exist(idInformationKey))
                {
                    receivingBankList = (List <L_RecievingBank>)StaticCache.Get(idInformationKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lReceivingBankRepo =
                            new L_RecievingBankRepository(new EFRepository <L_RecievingBank>(), unitOfWork);

                        //Returning list of receiving bank values
                        receivingBankList = lReceivingBankRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(idInformationKey, receivingBankList);
                    }
                }
                return(receivingBankList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        /// <summary>
        /// This Function will Return All Trustee Type
        /// </summary>
        /// <returns></returns>
        public List <L_CompanyTypeValue> GetCompanyType()
        {
            try
            {
                var companyTypeKey  = CacheKey.CDS_COMPANYTYPE;
                var companyTypeList = new List <L_CompanyTypeValue>();

                if (StaticCache.Exist(companyTypeKey))
                {
                    companyTypeList = (List <L_CompanyTypeValue>)StaticCache.Get(companyTypeKey);
                }
                else
                {
                    using (var unitOfWork = new EFUnitOfWork())
                    {
                        var lCompanyTypeRepo =
                            new L_CompanyTypeValueRepository(new EFRepository <L_CompanyTypeValue>(), unitOfWork);

                        //Returning List Of Demo Lead
                        companyTypeList = lCompanyTypeRepo.All().ToList();

                        //Store it into the cache
                        StaticCache.Max(companyTypeKey, companyTypeList);
                    }
                }

                return(companyTypeList);
            }
            catch (Exception ex)
            {
                CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name);
                throw;
            }
        }
        public static DataConfigureAttribute GetAttribute(Type type)
        {
            StaticCache cache     = new StaticCache();
            string      typeName  = type.FullName;
            var         attribute = cache.Get("DataConfigureAttribute_" + typeName, m => GetCustomAttribute(type, typeof(DataConfigureAttribute)) as DataConfigureAttribute);

            return(attribute);
        }
 public virtual SystemSettingBase Get()
 {
     return(cache.Get("CacheKey_SystemSettingAll", m =>
     {
         m.When(SignalSystemSettingUpdate);
         return rep.Get();
     }));
 }
Example #15
0
        public static ViewConfigureAttribute GetAttribute <T>()
        {
            Type        targetType = typeof(T);
            StaticCache cache      = new StaticCache();
            string      typeName   = targetType.FullName;
            var         attribute  = cache.Get("DataConfigureAttribute_" + typeName, m => targetType.GetTypeInfo().GetCustomAttribute(typeof(ViewConfigureAttribute)) as ViewConfigureAttribute);

            return(attribute);
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            Zones = new ZoneWidgetCollection();
            //Page
            var page = GetPage(filterContext);

            if (page != null)
            {
                var          cache         = new StaticCache();
                var          layoutService = ServiceLocator.Current.GetInstance <ILayoutService>();
                LayoutEntity layout        = layoutService.Get(page.LayoutId);
                layout.Page = page;
                Action <WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                                                             Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                                                             );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (Zones)
                    {
                        if (Zones.ContainsKey(part.Widget.ZoneID))
                        {
                            Zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection {
                                part
                            };
                            Zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var widgetService = ServiceLocator.Current.GetInstance <IWidgetService>();
                IEnumerable <WidgetBase> widgets = widgetService.GetAllByPageId(page.ID);
                var parallel = from widget in widgets.AsParallel() select widget;
                parallel.ForAll(processWidget);

                layout.ZoneWidgets = Zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    string layoutView = GetLayout();
                    if (layoutView.IsNotNullAndWhiteSpace())
                    {
                        viewResult.MasterName = layoutView;
                    }
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
Example #17
0
        public static ViewConfigureAttribute GetAttribute(Type type)
        {
            if (type == null)
            {
                return(null);
            }
            StaticCache cache     = new StaticCache();
            string      typeName  = type.FullName;
            var         attribute = cache.Get("DataConfigureAttribute_" + typeName, m => type.GetTypeInfo().GetCustomAttribute(typeof(ViewConfigureAttribute)) as ViewConfigureAttribute);

            return(attribute);
        }
Example #18
0
        public WidgetBase CreateViewModelInstance()
        {
            StaticCache cache = new StaticCache();
            var         type  = cache.Get("WidgetBase_" + AssemblyName + ViewModelTypeName, source =>
            {
                _widgetBase = _widgetBase ??
                              (_widgetBase = Activator.CreateInstance(AssemblyName, ViewModelTypeName).Unwrap() as WidgetBase);
                return(_widgetBase.GetType());
            });

            return(_widgetBase ?? (_widgetBase = ServiceLocator.Current.GetInstance(type) as WidgetBase));
        }
Example #19
0
        public IWidgetPartDriver CreateServiceInstance()
        {
            if (_partDriver != null)
            {
                return(_partDriver);
            }
            StaticCache cache = new StaticCache();
            var         type  = cache.Get("WidgetPart_" + AssemblyName + ServiceTypeName, source =>
            {
                _partDriver = _partDriver ??
                              (_partDriver = Activator.CreateInstance(AssemblyName, ServiceTypeName).Unwrap() as IWidgetPartDriver);
                return(_partDriver.GetType());
            });

            return(_partDriver ?? (_partDriver = ServiceLocator.Current.GetInstance(type) as IWidgetPartDriver));
        }
Example #20
0
        public Type GetViewModelType()
        {
            StaticCache cache = new StaticCache();

            return(cache.Get("TypeCache_" + this.ViewModelTypeName, m =>
            {
                Type type = null;
                AppDomain.CurrentDomain.GetAssemblies().Each(n => n.GetTypes().Each(t =>
                {
                    if (type == null && t.FullName == this.ViewModelTypeName)
                    {
                        type = t;
                    }
                }));
                return type;
            }));
        }
Example #21
0
        public static string Get(string lanKey)
        {
            var            lanCache = new StaticCache();
            LanguageEntity lan      = lanCache.Get(lanKey, m =>
            {
                m.When(LanguageService.SignalLanguageUpdate);

                if (LanService == null)
                {
                    return new LanguageEntity {
                        LanKey = lanKey, LanValue = lanKey
                    }
                }
                ;
                var language = LanService.Get(lanKey, GetCurrentLanID());
                if (language == null)
                {
                    string lanValue = lanKey;

                    string lanType = "UnKnown";
                    string module  = "Unknown";
                    if (lanKey.Contains("@"))
                    {
                        lanValue = lanKey.Split('@')[1];
                        lanType  = "EntityProperty";
                        module   = lanKey.Split('@')[0];
                    }
                    language = new LanguageEntity
                    {
                        LanID    = GetCurrentLanID(),
                        LanValue = lanValue,
                        LanKey   = lanKey,
                        LanType  = lanType,
                        Module   = module
                    };
                    LanService.Add(language);
                }
                return(language);
            });

            return(lan.LanValue);
        }
Example #22
0
        public override LayoutEntity Get(params object[] primaryKeys)
        {
            var cache = new StaticCache();

            return(cache.Get("Layout_" + primaryKeys[0], m =>
            {
                m.When(LayoutChanged);
                LayoutEntity entity = base.Get(primaryKeys);
                if (entity == null)
                {
                    return null;
                }
                IEnumerable <ZoneEntity> zones = new ZoneService().Get(new Data.DataFilter().Where("LayoutId", OperatorType.Equal, entity.ID));
                entity.Zones = new ZoneCollection();
                zones.Each(entity.Zones.Add);
                IEnumerable <LayoutHtml> htmls = new LayoutHtmlService().Get(new Data.DataFilter().OrderBy("LayoutHtmlId", OrderType.Ascending).Where("LayoutId", OperatorType.Equal, entity.ID));
                entity.Html = new LayoutHtmlCollection();
                htmls.Each(entity.Html.Add);
                return entity;
            }));
        }
Example #23
0
        public override LayoutEntity Get(params object[] primaryKeys)
        {
            var cache  = new StaticCache();
            var layout = cache.Get((ApplicationContext as CMSApplicationContext).RequestUrl.Host + "_Layout_" + primaryKeys[0], m =>
            {
                m.When(LayoutChanged);
                LayoutEntity entity = base.Get(primaryKeys);
                if (entity == null)
                {
                    return(null);
                }
                IEnumerable <ZoneEntity> zones = ZoneService.Get(new Data.DataFilter().Where("LayoutId", OperatorType.Equal, entity.ID));
                entity.Zones = new ZoneCollection();
                zones.Each(entity.Zones.Add);
                IEnumerable <LayoutHtml> htmls = new LayoutHtmlService().Get(new Data.DataFilter().OrderBy("LayoutHtmlId", OrderType.Ascending).Where("LayoutId", OperatorType.Equal, entity.ID));
                entity.Html = new LayoutHtmlCollection();
                htmls.Each(entity.Html.Add);
                return(entity);
            });

            layout.Page = null;
            return(layout);
        }
Example #24
0
        public static string Get(string lanKey)
        {
            var            lanCache = new StaticCache();
            LanguageEntity lan      = lanCache.Get(lanKey, m =>
            {
                using (var languageService = ServiceLocator.GetService <ILanguageService>())
                {
                    var language = languageService.Get(n => n.LanKey == lanKey && n.CultureName == CultureInfo.CurrentUICulture.Name).FirstOrDefault();

                    if (language == null)
                    {
                        string lanValue = lanKey;
                        string lanType  = "UnKnown";
                        string module   = "Unknown";
                        if (lanKey.Contains("@"))
                        {
                            lanValue = lanKey.Split('@')[1];
                            lanType  = "EntityProperty";
                            module   = lanKey.Split('@')[0];
                        }
                        language = new LanguageEntity
                        {
                            CultureName = CultureInfo.CurrentUICulture.Name,
                            LanValue    = lanValue,
                            LanKey      = lanKey,
                            LanType     = lanType,
                            Module      = module
                        };
                        languageService.Add(language);
                    }

                    return(language);
                }
            });

            return(lan.LanValue);
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var zones = new ZoneWidgetCollection();
            var cache = new StaticCache();
            //Page
            string path = filterContext.RequestContext.HttpContext.Request.Path;
            if (path.EndsWith("/") && path.Length > 1)
            {
                path = path.Substring(0, path.Length - 1);
                //filterContext.HttpContext.Response.Redirect(path);
                filterContext.Result = new RedirectResult(path);
                return;
            }
            bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase);
            var page = new PageService().GetByPath(path, publish);
            if (page != null)
            {
                var layoutService = new LayoutService();
                LayoutEntity layout = layoutService.Get(page.LayoutId);
                layout.Page = page;

                Action<WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                         Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                    );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection { part };
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var layoutWidgetsTask = Task.Factory.StartNew(layoutId =>
                {
                    var widgetServiceIn = new WidgetService();
                    IEnumerable<WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId));
                    layoutwidgets.Each(processWidget);
                }, page.LayoutId);


                var widgetService = new WidgetService();
                IEnumerable<WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID));
                int middle = widgets.Count() / 2;
                var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget));
                widgets.Take(middle).Each(processWidget);
                Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask });

                layout.ZoneWidgets = zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }
        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var zones = new ZoneWidgetCollection();
            var cache = new StaticCache();
            //Page
            string path = filterContext.RequestContext.HttpContext.Request.Path;

            if (path.EndsWith("/") && path.Length > 1)
            {
                path = path.Substring(0, path.Length - 1);
                //filterContext.HttpContext.Response.Redirect(path);
                filterContext.Result = new RedirectResult(path);
                return;
            }
            bool publish = !ReView.Review.Equals(filterContext.RequestContext.HttpContext.Request.QueryString[ReView.QueryKey], StringComparison.CurrentCultureIgnoreCase);
            var  page    = new PageService().GetByPath(path, publish);

            if (page != null)
            {
                var          layoutService = new LayoutService();
                LayoutEntity layout        = layoutService.Get(page.LayoutId);
                layout.Page = page;

                Action <WidgetBase> processWidget = m =>
                {
                    IWidgetPartDriver partDriver = cache.Get("IWidgetPartDriver_" + m.AssemblyName + m.ServiceTypeName, source =>
                                                             Activator.CreateInstance(m.AssemblyName, m.ServiceTypeName).Unwrap() as IWidgetPartDriver
                                                             );
                    WidgetPart part = partDriver.Display(partDriver.GetWidget(m), filterContext.HttpContext);
                    lock (zones)
                    {
                        if (zones.ContainsKey(part.Widget.ZoneID))
                        {
                            zones[part.Widget.ZoneID].Add(part);
                        }
                        else
                        {
                            var partCollection = new WidgetCollection {
                                part
                            };
                            zones.Add(part.Widget.ZoneID, partCollection);
                        }
                    }
                };
                var layoutWidgetsTask = Task.Factory.StartNew(layoutId =>
                {
                    var widgetServiceIn = new WidgetService();
                    IEnumerable <WidgetBase> layoutwidgets = widgetServiceIn.Get(new DataFilter().Where("LayoutID", OperatorType.Equal, layoutId));
                    layoutwidgets.Each(processWidget);
                }, page.LayoutId);


                var widgetService = new WidgetService();
                IEnumerable <WidgetBase> widgets = widgetService.Get(new DataFilter().Where("PageID", OperatorType.Equal, page.ID));
                int middle          = widgets.Count() / 2;
                var pageWidgetsTask = Task.Factory.StartNew(() => widgets.Skip(middle).Each(processWidget));
                widgets.Take(middle).Each(processWidget);
                Task.WaitAll(new[] { pageWidgetsTask, layoutWidgetsTask });

                layout.ZoneWidgets = zones;
                var viewResult = (filterContext.Result as ViewResult);
                if (viewResult != null)
                {
                    //viewResult.MasterName = "~/Modules/Easy.Web.CMS.Page/Views/Shared/_Layout.cshtml";
                    viewResult.ViewData[LayoutEntity.LayoutKey] = layout;
                }
            }
            else
            {
                filterContext.Result = new HttpStatusCodeResult(404);
            }
        }