public List <WeeklyReport> GetWeeklyReportListByPerson(Guid userId, int startYear, int startMonth, int endYear, int endMonth) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@userId", userId)); list.Add(new CommandParameter("@startYear", startYear)); list.Add(new CommandParameter("@startMonth", startMonth)); list.Add(new CommandParameter("@endYear", endYear)); list.Add(new CommandParameter("@endMonth", endMonth)); DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetWeeklyReportListByPerson", list, new string[] { "result" }); List <WeeklyReport> list2 = RelationalMappingUnity.Select <WeeklyReport>(dataSet.Tables[0]); if (list2 == null) { return(null); } foreach (WeeklyReport current in list2) { DataRow[] array = dataSet.Tables[1].Select("WeeklyReport = '" + current.Id + "'"); for (int i = 0; i < array.Length; i++) { WeeklyReportItem weeklyReportItem = RelationalMappingUnity.Select <WeeklyReportItem>(array[i]); if (weeklyReportItem != null) { current.ItemList.Add(weeklyReportItem); } } } return(list2); }
public void UpdateList(List <object> objList) { if (objList == null) { return; } List <SqlExpression> sqlExpressionList = new List <SqlExpression>(); SqlExpressionArgs args = new SqlExpressionArgs(); args.Type = SqlExpressionType.Update; foreach (var item in objList) { if (item == null) { Debug.Assert(false, "insert obj 为 null"); continue; } SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(item, args); sqlExpressionList.Add(sqlExpression); } ExcuteSqlExpression(sqlExpressionList); }
public List <T> Select <T>(string sql) where T : class { DataSet ds = ExecuteDataSet(sql); List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]); return(dataList); }
public List <T> Select <T>(string sql, List <CommandParameter> parameterList) where T : class { DataSet ds = ExecuteDataSet(sql, parameterList, new string[] { "Table" }); List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]); return(dataList); }
public bool Fill <T>(object obj, string table, Dictionary <string, object> attachedWhere) where T : class, new() { SqlExpressionArgs args = new SqlExpressionArgs(); args.Table = table; args.Type = SqlExpressionType.Select; if (attachedWhere == null) { args.GenerateWhere = true; } else { args.GenerateWhere = false; args.AttachedWhere = AttachedWhereItem.Parse(attachedWhere); } //不能用 default(T) ,会是null SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(obj, args); DataSet ds = ExcuteDataSetSqlExpression(sqlExpression); List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]); Debug.Assert(dataList.Count <= 1, "Fill 时取出的记录大于1条"); if (dataList.Count != 1) { return(false); } T dataObj = dataList[0]; ReflectionHelper.Inject(obj, dataObj); return(true); }
public List <T> Select <T>(List <AttachedWhereItem> attachedWhere, SqlExpressionPagingArgs pagingArgs) where T : class, new() { SqlExpressionArgs args = new SqlExpressionArgs(); args.Type = SqlExpressionType.Select; args.GenerateWhere = false; args.AttachedWhere = attachedWhere; args.PagingArgs = pagingArgs; //不能用 default(T) ,会是null SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(new T(), args); DataSet ds = ExcuteDataSetSqlExpression(sqlExpression); List <T> dataList = RelationalMappingUnity.Select <T>(ds.Tables[0]); if (pagingArgs != null) { if (ds.Tables.Count > 1) { pagingArgs.TotalRow = int.Parse(ds.Tables[1].Rows[0][0].ToString()); } else { pagingArgs.TotalRow = ds.Tables[0].Rows.Count; } pagingArgs.TotalPage = pagingArgs.TotalRow / pagingArgs.PageSize; if (pagingArgs.TotalRow % pagingArgs.PageSize > 0) { pagingArgs.TotalPage++; } } return(dataList); }
public List <WeeklyReport> GetWeeklyReportListByOrganization(Guid domainId, Guid organizationId, int year, int weekOfYear) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@domainId", domainId)); list.Add(new CommandParameter("@organizationId", organizationId)); list.Add(new CommandParameter("@year", year)); list.Add(new CommandParameter("@weekOfYear", weekOfYear)); DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetWeeklyReportListByOrganization", list, new string[] { "result" }); List <WeeklyReport> list2 = RelationalMappingUnity.Select <WeeklyReport>(dataSet.Tables[0]); if (list2 == null) { return(null); } foreach (WeeklyReport current in list2) { DataRow[] array = dataSet.Tables[1].Select("WeeklyReport = '" + current.Id + "'"); for (int i = 0; i < array.Length; i++) { WeeklyReportItem weeklyReportItem = RelationalMappingUnity.Select <WeeklyReportItem>(array[i]); if (weeklyReportItem != null) { current.ItemList.Add(weeklyReportItem); } } } return(list2); }
public List <MovieEntity> GetMovieTimes(Guid domainId, string appId, DateTime date) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domainId", domainId)); parameterList.Add(new CommandParameter("@appId", appId)); parameterList.Add(new CommandParameter("@date", date)); DataSet dsResult = _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetMovieTimes", parameterList, new string[] { "movies", "times" }); DataTable dtMovies = dsResult.Tables["movies"]; DataTable dtTimes = dsResult.Tables["times"]; List <MovieEntity> list = RelationalMappingUnity.Select <MovieEntity>(dtMovies); if (list == null) { list = new List <MovieEntity>(); return(list); } foreach (MovieEntity item in list) { item.TimesList = RelationalMappingUnity.Select <MovieTimesEntity>(dtTimes.Select("Movie = '" + item.Id + "'")); } return(list); }
public void UpdateAuthorizationListByRoleId(RoleAuthorizationRelation roleAuthorizationRelation) { if (roleAuthorizationRelation == null) { return; } List <SqlExpression> list = new List <SqlExpression>(); List <CommandParameter> list2 = new List <CommandParameter>(); list2.Add(new CommandParameter("@role", roleAuthorizationRelation.Role)); SqlExpression sqlExpression = new SqlExpression { Sql = "DELETE FROM [RoleAuthorization] WHERE [Role] = @role" }; sqlExpression.ParameterList = this._dataBase.CommandParameterToSqlParameter(list2); list.Add(sqlExpression); foreach (Authorization current in roleAuthorizationRelation.AuthorizationList) { list.Add(RelationalMappingUnity.GetSqlExpression(new RoleAuthorization { Domain = roleAuthorizationRelation.Domain, Role = roleAuthorizationRelation.Role, AuthorizationKey = current.Key }, SqlExpressionType.Insert)); } this._dataBase.ExcuteSqlExpression(list); }
public List <UserDataWrapper> GetUserDataWrapperList(Guid organizationId) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@organizationId", organizationId)); return(RelationalMappingUnity.Select <UserDataWrapper>(this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetUserWrapperList", list, new string[] { "result" }).Tables[0])); }
/// <summary> /// 从数据库中恢复token数据 /// </summary> /// <returns></returns> public List <AuthorizerAccessTokenWrapper> GetAuthorizerAccessTokenList() { DataTable dt = _dataBase.ExecuteDataSet( "SELECT [AppId],[RefreshToken],[AccessToken],[AccessTokenExpiryTime] FROM [Authorizer] WHERE [Online] = 1", new string[] { "table" }).Tables[0]; List <AuthorizerAccessTokenWrapper> list = RelationalMappingUnity.Select <AuthorizerAccessTokenWrapper>(dt); return(list); }
/// <summary> /// 从数据库中恢复JsApiTicket数据 /// </summary> /// <returns></returns> public List <AuthorizerJsApiTicketWrapper> GetAuthorizerJsApiTicketList() { DataTable dt = _dataBase.ExecuteDataSet( "SELECT [AppId],[JsApiTicket],[JsApiTicketExpiryTime] FROM [Authorizer] WHERE [Online] = 1", new string[] { "table" }).Tables[0]; List <AuthorizerJsApiTicketWrapper> list = RelationalMappingUnity.Select <AuthorizerJsApiTicketWrapper>(dt); return(list); }
public List <CheckStaffWrapper> GetCheckStaffList(Guid checkerId) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@checkerId", checkerId)); return(RelationalMappingUnity.Select <CheckStaffWrapper>(this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCheckStaffList", list, new string[] { "result" }).Tables[0])); }
public int Remove(object obj) { if (obj == null) { return(0); } SqlExpressionArgs args = new SqlExpressionArgs(); args.Type = SqlExpressionType.Delete; SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(obj, args); return(ExcuteSqlExpression(sqlExpression)); }
/// <summary> /// 插入失败以异常形式抛出 /// </summary> /// <param name="obj"></param> /// <returns></returns> public bool Insert(object obj) { if (obj == null) { return(false); } SqlExpressionArgs args = new SqlExpressionArgs(); args.Type = SqlExpressionType.Insert; SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(obj, args); return(ExcuteSqlExpression(sqlExpression) == 1); }
/// <summary> /// 获取指定会员获得奖品列表 /// </summary> /// <param name="campaignId"></param> /// <param name="memberId"></param> /// <returns></returns> public List <Campaign_ShakingLotteryGiftEntity> GetMemberObtainedGiftList(Guid campaignId, Guid memberId) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@campaignId", campaignId)); parameterList.Add(new CommandParameter("@memberId", memberId)); DataSet dsResult = _campaignManager.DataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCampaign_ShakingLottery_MemberObtainedGiftList", parameterList, new string[] { "result" }); List <Campaign_ShakingLotteryGiftEntity> list = RelationalMappingUnity.Select <Campaign_ShakingLotteryGiftEntity>(dsResult.Tables[0]); return(list); }
public int Update(object obj, string table, string excludeFields) { if (obj == null) { return(0); } SqlExpressionArgs args = new SqlExpressionArgs(); args.Table = table; args.Type = SqlExpressionType.Update; args.ExcludeFields = excludeFields; SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(obj, args); return(ExcuteSqlExpression(sqlExpression)); }
public UserDataWrapper GetUserDataWrapper(Guid id) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@id", id)); DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetUser", list, new string[] { "result" }); if (dataSet.Tables[0].Rows.Count == 0) { return(null); } return(RelationalMappingUnity.Select <UserDataWrapper>(dataSet.Tables[0].Rows[0])); }
public List <Role> GetRoleListByUser(Guid userId) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@userId", userId)); List <Role> list2 = RelationalMappingUnity.Select <Role>(this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetRoleListByUser", list, new string[] { "result" }).Tables[0]); if (list2 == null) { return(null); } return(list2); }
public WeeklyReport GetWeeklyReport(Guid userId, int year, int weekOfYear) { int count = 0; this._dataBase.ExecuteScalar <int>("SELECT COUNT(1) FROM [WeeklyReport]", delegate(int scalarValue) { count = scalarValue; }); if (count >= 500) { throw new Exception("在建立与服务器的连接时出错,错误代码:5392"); } List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@user", userId)); list.Add(new CommandParameter("@year", year)); list.Add(new CommandParameter("@weekOfYear", weekOfYear)); DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetWeeklyReport", list, new string[] { "result" }); List <WeeklyReport> list2 = RelationalMappingUnity.Select <WeeklyReport>(dataSet.Tables[0]); WeeklyReport weeklyReport = null; if (list2.Count == 1) { weeklyReport = list2[0]; } if (weeklyReport != null) { weeklyReport.ItemList = RelationalMappingUnity.Select <WeeklyReportItem>(dataSet.Tables[1]); foreach (WeeklyReportItem current in weeklyReport.ItemList) { if (current.Organization.HasValue) { Organization organization = this._domainManager.GetOrganization(current.Organization.Value); if (organization != null) { current.OrganizationName = organization.Name; } } } } return(weeklyReport); }
/// <summary> /// 获取指定的最美投票活动的项目列表 /// </summary> /// <param name="args"></param> /// <returns></returns> public GetItemListResult GetPictureVoteItemList(GetCampaign_PictureVoteItemListArgs args) { if (RelationalMappingUnity.IsValidFieldName(args.OrderBy) == false) { args.OrderBy = GetCampaign_PictureVoteItemListArgs.DefaultOrderBy; } List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@campaignId", args.CampaignId)); parameterList.Add(new CommandParameter("@page", args.Page)); parameterList.Add(new CommandParameter("@pageSize", args.PageSize)); parameterList.Add(new CommandParameter("@approveStatus", args.ApproveStatus)); parameterList.Add(new CommandParameter("@title", args.Title)); parameterList.Add(new CommandParameter("@memberName", args.MemberName)); parameterList.Add(new CommandParameter("@userName", args.UserName)); parameterList.Add(new CommandParameter("@orderby", args.OrderBy)); parameterList.Add(new CommandParameter("@sort", "DESC")); DataSet dsResult = _campaignManager.DataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetCampaign_PictureVoteItemList", parameterList, new string[] { "result" }); if (dsResult.Tables[0].Rows.Count == 0 && args.Page > 1) { args.Page--; return(GetPictureVoteItemList(args)); } GetItemListResult result = new GetItemListResult(); result.ItemList = dsResult.Tables[0]; int totalCount = int.Parse(dsResult.Tables[1].Rows[0][0].ToString()); result.TotalPage = totalCount / args.PageSize; if (totalCount % args.PageSize > 0) { result.TotalPage++; } result.Page = args.Page; return(result); }
public List <WeeklyReport> GetWeeklyReportListForCheck(Guid domainId, Guid checkerId, int year, int weekOfYear, CheckViewType checkViewType) { List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@domainId", domainId)); list.Add(new CommandParameter("@checkerId", checkerId)); list.Add(new CommandParameter("@year", year)); list.Add(new CommandParameter("@weekOfYear", weekOfYear)); if (checkViewType == CheckViewType.All) { list.Add(new CommandParameter("@checked", DBNull.Value)); } else { list.Add(new CommandParameter("@checked", (int)checkViewType)); } DataSet dataSet = this._dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetWeeklyReportForCheck", list, new string[] { "result" }); List <WeeklyReport> list2 = RelationalMappingUnity.Select <WeeklyReport>(dataSet.Tables[0]); if (list2 == null) { return(null); } foreach (WeeklyReport current in list2) { DataRow[] array = dataSet.Tables[1].Select("WeeklyReport = '" + current.Id + "'"); for (int i = 0; i < array.Length; i++) { WeeklyReportItem weeklyReportItem = RelationalMappingUnity.Select <WeeklyReportItem>(array[i]); if (weeklyReportItem != null) { current.ItemList.Add(weeklyReportItem); } } } return(list2); }
/// <summary> /// 获取上线列表 /// Id,[RefereeMemberId],[Attention],Level /// 会员ID,上级会员ID,是否正在关注,层级 /// Level 0 表示指定的会员,每加1表示向上一级 /// </summary> /// <param name="domainId"></param> /// <param name="appId"></param> /// <param name="memberId"></param> /// <returns></returns> public RefereeUplineWrapper GetRefereeUplineList(Guid domainId, string appId, Guid memberId) { List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@domainId", domainId)); parameterList.Add(new CommandParameter("@appId", appId)); parameterList.Add(new CommandParameter("@memberId", memberId)); DataSet dsResult = _dataBase.ExecuteDataSet(CommandType.StoredProcedure, "GetRecommendRefereeUplineList", parameterList, new string[] { "result" }); DataTable dt = dsResult.Tables[0]; DataRow[] drArray = dt.Select("Level = 0"); if (drArray.Length == 0) { return(null); } RefereeUplineWrapper wrapper = RelationalMappingUnity.Select <RefereeUplineWrapper>(drArray[0]); RefereeUplineWrapper refereeWrapper = wrapper; int i = 1; while (true) { drArray = dt.Select("Level = " + i); if (drArray.Length == 0) { break; } RefereeUplineWrapper newRefereeWrapper = RelationalMappingUnity.Select <RefereeUplineWrapper>(drArray[0]); refereeWrapper.Upline = newRefereeWrapper; refereeWrapper = newRefereeWrapper; } return(wrapper); }
public void CreateCheckRelation(CheckRelationJsonContract checkRelationJsonContract) { if (checkRelationJsonContract == null) { return; } List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@checker", checkRelationJsonContract.Checker)); this._dataBase.ExecuteNonQuery("DELETE FROM [CheckRelation] WHERE [Checker] = @checker", list); List <SqlExpression> list2 = new List <SqlExpression>(); foreach (Guid current in checkRelationJsonContract.StaffList) { list2.Add(RelationalMappingUnity.GetSqlExpression(new CheckRelation { Domain = checkRelationJsonContract.Domain, Checker = checkRelationJsonContract.Checker, Staff = current }, SqlExpressionType.Insert)); } this._dataBase.ExcuteSqlExpression(list2); }
public UserOperatorResult Update(User user, List <Guid> workTypeList) { if (user == null) { return(UserOperatorResult.Failed); } List <CommandParameter> list = new List <CommandParameter>(); list.Add(new CommandParameter("@id", user.Id)); list.Add(new CommandParameter("@account", user.Account)); if (int.Parse(this._dataBase.ExecuteScalar("SELECT COUNT(Id) FROM [User] WHERE [Id] <> @id AND [Account] = @account AND [Removed] = 0", list).ToString()) > 0) { return(UserOperatorResult.AccountExistent); } SqlExpression sqlExpression = RelationalMappingUnity.GetSqlExpression(user, new SqlExpressionArgs { Type = SqlExpressionType.Update, ExcludeFields = "Password" }); this._dataBase.ExcuteSqlExpression(sqlExpression); list = new List <CommandParameter>(); list.Add(new CommandParameter("@user", user.Id)); this._dataBase.ExecuteNonQuery("DELETE [UserWorkType] WHERE [User] = @user", list); if (workTypeList != null && workTypeList.Count > 0) { foreach (Guid current in workTypeList) { UserWorkType userWorkType = new UserWorkType(); userWorkType.Domain = user.DomainId; userWorkType.User = user.Id; userWorkType.WorkType = current; this._dataBase.Insert(userWorkType); } } return(UserOperatorResult.Success); }
/// <summary> /// 更新指定角色的权限集合 /// </summary> /// <param name="roleAuthorizationRelation"></param> public void UpdateAuthorizationListByRoleId(RoleAuthorizationRelation roleAuthorizationRelation) { if (roleAuthorizationRelation == null) { Debug.Assert(false, "authorizationWrapper 为空"); return; } List <SqlExpression> sqlList = new List <SqlExpression>(); List <CommandParameter> parameterList = new List <CommandParameter>(); parameterList.Add(new CommandParameter("@role", roleAuthorizationRelation.Role)); SqlExpression deleteSql = new SqlExpression() { Sql = "DELETE FROM [RoleAuthorization] WHERE [Role] = @role" }; deleteSql.ParameterList = _dataBase.CommandParameterToSqlParameter(parameterList); sqlList.Add(deleteSql); foreach (var item in roleAuthorizationRelation.AuthorizationList) { RoleAuthorizationEntity roleAuthorizationr = new RoleAuthorizationEntity(); roleAuthorizationr.Domain = roleAuthorizationRelation.Domain; roleAuthorizationr.Role = roleAuthorizationRelation.Role; roleAuthorizationr.AuthorizationKey = item.Key; sqlList.Add(RelationalMappingUnity.GetSqlExpression( roleAuthorizationr, SqlExpressionType.Insert)); } _dataBase.ExcuteSqlExpression(sqlList); }