本文整理汇总了C#中System.Web.HttpContext.UserName方法的典型用法代码示例。如果您正苦于以下问题:C# HttpContext.UserName方法的具体用法?C# HttpContext.UserName怎么用?C# HttpContext.UserName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.HttpContext
的用法示例。
在下文中一共展示了HttpContext.UserName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Page
static HElement Page(MailState state, HttpContext httpContext)
{
try
{
string viewKind = httpContext.Get("view") ?? "inbox";
int? displayPage = httpContext.GetUInt("page");
int? messageId = httpContext.GetUInt("id");
//Logger.AddMessage("ViewKind: {0}, {1}", viewKind, state.MessageSendError);
bool guest = httpContext.UserName() == null;
string title;
IHtmlControl mainPanel = new HPanel("main",
std.RowPanel(
new HHoverDropdown(
new HDropStyle().
DropList(new HTone()
.Left("0px").Top("20px")
.Padding(4)
),
new HButton("Все проекты"),
new HLink(@"https://r.mail.ru/n211655019", "Авто"),
new HLink(@"https://r.mail.ru/n211655021", "Гороскопы"),
new HLink(@"https://r.mail.ru/n211655026", "Погода")
).Hide(true),
std.DockFill(),
//new HPanel(
// new HPanel().Size(1200, 10)
//).Width("100%").WidthLimit("100px", "0").Overflow("hidden"),
ViewHlp.GetAuthPanel(MailContext.Default.DbConnection, httpContext, state)
),
new HXPanel().HeightLimit("3em", "").Background(Color.FromArgb(22, 141, 226)),
//ViewHlp.GetButtonPanel(httpContext, state, viewKind).Hide(guest),
new HXPanel(
new HPanel(ViewHlp.GetLeftPanel(httpContext, state, viewKind)),
ViewHlp.GetCenterPanel(httpContext, state, viewKind, displayPage, messageId, out title)
//new HPanel("left",
// ViewHlp.GetLeftGrid(state, viewKind)
//).Height("40em").Padding(0, 5, 5, 20).Background(Color.WhiteSmoke).Border("2px", "solid", Color.DarkGray, ""),
//new HPanel("center",
// ViewHlp.GetCenterPanel(httpContext, state, viewKind, page, messageId)
//).Width("100%").WidthLimit("", "0").Background(Color.WhiteSmoke).Border("2px", "solid", Color.DarkGray, "")
).HeightLimit("600px", "").Hide(guest),
new HPanel("test",
new HSpoiler("SPOILER", new HSpan("Lorem ipsum dolor sit amet, consectetur adipisicing elit. Amet aspernatur dolorem ducimus eaque! Alias assumenda, blanditiis dignissimos facilis fuga ipsam molestias necessitatibus nostrum numquam raesentium quo sed sit! Aut, vitae?"))
),
new HPanel("debug",
new HSpan(string.Format("{0}{1}{1}{2}", state.lastJson, Environment.NewLine, state.Authorization))).
Align(null, null).Border("10px", "solid", Color.Gray, "3px").Background(Color.WhiteSmoke).
Hide(!state.Authorization),
std.OperationState(state.Operation).Top("2em").Right("0")
).WidthLimit("800px", "").EditContainer("allData");
StringBuilder css = new StringBuilder();
//HtmlHlp.AddClassToCss(css, buttonStyle);
HElement mainElement = mainPanel.ToHtml("main", css);
if (guest)
title = "Авторизация - Почта";
return h.Html
(
h.Head(
),
h.Body(
h.Element("title", title),
h.LinkCss("font/font.css"),
h.LinkScript("ckeditor/ckeditor.js"),
h.Script(@"
function CK_updateAll()
{
try
{
for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].updateElement();
}
catch(ex)
{
console.log(ex);
}
}
"),
h.Css(h.Raw(css.ToString())
),
mainElement
// h.Script(@"
// function CK_updateAll()
// {
// for (instance in CKEDITOR.instances)
// CKEDITOR.instances[instance].updateElement();
// }
// ")
//h.Script(new HAttribute("data-sample", "1"), @"CKEDITOR.replace( 'editor1' );")
)
);
}
//.........这里部分代码省略.........
示例2: GetLeftPanel
//public static HXPanel GetButtonPanel(HttpContext httpContext, MailState state, string viewKind)
//{
// string user = httpContext.UserName();
// if (viewKind == "inbox")
// {
// return new HXPanel("inboxButtonPanel",
// new HLink("/?view=messageNew", ViewHlp.IconButton("Написать письмо", @"\270e")).Color(Color.Black),
// new HPanel(
// new HPanel().Width("64px")
// ),
// ViewHlp.IconButton("Удалить", @"\25a9").
// //LinearGradient("to bottom", Color.FromArgb(201, 201, 201), Color.FromArgb(241, 241, 241)).
// Margin(0, 10).VAlign(null),
// new HPanel(new HPanel().Width("10px")),
// ViewHlp.IconButton("Спам", @"\2639").VAlign(null),
// new HPanel(new HCheckEdit("testCheckEdit", state.Authorization).Margin(0, 10)).VAlign(null),
// new HPanel(new HTextEdit("testTextEdit", "").Placeholder("Введите сообщение...")).VAlign(null),
// new HPanel(new HComboEdit<string>("testComboEdit", "второй", null, null, "первый", "второй").
// Margin(0, 10)).VAlign(null),
// new HPanel(
// std.Button("Отправить"). //, new HImage(@"/Images/icss_pseudo-class.png")).
// ToolTip("Отправить Json на сервер").
// Event("send", "testData", delegate (JsonData json)
// {
// state.Authorization = json.GetData("testCheckEdit").ToString_Fair() == "True";
// })
// ).VAlign(null),
// new HPanel(
// new HPanel().Size(1200, 10)
// ).Width("100%"), //.WidthLimit("100px", "0").Overflow("hidden"),
// new HPanel(std.Button("Вид")).Hide(!state.Authorization)
// ).EditContainer("testData").Padding("10px").Background(Color.Wheat);
// }
// if (viewKind == "messageNew")
// {
// return std.RowPanel(
// std.Button("Сохранить").MarginLeft(250).MarginRight(10).
// OnClick("CK_updateAll();").
// Event("sendMail", "allData",
// delegate(JsonData json)
// {
// try
// {
// string recipient = json.GetData("recipientTextEdit").ToString_Fair();
// string subject = json.GetData("subjectTextEdit").ToString_Fair();
// string mailText = json.GetData("mailText").ToString_Fair();
// TraceHlp.AddMessage("Json.SendMail: {0}, {1}, {2}", recipient, subject, mailText);
// state.lastJson = json;
// Logger.AddMessage("Recipient: '{0}'", recipient);
// if (StringHlp.IsEmpty(recipient))
// {
// state.Operation.Error = "Не заполнено поле 'Кому'";
// Logger.AddMessage("Ошибка валидации");
// return;
// }
// object result = MailContext.Default.DbConnection.GetScalar("",
// "Insert Into letter (sender, recipient, time, subject, content) Values (@sender, @recipient, @time, @subject, @content)",
// new DbParameter("sender", user),
// new DbParameter("recipient", recipient),
// new DbParameter("time", DateTime.UtcNow),
// new DbParameter("subject", subject),
// new DbParameter("content", mailText)
// );
// Logger.AddMessage("Письмо сохранено: {0}", result);
// state.Operation.Completed = true;
// }
// catch (Exception ex)
// {
// TraceHlp.WriteException(ex);
// state.Operation.Error = "Непредвиденная ошибка сохранения в базу данных";
// }
// }),
// new HLink(@"/?view=inbox", std.Button("Отмена")).Color(Color.Black)
// );
// }
// return new HXPanel(new HSpan(viewKind));
//}
public static IHtmlControl GetLeftPanel(HttpContext httpContext, MailState state, string viewKind)
{
string user = httpContext.UserName();
return new HPanel(
std.RowPanel(
new HLink("/?view=messageNew", SeptStd.IconButton("Написать письмо", @"\270e")).MarginLeft(10).Color(Color.Black)
).Padding("10px"),
new HPanel(
new HTableGrid("viewKind",
new HRowStyle()
.AnyRow(new HTone().Padding("4px"))
.ALink(delegate(DisplayName mode)
{
//.........这里部分代码省略.........
示例3: GetCenterPanel
public static IHtmlControl GetCenterPanel(HttpContext httpContext, MailState state,
string viewKind, int? displayPage, int? messageId, out string title)
{
string user = httpContext.UserName();
title = string.Format(" - {0} - Почта", user);
if (viewKind == "inbox" || viewKind == "sent" || viewKind == "trash")
{
if (viewKind == "inbox")
title = "Входящие" + title;
else if (viewKind == "sent")
title = "Отправленные" + title;
else
title = "Корзина" + title;
int pageNumber = displayPage != null ? displayPage.Value - 1 : 0;
int limit = 15;
bool isSent = viewKind == "sent";
string condition = "recipient = @address and folder is null";
if (viewKind == "sent")
{
condition = "sender = @address and folder is null";
}
if (viewKind == "trash")
{
condition = "(recipient = @address or sender = @address) and folder is not null";
}
int letterCount = DatabaseHlp.RowCount(dbConnection, "", "letter", condition, new DbParameter("address", user));
Point pageInterval = DataHlp.GetPageInterval(letterCount, limit, 5, ref pageNumber);
TableLink letterTable = TableLink.LoadTableLink(MailContext.Default.DbConnection, null,
new FieldBlank[] { LetterType.Id, LetterType.Sender, LetterType.Recipient,
LetterType.Time, LetterType.Subject, LetterType.Read },
new IndexBlank[] { LetterType.LetterById },
"", "Select id, sender, recipient, time, subject, read From letter",
string.Format("{0} order by time desc limit {1} offset {2}", condition, limit, pageNumber * limit),
new DbParameter("address", user)
);
List<IHtmlControl> paginatorControls = new List<IHtmlControl>(7);
for (int i = pageInterval.X; i <= pageInterval.Y; ++i)
{
if (i == pageNumber)
{
paginatorControls.Add(
new HSpan((i + 1).ToString()).Padding(6, 8).Background("#ededed").Display("inline-block")
);
continue;
}
paginatorControls.Add(
new HLink(string.Format("/?view={0}&page={1}", viewKind, i + 1), (i + 1).ToString())
.Padding(6, 8).Display("inline-block").Color(Color.Black).CssAttribute("text-decoration", "none")
);
}
ICollection<UniversalKey> keys = letterTable.KeysForIndex(LetterType.LetterById);
return new HPanel(
std.RowPanel(
SeptStd.IconButton("Удалить", @"\25a9").MarginRight(10)
.Event("delete_letter", "mailListData", delegate(JsonData json)
{
List<int> selectedIds = DataHlp.GetSelectedLetterIds(json, letterTable);
if (selectedIds.Count == 0)
{
state.Operation.Error = "Нет выбранных писем";
return;
}
dbConnection.GetScalar("", string.Format(
"delete from letter Where id in ({0})",
StringHlp.Join(", ", "{0}", selectedIds)
));
}),
SeptStd.IconButton(viewKind == "trash" ? "Восстановить" : "Корзина", @"\2639").MarginRight(10)
.Event("move_letter_to_trash", "mailListData", delegate(JsonData json)
{
List<int> selectedIds = DataHlp.GetSelectedLetterIds(json, letterTable);
if (selectedIds.Count == 0)
{
state.Operation.Error = "Нет выбранных писем";
return;
}
dbConnection.GetScalar("", string.Format(
"update letter Set folder = {0} Where id in ({1})",
viewKind != "trash" ? "'trash'" : "null",
StringHlp.Join(", ", "{0}", selectedIds)
));
}),
//OnClick("$('input:checkbox').removeAttr('checked');"),
ViewHlp.MoreComboButton(state, letterTable),
std.DockFill(),
new HPanel(paginatorControls.ToArray()).Border("1px", "solid", "#bbb", "2px").VAlign(null).NoWrap(),
new HPanel().Width("30px"),
std.Button("Вид")
//.........这里部分代码省略.........
示例4: GetAuthPanel
public static IHtmlControl GetAuthPanel(IDataLayer mailConnection, HttpContext context, MailState state)
{
if (context.UserName() == null)
{
return std.RowPanel(
new HTextEdit("loginEdit").Placeholder("Введите логин...").MarginRight(10),
new HPasswordEdit("passwordEdit").MarginRight(10),
std.Button("Войти", 0, 12).
Event("loginUser", "loginData", delegate(JsonData json)
{
string login = json.GetText("loginEdit");
string password = json.GetText("passwordEdit");
if (StringHlp.IsEmpty(login))
{
state.Operation.Error = "Не задан логин";
return;
}
if (StringHlp.IsEmpty(password))
{
state.Operation.Error = "Не задан пароль";
return;
}
int count = DatabaseHlp.RowCount(mailConnection, "", "account",
"login = @login and password = @password",
new DbParameter("login", login), new DbParameter("password", password));
if (count == 0)
{
state.Operation.Error = "Неверный логин или пароль";
return;
}
context.SetUserAndCookie(login);
})
).EditContainer("loginData").Padding(6);
}
return std.RowPanel(
new HLabel(context.UserName()).MarginRight(10),
std.Button("Выйти", 0, 12).
Event("logoutUser", "authData", delegate(JsonData json)
{
context.SetUserAndCookie(null);
})
).EditContainer("logoutData").Padding(6);
}