static IHtmlControl GetNewsEditPanel(SiteState state, TopicStorage topic) { LightObject news = topic.Topic; string blockHint = string.Format("news_edit_{0}", news.Id); IHtmlControl redoPanel = null; if (state.BlockHint == blockHint) { IHtmlControl deletePanel = null; if (state.ModeratorMode) { deletePanel = DeleteTopicPanel(state, topic); } if (state.Tag == null) { state.Tag = ViewTagHlp.GetTopicDisplayTags(context.Tags.TagBox, topic.Topic); } redoPanel = new HPanel( deletePanel, Decor.PropertyEdit("newsTitle", "Заголовок новости", news.Get(NewsType.Title)), new HPanel( HtmlHlp.CKEditorCreate("newsText", news.Get(NewsType.Text), "300px", true) ), ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, false), Decor.PropertyEdit("newsOriginName", "Источник", news.Get(NewsType.OriginName)), Decor.PropertyEdit("newsOriginUrl", "Ссылка", news.Get(NewsType.OriginUrl)), Decor.Button("Изменить новость").CKEditorOnUpdateAll().MarginTop(10) .Event("save_news_edit", "editNewsData", delegate(JsonData json) { string title = json.GetText("newsTitle"); string text = json.GetText("newsText"); string originName = json.GetText("newsOriginName"); string originUrl = json.GetText("newsOriginUrl"); WebOperation operation = state.Operation; if (!operation.Validate(title, "Не задан заголовок")) { return; } if (!operation.Validate(text, "Не задан текст")) { return; } LightKin editNews = DataBox.LoadKin(context.FabricConnection, NewsType.News, news.Id); editNews.SetWithoutCheck(NewsType.Title, title); editNews.Set(NewsType.Text, text); editNews.Set(NewsType.OriginName, originName); editNews.Set(NewsType.OriginUrl, originUrl); editNews.Set(ObjectType.ActTill, DateTime.UtcNow); ViewTagHlp.SaveTags(context, state, editNews); editNews.Box.Update(); context.UpdateNews(); context.NewsStorages.ForTopic(news.Id).UpdateTopic(); state.BlockHint = ""; }, news.Id ) ).EditContainer("editNewsData") .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground); } return(new HPanel( Decor.Button("Редактировать") .Event("news_edit", "", delegate { state.SetBlockHint(blockHint); } ), redoPanel ).MarginTop(10)); }
public static IHtmlControl GetRestorePasswordView(SiteState state) { return(new HPanel( Decor.Title("Восстановление пароля"), Decor.AuthEdit("login", "Введите логин:"), Decor.AuthEdit("email", "Или E-mail:"), new HPanel( Decor.Button("Выслать пароль на почту").Event("user_restore", "restoreData", delegate(JsonData json) { string login = json.GetText("login"); string email = json.GetText("email"); WebOperation operation = state.Operation; if (!operation.Validate(StringHlp.IsEmpty(login) && StringHlp.IsEmpty(email), "Введите логин или email")) { return; } LightObject findUser = null; if (!StringHlp.IsEmpty(login)) { string xmlLogin = UserType.Login.CreateXmlIds("", login); findUser = context.UserStorage.FindUser(xmlLogin); } else { foreach (LightObject user in context.UserStorage.All) { if (user.Get(BasketballUserType.Email) == email) { findUser = user; break; } } } if (!operation.Validate(findUser == null, "Пользователь не найден")) { return; } try { HElement answer = h.Div( h.P(string.Format("Ваш логин: {0}", findUser.Get(BasketballUserType.Login))), h.P(string.Format("Ваш пароль: {0}", findUser.Get(BasketballUserType.Password))) ); SiteSettings settings = SiteContext.Default.SiteSettings; SmtpClient smtpClient = AuthHlp.CreateSmtpClient( settings.SmtpHost, settings.SmtpPort, settings.SmtpUserName, settings.SmtpPassword); AuthHlp.SendMail(smtpClient, settings.MailFrom, findUser.Get(BasketballUserType.Email), "Восстановление пароля", answer.ToHtmlText() ); } catch (Exception ex) { Logger.WriteException(ex); operation.Validate(true, string.Format("Непредвиденная ошибка при отправке заявки: {0}", ex.Message)); return; } operation.Message = "Пароль выслан вам на почту"; } ) ) ).EditContainer("restoreData")); }
public GetGroupsOperationResult Execute() { return(new GetGroupsOperationResult(WebOperation.Execute(new WebOperationCriteria(WebOperationURLs.GetURL(GetType()), GetFieldDictionaryFromCriteria(_getGroupsOperationCriteria))))); }
public static IHtmlControl GetActualNewsBlock(SiteState state, LightObject currentUser) { IHtmlControl[] items = ViewNewsHlp.GetNewsItems(state, context.ActualNews); HPanel editBlock = null; string editHint = "news_add"; if (state.BlockHint == editHint) { if (state.Tag == null) { state.Tag = new List <string>(); } string unsaveText = BasketballHlp.AddCommentFromCookie(); editBlock = new HPanel( Decor.PropertyEdit("newsTitle", "Заголовок новости"), new HPanel( HtmlHlp.CKEditorCreate("newsText", unsaveText, "300px", true) ), ViewTagHlp.GetEditTagsPanel(state, context.Tags.TagBox, state.Tag as List <string>, true), Decor.PropertyEdit("newsOriginName", "Источник"), Decor.PropertyEdit("newsOriginUrl", "Ссылка"), Decor.Button("Добавить новость").MarginTop(10) //.CKEditorOnUpdateAll() .OnClick(string.Format("CK_updateAll(); {0}", BasketballHlp.AddCommentToCookieScript("newsText"))) .Event("save_news_add", "addNewsData", delegate(JsonData json) { string title = json.GetText("newsTitle"); string text = json.GetText("newsText"); string originName = json.GetText("newsOriginName"); string originUrl = json.GetText("newsOriginUrl"); WebOperation operation = state.Operation; if (!operation.Validate(title, "Не задан заголовок")) { return; } if (!operation.Validate(text, "Не задан текст")) { return; } ParentBox editBox = new ParentBox(context.FabricConnection, "1=0"); int addNewsId = editBox.CreateObject(NewsType.News, NewsType.Title.CreateXmlIds(title), DateTime.UtcNow); LightParent editNews = new LightParent(editBox, addNewsId); editNews.Set(NewsType.PublisherId, currentUser.Id); editNews.Set(NewsType.Text, text); editNews.Set(NewsType.OriginName, originName); editNews.Set(NewsType.OriginUrl, originUrl); ViewTagHlp.SaveTags(context, state, editNews); editBox.Update(); context.UpdateNews(); state.BlockHint = ""; state.Tag = null; BasketballHlp.ResetAddComment(); } ) ).EditContainer("addNewsData").Padding(5, 10).MarginTop(10).Background(Decor.pageBackground); } IHtmlControl addButton = null; if (currentUser != null && !BasketballHlp.NoRedactor(currentUser)) { addButton = Decor.Button("Добавить").MarginLeft(10) .Event("news_add", "", delegate { state.Tag = null; state.SetBlockHint(editHint); } ); } return(new HPanel( Decor.Subtitle("Новости"), new HPanel( items.ToArray() ), new HPanel( new HLink("/novosti", "Все новости", new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2) ).FontBold(), addButton ).MarginTop(15), editBlock )); }
public static IHtmlControl GetActualArticleBlock(SiteState state, LightObject currentUser) { IHtmlControl[] items = ViewArticleHlp.GetArticleItems(state, context.ActualArticles); HPanel editBlock = null; if (state.BlockHint == "articleAdd") { editBlock = new HPanel( Decor.PropertyEdit("addArticleTitle", "Заголовок статьи"), Decor.Button("Добавить статью").MarginTop(10) .Event("article_add_save", "addArticleData", delegate(JsonData json) { string title = json.GetText("addArticleTitle"); WebOperation operation = state.Operation; if (!operation.Validate(title, "Не задан заголовок")) { return; } ObjectBox editBox = new ObjectBox(context.FabricConnection, "1=0"); int addArticleId = editBox.CreateObject( ArticleType.Article, ArticleType.Title.CreateXmlIds(title), DateTime.UtcNow ); LightObject editArticle = new LightObject(editBox, addArticleId); editArticle.Set(ArticleType.PublisherId, currentUser.Id); editBox.Update(); context.UpdateArticles(); state.BlockHint = ""; state.RedirectUrl = UrlHlp.ShopUrl("article", addArticleId); } ) ).EditContainer("addArticleData") .Padding(5, 10).MarginTop(10).Background(Decor.pageBackground); } HButton addButton = null; if (currentUser != null && !BasketballHlp.NoRedactor(currentUser)) { addButton = Decor.Button("Добавить").Hide(currentUser == null).MarginLeft(10) .Event("article_add", "", delegate { state.SetBlockHint("articleAdd"); } ); } return(new HPanel( Decor.Subtitle("Статьи").MarginBottom(12), new HPanel( items.ToArray() ), new HPanel( new HLink("/stati", "Все статьи", new HBefore().ContentIcon(5, 12).BackgroundImage(UrlHlp.ImageUrl("pointer.gif")).MarginRight(5).VAlign(-2) ).FontBold(), addButton ).MarginTop(15), editBlock ).MarginTop(10)); }
static IHtmlControl GetArticleEditPanel(SiteState state, TopicStorage topic) { LightObject article = topic.Topic; string blockHint = string.Format("article_edit_{0}", article.Id); IHtmlControl redoPanel = null; if (state.BlockHint == blockHint) { IHtmlControl deletePanel = null; if (state.ModeratorMode) { deletePanel = ViewNewsHlp.DeleteTopicPanel(state, topic); } redoPanel = new HPanel( deletePanel, new HPanel( Decor.PropertyEdit("editArticleTitle", "Заголовок статьи", article.Get(NewsType.Title)), new HPanel( new HLabel("Аннотация").FontBold(), new HTextArea("editArticleAnnotation", article.Get(NewsType.Annotation)) .Width("100%").Height("4em").MarginBottom(5) ), new HPanel( new HInputCheck( "editArticleWideContent", article.Get(ArticleType.WideContent), new HAfter().Content("Таблицы шире колонки статьи").MarginLeft(18).MarginBottom(1) ).NoWrap() ).MarginBottom(5), HtmlHlp.CKEditorCreate("editArticleText", article.Get(NewsType.Text), "300px", true), Decor.PropertyEdit("editArticleAuthor", "Автор", article.Get(ArticleType.Author)), Decor.PropertyEdit("editArticleOriginName", "Источник (без префикса http://)", article.Get(NewsType.OriginName)), Decor.PropertyEdit("editArticleOriginUrl", "Ссылка (с префиксом http://)", article.Get(NewsType.OriginUrl)), Decor.Button("Сохранить статью").CKEditorOnUpdateAll().MarginTop(10).MarginBottom(10) .Event("save_article_edit", "editArticleData", delegate(JsonData json) { string title = json.GetText("editArticleTitle"); string annotation = json.GetText("editArticleAnnotation"); bool wideContent = json.GetBool("editArticleWideContent"); string text = json.GetText("editArticleText"); string author = json.GetText("editArticleAuthor"); string originName = json.GetText("editArticleOriginName"); string originUrl = json.GetText("editArticleOriginUrl"); WebOperation operation = state.Operation; if (!operation.Validate(title, "Не задан заголовок")) { return; } if (!operation.Validate(text, "Не задан текст")) { return; } LightObject editNews = DataBox.LoadObject(context.FabricConnection, ArticleType.Article, article.Id); editNews.SetWithoutCheck(NewsType.Title, title); editNews.Set(ArticleType.WideContent, wideContent); editNews.Set(NewsType.Annotation, annotation); editNews.Set(NewsType.Text, text); editNews.Set(ArticleType.Author, author); editNews.Set(NewsType.OriginName, originName); editNews.Set(NewsType.OriginUrl, originUrl); editNews.Set(ObjectType.ActTill, DateTime.UtcNow); editNews.Box.Update(); context.UpdateArticles(); context.ArticleStorages.ForTopic(article.Id).UpdateTopic(); state.BlockHint = ""; }, article.Id ) ).EditContainer("editArticleData"), new HPanel( EditElementHlp.GetImageThumb(article.Id) ), new HPanel( EditElementHlp.GetDescriptionImagesPanel(state.Option, article.Id) ) ).Padding(5, 10).MarginTop(10).Background(Decor.pageBackground); } return(new HPanel( Decor.Button("Редактировать") .Event("article_edit", "", delegate { state.SetBlockHint(blockHint); } ), redoPanel ).MarginTop(5)); }
public static IEnumerable <Scan> GetScans(CxRestContext ctx, CancellationToken token, int projectId) { int curPage = 1; List <Scan> osaScans = new List <Scan>(); Func <int, String> url = (pg) => CxRestContext.MakeUrl(ctx.Url, URL_SUFFIX, new Dictionary <String, String>() { { "projectId", Convert.ToString(projectId) }, { "page", Convert.ToString(pg) }, { "itemsPerPage", PAGE_SIZE } }); while (true) { if (token.IsCancellationRequested) { return(null); } var beforeCount = osaScans.Count; var scans = WebOperation.ExecuteGet <IEnumerable <Scan> >(ctx.Json.CreateSastClient , (response) => { using (var sr = new StreamReader(response.Content.ReadAsStreamAsync().Result)) using (var jtr = new JsonTextReader(sr)) { JToken jt = JToken.Load(jtr); return(new ScansReader(jt, projectId)); } } , url(curPage++) , ctx , token , (response) => { if (response.StatusCode == System.Net.HttpStatusCode.Forbidden) { _log.Debug("403 response indicates OSA is not licensed for this instance."); return(false); } return(true); }); if (scans != null) { osaScans.AddRange(scans); } if (osaScans.Count == beforeCount) { break; } } return(osaScans); }
/// <summary> /// Executes the RegisterOperation. /// </summary> /// <returns>A RegisterOperationResult containing the result of the operation.</returns> public RegisterOperationResult Execute() { ResultSet resultSet = WebOperation.Execute(new WebOperationCriteria(WebOperationURLs.GetURL(GetType()), CreateFieldDictionaryFromCriteria(_criteria))); return(CreateResultFromResultSet(resultSet)); }
public static HPanel OperationState(WebOperation operation) { //HHover closeHover = new HHover().Background(Color.FromArgb(189, 216, 249)); HBefore alert = new HBefore().Content(@"!").CssAttribute("border-radius", 5).MarginRight(4); return new HPanel( new HButton("", new HAfter().Content(@"\2A2F").FontWeight("700").FontSize("125%")) .CssAttribute("margin-top", "-6px") .MarginRight("4px").FloatRight().Color("#4e545b") .Event("currentOperationState_Hide", "currentOperationState", delegate(JsonData json) { operation.Message = ""; } ), new HLabel(operation.Message, alert).Padding(10, 12, 8, 12) ).EditContainer("currentOperationState"). CssAttribute("position", "relative").Display("inline-block"). Border("2px", "outset", Color.Blue, "2px").Color(Color.FromArgb(220, 50, 47)). Background(Color.LightBlue).WidthLimit("200px", ""). Hide(operation.Completed || StringHlp.IsEmpty(operation.Message)); }
public static HPanel OperationWarning(WebOperation operation) { string titleColor = "#FFF"; // "#F1F6CD"; string titleBackground = "#880000"; // "#CC0000"; // "#597BA5"; return new HPanel( new HPanel( new HLabel("", new HBefore().Content(@"\f0e7") .Color(titleColor).Opacity("0.6").FontFamily("FontAwesome").FontBold() ).Cursor("default"), new HLabel(operation.Message).MarginLeft(8) .Color(titleColor).FontFamily("Arial").FontSize("13px").FontBold(), new HButton("", new HAfter().Content(@"\f00d") .FontFamily("FontAwesome").FontSize("1.15em"), new HHover().Opacity("1") ).FloatRight().MarginTop(-1).Color("#FFF").Opacity("0.6") .Event("warning_hide", "", delegate (JsonData json) { operation.Reset(); }) ).Padding(6, 10, 7, 14).Background(titleBackground).BorderRadius(16) ).Hide(operation.Completed || StringHlp.IsEmpty(operation.Message)) .MarginTop(12); }
public static IHtmlControl GetAuthBlock(HttpContext httpContext, SiteState state, LightObject currentUser) { HImage keyImage = new HImage(UrlHlp.ImageUrl("key.gif")).MarginRight(8).VAlign(false); if (currentUser == null) { return(new HPanel( keyImage, new HTextEdit("authLogin").Width(90).MarginRight(5), new HPasswordEdit("authPassword").Width(90).MarginRight(5), Decor.Button("Войти").Event("user_login", "loginData", delegate(JsonData json) { string login = json.GetText("authLogin"); string password = json.GetText("authPassword"); WebOperation operation = state.Operation; if (!operation.Validate(login, "Введите логин")) { return; } if (!operation.Validate(password, "Введите пароль")) { return; } string xmlLogin = UserType.Login.CreateXmlIds("", login); LightObject user = SiteContext.Default.UserStorage.FindUser(xmlLogin); if (!operation.Validate(user == null, "Логин не найден")) { return; } if (!operation.Validate(user.Get(UserType.Password) != password, "Неверный пароль")) { return; } if (!operation.Validate(user.Get(UserType.NotConfirmed), "Ваш аккаунт не подтвержден через электронную почту. Письмо для подтверждения выслано вам на почту еще раз.")) { try { BasketballHlp.SendRegistrationConfirmation(user.Id, login, user.Get(UserType.Email)); } catch (Exception ex) { Logger.WriteException(ex); } return; } if (!operation.Validate(BasketballHlp.IsBanned(user), string.Format("Вы заблокированы до {0} и не можете войти на сайт", user.Get(BasketballUserType.BannedUntil)?.ToLocalTime().ToString("dd-MM-yyyy HH:mm") ) )) { return; } httpContext.SetUserAndCookie(xmlLogin); } ), new HPanel( new HPanel(new HLink("/register", "Регистрация")) .MediaSmartfon(new HStyle().InlineBlock()), new HPanel(new HLink("/passwordreset", "Забыли пароль")) .MediaSmartfon(new HStyle().InlineBlock().MarginLeft(10)) ).Align(true).InlineBlock().MarginLeft(5).FontSize("80%").VAlign(false) .MediaSmartfon(new HStyle().Block().MarginLeft(18)) ).EditContainer("loginData").PositionRelative().InlineBlock().MarginTop(10) .MediaTablet(new HStyle().MarginTop(5)) .MediaSmartfon(new HStyle().MarginTop(0))); } HButton moderatorButton = null; if (currentUser.Get(BasketballUserType.IsModerator)) { moderatorButton = new HButton("", std.BeforeAwesome(@"\f1e2", 0) ).Title("Режим модерирования").MarginRight(3).MarginLeft(5).FontSize(14) .Color(state.ModeratorMode ? Decor.redColor : Decor.disabledColor) .Event("moderator_mode_set", "", delegate { state.ModeratorMode = !state.ModeratorMode; }); } return(new HPanel( keyImage, new HLabel("Здравствуйте,").MarginRight(5), new HLink(UrlHlp.ShopUrl("user", currentUser.Id), currentUser.Get(UserType.FirstName)).FontBold(), new HLabel("!"), moderatorButton, Decor.Button("Выйти").MarginLeft(5).Event("user_logout", "", delegate(JsonData json) { httpContext.Logout(); } ) ).InlineBlock().MarginTop(10)); }