public JsonResult GetBgSound(string currentpage, string pagesize) { #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Audio_Background> myIQueryable = null; myIQueryable = myOperating.Audio_Background; // if (myIQueryable != null) { var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { BgMusicId = s.BgMusicId, MusicTitle = s.MusicTitle, MusicUrl = StaticVarClass.myDomain + s.MusicUrl, TimeSeconds = s.TimeSeconds }).ToList(); myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = BookTable; } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public JsonResult ArticleContent(string articleid) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { ArticlDataContent myArticlDataContent = new ArticlDataContent(); long myLong = 0;//文章主键 bool isLong = long.TryParse(articleid, out myLong); if (isLong) { Teacher_Article myTable = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == myLong && p.Status == 200); DataMethodClass myDataMethodClass = new DataMethodClass(); if (myTable != null) { myArticlDataContent.ArticleId = myLong; myArticlDataContent.ArticleTitle = myTable.ArticleTitle; if (!String.IsNullOrWhiteSpace(myTable.ArticleImages)) { myArticlDataContent.ArticleImages = StaticVarClass.myDomain + myTable.ArticleImages; } else { myArticlDataContent.ArticleImages = StaticVarClass.myDomain + "defaultTeacherArticle.png"; } myArticlDataContent.AddDate = myTable.AddDate; myArticlDataContent.ReadTimes = myTable.ReadTimes; myArticlDataContent.OpenUrl = StaticVarClass.myDomain + "Community/" + myLong + ".html"; // #region 阅读次数加一 if (myTable.ReadTimes != null) { myTable.ReadTimes = myTable.ReadTimes + 1; } else { myTable.ReadTimes = 1; } myOperating.SaveChanges(); #endregion } myStatusData.dataTable = myArticlDataContent; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult AddComment(string articleid, string content) { StatusData myStatusData = new StatusData(); //返回的类型 string mobilePhone = ""; // // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; // using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { Discover_Article_Comment myRecord = new Discover_Article_Comment(); long myLong = 0;//要评论的文章 bool isOk = long.TryParse(articleid, out myLong); if (isOk) { try { myRecord.AboutId = myLong; myRecord.Detail = content; myRecord.MobilePhone = mobilePhone; myRecord.NickName = ""; myRecord.AddDate = DateTime.Now; myRecord.Status = 200; myOperating.Discover_Article_Comment.Add(myRecord); myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "参数错误"; } } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
// #region 检查是否收藏 public bool CollectExist(int classid, long aboutid, bool isTeacherVideo = false) {// // bool isExist = false; // #region 检查授权 string mobilePhone = "";//手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; // using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { int myCount = 0; // try { if (isTeacherVideo) {//classid=45679 myCount = myOperating.User_Collect.Count(p => p.MobilePhone == mobilePhone && p.IsTeacherVideo == true && p.AboutId == aboutid); } else { myCount = myOperating.User_Collect.Count(p => p.MobilePhone == mobilePhone && p.ClassId == classid && p.AboutId == aboutid); } if (myCount > 0) { isExist = true; } } catch { isExist = false; } } } return(isExist); }
public JsonResult DelCollectItem(string collectid) { #region 检查授权 string myMobilePhone = ""; AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; try { using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { long myLong = 0; // bool isLong = long.TryParse(collectid, out myLong); User_Collect myUser_Collect = new User_Collect(); myUser_Collect = myOperating.User_Collect.FirstOrDefault(p => p.MobilePhone == myMobilePhone && p.CollectId == myLong);; // if (myUser_Collect != null) { myOperating.User_Collect.Remove(myUser_Collect); // myOperating.SaveChanges(); // myStatusData.operateStatus = 200; } } } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult GetAudio(string myid) { //orderby=1按日期排序,2按播放次数排序 string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { if (!String.IsNullOrWhiteSpace(myid)) { long myLong = 0; bool isOk = long.TryParse(myid, out myLong); if (isOk) { // var myChild_Audio_List = myOperating.Child_Audio_List.Join(myOperating.Child_Audio_Album, tL => tL.AlbumId, album => album.AlbumId, (tL, album) => new { tL.AudioId, tL.AudioTitle, album.AlbumImage, tL.AudioUrl, tL.AudioWords, tL.PlayTimes, tL.TimeSeconds, tL.Status }).Where(p => p.AudioId == myLong && p.Status == 200).Select(s => new { AudioId = s.AudioId, AudioTitle = s.AudioTitle, AudioImage = StaticVarClass.myDomain + s.AlbumImage, AudioUrl = StaticVarClass.myDomain + s.AudioUrl, AudioWords = s.AudioWords, PlayTimes = s.PlayTimes, TimeSeconds = s.TimeSeconds }).ToList(); if (myChild_Audio_List != null) { myStatusData.dataTable = myChild_Audio_List; } myStatusData.operateStatus = 200; } else { myStatusData.operateStatus = 400; } } else { myStatusData.operateStatus = 400; } } return(Json(myStatusData)); }
public JsonResult GetBook(string myid) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { if (!String.IsNullOrWhiteSpace(myid)) { long myLong = 0; bool isOk = long.TryParse(myid, out myLong); if (isOk) { var myChild_Book_Click = myOperating.Child_Book_Click.Where(p => p.BookID == myLong && p.BookStatus == 200).Select(s => new { BookID = s.BookID, BookName = s.BookName, BookOnlineUrl = StaticVarClass.BookClickResourceUrl + s.BookOnlineUrl, ScreenH = s.ScreenH }).ToList(); if (myChild_Book_Click != null) { myStatusData.dataTable = myChild_Book_Click; } myStatusData.operateStatus = 200; } else { myStatusData.operateStatus = 400; } } else { myStatusData.operateStatus = 400; } } return(Json(myStatusData)); }
public JsonResult GetUserInfo() { StatusData myStatusData = new StatusData();//返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // if (checkAuthCodeBool) { DataMethodClass myDataMethodClass = new DataMethodClass();//检查验证码 // //User_UserName myUserInfo = new User_UserName(); using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { var myUserInfo = myOperating.User_UserName.Select(s => new { MobilePhone = s.MobilePhone, HeadImage = StaticVarClass.myDomain + s.HeadImage, NickName = s.NickName, Sex = s.Sex, BirthDate = s.BirthDate, ProvinceName = s.ProvinceName, CityName = s.CityName, DistrictName = s.DistrictName, DistrictNum = s.DistrictNum, Address = s.Address, Kindergarten = s.Kindergarten, RoleId = s.RoleId }).FirstOrDefault(p => p.MobilePhone == myAuthCodeInstance.mobilePhone); if (myUserInfo == null) { myStatusData.operateStatus = 1;//用户名错误 } else { try { myStatusData.dataTable = myUserInfo; myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public JsonResult GetVideo(string myid) { //orderby=1按日期排序,2按播放次数排序 string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { if (!String.IsNullOrWhiteSpace(myid)) { long myLong = 0; bool isOk = long.TryParse(myid, out myLong); if (isOk) { var myTeacher_Video_List = myOperating.Teacher_Video_List.Where(p => p.VideoId == myLong && p.Status == 200).Select(s => new { VideoId = s.VideoId, VideoTitle = s.VideoTitle, VideoDes = s.VideoDes, VideoImage = StaticVarClass.myDomain + s.VideoImage, VideoUrl = StaticVarClass.myDomain + s.VideoUrl, PlayTimes = s.PlayTimes, TimeSeconds = s.TimeSeconds, ClassId = s.ClassId }).ToList(); if (myTeacher_Video_List != null) { myStatusData.dataTable = myTeacher_Video_List; } myStatusData.operateStatus = 200; } else { myStatusData.operateStatus = 400; } } else { myStatusData.operateStatus = 400; } } return(Json(myStatusData)); }
public JsonResult GetReadDays() { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; // ReadCount myReadCount = new ReadCount(); // var myUser_Book_Click_ReadDay = myOperating.User_Book_Click_ReadDay.Where(p => p.MobilePhone == mobilePhone).Select(s => new { ReadDayCount = s.ReadDayCount, RecentlyReadBookId = s.RecentlyReadBookId }).FirstOrDefault(); if (myUser_Book_Click_ReadDay != null) { myReadCount.RecentlyReadBookId = myUser_Book_Click_ReadDay.RecentlyReadBookId; myReadCount.ReadDayCount = myUser_Book_Click_ReadDay.ReadDayCount; myReadCount.RankNum = UserOptionClass.ReadDayRank(mobilePhone); } // myStatusData.dataTable = myReadCount; myStatusData.operateStatus = 200; } } return(Json(myStatusData)); }
public JsonResult ArticleList(string classid, string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "AddDate"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Teacher_Article> myIQueryable = null; if (!String.IsNullOrWhiteSpace(classid)) { int myInt = 0; bool isOk = int.TryParse(classid, out myInt); if ((isOk) && (myInt > 0)) { myIQueryable = myOperating.Teacher_Article.Where(p => p.ClassId == myInt && p.Status == 200); } else { myIQueryable = myOperating.Teacher_Article.Where(p => p.Status == 200); } } else { myIQueryable = myOperating.Teacher_Article.Where(p => p.Status == 200); } // if (myIQueryable != null) { List <ArticlDataList> myArticlDataList = new List <ArticlDataList>(); var EfDataTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { ArticlId = s.ArticlId, ArticleTitle = s.ArticleTitle, ArticleImages = s.ArticleImages, ReadTimes = s.ReadTimes }).ToList(); if (EfDataTable != null) { long ArticlId = 0; for (int i = 0; i < EfDataTable.Count(); i++) { ArticlDataList ArticlDataListItem = new ArticlDataList(); ArticlId = EfDataTable[i].ArticlId; ArticlDataListItem.ArticleId = EfDataTable[i].ArticlId; ArticlDataListItem.ArticleTitle = EfDataTable[i].ArticleTitle; if (!String.IsNullOrWhiteSpace(EfDataTable[i].ArticleImages)) { ArticlDataListItem.ArticleImages = StaticVarClass.myDomain + EfDataTable[i].ArticleImages; } else { ArticlDataListItem.ArticleImages = StaticVarClass.myDomain + "defaultTeacherArticle.png"; } ArticlDataListItem.OpenUrl = StaticVarClass.myDomain + "Community/" + EfDataTable[i].ArticlId + ".html"; ArticlDataListItem.ReadTimes = EfDataTable[i].ReadTimes; ArticlDataListItem.CommentCount = myOperating.Teacher_Article_Comment.Count(p => p.AboutId == ArticlId); myArticlDataList.Add(ArticlDataListItem); } } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myArticlDataList; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult DeleteItem(string myid, string del) { #region 检查授权 string myMobilePhone = "";//手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { int operatType = 0; //1删除全部,2删除指定 long idLong = 0; #region 判断参数 if (!String.IsNullOrWhiteSpace(del)) { switch (del.ToLower()) { case "all": operatType = 1; break; case "single": if (!String.IsNullOrWhiteSpace(myid)) { bool isLong = long.TryParse(myid, out idLong); if (isLong) { operatType = 2; } } break; } } #endregion // if (operatType == 1) { IQueryable <Child_Audio_List_User> myList = myOperating.Child_Audio_List_User.Where(p => p.MobilePhone == myMobilePhone); if (myList != null) { foreach (Child_Audio_List_User recordItem in myList) { FunctionClass.DeleteFile(recordItem.AudioUrl); myOperating.Child_Audio_List_User.Remove(recordItem); } myOperating.SaveChanges(); } myStatusData.operateStatus = 200; } else if (operatType == 2) { Child_Audio_List_User myDataRecord = new Child_Audio_List_User(); myDataRecord = myOperating.Child_Audio_List_User.FirstOrDefault(p => p.AudioUserId == idLong && p.MobilePhone == myMobilePhone); if (myDataRecord != null) { FunctionClass.DeleteFile(myDataRecord.AudioUrl); myOperating.Child_Audio_List_User.Remove(myDataRecord); myOperating.SaveChanges(); myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 0; } } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult UpdateFile(string filetype, string upfilename) { StatusData myStatusData = new StatusData();//返回的类型 #region 检查授权 string mobilePhone = ""; AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // string myPath = ""; string fileExt = ""; string myFolder = ""; int RandKey = 1000; string fileName = ""; string filePath = ""; // #region 判断是否续传 string upfilenamefullpath = ""; bool xuchuan = false; // if (!String.IsNullOrWhiteSpace(upfilename)) { upfilenamefullpath = Path.Combine(HttpRuntime.AppDomainAppPath, upfilename); if (System.IO.File.Exists(upfilenamefullpath)) { xuchuan = true; } else { xuchuan = false; } } #endregion // if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; try { if (!xuchuan) { #region 是续传,获得文件相关属性 folderActions myForderObject = new folderActions(); // myPath = StaticVarClass.ImageFolderCfg + "/" + DateTime.Now.Year.ToString() + "/" + mobilePhone + "/" + DateTime.Now.Month.ToString(); fileExt = filetype; #region 判断文件类型 if (!String.IsNullOrWhiteSpace(fileExt)) { fileExt = fileExt.ToLower(); } else { fileExt = ""; } switch (fileExt) { case "jpg": case "png": case "gif": case "jpeg": myPath = StaticVarClass.ImageFolderCfg; break; case "mp3": case "aac": myPath = StaticVarClass.AudioFolderCfg; break; case "mov": case "mp4": myPath = StaticVarClass.VideoFolderCfg; break; default: myStatusData.operateStatus = 400; myStatusData.operateMsg = "文件类型错误"; return(Json(myStatusData)); } myPath = myPath + "/" + DateTime.Now.Year.ToString() + "/" + mobilePhone + "/" + DateTime.Now.Month.ToString(); #endregion // myForderObject.setFolderFullName = myPath; myForderObject.CreateFolder(); myFolder = myForderObject.getFolderRealPath; Random ran = new Random(unchecked ((int)DateTime.Now.Ticks)); RandKey = ran.Next(1, 9999); fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + RandKey.ToString(); filePath = myFolder + "/" + fileName + "." + fileExt; #endregion } else {//续传,直接用文件路径 filePath = upfilenamefullpath; } // try { if ((!xuchuan) && (!System.IO.File.Exists(filePath))) { #region 新文件 using (Stream stream = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { //将字符信息写入文件系统 System.IO.Stream s = HttpContext.Request.InputStream; if (s.Length > 10) { int count = 0; byte[] buffer = new byte[1024]; while ((count = s.Read(buffer, 0, 1024)) > 0) { stream.Write(buffer, 0, count); } s.Flush(); s.Close(); s.Dispose(); UploadFileClass myUploadFileClass = new UploadFileClass(); myUploadFileClass.filename = myPath + "/" + fileName + "." + fileExt; myUploadFileClass.fileurl = myPath + "/" + fileName + "." + fileExt; //myUploadFileClass.fileurl = StaticVarClass.myDomain + myPath + "/" + fileName + "." + fileExt; myStatusData.dataTable = myUploadFileClass; myStatusData.operateStatus = 200; } else { myStatusData.operateMsg = "文件为空"; myStatusData.operateStatus = 0; } } // #endregion } else if (xuchuan) { #region 续传文件 using (Stream stream = new FileStream(filePath, FileMode.Append, FileAccess.Write)) { //将字符信息写入文件系统 System.IO.Stream s = HttpContext.Request.InputStream; if (s.Length > 10) { int count = 0; byte[] buffer = new byte[1024]; while ((count = s.Read(buffer, 0, 1024)) > 0) { stream.Write(buffer, 0, count); } s.Flush(); s.Close(); s.Dispose(); // UploadFileClass myUploadFileClass = new UploadFileClass(); myUploadFileClass.filename = upfilename; myUploadFileClass.fileurl = upfilename; //myUploadFileClass.fileurl = StaticVarClass.myDomain + upfilename; myStatusData.dataTable = myUploadFileClass; myStatusData.operateStatus = 200; } else { myStatusData.operateMsg = "文件为空"; myStatusData.operateStatus = 0; } } #endregion } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "文件已经存在"; } } catch {//发生错误删除文件 if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } myStatusData.operateStatus = -1; } } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult AddCollect(string classid, string aboutid) { // #region 检查授权 string myMobilePhone = ""; //手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { int myClassid = 0; //类别 long myAboutid = 0; //主键 #region 判断输入参数 bool classIsNumber = false; //判断输入参数类型 bool AboutIsNumber = false; //判断输入参数类型 if (!String.IsNullOrEmpty(aboutid)) { classIsNumber = int.TryParse(classid, out myClassid); } // if (!String.IsNullOrEmpty(aboutid)) { AboutIsNumber = long.TryParse(aboutid, out myAboutid); } // if ((myClassid < 1) || (myClassid > 9) || (myAboutid < 1)) { myStatusData.operateMsg = "输入参数错误"; myStatusData.operateStatus = 400; return(Json(myStatusData)); } #endregion // #region 检查是否已经收藏 int checkUser_Collect = myOperating.User_Collect.Count(p => p.ClassId == myClassid && p.AboutId == myAboutid && p.MobilePhone == myMobilePhone); if (checkUser_Collect > 0) { myStatusData.operateMsg = "已收藏,不能重复收藏"; myStatusData.operateStatus = 400; return(Json(myStatusData)); } #endregion // bool isTeacherVideo = false; //类别为45679的收藏为true bool isExict = false; //是否存在 string myCoverImage = ""; //图片 string myTitle = ""; //标题 string mySummart = ""; //摘要 #region 根据收藏类别取出图片和标题 switch (myClassid) {///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; case 1: //点一点 #region 点一点 Child_Book_Click myChild_Book_Click = new Child_Book_Click(); myChild_Book_Click = myOperating.Child_Book_Click.FirstOrDefault(p => p.BookID == myAboutid); if (myChild_Book_Click != null) { myTitle = myChild_Book_Click.BookName; if (!String.IsNullOrWhiteSpace(myChild_Book_Click.BookOnlineUrl)) { myCoverImage = StaticVarClass.BookClickResourceUrl + myChild_Book_Click.BookOnlineUrl + "main.png"; } isExict = true; } #endregion break; case 2: //2听一听 #region 听一听 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAboutid); if (myChild_Audio_List != null) { myTitle = myChild_Audio_List.AudioTitle; int AlibumId = myChild_Audio_List.AlbumId; string AudioBgImg = ""; try { AudioBgImg = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == AlibumId).AlbumImage; if (!String.IsNullOrWhiteSpace(AudioBgImg)) { myCoverImage = StaticVarClass.myDomain + AudioBgImg; } } catch { } isExict = true; } #endregion break; case 3: //3看一看 #region 一看 Child_Video_List myChild_Video_List = new Child_Video_List(); myChild_Video_List = myOperating.Child_Video_List.FirstOrDefault(p => p.VideoId == myAboutid); if (myChild_Video_List != null) { myTitle = myChild_Video_List.VideoTitle; myCoverImage = StaticVarClass.myDomain + myChild_Video_List.VideoImage; isExict = true; } #endregion break; case 4: case 5: case 6: case 7: //4课程讲解;5幼儿公开课;6教育技能;7操作说明 #region 教师社区 Teacher_Video_List myTeacher_Video_List = new Teacher_Video_List(); myTeacher_Video_List = myOperating.Teacher_Video_List.FirstOrDefault(p => p.VideoId == myAboutid); if (myTeacher_Video_List != null) { myTitle = myTeacher_Video_List.VideoTitle; myCoverImage = StaticVarClass.myDomain + myTeacher_Video_List.VideoImage; isExict = true; isTeacherVideo = true; } #endregion break; case 8: //8教师社区 #region 教师社区 Teacher_Article myTeacher_Article = new Teacher_Article(); myTeacher_Article = myOperating.Teacher_Article.FirstOrDefault(p => p.ArticlId == myAboutid); if (myTeacher_Article != null) { myTitle = myTeacher_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myTeacher_Article.ArticleImages)) { myCoverImage = StaticVarClass.myDomain + myTeacher_Article.ArticleImages; } if ((myTeacher_Article.ArticleSummary != null) && (myTeacher_Article.ArticleSummary.Length > 50)) { mySummart = myTeacher_Article.ArticleSummary.Substring(0, 50); } else { mySummart = myTeacher_Article.ArticleSummary; } isExict = true; } #endregion break; case 9: //9精彩瞬间 #region 精彩瞬间 Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == myAboutid); if (myDiscover_Article != null) { myTitle = myDiscover_Article.ArticleTitle; if (!String.IsNullOrWhiteSpace(myDiscover_Article.ArticleImages)) { //取出第一幅图 string[] imageOne = myDiscover_Article.ArticleImages.Split(';'); if (imageOne.Count() > 0) { myCoverImage = StaticVarClass.myDomain + imageOne[0]; } } if ((myDiscover_Article.ArticleContent != null) && (myDiscover_Article.ArticleContent.Length > 50)) { mySummart = myDiscover_Article.ArticleContent.Substring(0, 50); } else { mySummart = myDiscover_Article.ArticleContent; } isExict = true; } #endregion break; } #endregion // #region 添加到数据库 if (isExict) { try { User_Collect myUser_Collect = new User_Collect(); // myUser_Collect.ClassId = myClassid; myUser_Collect.AboutId = myAboutid; myUser_Collect.AboutTitle = myTitle; myUser_Collect.AboutImage = myCoverImage; myUser_Collect.AboutSummary = mySummart; myUser_Collect.MobilePhone = myMobilePhone; myUser_Collect.ClassId = myClassid;//收藏类别 myUser_Collect.CollectDate = DateTime.Now; myUser_Collect.IsTeacherVideo = isTeacherVideo; myUser_Collect.OrderBy = 10000; // myOperating.User_Collect.Add(myUser_Collect); myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateMsg = "不存在"; myStatusData.operateStatus = 400; } #endregion } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public JsonResult PublishAudio(string audioid, string operate) { //operate=0保存;1保存并发布 #region 检查授权 string myMobilePhone = ""; //手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { long myLong = 0; bool isLong = false; if (!String.IsNullOrEmpty(audioid)) { isLong = long.TryParse(audioid, out myLong); } if (isLong) { #region 修改状态 try { Child_Audio_List_User myChild_Audio_List_User = myOperating.Child_Audio_List_User.FirstOrDefault(p => p.AudioUserId == myLong); // if (myChild_Audio_List_User != null) { if (!String.IsNullOrWhiteSpace(operate)) { int myStatus = 0; bool isInt = int.TryParse(operate, out myStatus); if (isInt) { if (myStatus == 1) { myChild_Audio_List_User.Status = 200;//发布 } else { myChild_Audio_List_User.Status = 300;//撤下 } } else { myChild_Audio_List_User.Status = 300;//撤下 } } else { myChild_Audio_List_User.Status = 300;//撤下 } myOperating.SaveChanges(); myStatusData.operateStatus = 200; } else { myStatusData.operateStatus = 400; } // } catch { myStatusData.operateStatus = -1; } #endregion } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "参数错误"; } } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public JsonResult GetGameList(string classid, string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Game_List> myIQueryable = null; if (!String.IsNullOrWhiteSpace(classid)) { int myInt = 0; bool isOk = int.TryParse(classid, out myInt); if (isOk) { myIQueryable = myOperating.Game_List.Where(p => p.GameClass == myInt && p.Status == 200); } else { myIQueryable = null; } } else { myIQueryable = myOperating.Game_List.Where(p => p.Status == 200); } if (myIQueryable != null) { var myTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, false).Select(s => new { GameId = s.GameId, GameName = s.GameName, GameImage = StaticVarClass.myDomain + s.GameImage, GameDescribe = s.GameDescribe, GameUrl = s.GameUrl }).ToList(); // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myTable; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult ArticleList(string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "ArticlId"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Discover_Article> myIQueryable = null; myIQueryable = myOperating.Discover_Article.Where(p => p.Status == 200); // if (myIQueryable != null) { List <DiscoverDataItem> DiscoverDataItemList = new List <DiscoverDataItem>(); var EfDataTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { ArticlId = s.ArticlId, ArticleTitle = s.ArticleTitle, ArticleImages = s.ArticleImages, AddDate = s.AddDate, ReadTimes = s.ReadTimes, MobilePhone = s.MobilePhone }).ToList(); if (EfDataTable != null) { for (int i = 0; i < EfDataTable.Count(); i++) { #region 昵称和头像 string dataMobilePhone = EfDataTable[i].MobilePhone; DataMethodClass myDataMethodClass = new DataMethodClass(); string myHeadImage = StaticVarClass.DefaultHeadImage; //头像 string myNickName = "匿名"; //昵称 myDataMethodClass.GetNickNameAndPic(dataMobilePhone, out myNickName, out myHeadImage); #endregion int myCommentTimes = 0; //评论次数 long myArticlId = 0; //文章主键 myArticlId = EfDataTable[i].ArticlId; DiscoverDataItem myDiscoverDataItem = new DiscoverDataItem(); myDiscoverDataItem.ArticleId = myArticlId; myDiscoverDataItem.ArticleTitle = EfDataTable[i].ArticleTitle; myDiscoverDataItem.ReadTimes = EfDataTable[i].ReadTimes; myDiscoverDataItem.AddDate = EfDataTable[i].AddDate; // myDiscoverDataItem.NickName = myNickName; myDiscoverDataItem.HeadImage = myHeadImage; // myCommentTimes = myOperating.Discover_Article_Comment.Count(p => p.AboutId == myArticlId); // myDiscoverDataItem.CommentTimes = myCommentTimes; // DiscoverDataItemList.Add(myDiscoverDataItem); } } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = DiscoverDataItemList; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult ArticleContent(string articleid) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { DiscoverDataContent myDiscoverDataContent = new DiscoverDataContent(); long myLong = 0;//文章主键 bool isLong = long.TryParse(articleid, out myLong); if (isLong) { Discover_Article myTable = myOperating.Discover_Article.FirstOrDefault(p => p.ArticlId == myLong && p.Status == 200); if (myTable != null) { #region 昵称和头像 string dataMobilePhone = myTable.MobilePhone; DataMethodClass myDataMethodClass = new DataMethodClass(); string myHeadImage = StaticVarClass.DefaultHeadImage; //头像 string myNickName = "匿名"; //昵称 myDataMethodClass.GetNickNameAndPic(dataMobilePhone, out myNickName, out myHeadImage); #endregion int myCommentTimes = 0;//评论次数 myDiscoverDataContent.ArticleId = myTable.ArticlId; myDiscoverDataContent.ArticleTitle = myTable.ArticleTitle; myDiscoverDataContent.ArticleImages = FunctionClass.GetFileUrl(myTable.ArticleImages); myDiscoverDataContent.ArticleVideo = FunctionClass.GetFileUrl(myTable.ArticleVideo); myDiscoverDataContent.ArticleContent = myTable.ArticleContent; myDiscoverDataContent.AddDate = myTable.AddDate; myDiscoverDataContent.ReadTimes = myTable.ReadTimes; myCommentTimes = myOperating.Discover_Article_Comment.Count(p => p.AboutId == myLong); // myDiscoverDataContent.CommentTimes = myCommentTimes; myDiscoverDataContent.HeadImage = myHeadImage; myDiscoverDataContent.NickName = myNickName; // #region 阅读次数加一 if (myTable.ReadTimes != null) { myTable.ReadTimes = myTable.ReadTimes + 1; } else { myTable.ReadTimes = 1; } myOperating.SaveChanges(); #endregion } myStatusData.dataTable = myDiscoverDataContent; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult EditUserInfo(string headimage, string nickname, string birthdate, string districtnum, string address, string kindergarten, string roleid) { #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { DataMethodClass myDataMethodClass = new DataMethodClass();//检查验证码 // User_UserName myUserInfo = new User_UserName(); using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { myUserInfo = myOperating.User_UserName.FirstOrDefault(p => p.MobilePhone == myAuthCodeInstance.mobilePhone); if (myUserInfo == null) { myStatusData.operateStatus = 1;//用户名错误 } else { int nickNameExist = 0; #region 用户昵称是否可用 if (!String.IsNullOrEmpty(nickname)) { nickNameExist = myOperating.User_UserName.Count(p => p.MobilePhone != myAuthCodeInstance.mobilePhone && p.NickName == nickname); } #endregion // if (nickNameExist == 0) { try { #region 修改信息 if (!String.IsNullOrEmpty(headimage)) { string temPath = headimage.Replace("\\", "/"); if (temPath.IndexOf("http://") == 0) { int domainPosition = 0; temPath = temPath.Replace("http://", ""); domainPosition = temPath.IndexOf('/') + 1; if (domainPosition < temPath.Length) { temPath = temPath.Substring(domainPosition); } } myUserInfo.HeadImage = temPath; } if (!String.IsNullOrEmpty(nickname)) { myUserInfo.NickName = nickname; } if (!String.IsNullOrEmpty(birthdate)) { DateTime myDateTime = DateTime.Now; bool isTrue = DateTime.TryParse(birthdate, out myDateTime); if (isTrue) { myUserInfo.BirthDate = myDateTime; } } #region 择地区 if (!String.IsNullOrEmpty(districtnum)) { int myInt = 0; bool isTrue = int.TryParse(districtnum, out myInt); if (isTrue) { Sys_Area_District myDistrictTable = myOperating.Sys_Area_District.FirstOrDefault(p => p.DistrictNum == myInt); if (myDistrictTable != null) { myUserInfo.DistrictNum = myDistrictTable.DistrictNum; myUserInfo.DistrictName = myDistrictTable.DistrictName; Sys_Area_City myCity = myOperating.Sys_Area_City.FirstOrDefault(p => p.CityNum == myDistrictTable.CityID); if (myCity != null) { myUserInfo.CityNum = myCity.CityNum; myUserInfo.CityName = myCity.CityName; Sys_Area_Province myProvince = myOperating.Sys_Area_Province.FirstOrDefault(p => p.ProvinceNum == myCity.ProvinceID); if (myProvince != null) { myUserInfo.ProvinceNum = myProvince.ProvinceNum; myUserInfo.ProvinceName = myProvince.ProvinceName; } } } } } #endregion if (!String.IsNullOrEmpty(address)) { myUserInfo.Address = address; } if (!String.IsNullOrEmpty(kindergarten)) { myUserInfo.Kindergarten = kindergarten; } if (!String.IsNullOrEmpty(roleid)) { if (myUserInfo.RoleId < 100) { int myInt = 0; bool isTrue = int.TryParse(roleid, out myInt); if (isTrue) { myUserInfo.RoleId = myInt; } } } #endregion myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "该用户昵称已经存在"; } } } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }
public JsonResult AudioList(string albumid, string currentpage, string pagesize, string orderby, string isasc) { //orderby=1按日期排序,2按播放次数排序 string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; bool isDesc = true;//倒序 // #region 指定排序规则 if (String.IsNullOrWhiteSpace(orderby)) { orderby = ""; } switch (orderby) { case "1": orderbyfiled = "AddDate"; break; case "2": orderbyfiled = "PlayTimes"; break; } if (String.IsNullOrWhiteSpace(isasc)) { isasc = ""; } switch (isasc) { case "1": isDesc = true; //倒序 break; case "2": isDesc = false; //倒序 break; } #endregion //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion string soundBgImage = "";//获取专辑图片 IQueryable <Child_Audio_List> myIQueryable = null; if (!String.IsNullOrWhiteSpace(albumid)) { int myInt = 0; bool isOk = int.TryParse(albumid, out myInt); if (isOk) { #region 背景图片 Child_Audio_Album myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == myInt); if (myChild_Audio_Album != null) { soundBgImage = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage; } #endregion myIQueryable = myOperating.Child_Audio_List.Where(p => p.AlbumId == myInt && p.Status == 200); } else { myIQueryable = null; myStatusData.operateStatus = 400; } } // if (myIQueryable != null) { var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { AudioId = s.AudioId, AudioTitle = s.AudioTitle, AudioImage = soundBgImage, AudioUrl = StaticVarClass.myDomain + s.AudioUrl, PlayTimes = s.PlayTimes, TimeSeconds = s.TimeSeconds, AudioWords = s.AudioWords, AddDate = s.AddDate }).ToList(); // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = BookTable; myStatusData.operateStatus = 200; } } return(Json(myStatusData)); }
public JsonResult GetCollectList(string classid, string currentpage, string pagesize) { ///1点一点;2听一听;3看一看; ///4课程讲解;5幼儿公开课;6教育技能; ///7操作说明;8教师社区;9精彩瞬间; #region 检查授权 string myMobilePhone = ""; AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "CollectDate"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } int myInt = 0; #endregion if (!String.IsNullOrWhiteSpace(classid)) { bool isInt = int.TryParse(classid, out myInt); } // IQueryable <User_Collect> myIQueryable = null; if (myInt > 0) { myIQueryable = myOperating.User_Collect.Where(p => p.MobilePhone == myMobilePhone && p.ClassId == myInt); } else { myIQueryable = myOperating.User_Collect.Where(p => p.MobilePhone == myMobilePhone); } // if (myIQueryable != null) { List <collectData> collectDataList = new List <collectData>(); var CollcetTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { CollectId = s.CollectId, ClassId = s.ClassId, AboutId = s.AboutId, AboutTitle = s.AboutTitle, AboutImage = s.AboutImage, AboutSummary = s.AboutSummary, CollectDate = s.CollectDate }).ToList(); for (int i = 0; i < CollcetTable.Count; i++) { collectData collectDataItem = new collectData(); collectDataItem.CollectId = CollcetTable[i].CollectId; collectDataItem.ClassId = CollcetTable[i].ClassId; long aboutId = CollcetTable[i].AboutId; #region 听一听返回时长和播放次数 if (collectDataItem.ClassId == 2) { //听一听返回时长和播放次数 Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == aboutId); if (myChild_Audio_List != null) { collectDataItem.TimeSeconds = myChild_Audio_List.TimeSeconds; collectDataItem.PlayTimes = myChild_Audio_List.PlayTimes; } } #endregion collectDataItem.AboutId = aboutId; collectDataItem.AboutTitle = CollcetTable[i].AboutTitle; collectDataItem.AboutImage = CollcetTable[i].AboutImage; collectDataItem.AboutSummary = CollcetTable[i].AboutSummary; collectDataItem.CollectDate = CollcetTable[i].CollectDate; collectDataList.Add(collectDataItem); } // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = collectDataList; } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult AddArticleContent(string articletitle, string content, string images, string videos) { // string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 #region 判断条件 if (String.IsNullOrWhiteSpace(articletitle.Trim())) { myStatusData.operateStatus = 400; myStatusData.operateMsg = "标题不能为空"; return(Json(myStatusData)); } else if (articletitle.Trim().Length > 50) { myStatusData.operateStatus = 400; myStatusData.operateMsg = "标题不能多于50个字符"; return(Json(myStatusData)); } if (String.IsNullOrWhiteSpace(content.Trim())) { myStatusData.operateStatus = 400; myStatusData.operateMsg = "内容不能为空"; return(Json(myStatusData)); } else if (content.Trim().Length < 2) { myStatusData.operateStatus = 400; myStatusData.operateMsg = "内容太少"; return(Json(myStatusData)); } #endregion // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { try { Discover_Article myDiscover_Article = new Discover_Article(); myDiscover_Article.MobilePhone = mobilePhone; myDiscover_Article.ArticleTitle = articletitle; myDiscover_Article.ArticleContent = content; myDiscover_Article.ArticleImages = images; myDiscover_Article.ArticleVideo = videos; myDiscover_Article.AddDate = DateTime.Now; myDiscover_Article.OrderBy = 10000; myDiscover_Article.PraiseCount = 0; myDiscover_Article.ReadTimes = 0; myDiscover_Article.Status = 200; myOperating.Discover_Article.Add(myDiscover_Article); myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult CommentList(string articleid, string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "AddDate"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Teacher_Article_Comment> myIQueryable = null; if (!String.IsNullOrWhiteSpace(articleid)) { long myLong = 0; bool isOk = long.TryParse(articleid, out myLong); if (isOk) { myIQueryable = myOperating.Teacher_Article_Comment.Where(p => p.AboutId == myLong && p.Status == 200); } else { myIQueryable = null; } } else { myIQueryable = myOperating.Teacher_Article_Comment.Where(p => p.Status == 200); } // if (myIQueryable != null) { List <CommentData> myCommentDataList = new List <CommentData>(); var EfDataTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).Select(s => new { CommentId = s.CommentId, Detail = s.Detail, AddDate = s.AddDate, MobilePhone = s.MobilePhone }).ToList(); // if (EfDataTable != null) { for (int i = 0; i < EfDataTable.Count(); i++) { #region 昵称和头像 string dataMobilePhone = EfDataTable[i].MobilePhone; DataMethodClass myDataMethodClass = new DataMethodClass(); string myHeadImage = StaticVarClass.DefaultHeadImage; //头像 string myNickName = "匿名"; //昵称 myDataMethodClass.GetNickNameAndPic(dataMobilePhone, out myNickName, out myHeadImage); #endregion CommentData myCommentData = new CommentData(); myCommentData.CommentId = EfDataTable[i].CommentId; myCommentData.Detail = EfDataTable[i].Detail; myCommentData.AddDate = EfDataTable[i].AddDate; myCommentData.NickName = myNickName; myCommentData.HeadImage = myHeadImage; myCommentDataList.Add(myCommentData); } } // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myCommentDataList; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult PersonalAudioList(string currentpage, string pagesize) { #region 检查授权 string myMobilePhone = "";//手机号 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "AudioUserId"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Child_Audio_List_User> myIQueryable = null; myIQueryable = myOperating.Child_Audio_List_User.Where(p => p.MobilePhone == myMobilePhone); // if (myIQueryable != null) { var UserSoundTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc).ToList(); List <PersonalSoundData> myUserSoundDataList = new List <PersonalSoundData>(); if (UserSoundTable != null) { for (int i = 0; i < UserSoundTable.Count(); i++) { PersonalSoundData myUserSoundDataItem = new PersonalSoundData(); Nullable <long> myAudioId = 0; //听一听主键 Nullable <int> myAlbumId = 0; //专辑主键 string mySoundTitle = "佚名"; string myAudioWords = ""; string mySoundImage = "";//封面图片 // myAudioId = UserSoundTable[i].AudioId; #region 音乐名称和歌词 if (myAudioId != null) { Child_Audio_List myChild_Audio_List = myOperating.Child_Audio_List.FirstOrDefault(p => p.AudioId == myAudioId); if (myChild_Audio_List != null) { myAlbumId = myChild_Audio_List.AlbumId; mySoundTitle = myChild_Audio_List.AudioTitle; myAudioWords = myChild_Audio_List.AudioWords; } } #endregion // #region 背景图片 if (myAlbumId != null) { Child_Audio_Album myChild_Audio_Album = myOperating.Child_Audio_Album.FirstOrDefault(p => p.AlbumId == myAlbumId); if (myChild_Audio_Album != null) { mySoundImage = StaticVarClass.myDomain + myChild_Audio_Album.AlbumImage; } } #endregion // myUserSoundDataItem.AudioUserId = UserSoundTable[i].AudioUserId; myUserSoundDataItem.MusicTitle = mySoundTitle; myUserSoundDataItem.AudioImage = mySoundImage; myUserSoundDataItem.AudioWords = myAudioWords; myUserSoundDataItem.BgMusicUrl = StaticVarClass.myDomain + UserSoundTable[i].BgMusicUrl; myUserSoundDataItem.AudioUrl = StaticVarClass.myDomain + UserSoundTable[i].AudioUrl; myUserSoundDataItem.AddDate = UserSoundTable[i].AddDate; myUserSoundDataItem.TimeSeconds = UserSoundTable[i].TimeSeconds; myUserSoundDataItem.PlayTimes = UserSoundTable[i].PlayTimes; myUserSoundDataItem.Status = UserSoundTable[i].Status; // myUserSoundDataList.Add(myUserSoundDataItem); } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myUserSoundDataList; } } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult VideoList(string classid, string lessonid, string currentpage, string pagesize, string orderby, string isasc) { //orderby=1按日期排序,2按播放次数排序 string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "Recommended"; string orderbyfiled2 = "OrderBy"; bool isDesc = true;//倒序 // #region 指定排序规则 if (String.IsNullOrWhiteSpace(orderby)) { orderby = ""; } switch (orderby) { case "1": orderbyfiled = "AddDate"; break; case "2": orderbyfiled = "PlayTimes"; break; case "3": orderbyfiled = "OrderBy"; break; } if (String.IsNullOrWhiteSpace(isasc)) { isasc = ""; } switch (isasc) { case "1": isDesc = false; //正序 break; case "2": isDesc = true; //倒序 break; } #endregion //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Teacher_Video_List> myIQueryable = null; if (!String.IsNullOrWhiteSpace(classid)) { int myInt = 0; bool isOk = int.TryParse(classid, out myInt); if ((isOk) && (myInt > 0)) { //lessonid if (!String.IsNullOrWhiteSpace(lessonid)) {//课程类别 int myLessonid = 0; isOk = int.TryParse(lessonid, out myLessonid); if ((isOk) && (myLessonid > 0)) { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.ClassId == myInt && p.LessonId == myLessonid && p.Status == 200); } else { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.ClassId == myInt && p.Status == 200); } } else { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.ClassId == myInt && p.Status == 200); } } else { myIQueryable = null; } } else { myIQueryable = myOperating.Teacher_Video_List.Where(p => p.Status == 200 && p.Recommended > 0); } // if (myIQueryable != null) { var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc, orderbyfiled2).Select(s => new { VideoId = s.VideoId, VideoTitle = s.VideoTitle, VideoDes = s.VideoDes, VideoImage = StaticVarClass.myDomain + s.VideoImage, VideoUrl = StaticVarClass.myDomain + s.VideoUrl, PlayTimes = s.PlayTimes, TimeSeconds = s.TimeSeconds, ClassId = s.ClassId }).ToList(); myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = BookTable; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult BookList(string bookclassid, string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Child_Book_Click> myIQueryable = null; if (!String.IsNullOrWhiteSpace(bookclassid)) { int myInt = 0; bool isOk = int.TryParse(bookclassid, out myInt); if (isOk) { myIQueryable = myOperating.Child_Book_Click.Where(p => p.BookClassID == myInt && p.BookStatus == 200); } else { myIQueryable = null; } } else { myIQueryable = myOperating.Child_Book_Click.Where(p => p.BookStatus == 200); } // if (myIQueryable != null) { var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, false).Select(s => new { BookID = s.BookID, BookName = s.BookName, BookOnlineUrl = StaticVarClass.BookClickResourceUrl + s.BookOnlineUrl, ScreenH = s.ScreenH }).ToList(); // myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = BookTable; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult AlbumList(string classid, string currentpage, string pagesize) { string mobilePhone = "";// // DataOptionClass myDataOptionClass = new DataOptionClass(); // StatusData myStatusData = new StatusData();//返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; } #endregion using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "OrderBy"; // //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Child_Audio_Album> myIQueryable = null; if (!String.IsNullOrWhiteSpace(classid)) { int myInt = 0; bool isOk = int.TryParse(classid, out myInt); if (isOk) { myIQueryable = myOperating.Child_Audio_Album.Where(p => p.ClassId == myInt && p.Status == 200); } else { myIQueryable = null; } } else { myIQueryable = myOperating.Child_Audio_Album.Where(p => p.Status == 200); } // if (myIQueryable != null) { DataMethodClass myDataMethodClass = new DataMethodClass(); List <AudioAlbumData> myAudioAlbumDataList = new List <AudioAlbumData>(); var BookTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, true).Select(s => new { AlbumId = s.AlbumId, AlbumTitle = s.AlbumTitle, Anchor = s.Anchor, AlbumImage = StaticVarClass.myDomain + s.AlbumImage, AlbumDescrib = s.AlbumDescrib, AudioCount = s.AudioCount, PlayTimes = s.PlayTimes, ClassId = s.ClassId }).ToList(); if (BookTable != null) { for (int i = 0; i < BookTable.Count(); i++) { AudioAlbumData myAudioAlbumData = new AudioAlbumData(); int myInt = BookTable[i].AlbumId; int ListCount = 0;//总共数量 Child_Audio_List myChild_Audio_List = new Child_Audio_List(); ListCount = myOperating.Child_Audio_List.Count(p => p.AlbumId == myInt); // myAudioAlbumData.AlbumId = BookTable[i].AlbumId; myAudioAlbumData.AlbumTitle = BookTable[i].AlbumTitle; myAudioAlbumData.Anchor = BookTable[i].Anchor; myAudioAlbumData.AlbumImage = BookTable[i].AlbumImage; myAudioAlbumData.AlbumDescrib = BookTable[i].AlbumDescrib; myAudioAlbumData.AudioCount = ListCount; myAudioAlbumData.PlayTimes = myDataOptionClass.GetReadPlayTimes(2, myInt); myAudioAlbumData.ClassName = myDataMethodClass.GetAudioClassName(BookTable[i].ClassId); myAudioAlbumDataList.Add(myAudioAlbumData); } } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = myAudioAlbumDataList; } myStatusData.operateStatus = 200; } return(Json(myStatusData)); }
public JsonResult PersonalList(string currentpage, string pagesize) { string mobilePhone = ""; // // StatusData myStatusData = new StatusData(); //返回状态 // #region 检查授权 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion if (checkAuthCodeBool) { mobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { #region 翻页属性 int recordCount = 0; int pageCount = 0; string orderbyfiled = "ArticlId"; bool isDesc = true;//倒序 //当前页 int sqlCurrentpage = 1; if (!String.IsNullOrWhiteSpace(currentpage)) { bool isOk = int.TryParse(currentpage, out sqlCurrentpage); if (!isOk) { sqlCurrentpage = 1; } } //页大小 int sqlPagesize = 10; if (!String.IsNullOrWhiteSpace(pagesize)) { bool isOk = int.TryParse(pagesize, out sqlPagesize); if (!isOk) { sqlPagesize = 10; } } #endregion IQueryable <Discover_Article> myIQueryable = null; myIQueryable = myOperating.Discover_Article.Where(p => p.MobilePhone == mobilePhone); // if (myIQueryable != null) { List <DiscoverPersonDataItem> DiscoverDataItemList = new List <DiscoverPersonDataItem>(); IQueryable <Discover_Article> EfDataTable = QueryableExtensions.OrderBy(myIQueryable, orderbyfiled, out recordCount, out pageCount, ref sqlCurrentpage, sqlPagesize, isDesc); foreach (Discover_Article item in EfDataTable) { DiscoverPersonDataItem dataItem = new DiscoverPersonDataItem(); dataItem.ArticleId = item.ArticlId; dataItem.ArticleTitle = item.ArticleTitle; dataItem.ArticleImages = FunctionClass.GetFileUrl(item.ArticleImages); dataItem.AddDate = item.AddDate; dataItem.ReadTimes = item.ReadTimes; DiscoverDataItemList.Add(dataItem); } myStatusData.dataPageCount = pageCount; myStatusData.dataRecordCount = recordCount; myStatusData.dataTable = DiscoverDataItemList; } myStatusData.operateStatus = 200; } } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult Scan(string codestr) { StatusData myStatusData = new StatusData();//返回状态 // #region 检查授权 string myMobilePhone = "";//手机号码 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // int myTypeInt = 0; //类型;0注册开通课件;1学一学电子书注册 string myCodeStr = ""; //二维码 string tempCodeStr = ""; //临时 #region 解析二维码字符串 if (!String.IsNullOrWhiteSpace(codestr)) { tempCodeStr = codestr.ToUpper().Replace(StaticVarClass.QRCodeUrl.ToUpper(), ""); tempCodeStr = tempCodeStr.Replace("\\", "/"); string[] temCode = tempCodeStr.Split('/'); if (temCode.Length > 1) { bool isInt = int.TryParse(temCode[0], out myTypeInt); if (isInt) { myCodeStr = temCode[1];// } else { if (myTypeInt < 1) { myStatusData.operateStatus = 400; myStatusData.operateMsg = "类型错误:" + codestr; return(Json(myStatusData)); } } } else { myTypeInt = 0; myCodeStr = codestr; } } else { myStatusData.operateStatus = 400; return(Json(myStatusData)); } #endregion // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; // switch (myTypeInt) { case 0: break; case 1: #region 判断并开通学一学电子书 using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities()) //数据库操作 { Sys_BookStudy_QRCode mySys_BookStudy_QRCode = new Sys_BookStudy_QRCode(); mySys_BookStudy_QRCode = myOperating.Sys_BookStudy_QRCode.FirstOrDefault(p => p.QRCode == myCodeStr); if (mySys_BookStudy_QRCode != null) { if (mySys_BookStudy_QRCode.Used) { //注册码已经使用过 myStatusData.operateStatus = 500; } else { #region 判断是否已经开通该课程,否则开通 int TheBookIsReg = myOperating.User_RegBook_List.Count(p => p.MobilePhone == myMobilePhone && p.BookStudyID == mySys_BookStudy_QRCode.BookStudyID); if (TheBookIsReg == 0) { //判断该用户是否已经开通该课件 #region 注册开通 User_RegBook_List newUser_RegBook_List = new User_RegBook_List(); int isReg = myOperating.User_RegBook_List.Count(p => p.QRCode == myCodeStr); if (isReg == 0) { newUser_RegBook_List.QRCode = myCodeStr; newUser_RegBook_List.MobilePhone = myMobilePhone; newUser_RegBook_List.BookStudyID = mySys_BookStudy_QRCode.BookStudyID; newUser_RegBook_List.RegDate = DateTime.Now; myOperating.User_RegBook_List.Add(newUser_RegBook_List); // mySys_BookStudy_QRCode.MobilePhone = myMobilePhone; mySys_BookStudy_QRCode.Used = true; mySys_BookStudy_QRCode.UsedDate = DateTime.Now; // myOperating.SaveChanges(); myStatusData.operateStatus = 200; } else { myStatusData.operateStatus = 500; } #endregion } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "已经开通,无需重新开通"; } #endregion } } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "不存在"; } } #endregion break; } // } else { myStatusData.operateStatus = 5; } return(Json(myStatusData)); }
public JsonResult AddSoundRecord(string audioid, string audiourl, string bgmusic, string seconds, string operate) { //operate=0保存;1保存并发布 #region 检查授权 string myMobilePhone = ""; //新授权码 AuthCodeInstance myAuthCodeInstance = new AuthCodeInstance(); AuthCodeClass myAuthCodeClass = new AuthCodeClass(); bool checkAuthCodeBool = myAuthCodeClass.checkAuthCode(out myAuthCodeInstance); #endregion // #region 替换域名信息 if (!String.IsNullOrWhiteSpace(bgmusic)) { bgmusic = bgmusic.ToLower().Replace("http://", ""); int strIndex = bgmusic.IndexOf('/') + 1; if (strIndex < bgmusic.Length) { bgmusic = bgmusic.Substring(strIndex); } } #endregion // StatusData myStatusData = new StatusData();//返回状态 // if (checkAuthCodeBool) { myMobilePhone = myAuthCodeInstance.mobilePhone; using (chefuzi_dataEntities myOperating = new chefuzi_dataEntities())//数据库操作 { long myLong = 0; bool isLong = false; if (!String.IsNullOrEmpty(audioid)) { isLong = long.TryParse(audioid, out myLong); } if (isLong) { try { Child_Audio_List_User oldChild_Audio_List_User = new Child_Audio_List_User(); oldChild_Audio_List_User = myOperating.Child_Audio_List_User.FirstOrDefault(p => p.AudioId == myLong && p.MobilePhone == myMobilePhone); if (oldChild_Audio_List_User == null) { #region 添加新的 Child_Audio_List_User myChild_Audio_List_User = new Child_Audio_List_User(); // myChild_Audio_List_User.AudioId = myLong; myChild_Audio_List_User.MobilePhone = myMobilePhone; if (!String.IsNullOrEmpty(audiourl)) { myChild_Audio_List_User.AudioUrl = audiourl; } if (!String.IsNullOrEmpty(bgmusic)) { myChild_Audio_List_User.BgMusicUrl = bgmusic; } int myseconds = 0;//时长 if (!String.IsNullOrWhiteSpace(seconds)) { int.TryParse(seconds, out myseconds); } myChild_Audio_List_User.TimeSeconds = myseconds; myChild_Audio_List_User.AddDate = DateTime.Now; myChild_Audio_List_User.PlayTimes = 0; myChild_Audio_List_User.PraiceCount = 0; myChild_Audio_List_User.OrderBy = 10000; if (!String.IsNullOrWhiteSpace(operate)) { if (operate == "1") { myChild_Audio_List_User.Status = 200;// } else { myChild_Audio_List_User.Status = 300;// } } else { myChild_Audio_List_User.Status = 300;// } myOperating.Child_Audio_List_User.Add(myChild_Audio_List_User); #endregion } else {//修改 #region 修改状态 if (!String.IsNullOrWhiteSpace(operate)) { if (operate == "1") { oldChild_Audio_List_User.Status = 200;// } else { oldChild_Audio_List_User.Status = 300;// } } else { oldChild_Audio_List_User.Status = 300;// } #endregion } myOperating.SaveChanges(); myStatusData.operateStatus = 200; } catch { myStatusData.operateStatus = -1; } } else { myStatusData.operateStatus = 400; myStatusData.operateMsg = "参数错误"; } } } else { myStatusData.operateStatus = 5;//登陆失效 } return(Json(myStatusData)); }