/// <summary> /// 赋权 /// </summary> /// <param name="roleAuthorEntity"></param> /// <returns></returns> public bool AddRoleAuthor(RoleAuthorEntity roleAuthorEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("@JournalID"); sqlCommandText.Append(", @RoleID"); sqlCommandText.Append(", @AuthorID"); DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO dbo.RoleAuthor ({0}) VALUES ({1})",sqlCommandText.ToString().Replace("@", ""),sqlCommandText.ToString())); db.AddInParameter(cmd,"@JournalID",DbType.Int64,roleAuthorEntity.JournalID); db.AddInParameter(cmd,"@RoleID",DbType.Int64,roleAuthorEntity.RoleID); db.AddInParameter(cmd,"@AuthorID",DbType.Int64,roleAuthorEntity.AuthorID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
public ActionResult AddAurhorRole(long RoleID, long[] IDAarry) { ExecResult execResult = new ExecResult(); try { foreach (long AuthorID in IDAarry) { RoleAuthorEntity roleAuthorEntity = new RoleAuthorEntity(); roleAuthorEntity.AuthorID = AuthorID; roleAuthorEntity.RoleID = RoleID; roleAuthorEntity.JournalID = JournalID; IAuthorFacadeService authorService = ServiceContainer.Instance.Container.Resolve<IAuthorFacadeService>(); execResult = authorService.SetAurhorRole(roleAuthorEntity); if (execResult.result == EnumJsonResult.error.ToString() || execResult.result == EnumJsonResult.failure.ToString()) { break; } } } catch (Exception ex) { execResult.result = EnumJsonResult.error.ToString(); execResult.msg = "添加用户到当前角色出现异常:" + ex.Message; WKT.Log.LogProvider.Instance.Error("添加用户到当前角色出现异常:" + ex.Message); } return Content(JsonConvert.SerializeObject(execResult)); }
public ExecResult DelAurhoRole(RoleAuthorEntity roleAuthorEntity) { ExecResult result = new ExecResult(); try { IRoleAuthorService roleAuthorService = ServiceContainer.Instance.Container.Resolve<IRoleAuthorService>(); bool flag = roleAuthorService.DeleteRoleAuthor(roleAuthorEntity); if (flag) { result.result = EnumJsonResult.success.ToString(); result.msg = "成功"; } else { result.result = EnumJsonResult.failure.ToString(); result.msg = "删除作者角色失败,请确认作者信息是否正确"; } } catch (Exception ex) { result.result = EnumJsonResult.error.ToString(); result.msg = "删除作者角色时出现异常:" + ex.Message; } return result; }
/// <summary> /// 从存储媒介中删除对象 /// </summary> /// <param name="mapID"></param> /// <returns></returns> public ExecResult DeleteRoleAuthor(long mapID) { HttpClientHelper clientHelper = new HttpClientHelper(); RoleAuthorEntity roleAuthor = new RoleAuthorEntity(); roleAuthor.MapID = mapID; ExecResult execResult = clientHelper.PostAuth<ExecResult, RoleAuthorEntity>(GetAPIUrl(APIConstant.DELETEROLEAUTHOR), roleAuthor); return execResult; }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="roleAuthor">RoleAuthorEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddRoleAuthor(RoleAuthorEntity roleAuthor) { return RoleAuthorBusProvider.AddRoleAuthor(roleAuthor); }
/// <summary> /// 更新存储媒介中的实体数据 /// </summary> /// <param name="roleAuthor">RoleAuthorEntity实体对象</param> /// <returns>true:更新成功 false:更新失败</returns> public bool UpdateRoleAuthor(RoleAuthorEntity roleAuthor) { return RoleAuthorBusProvider.UpdateRoleAuthor(roleAuthor); }
public bool UpdateRoleAuthor(RoleAuthorEntity roleAuthorEntity) { bool flag = false; StringBuilder whereCommandText = new StringBuilder(); whereCommandText.Append(" MapID=@MapID"); StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append(" JournalID=@JournalID"); sqlCommandText.Append(", RoleID=@RoleID"); sqlCommandText.Append(", AuthorID=@AuthorID"); sqlCommandText.Append(", AddDate=@AddDate"); DbCommand cmd = db.GetSqlStringCommand(String.Format("UPDATE dbo.RoleAuthor SET {0} WHERE {1}",sqlCommandText.ToString(),whereCommandText.ToString())); db.AddInParameter(cmd,"@MapID",DbType.Int64,roleAuthorEntity.MapID); db.AddInParameter(cmd,"@JournalID",DbType.Int64,roleAuthorEntity.JournalID); db.AddInParameter(cmd,"@RoleID",DbType.Int64,roleAuthorEntity.RoleID); db.AddInParameter(cmd,"@AuthorID",DbType.Int64,roleAuthorEntity.AuthorID); db.AddInParameter(cmd,"@AddDate",DbType.DateTime,roleAuthorEntity.AddDate); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="roleAuthor">RoleAuthorEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteRoleAuthor(RoleAuthorEntity roleAuthor) { return RoleAuthorDataAccess.Instance.DeleteRoleAuthor(roleAuthor); }
public RoleAuthorEntity MakeRoleAuthorDetail(DataRow dr) { RoleAuthorEntity roleAuthorEntity = null; if (dr != null) { roleAuthorEntity = new RoleAuthorEntity(); roleAuthorEntity.MapID = (Int64)dr["MapID"]; roleAuthorEntity.JournalID = (Int64)dr["JournalID"]; roleAuthorEntity.RoleID = (Int64)dr["RoleID"]; roleAuthorEntity.RoleName = (String)dr["RoleName"]; roleAuthorEntity.AuthorID = (Int64)dr["AuthorID"]; roleAuthorEntity.RealName = (String)dr["RealName"]; roleAuthorEntity.LoginName = (String)dr["LoginName"]; roleAuthorEntity.AddDate = (DateTime)dr["AddDate"]; } return roleAuthorEntity; }
public RoleAuthorEntity MakeRoleAuthor(DataRow dr) { RoleAuthorEntity roleAuthorEntity=null; if(dr!=null) { roleAuthorEntity=new RoleAuthorEntity(); roleAuthorEntity.MapID = (Int64)dr["MapID"]; roleAuthorEntity.JournalID = (Int64)dr["JournalID"]; roleAuthorEntity.RoleID = (Int64)dr["RoleID"]; roleAuthorEntity.AuthorID = (Int64)dr["AuthorID"]; roleAuthorEntity.AddDate = (DateTime)dr["AddDate"]; } return roleAuthorEntity; }
public RoleAuthorEntity MakeRoleAuthor(IDataReader dr) { RoleAuthorEntity roleAuthorEntity = null; if(dr.Read()) { roleAuthorEntity=new RoleAuthorEntity(); roleAuthorEntity.MapID = (Int64)dr["MapID"]; roleAuthorEntity.JournalID = (Int64)dr["JournalID"]; roleAuthorEntity.RoleID = (Int64)dr["RoleID"]; roleAuthorEntity.AuthorID = (Int64)dr["AuthorID"]; roleAuthorEntity.AddDate = (DateTime)dr["AddDate"]; } dr.Close(); return roleAuthorEntity; }
public bool DeleteRoleAuthor(RoleAuthorEntity roleAuthorEntity) { bool flag = false; StringBuilder sqlCommandText = new StringBuilder(); sqlCommandText.Append("DELETE FROM dbo.RoleAuthor"); sqlCommandText.Append(" WHERE RoleID=@RoleID AND AuthorID=@AuthorID"); DbCommand cmd = db.GetSqlStringCommand(sqlCommandText.ToString()); db.AddInParameter(cmd, "@RoleID", DbType.Int64, roleAuthorEntity.RoleID); db.AddInParameter(cmd, "@AuthorID", DbType.Int64, roleAuthorEntity.AuthorID); try { db.ExecuteNonQuery(cmd); flag = true; } catch(SqlException sqlEx) { throw sqlEx; } return flag; }
/// <summary> /// 持久化一个新对象(保存新对象到存储媒介中) /// </summary> /// <param name="roleAuthor"></param> /// <returns></returns> public ExecResult AddRoleAuthor(RoleAuthorEntity roleAuthor) { HttpClientHelper clientHelper = new HttpClientHelper(); ExecResult execResult = clientHelper.PostAuth<ExecResult, RoleAuthorEntity>(GetAPIUrl(APIConstant.ADDROLEAUTHOR), roleAuthor); return execResult; }
/// <summary> /// 从存储媒介删除实体数据 /// </summary> /// <param name="roleAuthor">RoleAuthorEntity实体对象</param> /// <returns>true:删除成功 false:删除失败</returns> public bool DeleteRoleAuthor(RoleAuthorEntity roleAuthor) { return RoleAuthorBusProvider.DeleteRoleAuthor(roleAuthor); }
public List<RoleAuthorEntity> MakeRoleAuthorDetailList(IDataReader dr) { List<RoleAuthorEntity> list = new List<RoleAuthorEntity>(); while (dr.Read()) { RoleAuthorEntity roleAuthorEntity = new RoleAuthorEntity(); roleAuthorEntity.MapID = (Int64)dr["MapID"]; roleAuthorEntity.JournalID = (Int64)dr["JournalID"]; roleAuthorEntity.RoleID = (Int64)dr["RoleID"]; roleAuthorEntity.RoleName = dr["RoleName"]==System.DBNull.Value?"":(String)dr["RoleName"]; roleAuthorEntity.AuthorID = (Int64)dr["AuthorID"]; roleAuthorEntity.RealName = (String)dr["RealName"]; roleAuthorEntity.LoginName = (String)dr["LoginName"]; roleAuthorEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(roleAuthorEntity); } dr.Close(); return list; }
/// <summary> /// 更新一个持久化对象 /// </summary> /// <param name="roleAuthor"></param> /// <returns></returns> public ExecResult UpdateRoleAuthor(RoleAuthorEntity roleAuthor) { ExecResult result = new ExecResult(); try { IRoleAuthorService roleAuthorService = ServiceContainer.Instance.Container.Resolve<IRoleAuthorService>(); bool flag = roleAuthorService.UpdateRoleAuthor(roleAuthor); if (flag) { result.result = EnumJsonResult.success.ToString(); result.msg = "成功"; } else { result.result = EnumJsonResult.failure.ToString(); result.msg = "操作失败"; } } catch (Exception ex) { result.result = EnumJsonResult.error.ToString(); result.msg = "更新角色作者信息时出现异常:" + ex.Message; } return result; }
public List<RoleAuthorEntity> MakeRoleAuthorList(IDataReader dr) { List<RoleAuthorEntity> list=new List<RoleAuthorEntity>(); while(dr.Read()) { RoleAuthorEntity roleAuthorEntity=new RoleAuthorEntity(); roleAuthorEntity.MapID = (Int64)dr["MapID"]; roleAuthorEntity.JournalID = (Int64)dr["JournalID"]; roleAuthorEntity.RoleID = (Int64)dr["RoleID"]; roleAuthorEntity.AuthorID = (Int64)dr["AuthorID"]; roleAuthorEntity.AddDate = (DateTime)dr["AddDate"]; list.Add(roleAuthorEntity); } dr.Close(); return list; }
public ExecResult SetAurhoRole(RoleAuthorEntity roleAuthorEntity) { ExecResult result = new ExecResult(); try { RoleAuthorQuery roleAuthorQuery = new RoleAuthorQuery(); roleAuthorQuery.AuthorID = roleAuthorEntity.AuthorID; roleAuthorQuery.JournalID = roleAuthorEntity.JournalID; roleAuthorQuery.RoleID = roleAuthorEntity.RoleID; IRoleAuthorService roleAuthorService = ServiceContainer.Instance.Container.Resolve<IRoleAuthorService>(); List<RoleAuthorEntity> checkIsExist = roleAuthorService.GetRoleAuthorList(roleAuthorQuery); if (checkIsExist != null && checkIsExist.Count > 0) { result.result = EnumJsonResult.success.ToString(); result.msg = "成功"; } else { bool flag = roleAuthorService.AddRoleAuthor(roleAuthorEntity); if (flag) { result.result = EnumJsonResult.success.ToString(); result.msg = "成功"; } else { result.result = EnumJsonResult.failure.ToString(); result.msg = "设置作者角色失败,请确认作者信息是否正确"; } } } catch (Exception ex) { result.result = EnumJsonResult.error.ToString(); result.msg = "设置作者角色时出现异常:" + ex.Message; } return result; }
/// <summary> /// 将实体数据存入存储媒介(持久化一个对象) /// </summary> /// <param name="roleAuthor">RoleAuthorEntity实体对象</param> /// <returns>true:存储成功 false:存储失败</returns> public bool AddRoleAuthor(RoleAuthorEntity roleAuthor) { return RoleAuthorDataAccess.Instance.AddRoleAuthor(roleAuthor); }