public static string GetDataList(string SchoolId, string BookId, string BookName, string Resource_TypeName, string IsNeed, int PageSize, int PageIndex) { try { bool isBook = true; //是否图书 bool isCanExecing = true; //是否可执行 string strSql = string.Empty; strSql = "select top 1 FileSyncExecRecord_TimeStart from FileSyncExecRecord where FileSyncExecRecord_Status = '0' and FileSyncExecRecord_Type='同步学校资源" + SchoolId + "' order by FileSyncExecRecord_TimeStart desc"; string str = Rc.Common.DBUtility.DbHelperSQL.GetSingle(strSql).ToString(); if (str != "") { isCanExecing = false; } int rCount; SchoolId = SchoolId.Filter(); BookId = BookId.Filter(); DataTable dtRes = new DataTable(); List <object> listReturn = new List <object>(); strSql = string.Empty; string strWhere = string.Format(" SchoolId='{0}' ", SchoolId); if (string.IsNullOrEmpty(BookId)) { //dtRes = new BLL_SyncFileToSchool().GetListByPage(1, SchoolId, BookId, PageIndex, PageSize, out rCount).Tables[0]; #region 图书列表 BLL_SyncFileToSchoolDataDetail bll = new BLL_SyncFileToSchoolDataDetail(); if (IsNeed == "1") { strWhere += " and SyncStatus='0' "; } dtRes = bll.GetListByPage(strWhere, "SyncStatus,Resource_Type,BookName", ((PageIndex - 1) * PageSize + 1), (PageIndex * PageSize)).Tables[0]; rCount = bll.GetRecordCount(strWhere); foreach (DataRow item in dtRes.Rows) { listReturn.Add(new { Resource_Type = item["Resource_Type"].ToString(), Resource_TypeName = item["Resource_TypeName"].ToString(), BookId = item["BookId"].ToString(), BookName = item["BookName"].ToString(), ParentName = "", rtrfId = "", rtrfName = "", CreateTime = pfunction.ConvertToLongDateTime(item["CreateTime"].ToString()), SyncStatus = item["SyncStatus"].ToString(), SyncStatusName = item["SyncStatus"].ToString() == "1" ? "已同步" : "待同步", IsCanExecing = isCanExecing, IsBook = isBook }); } if (dtRes.Rows.Count > 0) { return(JsonConvert.SerializeObject(new { err = "null", PageIndex = PageIndex, PageSize = PageSize, TotalCount = rCount, list = listReturn, IsBook = isBook })); } else { return(JsonConvert.SerializeObject(new { err = "暂无数据" })); } #endregion } else { //dtRes = new BLL_SyncFileToSchool().GetListByPage(2, SchoolId, BookId, PageIndex, PageSize, out rCount).Tables[0]; #region 资源列表 isBook = false; BLL_SyncFileToSchool bll = new BLL_SyncFileToSchool(); dtRes = bll.GetListByPage(SchoolId, BookId, IsNeed, PageIndex, PageSize, out rCount).Tables[0]; foreach (DataRow item in dtRes.Rows) { listReturn.Add(new { Resource_Type = item["Resource_Type"].ToString(), Resource_TypeName = Resource_TypeName, BookId = BookId, BookName = BookName, ParentName = ">>" + item["ResourceFolder_Name"].ToString(), rtrfId = item["ResourceToResourceFolder_Id"].ToString(), rtrfName = item["Resource_Name"].ToString(), CreateTime = pfunction.ConvertToLongDateTime(item["CreateTime"].ToString()), SyncStatus = string.IsNullOrEmpty(item["SyncFileToSchoolDataDetail2_Id"].ToString()) ? "1" : "0", SyncStatusName = string.IsNullOrEmpty(item["SyncFileToSchoolDataDetail2_Id"].ToString()) ? "已同步" : "待同步", IsCanExecing = isCanExecing, IsBook = isBook }); } if (dtRes.Rows.Count > 0) { return(JsonConvert.SerializeObject(new { err = "null", PageIndex = PageIndex, PageSize = PageSize, TotalCount = rCount, list = listReturn, IsBook = isBook })); } else { return(JsonConvert.SerializeObject(new { err = "暂无数据" })); } #endregion } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { err = "error" //ex.Message.ToString() })); } }
public static string GetDataList(string isCanExecing, string schoolId, string bookId, int PageSize, int PageIndex) { try { int rCount; schoolId = schoolId.Filter(); bookId = bookId.Filter(); DataTable dtRes = new DataTable(); List <object> listReturn = new List <object>(); string strSql = string.Empty; string strSqlCount = string.Empty; string strWhere = string.Empty; string isShowDetail = "0"; if (string.IsNullOrEmpty(bookId)) { isShowDetail = "1"; dtRes = new BLL_SyncFileToSchool().GetListByPage(1, schoolId, bookId, PageIndex, PageSize, out rCount).Tables[0]; #region 图书列表 // strSql = string.Format(@"select * from (select ROW_NUMBER() over(ORDER BY CreateTime desc) row,* from ( //select rf2.Resource_Type,dic.D_Name as Resource_TypeName,rf2.Book_Id as bookId,rf2.ResourceFolder_Name as bookName,min(t.CreateTime) as CreateTime //,null as rtrfId,null as rtrfName //from SyncData t //inner join ResourceToResourceFolder rtrf on rtrf.ResourceToResourceFolder_Id=t.DataId //inner join ResourceFolder rf2 on rf2.Book_Id=rtrf.Book_Id and rf2.ResourceFolder_Level=5 //left join BookAudit ba on ba.ResourceFolder_Id=rtrf.Book_Id //inner join UserBuyResources ub on ub.Book_Id=rtrf.Book_Id //inner join VW_UserOnClassGradeSchool vw on vw.SchoolId='{0}' and vw.UserId=ub.UserId //inner join Common_Dict dic on dic.Common_Dict_Id=rf2.Resource_Type //where t.TableName='ResourceToResourceFolder' and t.OperateType in('add','modify') and t.SyncStatus not in(0,2) {1} //and rtrf.Resource_Class='{2}' //and ba.AuditState='1' //and not exists(select 1 from SyncFileToSchool where SchoolId='{0}' and ResourceToResourceFolder_Id=rtrf.ResourceToResourceFolder_Id and CreateTime>t.CreateTime) //group by rf2.Resource_Type,dic.D_Name,rf2.Book_Id,rf2.ResourceFolder_Name //) t ) t where row between {3} and {4} " // , schoolId // , strWhere // , Resource_ClassConst.云资源 // , ((PageIndex - 1) * PageSize + 1) // , (PageIndex * PageSize)); // strSqlCount = string.Format(@"select count(1) as icount from (select rf2.Book_Id from SyncData t //inner join ResourceToResourceFolder rtrf on rtrf.ResourceToResourceFolder_Id=t.DataId //inner join ResourceFolder rf2 on rf2.Book_Id=rtrf.Book_Id and rf2.ResourceFolder_Level=5 //left join BookAudit ba on ba.ResourceFolder_Id=rtrf.Book_Id //inner join UserBuyResources ub on ub.Book_Id=rtrf.Book_Id //inner join VW_UserOnClassGradeSchool vw on vw.SchoolId='{0}' and vw.UserId=ub.UserId //inner join Common_Dict dic on dic.Common_Dict_Id=rf2.Resource_Type //where t.TableName='ResourceToResourceFolder' and t.OperateType in('add','modify') and t.SyncStatus not in(0,2) {1} //and rtrf.Resource_Class='{2}' //and ba.AuditState='1' //and not exists(select 1 from SyncFileToSchool where SchoolId='{0}' and ResourceToResourceFolder_Id=rtrf.ResourceToResourceFolder_Id and CreateTime>t.CreateTime) //group by rf2.Resource_Type,dic.D_Name,rf2.Book_Id,rf2.ResourceFolder_Name //) t " // , schoolId // , strWhere // , Resource_ClassConst.云资源); #endregion } else { dtRes = new BLL_SyncFileToSchool().GetListByPage(2, schoolId, bookId, PageIndex, PageSize, out rCount).Tables[0]; #region 资源列表 // strWhere += " and rf2.Book_Id='" + bookId + "' "; // strSql = string.Format(@"select * from (select ROW_NUMBER() over(ORDER BY CreateTime desc) row,* from ( //select rf2.Resource_Type,dic.D_Name as Resource_TypeName,rf2.Book_Id as bookId,rf2.ResourceFolder_Name as bookName,min(t.CreateTime) as CreateTime //,rtrf.ResourceToResourceFolder_Id as rtrfId,rtrf.Resource_Name as rtrfName //from SyncData t //inner join ResourceToResourceFolder rtrf on rtrf.ResourceToResourceFolder_Id=t.DataId //inner join ResourceFolder rf2 on rf2.Book_Id=rtrf.Book_Id and rf2.ResourceFolder_Level=5 //left join BookAudit ba on ba.ResourceFolder_Id=rtrf.Book_Id //inner join UserBuyResources ub on ub.Book_Id=rtrf.Book_Id //inner join VW_UserOnClassGradeSchool vw on vw.SchoolId='{0}' and vw.UserId=ub.UserId //inner join Common_Dict dic on dic.Common_Dict_Id=rf2.Resource_Type //where t.TableName='ResourceToResourceFolder' and t.OperateType in('add','modify') and t.SyncStatus not in(0,2) {1} //and rtrf.Resource_Class='{2}' //and ba.AuditState='1' //and not exists(select 1 from SyncFileToSchool where SchoolId='{0}' and ResourceToResourceFolder_Id=rtrf.ResourceToResourceFolder_Id and CreateTime>t.CreateTime) //group by rf2.Resource_Type,dic.D_Name,rf2.Book_Id,rf2.ResourceFolder_Name,rtrf.ResourceToResourceFolder_Id,rtrf.Resource_Name //) t ) t where row between {3} and {4} " // , schoolId // , strWhere // , Resource_ClassConst.云资源 // , ((PageIndex - 1) * PageSize + 1) // , (PageIndex * PageSize)); // strSqlCount = string.Format(@"select count(1) as icount from ( select rtrf.ResourceToResourceFolder_Id from SyncData t //inner join ResourceToResourceFolder rtrf on rtrf.ResourceToResourceFolder_Id=t.DataId //inner join ResourceFolder rf2 on rf2.Book_Id=rtrf.Book_Id and rf2.ResourceFolder_Level=5 //left join BookAudit ba on ba.ResourceFolder_Id=rtrf.Book_Id //inner join UserBuyResources ub on ub.Book_Id=rtrf.Book_Id //inner join VW_UserOnClassGradeSchool vw on vw.SchoolId='{0}' and vw.UserId=ub.UserId //inner join Common_Dict dic on dic.Common_Dict_Id=rf2.Resource_Type //where t.TableName='ResourceToResourceFolder' and t.OperateType in('add','modify') and t.SyncStatus not in(0,2) {1} //and rtrf.Resource_Class='{2}' //and ba.AuditState='1' //and not exists(select 1 from SyncFileToSchool where SchoolId='{0}' and ResourceToResourceFolder_Id=rtrf.ResourceToResourceFolder_Id and CreateTime>t.CreateTime) //group by rf2.Resource_Type,dic.D_Name,rf2.Book_Id,rf2.ResourceFolder_Name,rtrf.ResourceToResourceFolder_Id,rtrf.Resource_Name ) t " // , schoolId // , strWhere // , Resource_ClassConst.云资源); // dtRes = Rc.Common.DBUtility.DbHelperSQL.Query(strSql, 600).Tables[0]; // rCount = Convert.ToInt32(Rc.Common.DBUtility.DbHelperSQL.GetSingle(strSqlCount, 600).ToString()); #endregion } int inum = 0; for (int i = 0; i < dtRes.Rows.Count; i++) { inum++; listReturn.Add(new { inum = (i + 1), Resource_Type = dtRes.Rows[i]["Resource_Type"].ToString(), Resource_TypeName = dtRes.Rows[i]["Resource_TypeName"].ToString(), bookId = dtRes.Rows[i]["bookId"].ToString(), rtrfId = dtRes.Rows[i]["rtrfId"].ToString(), bookName = dtRes.Rows[i]["bookName"].ToString(), rtrfName = dtRes.Rows[i]["rtrfName"].ToString(), CreateTime = pfunction.ConvertToLongDateTime(dtRes.Rows[i]["CreateTime"].ToString()), IsShowDetail = isShowDetail, IsCanExecing = isCanExecing }); } if (inum > 0) { return(JsonConvert.SerializeObject(new { err = "null", PageIndex = PageIndex, PageSize = PageSize, TotalCount = rCount, list = listReturn })); } else { return(JsonConvert.SerializeObject(new { err = "暂无数据" })); } } catch (Exception ex) { return(JsonConvert.SerializeObject(new { err = "error" //ex.Message.ToString() })); } }