public List <App> GetAll() { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { List <App> _Apps = new List <App>(); try { string strCmd = @" SELECT * FROM `app`"; DataTable dt = db.GetDataSet(strCmd); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { App item = RowToObject(row); _Apps.Add(item); } } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao.GetAll.{0}", ex.Message), new Exception("error")); } return(_Apps); } }
public bool Create(Platform model) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"INSERT INTO `platform` (`Name`,`Description`,`CreateTime`,`ModifyTime`) VALUES(@Name,@Description,NOW(),NOW())"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Name", MySqlDbType.String), new MySqlParameter("@Description", MySqlDbType.String) }; paramters[0].Value = model.Id; paramters[1].Value = model.Description; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("AppTypeDao.Create.{0}", ex.Message), new Exception("error")); return(false); } } }
public bool Create(AppApi model) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"INSERT INTO `appapi` (`AppId`,`ApiId`,`IsUse`,`CreateTime`,`ModifyTime`) VALUES(@AppId,@ApiId,@IsUse,NOW(),NOW())"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@AppId", MySqlDbType.Int32), new MySqlParameter("@ApiId", MySqlDbType.Int32), new MySqlParameter("@IsUse", MySqlDbType.Binary) }; paramters[0].Value = model.Id; paramters[1].Value = model.Description; paramters[2].Value = model.IsUse; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("AppApiDao.Create.{0}", ex.Message), new Exception("error")); return(false); } } }
public AdminUser GetByAccount(string account) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { AdminUser item = null; try { string strCmd = @"SELECT * FROM `user` WHERE `Account`=@Account"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Account", MySqlDbType.String) }; paramters[0].Value = account; DataRow dr = db.GetDataRow(strCmd, paramters); if (dr != null) { item = RowToObject(dr); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("AdminUserDao.GetByAccount.{0}", ex.Message), new Exception("error")); } return(item); } }
/// <summary> /// 设置是否可用 /// </summary> /// <param name="id"></param> /// <param name="loginAccountId"></param> /// <returns></returns> public bool CanUse(int id, string loginAccountId) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr_pangu"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"UPDATE `user` SET `IsUse`=IF( `IsUse`=FALSE,TRUE,FALSE) WHERE `Id`=@Id"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Id", MySqlDbType.Int32) }; paramters[0].Value = id; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("AdminUserDao.CanUse.{0}", ex.Message), new Exception("error")); return(false); } } }
public UserPlatform GetByAppKey(string appkey, string appsecrect) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { UserPlatform item = null; try { string strCmd = @"SELECT * FROM `userplatform` WHERE `AppKey`=@AppKey AND `AppSecrect`=@AppSecrect"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@AppKey", MySqlDbType.String), new MySqlParameter("@AppSecrect", MySqlDbType.String) }; paramters[0].Value = appkey; paramters[1].Value = appsecrect; DataRow dr = db.GetDataRow(strCmd, paramters); if (dr != null) { item = RowToObject(dr); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("UserPlatformDao.GetByAppKey.{0}", ex.Message), new Exception("error")); } return(item); } }
public Api GetById(int id) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { Api item = null; try { string strCmd = @"SELECT * FROM `api` WHERE `Id`=@Id"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Id", MySqlDbType.Int32) }; paramters[0].Value = id; DataRow dr = db.GetDataRow(strCmd, paramters); if (dr != null) { item = RowToObject(dr); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("ApiDao.GetById.{0}", ex.Message), new Exception("error")); } return(item); } }
public bool Update(Platform model) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"UPDATE `platform` SET `Name`=@Name,`Description`=@Description,`ModifyTime`=NOW() WHERE `Id`=@Id"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Name", MySqlDbType.String), new MySqlParameter("@Description", MySqlDbType.String), new MySqlParameter("@Id", MySqlDbType.Int32), }; paramters[0].Value = model.Name; paramters[1].Value = model.Description; paramters[2].Value = model.Id; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao.Update.{0}", ex.Message), new Exception("error")); return(false); } } }
private int Count(string name) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { int total = 0; try { string strCmd = @" SELECT COUNT(1) FROM `platform` WHERE 1=1 "; if (!String.IsNullOrEmpty(name)) { strCmd += @" AND `Name` LIKE '%" + name + "%'"; } DataRow row = db.GetDataRow(strCmd); if (row != null) { total = int.Parse(row["COUNT(1)"].ToString()); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao.Count.{0}", ex.Message), ex); } return(total); } }
/// <summary> /// 物理删除 /// </summary> /// <param name="id"></param> /// <param name="loginAccountId"></param> /// <returns></returns> public bool PhysicDelete(int id, string loginAccountId) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"DELETE FROM `api` WHERE `Id`=@Id"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Id", MySqlDbType.Int32) }; paramters[0].Value = id; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("ApiDao.PhysicDelete.{0}", ex.Message), new Exception("error")); return(false); } } }
public bool IsExistAppKey(string appKey) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { int total = 0; try { string strCmd = @"SELECT COUNT(1) FROM `userplatform` WHERE `AppKey`=@AppKey"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@AppKey", MySqlDbType.String) }; paramters[0].Value = appKey; DataRow row = db.GetDataRow(strCmd, paramters); if (row != null) { total = int.Parse(row["COUNT(1)"].ToString()); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao.IsExistAppKey.{0}", ex.Message), ex); } return(total > 0 ? true : false); } }
public bool UpdateToken(string appkey, string token, DateTime tokenExpireTime) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"UPDATE `userplatform` SET `Token`=@Token,`TokenExpireTime`=@TokenExpireTime WHERE `AppKey`=@AppKey"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Token", MySqlDbType.String), new MySqlParameter("@AppKey", MySqlDbType.String), new MySqlParameter("@TokenExpireTime", MySqlDbType.DateTime) }; paramters[0].Value = token; paramters[1].Value = appkey; paramters[2].Value = tokenExpireTime; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("UserPlatformDao.UpdateToken.{0}", ex.Message), new Exception("error")); return(false); } } }
private List <UserPlatform> _Filter(int appId, int platformId, int limit, int pageSize) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { List <UserPlatform> _Platforms = new List <UserPlatform>(); try { string strCmd = @"SELECT * FROM `userplatform` WHERE 1=1"; if (platformId != 0) { strCmd += @" AND `PlatformId`=@PlatformId"; } if (appId != 0) { strCmd += @" AND `AppId`=@AppId"; } strCmd += " ORDER BY CreateTime DESC"; strCmd += " LIMIT " + limit + "," + pageSize; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@PlatformId", MySqlDbType.Int32), new MySqlParameter("@AppId", MySqlDbType.Int32) }; paramters[0].Value = platformId; paramters[1].Value = appId; DataTable dt = db.GetDataSet(strCmd, paramters); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { UserPlatform item = RowToObject(row); _Platforms.Add(item); } } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao._Filter.{0}", ex.Message), new Exception("error")); } return(_Platforms); } }
private int Count(int appId, int platformId) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { int total = 0; try { string strCmd = @" SELECT COUNT(1) FROM `platform` WHERE 1=1 "; if (platformId != 0) { strCmd += @" AND `PlatformId`=@PlatformId"; } if (appId != 0) { strCmd += @" AND `AppId`=@AppId"; } MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@PlatformId", MySqlDbType.Int32), new MySqlParameter("@AppId", MySqlDbType.Int32) }; paramters[0].Value = platformId; paramters[1].Value = appId; DataRow row = db.GetDataRow(strCmd, paramters); if (row != null) { total = int.Parse(row["COUNT(1)"].ToString()); } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("PlatformDao.Count.{0}", ex.Message), ex); } return(total); } }
public bool Create(AdminUser model) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"INSERT INTO `user`(`Id`,`RealName`,`Account`,`Email`,`Phone`,`IsUse`,`Avatar`,`Description`,`CreateTime`,`ModifyTime`) VALUES(@Id,@RealName,@Account,@Email,@Phone,@IsUse,@Avatar,@Description,NOW(),NOW())"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@Id", MySqlDbType.Int32), new MySqlParameter("@RealName", MySqlDbType.String), new MySqlParameter("@Account", MySqlDbType.String), new MySqlParameter("@Email", MySqlDbType.String), new MySqlParameter("@Phone", MySqlDbType.String), new MySqlParameter("@IsUse", MySqlDbType.Bit), new MySqlParameter("@Avatar", MySqlDbType.String), new MySqlParameter("@Description", MySqlDbType.String) }; paramters[0].Value = model.Id; paramters[1].Value = model.RealName; paramters[2].Value = model.Account; paramters[3].Value = model.Email; paramters[4].Value = model.Phone; paramters[5].Value = model.IsUse; paramters[6].Value = model.Avatar; paramters[7].Value = model.Description; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("AdminUserDao.Create.{0}", ex.Message), new Exception("error")); return(false); } } }
private List <Api> _Filter(string keyword, int limit, int pageSize) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { List <Api> list = new List <Api>(); try { string strCmd = @"SELECT * FROM `api` WHERE 1=1"; if (!string.IsNullOrEmpty(keyword)) { strCmd += @" AND `Name` like " + string.Format("%{0}%", keyword); } strCmd += " ORDER BY CreateTime DESC"; strCmd += " LIMIT " + limit + "," + pageSize; DataTable dt = db.GetDataSet(strCmd); if (dt != null && dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { Api item = RowToObject(row); list.Add(item); } } } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("ApiDao._Filter.{0}", ex.Message), new Exception("error")); } return(list); } }
public bool Create(UserPlatform model) { ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings["connectStr"]; string conStr = SysInfoManage.DENString(settings.ConnectionString); using (ULinker.Common.DB.DBHelper db = new Common.DB.DBHelper(conStr)) { try { string strCmd = @"INSERT INTO `userplatform`(`CreatorId`,`PlatformId`,`AppId`,`AppKey`,`AppSecrect`,`CreateTime`,`ModifyTime`) VALUES(@CreatorId,@PlatformId,@AppId,@AppKey,@AppSecrect,NOW(),NOW())"; MySqlParameter[] paramters = new MySqlParameter[] { new MySqlParameter("@CreatorId", MySqlDbType.Int32), new MySqlParameter("@PlatformId", MySqlDbType.Int32), new MySqlParameter("@AppId", MySqlDbType.Int32), new MySqlParameter("@AppKey", MySqlDbType.String), new MySqlParameter("@AppSecrect", MySqlDbType.String) }; paramters[0].Value = model.CreatorId; paramters[1].Value = model.PlatformId; paramters[2].Value = model.AppId; paramters[3].Value = model.AppKey; paramters[4].Value = model.AppSecrect; int count = db.ExecuteNonQuery(strCmd, paramters); return(count > 0 ? true : false); } catch (Exception ex) { Log4Helper.Error(this.GetType(), String.Format("UserPlatformDao.Create.{0}", ex.Message), new Exception("error")); return(false); } } }