public SiteConfig GetAll() { List<Option> options = _options.ToList(); var model = new SiteConfig { AdminEmail = options.Where(op => op.Name.Equals("AdminEmail")).FirstOrDefault().Value, BlogDescription = options.Where(op => op.Name.Equals("BlogDescription")).FirstOrDefault().Value, BlogKeywords = options.Where(op => op.Name.Equals("BlogKeywords")).FirstOrDefault().Value, BlogName = options.Where(op => op.Name.Equals("BlogName")).FirstOrDefault().Value, CommentsNotify = Convert.ToBoolean(options.Where(op => op.Name.Equals("CommentsNotify")).FirstOrDefault().Value), CommentModeratingStatus = Convert.ToBoolean(options.Where(op => op.Name.Equals("CommentModeratingStatus")) .FirstOrDefault().Value), MailServerLogin = options.Where(op => op.Name.Equals("MailServerLogin")).FirstOrDefault().Value, MailServerPass = options.Where(op => op.Name.Equals("MailServerPass")).FirstOrDefault().Value, MailServerPort = Convert.ToInt32(options.Where(op => op.Name.Equals("MailServerPort")).FirstOrDefault().Value), MailServerUrl = options.Where(op => op.Name.Equals("MailServerUrl")).FirstOrDefault().Value, PostPerPage = Convert.ToInt32(options.Where(op => op.Name.Equals("PostPerPage")).FirstOrDefault().Value), SiteUrl = options.Where(op => op.Name.Equals("SiteUrl")).FirstOrDefault().Value, UsersCanRegister = Convert.ToBoolean(options.Where(op => op.Name.Equals("UsersCanRegister")) .FirstOrDefault().Value) }; return model; }
public PingbackAPI() { siteConfig = SiteConfig.GetSiteConfig(); logDataService = LoggingDataServiceFactory.GetService(SiteConfig.GetLogPathFromCurrentContext()); dataService = BlogDataServiceFactory.GetService(SiteConfig.GetContentPathFromCurrentContext(), logDataService); }
public static string ApplyClickThrough( SiteConfig siteConfig, string entryId, string content ) { if ( siteConfig.EnableClickThrough && content != null && !SiteSecurity.IsValidContributor()) { StringBuilder contentSb = new StringBuilder(); int currentIndex = 0; foreach( Match match in FindHyperLinks(content) ) { contentSb.Append(content.Substring(currentIndex,match.Index-currentIndex)); currentIndex = match.Index+match.Length; if(!match.Groups["postfix"].Value.Equals("\"")) { // Patched with the {4} to avoid duplicated quotes at the end of the href contentSb.AppendFormat("<a{0} href=\"{1}&url={2}{4}{3}>", match.Groups["prefix"].Value,GetClickThroughUrl(siteConfig, entryId), HttpUtility.UrlEncode(HttpUtility.HtmlDecode(match.Groups["link"].Value)), match.Groups["postfix"].Value, (match.Groups["postfix"].Value.StartsWith("\"") ? "" : "\"")); } else { contentSb.AppendFormat("<a{0} href=\"{1}&url={2}\">", match.Groups["prefix"].Value,GetClickThroughUrl(siteConfig, entryId), HttpUtility.UrlEncode(HttpUtility.HtmlDecode(match.Groups["link"].Value))); } } contentSb.Append(content.Substring(currentIndex)); content = contentSb.ToString(); } return content; }
public SiteControllerBase() { Config = new SiteConfig(); ViewBag.Config = Config; ViewBag.StylesheetUrls = Repository.Stylesheets.Select(u => Url.Action("display", "upload", new { category = u.Category, fileName = u.FileName })); ViewBag.LegacyStylesheetUrls = Repository.LegacyStylesheets.Select(u => Url.Action("display", "upload", new { category = u.Category, fileName = u.FileName })); ViewBag.ScriptUrls = Repository.Scripts.Select(u => Url.Action("display", "upload", new { category = u.Category, fileName = u.FileName })); }
public virtual ActionResult Index(SiteConfig model) { _optionService.Update(model); _uow.SaveChanges(); _cacheService.RemoveSiteConfig(); return PartialView(MVC.Admin.Shared.Views._Alert, new Alert { Message = "تنظیمات سایت با موفقیت به روز رسانی شد", Mode = AlertMode.Success }); }
public void SerializeTest(){ SiteConfig config = new SiteConfig(); XmlSerializer ser = new XmlSerializer(typeof(SiteConfig)); using( StringWriter writer = new StringWriter() ){ ser.Serialize( writer, config ); //Debug.Write( writer.ToString() ); } }
private void ShowInfo() { SiteConfig bll = new SiteConfig(); Com_Config model = bll.loadConfig(Utils.GetXmlMapPath(LoneuKeys.FILE_SITE_XML_CONFING)); webname.Text = model.webname; webcompany.Text = model.webcompany; weburl.Text = model.weburl; webtel.Text = model.webtel; webfax.Text = model.webfax; webmail.Text = model.webmail; webcrod.Text = model.webcrod; webtitle.Text = model.webtitle; webkeyword.Text = model.webkeyword; webdescription.Text = model.webdescription; webcopyright.Text = model.webcopyright; emailstmp.Text = model.emailstmp; emailport.Text = model.emailport.ToString(); emailfrom.Text = model.emailfrom; emailusername.Text = model.emailusername; if (!string.IsNullOrEmpty(model.emailpassword)) { emailpassword.Attributes["value"] = defaultpassword; } emailnickname.Text = model.emailnickname; attachpath.Text = model.attachpath; attachextension.Text = model.attachextension; attachsave.SelectedValue = model.attachsave.ToString(); attachfilesize.Text = model.attachfilesize.ToString(); attachimgsize.Text = model.attachimgsize.ToString(); attachimgmaxheight.Text = model.attachimgmaxheight.ToString(); attachimgmaxwidth.Text = model.attachimgmaxwidth.ToString(); thumbnailheight.Text = model.thumbnailheight.ToString(); thumbnailwidth.Text = model.thumbnailwidth.ToString(); watermarktype.SelectedValue = model.watermarktype.ToString(); watermarkposition.Text = model.watermarkposition.ToString(); watermarkimgquality.Text = model.watermarkimgquality.ToString(); watermarkpic.Text = model.watermarkpic; watermarktransparency.Text = model.watermarktransparency.ToString(); watermarktext.Text = model.watermarktext; watermarkfont.Text = model.watermarkfont; watermarkfontsize.Text = model.watermarkfontsize.ToString(); }
internal static SiteConfig ToSiteConfig(this WebSiteGetConfigurationResponse getConfigResponse) { var config = new SiteConfig { NumberOfWorkers = getConfigResponse.NumberOfWorkers, DefaultDocuments = getConfigResponse.DefaultDocuments.ToArray(), NetFrameworkVersion = getConfigResponse.NetFrameworkVersion, PhpVersion = getConfigResponse.PhpVersion, RequestTracingEnabled = getConfigResponse.RequestTracingEnabled, HttpLoggingEnabled = getConfigResponse.HttpLoggingEnabled, DetailedErrorLoggingEnabled = getConfigResponse.DetailedErrorLoggingEnabled, PublishingUsername = getConfigResponse.PublishingUserName, PublishingPassword = getConfigResponse.PublishingPassword, AppSettings = getConfigResponse.AppSettings.Select(ToNameValuePair).ToList(), Metadata = getConfigResponse.Metadata.Select(ToNameValuePair).ToList(), ConnectionStrings = new ConnStringPropertyBag( getConfigResponse.ConnectionStrings.Select(cs => new ConnStringInfo { ConnectionString = cs.ConnectionString, Name = cs.Name, Type = (DatabaseType)Enum.Parse(typeof(DatabaseType), cs.Type) }).ToList()), HandlerMappings = getConfigResponse.HandlerMappings.Select(hm => new HandlerMapping { Arguments = hm.Arguments, Extension = hm.Extension, ScriptProcessor = hm.ScriptProcessor }).ToArray(), ManagedPipelineMode = getConfigResponse.ManagedPipelineMode, WebSocketsEnabled = getConfigResponse.WebSocketsEnabled, RemoteDebuggingEnabled = getConfigResponse.RemoteDebuggingEnabled, RemoteDebuggingVersion = getConfigResponse.RemoteDebuggingVersion.GetValueOrDefault() }; return config; }
public void UpdateSiteConfig(SiteConfig siteConfig) { SiteConfig currentSiteConfig = SiteConfig.GetSiteConfig(); if ( !currentSiteConfig.EnableConfigEditService ) { throw new ServiceDisabledException(); } if (authenticationHeader == null || SiteSecurity.Login(authenticationHeader.userName, authenticationHeader.password).Role != "admin") { throw new Exception("Invalid Password"); } XmlSerializer ser = new XmlSerializer(typeof(SiteConfig)); using (StreamWriter writer = new StreamWriter(SiteConfig.GetConfigFilePathFromCurrentContext())) { ser.Serialize(writer, siteConfig); } }
public void SendEmailReport(DateTime reportDate, SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService) { MailMessage emailMessage = new MailMessage(); if ( siteConfig.NotificationEMailAddress != null && siteConfig.NotificationEMailAddress.Length > 0 ) { emailMessage.To.Add(siteConfig.NotificationEMailAddress); } else { emailMessage.To.Add(siteConfig.Contact); } emailMessage.Subject = String.Format("Weblog Daily Activity Report for '{0}'", reportDate.ToLongDateString()); emailMessage.Body = GenerateReportEmailBody(reportDate); emailMessage.IsBodyHtml = true; emailMessage.BodyEncoding = System.Text.Encoding.UTF8; emailMessage.From = new MailAddress(siteConfig.Contact); SendMailInfo sendMailInfo = new SendMailInfo(emailMessage, siteConfig.SmtpServer, siteConfig.EnableSmtpAuthentication, siteConfig.UseSSLForSMTP, siteConfig.SmtpUserName, siteConfig.SmtpPassword, siteConfig.SmtpPort); dataService.AddTracking(null, sendMailInfo ); // use this with null tracking object, just to get the email sent loggingService.AddEvent( new EventDataItem( EventCodes.ReportMailerReportSent,"","")); }
/// <summary> /// Update the website configuration /// </summary> /// <param name="name">The website name</param> /// <param name="newConfiguration">The website configuration object containing updates.</param> public void UpdateWebsiteConfiguration(string name, SiteConfig newConfiguration) { Site website = GetWebsite(name); WebsiteManagementClient.WebSites.UpdateConfiguration(website.WebSpace, name, newConfiguration.ToConfigUpdateParameters()); }
public void UpdateWebAppConfiguration(string resourceGroupName, string location, string webSiteName, string slotName, SiteConfig siteConfig = null, IDictionary <string, string> appSettings = null, IDictionary <string, ConnStringValueTypePair> connectionStrings = null, AzureStoragePropertyDictionaryResource azureStorageSettings = null) { string qualifiedSiteName; var useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName); if (useSlot) { if (siteConfig != null) { WrappedWebsitesClient.WebApps().UpdateConfigurationSlot( resourceGroupName, webSiteName, siteConfig.ConvertToSiteConfigResource(), slotName); } if (appSettings != null) { WrappedWebsitesClient.WebApps().UpdateApplicationSettingsSlot( resourceGroupName, webSiteName, new StringDictionary { Properties = appSettings }, slotName); } if (connectionStrings != null) { WrappedWebsitesClient.WebApps().UpdateConnectionStringsSlot( resourceGroupName, webSiteName, new ConnectionStringDictionary { Properties = connectionStrings }, slotName); } if (azureStorageSettings != null) { WrappedWebsitesClient.WebApps().UpdateAzureStorageAccountsSlot( resourceGroupName, webSiteName, azureStorageSettings, slotName); } } else { if (siteConfig != null) { WrappedWebsitesClient.WebApps().UpdateConfiguration(resourceGroupName, webSiteName, siteConfig.ConvertToSiteConfigResource()); } if (appSettings != null) { WrappedWebsitesClient.WebApps().UpdateApplicationSettings( resourceGroupName, webSiteName, new StringDictionary { Properties = appSettings }); } if (connectionStrings != null) { WrappedWebsitesClient.WebApps().UpdateConnectionStrings( resourceGroupName, webSiteName, new ConnectionStringDictionary { Properties = connectionStrings }); } if (azureStorageSettings != null) { WrappedWebsitesClient.WebApps().UpdateAzureStorageAccounts( resourceGroupName, webSiteName, azureStorageSettings); } } }
public SyndicationServiceExperimentalImplementation(SiteConfig siteConfig, IBlogDataService dataService, ILoggingDataService loggingService): base( siteConfig, dataService, loggingService ) { //CODEGEN: This call is required by the ASP.NET Web Services Designer InitializeComponent(); }
public DocumentService(IGlobalStoreManager globalStore, IQueryFactory queryFactory, SiteConfig siteConfig, ProcessHandler processHandler, UrlProvider urlProvider) { this.siteConfig = siteConfig; this.queryFactory = queryFactory; this.globalStore = globalStore; this.processHandler = processHandler; this.urlProvider = urlProvider; }
public static string GetPayBodyContent(string ProductNames) { string body = new SiteConfig().SystemName + ProductNames; return(body); }
/// <summary> /// 获取稿件相关附件格式限制 /// </summary> /// <param name="helper"></param> /// <param name="type">0:稿件 1:附图 3:稿件pdf 4:介绍信</param> /// <returns></returns> public static string ContributionInfoFileExt(this HtmlHelper helper, Int32 type) { return(SiteConfig.GetContributionInfoFileExt(type)); }
public override void ExecuteCmdlet() { if (Git && GitHub) { throw new Exception("Please run the command with either -Git or -GitHub options. Not both."); } if (Git) { PublishingUsername = GetPublishingUser(); } WebSpaces webspaceList = null; InvokeInOperationContext(() => { webspaceList = RetryCall(s => Channel.GetWebSpacesWithCache(s)); }); if (Git && webspaceList.Count == 0) { // If location is still empty or null, give portal instructions. string error = string.Format(Resources.PortalInstructions, Name); throw new Exception(!Git ? error : string.Format("{0}\n{1}", error, Resources.PortalInstructionsGit)); } WebSpace webspace = null; if (string.IsNullOrEmpty(Location)) { // If no location was provided as a parameter, try to default it webspace = webspaceList.FirstOrDefault(); if (webspace == null) { // Use east us webspace = new WebSpace { Name = "eastuswebspace", GeoRegion = "East US", Subscription = CurrentSubscription.SubscriptionId, Plan = "VirtualDedicatedPlan" }; } } else { // Find the webspace that corresponds to the georegion webspace = webspaceList.FirstOrDefault(w => w.GeoRegion.Equals(Location, StringComparison.OrdinalIgnoreCase)); if (webspace == null) { // If no webspace corresponding to the georegion was found, attempt to create it webspace = new WebSpace { Name = Regex.Replace(Location.ToLower(), " ", "") + "webspace", GeoRegion = Location, Subscription = CurrentSubscription.SubscriptionId, Plan = "VirtualDedicatedPlan" }; } } SiteWithWebSpace website = new SiteWithWebSpace { Name = Name, HostNames = new[] { Name + General.AzureWebsiteHostNameSuffix }, WebSpace = webspace.Name, WebSpaceToCreate = webspace }; if (!string.IsNullOrEmpty(Hostname)) { List <string> newHostNames = new List <string>(website.HostNames); newHostNames.Add(Hostname); website.HostNames = newHostNames.ToArray(); } try { InvokeInOperationContext(() => RetryCall(s => Channel.CreateSite(s, webspace.Name, website))); // If operation succeeded try to update cache with new webspace if that's the case if (webspaceList.FirstOrDefault(ws => ws.Name.Equals(webspace.Name)) == null) { Cache.AddWebSpace(CurrentSubscription.SubscriptionId, webspace); } Cache.AddSite(CurrentSubscription.SubscriptionId, website); SiteConfig websiteConfiguration = null; InvokeInOperationContext(() => { websiteConfiguration = RetryCall(s => Channel.GetSiteConfig(s, website.WebSpace, website.Name)); WaitForOperation(CommandRuntime.ToString()); }); WriteObject(new SiteWithConfig(website, websiteConfiguration)); } catch (ProtocolException ex) { // Handle site creating indepently so that cmdlet is idempotent. string message = ProcessException(ex, false); if (message.Equals(string.Format(Resources.WebsiteAlreadyExistsReplacement, Name)) && (Git || GitHub)) { WriteWarning(message); } else if (message.Equals(Resources.DefaultHostnamesValidation)) { WriteExceptionError(new Exception(Resources.InvalidHostnameValidation)); } else { WriteExceptionError(new Exception(message)); } } if (Git || GitHub) { try { Directory.SetCurrentDirectory(SessionState.Path.CurrentFileSystemLocation.Path); } catch (Exception) { // Do nothing if session state is not present } LinkedRevisionControl linkedRevisionControl = null; if (Git) { linkedRevisionControl = new GitClient(this); } else if (GitHub) { linkedRevisionControl = new GithubClient(this, GithubCredentials, GithubRepository); } linkedRevisionControl.Init(); CopyIisNodeWhenServerJsPresent(); UpdateLocalConfigWithSiteName(Name, webspace.Name); InitializeRemoteRepo(webspace.Name, Name); Site updatedWebsite = RetryCall(s => Channel.GetSite(s, webspace.Name, Name, "repositoryuri,publishingpassword,publishingusername")); if (Git) { AddRemoteToLocalGitRepo(updatedWebsite); } linkedRevisionControl.Deploy(updatedWebsite); linkedRevisionControl.Dispose(); } }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); SiteConfig siteConfig = null; Site site = null; string location = null; IDictionary <string, string> tags = null; switch (ParameterSetName) { case ParameterSet1Name: WebApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); location = WebApp.Location; tags = WebApp.Tags; var parameters = new HashSet <string>(MyInvocation.BoundParameters.Keys, StringComparer.OrdinalIgnoreCase); if (parameters.Any(p => CmdletHelpers.SiteConfigParameters.Contains(p))) { siteConfig = new SiteConfig { DefaultDocuments = parameters.Contains("DefaultDocuments") ? DefaultDocuments : null, NetFrameworkVersion = parameters.Contains("NetFrameworkVersion") ? NetFrameworkVersion : null, PhpVersion = parameters.Contains("PhpVersion") ? PhpVersion.ToLower() == "off" ? "" : PhpVersion : null, RequestTracingEnabled = parameters.Contains("RequestTracingEnabled") ? (bool?)RequestTracingEnabled : null, HttpLoggingEnabled = parameters.Contains("HttpLoggingEnabled") ? (bool?)HttpLoggingEnabled : null, DetailedErrorLoggingEnabled = parameters.Contains("DetailedErrorLoggingEnabled") ? (bool?)DetailedErrorLoggingEnabled : null, HandlerMappings = parameters.Contains("HandlerMappings") ? HandlerMappings : null, ManagedPipelineMode = parameters.Contains("ManagedPipelineMode") ? (ManagedPipelineMode?)Enum.Parse(typeof(ManagedPipelineMode), ManagedPipelineMode) : null, WebSocketsEnabled = parameters.Contains("WebSocketsEnabled") ? (bool?)WebSocketsEnabled : null, Use32BitWorkerProcess = parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null, AutoSwapSlotName = parameters.Contains("AutoSwapSlotName") ? AutoSwapSlotName : null, NumberOfWorkers = parameters.Contains("NumberOfWorkers") ? NumberOfWorkers : WebApp.SiteConfig.NumberOfWorkers }; } Hashtable appSettings = AppSettings ?? new Hashtable(); if (siteConfig == null) { siteConfig = WebApp.SiteConfig; } //According to current implementation if AppSettings parameter is provided we are overriding existing AppSettings if (WebApp.SiteConfig.AppSettings != null && AppSettings == null) { foreach (var setting in WebApp.SiteConfig.AppSettings) { appSettings[setting.Name] = setting.Value; } } if (ContainerImageName != null) { string dockerImage = CmdletHelpers.DockerImagePrefix + ContainerImageName; if (WebApp.IsXenon.GetValueOrDefault()) { siteConfig.WindowsFxVersion = dockerImage; } else if (WebApp.Reserved.GetValueOrDefault()) { siteConfig.LinuxFxVersion = dockerImage; } } if (ContainerRegistryUrl != null) { appSettings[CmdletHelpers.DocerRegistryServerUrl] = ContainerRegistryUrl; } if (ContainerRegistryUser != null) { appSettings[CmdletHelpers.DocerRegistryServerUserName] = ContainerRegistryUser; } if (ContainerRegistryPassword != null) { appSettings[CmdletHelpers.DocerRegistryServerPassword] = ContainerRegistryPassword.ConvertToString(); } if (parameters.Contains("EnableContainerContinuousDeployment")) { if (EnableContainerContinuousDeployment) { appSettings[CmdletHelpers.DockerEnableCI] = "true"; } else { appSettings.Remove(CmdletHelpers.DockerEnableCI); } } // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, appSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary(), AzureStoragePath.ConvertToAzureStorageAccountPathPropertyDictionary()); //update reference to WebApp object after site configuration update WebApp = new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); if (parameters.Any(p => CmdletHelpers.SiteParameters.Contains(p))) { site = new Site { Location = location, Tags = tags, ServerFarmId = WebApp.ServerFarmId, Identity = parameters.Contains("AssignIdentity") ? AssignIdentity ? new ManagedServiceIdentity("SystemAssigned", null, null) : new ManagedServiceIdentity("None", null, null) : WebApp.Identity, HttpsOnly = parameters.Contains("HttpsOnly") ? HttpsOnly : WebApp.HttpsOnly }; WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, WebApp.ServerFarmId, new PSSite(site)); } if (parameters.Contains("AppServicePlan")) { WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan); } break; case ParameterSet2Name: // Web app is direct or pipeline input string servicePlanName; string rg; location = WebApp.Location; siteConfig = WebApp.SiteConfig; // Update web app configuration WebsitesClient.UpdateWebAppConfiguration( ResourceGroupName, location, Name, Slot, siteConfig, WebApp.SiteConfig == null ? null : WebApp.SiteConfig.AppSettings .ToDictionary( nvp => nvp.Name, nvp => nvp.Value, StringComparer.OrdinalIgnoreCase), WebApp.SiteConfig == null ? null : WebApp.SiteConfig.ConnectionStrings .ToDictionary( nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type.Value, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName); WebApp.AzureStoragePath = null; // the API to update site Object doesn't have the AzureStorage Path property WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName, WebApp); break; } WriteObject(new PSSite(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot))); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); SiteConfig siteConfig = null; string location = null; switch (ParameterSetName) { case ParameterSet1Name: WebApp = WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot); location = WebApp.Location; var parameters = new HashSet <string>(MyInvocation.BoundParameters.Keys, StringComparer.OrdinalIgnoreCase); if (parameters.Any(p => CmdletHelpers.SiteConfigParameters.Contains(p))) { siteConfig = new SiteConfig { DefaultDocuments = parameters.Contains("DefaultDocuments") ? DefaultDocuments : null, NetFrameworkVersion = parameters.Contains("NetFrameworkVersion") ? NetFrameworkVersion : null, PhpVersion = parameters.Contains("PhpVersion") ? PhpVersion : null, RequestTracingEnabled = parameters.Contains("RequestTracingEnabled") ? (bool?)RequestTracingEnabled : null, HttpLoggingEnabled = parameters.Contains("HttpLoggingEnabled") ? (bool?)HttpLoggingEnabled : null, DetailedErrorLoggingEnabled = parameters.Contains("DetailedErrorLoggingEnabled") ? (bool?)DetailedErrorLoggingEnabled : null, HandlerMappings = parameters.Contains("HandlerMappings") ? HandlerMappings : null, ManagedPipelineMode = parameters.Contains("ManagedPipelineMode") ? (ManagedPipelineMode?)Enum.Parse(typeof(ManagedPipelineMode), ManagedPipelineMode) : null, WebSocketsEnabled = parameters.Contains("WebSocketsEnabled") ? (bool?)WebSocketsEnabled : null, Use32BitWorkerProcess = parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null, AutoSwapSlotName = parameters.Contains("AutoSwapSlotName") ? AutoSwapSlotName : null, NumberOfWorkers = parameters.Contains("NumberOfWorkers") ? NumberOfWorkers : WebApp.SiteConfig.NumberOfWorkers }; } // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, AppSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary()); if (parameters.Contains("AppServicePlan")) { WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan); } break; case ParameterSet2Name: // Web app is direct or pipeline input string servicePlanName; string rg; location = WebApp.Location; siteConfig = WebApp.SiteConfig; // Update web app configuration WebsitesClient.UpdateWebAppConfiguration( ResourceGroupName, location, Name, Slot, siteConfig, WebApp.SiteConfig == null ? null : WebApp.SiteConfig.AppSettings .ToDictionary( nvp => nvp.Name, nvp => nvp.Value, StringComparer.OrdinalIgnoreCase), WebApp.SiteConfig == null ? null : WebApp.SiteConfig.ConnectionStrings .ToDictionary( nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type.Value, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName); WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName); break; } WriteObject(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); }
public override void OnActionExecuting(ActionExecutingContext context) { base.OnActionExecuting(context); //是否启用令牌验证 var rquired = SiteConfig.GetSite("CustomConfiguration", "IsVerifyToken").ToLower() == "true"; if (!rquired) { return; } var rquireduas = SiteConfig.GetSite("CustomConfiguration", "IsVerifyUasToken").ToLower() == "true"; //是否匿名访问验证 var isDefined = false; if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor) { isDefined = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true) .Any(a => a.GetType().Equals(typeof(AnonymousFilter))); } if (isDefined) { return; } JsonSerializerSettings setting = Util.GetJsonSetting(); try { var requestHead = context.HttpContext.Request.Headers; var ReqUserToken = requestHead["ReqUserToken"]; var ReqUserId = requestHead["ReqUserId"]; var ReqDateExpire = requestHead["ReqDateExpire"]; var ReqUasToken = requestHead["ReqUasToken"]; var ReqUasSub = requestHead["ReqUasSub"]; UserTokenModel token = getUserToken(ReqUserToken, ReqUserId, ReqDateExpire); if (token == null || string.IsNullOrEmpty(token.ReqUserId) || string.IsNullOrEmpty(token.ReqUserToken)) { var requestQuery = context.HttpContext.Request.Query; ReqUserToken = requestQuery["ReqUserToken"]; ReqUserId = requestQuery["ReqUserId"]; ReqDateExpire = requestQuery["ReqDateExpire"]; ReqUasToken = requestQuery["ReqUasToken"]; ReqUasSub = requestQuery["ReqUasSub"]; token = getUserToken(ReqUserToken, ReqUserId, ReqDateExpire); } if (token == null) { token = new UserTokenModel { ReqUserId = string.Empty }; } if (token.ReqUserId == string.Empty || string.IsNullOrEmpty(token.ReqUserToken)) { context.Result = new JsonResult(new ApiReponseModel <string>() { Code = ApiResponseCode.businessfail, Message = "无效的令牌请求参数" }, setting); } else { //验证用户令牌 var message = string.Empty; try { if (rquireduas) { //Log.Log4netHelper.Error(this, "ReqUasToken:" + ReqUasToken + ">>ReqUasSub:" + ReqUasSub); if (string.IsNullOrEmpty(ReqUasToken) || string.IsNullOrEmpty(ReqUasSub)) { message = "UasToken验证失败:ReqUasToken或ReqUasSub为空"; } else if (!RedisOperation.RedisHelper.Default.KeyExists(ReqUasSub)) { message = "UasToken验证失败:Redis中不存在Key"; } else { var redisUasToken = RedisOperation.RedisHelper.Default.GetStringKey <string>(ReqUasSub); if (!redisUasToken.Equals(ReqUasToken)) { message = "UasToken验证失败:redis中的key与传递的key不相等"; } } } if (string.IsNullOrEmpty(message)) { var rsa = new RSAHelper(RSAType.RSA2); var decrypt = rsa.Decrypt(token.ReqUserToken); if (string.IsNullOrEmpty(decrypt) || decrypt.Length != 36) { message = "错误的用户令牌"; } else if (decrypt != token.ReqUserId) { message = "用户信息错误,请重新登录"; } } } catch (Exception ex) { message = Util.ExceptionMessage(ex); } if (string.IsNullOrEmpty(message)) { return; } context.Result = new JsonResult(new ApiReponseModel <string>() { Code = ApiResponseCode.businessfail, Message = message }, setting); } } catch (Exception ex) { var message = Util.ExceptionMessage(ex); context.Result = new JsonResult(new ApiReponseModel <string>() { Code = ApiResponseCode.businessfail, Message = message }, setting); } }
public static string GetAggregatorBugUrl( SiteConfig siteConfig, string id ) { return SiteUtilities.GetAggregatorBugUrl(siteConfig,id); }
public void SetAzureWebsiteProcess() { const string websiteName = "website1"; const string webspaceName = "webspace"; // Setup bool updatedSite = false; bool updatedSiteConfig = false; SimpleWebsitesManagement channel = new SimpleWebsitesManagement(); Site site = new Site {Name = websiteName, WebSpace = webspaceName}; SiteConfig siteConfig = new SiteConfig { NumberOfWorkers = 1}; channel.GetWebSpacesThunk = ar => new WebSpaces(new List<WebSpace> { new WebSpace { Name = webspaceName } }); channel.GetSitesThunk = ar => new Sites(new List<Site> { site }); channel.GetSiteThunk = ar => site; channel.GetSiteConfigThunk = ar => siteConfig; channel.UpdateSiteConfigThunk = ar => { Assert.AreEqual(webspaceName, ar.Values["webspaceName"]); SiteConfig website = ar.Values["siteConfig"] as SiteConfig; Assert.IsNotNull(website); Assert.AreEqual(website.NumberOfWorkers, 3); siteConfig.NumberOfWorkers = website.NumberOfWorkers; updatedSiteConfig = true; }; channel.UpdateSiteThunk = ar => { Assert.AreEqual(webspaceName, ar.Values["webspaceName"]); Site website = ar.Values["site"] as Site; Assert.IsNotNull(website); Assert.AreEqual(websiteName, website.Name); Assert.IsTrue(website.HostNames.Any(hostname => hostname.Equals(websiteName + General.AzureWebsiteHostNameSuffix))); Assert.IsNotNull(website.HostNames.Any(hostname => hostname.Equals("stuff.com"))); site.HostNames = website.HostNames; updatedSite = true; }; // Test SetAzureWebsiteCommand setAzureWebsiteCommand = new SetAzureWebsiteCommand(channel) { ShareChannel = true, CommandRuntime = new MockCommandRuntime(), Name = websiteName, CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }, NumberOfWorkers = 3 }; setAzureWebsiteCommand.ExecuteCmdlet(); Assert.IsTrue(updatedSiteConfig); Assert.IsFalse(updatedSite); // Test updating site only and not configurations updatedSite = false; updatedSiteConfig = false; setAzureWebsiteCommand = new SetAzureWebsiteCommand(channel) { ShareChannel = true, CommandRuntime = new MockCommandRuntime(), Name = websiteName, CurrentSubscription = new SubscriptionData { SubscriptionId = base.subscriptionName }, HostNames = new [] { "stuff.com" } }; setAzureWebsiteCommand.ExecuteCmdlet(); Assert.IsFalse(updatedSiteConfig); Assert.IsTrue(updatedSite); }
public ThemeProvider(SiteConfig siteConfig, IWebHelper webHelper) { basePath = webHelper.MapPath(siteConfig.ThemeBasePath); LoadConfigurations(); }
public IAsyncResult BeginUpdateSiteConfig(string subscriptionName, string webspaceName, string name, SiteConfig siteConfig, AsyncCallback callback, object state) { SimpleServiceManagementAsyncResult result = new SimpleServiceManagementAsyncResult(); result.Values["subscriptionName"] = subscriptionName; result.Values["webspaceName"] = webspaceName; result.Values["name"] = name; result.Values["siteConfig"] = siteConfig; result.Values["callback"] = callback; result.Values["state"] = state; return result; }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); SiteConfig siteConfig = null; string location = null; switch (ParameterSetName) { case ParameterSet1Name: WebApp = WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot); location = WebApp.Location; var parameters = new HashSet<string>(MyInvocation.BoundParameters.Keys, StringComparer.OrdinalIgnoreCase); if (parameters.Any(p => CmdletHelpers.SiteConfigParameters.Contains(p))) { siteConfig = new SiteConfig { DefaultDocuments = parameters.Contains("DefaultDocuments") ? DefaultDocuments : null, NetFrameworkVersion = parameters.Contains("NetFrameworkVersion") ? NetFrameworkVersion : null, PhpVersion = parameters.Contains("PhpVersion") ? PhpVersion : null, RequestTracingEnabled = parameters.Contains("RequestTracingEnabled") ? (bool?)RequestTracingEnabled : null, HttpLoggingEnabled = parameters.Contains("HttpLoggingEnabled") ? (bool?)HttpLoggingEnabled : null, DetailedErrorLoggingEnabled = parameters.Contains("DetailedErrorLoggingEnabled") ? (bool?)DetailedErrorLoggingEnabled : null, HandlerMappings = parameters.Contains("HandlerMappings") ? HandlerMappings : null, ManagedPipelineMode = parameters.Contains("ManagedPipelineMode") ? (ManagedPipelineMode?)Enum.Parse(typeof(ManagedPipelineMode), ManagedPipelineMode) : null, WebSocketsEnabled = parameters.Contains("WebSocketsEnabled") ? (bool?)WebSocketsEnabled : null, Use32BitWorkerProcess = parameters.Contains("Use32BitWorkerProcess") ? (bool?)Use32BitWorkerProcess : null }; } // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, AppSettings.ConvertToStringDictionary(), ConnectionStrings.ConvertToConnectionStringDictionary()); if (parameters.Contains("AppServicePlan")) { WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, AppServicePlan); } break; case ParameterSet2Name: // Web app is direct or pipeline input string servicePlanName; string rg; location = WebApp.Location; siteConfig = WebApp.SiteConfig; // Update web app configuration WebsitesClient.UpdateWebAppConfiguration(ResourceGroupName, location, Name, Slot, siteConfig, WebApp.SiteConfig == null ? null : WebApp.SiteConfig.AppSettings.ToDictionary(nvp => nvp.Name, nvp => nvp.Value, StringComparer.OrdinalIgnoreCase), WebApp.SiteConfig == null ? null : WebApp.SiteConfig.ConnectionStrings.ToDictionary(nvp => nvp.Name, nvp => new ConnStringValueTypePair { Type = nvp.Type, Value = nvp.ConnectionString }, StringComparer.OrdinalIgnoreCase)); CmdletHelpers.TryParseAppServicePlanMetadataFromResourceId(WebApp.ServerFarmId, out rg, out servicePlanName); WebsitesClient.UpdateWebApp(ResourceGroupName, location, Name, Slot, servicePlanName); break; } WriteObject(WebsitesClient.GetWebApp(ResourceGroupName, Name, Slot)); }
public AdminController(IOptions <SiteConfig> siteConfig, PassportService passportService) { this.siteConfig = siteConfig.Value; this.passportService = passportService; }
public static bool ReferralFromSelf(SiteConfig siteConfig, string referral) { return SiteUtilities.ReferralFromSelf(siteConfig,referral); }
public static string RelativeToRoot(SiteConfig siteConfig, string relative) { return SiteUtilities.RelativeToRoot(siteConfig, relative); }
public static void UpdateSiteConfig(this IWebsitesServiceManagement proxy, string subscriptionName, string webspaceName, string name, SiteConfig siteConfig) { proxy.EndUpdateSiteConfig(proxy.BeginUpdateSiteConfig(subscriptionName, webspaceName, name, siteConfig, null, null)); }
public static void SaveEntry(Entry entry, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SiteUtilities.SaveEntry(entry,siteConfig,logService,dataService); }
private SiteConfig createSiteConfigWithFilter(string expression, string mapTo, bool isRegularExpression) { SiteConfig siteConfig = new SiteConfig(); siteConfig.ContentFilters.Add(createContentFilter(expression, mapTo, isRegularExpression)); return siteConfig; }
public static void SaveEntry(Entry entry, TrackbackInfoCollection trackbackList, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { SiteUtilities.SaveEntry(entry,trackbackList,crosspostList,siteConfig,logService,dataService); }
/// <summary> /// Update the website slot configuration /// </summary> /// <param name="name">The website name</param> /// <param name="newConfiguration">The website configuration object containing updates.</param> /// <param name="slot">The website slot name</param> public void UpdateWebsiteConfiguration(string name, SiteConfig newConfiguration, string slot) { name = SetWebsiteName(name, slot); UpdateWebsiteConfiguration(name, newConfiguration); }
public static EntrySaveState UpdateEntry(Entry entry, string trackbackUrl, CrosspostInfoCollection crosspostList, SiteConfig siteConfig, ILoggingDataService logService, IBlogDataService dataService) { return SiteUtilities.UpdateEntry(entry,trackbackUrl,crosspostList,siteConfig,logService,dataService); }
public void UpdateWebAppConfiguration(string resourceGroupName, string location, string webSiteName, string slotName, SiteConfig siteConfig = null, IDictionary<string, string> appSettings = null, IDictionary<string, ConnStringValueTypePair> connectionStrings = null) { string qualifiedSiteName; var useSlot = CmdletHelpers.ShouldUseDeploymentSlot(webSiteName, slotName, out qualifiedSiteName); if (useSlot) { if (siteConfig != null) { WrappedWebsitesClient.Sites.UpdateSiteConfigSlot(resourceGroupName, webSiteName, siteConfig, slotName); } if (appSettings != null) { WrappedWebsitesClient.Sites.UpdateSiteAppSettingsSlot(resourceGroupName, webSiteName, new StringDictionary { Location = location, Properties = appSettings}, slotName); } if (connectionStrings != null) { WrappedWebsitesClient.Sites.UpdateSiteConnectionStringsSlot(resourceGroupName, webSiteName, new ConnectionStringDictionary { Location = location, Properties = connectionStrings }, slotName); } } else { if (siteConfig != null) { WrappedWebsitesClient.Sites.UpdateSiteConfig(resourceGroupName, webSiteName, siteConfig); } if (appSettings != null) { WrappedWebsitesClient.Sites.UpdateSiteAppSettings(resourceGroupName, webSiteName, new StringDictionary { Location = location, Properties = appSettings }); } if (connectionStrings != null) { WrappedWebsitesClient.Sites.UpdateSiteConnectionStrings(resourceGroupName, webSiteName, new ConnectionStringDictionary { Location = location, Properties = connectionStrings }); } } }
/// <summary> /// Send an email notification that an entry has been made. /// </summary> /// <param name="siteConfig">The page making the request.</param> /// <param name="entry">The entry being added.</param> internal static void SendEmail(Entry entry, SiteConfig siteConfig, ILoggingDataService logService) { SiteUtilities.SendEmail(entry,siteConfig,logService); }
static async Task CreateSite(string rgName, string appServicePlanName, string siteName, string location) { // Create/Update the resource group var rgCreateResult = await _resourceGroupClient.ResourceGroups.CreateOrUpdateAsync(rgName, new ResourceGroup { Location = location }); // Create/Update the App Service Plan var serverFarmWithRichSku = new ServerFarmWithRichSku { Location = location, Sku = new SkuDescription { Name = "F1", Tier = "Free" } }; serverFarmWithRichSku = await _websiteClient.ServerFarms.CreateOrUpdateServerFarmAsync(rgName, appServicePlanName, serverFarmWithRichSku); // Create/Update the Website var site = new Site { Location = location, ServerFarmId = appServicePlanName }; site = await _websiteClient.Sites.CreateOrUpdateSiteAsync(rgName, siteName, site); // Create/Update the Website configuration var siteConfig = new SiteConfig { Location = location, PhpVersion = "5.6" }; siteConfig = await _websiteClient.Sites.CreateOrUpdateSiteConfigAsync(rgName, siteName, siteConfig); // Create/Update some App Settings var appSettings = new StringDictionary { Location = location, Properties = new Dictionary<string, string> { { "MyFirstKey", "My first value" }, { "MySecondKey", "My second value" } } }; await _websiteClient.Sites.UpdateSiteAppSettingsAsync(rgName, siteName, appSettings); // Create/Update some Connection Strings var connStrings = new ConnectionStringDictionary { Location = location, Properties = new Dictionary<string, ConnStringValueTypePair> { { "MyFirstConnString", new ConnStringValueTypePair { Value = "My SQL conn string", Type = DatabaseServerType.SQLAzure }}, { "MySecondConnString", new ConnStringValueTypePair { Value = "My custom conn string", Type = DatabaseServerType.Custom }} } }; await _websiteClient.Sites.UpdateSiteConnectionStringsAsync(rgName, siteName, connStrings); }
public static string GetAdminPageUrl(SiteConfig siteConfig) { return SiteUtilities.GetAdminPageUrl(siteConfig); }
private void GetCurrentSiteState() { website = WebsitesClient.GetWebsite(Name, Slot); currentSiteConfig = WebsitesClient.GetWebsiteConfiguration(Name, Slot); }
public static void UpdateSiteConfig(this IWebsitesServiceManagement proxy, string subscriptionId, string webspaceName, string name, SiteConfig siteConfig) { proxy.EndUpdateSiteConfig(proxy.BeginUpdateSiteConfig(subscriptionId, webspaceName, name, siteConfig, null, null)); }