namespace RSIwelcome
{
/// <summary>
/// Description for WebPart1.
/// </summary>
[DefaultProperty("Text"),
ToolboxData("<{0}:WebPart1 runat=server></{0}:WebPart1>"),
XmlRoot(Namespace = "RSIwelcome")]
public class RSIwelcome : Microsoft.SharePoint.WebPartPages.WebPart
{
private const string defaultText = "";
private string text = defaultText;
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(defaultText),
WebPartStorage(Storage.Personal),
FriendlyName("Text"),
Description("Text Property")]
public string Text
{
get
{
return text;
}
set
{
text = value;
}
}
public string getTime()
{
string strTimeStatus = "";
int gHour = DateTime.Now.Hour;
if (gHour > 2 && gHour < 12)
{
strTimeStatus = "早安! ";
}
else if (gHour > 11 && gHour < 19)
{
strTimeStatus = "午安! ";
}
else if (gHour > 18 || gHour < 3)
{
strTimeStatus = "晚安! ";
}
return strTimeStatus;
}
protected override void RenderWebPart(HtmlTextWriter output)
{
string sUserName = Context.User.Identity.Name;
sUserName = sUserName.Substring(sUserName.IndexOf("\\") + 1);
string strUI = "<font size=3 color='#0000FF'><b>Hi! " + getUserName(sUserName) + " " + getTime() + "</b></font>";
output.Write(strUI);
}
}
}
浙公网安备 33010602011771号