/// <summary> /// 获取签到详情 /// </summary> /// <param name="userid"></param> /// <param name="time"></param> /// <returns></returns> public SignInAreaPartModel GetSignDetails(int?userid, DateTime time) { Entities db = new Entities(); IQueryable <SignInAreaPartModel> quwryable = from a in db.qw_usertasks join b_json in db.qw_signinareas on a.signinareaid equals b_json.signinareaid into bTemp from b in bTemp.DefaultIfEmpty() join c_json in db.base_units on a.sszd equals c_json.id into cTemp from c in cTemp.DefaultIfEmpty() join d_json in db.base_units on a.ssbc equals d_json.id into dTemp from d in dTemp.DefaultIfEmpty() join e_json in db.base_users on a.userid equals e_json.id into eTemp from e in eTemp.DefaultIfEmpty() select new SignInAreaPartModel { areaid = a.signinareaid, geometry = b.grometry, areaname = b.name, areadescription = b.explain, start_stime = b.start_stime, start_etime = b.start_etime, end_stime = b.end_stime, end_etime = b.end_etime, sszd = a.sszd, ssbzname = c == null ? "" : c.name, ssbc = a.ssbc, sszdname = d == null ? "" : d.name, time = a.taskstarttime, userid = a.userid, username = e.displayname }; SignInAreaPartModel model = quwryable.Where(a => a.userid == userid && a.time.Value.Year == time.Year && a.time.Value.Month == time.Month && a.time.Value.Day == time.Day).FirstOrDefault(); if (model != null) { model.usersigninlist = GetSignInById(model.userid, model.time); } return(model); }
/// <summary> /// 查询签到区域坐标集合 /// </summary> /// <returns></returns> public SignInAreaPartModel GetAreaGeometry(int UserId, double x, double y) { Entities db = new Entities(); DateTime nowdate = DateTime.Parse(DateTime.Now.ToLongDateString()); IQueryable <SignInAreaPartModel> Queryable = (from a in db.qw_usertasks join b in db.qw_signinareas on a.signinareaid equals b.signinareaid where a.userid == UserId && a.taskstarttime.Year == nowdate.Year && a.taskstarttime.Month == nowdate.Month && a.taskstarttime.Day == nowdate.Day select new SignInAreaPartModel { areaid = a.signinareaid, geometry = b.grometry, areaname = b.name, areadescription = b.explain, start_stime = b.start_stime, start_etime = b.start_etime, end_stime = b.end_stime, end_etime = b.end_etime, ssbc = a.ssbc, sszd = a.sszd, }); SignInAreaPartModel model = Queryable.FirstOrDefault(); MapPoint mapmodel = new MapPoint(); mapmodel.X = x; mapmodel.Y = y; if (model != null) { if (!string.IsNullOrEmpty(model.geometry)) { string[] splitmap = model.geometry.Split(';'); List <MapPoint> listmp = new List <MapPoint>(); for (int i = 0; i < splitmap.Length; i++) { MapPoint mp = new MapPoint(); if (string.IsNullOrEmpty(splitmap[i])) { continue; } mp.X = double.Parse(splitmap[i].Split(',')[0]); mp.Y = double.Parse(splitmap[i].Split(',')[1]); listmp.Add(mp); } //用户是否在签到区域内model if (PointInFences(mapmodel, listmp)) { model.issignin = true; } else { model.issignin = false; } } model.usersigninlist = GetSignInById(UserId, nowdate); } else { model = new SignInAreaPartModel(); } return(model); }