/// <summary>
 ///
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void gcProcessInstance_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     try
     {
         if (e.Row.RowType == DataControlRowType.DataRow)
         {
             LinkButton btnCanExec  = e.Row.FindControl("btnCanExec")  as LinkButton;
             LinkButton btnComplete = e.Row.FindControl("btnComplete") as LinkButton;
             LinkButton btnView     = e.Row.FindControl("btnView") as LinkButton;
             if (e.Row.DataItem != null)
             {
                 int    state        = DataBinder.Eval(e.Row.DataItem, "State") == null ? -1 : Int32.Parse(DataBinder.Eval(e.Row.DataItem, "State").ToString());
                 int    createUserId = DataBinder.Eval(e.Row.DataItem, "CreateUserId") == null ? -1 : Int32.Parse(DataBinder.Eval(e.Row.DataItem, "CreateUserId").ToString());
                 string record       = DataBinder.Eval(e.Row.DataItem, "OperationRecord") == null ? string.Empty : DataBinder.Eval(e.Row.DataItem, "OperationRecord").ToString();
                 if (createUserId > 0)
                 {
                     gcProcessInstance.SetRowText(e.Row, "CreateUserId", OrgManager.GetDisplayValue("T_User", createUserId));
                 }
                 if (state > 0)
                 {
                     gcProcessInstance.SetRowText(e.Row, "State", EnumHelper.GetDescription(typeof(OperationErrorLogStateEnum), state));
                     if (state == (int)OperationErrorLogStateEnum.CanExec)
                     {
                         if (btnCanExec != null)
                         {
                             btnCanExec.Visible = false;
                         }
                     }
                     if (state == (int)OperationErrorLogStateEnum.Finish)
                     {
                         if (btnCanExec != null)
                         {
                             btnCanExec.Visible = false;
                         }
                         if (btnComplete != null)
                         {
                             btnComplete.Visible = false;
                         }
                     }
                 }
                 if (record.Length > 30)
                 {
                     if (btnView != null)
                     {
                         btnView.Text    = record.Substring(0, 30) + "...";
                         btnView.ToolTip = record;
                     }
                     gcProcessInstance.SetRowText(e.Row, "OperationRecord", record.Substring(0, 30) + "...");
                     //e.Row.ToolTip = record;
                 }
             }
         }
     }
     catch (ApplicationException ex)
     {
         this.AjaxAlert(ex.Message);
     }
 }
        /// <summary>
        /// 加载数据
        /// </summary>
        void LoadData()
        {
            string id = Request.QueryString["id"];

            if (!string.IsNullOrEmpty(id))
            {
                int piid = int.Parse(id);
                using (DrisionDbContext context = new DrisionDbContext(GlobalObject.ConnString))
                {
                    T_MobileOperationErrorLog log = context.T_MobileOperationErrorLog.FirstOrDefault(p => p.Id == piid);
                    if (log != null)
                    {
                        lblCreateUserId.Text    = log.CreateUserId.HasValue?OrgManager.GetDisplayValue("T_User", log.CreateUserId.Value):string.Empty;
                        lblCreateTime.Text      = log.CreateTime.HasValue ? log.CreateTime.Value.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty;
                        lblOperationRecord.Text = log.OperationRecord;
                        lblState.Text           = log.State.HasValue? EnumHelper.GetDescription(typeof(OperationErrorLogStateEnum), log.State.Value):string.Empty;
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// 2013-1-5 zhumin 重写查询,提速
        /// </summary>
        private void BindGrid()
        {
            var result = from wi in this.DataHelper.Set <SysWorkItem>()
                         join ai in this.DataHelper.Set <SysActivityInstance>()
                         on wi.ActivityInstanceId equals ai.ActivityInstanceId
                         join pi in this.DataHelper.Set <SysProcessInstance>()
                         on ai.ProcessInstanceId equals pi.ProcessInstanceId
                         join p in this.DataHelper.Set <SysProcess>()
                         on pi.ProcessId equals p.ProcessId
                         //join et in this.DataHelper.Set<SysEntity>()
                         //on p.EntityId equals et.EntityId
                         where wi.OwnerId == LoginUserID &&
                         (p.ProcessStatus == (int)ProcessState.StartUsed || p.ProcessStatus == (int)ProcessState.Updated) &&
                         p.ProcessCategory != (int)ProcessCategory.FormApprove    //2013-9-13 zhumin 排除表单流程
                         orderby pi.StartTime descending
                         select new
            {
                pi.ProcessInstanceId,
                p.ProcessName,
                //et.EntityName,
                EntityName = this.EntityCache.FindById <SysEntity>(p.EntityId).EntityName,
                pi.StartTime,
                pi.EndTime,
                pi.InstanceStatus,
                pi.ObjectId,
                OwnerItemName = "",
                pi.ApproveResult,
                p.EntityId
            };
            //加上条件
            var list = result.Where(p => p.ProcessName.Contains(this.tbT_ProcessName.Text.Trim()));

            if (dtStartTime1.Text != "")
            {
                DateTime st1 = DateTime.Parse(dtStartTime1.Text);
                list = list.Where(p => p.StartTime > st1);
            }
            if (dtStartTime2.Text != "")
            {
                DateTime st2 = DateTime.Parse(dtStartTime2.Text);
                list = list.Where(p => p.StartTime < st2);
            }

            var orgManager = new OrgManager(this.DataHelper);

            if (string.IsNullOrEmpty(tbT_OwnerItemName.Text.Trim())) //不需要查询“对象”
            {
                int count = list.Count();
                this.gcProcessInstance.PagerSettings.DataCount = count;
                var source = list;
                //绑定
                if (count > this.PageIndex * this.PageSize)
                {
                    source = list.Skip(this.PageIndex * this.PageSize).Take(this.PageSize);
                }
                else
                {
                    this.PageIndex = 0;
                    this.gcProcessInstance.PagerSettings.PageIndex = 0;
                    source = list.Take(this.PageSize);
                }

                gcProcessInstance.DataSource = source.ToList().Select(p => new
                {
                    p.ProcessInstanceId,
                    p.ProcessName,
                    p.EntityName,
                    p.ObjectId,
                    OwnerItemName = orgManager.GetDisplayValue(p.EntityName, p.ObjectId),
                    p.StartTime,
                    p.EndTime,
                    p.InstanceStatus,
                    p.ApproveResult,
                    p.EntityId
                }).ToList();
                gcProcessInstance.DataBind();
            }
            else //需要查询“对象”
            {
                var tempSource = list.ToList().Select(p => new
                {
                    p.ProcessInstanceId,
                    p.ProcessName,
                    p.EntityName,
                    p.ObjectId,
                    OwnerItemName = orgManager.GetDisplayValue(p.EntityName, p.ObjectId),
                    p.StartTime,
                    p.EndTime,
                    p.InstanceStatus,
                    p.ApproveResult,
                    p.EntityId
                }).Where(p => p.OwnerItemName.Contains(tbT_OwnerItemName.Text.Trim())).ToList();

                int count = tempSource.Count;
                this.gcProcessInstance.PagerSettings.DataCount = count;
                var source = tempSource;
                //绑定
                if (count > this.PageIndex * this.PageSize)
                {
                    source = tempSource.Skip(this.PageIndex * this.PageSize).Take(this.PageSize).ToList();
                }
                else
                {
                    this.PageIndex = 0;
                    this.gcProcessInstance.PagerSettings.PageIndex = 0;
                    source = tempSource.Take(this.PageSize).ToList();
                }
                gcProcessInstance.DataSource = source;
                gcProcessInstance.DataBind();
            }
        }
Beispiel #4
0
        /// <summary>
        /// 2013-1-5 zhumin 重写查询,提速
        /// </summary>
        private void BindGrid()
        {
            var result = from pi in this.DataHelper.Set <SysProcessInstance>()
                         join p in this.DataHelper.Set <SysProcess>()
                         on pi.ProcessId equals p.ProcessId
                         join u in this.DataHelper.Set <T_User>()
                         on pi.StartUserId equals u.User_ID
                         join d in this.DataHelper.Set <T_Department>()
                         on pi.StartDeptId equals d.Department_ID
                                                                               //join et in this.DataHelper.Set<SysEntity>()
                                                                               //on p.EntityId equals et.EntityId
                         where (p.ProcessStatus == (int)ProcessState.StartUsed || p.ProcessStatus == (int)ProcessState.Updated) &&
                         p.ProcessCategory != (int)ProcessCategory.FormApprove //2013-9-13 zhumin 排除表单流程
                         orderby pi.StartTime descending
                         select new
            {
                pi.ProcessInstanceId,
                p.ProcessName,
                p.ProcessType,
                //et.EntityName,
                //et.DisplayText,
                EntityName  = this.EntityCache.FindById <SysEntity>(p.EntityId).EntityName,
                DisplayText = this.EntityCache.FindById <SysEntity>(p.EntityId).DisplayText,
                pi.StartUserId,
                u.User_Name,
                pi.ObjectId,
                OwnerItemName = "",
                d.Department_Name,
                pi.StartTime,
                pi.EndTime,
                pi.InstanceStatus,
                pi.ApproveResult,
                p.EntityId
            };
            //加上条件
            var list = result.Where(p => p.ProcessName.Contains(tbT_ProcessName.Text));

            if (cbStartUser.SelectedValue != null)
            {
                int startUserId = Int32.Parse(cbStartUser.SelectedValue);
                list = list.Where(p => p.StartUserId == startUserId);
            }
            if (cbStatus.SelectedValue != null)
            {
                int stateId = Int32.Parse(cbStatus.SelectedValue);
                list = list.Where(p => p.InstanceStatus == stateId);
            }
            if (dtStartTime1.Text != "")
            {
                DateTime st1 = DateTime.Parse(dtStartTime1.Text);
                list = list.Where(p => p.StartTime > st1);
            }
            if (dtStartTime2.Text != "")
            {
                DateTime st2 = DateTime.Parse(dtStartTime2.Text);
                list = list.Where(p => p.StartTime < st2);
            }
            if (dtEndTime1.Text != "")
            {
                DateTime et1 = DateTime.Parse(dtEndTime1.Text);
                list = list.Where(p => p.EndTime > et1);
            }
            if (dtEndTime2.Text != "")
            {
                DateTime et2 = DateTime.Parse(dtEndTime2.Text);
                list = list.Where(p => p.EndTime < et2);
            }
            if (cbProcess.SelectedValue != null)
            {
                long typeid = long.Parse(cbProcess.SelectedValue);
                list = list.Where(p => p.ProcessType == typeid);
            }

            var orgManager = new OrgManager(this.DataHelper);

            if (string.IsNullOrEmpty(tbT_OwnerItemName.Text.Trim())) //不需要查询“对象”
            {
                int count = list.Count();
                this.gcProcessInstance.PagerSettings.DataCount = count;
                var source = list;
                //绑定
                if (count > this.PageIndex * this.PageSize)
                {
                    source = list.Skip(this.PageIndex * this.PageSize).Take(this.PageSize);
                }
                else
                {
                    this.PageIndex = 0;
                    this.gcProcessInstance.PagerSettings.PageIndex = 0;
                    source = list.Take(this.PageSize);
                }

                gcProcessInstance.DataSource = source.ToList().Select(p => new
                {
                    p.ProcessInstanceId,
                    p.ProcessName,
                    p.ProcessType,
                    p.EntityName,
                    p.DisplayText,
                    p.StartUserId,
                    p.User_Name,
                    p.ObjectId,
                    OwnerItemName = orgManager.GetDisplayValue(p.EntityName, p.ObjectId),
                    p.Department_Name,
                    p.StartTime,
                    p.EndTime,
                    p.InstanceStatus,
                    p.ApproveResult,
                    p.EntityId
                }).ToList();
                gcProcessInstance.DataBind();
            }
            else //需要查询“对象”
            {
                var tempSource = list.ToList().Select(p => new
                {
                    p.ProcessInstanceId,
                    p.ProcessName,
                    p.ProcessType,
                    p.EntityName,
                    p.DisplayText,
                    p.StartUserId,
                    p.User_Name,
                    p.ObjectId,
                    OwnerItemName = orgManager.GetDisplayValue(p.EntityName, p.ObjectId),
                    p.Department_Name,
                    p.StartTime,
                    p.EndTime,
                    p.InstanceStatus,
                    p.ApproveResult,
                    p.EntityId
                }).Where(p => p.OwnerItemName.Contains(tbT_OwnerItemName.Text.Trim())).ToList();

                int count = tempSource.Count;
                this.gcProcessInstance.PagerSettings.DataCount = count;
                var source = tempSource;
                //绑定
                if (count > this.PageIndex * this.PageSize)
                {
                    source = tempSource.Skip(this.PageIndex * this.PageSize).Take(this.PageSize).ToList();
                }
                else
                {
                    this.PageIndex = 0;
                    this.gcProcessInstance.PagerSettings.PageIndex = 0;
                    source = tempSource.Take(this.PageSize).ToList();
                }
                gcProcessInstance.DataSource = source;
                gcProcessInstance.DataBind();
            }
        }