/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBPoint DataRowToModel(DataRow row) { DBCommon.Model.DBPoint model = new DBCommon.Model.DBPoint(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["Name"] != null) { model.Name = row["Name"].ToString(); } if (row["QrCode"] != null) { model.QrCode = row["QrCode"].ToString(); } if (row["WifiMac"] != null) { model.WifiMac = row["WifiMac"].ToString(); } if (row["WifiName"] != null) { model.WifiName = row["WifiName"].ToString(); } //model.Lon=row["Lon"].ToString(); //model.Lat=row["Lat"].ToString(); } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(DBCommon.Model.DBPoint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update PointInfo set "); strSql.Append("Name=@Name,"); strSql.Append("QrCode=@QrCode,"); strSql.Append("WifiMac=@WifiMac,"); strSql.Append("WifiName=@WifiName,"); strSql.Append("Lon=@Lon,"); strSql.Append("Lat=@Lat"); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@Name", DbType.String, 2147483647), new SQLiteParameter("@QrCode", DbType.String, 2147483647), new SQLiteParameter("@WifiMac", DbType.String, 2147483647), new SQLiteParameter("@WifiName", DbType.String, 2147483647), new SQLiteParameter("@Lon", DbType.Double, 8), new SQLiteParameter("@Lat", DbType.Double, 8), new SQLiteParameter("@ID", DbType.String, 2147483647) }; parameters[0].Value = model.Name; parameters[1].Value = model.QrCode; parameters[2].Value = model.WifiMac; parameters[3].Value = model.WifiName; parameters[4].Value = model.Lon; parameters[5].Value = model.Lat; parameters[6].Value = model.ID; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DBCommon.Model.DBPoint model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into PointInfo("); strSql.Append("ID,Name,QrCode,WifiMac,WifiName,Lon,Lat)"); strSql.Append(" values ("); strSql.Append("@ID,@Name,@QrCode,@WifiMac,@WifiName,@Lon,@Lat)"); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String, 2147483647), new SQLiteParameter("@Name", DbType.String, 2147483647), new SQLiteParameter("@QrCode", DbType.String, 2147483647), new SQLiteParameter("@WifiMac", DbType.String, 2147483647), new SQLiteParameter("@WifiName", DbType.String, 2147483647), new SQLiteParameter("@Lon", DbType.Double, 8), new SQLiteParameter("@Lat", DbType.Double, 8) }; parameters[0].Value = model.ID; parameters[1].Value = model.Name; parameters[2].Value = model.QrCode; parameters[3].Value = model.WifiMac; parameters[4].Value = model.WifiName; parameters[5].Value = model.Lon; parameters[6].Value = model.Lat; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBPoint GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,Name,QrCode,WifiMac,WifiName,Lon,Lat from PointInfo "); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String, 2147483647) }; parameters[0].Value = ID; DBCommon.Model.DBPoint model = new DBCommon.Model.DBPoint(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
public BaseGetResponse <CheckResult> CheckByScanQrcode([FromUri] string code, [FromUri] string sessionkey) { var res = new BaseGetResponse <CheckResult>() { Code = -1, Msg = "没有这个打卡点", Data = null }; //TODO: //1.检查是否有这个用户 var user = UserRepository.FindUser(sessionkey); if (user == null) { res.Msg = "会话已过期,需要重新登录"; res.Code = 1; return(res); } //2.检查是否有这个二维码对应的打卡点 DBCommon.Model.DBPoint point = null; point = PointRepository.FindPoint(code); if (point == null) { return(res); } //找出该打卡点当前时间正在进行的支部活动 var BA_list = PointRepository.FindBranchActionByPointID(point.ID); BA_list = BA_list.Where(a => a.BranchID.Equals(user.BranchID)).ToList(); bool isBranchAction = false; if (BA_list.Count > 0) { isBranchAction = true; } //3.打卡是否重复,不重复则写入数据库,重复则返回打卡失败 #warning 需要完善步骤 if (isBranchAction) { string title = ""; int num = 0; foreach (var action in BA_list) { var dataresult = ScoreRepository.BA_Signin(action.ID, user.OpenID); if (dataresult != null) { num++; title += string.Format("[{0}.{1}]", num, dataresult.CheckPoint); } else { res.Msg = "打卡失败,没有找到未打卡的支部活动"; res.Code = 4; } } if (num > 0) { res.Msg = "打卡成功"; res.Code = 0; res.Data = new CheckResult() { CheckPoint = string.Format("{0}共{1}个活动打卡", title, num), CheckTime = DateTime.Now }; } else { return(res); } } else { string dataid = ScoreRepository.IsSignined(point.ID, user.OpenID); if (dataid != null) { res.Msg = "今天已打卡,请勿重复打卡"; res.Code = 2; return(res); } var dataresult = ScoreRepository.Signin(point.ID, user.OpenID); if (dataresult != null) { res.Msg = "打卡成功"; res.Code = 0; res.Data = dataresult; } else { res.Msg = "打卡失败,未知错误"; res.Code = 4; } } //var resultModel = PointRepository.CheckByScanQrcode(code, sessionkey); return(res); }