public static JsonResponse Save(string hdr, string ftr)
        {
            var response = new JsonResponse {Success = false};

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
                BlogSettings.Instance.HtmlHeader = hdr;
                BlogSettings.Instance.TrackingScript = ftr;
                BlogSettings.Instance.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.HeadTrack.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Settings saved";
            return response;
        }
示例#2
0
        public JsonResponse Add(string roleName)
        {
            if (!Security.IsAuthorizedTo(Rights.CreateNewRoles))
            {
                return GetNotAuthorized();
            }
            else if (Utils.StringIsNullOrWhitespace(roleName))
            {
                return new JsonResponse() { Message = Resources.labels.roleNameIsRequired };
            }
            else if (Roles.RoleExists(roleName))
            {
                return new JsonResponse() { Message = string.Format(Resources.labels.roleAlreadyExists, roleName) };
            }
            else
            {
                var response = new JsonResponse();

                try
                {
                    Roles.CreateRole(roleName);
                    response.Success = true;
                    response.Message = string.Format(Resources.labels.roleHasBeenCreated, roleName);

                }
                catch (Exception ex)
                {
                    Utils.Log(string.Format("Roles.AddRole: {0}", ex.Message));
                    response.Success = false;
                    response.Message = string.Format(Resources.labels.couldNotCreateRole, roleName);
                }

                return response;
            }
        }
        public static JsonResponse Save(string name,
            string desc,
            string postsPerPage,
            string themeCookieName,
            string useBlogNameInPageTitles,
            string enableRelatedPosts,
            string enableRating,
            string showDescriptionInPostList,
            string descriptionCharacters,
            string showDescriptionInPostListForPostsByTagOrCategory,
            string descriptionCharactersForPostsByTagOrCategory,
            string timeStampPostLinks,
            string showPostNavigation,
            string culture,
            string timezone,
            string removeFileExtension)
        {
            var response = new JsonResponse { Success = false };

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
                BlogSettings.Instance.Name = name;
                BlogSettings.Instance.Description = desc;
                BlogSettings.Instance.PostsPerPage = int.Parse(postsPerPage);
                BlogSettings.Instance.ThemeCookieName = themeCookieName;
                BlogSettings.Instance.UseBlogNameInPageTitles = bool.Parse(useBlogNameInPageTitles);
                BlogSettings.Instance.EnableRelatedPosts = bool.Parse(enableRelatedPosts);
                BlogSettings.Instance.EnableRating = bool.Parse(enableRating);
                BlogSettings.Instance.ShowDescriptionInPostList = bool.Parse(showDescriptionInPostList);
                BlogSettings.Instance.DescriptionCharacters = int.Parse(descriptionCharacters);
                BlogSettings.Instance.ShowDescriptionInPostListForPostsByTagOrCategory =
                    bool.Parse(showDescriptionInPostListForPostsByTagOrCategory);
                BlogSettings.Instance.DescriptionCharactersForPostsByTagOrCategory =
                    int.Parse(descriptionCharactersForPostsByTagOrCategory);
                BlogSettings.Instance.TimeStampPostLinks = bool.Parse(timeStampPostLinks);
                BlogSettings.Instance.ShowPostNavigation = bool.Parse(showPostNavigation);
                BlogSettings.Instance.Culture = culture;
                BlogSettings.Instance.Timezone = double.Parse(timezone);
                BlogSettings.Instance.RemoveExtensionsFromUrls = bool.Parse(removeFileExtension);
                BlogSettings.Instance.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.Main.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Settings saved";
            return response;
        }
        public static JsonResponse Save(
			string email, 
			string smtpServer,
			string smtpServerPort,
			string smtpUserName,
			string smtpPassword,
			string sendMailOnComment,
			string enableSsl,
			string emailSubjectPrefix,
            string contactThankMessage,
            string contactDescription)
        {
            var response = new JsonResponse {Success = false};

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
                BlogSettings.Instance.Email = email;
                BlogSettings.Instance.SmtpServer = smtpServer;
                BlogSettings.Instance.SmtpServerPort = int.Parse(smtpServerPort);
                BlogSettings.Instance.SmtpUserName = smtpUserName;
                BlogSettings.Instance.SmtpPassword = smtpPassword;
                BlogSettings.Instance.SendMailOnComment = bool.Parse(sendMailOnComment);
                BlogSettings.Instance.EnableSsl = bool.Parse(enableSsl);
                BlogSettings.Instance.EmailSubjectPrefix = emailSubjectPrefix;
                BlogSettings.Instance.ContactThankMessage = contactThankMessage;
                BlogSettings.Instance.ContactFormMessage = contactDescription;

                BlogSettings.Instance.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.Email.Save(): {0}", ex.Message));
                response.Message = string.Format("Kon de instellingen niet opslaan: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Instellingen opgeslagen";
            return response;
        }
示例#5
0
文件: Tags.cs 项目: sagasu/tddLegacy
        public JsonResponse Edit(string id, string bg, string[] vals)
        {
            if (!WebUtils.CheckRightsForAdminPostPages(true))
            {
                return new JsonResponse { Success = false, Message = Resources.labels.notAuthorized };
            }
            if (Utils.StringIsNullOrWhitespace(id))
            {
                return new JsonResponse { Message = Resources.labels.idArgumentNull };
            }
            if (vals == null)
            {
                return new JsonResponse { Message = Resources.labels.valsArgumentNull };
            }
            if (vals.Length == 0 || Utils.StringIsNullOrWhitespace(vals[0]))
            {
                return new JsonResponse { Message = Resources.labels.tagIsRequired };
            }

            var response = new JsonResponse();
            try
            {
                foreach (var p in Post.Posts.ToArray())
                {
                    var tg = p.Tags.FirstOrDefault(tag => tag == id);
                    if(tg != null)
                    {
                        p.Tags.Remove(tg);
                        p.Tags.Add(vals[0]);
                        p.DateModified = DateTime.Now;
                        p.Save();
                    }
                }
                response.Success = true;
                response.Message = string.Format(Resources.labels.tagChangedFromTo, id, vals[0]);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("Tags.Update: {0}", ex.Message));
                response.Message = string.Format(Resources.labels.couldNotUpdateTag, vals[0]);
            }

            return response;
        }
        public static JsonResponse Save(
			string email, 
			string smtpServer,
			string smtpServerPort,
			string smtpUserName,
			string smtpPassword,
			string sendMailOnComment,
			string enableSsl,
			string emailSubjectPrefix)
        {
            var response = new JsonResponse {Success = false};

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
                BlogSettings.Instance.Email = email;
				BlogSettings.Instance.SmtpServer = smtpServer;
				BlogSettings.Instance.SmtpServerPort = int.Parse(smtpServerPort);
				BlogSettings.Instance.SmtpUserName = smtpUserName;
				BlogSettings.Instance.SmtpPassword = smtpPassword;
				BlogSettings.Instance.SendMailOnComment = bool.Parse(sendMailOnComment);
				BlogSettings.Instance.EnableSsl = bool.Parse(enableSsl);
				BlogSettings.Instance.EmailSubjectPrefix = emailSubjectPrefix;
			
                BlogSettings.Instance.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.Email.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Settings saved";
            return response;
        }
示例#7
0
文件: Posts.cs 项目: sagasu/tddLegacy
        public JsonResponse DeletePage(string id)
        {
            JsonResponse response = new JsonResponse();
            response.Success = false;

            if (string.IsNullOrEmpty(id))
            {
                response.Message = Resources.labels.pageIdRequired;
                return response;
            }

            var page = Page.GetPage(new Guid(id));
            if (page == null)
            {
                return new JsonResponse() { Message = Resources.labels.invalidPageId };
            }

            if (!page.CanUserDelete)
            {
                return new JsonResponse() { Message = Resources.labels.notAuthorized };
            }

            try
            {
                page.Delete();
                page.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("Api.Posts.DeletePage: {0}", ex.Message));
                response.Message = string.Format(Resources.labels.couldNotDeletePage, ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = Resources.labels.pageDeleted;
            return response;
        }
示例#8
0
        public JsonResponse GetDefaultRoleRights(string roleName)
        {
            if (!Security.IsAuthorizedTo(Rights.EditRoles))
            {
                return GetNotAuthorized();
            }
            else if (Utils.StringIsNullOrWhitespace(roleName))
            {
                return new JsonResponse() { Message = Resources.labels.roleNameArgumentNull };
            }

            List<Rights> defaultRights = Right.GetDefaultRights(roleName);

            var response = new JsonResponse()
            {
                Success = true,
                Data = string.Join("|", defaultRights.Select(r => Utils.FormatIdentifierForDisplay(r.ToString())).ToArray())
            };

            return response;
        }
示例#9
0
        public JsonResponse Edit(string id, string bg, string[] vals)
        {
            if (!Security.IsAuthorizedTo(Rights.EditRoles))
            {
                return GetNotAuthorized();
            }
            else if (Utils.StringIsNullOrWhitespace(id))
            {
                return new JsonResponse() { Message = Resources.labels.idArgumentNull };
            }
            else if (vals == null)
            {
                return new JsonResponse() { Message = Resources.labels.valsArgumentNull };
            }
            else if (vals.Length == 0 || Utils.StringIsNullOrWhitespace(vals[0]))
            {
                return new JsonResponse() { Message = Resources.labels.roleNameIsRequired };
            }

            var response = new JsonResponse();

            try
            {
                Right.OnRenamingRole(id, vals[0]);

                string[] usersInRole = Roles.GetUsersInRole(id);
                if (usersInRole.Length > 0)
                {
                    Roles.RemoveUsersFromRoles(usersInRole, new string[] { id });
                }

                Roles.DeleteRole(id);
                Roles.CreateRole(vals[0]);

                if (usersInRole.Length > 0)
                {
                    Roles.AddUsersToRoles(usersInRole, new string[] { vals[0] });
                }

                Right.RefreshAllRights();
               
                response.Success = true;
                response.Message = string.Format(Resources.labels.roleUpdatedFromTo, id, vals[0]);
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("Roles.UpdateRole: {0}", ex.Message));
                response.Message = string.Format(Resources.labels.couldNotUpdateRole, vals[0]);
            }

            return response;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="UserService"/> class.
 /// </summary>
 public UserService()
 {
     this.response = new JsonResponse();
 }
示例#11
0
 /// <summary>
 ///     Initializes a new instance of the <see cref = "Comments" /> class.
 /// </summary>
 public Comments()
 {
     this.response = new JsonResponse();
 }
示例#12
0
        public static JsonResponse SavePage(
            string id,
            string content,
            string title,
            string description,
            string keywords,
            string slug,
            bool isFrontPage,
            bool showInList,
            bool isPublished,
            string parent)
        {
            WebUtils.CheckRightsForAdminPagesPages(false);

            var response = new JsonResponse { Success = false };
            var settings = BlogSettings.Instance;

            if (string.IsNullOrEmpty(id) && !Security.IsAuthorizedTo(Rights.CreateNewPages))
            {
                response.Message = "Not authorized to create new Pages.";
                return response;
            }

            try
            {
                var page = string.IsNullOrEmpty(id) ? new BlogEngine.Core.Page() : BlogEngine.Core.Page.GetPage(new Guid(id));

                if (page == null)
                {
                    response.Message = "Page to Edit was not found.";
                    return response;
                }
                else if (!string.IsNullOrEmpty(id) && !page.CanUserEdit)
                {
                    response.Message = "Not authorized to edit this Page.";
                    return response;
                }

                bool isSwitchingToPublished = isPublished && (page.New || !page.IsPublished);

                if (isSwitchingToPublished)
                {
                    if (!page.CanPublish())
                    {
                        response.Message = "Not authorized to publish this Page.";
                        return response;
                    }
                }

                page.Title = title;
                page.Content = content;
                page.Description = description;
                page.Keywords = keywords;

                if (isFrontPage)
                {
                    foreach (var otherPage in BlogEngine.Core.Page.Pages.Where(otherPage => otherPage.IsFrontPage))
                    {
                        otherPage.IsFrontPage = false;
                        otherPage.Save();
                    }
                }

                page.IsFrontPage = isFrontPage;
                page.ShowInList = showInList;
                page.IsPublished = isPublished;

                if (!string.IsNullOrEmpty(slug))
                {
                    page.Slug = Utils.RemoveIllegalCharacters(slug.Trim());
                }

                if(string.IsNullOrEmpty(parent) || (parent.StartsWith("-- ") && parent.EndsWith(" --")))
                    page.Parent = Guid.Empty;
                else
                    page.Parent = new Guid(parent);

                page.Save();

                // If this is an unpublished page and the user does not have rights to
                // view unpublished pages, then redirect to the Pages list.
                if (page.IsVisible)
                    response.Data = page.RelativeLink;
                else
                    response.Data = string.Format("{0}admin/Pages/Pages.aspx", Utils.RelativeWebRoot);

            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("Admin.AjaxHelper.SavePage(): {0}", ex.Message));
                response.Message = string.Format("Could not save page: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Page saved";
            return response;
        }
示例#13
0
        public static JsonResponse TestSmtp(
            string email,
            string smtpServer,
            string smtpServerPort,
            string smtpUserName,
            string smtpPassword,
            string sendMailOnComment,
            string enableSsl,
            string emailSubjectPrefix
            )
        {
            var response = new JsonResponse { Success = false };

            StringBuilder errorMsg = new StringBuilder();

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }
            try
            {
                var mail = new MailMessage
                {
                    From = new MailAddress(email, smtpUserName),
                    Subject = string.Format("Test mail from {0}", smtpUserName),
                    IsBodyHtml = true
                };
                mail.To.Add(mail.From);
                var body = new StringBuilder();
                body.Append("<div style=\"font: 11px verdana, arial\">");
                body.Append("Success");
                if (HttpContext.Current != null)
                {
                    body.Append(
                        "<br /><br />_______________________________________________________________________________<br /><br />");
                    body.AppendFormat("<strong>IP address:</strong> {0}<br />", HttpContext.Current.Request.UserHostAddress);
                    body.AppendFormat("<strong>User-agent:</strong> {0}", HttpContext.Current.Request.UserAgent);
                }

                body.Append("</div>");
                mail.Body = body.ToString();

                string error = Utils.SendMailMessage(mail);
                if (!string.IsNullOrEmpty(error))
                    errorMsg.Append(error);
            }
            catch (Exception ex)
            {
                Exception current = ex;

                while (current != null)
                {
                    if (errorMsg.Length > 0) { errorMsg.Append(" "); }
                    errorMsg.Append(current.Message);
                    current = current.InnerException;
                }
            }

            if (errorMsg.Length > 0)
            {
                response.Message = string.Format("Error: {0}", errorMsg.ToString());
                return response;
            }

            response.Success = true;
            response.Message = "Test successful";
            return response;
        }
        public static JsonResponse Save(string enable, string days)
        {
            var response = new JsonResponse { Success = false };

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
                BlogSettings.Instance.EnableReferrerTracking = bool.Parse(enable);
                BlogSettings.Instance.NumberOfReferrerDays = int.Parse(days);
                BlogSettings.Instance.Save();
                response.Success = true;
                response.Message = string.Format("Settings saved");
                return response;
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Tracking.referrers.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }
        }
示例#15
0
        public JsonResponse GetRoleRights(string roleName)
        {
            if (!Security.IsAuthorizedTo(Rights.EditRoles))
            {
                return GetNotAuthorized();
            }
            else if (Utils.StringIsNullOrWhitespace(roleName))
            {
                return new JsonResponse() { Message = Resources.labels.roleNameArgumentNull };
            }

            IEnumerable<Right> roleRights = Right.GetRights(roleName);

            var response = new JsonResponse()
            {
                Success = true,
                Data = string.Join("|", roleRights.Select(r => r.DisplayName).ToArray())
            };

            return response;
        }
示例#16
0
        public static JsonResponse SavePost(
            string id,
            string content,
            string title,
            string desc,
            string slug,
            string tags,
            string author,
            bool isPublished,
            bool hasCommentsEnabled,
            string cats,
            string date,
            string time)
        {
            if (!WebUtils.CheckRightsForAdminPostPages(false)) { return null; }

            var response = new JsonResponse { Success = false };
            var settings = BlogSettings.Instance;

            if (string.IsNullOrEmpty(id) && !Security.IsAuthorizedTo(Rights.CreateNewPosts))
            {
                response.Message = "Not authorized to create new Posts.";
                return response;
            }

            try
            {
                var post = string.IsNullOrEmpty(id) ? new BlogEngine.Core.Post() : BlogEngine.Core.Post.GetPost(new Guid(id));
                if (post == null)
                {
                    response.Message = "Post to Edit was not found.";
                    return response;
                }
                else if (!string.IsNullOrEmpty(id) && !post.CanUserEdit)
                {
                    response.Message = "Not authorized to edit this Post.";
                    return response;
                }

                bool isSwitchingToPublished = isPublished && (post.New || !post.IsPublished);

                if (isSwitchingToPublished)
                {
                    if (!post.CanPublish(author))
                    {
                        response.Message = "Not authorized to publish this Post.";
                        return response;
                    }
                }

                if (string.IsNullOrEmpty(content))
                {
                    content = "[No text]";
                }
                post.Author = author;
                post.Title = title;
                post.Content = content;
                post.Description = desc;

                if (!string.IsNullOrEmpty(slug))
                {
                    post.Slug = Utils.RemoveIllegalCharacters(slug.Trim());
                }

                post.DateCreated =
                DateTime.ParseExact(date + " " + time, "yyyy-MM-dd HH\\:mm", null).AddHours(
                    -BlogSettings.Instance.Timezone);

                post.IsPublished = isPublished;
                post.HasCommentsEnabled = hasCommentsEnabled;

                post.Tags.Clear();
                if (tags.Trim().Length > 0)
                {
                    var vtags = tags.Trim().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var tag in
                        vtags.Where(tag => string.IsNullOrEmpty(post.Tags.Find(t => t.Equals(tag.Trim(), StringComparison.OrdinalIgnoreCase)))))
                    {
                        post.Tags.Add(tag.Trim());
                    }
                }

                post.Categories.Clear();
                if (cats.Trim().Length > 0)
                {
                    var vcats = cats.Trim().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var cat in vcats)
                    {
                        post.Categories.Add(Category.GetCategory(new Guid(cat)));
                    }
                }

                post.Save();

                // If this is an unpublished post and the user does not have rights to
                // view unpublished posts, then redirect to the Posts list.
                if (post.IsVisible)
                    response.Data = post.RelativeLink;
                else
                    response.Data = string.Format("{0}admin/Posts/Posts.aspx", Utils.RelativeWebRoot);

                HttpContext.Current.Session.Remove("content");
                HttpContext.Current.Session.Remove("title");
                HttpContext.Current.Session.Remove("description");
                HttpContext.Current.Session.Remove("slug");
                HttpContext.Current.Session.Remove("tags");
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("Admin.AjaxHelper.SavePost(): {0}", ex.Message));
                response.Message = string.Format("Could not save post: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Post saved";

            return response;
        }
示例#17
0
        public static JsonResponse Save(
			string syndicationFormat, 
			string postsPerFeed,
			string dublinCoreCreator,
            string feedemail,
			string dublinCoreLanguage,
			string geocodingLatitude,
			string geocodingLongitude,
			string blogChannelBLink,
			string alternateFeedUrl,
            string enableEnclosures)
        {
            var response = new JsonResponse {Success = false};

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {
				BlogSettings.Instance.SyndicationFormat = syndicationFormat;
				BlogSettings.Instance.PostsPerFeed = int.Parse(postsPerFeed, CultureInfo.InvariantCulture);
				BlogSettings.Instance.AuthorName = dublinCoreCreator;
                BlogSettings.Instance.FeedAuthor = feedemail;
				BlogSettings.Instance.Language = dublinCoreLanguage;

				float latitude;
				BlogSettings.Instance.GeocodingLatitude = Single.TryParse(
					geocodingLatitude.Replace(",", "."),
					NumberStyles.Any,
					CultureInfo.InvariantCulture,
					out latitude) ? latitude : Single.MinValue;

				float longitude;
				BlogSettings.Instance.GeocodingLongitude = Single.TryParse(
					geocodingLongitude.Replace(",", "."),
					NumberStyles.Any,
					CultureInfo.InvariantCulture,
					out longitude) ? longitude : Single.MinValue;

				BlogSettings.Instance.Endorsement = blogChannelBLink;

				if (alternateFeedUrl.Trim().Length > 0 && !alternateFeedUrl.Contains("://"))
				{
					alternateFeedUrl = string.Format("http://{0}", alternateFeedUrl);
				}

				BlogSettings.Instance.AlternateFeedUrl = alternateFeedUrl;
                BlogSettings.Instance.EnableEnclosures = bool.Parse(enableEnclosures);

                BlogSettings.Instance.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.Feed.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Settings saved";
            return response;
        }
示例#18
0
        public static JsonResponse Save(bool enableCompression, 
			bool enableOptimization,
            bool compressWebResource,
            bool enableOpenSearch,
            bool requireSslForMetaWeblogApi,
			string wwwSubdomain,
            /*bool enableTrackBackSend,
            bool enableTrackBackReceive,
            bool enablePingBackSend,
            bool enablePingBackReceive,*/
            bool enableErrorLogging,
            bool allowRemoteFileDownloads,
            int remoteTimeout,
            int remoteMaxFileSize,
            string galleryFeedUrl,
            string enablePasswordReset,
            string enableSelfRegistration,
            string selfRegistrationInitialRole)
        {
            var response = new JsonResponse { Success = false };
            var settings = BlogSettings.Instance;

            if (!WebUtils.CheckRightsForAdminSettingsPage(true))
            {
                response.Message = "Not authorized";
                return response;
            }

            try
            {

                // Validate values before setting any of them to the BlogSettings instance.
                // Because it's a singleton, we don't want partial data being stored to
                // it if there's any exceptions thrown prior to saving. 

                if (remoteTimeout < 0)
                {
                    throw new ArgumentOutOfRangeException("RemoteFileDownloadTimeout must be greater than or equal to 0 milliseconds.");
                }
                else if (remoteMaxFileSize < 0)
                {
                    throw new ArgumentOutOfRangeException("RemoteMaxFileSize must be greater than or equal to 0 bytes.");
                }  

                settings.EnableHttpCompression = enableCompression;
                settings.EnableOptimization = enableOptimization;
                settings.CompressWebResource = compressWebResource;
                settings.EnableOpenSearch = enableOpenSearch;
                settings.RequireSslMetaWeblogApi = requireSslForMetaWeblogApi;
                settings.HandleWwwSubdomain = wwwSubdomain;
                settings.EnableErrorLogging = enableErrorLogging;
                settings.GalleryFeedUrl = galleryFeedUrl;

                settings.AllowServerToDownloadRemoteFiles = allowRemoteFileDownloads;
                settings.RemoteFileDownloadTimeout = remoteTimeout;
                settings.RemoteMaxFileSize = remoteMaxFileSize;
                settings.EnablePasswordReset = bool.Parse(enablePasswordReset);
                settings.EnableSelfRegistration = bool.Parse(enableSelfRegistration);
                settings.SelfRegistrationInitialRole = selfRegistrationInitialRole;

                settings.Save();
            }
            catch (Exception ex)
            {
                Utils.Log(string.Format("admin.Settings.Advanced.Save(): {0}", ex.Message));
                response.Message = string.Format("Could not save settings: {0}", ex.Message);
                return response;
            }

            response.Success = true;
            response.Message = "Settings saved";
            return response;
        }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Profile"/> class.
 /// </summary>
 public Profile()
 {
     this.response = new JsonResponse();
 }