/// <summary> /// 系统基础数据设置 /// </summary> /// <returns></returns> public IActionResult Config() { WebSiteRepository repository = new WebSiteRepository(); Models.WebSiteConfigModel model = repository.GetWebSiteConfig(); return(View(model)); }
public async Task <ActionResult> SignIn(LoginViewModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Неудачная попытка входа."); return(View("MasterPagePartial", model)); } IPersonality rep = new WebSiteRepository(); object account = await Task.Run(() => rep.Authentication ( model.Login, model.Password ) ); if (account == null) { ModelState.AddModelError("", "Неудачная попытка входа."); return(View("MasterPagePartial", model)); } Session["CurrUsr"] = account; return(RedirectToAction ( "Index", "Account" )); }
public IActionResult Navigation() { WebSiteRepository repository = new WebSiteRepository(); List <Models.WebSiteNavigationModel> model = repository.GetWebSiteNavigations().ToList(); return(View(model)); }
public void Setup() { var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount); _repository = new WebSiteRepository(factory); _webSiteTable = factory.GetTable <WebSiteRow>(typeof(WebSiteRow).Name); _bindingTable = factory.GetTable <BindingRow>(typeof(BindingRow).Name); }
protected override void FixtureSetup() { base.FixtureSetup(); // RoleEnvironment AzureRoleEnvironment.DeploymentId = () => "DEPLOYMENTID"; AzureRoleEnvironment.CurrentRoleInstanceId = () => "ROLEINSTANCEID"; // File Resource Paths var basePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase.Replace("file:///", "")); _sitePath = Path.Combine(basePath, "Sites"); _tempPath = Path.Combine(basePath, "Temp"); _configPath = Path.Combine(basePath, "Config"); _resourcesPath = Path.Combine(basePath, "_resources"); Directory.CreateDirectory(_sitePath); Directory.CreateDirectory(_tempPath); Directory.CreateDirectory(_configPath); // Website Repository var factory = new AzureStorageFactory(CloudStorageAccount.DevelopmentStorageAccount); _repo = new WebSiteRepository(factory); _webSiteTable = factory.GetTable <WebSiteRow>(typeof(WebSiteRow).Name); _bindingTable = factory.GetTable <BindingRow>(typeof(BindingRow).Name); // Clean up IIS and table storage to prepare for test using (var serverManager = new ServerManager()) { _excludedSites = new List <string>(); using (var manager = new ServerManager()) { manager.Sites.Where(s => s.Name != AzureRoleEnvironment.RoleWebsiteName()).ToList().ForEach(s => _excludedSites.Add(s.Name)); } CleanupWebsiteTest(serverManager); } // Sync Service _syncService = new SyncService( _repo, new SyncStatusRepository(factory), CloudStorageAccount.DevelopmentStorageAccount, _sitePath, _tempPath, new string[] { }, _excludedSites, () => true, new IISManager(_sitePath, _tempPath, new SyncStatusRepository(factory), new ConsoleFactory(), LoggerLevel.Debug), new ConsoleFactory(), LoggerLevel.Debug ); }
static void Main() { Console.Write("Enter the storage account name: "); var accountName = Console.ReadLine(); Console.Write("Enter the storage account key: "); var accountKey = Console.ReadLine(); var repo = new WebSiteRepository(new AzureStorageFactory(new CloudStorageAccount(new StorageCredentialsAccountAndKey(accountName, accountKey), true))); var sites = repo.RetrieveWebSitesWithBindings(); var i = 0; foreach (var site in sites) { Console.WriteLine("{0}. {1}", ++i, site.Name); } Console.Write("Which site do you want to edit (0) for new site: "); var siteNo = Convert.ToInt32(Console.ReadLine()); if (siteNo == 0) { var site = new WebSite { EnableCDNChildApplication = false, EnableTestChildApplication = false, Name = "", Description = "", Bindings = new List <Binding> { DefaultBinding() } }; EditWebSite(site); repo.CreateWebSite(site); foreach (var binding in site.Bindings) { repo.AddBindingToWebSite(site, binding); } } else { EditWebSite(sites[siteNo - 1]); repo.UpdateWebSite(sites[siteNo - 1]); foreach (var binding in sites[siteNo - 1].Bindings) { repo.UpdateBinding(binding); } } }
/// <summary> /// 从缓存服务中获取网站顶部导航数据 /// </summary> /// <returns></returns> public List <Models.WebSiteNavigationModel> GetWebSiteNavigationByCache() { List <Models.WebSiteNavigationModel> Result = null; ICacheService cacheService = ServiceContext.GetService <ICacheService>(); string cacheData = cacheService.Get("WebSiteNavigationCache"); if (string.IsNullOrEmpty(cacheData)) { WebSiteRepository repository = new WebSiteRepository(); Result = repository.GetWebSiteNavigations().Where(m => m.IsShow == true).ToList(); cacheData = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Result))); //写入缓存 cacheService.Add("WebSiteNavigationCache", cacheData); } else { cacheData = Encoding.UTF8.GetString(Convert.FromBase64String(cacheData.Replace("\"", ""))); //从缓存中获取 Result = JsonConvert.DeserializeObject <List <Models.WebSiteNavigationModel> >(cacheData); } return(Result); }
/// <summary> /// 获取网站基本配置信息 /// </summary> /// <returns></returns> public Models.WebSiteConfigModel GetWebSiteConfigByCache() { Models.WebSiteConfigModel Result = null; ICacheService cacheService = ServiceContext.GetService <ICacheService>(); string cacheData = cacheService.Get("WebSiteConfigCache"); if (string.IsNullOrEmpty(cacheData)) { WebSiteRepository repository = new WebSiteRepository(); Result = repository.GetWebSiteConfig(); cacheData = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(Result))); //写入缓存 cacheService.Add("WebSiteConfigCache", cacheData); } else { cacheData = Encoding.UTF8.GetString(Convert.FromBase64String(cacheData.Replace("\"", ""))); //从缓存中获取 Result = JsonConvert.DeserializeObject <Models.WebSiteConfigModel>(cacheData); } return(Result); }