Beispiel #1
0
 public void Add(Normalization_Info obj)
 {
     throw new NotImplementedException();
 }
Beispiel #2
0
        //值班认领 签到、签退
        public int HandleAdd(VA_HandleAddViewModel AddViewModel)
        {
            int count = 0;
            MydutyClaim_Sign model = new MydutyClaim_Sign();
            //是否注册
            var VolunteerInfo = _IVolunteerInfoRepository.SearchInfoByID(AddViewModel.VID);

            if (VolunteerInfo == null)
            {
                count = 6;
                return(count);
            }

            double points = 0;
            ////认领得 值班信息
            MydutyClaim_Info claim_Info = _IMydutyClaimInfoRepository.GetByUidandID(AddViewModel.VID, AddViewModel.ContentID);

            if (claim_Info != null)
            {
                //判断是否在值班区间内进行打卡 20200622  值班时间前后15 分钟均可签到签退
                DateTime start = DateTime.Parse(claim_Info.StartDutyTime.ToString());
                DateTime end   = DateTime.Parse(claim_Info.EndDutyTime.ToString());

                if ((DateTime.Now >= start.AddMinutes(-15) && DateTime.Now <= start.AddMinutes(15) && AddViewModel.type == "in") ||
                    (DateTime.Now >= end && DateTime.Now <= end.AddMinutes(15) && AddViewModel.type == "out"))
                {
                    OndutyClaims_Info ondutyClaims = _claimsInfoRepository.GetByID(claim_Info.OndutyClaims_InfoId);
                    if (ondutyClaims != null)
                    {
                        Normalization_Info Normalization = _normalizationInfo.NormalizationByID(ondutyClaims.Normalization_InfoId);
                        if (Normalization != null)
                        {
                            points = double.Parse(Normalization.PointsEarned);
                        }

                        model.OndutyClaims_InfoId = ondutyClaims.id;
                        model.MydutyClaim_InfoID  = AddViewModel.ContentID;
                        //获取小区经纬度信息
                        List <User_Depart> departAll = _IVolunteerInfoRepository.GetDepartAll();

                        var departList = _IMapper.Map <List <User_Depart>, List <UserDepartSearchMidModel> >(departAll);

                        List <UserDepartSearchMidModel> result = new List <UserDepartSearchMidModel>();
                        result.AddRange(departList.Where(p => p.Code == ondutyClaims.SubdistrictID).ToList());
                        UserDepartSearchMidModel depart = new UserDepartSearchMidModel();
                        if (result.Count > 0)
                        {
                            depart = result.First();
                        }


                        //获取 经纬度
                        if (!String.IsNullOrEmpty(AddViewModel.Checklongitude) && !String.IsNullOrEmpty(AddViewModel.Checklatitude))
                        {
                            //进行地址判断 活动地址方圆1000米可以签到
                            if (!String.IsNullOrEmpty(depart.longitude) && !String.IsNullOrEmpty(depart.latitude))
                            {
                                var checks = CheckAddress(double.Parse(depart.longitude), double.Parse(depart.latitude), double.Parse(AddViewModel.Checklongitude), double.Parse(AddViewModel.Checklatitude), 1);
                                if (!checks)
                                {
                                    count = 9;
                                    return(count);
                                }
                            }
                            else
                            {
                                count = 8;
                                return(count);
                            }
                        }
                        else
                        {
                            count = 7;
                            return(count);
                        }
                    }
                }
                else
                {
                    count = 5;
                    return(count);
                }
            }
            else
            {
                count = 4;
                return(count);
            }

            DEncrypt encrypt = new DEncrypt();

            //保存签到签退信息
            model.id             = Guid.NewGuid().ToString();
            model.Userid         = AddViewModel.VID;
            model.UserName       = encrypt.Decrypt(VolunteerInfo.Name);
            model.CheckTime      = DateTime.Now;
            model.type           = AddViewModel.type;
            model.CreateUser     = VolunteerInfo.ID;
            model.CreateDate     = DateTime.Now;
            model.CheckAddress   = AddViewModel.CheckAddress;
            model.Checklongitude = AddViewModel.Checklongitude;
            model.Checklatitude  = AddViewModel.Checklatitude;


            _mydutyClaim_Sign.Add(model);
            count = _mydutyClaim_Sign.SaveChanges();
            if (count == 1)
            {
                string id = Guid.NewGuid().ToString();

                //签退 时按时长积分继续计算
                if (AddViewModel.type == "out")
                {
                    Volunteer_Score score = new Volunteer_Score();
                    score.ID         = id;
                    score.ContentID  = AddViewModel.ContentID;
                    score.tableName  = "MydutyClaim_Info";
                    score.VID        = AddViewModel.VID;
                    score.type       = "out";
                    score.Score      = points;
                    score.CreateUser = AddViewModel.VID;
                    score.CreateDate = DateTime.Now;

                    _IVolunteer_ScoreRepository.Add(score);
                    int b = _IVolunteer_ScoreRepository.SaveChanges();
                    if (b > 0)
                    {
                        //插入到  泰便利积分表  20200622
                        ET_points ipointMiddle = new ET_points();

                        ipointMiddle.ID         = id;
                        ipointMiddle.uid        = AddViewModel.VID;
                        ipointMiddle.points     = score.Score;
                        ipointMiddle.type       = "MydutySign";
                        ipointMiddle.tableName  = "TedaVolunteerDB.dbo.Volunteer_Score";
                        ipointMiddle.CreateUser = AddViewModel.VID;
                        ipointMiddle.CreateDate = DateTime.Now;
                        eT_PointsRepository.Add(ipointMiddle);
                        int j = eT_PointsRepository.SaveChanges();
                    }
                }
            }

            return(count);
        }