Exemplo n.º 1
0
        public Rtn <List <Incard> > incardMonth([FromForm(Name = "year")] int year = 2019, [FromForm(Name = "month")] int month = 1)
        {
            var tokenUser = this.userService.getUserFromAuthcationHeader();
            var startTime = (int)new DateTime(year, month, 1, 0, 0, 0, 0, 0).Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
            int endTime;

            if (month != 12)
            {
                endTime = (int)new DateTime(year, month + 1, 1, 0, 0, 0, 0, 0).Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
            }
            else
            {
                endTime = (int)new DateTime(year + 1, 1, 1, 0, 0, 0, 0, 0).Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds;
            }
            var data = (from i in this.oaContext.incards where i.inputTime >= startTime && i.inputTime <= endTime select i).ToList();

            foreach (var item in data)
            {
                item.daliySegment = item.time.Value.TotalSeconds >= 12 * 60 * 60 ? IncardDaliySegment.Afternoon : IncardDaliySegment.Monring;
            }

            foreach (var item in data)
            {
                item.getInputTime();
            }
            // 外勤记录
            var outCards = (from c in this.oaContext.outcards where c.userId == tokenUser.id && c.inputTime >= startTime && c.inputTime <= c.inputTime select c).ToList();

            // 外勤记录
            foreach (var o in outCards)
            {
                var day = o.getInputTime().Day;
                foreach (var d in outCards)
                {
                    if (d.getInputTime().Day != day)
                    {
                        var newIncard = new Incard
                        {
                            result       = IncardTimeResult.OutCard,
                            time         = d.time,
                            inputTime    = d.inputTime,
                            userId       = d.userId,
                            daliySegment = d.time.Value.TotalSeconds >= 12 * 60 * 60 ? IncardDaliySegment.Afternoon : IncardDaliySegment.Monring
                        };
                        // output.outCard.Add(newIncard);
                    }
                }
            }
            return(Rtn <List <Incard> > .Success(data));
        }
Exemplo n.º 2
0
        private void addIncard(InCardTimeType?cardType, IncardTimeResult?result, string userId, string companyId, TimeSpan?time)
        {
            var now       = DateTime.Now;
            var newIncard = new Incard();

            newIncard.cardTimeType = cardType;
            newIncard.result       = result;
            newIncard.cardType     = IncardType.Normal;
            newIncard.userId       = userId;
            newIncard.companyId    = companyId;
            newIncard.createTime   = new DateTime();
            newIncard.inputTime    = (int)DateTime.Now.Subtract(new DateTime(1970, 1, 1, 0, 0, 0, 0, 0)).TotalSeconds;
            newIncard.time         = time;
            this.oaContext.incards.Add(newIncard);
            this.oaContext.SaveChanges();
        }