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 <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 <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 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); }
/// <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); }
/// <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); }
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])); }
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 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); }
/// <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 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); }
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); }