using LYFZ.WanYuKeFuData.Model; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; namespace LYFZ.WanYuKeFuData.DAL { public class GTMessagePushUser : BaseDataOperate { public GTMessagePushUser(LYFZ.WanYuKeFuData.Model.DBConnection dbConn) { base.DBConn = dbConn; } public bool BadgeClear(string cid, int badge = 0) { string sql = String.Format("update [dbo].[tb_GTMessagePushUser] set Badge={1} where GTClientID='{0}'", cid, badge); if (LYFZ.Helper.SQLHelper.ExecuteSql(sql, this.DBConn.GetDBConnectionString()) > 0) { return true; } else { return false; } } /// /// 用户未读消息统计 (Badge累加 1) /// /// /// public bool AddBadgeNumber(string[] cidList) { if (cidList.Length > 0) { string cidString = String.Join(",", cidList).Trim(',').Trim(); if (!String.IsNullOrEmpty(cidString)) { string sql = String.Format("update [dbo].[tb_GTMessagePushUser] set Badge=Badge+1 where GTClientID in ('{0}')", cidString.Trim(',').Trim()).Replace(",", "','"); if (LYFZ.Helper.SQLHelper.ExecuteSql(sql, this.DBConn.GetDBConnectionString()) > 0) { return true; } else { return false; } } else { return true; } } else { return true; } } /// /// /// /// 目标用户 0 为全部用户 1 为特定用户 /// public List GetPushSingleUserList(int targetUser, string targetList) { List sUserList = new List(); targetList = targetList.Trim(','); string sql = String.Format("SELECT [GTType],[Badge],[UserID],[GTClientID],[APPState],[LYFZAPPID] FROM [dbo].[tb_GTMessagePushUser]"); DataTable tb = null; if (targetList.Trim(',').Trim().Length > 0 || targetUser == 0) { switch (targetUser) { case 0: tb = LYFZ.Helper.SQLHelper.Query(String.Format("{0} where UpdateTime>{1}", sql, DateTime.Now.AddDays(-90).ToJavaScriptTimeStamp()), this.DBConn.GetDBConnectionString()).Tables[0]; break; case 1: tb = LYFZ.Helper.SQLHelper.Query(String.Format("{0} where GTClientID in ('{1}')", sql, targetList.Replace(",", "','")), this.DBConn.GetDBConnectionString()).Tables[0]; break; } } if (tb != null) { foreach (DataRow row in tb.Rows) { PushSingleUser sUser = new PushSingleUser(); sUser.GTType = Convert.ToInt32(row["GTType"].ToString()); sUser.GTClientID = row["GTClientID"].ToString(); sUser.Badge = Convert.ToInt32(row["Badge"].ToString()); sUser.UserID = row["UserID"].ToString(); sUser.APPState= Convert.ToInt32(row["APPState"].ToString()); sUser.LYFZAPPID= row["LYFZAPPID"].ToString(); sUserList.Add(sUser); } } return sUserList; } } }