コード例 #1
0
        public Store GetStore(String domainName)
        {
            String key  = String.Format("GetStoreDomain-{0}", domainName);
            Store  site = null;

            StoreCache.TryGet(key, out site);
            if (site == null)
            {
                site = this.GetStoreByDomain(domainName);
                if (site != null)
                {
                    string layout      = String.Format("~/Views/Shared/Layouts/{0}.cshtml", !String.IsNullOrEmpty((String)site.Layout) ? (String)site.Layout : "_Layout1");
                    var    isFileExist = File.Exists(System.Web.HttpContext.Current.Server.MapPath(layout));
                    _defaultlayout = String.Format(_defaultlayout, ProjectAppSettings.GetWebConfigString("DefaultLayout", "_Layout1"));
                    if (!isFileExist)
                    {
                        Logger.Info(String.Format("Layout is not found.Default Layout {0} is used.Site Domain is {1} ", _defaultlayout, site.Domain));
                    }
                    String selectedLayout = isFileExist ? layout : _defaultlayout;

                    site.Layout = selectedLayout;
                    StoreCache.Set(key, site, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000)));
                }
            }
            return(site);
        }
コード例 #2
0
        protected string GetCleanHtml(String source)
        {
            if (String.IsNullOrEmpty(source))
            {
                return(String.Empty);
            }

            source = HttpUtility.HtmlDecode(source);

            string path       = HttpContext.Server.MapPath("~/tags.config");
            var    myFile     = new System.IO.StreamReader(path);
            string myTags     = myFile.ReadToEnd();
            var    returnHtml = HtmlCleanHelper.SanitizeHtmlSoft(myTags, source);

            returnHtml = GeneralHelper.NofollowExternalLinks(returnHtml);

            var attributes = new List <String>();

            attributes.AddRange(ProjectAppSettings.GetWebConfigString("StyleUnWantedAttributes", "background:").Split(",".ToCharArray()).ToList());
            returnHtml = HtmlCleanHelper.CleanStyleAttributes(returnHtml, attributes);


            if (!string.IsNullOrEmpty(source) && string.IsNullOrEmpty(returnHtml))
            {
                return(source);
            }
            else
            {
                return(returnHtml);
            }
        }
コード例 #3
0
        public Store GetStoreByDomain(HttpContextBase request)
        {
            String siteStatus = ProjectAppSettings.GetWebConfigString("SiteStatus", "dev");
            String domainName = "FUELTECHNOLOGYAGE.COM";

            domainName = GeneralHelper.GetSiteDomain(request);
            if (siteStatus.IndexOf("live", StringComparison.InvariantCultureIgnoreCase) >= 0)
            {
                String key      = domainName;
                Store  storeObj = new Store();
                storeObj = (Store)MemoryCache.Default.Get(key);
                if (storeObj == null)
                {
                    storeObj = StoreService.GetStoreByDomain(domainName);

                    CacheItemPolicy policy = null;

                    policy                    = new CacheItemPolicy();
                    policy.Priority           = CacheItemPriority.Default;
                    policy.AbsoluteExpiration = DateTimeOffset.Now.AddSeconds(ProjectAppSettings.CacheLongSeconds);

                    MemoryCache.Default.Set(key, storeObj, policy);
                }
                return(storeObj);
            }
            else
            {
                String defaultSiteDomain = ProjectAppSettings.GetWebConfigString("DefaultSiteDomain",
                                                                                 "login.seatechnologyjobs.com");
                BaseLogger.Trace("Default Site Domain is used." + defaultSiteDomain + " for " + domainName);
                return(StoreService.GetStoreByDomain(defaultSiteDomain));
            }
        }
コード例 #4
0
ファイル: StoreHelper.cs プロジェクト: vinhch/StoreManagement
        public Store GetStore(HttpRequest Request)
        {
            String domainName = "FUELTECHNOLOGYAGE.COM";

            domainName = Request.Url.Scheme + Uri.SchemeDelimiter + Request.Url.Host + (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port);
            domainName = GeneralHelper.GetDomainPart(domainName);
            Logger.Info("Domain name=" + domainName);
            Store  site        = _storeRepository.GetStoreByDomain(domainName);
            string layout      = String.Format("~/Views/Shared/Layouts/{0}.cshtml", !String.IsNullOrEmpty((String)site.Layout) ? (String)site.Layout : "_Layout1");
            var    isFileExist = File.Exists(System.Web.HttpContext.Current.Server.MapPath(layout));

            defaultlayout = String.Format(defaultlayout, ProjectAppSettings.GetWebConfigString("DefaultLayout", "_Layout1"));
            if (!isFileExist)
            {
                Logger.Info(String.Format("Layout is not found.Default Layout {0} is used.Site Domain is {1} ", defaultlayout, site.Domain));
            }
            String selectedLayout = isFileExist ? layout : defaultlayout;

            site.Layout = selectedLayout;

            Logger.Info("Selected site=" + site);


            return(site);
        }
コード例 #5
0
        public Task <List <Navigation> > GetStoreActiveNavigationsAsync(int storeId)
        {
            SetCache();
            string url = string.Format("http://{0}/api/{1}/GetStoreActiveNavigationsAsync?storeId={2}", WebServiceAddress, ApiControllerName, storeId);

            HttpRequestHelper.CacheMinute = ProjectAppSettings.GetWebConfigInt("RequestHelperCacheLongMinute", 600);
            return(HttpRequestHelper.GetUrlResultsAsync <Navigation>(url));
        }
コード例 #6
0
        public FileContentResult RobotsText()
        {
            var    content    = "User-agent: *" + Environment.NewLine;
            String siteStatus = ProjectAppSettings.GetWebConfigString("SiteStatus", "dev");

            content += "Disallow: /" + Environment.NewLine;
            return(File(Encoding.UTF8.GetBytes(content), "text/plain"));
        }
コード例 #7
0
 protected String GetSettingValue(String key, String defaultValue)
 {
     var value = GetSettingValue(key);
     if (String.IsNullOrEmpty(value))
     {
         BaseLogger.Trace("Store Default Setting= " + StoreId + " Key=" + key + " defaultValue=" + defaultValue);
         return ProjectAppSettings.GetWebConfigString(key, defaultValue);
     }
     else
     {
         return value;
     }
 }
コード例 #8
0
        public static EmailAccount GetAdminEmailAccount()
        {
            var emailAccount = new EmailAccount();

            emailAccount.Username              = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Username");
            emailAccount.Email                 = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Email");
            emailAccount.DisplayName           = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_DisplayName");
            emailAccount.Password              = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Password");
            emailAccount.Host                  = ProjectAppSettings.GetWebConfigString("AdminEmailAccount_Host");
            emailAccount.Port                  = ProjectAppSettings.GetWebConfigInt("AdminEmailAccount_Port");
            emailAccount.EnableSsl             = ProjectAppSettings.GetWebConfigBool("AdminEmailAccount_EnableSsl");
            emailAccount.UseDefaultCredentials = ProjectAppSettings.GetWebConfigBool("AdminEmailAccount_UseDefaultCredentials");

            return(emailAccount);
        }
コード例 #9
0
        public Startup(IHostingEnvironment env)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(env.ContentRootPath)
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
                          .AddEnvironmentVariables();

            Configuration = builder.Build();

            AutoMapper.Mapper.Initialize(cfg => {
                cfg.AddProfile <ServiceModelMappings>();
                cfg.AddProfile <ApiModelMappings>();
            });

            ProjectAppSettings appSettings = new ProjectAppSettings();

            ConfigurationBinder.Bind(Configuration, appSettings);
        }
コード例 #10
0
        public FileContentResult RobotsText()
        {
            var    content    = "User-agent: *" + Environment.NewLine;
            String siteStatus = ProjectAppSettings.GetWebConfigString("SiteStatus", "dev");


            //  if (string.Equals(siteStatus, "live", StringComparison.InvariantCultureIgnoreCase))
            if (siteStatus.IndexOf("live", StringComparison.InvariantCultureIgnoreCase) >= 0)
            {
                content += "Disallow: " + Environment.NewLine;
            }
            else
            {
                content += "Disallow: /" + Environment.NewLine;
                //content += "Disallow: /" + Environment.NewLine;
            }

            // content += siteStatus;

            return(File(Encoding.UTF8.GetBytes(content), "text/plain"));
        }
コード例 #11
0
        public override HttpResponseMessage Post(system_logging value)
        {
            //  Logger.Trace("Log Post is coming :"+value.log_application);
            if (ModelState.IsValid)
            {
                var logLevel       = (LogLevels)Enum.Parse(typeof(LogLevels), value.log_level);
                var logLevelConfig = (LogLevels)Enum.Parse(typeof(LogLevels), ProjectAppSettings.GetWebConfigString("LogRepositoryLogLevel"));
                if (logLevel <= logLevelConfig)
                {
                    LogRepository.Add(value);
                    LogRepository.Save();
                }

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, value);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = value.Id }));
                return(response);
            }
            else
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }
        }
コード例 #12
0
        public Store GetStoreByDomain(IStoreGeneralRepository storeService, HttpRequestBase request)
        {
            String siteStatus = ProjectAppSettings.GetWebConfigString("SiteStatus", "dev");
            Store  result     = null;

            if (siteStatus.IndexOf("live", StringComparison.InvariantCultureIgnoreCase) >= 0)
            {
                String domainName = "FUELTECHNOLOGYAGE.COM";
                domainName = request.Url.Scheme + Uri.SchemeDelimiter + request.Url.Host +
                             (request.Url.IsDefaultPort ? "" : ":" + request.Url.Port);
                domainName = GeneralHelper.GetDomainPart(domainName);
                result     = storeService.GetStore(domainName);
            }

            if (result == null)
            {
                String defaultSiteDomain = ProjectAppSettings.GetWebConfigString("DefaultSiteDomain", "login.seatechnologyjobs.com");
                result = storeService.GetStoreByDomain(defaultSiteDomain);
            }

            return(result);
        }
コード例 #13
0
        public List <ProductCategory> GetProductCategoriesByStoreIdFromCache(int storeId, string type)
        {
            String key = String.Format("GetProductCategoriesByStoreIdFromCache-{0}-{1}", storeId, type);
            List <ProductCategory> items = null;

            ProductCategoryCache.TryGet(key, out items);

            if (items == null)
            {
                var cats = this.FindBy(r => r.StoreId == storeId &&
                                       r.CategoryType.Equals(type, StringComparison.InvariantCultureIgnoreCase))
                           .OrderBy(r => r.Ordering)
                           .Include(r => r.Products.Select(r1 => r1.ProductFiles.Select(m => m.FileManager)));

                items = cats.ToList();

                foreach (var category in items)
                {
                    foreach (var ccc in category.Products)
                    {
                        ccc.Description = ""; // GeneralHelper.GetDescription(ccc.Description, 200);
                    }
                }


                ProductCategoryCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("ProductCategories_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(items);
        }
コード例 #14
0
        public List <Setting> GetStoreSettingsFromCache(int storeid)
        {
            String key = String.Format("GetStoreSettingsFromCache-{0}", storeid);

            _settingStoreCache.IsCacheEnable = this.IsCacheEnable;
            List <Setting> items = null;

            _settingStoreCache.TryGet(key, out items);
            if (items == null)
            {
                items = GetStoreSettings(storeid).Where(r => r.State).OrderBy(r => r.Ordering).ToList();
                _settingStoreCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Setting_CacheAbsoluteExpiration_Minute", 10)));
            }
            return(items);
        }
コード例 #15
0
 public TemplatesController(ITemplateService service, IOptions <ProjectAppSettings> options)
 {
     _AppSettings = options.Value;
     _service     = service;
 }
コード例 #16
0
        public List <Product> GetProductByTypeAndCategoryIdFromCache(int storeId, string typeName, int categoryId)
        {
            String         key   = String.Format("GetProductByTypeAndCategoryIdFromCache-{0}-{1}-{2}", storeId, typeName, categoryId);
            List <Product> items = null;

            ProductCache.TryGet(key, out items);

            if (items == null)
            {
                items = GetProductByTypeAndCategoryId(storeId, typeName, categoryId);
                ProductCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Products_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(items);
        }
コード例 #17
0
        public StoreUser GetStoreUserByUserId(int userId)
        {
            String    key  = String.Format("GetStoreUserByUserId-{0}", userId);
            StoreUser item = null;

            StoreUserCache.TryGet(key, out item);

            if (item == null)
            {
                item = this.FindBy(r => r.UserId == userId).FirstOrDefault();
                //  item = this.GetSingleIncluding(userId, r => r.UserProfile);
                //var res = from s in  this.StoreDbContext.StoreUsers
                //          join u in this.StoreDbContext.UserProfiles on s.UserId equals u.UserId
                //          where s.UserId == userId
                //          select s;

                // item = res.FirstOrDefault();
                StoreUserCache.Set(key, item, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("MainMenuNavigation_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(item);
        }
コード例 #18
0
        public ActionResult AdminSearch(String adminsearchkey, int page = 1)
        {
            if (String.IsNullOrEmpty(adminsearchkey))
            {
                return(View(new PagedList <BaseEntity>(new List <BaseEntity>(), page - 1, 20, 0)));
            }
            ViewBag.SearchKey = adminsearchkey;
            adminsearchkey    = adminsearchkey.Trim().ToLower();

            int               storeId    = this.LoginStore.Id;
            String            key        = String.Format("SearchEntireStore-{0}-{1}", storeId, adminsearchkey);
            List <BaseEntity> resultList = null;

            StoreSearchCache.TryGet(key, out resultList);

            if (resultList == null)
            {
                resultList = SearchEntireStoreAsync(adminsearchkey, storeId).Result;
                StoreSearchCache.Set(key, resultList, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("SearchEntireStore_Minute", 10)));
            }

            var returnSearchModel = new PagedList <BaseEntity>(resultList, page - 1, 20, resultList.Count);

            return(View(returnSearchModel));
        }
コード例 #19
0
        public StorePagedList <Product> GetProductsCategoryId(int storeId, int?categoryId, string typeName, bool?isActive, int page,
                                                              int pageSize)
        {
            String key = String.Format("GetContentsCategoryId-{0}-{1}-{2}-{3}-{4}-{5}", storeId, typeName, categoryId, isActive.HasValue ? isActive.Value.ToStr() : "", page, pageSize);
            StorePagedList <Product> items = null;

            ProductCacheStorePagedList.TryGet(key, out items);

            if (items == null)
            {
                var returnList =
                    this.GetAllIncluding(r => r.ProductFiles.Select(r1 => r1.FileManager)).Where(r2 => r2.StoreId == storeId && r2.Type.Equals(typeName, StringComparison.InvariantCultureIgnoreCase));


                if (categoryId.HasValue)
                {
                    returnList = returnList.Where(r => r.ProductCategoryId == categoryId.Value);
                }
                if (isActive.HasValue)
                {
                    returnList = returnList.Where(r => r.State == isActive);
                }

                var cat = returnList.OrderByDescending(r => r.Id).ToList();
                items = new StorePagedList <Product>(cat.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, cat.Count());
                //  items = new PagedList<Content>(cat, page, cat.Count());
                //  items = (PagedList<Content>) cat.ToPagedList(page, pageSize);
                ProductCacheStorePagedList.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Products_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(items);
        }
コード例 #20
0
        public StorePagedList <FileManager> GetImagesByStoreId(int storeId, int page, int pageSize)
        {
            String key = String.Format("StoreFileManager-{0}", storeId);
            StorePagedList <FileManager> items = null;

            StorePagedListFileManagerCache.TryGet(key, out items);
            if (items == null)
            {
                var images = FindBy(r => r.StoreId == storeId).ToList();
                items = new StorePagedList <FileManager>(images.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, pageSize, images.Count());
                StorePagedListFileManagerCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("FileManager_CacheAbsoluteExpiration_Minute", 10)));
            }
            return(items);
        }
コード例 #21
0
        protected List<Setting> GetStoreSettings()
        {
            String key = String.Format("GetStoreSettingsFromCacheAsync-{0}", StoreId);
            _settingStoreCache.IsCacheEnable = true;
            List<Setting> items = null;
            _settingStoreCache.TryGet(key, out items);
            if (items == null)
            {
                var itemsAsyn = SettingService.GetStoreSettingsFromCache(StoreId);

                items = itemsAsyn;
                _settingStoreCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("Setting_CacheAbsoluteExpiration_Minute", 10)));

            }
            return items;

        }
コード例 #22
0
        public List <FileManager> GetFilesByStoreIdFromCache(int storeId)
        {
            String             key   = String.Format("StoreFileManager-{0}", storeId);
            List <FileManager> items = null;

            StoreFileManagerCache.TryGet(key, out items);
            if (items == null)
            {
                items = GetFilesByStoreId(storeId);
                StoreFileManagerCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("FileManager_CacheAbsoluteExpiration_Minute", 10)));
            }
            return(items);
        }
コード例 #23
0
        public Store GetStore(int id)
        {
            String key  = String.Format("GetStore-{0}", id);
            Store  site = null;

            StoreCache.TryGet(key, out site);
            if (site == null)
            {
                site = GetSingle(id);
                if (site != null)
                {
                    StoreCache.Set(key, site, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000)));
                }
            }
            return(site);
        }
コード例 #24
0
        public List <Navigation> GetStoreActiveNavigations(int storeId)
        {
            String            key   = String.Format("Navigation-{0}", storeId);
            List <Navigation> items = null;

            NavigationsCache.TryGet(key, out items);

            if (items == null)
            {
                items = GetStoreNavigations(storeId).Where(r => r.State).ToList();
                NavigationsCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("MainMenuNavigation_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(items);
        }
コード例 #25
0
        public List <Store> GetAllStores()
        {
            String       key   = String.Format("GetAllStores");
            List <Store> sites = null;

            AllStoreCache.TryGet(key, out sites);
            if (sites == null)
            {
                sites = GetAll().ToList();
                StoreCache.Set(key, sites, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("TooMuchTime_CacheAbsoluteExpiration_Minute", 100000)));
            }
            return(sites);
        }
コード例 #26
0
        public StorePagedList <ProductCategory> GetProductCategoryWithContents(int categoryId, int page, int pageSize = 25)
        {
            String key = String.Format("GetProductCategoryWithContents-{0}-{1}", categoryId, page);
            StorePagedList <ProductCategory> items = null;

            PagingProductCategoryCache.TryGet(key, out items);

            if (items == null)
            {
                IQueryable <ProductCategory> cats = StoreDbContext.ProductCategories.Where(r => r.Id == categoryId && r.Products.Any())
                                                    .Include(
                    r =>
                    r.Products.Select(
                        r1 => r1.ProductFiles.Select(m => m.FileManager)))
                                                    .OrderByDescending(r => r.Ordering);


                var c = cats.ToList();
                items = new StorePagedList <ProductCategory>(c.Skip((page - 1) * pageSize).Take(pageSize).ToList(), page, c.Count());
                PagingProductCategoryCache.Set(key, items, MemoryCacheHelper.CacheAbsoluteExpirationPolicy(ProjectAppSettings.GetWebConfigInt("ProductCategories_CacheAbsoluteExpiration_Minute", 10)));
            }

            return(items);
        }
コード例 #27
0
ファイル: UserController.cs プロジェクト: PSCSeifu/ReportAPI
 public UserController(IUserService service, IOptions <ProjectAppSettings> options)
 {
     _AppSettings = options.Value;
     _service     = service;
 }