AbstractNotificationGrid.cs
上传用户:li2971742
上传日期:2021-11-18
资源大小:39096k
文件大小:4k
源码类别:

OA系统

开发平台:

C#

  1. using System;
  2. using System.Data;
  3. using System.Configuration;
  4. using System.Web;
  5. using System.Web.Security;
  6. using System.Web.UI;
  7. using System.Web.UI.WebControls;
  8. using System.Web.UI.WebControls.WebParts;
  9. using System.Web.UI.HtmlControls;
  10. using System.ComponentModel;
  11. namespace OThinker.H3.Portal
  12. {
  13.     /// <summary>
  14.     /// Summary description for AbstractNotificationGrid
  15.     /// </summary>
  16.     [DefaultProperty("Text"),
  17.           ToolboxData("<{0}:AbstractNotificationGrid runat=server></{0}:AbstractNotificationGrid>")]
  18.     public class AbstractNotificationGrid : NotificationGrid
  19.     {
  20.         protected TemplateColumn AbstractColumn = new TemplateColumn();
  21.         protected int AbstractColumnIndex
  22.         {
  23.             get
  24.             {
  25.                 return this.Columns.IndexOf(this.AbstractColumn);
  26.             }
  27.         }
  28.         public AbstractNotificationGrid()
  29.         {
  30.             this.PageIndexChanged += new DataGridPageChangedEventHandler(InstanceGridView_PageIndexChanged);
  31.             this.AllowPaging = true;
  32.             this.PagerStyle.Mode = PagerMode.NumericPages;
  33.             foreach (DataGridColumn column in this.Columns)
  34.             {
  35.                 column.Visible = false;
  36.             }
  37.             this.AbstractColumn.HeaderText = "消息";
  38.             this.Columns.Add(this.AbstractColumn);
  39.         }
  40.         protected override void Grid_ItemDataBound(object sender, DataGridItemEventArgs e)
  41.         {
  42.             base.Grid_ItemDataBound(sender, e);
  43.             if (
  44.                 e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Header &&
  45.                 e.Item.ItemType != System.Web.UI.WebControls.ListItemType.Footer)
  46.             {
  47.                 string title = e.Item.Cells[this.TitleColumnIndex].Text;
  48.                 if (title == null || title == "" || title == "&nbsp;")
  49.                 {
  50.                     title = "未命名";
  51.                 }
  52.                 // From
  53.                 string from = e.Item.Cells[this.FromColumnIndex].Text;
  54.                 if (!this.DesignMode)
  55.                 {
  56.                     from = OThinker.H3.Server.Engine.Organization.GetFullName(from);
  57.                 }
  58.                 // To
  59.                 string to = e.Item.Cells[this.ToColumnIndex].Text;
  60.                 if (!this.DesignMode)
  61.                 {
  62.                     to = OThinker.H3.Server.Engine.Organization.GetFullName(to);
  63.                 }
  64.                 System.DateTime receiveTime = System.DateTime.Now;
  65.                 if (!this.DesignMode)
  66.                 {
  67.                     receiveTime = System.DateTime.Parse(e.Item.Cells[this.ReceiveTimeColumnIndex].Text);
  68.                 }
  69.                 OThinker.H3.Notification.NotificationState state = OThinker.H3.Notification.NotificationState.Read;
  70.                 if (!this.DesignMode)
  71.                 {
  72.                     state = (OThinker.H3.Notification.NotificationState)int.Parse(e.Item.Cells[this.StateColumnIndex].Text);
  73.                 }
  74.                 string package = e.Item.Cells[this.WorkflowPackageColumnIndex].Text;
  75.                 string workflowName = e.Item.Cells[this.WorkflowNameColumnIndex].Text;
  76.                 string strVersion = e.Item.Cells[this.WorkflowVersionColumnIndex].Text;
  77.                 int version = WorkflowTemplate.WorkflowTemplate.NullWorkflowVersion;
  78.                 if(!this.DesignMode)
  79.                 {
  80.                     version = int.Parse(strVersion);
  81.                 }
  82.                 string instanceId = e.Item.Cells[this.InstanceIDColumnIndex].Text;
  83.                 NotificationGridItem item = new NotificationGridItem(
  84.                     title,
  85.                     e.Item.Cells[this.UrlColumnIndex].Text, 
  86.                     state,
  87.                     receiveTime,
  88.                     package, 
  89.                     workflowName, 
  90.                     version, 
  91.                     instanceId, 
  92.                     to);
  93.                 e.Item.Cells[AbstractColumnIndex].Controls.Add(item);
  94.             }
  95.         }
  96.         private void InstanceGridView_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
  97.         {
  98.             this.CurrentPageIndex = e.NewPageIndex;
  99.             this.DataBind();
  100.         }
  101.     }
  102. }