Beispiel #1
0
        /// <summary>
        /// 处理数据
        /// </summary>
        /// <param name="month">月份</param>
        public void GetData(int year, int month)
        {
            reset();


            SetAllDay(year, month);



            var AllCheckDT = DB.Context.From <Dos.Model.original>().Where(d => d.name == Name).ToDataTable();
            var AlloaDT    = DB.Context.From <Dos.Model.oa>().Where(d => d.name == Name).ToDataTable();



            //遍历所有日期
            foreach (var date in AllDays)
            {
                //更新到昨天的数据

                if (date >= DateTime.Today)
                {
                    break;
                }

                var willaddcheck = new CheckInfo(this, date);
                if (isworkday(date))
                {
                    ShoudWorkDayCount++;
                }
                else
                {
                    willaddcheck.Warns.Add(new WarnInfo(date, System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(date.DayOfWeek), WarnInfoType.Info));
                }


                // 先处理OA
                //得到这个人今天的oa数据
                var oadata = new DataView(AlloaDT)
                {
                    RowFilter = $"date = '{date}'",
                };

                ProssOA(AllCheckDT, oadata);

                //得到这个人今天所有的打卡时间
                var checkDT = new DataView(AllCheckDT)
                {
                    RowFilter = $"date = '{date}'",
                }.ToTable();



                var data = new DataView(checkDT)
                {
                    Sort = "time asc" //从小到大
                };
                willaddcheck.Sourcerec = data;

                /*
                 * foreach (DataRowView drv in data)
                 * {
                 *  willaddcheck.Info += drv["info"] + " ";
                 * }*/


                //合成信息
                //bug 如果一天有多次同样的OA  只会出现一次提示,比如调休
                foreach (var r in from DataRowView t in data select t["info"].ToString() into r where !willaddcheck.Info.Contains(r) select r)
                {
                    willaddcheck.Info += r + " ";
                }

                //得到上下班时间
                switch (data.Count)//这一天打卡次数
                {
                case 0:
                    break;

                case 1:
                    //判断是上班,还是下班

                    var t = new TimeSpan((long)data[0].Row["time"]);


                    if (WorkTimeClass.IsWorkTimeClass)
                    {
                        willaddcheck.InTime = t;
                    }
                    else
                    {
                        //大于上班时间4小时
                        if (t > WorkTimeClass.InTime + new TimeSpan(0, 4, 0, 0))
                        {
                            willaddcheck.OutTime = t;
                        }
                        else
                        {
                            willaddcheck.InTime = t;
                        }
                    }

                    break;

                default:
                    //2次及2次以上
                    //取第一个 和最后一个

                    var t1 = new TimeSpan((long)data[0].Row["time"]);
                    var t2 = new TimeSpan((long)data[data.Count - 1].Row["time"]);



                    willaddcheck.InTime  = t1;
                    willaddcheck.OutTime = t2;
                    break;
                }
                AddCheck(willaddcheck);
            }

            Checks.Sort();
        }
Beispiel #2
0
 public void AddCheck(CheckInfo c)
 {
     Checks.Add(c);
     WorkTime += c.WorkTime;
 }