예제 #1
0
        public override SyncResponse ProcessRequest(SyncRequest request)
        {
            if (string.IsNullOrEmpty(request.Function))
            {
                return(SyncResponse.GetErrorResponse("无法确定接口信息!", request));
            }
            if (string.IsNullOrEmpty(request.Data))
            {
                return(SyncResponse.GetErrorResponse("提交的数据不能为空!", request));
            }
            SyncResponse response = null;

            switch (request.Function.Trim())
            {
            case "GetUrlStr":    //获取基础数据地址
                response = GetUrlStr(request);
                break;

            case "GetUserStandBook":    //根据用户ID获取教材数据
                response = GetUserStandBook(request);
                break;

            case "DelUserResource":    //删除用户上传资源
                response = DelUserResource(request);
                break;

            case "GetServiceDateTime":    //获取系统当前时间
                response = GetServiceDateTime(request);
                break;

            case "GetBookList":    //获取配置的教材ID列表
                response = GetBookList(request);
                break;

            case "GetBookListForTop":    //获取配置的教材ID列表
                response = GetBookListForTop(request);
                break;

            case "DeleteUserPreLessonData":    //
                response = DeleteUserPreLessonData(request);
                break;

            default:
                response = null;
                break;
            }
            return(response);
        }
예제 #2
0
        public override SyncResponse ProcessRequest(SyncRequest request)
        {
            if (string.IsNullOrEmpty(request.Function))
            {
                return(SyncResponse.GetErrorResponse("无法确定接口信息!", request));
            }
            if (string.IsNullOrEmpty(request.Data))
            {
                return(SyncResponse.GetErrorResponse("提交的数据不能为空!", request));
            }
            SyncResponse response = null;

            switch (request.Function.Trim())
            {
            case "CheckLoad":    //验证登录
                response = CheckLoad(request);
                break;

            case "CheckLoadDF":    //验证登录
                response = CheckLoadDF(request);
                break;

            case "GetUserInfoList":    //用GUID获取用户账号
                response = GetUserInfoList(request);
                break;

            case "GetUserInfoByGuid":    //用GUID获取用户账号
                response = GetUserInfoByGuid(request);
                break;

            case "AddUserStandBook":    //用户添加教材
                response = AddUserStandBook(request);
                break;

            case "SaveUserPresson":    //保存用户备课数据
                response = SaveUserPresson(request);
                break;

            case "GetUserPressonJsonByWhere":    //获取用户备课数据
                response = GetUserPressonJsonByWhere(request);
                break;

            case "SaveInitData":    //保存SelectBook页面初始化数据
                response = SaveInitData(request);
                break;

            case "SelectInitData":    //查询SelectBook页面初始化数据
                response = SelectInitData(request);
                break;

            case "UpdateInitData":    //更新SelectBook页面初始化数据
                response = UpdateInitData(request);
                break;

            case "SelectTeachingData":    //查询Teaching页面初始化数据
                response = SelectTeachingData(request);
                break;

            case "SaveTeachingData":    //保存Teaching页面初始化数据
                response = SaveTeachingData(request);
                break;

            case "UpdateTeachingData":    //更新Teaching页面初始化数据
                response = UpdateTeachingData(request);
                break;

            case "SelBookPageData":    //查询页面数据从智慧教室后台
                response = SelBookPageData(request);
                break;

            case "GetTextBookResource":    //查询页面水滴数据从智慧校园
                response = GetTextBookResource(request);
                break;

            case "SaveOperData":    //保存用户操作记录
                response = SaveOperData(request);
                break;

            case "GetUserResource":    //获取用户资源
                response = GetUserResource(request);
                break;

            case "SaveOperationRecord":    //保存用户操作记录
                response = SaveOperationRecord(request);
                break;

            case "SavsUserFinallyOperationRecord":    //保存用户最后的操作
                response = SavsUserFinallyOperationRecord(request);
                break;

            case "GetUserFinallyOperationRecord":    //获取用户最后的操作
                response = GetUserFinallyOperationRecord(request);
                break;

            case "SaveUserUploadResource":    //保存用户上传资源
                response = SaveUserUploadResource(request);
                break;

            case "SelExercises":    //查询是否存在课堂练习
                response = SelExercises(request);
                break;

            case "InsertExercises":    //插入课堂练习
                response = InsertExercises(request);
                break;

            case "UpdateExercises":    //更新课堂练习
                response = UpdateExercises(request);
                break;

            case "GetUserResourceByKey":    //检索用户资源
                response = GetUserResourceByKey(request);
                break;

            case "CheckPreLessonResource":    //检查备课中的资源
                response = CheckPreLessonResource(request);
                break;

            case "SaveUserTeachMap":    //保存用户教学地图数据
                response = SaveUserTeachMap(request);
                break;

            case "GetUserTeachMapJsonByWhere":    //获取用户教学地图数据
                response = GetUserTeachMapJsonByWhere(request);
                break;

            case "GetSchoolResourceList":    //获取校本资源数据
                response = GetSchoolResourceList(request);
                break;

            case "ShareUserResource":    //用户分享资源
                response = ShareUserResource(request);
                break;

            case "DeletePreLessonResource":    //用户删除备课水滴资源
                response = DeletePreLessonResource(request);
                break;

            case "DeletePreLesson":    //用户删除备课水滴资源
                response = DeletePreLesson(request);
                break;

            case "UpdateStanBookUsingTime":
                response = UpdateStanBookUsingTime(request);    //修改用户使用教材时间
                break;

            case "GetResourceUrlByFileID":
                response = GetResourceUrlByFileID(request);    //获取资源地址
                break;

            default:
                response = null;
                break;
            }
            return(response);
        }
예제 #3
0
        /// <summary>
        /// 用户添加教材
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        private SyncResponse AddUserStandBook(SyncRequest request)
        {
            try
            {
                UserStandBookModul submitData = JsonHelper.DecodeJson <UserStandBookModul>(request.Data);
                using (var db = new fz_wisdomcampusEntities())
                {
                    List <StandBook>           AddList    = new List <StandBook>();
                    List <clr_electronic_book> RemoveList = new List <clr_electronic_book>();;
                    var list = db.clr_electronic_book.Where(b => b.UserID == submitData.UserID).ToList();

                    ////////////////添加的教材为空的时候,清空用户教材//////////////////////
                    if (submitData.StandBookList.Count() == 0)
                    {
                        foreach (var item in list)
                        {
                            db.clr_electronic_book.Remove(item);
                        }
                        db.SaveChanges();
                    }
                    else
                    {
                        ///////////////匹配获取需要添加的教材//////////////////
                        foreach (var book in submitData.StandBookList)
                        {
                            clr_electronic_book model = list.FirstOrDefault(b => b.BookID == book.ID);
                            if (model == null)
                            {
                                AddList.Add(book);
                            }
                        }
                        ///////////////匹配获取需要删除的教材//////////////////
                        foreach (var book in list)
                        {
                            StandBook model = submitData.StandBookList.FirstOrDefault(b => b.ID == book.BookID);
                            if (model == null)
                            {
                                RemoveList.Add(book);
                            }
                        }
                        ///////////////删除教材/////////////////
                        foreach (var item in RemoveList)
                        {
                            clr_electronic_book model = list.FirstOrDefault(b => b.BookID == item.BookID);
                            db.clr_electronic_book.Remove(model);
                            db.SaveChanges();
                        }
                        ///////////////添加教材/////////////////
                        foreach (var book in AddList)
                        {
                            clr_electronic_book model = new clr_electronic_book();
                            model.BookID     = book.ID;
                            model.SubjectID  = book.Subject;
                            model.EditionID  = book.Edition;
                            model.GradeID    = book.Grade;
                            model.BookType   = book.BookType;
                            model.Stage      = book.Stage;
                            model.UserID     = submitData.UserID;
                            model.CreateDate = DateTime.Now;
                            db.clr_electronic_book.Add(model);
                        }
                        db.SaveChanges();
                    }
                }
                return(SyncResponse.GetResponse(request, true));
            }
            catch (Exception ex)
            {
                return(SyncResponse.GetErrorResponse(ex.Message));
            }
        }
예제 #4
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string formData = context.Request.Form["Form"];
                if (string.IsNullOrEmpty(formData))
                {
                    SyncResponse response = new SyncResponse();
                    response.Success   = false;
                    response.ErrorMsg  = "没有找到相应的数据包!";
                    response.RequestID = "";
                    response.Data      = null;
                    context.Response.Write(JsonHelper.EncodeJson(response));
                    context.Response.End();
                    return;
                }
                SyncForm form = JsonHelper.DecodeJson <SyncForm>(formData);
                if (form == null)
                {
                    SyncResponse response = new SyncResponse();
                    response.Success   = false;
                    response.ErrorMsg  = "没有找到相应的数据包!";
                    response.RequestID = "";
                    response.Data      = null;
                    context.Response.Write(JsonHelper.EncodeJson(response));
                    context.Response.End();
                    return;
                }
                string serviceID = form.SKEY;
                if (string.IsNullOrEmpty(serviceID))
                {
                    SyncResponse response = new SyncResponse();
                    response.Success   = false;
                    response.ErrorMsg  = "没有指定处理方法!";
                    response.RequestID = form.RID;
                    response.Data      = null;
                    context.Response.Write(JsonHelper.EncodeJson(response));
                    context.Response.End();
                    return;
                }
                else
                {
                    Type objType = Type.GetType("Kingsun.SmarterClassroom.BLL." + serviceID.Trim() + ",Kingsun.SmarterClassroom.BLL");
                    if (objType != null)
                    {
                        string package   = form.Pack;
                        string returnStr = null;

                        if (String.IsNullOrEmpty(package))
                        {
                            //返回错误信息
                            returnStr = SyncResponse.GetErrorResponseString("无法找到参数包");
                        }
                        else
                        {
                            SyncRequest request = SyncRequest.DecodeRequest(package);
                            if (request == null)
                            {
                                returnStr = SyncResponse.GetErrorResponseString("参数包解析失败");
                            }
                            else
                            {
                                BaseImplement obj = Activator.CreateInstance(objType) as BaseImplement;
                                SyncResponse  response;
                                if (obj != null)
                                {
                                    try
                                    {
                                        if ((request.Data != null) && (request.Data != String.Empty))
                                        {
                                            //验证传递参数是否存在SQL攻击嫌疑
                                            //true - 有注入, false - 没有注入
                                            bool result = Utils.filterSql(request.Data);
                                            if (result)
                                            {
                                                response = SyncResponse.GetErrorResponse("有SQL攻击嫌疑,请停止操作。");
                                            }
                                            else
                                            {
                                                response = obj.ProcessRequest(request);
                                            }
                                            //response = obj.ProcessRequest(request);
                                        }
                                        else
                                        {
                                            response = SyncResponse.GetErrorResponse("无法获取参数,请联系管理员。");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        response = SyncResponse.GetErrorResponse("服务接口内部错误,请联系管理员。" + ex.Message, request);
                                    }
                                }
                                else
                                {
                                    response = SyncResponse.GetErrorResponse("无法实例化服务接口!", request);
                                }
                                returnStr = JsonHelper.EncodeJson(response);
                            }
                        }
                        context.Response.Write(returnStr);
                    }
                    else
                    {
                        SyncResponse response = new SyncResponse();
                        response.Success   = false;
                        response.ErrorMsg  = "无法确定处理程序!";
                        response.RequestID = form.RID;
                        response.Data      = null;
                        context.Response.Write(JsonHelper.EncodeJson(response));
                        context.Response.End();
                    }
                }
            }
            catch
            {
                SyncResponse response = new SyncResponse();
                response.Success   = false;
                response.ErrorMsg  = "后台处理异常。";
                response.RequestID = "";
                response.Data      = null;
                context.Response.Write(JsonHelper.EncodeJson(response));
                context.Response.End();
            }
        }