This commit is contained in:
169
source/WBI/dashboard.aspx.cs
Normal file
169
source/WBI/dashboard.aspx.cs
Normal file
@@ -0,0 +1,169 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
using System.Configuration;
|
||||
using System.Collections;
|
||||
using System.Web;
|
||||
using System.Web.Security;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.WebControls.WebParts;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using GZTW.AyaNova.BLL;
|
||||
|
||||
public partial class dashboard : BaseThemePage
|
||||
{
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Util.Localize(this.Page);
|
||||
Page.Title = Util.LocaleText("Dashboard.Label.Dashboard");
|
||||
RefreshDisplay();
|
||||
|
||||
|
||||
//if (!IsPostBack && !IsAjaxCallback)
|
||||
//{
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
private void RefreshDisplay()
|
||||
{
|
||||
DashBoardInfo di = DashBoardInfo.Get(Util.LocaleText("Common.Label.More"));
|
||||
#region "My" panel
|
||||
if (di.MyPanelVisible)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
//sb.Append("<h1 class=\"dashboard\">" + Util.LocaleText("UI.Label.CurrentUserName") + "</h1>");
|
||||
sb.Append("<h1 class=\"dashboard\">" + System.Threading.Thread.CurrentPrincipal.Identity.Name + "</h1>");
|
||||
|
||||
|
||||
if (di.HasMyOverdueList) AppendDashboardSection(di.myOverdueList, "Dashboard.Label.Overdue", sb);
|
||||
if (di.HasMyScheduledList) AppendDashboardSection(di.myScheduledList, "Dashboard.Label.Scheduled", sb);
|
||||
if (di.HasMyServiceRateSummaryList) AppendDashboardSection(di.myServiceRateSummaryList, "WorkorderItemLabor.Label.ServiceRateQuantity", sb);
|
||||
if (di.HasMyReminderList) AppendDashboardSection(di.myRemindersList, "Dashboard.Label.Reminders", sb);
|
||||
if (di.HasMyNewMemoList) AppendDashboardSection(di.myNewMemosList, "Memo.Label.List", sb);
|
||||
litMy.Text = sb.ToString();
|
||||
}
|
||||
#endregion my panel
|
||||
|
||||
#region Company / Region panel
|
||||
if (di.CompPanelVisible)
|
||||
{
|
||||
System.Text.StringBuilder sb = new System.Text.StringBuilder();
|
||||
sb.Append("<h1 class=\"dashboard\">" + di.CurrentCompanyOrRegionName + "</h1>");
|
||||
|
||||
if (di.HasCompNotAssignedList) AppendDashboardSection(di.compNotAssignedList, "Dashboard.Label.NotAssigned", sb);
|
||||
if (di.HasCompOverdueList) AppendDashboardSection(di.compOverdueList, "Dashboard.Label.Overdue", sb);
|
||||
if (di.HasCompScheduledList) AppendDashboardSection(di.compScheduledList, "Dashboard.Label.Next", sb);
|
||||
if (di.HasCompServiceRateSummaryList) AppendDashboardSection(di.compServiceRateSummaryList, "WorkorderItemLabor.Label.ServiceRateQuantity", sb);
|
||||
if (di.HasCompServiceRequestList) AppendDashboardSection(di.compServiceRequestsList, "ClientServiceRequest.Label.List", sb);
|
||||
|
||||
litCompany.Text = sb.ToString();
|
||||
}
|
||||
#endregion company / region panel.
|
||||
|
||||
#region hide / show panels as appropriate
|
||||
if (di.MyPanelVisible && di.CompPanelVisible)
|
||||
{
|
||||
pnlCompany.Attributes.Add("class", "onehalfcolumn");
|
||||
pnlMy.Attributes.Add("class", "onehalfcolumn");
|
||||
pnlCompany.Visible = true;
|
||||
pnlMy.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//One of the two panels isn't visible
|
||||
//so make the other one take up all the space and hide the invisible one
|
||||
if (!di.MyPanelVisible)
|
||||
{
|
||||
pnlCompany.Visible = true;
|
||||
pnlMy.Visible = false;
|
||||
pnlCompany.Attributes.Add("class", "onecolumn");
|
||||
}
|
||||
else
|
||||
{
|
||||
pnlCompany.Visible = false;
|
||||
pnlMy.Visible = true;
|
||||
pnlMy.Attributes.Add("class", "onecolumn");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion hide show panels as appropriate
|
||||
|
||||
}
|
||||
|
||||
private static void AppendDashboardSection(System.Collections.Generic.List<DashBoardInfoItem> dList, string SectionLocaleKey, System.Text.StringBuilder sb)
|
||||
{
|
||||
sb.Append("<h2 class=\"dashboard\">" + Util.LocaleText(SectionLocaleKey) + "</h2>");
|
||||
bool HasOpenableItems = false;
|
||||
sb.Append("<ul class=\"dashboard\">");
|
||||
foreach (DashBoardInfoItem i in dList)
|
||||
{
|
||||
if (i.id.ID != Guid.Empty)
|
||||
{
|
||||
sb.Append("<li>");
|
||||
HasOpenableItems = true;
|
||||
sb.Append("<a href=\"" + TidToUrl(i.id) + "\" target=\"_blank\">");
|
||||
sb.Append(i.item);
|
||||
sb.Append("</a>");
|
||||
sb.Append("</li>");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!HasOpenableItems)//filter out the "more" item for web usage
|
||||
{
|
||||
sb.Append("<li>");
|
||||
sb.Append(i.item);
|
||||
sb.Append("</li>");
|
||||
}
|
||||
}
|
||||
}
|
||||
sb.Append("</ul>");
|
||||
}
|
||||
|
||||
|
||||
private static string TidToUrl(TypeAndID tid)
|
||||
{
|
||||
string toUrl = "";
|
||||
string sObject=tid.RootObjectType.ToString();
|
||||
switch (sObject)
|
||||
{
|
||||
case "Part":
|
||||
toUrl = "PartInventoryView.aspx?id=" + tid.ID.ToString();
|
||||
break;
|
||||
case "WikiPage":
|
||||
toUrl = "Wiki?id=" + tid.ID.ToString();
|
||||
break;
|
||||
case "WorkorderItemScheduledUser":
|
||||
{
|
||||
toUrl = "WorkorderEdit.aspx?id=" + Workorder.GetWorkorderByRelativeNoMRU(tid.RootObjectType, tid.ID).ID.ToString();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
if (tid.ID == Guid.Empty)
|
||||
toUrl = sObject + "Edit.aspx";
|
||||
else
|
||||
toUrl = sObject + "Edit.aspx?id=" + tid.ID.ToString();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return toUrl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void btnNewWo_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Write("<script>window.open('WorkorderNew.aspx','_blank');</script>");
|
||||
}
|
||||
protected void btnNewClient_Click(object sender, EventArgs e)
|
||||
{
|
||||
Response.Write("<script>window.open('ClientEdit.aspx','_blank');</script>");
|
||||
}
|
||||
protected void btnRefresh_Click(object sender, EventArgs e)
|
||||
{
|
||||
//no-op, let it refresh
|
||||
}
|
||||
}//eoc
|
||||
Reference in New Issue
Block a user