BPM实例分享

有童鞋问到字典库的排序难点,这里大致介绍贰个新技能。

     //按部门集中
            IEnumerable<WeekReportWithDepartmentInfo> report =
summary
            .GroupBy(x => new
            {
                x.DeptID,
                x.DeptName
            }).Select(g => new WeekReportWithDepartmentInfo
            {
                DeptID = g.Key.DeptID,
                DeptName = g.Key.DeptName,
                TotalNumber = g.Count(),
                WorkOvertime = g.Sum(a => a.WorkOverHours),
                WorkLeave = g.Where(a => a.IsNeedAttendance ==
true).Sum(a => a.WorkHours),
                PersonalLeave = g.Where(a => a.IsNeedAttendance ==
true).Sum(a => a.PersonalLeave),
                PaidLeave = g.Where(a => a.IsNeedAttendance ==
true).Sum(a => a.PaidLeave),
                LateAndLeavingEarly = g.Where(a => a.IsNeedAttendance
== true).Sum(a => a.LateAndLeavingEarly)
            }).Skip(PageSize * (CurrentPage – 1)).Take(PageSize);

数量字典使用处境:请假流程里的请假类型,有病假、事假、调休等。
定义数据字典,并且在流程中应用SheetDropDownListSheetRadioButtonList展现由用户来选择,如图:

            //总行数
            int rows = summary
            .GroupBy(x => new
            {
                x.DeptID,
                x.DeptName
            }).Count();

图片 1 

            List<WeekReportWithDepartmentInfo> reportlist = new
List<WeekReportWithDepartmentInfo>();
            IEnumerable<string> tempEmail;
            foreach (WeekReportWithDepartmentInfo item in report)
            {
                //找到当前机关的全部人
                tempEmail = employees.Where(e => e.DeptID ==
item.DeptID).Select(s => s.Email);
                item.TotalNumber = summary.Where(e => e.DeptID ==
item.DeptID).GroupBy(x => new {x.EmpID}).Count();
                ////汇总全体人的事假
                //item.PersonalLeave = personalLeave.Where(p =>
tempEmail.Contains(p.Key)).Sum(s => s.Value);

数量字典

                ////汇总全部人的带薪假总工作时间
                //item.PaidLeave = paidLeave.Where(p =>
tempEmail.Contains(p.Key)).Sum(s => s.Value);

使用SheetDropDownList,况兼安装该控件的性格MasterDataCategory为“请假类型”,其代码恐怕如下:

                //double jialeave=JiaLeave.Where(p =>
tempEmail.Contains(p.Key)).Sum(s => s.Value);
                ////迟到早退工作时间
                //item.LateAndLeavingEarly = item.LateAndLeavingEarly –
jialeave;
                //item.LateAndLeavingEarly = item.LateAndLeavingEarly
< 0 ? 0 : item.LateAndLeavingEarly;

<SheetControls:SheetDropDownListID=”SheetDropDownList1″runat=”server”DataField=”请假类型”MasterDataCategory=”请假类型”></SheetControls:SheetDropDownList>
在表单中体现的功力如下:

                //汇总全体人的突击总工程师作时间
                //item.WorkOvertime = workOvertime.Where(p =>
tempEmail.Contains(p.Key)).Sum(s => s.Value);

图片 2 

                //全勤人数
                item.QqingNumber = item.TotalNumber – summary.Where(s
=> s.IsNeedAttendance && s.DeptID == item.DeptID && s.AttendanceState
!= 9).Select(s => s.EmpID).Distinct().Count();//去重复
                //不奇怪考勤时 item.WorkLeave

SheetDropDownList使用数量字典

                //缺勤率
                item.BsenteeismRatio = (item.LateAndLeavingEarly +
item.PersonalLeave + item.PaidLeave) / item.WorkLeave * 100;
                //加班率
                item.OvertimeRatio = item.WorkOvertime / item.WorkLeave
* 100;

表单设计器中使用

                reportlist.Add(item);
            }

图片 3 

            //IEnumerable<KeyValue<string, double>> JiaLeave
= leaveWithWeek.Where(l => l.TypeName != LeaveType.加班
           
//                                                               &&
l.TypeName != LeaveType.补打卡)
            //                                                   
.GroupBy(x => new { x.Email })
            //                                                   
.Select(g => new KeyValue<string, double>
            //                                                    {
            //                                                       
Key = g.Key.Email,
            //                                                       
Value = g.Sum(a => (a.AskLeaveHour))
            //                                                    });

对于SheetDropDownListSheetCheckBoxList、SheetRadioButtonList控件,能够一直绑定数据字典来得选项。

                            //签到(9:00-12:00)
                            tempAtdRec = attendances.Where(a =>
a.EmpID == emp.EmpID && a.RecDateTime >
workDay.GetInTime().AddHours(-4) && a.RecDateTime <
workDay.GetOutTime()).OrderBy(a => a.RecDateTime);
                            if (tempAtdRec.Count() > 0)
                            {
                                info.SigninTime =
tempAtdRec.First().RecTime;
                                info.SigninDateTime =
tempAtdRec.First().RecDateTime;
                            }
                            //签退(13:30-18:00)
                            tempAtdRec = attendances.Where(a =>
a.EmpID == emp.EmpID && a.RecDateTime > workDay.GetInTime() &&
a.RecDateTime <
workDay.GetInTime().AddDays(1).AddHours(-4)).OrderByDescending(a =>
a.RecDateTime);
                            if (tempAtdRec.Count() > 0)
                            {
                                info.SignoutTime =
tempAtdRec.First().RecTime;
                                info.SignoutDateTime =
tempAtdRec.First().RecDateTime;
                            }

数据字典固然方便,一非常大心就建多了,字典库多了用起来也有一些麻烦。

                         

图片 4 

上边教给大家二个粗略实用的排序本事.
率先找到

 

\Portal\Admin\MvcDesigner\MvcDesignerService.ashx

 

上面包车型地铁这几个函数

 

#region 获取数据字典

   

        public void GetMasterDataCategory(HttpContext context)

        {

            List<string> items = new List<string>();

            Dictionary<string, string> table =
OThinker.H3.WorkSheet.AppUtility.Engine.MetadataRepository.GetCategoryTable();

            foreach (string key in
table.OrderBy(s=>s.Value).Select(x=>x.Key))

            {

                items.Add(table[key]);

            }

            context.Response.Write(JSSerializer.Serialize(items));

        }

   

        #endregion

 

把原来的 table.Keys 改成

 

table.OrderBy(s=>s.Value).Select(x=>x.Key)

 

能够随便改成喜欢的排序都能够。

相关文章