/// <summary> /// 获取基础数据地址 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUrlStr(SyncRequest request) { UrlModel submitData = JsonHelper.DecodeJson <UrlModel>(request.Data); string url = ConfigurationManager.AppSettings[submitData.Type].ToString(); return(SyncResponse.GetResponse(request, url)); }
/// <summary> /// 保存用户最后的操作 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SavsUserFinallyOperationRecord(SyncRequest request) { clr_pageInit submitData = JsonHelper.DecodeJson <clr_pageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { clr_pageInit page = db.clr_pageInit.FirstOrDefault(p => p.UserID == submitData.UserID && p.AspxName == "Common"); if (page != null) { page.BookType = submitData.BookType; page.Stage = submitData.Stage; page.GradeID = submitData.GradeID; page.SubjectID = submitData.SubjectID; page.EditionID = submitData.EditionID; page.BookID = submitData.BookID; page.UnitID = submitData.UnitID; page.PageNum = submitData.PageNum; db.SaveChanges(); } else { submitData.PageInitID = Guid.NewGuid().ToString(); submitData.CreateTime = DateTime.Now; submitData.AspxName = "Common"; db.clr_pageInit.Add(submitData); db.SaveChanges(); } return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 获取资源地址 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetResourceUrlByFileID(SyncRequest request) { UserResource submitData = JsonHelper.DecodeJson <UserResource>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //webapi_url HttpResponseMessage response = myHttpClient.GetAsync("ResourcePreview?id=" + submitData.FileID).Result; if (response.IsSuccessStatusCode) { string json = response.Content.ReadAsStringAsync().Result; if (json.IndexOf("http") != -1) { return(SyncResponse.GetResponse(request, json)); } else { return(SyncResponse.GetResponse(request, false)); } } else { return(SyncResponse.GetResponse(request, null)); } }
private SyncResponse DeletePreLessonResource(SyncRequest request) { PreLessonContent preLessonContent = new PreLessonContent(); clr_preLesson submitData = JsonHelper.DecodeJson <clr_preLesson>(request.Data); PreLessonBtn submitDataBtn = JsonHelper.DecodeJson <PreLessonBtn>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_preLesson> prelessonList = db.clr_preLesson.Where(p => p.UserID == submitData.UserID).ToList(); foreach (var prelesson in prelessonList) { preLessonContent = JsonHelper.DecodeJson <PreLessonContent>(prelesson.PreLessonContent); for (int i = preLessonContent.btns.Count - 1; i >= 0; i--) { if (submitDataBtn.sourceUrl.IndexOf(preLessonContent.btns[i].sourceUrl) != -1) { preLessonContent.btns.Remove(preLessonContent.btns[i]); } } string jsonContent = JsonHelper.DeepEncodeJson(preLessonContent); prelesson.PreLessonContent = jsonContent; prelesson.CreateDate = DateTime.Now; db.SaveChanges(); } return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 检查备课中的资源 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse CheckPreLessonResource(SyncRequest request) { Resource submitData = JsonHelper.DecodeJson <Resource>(request.Data); UserInfo userDate = JsonHelper.DecodeJson <UserInfo>(request.Data); string[] resourceArr = submitData.ResourceID.Split(','); bool result = false; foreach (var item in resourceArr) { using (var db = new fz_wisdomcampusEntities()) { IList <clr_preLesson> preLessonlist = db.clr_preLesson.Where(p => p.PreLessonContent.Contains(item) && p.UserID == userDate.UserID).ToList(); if (preLessonlist != null && preLessonlist.Count != 0) { result = true; } IList <clr_teachmap> maplist = db.clr_teachmap.Where(m => m.Map.Contains(item) && m.UserID == userDate.UserID).ToList(); if (maplist != null && maplist.Count != 0) { result = true; } } } return(SyncResponse.GetResponse(request, result)); }
/// <summary> /// 根据用户ID获取教材数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUserStandBook(SyncRequest request) { UserStandBook submitData = JsonHelper.DecodeJson <UserStandBook>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_electronic_book> booklist = db.clr_electronic_book.Where(b => b.UserID == submitData.UserID).ToList(); return(SyncResponse.GetResponse(request, booklist)); } }
private SyncResponse GetBookListForTop(SyncRequest request) { UserStandBook submitData = JsonHelper.DecodeJson <UserStandBook>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_electronic_book> booklist = db.clr_electronic_book.Where(b => b.UserID == submitData.UserID).OrderByDescending(o => o.CreateDate).OrderByDescending(o => o.EndUseDate).Take(3).ToList(); return(SyncResponse.GetResponse(request, booklist)); } }
private SyncResponse SelExercises(SyncRequest request) { clr_exercises submitData = JsonHelper.DecodeJson <clr_exercises>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_exercises> list = db.clr_exercises.Where(e => e.UserID == submitData.UserID).ToList(); return(SyncResponse.GetResponse(request, list)); } }
/// <summary> /// 查询SelectBook页面操作数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SelectInitData(SyncRequest request) { clr_pageInit submitData = JsonHelper.DecodeJson <clr_pageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_pageInit> list = db.clr_pageInit.Where(p => p.UserID == submitData.UserID && p.AspxName == submitData.AspxName).ToList(); return(SyncResponse.GetResponse(request, list)); } }
private SyncResponse GetUserFinallyOperationRecord(SyncRequest request) { PageInit submitData = JsonHelper.DecodeJson <PageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { clr_pageInit page = db.clr_pageInit.FirstOrDefault(p => p.UserID == submitData.UserID && p.AspxName == "Common"); return(SyncResponse.GetResponse(request, page)); } }
private SyncResponse InsertExercises(SyncRequest request) { clr_exercises submitData = JsonHelper.DecodeJson <clr_exercises>(request.Data); using (var db = new fz_wisdomcampusEntities()) { db.clr_exercises.Add(submitData); db.SaveChanges(); return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 保存Teaching页面操作数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveTeachingData(SyncRequest request) { clr_pageInit submitData = JsonHelper.DecodeJson <clr_pageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { db.clr_pageInit.Add(submitData); db.SaveChanges(); return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 根据GUID获取用户账号 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUserInfoByGuid(SyncRequest request) { UserInfo submitData = JsonHelper.DecodeJson <UserInfo>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); HttpResponseMessage response = myHttpClient.GetAsync("GetAccount?ticket=" + submitData.UserAccount + "&ip=" + submitData.IP).Result; string UserInfolist = response.Content.ReadAsStringAsync().Result; return(SyncResponse.GetResponse(request, UserInfolist)); }
private SyncResponse UpdateStanBookUsingTime(SyncRequest request) { clr_electronic_book submitData = JsonHelper.DecodeJson <clr_electronic_book>(request.Data); using (var db = new fz_wisdomcampusEntities()) { clr_electronic_book book = db.clr_electronic_book.FirstOrDefault(b => b.UserID == submitData.UserID && b.BookID == submitData.BookID); book.EndUseDate = DateTime.Now; db.SaveChanges(); return(SyncResponse.GetResponse(request, true)); } }
private SyncResponse DeleteUserPreLessonData(SyncRequest request) { UserInfo submitData = JsonHelper.DecodeJson <UserInfo>(request.Data); using (var db = new fz_wisdomcampusEntities()) { var list = db.clr_preLesson.Where(p => p.UserID == submitData.UserID).ToList(); foreach (var item in list) { db.clr_preLesson.Remove(item); } db.SaveChanges(); } return(SyncResponse.GetResponse(request, true)); }
/// <summary> /// 保存用户操作记录 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveOperData(SyncRequest request) { UserOperData submitData = JsonHelper.DecodeJson <UserOperData>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url);//webapi_url string json = JsonHelper.DeepEncodeJson(submitData); var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("ClrLogMonitorWeb_Add", content).Result; return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); }
/// <summary> /// 根据用户账号获取用户信息 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUserInfoList(SyncRequest request) { UserInfo submitData = JsonHelper.DecodeJson <UserInfo>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); HttpResponseMessage response = myHttpClient.GetAsync("GetUserInfo/" + submitData.UserAccount).Result; string json = null; if (response.IsSuccessStatusCode) { json = response.Content.ReadAsStringAsync().Result; } return(SyncResponse.GetResponse(request, json)); }
/// <summary> /// 删除用户上传资源 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse DelUserResource(SyncRequest request) { Resource submitData = JsonHelper.DecodeJson <Resource>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); var content = new FormUrlEncodedContent(new Dictionary <string, string>() { { "ResourceIDs", submitData.ResourceID }, { "UserID", submitData.UserID } }); HttpResponseMessage response = myHttpClient.PostAsync("ResourceDelete", content).Result; return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); }
/// <summary> /// 查询页面备课数据从智慧教室后台 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SelBookPageData(SyncRequest request) { BookInfo submitData = JsonHelper.DecodeJson <BookInfo>(request.Data); //List<int> pages = new List<int>(submitData.Pages); using (var db = new fz_wisdomcampusEntities()) { List <clr_preLesson> list = db.clr_preLesson.Where( p => p.UserID == submitData.UserID && p.BookID == submitData.BookID && submitData.Pages.Contains((int)p.Page) ).ToList(); return(SyncResponse.GetResponse(request, list)); } }
private SyncResponse DeletePreLesson(SyncRequest request) { PreLessonContent preLessonContent = new PreLessonContent(); clr_preLesson submitData = JsonHelper.DecodeJson <clr_preLesson>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_preLesson> prelessonList = db.clr_preLesson.Where(p => p.UserID == submitData.UserID).ToList(); foreach (var prelesson in prelessonList) { db.clr_preLesson.Remove(prelesson); db.SaveChanges(); } return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 保存用户上传资源 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveUserUploadResource(SyncRequest request) { List <UploadFile> submitDataList = JsonHelper.DecodeJson <List <UploadFile> >(request.Data); string json = JsonHelper.DeepEncodeJson(submitDataList); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); /*webapi_url*/ var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("Resource", content).Result; return(SyncResponse.GetResponse(request, response.Content.ReadAsStringAsync().Result)); }
/// <summary> /// 检查用户账号密码 /// </summary> /// <param name="request"></param> /// <returns></returns> public SyncResponse CheckLoad(SyncRequest request) { UserInfo submitData = JsonHelper.DecodeJson <UserInfo>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //myHttpClient.BaseAddress = new Uri(webapi_url); HttpResponseMessage response = myHttpClient.GetAsync("CheckLogin?account=" + submitData.UserAccount + "&password="******"-4"; if (response.IsSuccessStatusCode) { json = response.Content.ReadAsStringAsync().Result; } return(SyncResponse.GetResponse(request, json)); }
/// <summary> /// 获取用户资源 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUserResource(SyncRequest request) { Resource submitData = JsonHelper.DecodeJson <Resource>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url);//webapi_url HttpResponseMessage response = myHttpClient.GetAsync("Resource?UserID=" + submitData.UserID + "&CatalogIds=" + submitData.UnitID).Result; if (response.IsSuccessStatusCode) { string json = response.Content.ReadAsStringAsync().Result; List <UserResource> list = JsonHelper.JosnDeserializer <UserResource>(json); return(SyncResponse.GetResponse(request, list)); } else { return(SyncResponse.GetResponse(request, null)); } }
/// <summary> /// 查询备课表中缺少的水滴数据从智慧校园接口 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetTextBookResource(SyncRequest request) { BookInfo submitData = JsonHelper.DecodeJson <BookInfo>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); HttpResponseMessage response = myHttpClient.GetAsync("TextbookResource?bookId=" + submitData.BookID + "&pages=" + string.Join("_", submitData.Pages)).Result; if (response.IsSuccessStatusCode) { string json = response.Content.ReadAsStringAsync().Result; return(SyncResponse.GetResponse(request, json)); } else { return(SyncResponse.GetResponse(request, null)); } }
/// <summary> /// 保存用户教学地图数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveUserTeachMap(SyncRequest request) { BookMap submitData = JsonHelper.DecodeJson <BookMap>(request.Data); UserInfo userData = JsonHelper.DecodeJson <UserInfo>(request.Data); if (userData.Type == 4)//管理员 { HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //webapi_url string json = JsonHelper.DeepEncodeJson(submitData); var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("GetTextBookMap", content).Result; return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); } else { using (var db = new fz_wisdomcampusEntities()) { var map = db.clr_teachmap.FirstOrDefault(m => m.UserID == userData.UserID && m.BookID == submitData.bookId && m.UnitID == submitData.unitId); if (map != null) { map.Map = submitData.MapContent; map.CreateTime = DateTime.Now; db.SaveChanges(); } else { clr_teachmap model = new clr_teachmap(); model.ID = Guid.NewGuid(); model.UserID = userData.UserID; model.BookID = submitData.bookId; model.UnitID = submitData.unitId; model.Map = submitData.MapContent; model.CreateTime = DateTime.Now; db.clr_teachmap.Add(model); db.SaveChanges(); } } return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 更新Teaching页面操作数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse UpdateTeachingData(SyncRequest request) { clr_pageInit submitData = JsonHelper.DecodeJson <clr_pageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { clr_pageInit item = db.clr_pageInit.Where( p => p.UserID == submitData.UserID && p.ClassID == submitData.ClassID && p.BookID == submitData.BookID && p.AspxName == submitData.AspxName ).OrderByDescending(o => o.CreateTime).FirstOrDefault(); item.UnitID = submitData.UnitID; item.PageNum = submitData.PageNum; item.CreateTime = submitData.CreateTime; item.UnitName = submitData.UnitName; db.SaveChanges(); return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 保存用户备课数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse SaveUserPresson(SyncRequest request) { List <clr_preLesson> submitData = JsonHelper.DecodeJson <List <clr_preLesson> >(request.Data); List <UserInfo> userData = JsonHelper.DecodeJson <List <UserInfo> >(request.Data); if (userData[0].Type == 4)//管理员 { HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); string json = JsonHelper.DeepEncodeJson(submitData); var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("TextbookResource", content).Result; return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); } else { foreach (var item in submitData) { using (var db = new fz_wisdomcampusEntities()) { var prelesson = db.clr_preLesson.FirstOrDefault(p => p.BookID == item.BookID && p.Page == item.Page && p.UserID == item.UserID); if (prelesson != null) { prelesson.PreLessonContent = item.PreLessonContent; prelesson.CreateDate = DateTime.Now; db.SaveChanges(); } else { item.PreLessonID = Guid.NewGuid().ToString(); item.CreateDate = DateTime.Now; db.clr_preLesson.Add(item); db.SaveChanges(); } } } return(SyncResponse.GetResponse(request, true)); } }
/// <summary> /// 用户分享资源 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse ShareUserResource(SyncRequest request) { ShareResource submitData = JsonHelper.DecodeJson <ShareResource>(request.Data); HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //webapi_url string json = JsonHelper.DeepEncodeJson(submitData); var content = new StringContent(json, Encoding.UTF8); content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); HttpResponseMessage response = myHttpClient.PostAsync("ResourceShare", content).Result; if (response.IsSuccessStatusCode) { return(SyncResponse.GetResponse(request, response.Content.ReadAsStringAsync().Result)); } else { return(SyncResponse.GetResponse(request, response.IsSuccessStatusCode)); } }
/// <summary> /// 获取用户教学地图数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse GetUserTeachMapJsonByWhere(SyncRequest request) { clr_teachmap submitData = JsonHelper.DecodeJson <clr_teachmap>(request.Data); using (var db = new fz_wisdomcampusEntities()) { var map = db.clr_teachmap.FirstOrDefault(m => m.UserID == submitData.UserID && m.BookID == submitData.BookID && m.UnitID == submitData.UnitID); if (map == null) { HttpClient myHttpClient = new HttpClient(); myHttpClient.BaseAddress = new Uri(webapi_url); //webapi_url HttpResponseMessage response = myHttpClient.GetAsync("GetTextBookMap?BookID=" + submitData.BookID + "&unitId=" + submitData.UnitID).Result; if (response.IsSuccessStatusCode) { string json = response.Content.ReadAsStringAsync().Result; if (json.IndexOf("\"[") != -1) { json = json.Substring(1, json.Length - 2); } if (json.Length > 2 && json != "null") { json = json.Replace("/", "").Replace("\\", ""); return(SyncResponse.GetResponse(request, json)); } else { return(SyncResponse.GetResponse(request, "")); } } else { return(SyncResponse.GetResponse(request, null)); } } else { return(SyncResponse.GetResponse(request, map.Map)); } } }
/// <summary> /// 更新SelectBook页面操作数据 /// </summary> /// <param name="request"></param> /// <returns></returns> private SyncResponse UpdateInitData(SyncRequest request) { clr_pageInit submitData = JsonHelper.DecodeJson <clr_pageInit>(request.Data); using (var db = new fz_wisdomcampusEntities()) { List <clr_pageInit> list = db.clr_pageInit.Where(p => p.UserID == submitData.UserID && p.AspxName == submitData.AspxName).ToList(); foreach (var item in list) { item.GradeID = submitData.GradeID; item.ClassID = submitData.ClassID; item.SubjectID = submitData.SubjectID; item.EditionID = submitData.EditionID; item.BookType = submitData.BookType; item.Stage = submitData.Stage; item.BookID = submitData.BookID; item.CreateTime = submitData.CreateTime; } db.SaveChanges(); return(SyncResponse.GetResponse(request, true)); } }