Ejemplo n.º 1
0
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         bool flag = false;
         if (rtype == "0")//文件夹
         {
             Model_ResourceFolder model = new BLL_ResourceFolder().GetModel(iid);
             model.ResourceFolder_Name = txtName.Text.Trim();
             flag = new BLL_ResourceFolder().Update(model);
         }
         else if (rtype == "1")//文件
         {
             Model_ResourceToResourceFolder model = new BLL_ResourceToResourceFolder().GetModel(iid);
             model.Resource_Name = txtName.Text.Trim();
             model.File_Name     = txtName.Text.Trim();
             flag = new BLL_ResourceToResourceFolder().Update(model);
         }
         if (flag)
         {
             ClientScript.RegisterStartupScript(this.GetType(), "update", "<script type='text/javascript'>$(function(){layer.ready(function(){layer.msg('修改成功!',{ time: 1000,icon:1},function(){parent.loadData();parent.layer.close(index);});})})</script>");
         }
         else
         {
             ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>$(function(){layer.ready(function(){layer.msg('操作失败!',{icon:2});})})</script>");
         }
     }
     catch (Exception ex)
     {
         new Rc.Cloud.BLL.BLL_clsAuth().AddLogFromBS("10401000", "操作异常," + ex + "操作人:(" + loginUser.SysUser_ID + ")" + loginUser.SysUser_Name);
         ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>$(function(){layer.ready(function(){layer.msg('操作失败!',{icon:2},function(){parent.loadData();parent.layer.close(index);});})})</script>");
     }
 }
Ejemplo n.º 2
0
        public static string share(string ResourceToResourceFolder_Id)
        {
            Rc.Model.Resources.Model_F_User FloginUser = Rc.Common.StrUtility.clsUtility.IsFPageFlag() as Rc.Model.Resources.Model_F_User;
            try
            {
                string    strsql = "select distinct(SchoolId) from dbo.VW_UserOnClassGradeSchool where UserId='" + FloginUser.UserId + "' and SchoolId<>''";
                DataTable dt     = Rc.Common.DBUtility.DbHelperSQL.Query(strsql).Tables[0];

                Model_ResourceShare rs = new Model_ResourceShare();
                rs.ResourceShareId             = Guid.NewGuid().ToString();
                rs.ResourceToResourceFolder_Id = ResourceToResourceFolder_Id;
                rs.ShareObjectId = dt.Rows.Count > 0 ? dt.Rows[0]["SchoolId"].ToString() : "";
                rs.CreateUserId  = FloginUser.UserId;
                rs.CreateTime    = DateTime.Now;

                Model_ResourceToResourceFolder rtr    = new Model_ResourceToResourceFolder();
                BLL_ResourceToResourceFolder   rtrbll = new BLL_ResourceToResourceFolder();
                rtr = rtrbll.GetModel(ResourceToResourceFolder_Id);
                rtr.Resource_shared = "1";
                BLL_ResourceShare bllrs = new BLL_ResourceShare();
                if (bllrs.ShareResource(rs, rtr))
                {
                    return("1");
                }
                else
                {
                    return("");
                }
            }
            catch (Exception)
            {
                return("");
            }
        }
Ejemplo n.º 3
0
        public static string GetQuestionTest(string ResourceToResourceFolder_Id, string ScoreId)
        {
            try
            {
                StringBuilder stbHtml = new StringBuilder();
                Model_ResourceToResourceFolder model = new Model_ResourceToResourceFolder();
                model = new BLL_ResourceToResourceFolder().GetModel(ResourceToResourceFolder_Id);
                string sqlTest = @"select TestQuestions_Score_ID,S_TestQuestions_TP_ID,TPNameBasic,TPName,tk.CreateTime from [S_TestQuestions_TP] tk
inner join [dbo].[S_TestingPoint] sp on sp.S_TestingPoint_Id=tk.S_TestingPoint_Id
left join S_TestingPointBasic t on t.S_TestingPointBasic_Id=sp.S_TestingPointBasic_Id
where  TestQuestions_Score_ID='" + ScoreId + "'";
                System.Data.DataTable dtTest = Rc.Common.DBUtility.DbHelperSQL.Query(sqlTest).Tables[0];
                System.Data.DataRow[] drAttr = dtTest.Select("TestQuestions_Score_ID='" + ScoreId + "'", "CreateTime desc,TPName");
                if (drAttr.Length > 0)
                {
                    foreach (var item in drAttr)
                    {
                        stbHtml.AppendFormat("<span class=\"tag\">{0}<i data-name=\"removeTest\" data-tkid=\"{1}\">×</i></span>", item["TPNameBasic"], item["S_TestQuestions_TP_ID"]);
                    }
                }
                if (model != null)
                {
                    stbHtml.AppendFormat("<span class=\"tag_add\" data-name=\"addTestNew\" data-scoreid=\"{0}\" data-g=\"{1}\" data-s=\"{2}\" data-v=\"{3}\" data-type=\"1\">+</span>"
                                         , ScoreId
                                         , model.GradeTerm
                                         , model.Subject
                                         , model.Resource_Version);
                }
                return(stbHtml.ToString());
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Ejemplo n.º 4
0
        protected void btnDelRes_Click(object sender, EventArgs e)
        {
            string strJson = string.Empty;

            try
            {
                string uploadPath = Server.MapPath("..\\Upload\\Resource\\");//存储文件基础路径
                string pathId     = txtRTRFId.Text.Trim();
                if (new BLL_HomeWork().GetRecordCount_Operate("ResourceToResourceFolder_Id='" + pathId + "'") > 0)
                {
                    #region 判断运营平台存在已布置作业,无法删除
                    strJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                    {
                        status    = false,
                        errorMsg  = "存在已布置作业,无法删除",
                        errorCode = "DeletePath"
                    });
                    #endregion
                }
                else
                {
                    #region  除文件
                    Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(pathId);
                    List <string> listFileUrl = GetResourceFile(modelRTRF, uploadPath);
                    if (new BLL_Resource().DeleteResource(pathId, modelRTRF.Resource_Id))
                    {
                        strJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                        {
                            status    = true,
                            errorMsg  = "",
                            errorCode = ""
                        });
                        DeleteResourceFile(listFileUrl);
                    }
                    else
                    {
                        strJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                        {
                            status    = false,
                            errorMsg  = "文件删除失败",
                            errorCode = "DeletePath"
                        });
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                strJson = Newtonsoft.Json.JsonConvert.SerializeObject(new
                {
                    status    = false,
                    errorMsg  = ex.Message.ToString(),
                    errorCode = "DeletePath"
                });
            }
            txtResult.Text = strJson;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 修改时的默认值
 /// </summary>
 protected void loadData()
 {
     if (rtype == "0")//文件夹
     {
         Model_ResourceFolder model = new BLL_ResourceFolder().GetModel(iid);
         txtName.Text = model.ResourceFolder_Name.ReplaceForFilter();
     }
     else if (rtype == "1")//文件
     {
         Model_ResourceToResourceFolder model = new BLL_ResourceToResourceFolder().GetModel(iid);
         txtName.Text = model.Resource_Name.ReplaceForFilter();
     }
 }
Ejemplo n.º 6
0
        private void LoadData()
        {
            string strWhere = string.Format(" User_ApplicationStatus='passed' and UserStatus='0' and UserGroup_Id='{0}' and MembershipEnum='{1}' ", classId, MembershipEnum.student);

            rptStudentList.DataSource = new BLL_UserGroup_Member().GetClassMemberListByPageEX(strWhere, "TrueName", 1, 1000).Tables[0];
            rptStudentList.DataBind();

            Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrId);

            if (modelRTRF != null)
            {
                txtHomeWork_Name.Text = modelRTRF.File_Name.ReplaceForFilter();
            }
            Model_UserGroup modelUserGroup = new BLL_UserGroup().GetModel(classId);

            if (modelUserGroup != null)
            {
                className = modelUserGroup.UserGroup_Name;
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ResourceToResourceFolder_Id = Request.QueryString["ResourceToResourceFolder_Id"].Filter();
            Model_ResourceToResourceFolder model = new Model_ResourceToResourceFolder();

            model = new BLL_ResourceToResourceFolder().GetModel(ResourceToResourceFolder_Id);
            if (model != null)
            {
                GradeTerm        = model.GradeTerm;
                Subject          = model.Subject;
                Resource_Version = model.Resource_Version;
                //加载来源
                DataTable dt  = new DataTable();
                string    sql = string.Format(@" select t.Dict_Id,t3.D_Name,t3.D_Order,t3.D_Type from DictRelation_Detail t 
inner join DictRelation t2 on t2.DictRelation_Id=t.DictRelation_Id
inner join Common_Dict t3 on t3.Common_Dict_Id=t.Dict_Id 
where t2.HeadDict_Id='934A3541-116E-438C-B9BA-4176368FCD9B' and t2.SonDict_Id='F3BB0E09-CF73-4696-84BF-007C30B249A1' and t.Parent_Id='{0}'
order by t3.D_Order", Subject);
                dt = Rc.Common.DBUtility.DbHelperSQL.Query(sql).Tables[0];
                Rc.Cloud.Web.Common.pfunction.SetDdl(ddltq_source, dt, "D_Name", "Dict_Id", "--请选择--");
            }
        }
Ejemplo n.º 8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ResourceToResourceFolder_Id = Request.QueryString["rtrfId"].Filter();
            tchId             = Request.QueryString["userId"].Filter();
            UserIdentity      = Request.QueryString["UserIdentity"].Filter();
            divAssign.Visible = false;
            if (UserIdentity == "T") // 老师,显示布置按钮
            {
                divAssign.Visible = true;
            }
            Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(ResourceToResourceFolder_Id);

            if (modelRTRF == null)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('资源不存在或已删除。',{icon:2,time:0});</script>");
                return;
            }
            else
            {
                Resource_Name = Server.UrlEncode(modelRTRF.Resource_Name);
            }

            strTestpaperViewWebSiteUrl = Rc.Cloud.Web.Common.pfunction.GetResourceHost("TestWebSiteUrl");
        }
Ejemplo n.º 9
0
 public static string cancel(string ResourceToResourceFolder_Id)
 {
     Rc.Model.Resources.Model_F_User FloginUser = Rc.Common.StrUtility.clsUtility.IsFPageFlag() as Rc.Model.Resources.Model_F_User;
     try
     {
         Model_ResourceToResourceFolder rtr    = new Model_ResourceToResourceFolder();
         BLL_ResourceToResourceFolder   rtrbll = new BLL_ResourceToResourceFolder();
         rtr = rtrbll.GetModel(ResourceToResourceFolder_Id);
         rtr.Resource_shared = "";
         BLL_ResourceShare bllrs = new BLL_ResourceShare();
         if (bllrs.CancelShareResource(ResourceToResourceFolder_Id, rtr))
         {
             return("1");
         }
         else
         {
             return("");
         }
     }
     catch (Exception)
     {
         return("");
     }
 }
Ejemplo n.º 10
0
        public static string CheckCalculation(string rtrfId, string gradeId)
        {
            try
            {
                rtrfId  = rtrfId.Filter();
                gradeId = gradeId.Filter();
                Model_F_User loginUser = HttpContext.Current.Session["FLoginUser"] as Model_F_User;
                #region  试卷 执行数据分析,记录日志
                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrfId);
                Model_StatsLog modelLog = new Model_StatsLog();
                modelLog.StatsLogId = Guid.NewGuid().ToString();
                modelLog.DataId     = modelRTRF.ResourceToResourceFolder_Id;
                modelLog.DataName   = modelRTRF.File_Name.ReplaceForFilter();
                modelLog.DataType   = "2";
                modelLog.LogStatus  = "2";
                modelLog.CTime      = DateTime.Now;
                modelLog.CUser      = loginUser.UserId;
                modelLog.GradeId    = gradeId;

                bool flag = new BLL_StatsLog().ExecuteStatsAddLog(modelLog);
                #endregion
                if (flag)
                {
                    return("1");
                }
                else
                {
                    return("0");
                }
            }
            catch (Exception ex)
            {
                new Rc.Cloud.BLL.BLL_clsAuth().AddLogErrorFromBS("", "计算失败:" + ex.Message.ToString());
                return("0");
            }
        }
Ejemplo n.º 11
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strHomeWork_Id = Guid.NewGuid().ToString();

            try
            {
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:1开始验证");
                // 学校公网IP
                string hostUrl = pfunction.GetResourceHost2("TestWebSiteUrl");
                #region 验证
                DataTable dtHWDetail = Rc.Common.DBUtility.DbHelperSQL.Query("select * from VW_ClassGradeSchool where ClassId='" + classId + "' and GradeId is not null and SchoolId is not null ").Tables[0];
                if (dtHWDetail.Rows.Count == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('加入年级后才可布置作业',{time:2000,icon:2});", true);
                    return;
                }
                BLL_HomeWork bll = new BLL_HomeWork();
                if (bll.GetRecordCount("ResourceToResourceFolder_Id='" + rtrId + "' and HomeWork_AssignTeacher='" + FloginUser.UserId + "' and UserGroup_Id='" + classId + "' ") > 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('该作业已被布置',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                    return;
                }

                if (new BLL_UserGroup_Member().GetRecordCount("UserStatus='0' and User_Id='" + FloginUser.UserId + "' and UserGroup_Id='" + classId + "' ") == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('老师与所布置作业班级关系错误',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                    return;
                }

                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrId);

                if (modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源)
                {
                    if (modelRTRF.Resource_Type != Resource_TypeConst.集体备课文件 && modelRTRF.CreateFUser != FloginUser.UserId)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('此资源不是您的',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                        return;
                    }
                }
                else if (modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                {
                    if (new BLL_UserBuyResources().GetRecordCount("UserId='" + FloginUser.UserId + "' and Book_Id='" + modelRTRF.Book_ID + "' ") == 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('老师还未购买此资源',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                        return;
                    }
                }
                if (pfunction.FilterKeyWords(this.txtHomeWork_Name.Text))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('作业名称存在敏感词汇,请重新填写。',{icon:2,time:2000});</script>");
                    return;
                }
                //Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:验证网络是否通畅" + hostUrl);
                ////检测网络是否通畅
                //if (RemotWeb.PostDataToServer(hostUrl + "/AuthApi/index.aspx?key=onlinecheck", "", Encoding.UTF8, "Get") != "ok")
                //{
                //    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('服务器网络不通畅。',{icon:2,time:3000});</script>");
                //    return;
                //}
                #endregion
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:1结束验证");

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:2开始组织提交数据");
                #region 组织提交数据

                DateTime hw_time      = DateTime.Now;
                int      isTimeLength = 0;
                int.TryParse(txtTimeLength.Text, out isTimeLength);
                int isTimeLimt = 1;
                isTimeLimt = (hwType_1.Checked == true) ? 1 : 2;//作业类型:1=作业,2=考试
                DateTime BeginTime = DateTime.Parse(txtBeginTime.Text);
                DateTime StopTime  = DateTime.Now;
                if (isTimeLimt == 2)
                {
                    StopTime = DateTime.Parse(BeginTime.ToString()).AddMinutes(int.Parse(isTimeLength.ToString()));
                }
                else
                {
                    StopTime = Convert.ToDateTime(txtStopTime.Text);
                }
                string strStudent = Rc.Cloud.Web.Common.pfunction.CheckImp(hidStudentId.Value);
                strStudent = strStudent.TrimEnd(',');
                string SubjectId = FloginUser.Subject;
                if (modelRTRF != null && modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                {
                    SubjectId = modelRTRF.Subject;
                }
                object objAssign = new
                {
                    stuInfo     = strStudent,
                    HomeWork_Id = strHomeWork_Id,
                    ResourceToResourceFolder_Id = rtrId,
                    HomeWork_Name          = txtHomeWork_Name.Text,
                    HomeWork_AssignTeacher = FloginUser.UserId,
                    BeginTime       = BeginTime,
                    StopTime        = StopTime,
                    IsHide          = chkIsHide.Checked ? 1 : 0,
                    HomeWork_Status = 0,
                    CreateTime      = hw_time,
                    UserGroup_Id    = classId,
                    isTimeLimt      = isTimeLimt,
                    isTimeLength    = isTimeLength,
                    SubjectId       = SubjectId,
                    IsShowAnswer    = (chkIsShowAnswer.Checked == true) ? 1 : 0
                };
                #endregion
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:2结束组织提交数据");

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:3开始提交到学校服务器");

                hostUrl += "teacher/tchAssignHW.aspx";
                string result = Rc.Common.RemotWeb.PostDataToServer(hostUrl, JsonConvert.SerializeObject(objAssign), System.Text.Encoding.UTF8, "POST");
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:3结束提交到学校服务器");
                if (result == "ok")
                {
                    string strJ = "layer.msg('布置作业成功" + result + "',{time:1000,icon:1},function(){";
                    if (Request.QueryString["tp"] != "1")
                    {
                        strJ += "window.parent.loadData();";
                    }
                    else
                    {
                        strJ += "window.parent.location.reload();";
                    }
                    strJ += "parent.layer.close(parent.layer.getFrameIndex(window.name));});";
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业成功" + result);
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", strJ, true);
                }
                else
                {
                    //RevokeHW 布置作业失败 撤销作业
                    new BLL_HomeWork().RevokeHW(strHomeWork_Id);
                    Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(FloginUser.UserId, "", "布置作业失败:学校未布置成功" + result + "; 。");
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('布置作业失败',{time:2000,icon:2});", true);
                }
            }
            catch (Exception ex)
            {
                //RevokeHW 布置作业失败 撤销作业
                new BLL_HomeWork().RevokeHW(strHomeWork_Id);
                Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS(FloginUser.UserId, "", "布置作业失败:" + ex.Message.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('布置作业异常,请联系管理员',{time:2000,icon:2});", true);
            }
        }
Ejemplo n.º 12
0
        protected void btnOn_Click(object sender, EventArgs e)
        {
            try
            {
                //删除
                BLL_FileSyncRecordFail fsrfbll = new BLL_FileSyncRecordFail();
                fsrfbll.DeleteClass(" Resource_Type in ('b8ea8767-4ae6-4b90-883f-93415a14e461','f1d1db22-c427-47e6-a8af-13d516d90633','e3a3e85e-2903-4ae6-ba17-f7f2ad9d7e0d')");
                List <Rc.Model.Resources.Model_ResourceToResourceFolder> rtrflist = new List <Model_ResourceToResourceFolder>();
                string StrWhere   = string.Empty;
                string StartTime  = txtStartTime.Text;
                string EndTime    = txtEndTiem.Text;
                string uploadPath = "\\Upload\\Resource\\";
                string filePath   = string.Empty;
                string imgPath    = string.Empty;
                string savePath   = string.Empty;
                string StrText    = string.Empty;
                StrWhere = " Resource_Class='" + Resource_ClassConst.云资源 + "'  ";
                if (!string.IsNullOrEmpty(StartTime))
                {
                    StrWhere += " and  CreateTime >= '" + StartTime.Filter() + "'";
                }
                if (!string.IsNullOrEmpty(EndTime))
                {
                    StrWhere += " and CreateTime <= '" + EndTime.Filter() + "'";
                }
                if (!string.IsNullOrEmpty(hidtxtBook.Value))
                {
                    StrWhere += " and Book_ID='" + hidtxtBook.Value + "'";
                }
                StrWhere += " and (Resource_Type in ('b8ea8767-4ae6-4b90-883f-93415a14e461','f1d1db22-c427-47e6-a8af-13d516d90633','e3a3e85e-2903-4ae6-ba17-f7f2ad9d7e0d'))";

                BLL_ResourceToResourceFolder rtrfbll = new BLL_ResourceToResourceFolder();
                rtrflist = rtrfbll.GetModelList(StrWhere);

                if (rtrflist != null)
                {
                    string SqlTemp = "delete from FileSyncRecordFail where Resource_Type in ('b8ea8767-4ae6-4b90-883f-93415a14e461','f1d1db22-c427-47e6-a8af-13d516d90633','e3a3e85e-2903-4ae6-ba17-f7f2ad9d7e0d')";
                    Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(SqlTemp);
                    foreach (var item in rtrflist)
                    {
                        savePath = string.Format("{0}\\{1}\\{2}\\{3}\\", item.ParticularYear, item.GradeTerm,
                                                 item.Resource_Version, item.Subject);

                        #region 教案
                        if ("1" == "1")
                        {
                            switch (item.Resource_Type)
                            {
                            case Resource_TypeConst.ScienceWord类型文件:
                                filePath = "swDocument\\";
                                imgPath  = "swView\\";
                                StrText  = "ScienceWord类型文件";
                                break;

                            case Resource_TypeConst.class类型微课件:
                                filePath = "microClassDocument\\";
                                imgPath  = "microClassView\\";
                                StrText  = "class类型微课件";
                                break;

                            case Resource_TypeConst.class类型文件:
                                filePath = "classDocument\\";
                                imgPath  = "classView\\";
                                StrText  = "class类型文件";
                                break;
                            }
                            #region 判断源文件 和html文件
                            if (!File.Exists(Server.MapPath(uploadPath + filePath + savePath + item.ResourceToResourceFolder_Id + "." + item.File_Suffix)))
                            {
                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + filePath + savePath + item.ResourceToResourceFolder_Id + "." + item.File_Suffix), item.Resource_Type, StrText);
                            }
                            if (!File.Exists(Server.MapPath(uploadPath + filePath + savePath + item.ResourceToResourceFolder_Id + ".htm")))
                            {
                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + filePath + savePath + item.ResourceToResourceFolder_Id + ".htm"), item.Resource_Type, StrText);
                            }
                            #endregion
                            #region 判断图片
                            BLL_ResourceToResourceFolder_img rtrfimgbll = new BLL_ResourceToResourceFolder_img();
                            DataTable dt = rtrfimgbll.GetList(" ResourceToResourceFolder_id='" + item.ResourceToResourceFolder_Id + "'").Tables[0];
                            if (dt.Rows.Count > 0)
                            {
                                for (int i = 0; i < dt.Rows.Count; i++)
                                {
                                    if (!File.Exists(Server.MapPath(uploadPath + imgPath + savePath + dt.Rows[i]["ResourceToResourceFolder_img_id"] + ".jpg")))
                                    {
                                        InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + imgPath + savePath + dt.Rows[i]["ResourceToResourceFolder_img_id"] + ".jpg"), item.Resource_Type, StrText + "jpg");
                                    }
                                }
                            }
                            #endregion
                        }
                        #endregion
                        #region 试卷
                        else
                        {
                            BLL_TestQuestions          tqbll  = new BLL_TestQuestions();
                            List <Model_TestQuestions> tqlist = new List <Model_TestQuestions>();
                            tqlist = tqbll.GetModelList("ResourceToResourceFolder_Id='" + item.ResourceToResourceFolder_Id + "'");
                            if (tqlist != null)
                            {
                                foreach (var tqitem in tqlist)
                                {
                                    #region 题干testQuestionBody
                                    if (!File.Exists(Server.MapPath(uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".htm")))
                                    {
                                        InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".htm"), item.Resource_Type, "题干htm");
                                    }
                                    if (!File.Exists(Server.MapPath(uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".txt")))
                                    {
                                        InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".txt"), item.Resource_Type, "题干txt");
                                    }
                                    #endregion

                                    #region 分值表
                                    BLL_TestQuestions_Score tqsbll = new BLL_TestQuestions_Score();
                                    DataTable tqsdt = tqsbll.GetList("TestQuestions_Id='" + tqitem.TestQuestions_Id + "'").Tables[0];
                                    if (tqsdt.Rows.Count > 0)
                                    {
                                        for (int k = 0; k < tqsdt.Rows.Count; k++)
                                        {
                                            #region  项testQuestionOption
                                            if (!File.Exists(Server.MapPath(uploadPath + "testQuestionOption\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionOption\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "选项txt");
                                            }
                                            #endregion
                                            #region 答案testQuestionCurrent
                                            if (!File.Exists(Server.MapPath(uploadPath + "testQuestionCurrent\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionCurrent\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "答案txt");
                                            }
                                            #endregion
                                            #region 解析AnalyzeData/AnalyzeHtml
                                            if (!File.Exists(Server.MapPath(uploadPath + "AnalyzeData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "AnalyzeData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "解析txt");
                                            }
                                            if (!File.Exists(Server.MapPath(uploadPath + "AnalyzeHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "AnalyzeHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm"), item.Resource_Type, "解析htm");
                                            }
                                            #endregion
                                            #region 强化训练TrainData/TrainHtml
                                            if (!File.Exists(Server.MapPath(uploadPath + "TrainData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "TrainData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "强化训练txt");
                                            }
                                            if (!File.Exists(Server.MapPath(uploadPath + "TrainHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm")))
                                            {
                                                InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "TrainHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm"), item.Resource_Type, "强化训练htm");
                                            }
                                            #endregion
                                        }
                                    }
                                    #endregion
                                }
                            }
                        }
                        #endregion
                    }
                }
                Response.Redirect(Request.Url.ToString());
            }
            catch (Exception ex)
            {
                new BLL_clsAuth().AddLogErrorFromBS("检测同步完成情况失败:", string.Format("类:{0},方法{1},错误信息:{2}", ex.TargetSite.DeclaringType.ToString()
                                                                                 , ex.TargetSite.Name.ToString(), ex.Message));
                Response.Redirect(Request.Url.ToString());
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// 执行数据同步
        /// </summary>
        private void ExecSyncData(string strFileSyncExecRecord_id)
        {
            //所有需要同步数据new
            DataTable dtAll = new DataTable();

            dtAll = new BLL_SyncData().GetList("SyncStatus='0' or SyncStatus='2' ").Tables[0];
            if (dtAll.Rows.Count > 0)
            {
                DataView dataView = dtAll.DefaultView;
                dtAll = dataView.ToTable(true, "TableName", "DataId", "OperateType");
            }

            //ResourceFolder数据
            DataTable dtRF = new DataTable();

            DataRow[] drRF = null;
            if (dtAll.Rows.Count > 0)
            {
                drRF = dtAll.Select("TableName='ResourceFolder'");
            }
            if (drRF != null && drRF.Length > 0)
            {
                dtRF = drRF.CopyToDataTable();
            }

            //ResourceToResourceFolder数据(delete)
            DataTable dtRTRF_Delete = new DataTable();

            DataRow[] drRTRF_Delete = null;
            if (dtAll.Rows.Count > 0)
            {
                drRTRF_Delete = dtAll.Select("TableName='ResourceToResourceFolder' and OperateType='delete'");
            }
            if (drRTRF_Delete != null && drRTRF_Delete.Length > 0)
            {
                dtRTRF_Delete = drRTRF_Delete.CopyToDataTable();
            }

            //ResourceToResourceFolder数据(move,rename)
            DataTable dtRTRF_MoveRename = new DataTable();

            DataRow[] drRTRF_MoveRename = null;
            if (dtAll.Rows.Count > 0)
            {
                drRTRF_MoveRename = dtAll.Select("TableName='ResourceToResourceFolder' and (OperateType='move' or OperateType='rename') ");
            }
            if (drRTRF_MoveRename != null && drRTRF_MoveRename.Length > 0)
            {
                dtRTRF_MoveRename = drRTRF_MoveRename.CopyToDataTable();
            }

            //ResourceToResourceFolder数据(add,modify)
            DataTable dtRTRF_AddModify = new DataTable();

            DataRow[] drRTRF_AddModify = null;
            if (dtAll.Rows.Count > 0)
            {
                drRTRF_AddModify = dtAll.Select("TableName='ResourceToResourceFolder' and (OperateType='modify' or OperateType='add') ");
            }
            if (drRTRF_AddModify != null && drRTRF_AddModify.Length > 0)
            {
                dtRTRF_AddModify = drRTRF_AddModify.CopyToDataTable();
            }
            if (dtRTRF_AddModify.Rows.Count > 0)
            {
                DataView dataView = dtRTRF_AddModify.DefaultView;
                dtRTRF_AddModify = dataView.ToTable(true, "DataId");
            }

            StringBuilder stbRF              = new StringBuilder();
            StringBuilder stbRTRF_Delete     = new StringBuilder();
            StringBuilder stbRTRF_MoveRename = new StringBuilder();
            StringBuilder stbRTRF_AddModify  = new StringBuilder();

            #region ①删除ResourceToResourceFolder数据(delete)
            Rc.Model.Resources.Model_FileSyncExecRecordDetail model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            Rc.BLL.Resources.BLL_FileSyncExecRecordDetail     bll_FileSyncExecRecordDetail   = new Rc.BLL.Resources.BLL_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "①删除ResourceToResourceFolder数据(delete)";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            foreach (DataRow item in dtRTRF_Delete.Rows)
            {
                stbRTRF_Delete = new StringBuilder();
                stbRTRF_Delete.Append("declare @resourceId char(36);");
                stbRTRF_Delete.AppendFormat(@"delete from TestQuestions_Option where TestQuestions_Id in(select TestQuestions_Id from TestQuestions where ResourceToResourceFolder_Id='{0}');
delete from TestQuestions_Score where ResourceToResourceFolder_Id='{0}';
delete from TestQuestions where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder_Property where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder_img where ResourceToResourceFolder_Id='{0}';
select @resourceId=Resource_Id from ResourceToResourceFolder where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder where ResourceToResourceFolder_Id='{0}';
delete from [Resource] where Resource_Id=@resourceId;", item["DataId"]);
                DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_Delete.ToString(), 7200);
                DbHelperSQL.ExecuteSqlByTime(string.Format("update SyncData set SyncStatus='1' where OperateType='delete' and DataId='{0}'; ", item["DataId"]), 60);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion

            #region ②同步ResourceFolder数据
            model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "②同步ResourceFolder数据";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            foreach (DataRow item in dtRF.Rows)
            {
                stbRF = new StringBuilder();
                #region delete
                if (item["OperateType"].ToString() == "delete")
                {
                    stbRF.AppendFormat("delete from ResourceFolder where ResourceFolder_Id='{0}'; ", item["DataId"]);
                }
                #endregion
                DataTable dtSub = new BLL_ResourceFolder().GetList("ResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                if (dtSub.Rows.Count == 1)
                {
                    #region move,rename
                    if (item["OperateType"].ToString() == "move" || item["OperateType"].ToString() == "rename")
                    {
                        stbRF.Append("update ResourceFolder set ");
                        stbRF.AppendFormat("ResourceFolder_ParentId='{0}',", dtSub.Rows[0]["ResourceFolder_ParentId"]);
                        stbRF.AppendFormat("ResourceFolder_Name=N'{0}',", dtSub.Rows[0]["ResourceFolder_Name"]);
                        stbRF.AppendFormat("ResourceFolder_Level='{0}',", dtSub.Rows[0]["ResourceFolder_Level"]);
                        stbRF.AppendFormat("Resource_Type='{0}',", dtSub.Rows[0]["Resource_Type"]);
                        stbRF.AppendFormat("Resource_Class='{0}',", dtSub.Rows[0]["Resource_Class"]);
                        stbRF.AppendFormat("Resource_Version='{0}',", dtSub.Rows[0]["Resource_Version"]);
                        stbRF.AppendFormat("ResourceFolder_Remark='{0}',", dtSub.Rows[0]["ResourceFolder_Remark"]);
                        stbRF.AppendFormat("ResourceFolder_Order='{0}',", dtSub.Rows[0]["ResourceFolder_Order"]);
                        stbRF.AppendFormat("ResourceFolder_Owner='{0}',", dtSub.Rows[0]["ResourceFolder_Owner"]);
                        stbRF.AppendFormat("CreateFUser='******',", dtSub.Rows[0]["CreateFUser"]);
                        stbRF.AppendFormat("CreateTime='{0}',", dtSub.Rows[0]["CreateTime"]);
                        stbRF.AppendFormat("ResourceFolder_isLast='{0}',", dtSub.Rows[0]["ResourceFolder_isLast"]);
                        stbRF.AppendFormat("LessonPlan_Type='{0}',", dtSub.Rows[0]["LessonPlan_Type"]);
                        stbRF.AppendFormat("GradeTerm='{0}',", dtSub.Rows[0]["GradeTerm"]);
                        stbRF.AppendFormat("Subject='{0}',", dtSub.Rows[0]["Subject"]);
                        stbRF.AppendFormat("Book_ID='{0}',", dtSub.Rows[0]["Book_ID"]);
                        stbRF.AppendFormat("ParticularYear='{0}'", dtSub.Rows[0]["ParticularYear"]);
                        stbRF.AppendFormat(" where ResourceFolder_Id='{0}' ", dtSub.Rows[0]["ResourceFolder_Id"]);
                    }
                    #endregion
                    #region add
                    if (item["OperateType"].ToString() == "add")
                    {
                        stbRF.AppendFormat("if(select COUNT(1) from ResourceFolder where ResourceFolder_Id='{0}')=0 insert into ResourceFolder(ResourceFolder_Id,ResourceFolder_ParentId,ResourceFolder_Name,ResourceFolder_Level,Resource_Type,Resource_Class,Resource_Version,ResourceFolder_Remark,ResourceFolder_Order,ResourceFolder_Owner,CreateFUser,CreateTime,ResourceFolder_isLast,LessonPlan_Type,GradeTerm,Subject,Book_ID,ParticularYear)", dtSub.Rows[0]["ResourceFolder_Id"]);
                        stbRF.AppendFormat(" values ('{0}','{1}',N'{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}');"
                                           , dtSub.Rows[0]["ResourceFolder_Id"]
                                           , dtSub.Rows[0]["ResourceFolder_ParentId"]
                                           , dtSub.Rows[0]["ResourceFolder_Name"]
                                           , dtSub.Rows[0]["ResourceFolder_Level"]
                                           , dtSub.Rows[0]["Resource_Type"]
                                           , dtSub.Rows[0]["Resource_Class"]
                                           , dtSub.Rows[0]["Resource_Version"]
                                           , dtSub.Rows[0]["ResourceFolder_Remark"]
                                           , dtSub.Rows[0]["ResourceFolder_Order"]
                                           , dtSub.Rows[0]["ResourceFolder_Owner"]
                                           , dtSub.Rows[0]["CreateFUser"]
                                           , dtSub.Rows[0]["CreateTime"]
                                           , dtSub.Rows[0]["ResourceFolder_isLast"]
                                           , dtSub.Rows[0]["LessonPlan_Type"]
                                           , dtSub.Rows[0]["GradeTerm"]
                                           , dtSub.Rows[0]["Subject"]
                                           , dtSub.Rows[0]["Book_ID"]
                                           , dtSub.Rows[0]["ParticularYear"]);
                    }
                    #endregion
                }
                if (!string.IsNullOrEmpty(stbRF.ToString()))
                {
                    DbHelperSQL_Operate.ExecuteSqlByTime(stbRF.ToString(), 7200);
                }
                DbHelperSQL.ExecuteSqlByTime(string.Format("update SyncData set SyncStatus='1' where TableName='ResourceFolder' and DataId='{0}'; ", item["DataId"]), 60);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion

            #region ③更新ResourceToResourceFolder数据(move,rename)
            model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "③更新ResourceToResourceFolder数据(move,rename)";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            foreach (DataRow item in dtRTRF_MoveRename.Rows)
            {
                stbRTRF_MoveRename = new StringBuilder();
                DataTable dtSub = new BLL_ResourceToResourceFolder().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                if (dtSub.Rows.Count == 1)
                {
                    stbRTRF_MoveRename.Append("update ResourceToResourceFolder set ");
                    stbRTRF_MoveRename.AppendFormat("ResourceFolder_Id='{0}',", dtSub.Rows[0]["ResourceFolder_Id"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Id='{0}',", dtSub.Rows[0]["Resource_Id"]);
                    stbRTRF_MoveRename.AppendFormat("File_Name=N'{0}',", dtSub.Rows[0]["File_Name"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Type='{0}',", dtSub.Rows[0]["Resource_Type"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Name=N'{0}',", dtSub.Rows[0]["Resource_Name"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Class='{0}',", dtSub.Rows[0]["Resource_Class"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Version='{0}',", dtSub.Rows[0]["Resource_Version"]);
                    stbRTRF_MoveRename.AppendFormat("File_Owner='{0}',", dtSub.Rows[0]["File_Owner"]);
                    stbRTRF_MoveRename.AppendFormat("CreateFUser='******',", dtSub.Rows[0]["CreateFUser"]);
                    stbRTRF_MoveRename.AppendFormat("CreateTime='{0}',", dtSub.Rows[0]["CreateTime"]);
                    stbRTRF_MoveRename.AppendFormat("UpdateTime='{0}',", dtSub.Rows[0]["UpdateTime"]);
                    stbRTRF_MoveRename.AppendFormat("File_Suffix='{0}',", dtSub.Rows[0]["File_Suffix"]);
                    stbRTRF_MoveRename.AppendFormat("LessonPlan_Type='{0}',", dtSub.Rows[0]["LessonPlan_Type"]);
                    stbRTRF_MoveRename.AppendFormat("GradeTerm='{0}',", dtSub.Rows[0]["GradeTerm"]);
                    stbRTRF_MoveRename.AppendFormat("Subject='{0}',", dtSub.Rows[0]["Subject"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Domain='{0}',", dtSub.Rows[0]["Resource_Domain"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_Url='{0}',", dtSub.Rows[0]["Resource_Url"]);
                    stbRTRF_MoveRename.AppendFormat("Resource_shared='{0}',", dtSub.Rows[0]["Resource_shared"]);
                    stbRTRF_MoveRename.AppendFormat("Book_ID='{0}',", dtSub.Rows[0]["Book_ID"]);
                    stbRTRF_MoveRename.AppendFormat("ParticularYear='{0}',", dtSub.Rows[0]["ParticularYear"]);
                    stbRTRF_MoveRename.AppendFormat("ResourceToResourceFolder_Order='{0}'", dtSub.Rows[0]["ResourceToResourceFolder_Order"]);
                    stbRTRF_MoveRename.AppendFormat(" where ResourceToResourceFolder_Id='{0}'; ", dtSub.Rows[0]["ResourceToResourceFolder_Id"]);
                }
                if (!string.IsNullOrEmpty(stbRTRF_MoveRename.ToString()))
                {
                    DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_MoveRename.ToString(), 7200);
                }
                DbHelperSQL.ExecuteSqlByTime(string.Format("update SyncData set SyncStatus='1' where TableName='ResourceToResourceFolder' and (OperateType='move' or OperateType='rename') and DataId='{0}'; ", item["DataId"]), 60);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion

            #region ④同步ResourceToResourceFolder数据 先删除数据 再增加数据(add,modify)
            model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "④同步ResourceToResourceFolder数据 先删除数据 再增加数据(add,modify)";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            foreach (DataRow item in dtRTRF_AddModify.Rows)
            {
                string resourceId = DbHelperSQL.GetSingle("select isnull(max(Resource_Id),'') from ResourceToResourceFolder where ResourceToResourceFolder_Id='" + item["DataId"] + "'").ToString();
                if (!string.IsNullOrEmpty(resourceId.Trim()))
                {
                    //删除数据
                    stbRTRF_AddModify = new StringBuilder();
                    stbRTRF_AddModify.AppendFormat(@"delete from TestQuestions_Option where TestQuestions_Id in(select TestQuestions_Id from TestQuestions where ResourceToResourceFolder_Id='{0}');
delete from TestQuestions_Score where ResourceToResourceFolder_Id='{0}';
delete from TestQuestions where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder_Property where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder_img where ResourceToResourceFolder_Id='{0}';
delete from ResourceToResourceFolder where ResourceToResourceFolder_Id='{0}';
delete from [Resource] where Resource_Id='{1}';"
                                                   , item["DataId"]
                                                   , resourceId);
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    //新增数据
                    #region Resource
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtRes = new BLL_Resource().GetList("Resource_Id='" + resourceId + "'").Tables[0];
                    stbRTRF_AddModify.Append("insert into Resource(Resource_Id,Resource_MD5,Resource_DataStrem,Resource_ContentHtml,CreateTime,Resource_ContentLength)");
                    stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}');"
                                                   , dtRes.Rows[0]["Resource_Id"]
                                                   , dtRes.Rows[0]["Resource_MD5"]
                                                   , dtRes.Rows[0]["Resource_DataStrem"]
                                                   , dtRes.Rows[0]["Resource_ContentHtml"]
                                                   , dtRes.Rows[0]["CreateTime"]
                                                   , dtRes.Rows[0]["Resource_ContentLength"]);
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                    #region ResourceToResourceFolder
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtRTRF = new BLL_ResourceToResourceFolder().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                    stbRTRF_AddModify.Append("insert into ResourceToResourceFolder(ResourceToResourceFolder_Id,ResourceFolder_Id,Resource_Id,File_Name,Resource_Type,Resource_Name,Resource_Class,Resource_Version,File_Owner,CreateFUser,CreateTime,UpdateTime,File_Suffix,LessonPlan_Type,GradeTerm,Subject,Resource_Domain,Resource_Url,Resource_shared,Book_ID,ParticularYear,ResourceToResourceFolder_Order)");
                    stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}',N'{3}','{4}',N'{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}');"
                                                   , dtRTRF.Rows[0]["ResourceToResourceFolder_Id"]
                                                   , dtRTRF.Rows[0]["ResourceFolder_Id"]
                                                   , dtRTRF.Rows[0]["Resource_Id"]
                                                   , dtRTRF.Rows[0]["File_Name"]
                                                   , dtRTRF.Rows[0]["Resource_Type"]
                                                   , dtRTRF.Rows[0]["Resource_Name"]
                                                   , dtRTRF.Rows[0]["Resource_Class"]
                                                   , dtRTRF.Rows[0]["Resource_Version"]
                                                   , dtRTRF.Rows[0]["File_Owner"]
                                                   , dtRTRF.Rows[0]["CreateFUser"]
                                                   , dtRTRF.Rows[0]["CreateTime"]
                                                   , dtRTRF.Rows[0]["UpdateTime"]
                                                   , dtRTRF.Rows[0]["File_Suffix"]
                                                   , dtRTRF.Rows[0]["LessonPlan_Type"]
                                                   , dtRTRF.Rows[0]["GradeTerm"]
                                                   , dtRTRF.Rows[0]["Subject"]
                                                   , dtRTRF.Rows[0]["Resource_Domain"]
                                                   , dtRTRF.Rows[0]["Resource_Url"]
                                                   , dtRTRF.Rows[0]["Resource_shared"]
                                                   , dtRTRF.Rows[0]["Book_ID"]
                                                   , dtRTRF.Rows[0]["ParticularYear"]
                                                   , dtRTRF.Rows[0]["ResourceToResourceFolder_Order"]);
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                    #region ResourceToResourceFolder_img
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtRTRF_Img = new BLL_ResourceToResourceFolder_img().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                    foreach (DataRow item_Img in dtRTRF_Img.Rows)
                    {
                        stbRTRF_AddModify.Append("insert into ResourceToResourceFolder_img(ResourceToResourceFolder_img_id,ResourceToResourceFolder_id,ResourceToResourceFolderImg_Url,ResourceToResourceFolderImg_Order,CreateTime)");
                        stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}');"
                                                       , item_Img["ResourceToResourceFolder_img_id"]
                                                       , item_Img["ResourceToResourceFolder_id"]
                                                       , item_Img["ResourceToResourceFolderImg_Url"]
                                                       , item_Img["ResourceToResourceFolderImg_Order"]
                                                       , item_Img["CreateTime"]);
                    }
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                    #region ResourceToResourceFolder_Property
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtRTRF_Property = new BLL_ResourceToResourceFolder_Property().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                    foreach (DataRow item_Property in dtRTRF_Property.Rows)
                    {
                        stbRTRF_AddModify.Append("insert into ResourceToResourceFolder_Property(ResourceToResourceFolder_Id,BooksCode,BooksUnitCode,GuidDoc,TestPaperName,CreateTime,paperHeaderDoc,paperHeaderHtml)");
                        stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}');"
                                                       , item_Property["ResourceToResourceFolder_Id"]
                                                       , item_Property["BooksCode"]
                                                       , item_Property["BooksUnitCode"]
                                                       , item_Property["GuidDoc"]
                                                       , item_Property["TestPaperName"]
                                                       , item_Property["CreateTime"]
                                                       , item_Property["paperHeaderDoc"]
                                                       , item_Property["paperHeaderHtml"]);
                    }
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                    #region TestQuestions,TestQuestions_Option
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtTQ = new BLL_TestQuestions().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                    foreach (DataRow item_TQ in dtTQ.Rows)
                    {
                        stbRTRF_AddModify.Append("insert into TestQuestions(TestQuestions_Id,ResourceToResourceFolder_Id,TestQuestions_Num,TestQuestions_Type,TestQuestions_SumScore,TestQuestions_Content,TestQuestions_Answer,CreateTime,topicNumber,Parent_Id,[type])");
                        stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}');"
                                                       , item_TQ["TestQuestions_Id"]
                                                       , item_TQ["ResourceToResourceFolder_Id"]
                                                       , item_TQ["TestQuestions_Num"]
                                                       , item_TQ["TestQuestions_Type"]
                                                       , item_TQ["TestQuestions_SumScore"]
                                                       , item_TQ["TestQuestions_Content"]
                                                       , item_TQ["TestQuestions_Answer"]
                                                       , item_TQ["CreateTime"]
                                                       , item_TQ["topicNumber"].ToString().Filter()
                                                       , item_TQ["Parent_Id"]
                                                       , item_TQ["type"]);
                        #region TestQuestions_Option
                        DataTable dtTQ_Option = new BLL_TestQuestions_Option().GetList("TestQuestions_Id='" + item_TQ["TestQuestions_Id"] + "'").Tables[0];
                        foreach (DataRow item_TQ_Option in dtTQ_Option.Rows)
                        {
                            stbRTRF_AddModify.Append("insert into TestQuestions_Option(TestQuestions_Option_Id,TestQuestions_Id,TestQuestions_OptionParent_OrderNum,TestQuestions_Option_Content,TestQuestions_Option_OrderNum,CreateTime,TestQuestions_Score_ID)");
                            stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}');"
                                                           , item_TQ_Option["TestQuestions_Option_Id"]
                                                           , item_TQ_Option["TestQuestions_Id"]
                                                           , item_TQ_Option["TestQuestions_OptionParent_OrderNum"]
                                                           , item_TQ_Option["TestQuestions_Option_Content"].ToString().Filter()
                                                           , item_TQ_Option["TestQuestions_Option_OrderNum"]
                                                           , item_TQ_Option["CreateTime"]
                                                           , item_TQ_Option["TestQuestions_Score_ID"]);
                        }
                        #endregion
                    }
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                    #region TestQuestions_Score
                    stbRTRF_AddModify = new StringBuilder();
                    DataTable dtTQ_Score = new BLL_TestQuestions_Score().GetList("ResourceToResourceFolder_Id='" + item["DataId"] + "'").Tables[0];
                    foreach (DataRow item_TQ_Score in dtTQ_Score.Rows)
                    {
                        stbRTRF_AddModify.Append("insert into TestQuestions_Score(TestQuestions_Score_ID,ResourceToResourceFolder_Id,TestQuestions_Id,TestQuestions_Num,TestQuestions_OrderNum,TestQuestions_Score,AnalyzeHyperlink,AnalyzeHyperlinkData,AnalyzeHyperlinkHtml,AnalyzeText,ComplexityHyperlink,ComplexityText,ContentHyperlink,ContentText,DocBase64,DocHtml,ScoreHyperlink,ScoreText,TargetHyperlink,TrainHyperlinkData,TrainHyperlinkHtml,TargetText,TestCorrect,TestType,TrainHyperlink,TrainText,TypeHyperlink,TypeText,CreateTime,AreaHyperlink,AreaText,kaofaText,testIndex)");
                        stbRTRF_AddModify.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}','{28}','{29}','{30}','{31}','{32}');"
                                                       , item_TQ_Score["TestQuestions_Score_ID"]
                                                       , item_TQ_Score["ResourceToResourceFolder_Id"]
                                                       , item_TQ_Score["TestQuestions_Id"]
                                                       , item_TQ_Score["TestQuestions_Num"]
                                                       , item_TQ_Score["TestQuestions_OrderNum"]
                                                       , item_TQ_Score["TestQuestions_Score"]
                                                       , item_TQ_Score["AnalyzeHyperlink"]
                                                       , item_TQ_Score["AnalyzeHyperlinkData"]
                                                       , item_TQ_Score["AnalyzeHyperlinkHtml"]
                                                       , item_TQ_Score["AnalyzeText"]
                                                       , item_TQ_Score["ComplexityHyperlink"]
                                                       , item_TQ_Score["ComplexityText"]
                                                       , item_TQ_Score["ContentHyperlink"]
                                                       , item_TQ_Score["ContentText"]
                                                       , item_TQ_Score["DocBase64"]
                                                       , item_TQ_Score["DocHtml"]
                                                       , item_TQ_Score["ScoreHyperlink"]
                                                       , item_TQ_Score["ScoreText"]
                                                       , item_TQ_Score["TargetHyperlink"]
                                                       , item_TQ_Score["TrainHyperlinkData"]
                                                       , item_TQ_Score["TrainHyperlinkHtml"]
                                                       , item_TQ_Score["TargetText"]
                                                       , item_TQ_Score["TestCorrect"]
                                                       , item_TQ_Score["TestType"]
                                                       , item_TQ_Score["TrainHyperlink"]
                                                       , item_TQ_Score["TrainText"]
                                                       , item_TQ_Score["TypeHyperlink"]
                                                       , item_TQ_Score["TypeText"]
                                                       , item_TQ_Score["CreateTime"]
                                                       , item_TQ_Score["AreaHyperlink"]
                                                       , item_TQ_Score["AreaText"]
                                                       , item_TQ_Score["kaofaText"]
                                                       , item_TQ_Score["testIndex"]);
                    }
                    AddLogInfo(string.Format("{0}--结束--", stbRTRF_AddModify.ToString()), true);
                    if (!string.IsNullOrEmpty(stbRTRF_AddModify.ToString()))
                    {
                        DbHelperSQL_Operate.ExecuteSqlByTime(stbRTRF_AddModify.ToString(), 7200);
                    }

                    #endregion
                }

                DbHelperSQL.ExecuteSqlByTime(string.Format("update SyncData set SyncStatus='1' where TableName='ResourceToResourceFolder' and (OperateType='add' or OperateType='modify') and DataId='{0}'; ", item["DataId"]), 60);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion

            #region ⑤同步BookAudit表数据
            model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "⑤同步BookAudit表数据";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            StringBuilder stbBookAudit = new StringBuilder();
            DataTable     dtBookAudit  = new BLL_BookAudit().GetList(" ResourceFolder_Id in(select DataId from SyncData where TableName='BookAudit' and (SyncStatus='0' or SyncStatus='2') ) ").Tables[0];
            foreach (DataRow item in dtBookAudit.Rows)
            {
                stbBookAudit.AppendFormat(@"if(select COUNT(1) from BookAudit where ResourceFolder_Id='{0}')=0 
                begin 
                insert into BookAudit(ResourceFolder_Id,Book_Name,AuditState,AuditRemark,CreateUser,CreateTime) values ('{0}',N'{1}','{2}','{3}','{4}','{5}');"
                                          , item["ResourceFolder_Id"]
                                          , item["Book_Name"]
                                          , item["AuditState"]
                                          , item["AuditRemark"]
                                          , item["CreateUser"]
                                          , item["CreateTime"]);
                stbBookAudit.Append(" end ");
                stbBookAudit.Append(" else ");
                stbBookAudit.Append(" begin ");
                stbBookAudit.AppendFormat(@"if(select COUNT(1) from BookAudit where ResourceFolder_Id='{0}' and (AuditState='{1}' or CreateTime='{2}') )=0 
                begin 
                    update BookAudit set AuditState='{1}',CreateTime='{2}' where ResourceFolder_Id='{0}';
                end ", item["ResourceFolder_Id"], item["AuditState"], item["CreateTime"]);
                stbBookAudit.Append(" end ");

                DbHelperSQL.ExecuteSqlByTime(string.Format("update SyncData set SyncStatus='1' where TableName='BookAudit' and OperateType='bookaudit' and DataId='{0}'; ", item["ResourceFolder_Id"]), 60);
            }
            AddLogInfo(string.Format("{0}--结束--", stbBookAudit.ToString()), true);
            if (!string.IsNullOrEmpty(stbBookAudit.ToString()))
            {
                DbHelperSQL_Operate.ExecuteSqlByTime(stbBookAudit.ToString(), 7200);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion

            #region ⑥同步SyncData表数据
            model_FileSyncExecRecordDetail = new Rc.Model.Resources.Model_FileSyncExecRecordDetail();
            model_FileSyncExecRecordDetail.FileSyncExecRecordDetail_id = Guid.NewGuid().ToString();
            model_FileSyncExecRecordDetail.FileSyncExecRecord_id       = strFileSyncExecRecord_id;
            model_FileSyncExecRecordDetail.Detail_Remark    = "⑥同步SyncData表数据";
            model_FileSyncExecRecordDetail.Detail_Status    = "0";
            model_FileSyncExecRecordDetail.Detail_TimeStart = DateTime.Now;
            bll_FileSyncExecRecordDetail.Add(model_FileSyncExecRecordDetail);

            StringBuilder stbSyncData = new StringBuilder();
            DataTable     dtSyncData  = new BLL_SyncData().GetList("").Tables[0];
            foreach (DataRow item in dtSyncData.Rows)
            {
                stbSyncData.AppendFormat("if(select COUNT(1) from SyncData where SyncDataId='{0}')=0 insert into SyncData(SyncDataId,TableName,DataId,OperateType,CreateTime,SyncStatus)", item["SyncDataId"]);
                stbSyncData.AppendFormat(" values ('{0}','{1}','{2}','{3}','{4}','{5}');"
                                         , item["SyncDataId"]
                                         , item["TableName"]
                                         , item["DataId"]
                                         , item["OperateType"]
                                         , item["CreateTime"]
                                         , item["SyncStatus"]);
            }
            AddLogInfo(string.Format("{0}--结束--", stbSyncData.ToString()), true);
            if (!string.IsNullOrEmpty(stbSyncData.ToString()))
            {
                DbHelperSQL_Operate.ExecuteSqlByTime(stbSyncData.ToString(), 7200);
            }

            model_FileSyncExecRecordDetail.Detail_Status  = "1";
            model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
            bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            #endregion
        }
Ejemplo n.º 14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string strHomeWork_Id = Guid.NewGuid().ToString();

            try
            {
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:1开始验证");
                // 学校IP
                string hostUrl = pfunction.GetResourceHost("TestWebSiteUrl");
                //if (hostUrl != Rc.Common.ConfigHelper.GetConfigString("TestWebSiteUrl"))
                //{
                //    #region 学校配置URL
                //    DataTable dtUrl = new BLL_ConfigSchool().GetSchoolPublicUrl(FloginUser.UserId).Tables[0];
                //    if (dtUrl.Rows.Count > 0)
                //    {
                //        hostUrl = dtUrl.Rows[0]["apiUrlList"].ToString();
                //    }
                //    #endregion
                //}

                #region 验证
                if (pfunction.FilterKeyWords(this.txtHomeWork_Name.Text))
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('作业名称存在敏感词汇,请重新填写。',{icon:2,time:2000});</script>");
                    return;
                }
                DataTable dtHWDetail = Rc.Common.DBUtility.DbHelperSQL.Query("select * from VW_ClassGradeSchool where ClassId='" + ddlClass.SelectedValue + "' and GradeId is not null and SchoolId is not null ").Tables[0];
                if (dtHWDetail.Rows.Count == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('加入年级后才可布置作业',{time:2000,icon:2});", true);
                    return;
                }
                if (new BLL_UserGroup_Member().GetRecordCount("UserStatus='0' and User_Id='" + FloginUser.UserId + "' and UserGroup_Id='" + ddlClass.SelectedValue + "' ") == 0)
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.ready(function(){layer.msg('老师与所布置作业班级关系错误',{time:2000,icon:2});});", true);
                    return;
                }

                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrfId);

                if (modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源)
                {
                    if (modelRTRF.Resource_Type != Resource_TypeConst.集体备课文件 && modelRTRF.CreateFUser != FloginUser.UserId)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('此资源不是您的',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                        return;
                    }
                }
                else if (modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                {
                    if (new BLL_UserBuyResources().GetRecordCount("UserId='" + FloginUser.UserId + "' and Book_Id='" + modelRTRF.Book_ID + "' ") == 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('老师还未购买此资源',{time:2000,icon:2},function(){window.parent.location.reload();parent.layer.close(parent.layer.getFrameIndex(window.name));});", true);
                        return;
                    }
                }

                //Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置作业:验证网络是否通畅" + hostUrl);
                ////检测网络是否通畅
                //if (RemotWeb.PostDataToServer(hostUrl + "/AuthApi/index.aspx?key=onlinecheck", "", Encoding.UTF8, "Get") != "ok")
                //{
                //    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('服务器网络不通畅。',{icon:2,time:3000});</script>");
                //    return;
                //}
                #endregion

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:1结束验证");

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:2开始组织提交数据");

                #region 组织提交数据
                DateTime hw_time   = DateTime.Now;
                string   SubjectId = FloginUser.Subject;
                if (modelRTRF != null && modelRTRF.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                {
                    SubjectId = modelRTRF.Subject;
                }
                int intTimeLength = 0;
                int.TryParse(txtTimeLength.Text, out intTimeLength);
                string strIsCountdown = "0";
                if (chkIsCountdown.Checked)
                {
                    strIsCountdown = "1";
                }
                object objAssign = new
                {
                    tqInfo                 = hidTQ.Value,
                    rtrfId_Old             = rtrfId,
                    HomeWork_Id            = strHomeWork_Id,
                    HomeWork_Name          = txtHomeWork_Name.Text,
                    HomeWork_AssignTeacher = FloginUser.UserId,
                    BeginTime              = DateTime.Now,
                    IsHide                 = 0,
                    HomeWork_Status        = 0,
                    CreateTime             = hw_time,
                    UserGroup_Id           = ddlClass.SelectedValue,
                    isTimeLimt             = 1,
                    isTimeLength           = intTimeLength,
                    SubjectId              = SubjectId,
                    IsShowAnswer           = 1,
                    IsCountdown            = strIsCountdown
                };
                #endregion

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:2结束组织提交数据");

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:3开始提交到学校服务器");

                hostUrl += "teacher/tchAssignTQ.aspx";
                string result = Rc.Common.RemotWeb.PostDataToServer(hostUrl, JsonConvert.SerializeObject(objAssign), System.Text.Encoding.UTF8, "POST");
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题:3结束提交到学校服务器");
                if (result == "ok")
                {
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题成功");
                    string strJ = "layer.msg('布置试题成功',{time:1000,icon:1},function(){window.parent.location.href='CommentCountdown.aspx?hwId=" + strHomeWork_Id + "';});";
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", strJ, true);
                }
                else
                {
                    //RevokeHW 布置作业失败 撤销作业
                    new BLL_HomeWork().RevokeHW(strHomeWork_Id);
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题失败:学校未布置成功");
                    ClientScript.RegisterStartupScript(this.GetType(), "temp", "layer.msg('布置试题失败',{time:2000,icon:2});", true);
                }
            }
            catch (Exception ex)
            {
                //RevokeHW 布置作业失败 撤销作业
                new BLL_HomeWork().RevokeHW(strHomeWork_Id);
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(FloginUser.UserId, "", "布置试题失败" + ex.Message.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('布置试题失败!',{ time: 2000,icon:2});</script>");
            }
        }
Ejemplo n.º 15
0
        private void LoadData()
        {
            Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(ResourceToResourceFolder_Id);

            if (modelRTRF != null)
            {
                Model_HomeWork modelHW = new BLL_HomeWork().GetModel(HomeWork_Id);
                ltlHomeWorkName.Text = modelRTRF.File_Name;
                string uploadTestPaperPath     = pfunction.GetResourceHost("TestWebSiteUrl") + "Upload/Resource/"; //存储文件基础路径
                string uploadStudentAnswerPath = Rc.Cloud.Web.Common.pfunction.GetResourceHost("StudentAnswerWebSiteUrl") + "Upload/Resource/";
                //生成存储路径
                string savePath             = string.Format("{0}\\{1}\\{2}\\{3}\\", modelRTRF.ParticularYear, modelRTRF.GradeTerm, modelRTRF.Resource_Version, modelRTRF.Subject);
                string fileTestPaperUrl     = uploadTestPaperPath + "{0}\\" + savePath + "{1}.{2}";                                                                                       //试题文件详细路径
                string fileStudentAnswerUrl = uploadStudentAnswerPath + "{0}\\" + Rc.Cloud.Web.Common.pfunction.ToShortDate(modelHW.CreateTime.ToString()) + "\\" + savePath + "{1}.{2}"; //学生答案文件详细路径

                Model_UserGroup modelUG = new BLL_UserGroup().GetModel(modelHW.UserGroup_Id);
                ltlClassName.Text = modelUG.UserGroup_Name;

                Model_TestQuestions modelTQ = new BLL_TestQuestions().GetModel(TestQuestions_Id);

                //题干
                string strTestQuestionBody = Rc.Common.RemotWeb.PostDataToServer(string.Format(fileTestPaperUrl, "testQuestionBody", modelTQ.TestQuestions_Id, "htm"), "", Encoding.UTF8, "Get");


                ltlTQSumScore.Text = modelTQ.TestQuestions_SumScore.ToString().clearLastZero();
                DataTable dtTQScore = new DataTable();
                string    strSql    = "select * from TestQuestions_Score where TestQuestions_Id='" + TestQuestions_Id + "' order by TestQuestions_OrderNum ";
                dtTQScore = Rc.Common.DBUtility.DbHelperSQL.Query(strSql).Tables[0];
                //选择题选项
                string strOption = string.Empty;
                int    num       = 0;
                foreach (DataRow item in dtTQScore.Rows)
                {
                    if (modelTQ.TestQuestions_Type == "selection" || modelTQ.TestQuestions_Type == "clozeTest")//选择题、完形填空题选项
                    {
                        //从文件读取选择题选项
                        string strTestQuestionOption = Rc.Common.RemotWeb.PostDataToServer(string.Format(fileTestPaperUrl, "testQuestionOption", item["TestQuestions_Score_ID"], "txt"), "", Encoding.UTF8, "Get");
                        List <Rc.Interface.TestSelections> listTestSelections = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Rc.Interface.TestSelections> >(strTestQuestionOption);
                        if (listTestSelections != null && listTestSelections.Count > 0)
                        {
                            foreach (var itemTS in listTestSelections)
                            {
                                if (!string.IsNullOrEmpty(itemTS.selectionHTML))
                                {
                                    strOption += string.Format("<div class=\"option_item\">{0}</div>", Rc.Cloud.Web.Common.pfunction.NoHTML(itemTS.selectionHTML));
                                }
                            }
                            if (num < dtTQScore.Rows.Count - 1 && !string.IsNullOrEmpty(strOption))
                            {
                                strOption += "<br/><hr style=' height:1px;border:none;border-top:1px dotted #185598;' />";
                            }
                        }
                    }

                    stbTQAnswerScore.Append("<div class=\"answer_main clearfix\">");
                    //从文件读取正确答案图片
                    string strTestQuestionCorrect = string.Empty;
                    if (modelTQ.TestQuestions_Type == "selection" || modelTQ.TestQuestions_Type == "clozeTest" || modelTQ.TestQuestions_Type == "truefalse")
                    {
                        strTestQuestionCorrect = item["TestCorrect"].ToString();
                    }
                    else if (modelTQ.TestQuestions_Type == "fill" || modelTQ.TestQuestions_Type == "answers")
                    {
                        strTestQuestionCorrect = Rc.Common.RemotWeb.PostDataToServer(string.Format(fileTestPaperUrl, "testQuestionCurrent", item["TestQuestions_Score_ID"], "txt"), "", Encoding.UTF8, "Get");
                        strTestQuestionCorrect = string.Format("<div>{0}</div>", Rc.Cloud.Web.Common.pfunction.NoHTML(strTestQuestionCorrect));
                    }
                    stbTQAnswerScore.AppendFormat("<div class=\"correct_answer\">{0}</div>", Rc.Cloud.Web.Common.pfunction.NoHTML(strTestQuestionCorrect));
                    stbTQAnswerScore.Append("<div class=\"score\">");
                    stbTQAnswerScore.AppendFormat("<div data-name=\"FillScore\"><input type=\"text\" name=\"fill_Score\" readonly value=\"{0}\" /></div>"
                                                  , item["TestQuestions_Score"].ToString().clearLastZero());
                    stbTQAnswerScore.Append("</div>");
                    stbTQAnswerScore.Append("</div>");

                    num++;
                }
                ltlTestQuestionsBody.Text = pfunction.NoHTML(strTestQuestionBody) + strOption;

                #region 学生答题详情
                string strWhere     = string.Empty;
                string strSqlAnswer = @"select tqs.TestQuestions_Id,tqs.TestQuestions_Score_ID,tqs.TestCorrect,tqs.TestQuestions_Score,tqs.TestQuestions_Num,tqs.TestQuestions_OrderNum,shwa.Student_HomeWorkAnswer_Id,shwa.Student_Id,shwa.Student_Answer,shwa.Student_Score,shwa.Student_Answer_Status,shwa.Comment
,fu.UserName,fu.TrueName,shwa.CreateTime
from TestQuestions_Score tqs 
                left join Student_HomeWorkAnswer shwa on TQS.TestQuestions_Id=SHWA.TestQuestions_Id and TQS.TestQuestions_Score_ID=SHWA.TestQuestions_Score_ID 
left join F_User fu on fu.UserId=shwa.Student_Id
where tqs.TestQuestions_Id='" + TestQuestions_Id + "' and shwa.HomeWork_Id='" + HomeWork_Id + "' " + strWhere + " order by tqs.TestQuestions_OrderNum,shwa.CreateTime";

                DataTable dtAnswerScore = Rc.Common.DBUtility.DbHelperSQL.Query(strSqlAnswer).Tables[0];
                DataTable dtDistinct    = dtAnswerScore.DefaultView.ToTable(true, "UserName", "TrueName", "Student_Id", "Comment");
                foreach (DataRow itemDistinct in dtDistinct.Rows)
                {
                    stbStuAnswer.Append("<div class=\"student_answer_box\">");
                    stbStuAnswer.Append("<div class=\"title clearfix\">");
                    stbStuAnswer.AppendFormat("<div class=\"student_name\">{0}的答案<a href='##' data-name=\"remark\" data-content=\"{1}\" id=\"{2}\">批注</a></div>"
                                              , string.IsNullOrEmpty(itemDistinct["TrueName"].ToString()) ? itemDistinct["UserName"] : itemDistinct["TrueName"]
                                              , itemDistinct["Comment"]
                                              , itemDistinct["Student_Id"]);

                    stbStuAnswer.Append("<div class=\"score_name\">得分</div>");
                    stbStuAnswer.Append("</div>");
                    stbStuAnswer.Append("<div class=\"con\">");
                    DataRow[] drScore = dtAnswerScore.Select("Student_Id='" + itemDistinct["Student_Id"] + "'");
                    foreach (DataRow item in drScore)
                    {
                        stbStuAnswer.Append("<div class=\"answer_score clearfix\">");
                        string strStudentAnswer = string.Empty;
                        if (modelTQ.TestQuestions_Type == "selection" || modelTQ.TestQuestions_Type == "clozeTest" || modelTQ.TestQuestions_Type == "truefalse")
                        {
                            strStudentAnswer = item["Student_Answer"].ToString();
                        }
                        else if (modelTQ.TestQuestions_Type == "fill" || modelTQ.TestQuestions_Type == "answers")
                        {
                            strStudentAnswer = Rc.Common.RemotWeb.PostDataToServer(string.Format(fileStudentAnswerUrl, "studentAnswer", item["Student_HomeWorkAnswer_Id"], "txt"), "", Encoding.UTF8, "Get");
                            strStudentAnswer = Rc.Cloud.Web.Common.pfunction.NoHTML(strStudentAnswer);
                            if (string.IsNullOrWhiteSpace(strStudentAnswer))
                            {
                                strStudentAnswer = "&nbsp;&nbsp;";
                            }
                            strStudentAnswer = string.Format("<div>{0}</div>", strStudentAnswer);
                        }
                        if (string.IsNullOrWhiteSpace(strStudentAnswer))
                        {
                            strStudentAnswer = "&nbsp;&nbsp;";
                        }
                        stbStuAnswer.AppendFormat("<div class=\"answer\">{0}</div>", strStudentAnswer);
                        stbStuAnswer.AppendFormat("<div class=\"score\"><input type=\"text\" data-actual-marks=\"{0}\" data-name=\"ScoreTxt\" value=\"{1}\" maxlength=\"3\" id=\"{2}\" tqsId=\"{3}\" /></div>"
                                                  , item["TestQuestions_Score"].ToString().clearLastZero()
                                                  , item["Student_Score"].ToString().clearLastZero()
                                                  , item["Student_HomeWorkAnswer_Id"].ToString()
                                                  , item["TestQuestions_Score_ID"].ToString());
                        stbStuAnswer.Append("</div>");
                    }
                    stbStuAnswer.Append("</div>");
                    stbStuAnswer.Append("</div>");
                }
                #endregion
            }
        }
        /// <summary>
        /// 同步习题集
        /// </summary>
        public void ResSynchroTeachingPlan()
        {
            //生产环境web站点存放文件的主目录
            string strProductPublicUrl      = ConfigurationManager.AppSettings["ProductPublicUrl"].ToString();
            string strFileSyncExecRecord_id = Guid.NewGuid().ToString();
            bool   isCover      = true;//是否覆盖
            string strCondition = string.Format("日期【】;是覆盖:【{0}】", isCover);
            string strbookId    = hid_bookId.Value.Filter();
            string strrtrfId    = hid_rtrfId.Value.Filter();

            if (!string.IsNullOrEmpty(strbookId))
            {
                Model_ResourceFolder modelRF = new BLL_ResourceFolder().GetModel(strbookId);
                if (modelRF != null)
                {
                    strCondition += string.Format(";书本【{0}】【{1}】", modelRF.ResourceFolder_Name, modelRF.ResourceFolder_Id);
                }
            }
            if (!string.IsNullOrEmpty(strrtrfId))
            {
                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(strrtrfId);
                if (modelRTRF != null)
                {
                    strCondition += string.Format(";资源【{0}】【{1}】", modelRTRF.Resource_Name, modelRTRF.ResourceToResourceFolder_Id);
                }
            }

            #region 记录同步开始信息

            Rc.Model.Resources.Model_FileSyncExecRecord model_FileSyncExecRecord = new Rc.Model.Resources.Model_FileSyncExecRecord();
            Rc.BLL.Resources.BLL_FileSyncExecRecord     bll_FileSyncExecRecord   = new Rc.BLL.Resources.BLL_FileSyncExecRecord();
            model_FileSyncExecRecord.FileSyncExecRecord_id        = strFileSyncExecRecord_id;
            model_FileSyncExecRecord.FileSyncExecRecord_Type      = "同步试卷new";
            model_FileSyncExecRecord.FileSyncExecRecord_Remark    = "同步进行中...";
            model_FileSyncExecRecord.FileSyncExecRecord_TimeStart = DateTime.Now;
            model_FileSyncExecRecord.FileSyncExecRecord_Status    = "0";
            model_FileSyncExecRecord.FileSyncExecRecord_Condition = strCondition;
            model_FileSyncExecRecord.createUser = SysUser_ID;
            bll_FileSyncExecRecord.Add(model_FileSyncExecRecord);
            #endregion

            try
            {
                //试卷文件相关数据
                DataTable dtFileTestPaper = GetDtFileTestPaperTestQuestion(strbookId, strrtrfId);
                //试题相关数据
                DataTable dtFileTestPaperScore = GetDtFileTestPaperTestQuestions_Score(strbookId, strrtrfId);

                DataView dataView = dtFileTestPaper.DefaultView;
                // 资源数据
                DataTable dtRTRF = new DataTable();
                if (dtFileTestPaper.Rows.Count > 0)
                {
                    dtRTRF = dataView.ToTable(true, "Book_Id", "ResourceToResourceFolder_Id");
                }
                foreach (DataRow item in dtRTRF.Rows)
                {
                    #region  载文件
                    DataRow[] dvFileTestPaper = dtFileTestPaper.Select(string.Format(" ResourceToResourceFolder_Id='{0}' ", item["ResourceToResourceFolder_Id"]));
                    //题干	BASE64内容,存储目录:testQuestionBody/属性层次目录/试题标识.txt
                    DownLoadFile(dvFileTestPaper, "testQuestionBody", "txt", strProductPublicUrl, strFileSyncExecRecord_id, "题干txt", isCover);
                    //题干 	HTML内容,存储目录:testQuestionBody/属性层次目录/试题标识.htm
                    DownLoadFile(dvFileTestPaper, "testQuestionBody", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "题干htm", isCover);

                    DataRow[] dvFileTestPaperScore = dtFileTestPaperScore.Select(string.Format(" ResourceToResourceFolder_Id='{0}' ", item["ResourceToResourceFolder_Id"]));
                    //	选择题的选项(数组对象)存储目录:testQuestionOption/属性层次目录/试题标识.txt(存储JSION结构到文本文件,一个题只有一个文件)
                    DownLoadFile(dvFileTestPaperScore, "testQuestionOption", "txt", strProductPublicUrl, strFileSyncExecRecord_id, "选择题选项txt", isCover);
                    //	c)	标准答案(数组)存储目录:testQuestionCurrent/属性层次目录/试题标识.txt(存储JSION结构到文本文件,一个题只有一个文件)
                    DownLoadFile(dvFileTestPaperScore, "testQuestionCurrent", "txt", strProductPublicUrl, strFileSyncExecRecord_id, "标准答案txt", isCover);
                    //	解析 	BASE64内容AnalyzeData/属性层次目录/试题标识.txt
                    DownLoadFile(dvFileTestPaperScore, "AnalyzeData", "txt", strProductPublicUrl, strFileSyncExecRecord_id, "解析txt", isCover);
                    //	解析 	HTML内容AnalyzeHtml/属性层次目录/试题标识.htm
                    DownLoadFile(dvFileTestPaperScore, "AnalyzeHtml", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "解析htm", isCover);
                    //	e)	强化训练 		BASE64内容TrainData/属性层次目录/试题标识.txt
                    DownLoadFile(dvFileTestPaperScore, "TrainData", "txt", strProductPublicUrl, strFileSyncExecRecord_id, "强化训练txt", isCover);
                    //	e)	强化训练 		HTML内容TrainHtml/属性层次目录/试题标识.htm
                    DownLoadFile(dvFileTestPaperScore, "TrainHtml", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "强化训练htm", isCover);
                    #endregion

                    #region 更新SyncData
                    string strSqlSyncData = string.Format(@"update SyncData set SyncStatus='3' where TableName='ResourceFolder' and  SyncStatus<>'3' and DataId='{0}';
                        update SyncData set SyncStatus='3' where TableName='ResourceToResourceFolder' and  SyncStatus<>'3' and DataId='{1}'; "
                                                          , item["Book_Id"], item["ResourceToResourceFolder_Id"]);
                    Rc.Common.DBUtility.DbHelperSQL.ExecuteSqlByTime(strSqlSyncData, 60);
                    #endregion
                }


                #region 记录同步结束信息并保存数据
                model_FileSyncExecRecord.FileSyncExecRecord_TimeEnd = DateTime.Now;
                model_FileSyncExecRecord.FileSyncExecRecord_Status  = "1";
                model_FileSyncExecRecord.FileSyncExecRecord_Remark  = "同步已完成";
                bll_FileSyncExecRecord.Update(model_FileSyncExecRecord);
                #endregion
            }
            catch (Exception ex)
            {
                model_FileSyncExecRecord.FileSyncExecRecord_TimeEnd = DateTime.Now;
                model_FileSyncExecRecord.FileSyncExecRecord_Status  = "2";
                model_FileSyncExecRecord.FileSyncExecRecord_Remark  = "同步失败:" + ex.Message.ToString();
                model_FileSyncExecRecord.FileSyncExecRecord_Remark  = ex.Message.ToString();
                bll_FileSyncExecRecord.Update(model_FileSyncExecRecord);
                throw;
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 生成学生作业txt 17-07-17TS
        /// </summary>
        private bool GenerateTestPaperFileForStudent(string tchId, string HomeWork_Id)
        {
            bool flag = false;

            try
            {
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):5开始组织试题");
                string uploadPath        = Server.MapPath("/Upload/Resource/");                     //存储文件基础路径
                string strTestWebSiteUrl = ConfigHelper.GetConfigString("StudentAnswerWebSiteUrl"); //学校局域网地址
                string hosturl           = pfunction.getHostPath();
                ////检测网络是否通畅
                //if (RemotWeb.PostDataToServer(strTestWebSiteUrl + "/AuthApi/index.aspx?key=onlinecheck", "", Encoding.UTF8, "Get") != "ok")
                //{
                //    Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):网络不通畅-" + strTestWebSiteUrl +"访问者URL:"+ hosturl);
                //    flag = false;
                //    return flag;
                //}
                Model_HomeWork modelHW          = new BLL_HomeWork().GetModel(HomeWork_Id);
                string         rtrfId           = modelHW.ResourceToResourceFolder_Id;
                string         strHomeWork_Name = modelHW.HomeWork_Name;
                int            isTimeLimt       = 0;
                int            isTimeLength     = 0;
                bool           isShowAnswer     = false;
                int.TryParse(modelHW.isTimeLimt.ToString(), out isTimeLimt);
                int.TryParse(modelHW.isTimeLength.ToString(), out isTimeLength);
                if (modelHW.IsShowAnswer == 1)
                {
                    isShowAnswer = true;
                }
                string        filePath        = pfunction.ToShortDate(modelHW.CreateTime.ToString()) + "\\" + HomeWork_Id + ".txt";
                string        filePathForTch  = pfunction.ToShortDate(modelHW.CreateTime.ToString()) + "\\" + HomeWork_Id + ".tch.txt";
                List <object> listTQObjForTch = new List <object>();    //老师客户端批改
                List <object> listTQObj       = new List <object>();    //学生客户端答题

                List <object> listTQObjForTchBig = new List <object>(); //老师客户端批改
                List <object> listTQObjBig       = new List <object>(); //学生客户端答题

                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrfId);

                #region 试题
                //试题数据
                string    strSqlTQ = string.Format(@"select  t1.TestQuestions_Id,t1.TestQuestions_Num,t1.TestQuestions_Type,t1.Parent_Id,t1.[type],t1.topicNumber
,T2.Resource_Version,T2.GradeTerm,t2.Subject,t2.ParticularYear,t2.Resource_Class,t2.CreateTime,t2.LessonPlan_Type
FROM TestQuestions t1 inner join ResourceToResourceFolder t2 ON t1.ResourceToResourceFolder_ID=T2.ResourceToResourceFolder_ID 
where  t1.ResourceToResourceFolder_Id='{0}' order by TestQuestions_Num ", rtrfId);
                DataTable dtTQ     = Rc.Common.DBUtility.DbHelperSQL.Query(strSqlTQ).Tables[0];

                //获取这个试卷的所有试题分值
                string strSqlScore = string.Empty;
                strSqlScore = string.Format(@"select  [TestQuestions_Score_ID]
      ,[ResourceToResourceFolder_Id]
      ,[TestQuestions_Id]
      ,[TestCorrect]
      ,[AnalyzeHyperlinkData]
      ,[TrainHyperlinkData]
      ,[TestType]
      ,[ScoreText],[testIndex],[TestType]
,TestQuestions_OrderNum FROM TestQuestions_Score where ResourceToResourceFolder_Id='{0}' order by TestQuestions_OrderNum ", rtrfId);
                DataTable dtTQ_Score = Rc.Common.DBUtility.DbHelperSQL.Query(strSqlScore).Tables[0];

                #region 普通题型 list
                DataRow[] drList = dtTQ.Select("Parent_Id='' ", "TestQuestions_Num");
                foreach (DataRow item in drList)
                {
                    string savePath      = string.Empty;
                    string saveOwnerPath = string.Empty;
                    if (item["Resource_Class"].ToString() == Resource_ClassConst.云资源)
                    {
                        savePath = string.Format("{0}\\{1}\\{2}\\{3}\\", item["ParticularYear"].ToString(), item["GradeTerm"],
                                                 item["Resource_Version"].ToString(), item["Subject"].ToString());
                    }
                    if (item["Resource_Class"].ToString() == Resource_ClassConst.自有资源)
                    {
                        saveOwnerPath = string.Format("{0}\\", pfunction.ConvertToLongDateTime(item["CreateTime"].ToString(), "yyyy-MM-dd"));
                    }
                    DataRow   drTQ_S     = null;
                    DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format("TestQuestions_ID='{0}'", item["TestQuestions_ID"].ToString()), "TestQuestions_OrderNum");

                    #region 试题分数
                    List <object> listTQ_SObjForTch = new List <object>(); //老师客户端批改
                    List <object> listTQ_SObj       = new List <object>(); //学生客户端答题
                    int           intIndex          = 0;
                    for (int j = 0; j < drTQ_Score.Length; j++)
                    {
                        drTQ_S = drTQ_Score[j];
                        string strAnalyzeUrl = string.Empty;
                        string strTrainUrl   = string.Empty;
                        if (!string.IsNullOrEmpty(drTQ_S["AnalyzeHyperlinkData"].ToString()))
                        {
                            strAnalyzeUrl = pfunction.GetAnalyzeTrainUrl(ConfigHelper.GetConfigString("StudentAnswerWebSiteUrl"), drTQ_S["AnalyzeHyperlinkData"].ToString());
                        }
                        if (!string.IsNullOrEmpty(drTQ_S["TrainHyperlinkData"].ToString()))
                        {
                            strTrainUrl = pfunction.GetAnalyzeTrainUrl(ConfigHelper.GetConfigString("StudentAnswerWebSiteUrl"), drTQ_S["TrainHyperlinkData"].ToString());
                        }
                        listTQ_SObj.Add(new
                        {
                            testScoreId = drTQ_S["TestQuestions_Score_ID"].ToString(),
                            testIndex   = drTQ_S["testIndex"].ToString(),
                            analyzeUrl  = strAnalyzeUrl,
                            trainUrl    = strTrainUrl
                        });

                        string strtestCorrectBase64 = string.Empty;
                        string strtestCorrect       = string.Empty;
                        switch (drTQ_Score[j]["TestType"].ToString())
                        {
                        case "selection":
                        case "clozeTest":
                        case "truefalse":
                            strtestCorrect = drTQ_Score[j]["TestCorrect"].ToString();
                            break;
                            //case "fill":
                            //case "answers":
                            //    strtestCorrectBase64 = pfunction.ReadAllText(uploadPath + saveOwnerPath + "testQuestionCurrent\\" + savePath + drTQ_Score[j]["TestQuestions_Score_ID"].ToString() + ".txt");
                            //    break;
                        }
                        listTQ_SObjForTch.Add(new
                        {
                            testScoreId = drTQ_S["TestQuestions_Score_ID"].ToString(),
                            testIndex   = drTQ_S["testIndex"].ToString(),
                            scoreText   = drTQ_Score[j]["ScoreText"].ToString(),
                            testCorrect = strtestCorrect
                        });
                    }
                    #endregion
                    string fileUrl = uploadPath + saveOwnerPath + "{0}\\" + savePath + "{1}.txt";//自有资源 savePath为空,云资源saveOwnerPath为空
                    if (drTQ_S != null)
                    {
                        string strtestQuestionBody = pfunction.ReadAllText(string.Format(fileUrl, "testQuestionBody", item["TestQuestions_Id"].ToString()));
                        string strtextTitle        = pfunction.ReadAllText(string.Format(fileUrl, "textTitle", item["TestQuestions_Id"].ToString()));
                        string strTopicNumber      = string.Empty;
                        if (item["LessonPlan_Type"].ToString() == LessonPlan_TypeConst.组卷)
                        {
                            strTopicNumber = item["topicNumber"].ToString();
                        }
                        listTQObj.Add(new
                        {
                            Testid      = item["TestQuestions_Id"],
                            testType    = item["TestQuestions_Type"],
                            topicNumber = strTopicNumber,
                            docBase64   = strtestQuestionBody,
                            textTitle   = strtextTitle,
                            list        = listTQ_SObj
                        });

                        if (drTQ_S["TestType"].ToString() == "selection" || drTQ_S["TestType"].ToString() == "clozeTest" || drTQ_S["TestType"].ToString() == "truefalse")
                        {
                            strtestQuestionBody = "";
                            strtextTitle        = "";
                        }
                        listTQObjForTch.Add(new
                        {
                            Testid      = item["TestQuestions_Id"],
                            testType    = item["TestQuestions_Type"],
                            topicNumber = strTopicNumber,
                            docBase64   = strtestQuestionBody,
                            textTitle   = strtextTitle,
                            list        = listTQ_SObjForTch
                        });
                    }
                    else
                    {
                        string strtestQuestionBody = pfunction.ReadAllText(string.Format(fileUrl, "testQuestionBody", item["TestQuestions_Id"].ToString()));
                        string strtextTitle        = pfunction.ReadAllText(string.Format(fileUrl, "textTitle", item["TestQuestions_Id"].ToString()));
                        string strTopicNumber      = string.Empty;
                        if (item["LessonPlan_Type"].ToString() == LessonPlan_TypeConst.组卷)
                        {
                            strTopicNumber = item["topicNumber"].ToString();
                        }
                        listTQObj.Add(new
                        {
                            Testid      = item["TestQuestions_Id"],
                            testType    = item["TestQuestions_Type"],
                            topicNumber = strTopicNumber,
                            docBase64   = strtestQuestionBody,
                            textTitle   = strtextTitle,
                            list        = ""
                        });

                        listTQObjForTch.Add(new
                        {
                            Testid      = item["TestQuestions_Id"],
                            testType    = item["TestQuestions_Type"],
                            topicNumber = strTopicNumber,
                            docBase64   = strtestQuestionBody,
                            textTitle   = strtextTitle,
                            list        = listTQ_SObjForTch
                        });
                    }
                }
                #endregion
                #region 综合题型 listBig
                DataRow[] drListBig = dtTQ.Select("Parent_Id='0' ", "TestQuestions_Num");
                foreach (DataRow item in drListBig)
                {
                    List <object> listTQObjForTchBig_Sub = new List <object>();
                    List <object> listTQObjBig_Sub       = new List <object>();
                    DataRow[]     drBig_Sub = dtTQ.Select("Parent_Id='" + item["TestQuestions_Id"] + "'", "TestQuestions_Num");
                    foreach (DataRow itemSub in drBig_Sub)
                    {
                        string savePath      = string.Empty;
                        string saveOwnerPath = string.Empty;
                        if (itemSub["Resource_Class"].ToString() == Resource_ClassConst.云资源)
                        {
                            savePath = string.Format("{0}\\{1}\\{2}\\{3}\\", itemSub["ParticularYear"].ToString(), itemSub["GradeTerm"],
                                                     itemSub["Resource_Version"].ToString(), itemSub["Subject"].ToString());
                        }
                        if (itemSub["Resource_Class"].ToString() == Resource_ClassConst.自有资源)
                        {
                            saveOwnerPath = string.Format("{0}\\", pfunction.ConvertToLongDateTime(itemSub["CreateTime"].ToString(), "yyyy-MM-dd"));
                        }
                        DataRow   drTQ_S     = null;
                        DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format("TestQuestions_ID='{0}'", itemSub["TestQuestions_ID"].ToString()), "TestQuestions_OrderNum");

                        #region 试题分数
                        List <object> listTQ_SObjForTch = new List <object>(); //老师客户端批改 分值,正确答案
                        List <object> listTQ_SObj       = new List <object>(); //学生客户端答题 解析,强化训练
                        int           intIndex          = 0;
                        for (int j = 0; j < drTQ_Score.Length; j++)
                        {
                            drTQ_S = drTQ_Score[j];
                            string strAnalyzeUrl = string.Empty;
                            string strTrainUrl   = string.Empty;
                            if (!string.IsNullOrEmpty(drTQ_S["AnalyzeHyperlinkData"].ToString()))
                            {
                                strAnalyzeUrl = pfunction.GetAnalyzeTrainUrl(ConfigHelper.GetConfigString("StudentAnswerWebSiteUrl"), drTQ_S["AnalyzeHyperlinkData"].ToString());
                            }
                            if (!string.IsNullOrEmpty(drTQ_S["TrainHyperlinkData"].ToString()))
                            {
                                strTrainUrl = pfunction.GetAnalyzeTrainUrl(ConfigHelper.GetConfigString("StudentAnswerWebSiteUrl"), drTQ_S["TrainHyperlinkData"].ToString());
                            }
                            listTQ_SObj.Add(new
                            {
                                testScoreId = drTQ_S["TestQuestions_Score_ID"].ToString(),
                                testIndex   = drTQ_S["testIndex"].ToString(),
                                analyzeUrl  = strAnalyzeUrl,
                                trainUrl    = strTrainUrl
                            });

                            string strtestCorrectBase64 = string.Empty;
                            string strtestCorrect       = string.Empty;
                            switch (drTQ_Score[j]["TestType"].ToString())
                            {
                            case "selection":
                            case "clozeTest":
                            case "truefalse":
                                strtestCorrect = drTQ_Score[j]["TestCorrect"].ToString();
                                break;
                                //case "fill":
                                //case "answers":
                                //    strtestCorrectBase64 = pfunction.ReadAllText(uploadPath + saveOwnerPath + "testQuestionCurrent\\" + savePath + drTQ_Score[j]["TestQuestions_Score_ID"].ToString() + ".txt");
                                //    break;
                            }
                            listTQ_SObjForTch.Add(new
                            {
                                testScoreId = drTQ_S["TestQuestions_Score_ID"].ToString(),
                                testIndex   = drTQ_S["testIndex"].ToString(),
                                scoreText   = drTQ_Score[j]["ScoreText"].ToString(),
                                testCorrect = strtestCorrect
                            });
                        }
                        if (listTQ_SObjForTch.Count == 0)
                        {
                            listTQ_SObjForTch.Add(null);
                        }
                        #endregion
                        string fileUrl = uploadPath + saveOwnerPath + "{0}\\" + savePath + "{1}.txt";//自有资源 savePath为空,云资源saveOwnerPath为空
                        if (drTQ_S != null)
                        {
                            string strtestQuestionBody = pfunction.ReadAllText(string.Format(fileUrl, "testQuestionBody", itemSub["TestQuestions_Id"].ToString()));
                            string strtextTitle        = pfunction.ReadAllText(string.Format(fileUrl, "textTitle", itemSub["TestQuestions_Id"].ToString()));
                            string strTopicNumber      = string.Empty;
                            if (item["LessonPlan_Type"].ToString() == LessonPlan_TypeConst.组卷)
                            {
                                strTopicNumber = itemSub["topicNumber"].ToString();
                            }
                            listTQObjBig_Sub.Add(new
                            {
                                Testid      = itemSub["TestQuestions_Id"],
                                testType    = itemSub["TestQuestions_Type"],
                                topicNumber = strTopicNumber,
                                docBase64   = strtestQuestionBody,
                                textTitle   = strtextTitle,
                                list        = listTQ_SObj
                            });

                            if (drTQ_S["TestType"].ToString() == "selection" || drTQ_S["TestType"].ToString() == "clozeTest" || drTQ_S["TestType"].ToString() == "truefalse")
                            {
                                strtestQuestionBody = "";
                                strtextTitle        = "";
                            }
                            listTQObjForTchBig_Sub.Add(new
                            {
                                Testid      = itemSub["TestQuestions_Id"],
                                testType    = itemSub["TestQuestions_Type"],
                                topicNumber = strTopicNumber,
                                docBase64   = strtestQuestionBody,
                                textTitle   = strtextTitle,
                                list        = listTQ_SObjForTch
                            });
                        }
                        else
                        {
                            string strtestQuestionBody = pfunction.ReadAllText(string.Format(fileUrl, "testQuestionBody", itemSub["TestQuestions_Id"].ToString()));
                            string strtextTitle        = pfunction.ReadAllText(string.Format(fileUrl, "textTitle", itemSub["TestQuestions_Id"].ToString()));
                            string strTopicNumber      = string.Empty;
                            if (item["LessonPlan_Type"].ToString() == LessonPlan_TypeConst.组卷)
                            {
                                strTopicNumber = itemSub["topicNumber"].ToString();
                            }
                            listTQObjBig_Sub.Add(new
                            {
                                Testid      = itemSub["TestQuestions_Id"],
                                testType    = itemSub["TestQuestions_Type"],
                                topicNumber = strTopicNumber,
                                docBase64   = strtestQuestionBody,
                                textTitle   = strtextTitle,
                                list        = ""
                            });

                            listTQObjForTchBig_Sub.Add(new
                            {
                                Testid      = itemSub["TestQuestions_Id"],
                                testType    = itemSub["TestQuestions_Type"],
                                topicNumber = strTopicNumber,
                                docBase64   = strtestQuestionBody,
                                textTitle   = strtextTitle,
                                list        = listTQ_SObjForTch
                            });
                        }
                    }
                    string savePathBig      = string.Empty;
                    string saveOwnerPathBig = string.Empty;
                    if (item["Resource_Class"].ToString() == Resource_ClassConst.云资源)
                    {
                        savePathBig = string.Format("{0}\\{1}\\{2}\\{3}\\", item["ParticularYear"].ToString(), item["GradeTerm"],
                                                    item["Resource_Version"].ToString(), item["Subject"].ToString());
                    }
                    if (item["Resource_Class"].ToString() == Resource_ClassConst.自有资源)
                    {
                        saveOwnerPathBig = string.Format("{0}\\", pfunction.ConvertToLongDateTime(item["CreateTime"].ToString(), "yyyy-MM-dd"));
                    }
                    string fileUrlBig   = uploadPath + saveOwnerPathBig + "{0}\\" + savePathBig + "{1}.{2}";//自有资源 savePath为空,云资源saveOwnerPath为空
                    string strdocBase64 = pfunction.ReadAllText(string.Format(fileUrlBig, "testQuestionBody", item["TestQuestions_Id"].ToString(), "txt"));
                    string strdocHtml   = pfunction.ReadAllText(string.Format(fileUrlBig, "testQuestionBody", item["TestQuestions_Id"].ToString(), "htm"));
                    string textTitle    = pfunction.ReadAllText(string.Format(fileUrlBig, "textTitle", item["TestQuestions_Id"].ToString(), "txt"));
                    listTQObjBig.Add(new
                    {
                        docBase64   = strdocBase64,
                        docHtml     = strdocHtml,
                        textTitle   = textTitle,
                        topicNumber = (item["LessonPlan_Type"].ToString() == LessonPlan_TypeConst.组卷) ? item["topicNumber"].ToString() : "",
                        list        = listTQObjBig_Sub,
                        type        = item["type"].ToString()
                    });
                    if (drBig_Sub.Length > 0) //没有子级试题,不加载节点
                    {
                        listTQObjForTchBig.Add(new
                        {
                            docBase64 = strdocBase64,
                            docHtml   = strdocHtml,
                            textTitle = textTitle,
                            list      = listTQObjForTchBig_Sub,
                            type      = item["type"].ToString()
                        });
                    }
                }
                #endregion

                #endregion
                string strJson = string.Empty;
                strJson = JsonConvert.SerializeObject(new
                {
                    status                     = true,
                    errorMsg                   = "",
                    errorCode                  = "",
                    paperHeaderDoc             = GetPaperHeaderDoc(rtrfId),
                    testPaperName              = "",
                    isTimeLimt                 = isTimeLimt,
                    isTimeLength               = isTimeLength,
                    sysTime                    = DateTime.Now.ToString(),
                    isShowAnswerAfterSubmiting = isShowAnswer,
                    list    = listTQObj,
                    listBig = listTQObjBig
                });
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):5结束组织试题");
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):6开始写入文件");
                pfunction.WriteToFile(uploadPath + "studentPaper\\" + filePath, strJson, true);

                string strJsonForTch = string.Empty;
                strJsonForTch = JsonConvert.SerializeObject(new
                {
                    list    = listTQObjForTch,
                    listBig = listTQObjForTchBig
                });
                pfunction.WriteToFile(uploadPath + "studentPaper\\" + filePathForTch, strJsonForTch, true);
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):6结束写入文件");
                flag = true;
                #region 判断作业文件是否存在,不存在则返回false
                if (!File.Exists(uploadPath + "studentPaper\\" + filePath) ||
                    !File.Exists(uploadPath + "studentPaper\\" + filePathForTch))
                {
                    flag = false;
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):6作业文件不存在,布置失败");
                }
                #endregion
            }
            catch (Exception ex)
            {
                flag = false;
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(tchId, "", "布置作业(学校服务器):异常,布置失败");
                Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", "", "布置作业失败(学校服务器):" + ex.Message.ToString());
            }
            return(flag);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 同步教案new
        /// </summary>
        public void ResSynchroTeachingPlan()
        {
            //生产环境web站点存放文件的主目录
            string strProductPublicUrl      = ConfigurationManager.AppSettings["ProductPublicUrl"].ToString();
            string strFileSyncExecRecord_id = Guid.NewGuid().ToString();
            bool   isCover      = true;//是否覆盖
            string strCondition = string.Format("日期【】;是覆盖:【{0}】", isCover);
            string strbookId    = hid_bookId.Value.Filter();
            string strrtrfId    = hid_rtrfId.Value.Filter();

            if (!string.IsNullOrEmpty(strbookId))
            {
                Model_ResourceFolder modelRF = new BLL_ResourceFolder().GetModel(strbookId);
                if (modelRF != null)
                {
                    strCondition += string.Format(";书本【{0}】【{1}】", modelRF.ResourceFolder_Name, modelRF.ResourceFolder_Id);
                }
            }
            if (!string.IsNullOrEmpty(strrtrfId))
            {
                Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(strrtrfId);
                if (modelRTRF != null)
                {
                    strCondition += string.Format(";资源【{0}】【{1}】", modelRTRF.Resource_Name, modelRTRF.ResourceToResourceFolder_Id);
                }
            }

            #region 记录同步开始信息
            Rc.Model.Resources.Model_FileSyncExecRecord model_FileSyncExecRecord = new Rc.Model.Resources.Model_FileSyncExecRecord();
            Rc.BLL.Resources.BLL_FileSyncExecRecord     bll_FileSyncExecRecord   = new Rc.BLL.Resources.BLL_FileSyncExecRecord();
            model_FileSyncExecRecord.FileSyncExecRecord_id        = strFileSyncExecRecord_id;
            model_FileSyncExecRecord.FileSyncExecRecord_Type      = "同步教案new";
            model_FileSyncExecRecord.FileSyncExecRecord_Remark    = "正在同步...";
            model_FileSyncExecRecord.FileSyncExecRecord_TimeStart = DateTime.Now;
            model_FileSyncExecRecord.FileSyncExecRecord_Status    = "0";
            model_FileSyncExecRecord.createUser = SysUser_ID;
            model_FileSyncExecRecord.FileSyncExecRecord_Condition = strCondition;
            bll_FileSyncExecRecord.Add(model_FileSyncExecRecord);
            #endregion

            try
            {
                //教案文件,htm文件相关数据
                DataTable dtFilePlan = GetDtFilePlan(strbookId, strrtrfId);
                //教案预览图片文件相关数据
                DataTable dtFilePlanView = GetDtFilePlanView(strbookId, strrtrfId);

                DataView dataView = dtFilePlan.DefaultView;
                // 资源数据
                DataTable dtRTRF = new DataTable();
                if (dtFilePlan.Rows.Count > 0)
                {
                    dtRTRF = dataView.ToTable(true, "Book_Id", "ResourceToResourceFolder_Id");
                }

                foreach (DataRow item in dtRTRF.Rows)
                {
                    #region  载文件
                    //教案SW+thm
                    DataRow[] drSWdsc = dtFilePlan.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                        , Resource_TypeConst.ScienceWord类型文件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drSWdsc, "swDocument", "dsc", strProductPublicUrl, strFileSyncExecRecord_id, "教案SWdsc", isCover);
                    DownLoadFile(drSWdsc, "swDocument", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "教案SWdsc", isCover);
                    //教案class+thm
                    DataRow[] drClass = dtFilePlan.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                        , Resource_TypeConst.class类型文件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drClass, "classDocument", "class", strProductPublicUrl, strFileSyncExecRecord_id, "教案class", isCover);
                    DownLoadFile(drClass, "classDocument", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "教案class", isCover);
                    //微课class+thm
                    DataRow[] drMicroClass = dtFilePlan.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                             , Resource_TypeConst.class类型微课件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drMicroClass, "microClassDocument", "class", strProductPublicUrl, strFileSyncExecRecord_id, "微课class", isCover);
                    DownLoadFile(drMicroClass, "microClassDocument", "htm", strProductPublicUrl, strFileSyncExecRecord_id, "微课class", isCover);


                    //教案SW+预览图片
                    DataRow[] drSWdscView = dtFilePlanView.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                                , Resource_TypeConst.ScienceWord类型文件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drSWdscView, "swView", "jpg", strProductPublicUrl, strFileSyncExecRecord_id, "教案SW预览图片", isCover);
                    //教案Class+预览图片
                    DataRow[] drClassView = dtFilePlanView.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                                , Resource_TypeConst.class类型文件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drClassView, "classView", "jpg", strProductPublicUrl, strFileSyncExecRecord_id, "教案Class预览图片", isCover);
                    //微课Class+预览图片
                    DataRow[] drMicroClassView = dtFilePlanView.Select(string.Format(" Resource_Type='{0}' and ResourceToResourceFolder_Id='{1}' "
                                                                                     , Resource_TypeConst.class类型微课件, item["ResourceToResourceFolder_Id"]));
                    DownLoadFile(drMicroClassView, "microClassView", "jpg", strProductPublicUrl, strFileSyncExecRecord_id, "微课Class预览图片", isCover);
                    #endregion

                    #region 更新SyncData
                    string strSqlSyncData = string.Format(@"update SyncData set SyncStatus='3' where TableName='ResourceFolder' and  SyncStatus<>'3' and DataId='{0}';
                        update SyncData set SyncStatus='3' where TableName='ResourceToResourceFolder' and  SyncStatus<>'3' and DataId='{1}'; "
                                                          , item["Book_Id"], item["ResourceToResourceFolder_Id"]);
                    Rc.Common.DBUtility.DbHelperSQL.ExecuteSqlByTime(strSqlSyncData, 60);
                    #endregion
                }



                #region 记录同步结束信息并保存数据
                model_FileSyncExecRecord.FileSyncExecRecord_TimeEnd = DateTime.Now;
                model_FileSyncExecRecord.FileSyncExecRecord_Remark  = "同步成功完成";
                model_FileSyncExecRecord.FileSyncExecRecord_Status  = "1";

                bll_FileSyncExecRecord.Update(model_FileSyncExecRecord);
                #endregion
            }
            catch (Exception ex)
            {
                model_FileSyncExecRecord.FileSyncExecRecord_TimeEnd = DateTime.Now;
                model_FileSyncExecRecord.FileSyncExecRecord_Status  = "2";
                model_FileSyncExecRecord.FileSyncExecRecord_Remark  = "同步失败:" + ex.Message.ToString();
                bll_FileSyncExecRecord.Update(model_FileSyncExecRecord);
            }
        }
Ejemplo n.º 19
0
        protected void btnOn_Click(object sender, EventArgs e)
        {
            try
            {
                BLL_FileSyncRecordFail fsrfbll = new BLL_FileSyncRecordFail();
                fsrfbll.DeleteClass(" Resource_Type='df94a052-8cdb-4e49-ae1d-635fe129c89a'");
                List <Rc.Model.Resources.Model_ResourceToResourceFolder> rtrflist = new List <Model_ResourceToResourceFolder>();
                string StrWhere   = string.Empty;
                string StartTime  = txtStartTime.Text;
                string EndTime    = txtEndTiem.Text;
                string uploadPath = "\\Upload\\Resource\\";
                string filePath   = string.Empty;
                string imgPath    = string.Empty;
                string savePath   = string.Empty;
                string StrText    = string.Empty;
                StrWhere = " Resource_Class='" + Resource_ClassConst.云资源 + "'  ";
                if (!string.IsNullOrEmpty(StartTime))
                {
                    StrWhere += " and  CreateTime >= '" + StartTime.Filter() + "'";
                }
                if (!string.IsNullOrEmpty(EndTime))
                {
                    StrWhere += " and CreateTime <= '" + EndTime.Filter() + "'";
                }
                if (!string.IsNullOrEmpty(hidtxtBook.Value))
                {
                    StrWhere += " and Book_ID='" + hidtxtBook.Value + "'";
                }
                StrWhere += " and Resource_Type='df94a052-8cdb-4e49-ae1d-635fe129c89a'";

                BLL_ResourceToResourceFolder rtrfbll = new BLL_ResourceToResourceFolder();
                rtrflist = rtrfbll.GetModelList(StrWhere);

                if (rtrflist != null)
                {
                    string SqlTemp = "delete from FileSyncRecordFail where Resource_Type='df94a052-8cdb-4e49-ae1d-635fe129c89a'";
                    Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(SqlTemp);
                    foreach (var item in rtrflist)
                    {
                        savePath = string.Format("{0}\\{1}\\{2}\\{3}\\", item.ParticularYear, item.GradeTerm,
                                                 item.Resource_Version, item.Subject);
                        #region 试卷

                        BLL_TestQuestions          tqbll  = new BLL_TestQuestions();
                        List <Model_TestQuestions> tqlist = new List <Model_TestQuestions>();
                        tqlist = tqbll.GetModelList("ResourceToResourceFolder_Id='" + item.ResourceToResourceFolder_Id + "'");
                        if (tqlist != null)
                        {
                            foreach (var tqitem in tqlist)
                            {
                                #region 题干testQuestionBody
                                if (!File.Exists(Server.MapPath(uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".htm")))
                                {
                                    InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".htm"), item.Resource_Type, "题干htm");
                                }
                                if (!File.Exists(Server.MapPath(uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".txt")))
                                {
                                    InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionBody\\" + savePath + tqitem.TestQuestions_Id + ".txt"), item.Resource_Type, "题干txt");
                                }
                                #endregion

                                #region 分值表
                                BLL_TestQuestions_Score tqsbll = new BLL_TestQuestions_Score();
                                DataTable tqsdt = tqsbll.GetList("TestQuestions_Id='" + tqitem.TestQuestions_Id + "'").Tables[0];
                                if (tqsdt.Rows.Count > 0)
                                {
                                    for (int k = 0; k < tqsdt.Rows.Count; k++)
                                    {
                                        #region  项testQuestionOption
                                        if ((tqsdt.Rows[k]["TestType"].ToString() == "selection" || tqsdt.Rows[k]["TestType"].ToString() == "clozeTest") && !File.Exists(Server.MapPath(uploadPath + "testQuestionOption\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionOption\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "选项txt");
                                        }
                                        #endregion
                                        #region 答案testQuestionCurrent
                                        if ((tqsdt.Rows[k]["TestType"].ToString() == "fill" || tqsdt.Rows[k]["TestType"].ToString() == "answers") && !File.Exists(Server.MapPath(uploadPath + "testQuestionCurrent\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "testQuestionCurrent\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "答案txt");
                                        }
                                        #endregion
                                        #region 解析AnalyzeData/AnalyzeHtml
                                        if (!string.IsNullOrEmpty(tqsdt.Rows[k]["AnalyzeHyperlinkData"].ToString()) && !File.Exists(Server.MapPath(uploadPath + "AnalyzeData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "AnalyzeData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "解析txt");
                                        }
                                        if (!string.IsNullOrEmpty(tqsdt.Rows[k]["AnalyzeHyperlinkData"].ToString()) && !File.Exists(Server.MapPath(uploadPath + "AnalyzeHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "AnalyzeHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm"), item.Resource_Type, "解析htm");
                                        }
                                        #endregion
                                        #region 强化训练TrainData/TrainHtml
                                        if (!string.IsNullOrEmpty(tqsdt.Rows[k]["TrainHyperlinkData"].ToString()) && !File.Exists(Server.MapPath(uploadPath + "TrainData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "TrainData\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".txt"), item.Resource_Type, "强化训练txt");
                                        }
                                        if (!string.IsNullOrEmpty(tqsdt.Rows[k]["TrainHyperlinkData"].ToString()) && !File.Exists(Server.MapPath(uploadPath + "TrainHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm")))
                                        {
                                            InsertFail(item.ResourceToResourceFolder_Id, item.Book_ID, (uploadPath + "TrainHtml\\" + savePath + tqsdt.Rows[k]["TestQuestions_Score_ID"] + ".htm"), item.Resource_Type, "强化训练htm");
                                        }
                                        #endregion
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                    #endregion
                }

                Response.Redirect(Request.Url.ToString());
            }
            catch (Exception ex)
            {
                new BLL_clsAuth().AddLogErrorFromBS("检测同步完成情况失败:", string.Format("类:{0},方法{1},错误信息:{2}", ex.TargetSite.DeclaringType.ToString()
                                                                                 , ex.TargetSite.Name.ToString(), ex.Message));
                Response.Redirect(Request.Url.ToString());
            }
        }
        public void SubmitStudentAnswer()
        {
            string StrSql = string.Empty;

            if (string.IsNullOrEmpty(SchoolId))
            {
                StrSql = @"select hw.HomeWork_Id,hw.CreateTime,shw.Student_HomeWork_Id,shw.HomeWork_Id,shw.Student_Id,shw.CreateTime,shwSubmit.Student_HomeWork_Status,shwSubmit.OpenTime,shwSubmit.StudentIP,shwSubmit.Student_Answer_Time 
from Student_HomeWork shw
inner join Student_HomeWork_Submit shwSubmit on shwSubmit.Student_HomeWork_Id=shw.Student_HomeWork_Id and shwSubmit.Student_HomeWork_Status='2'
inner join HomeWork hw on hw.HomeWork_Id=shw.HomeWork_Id
order by hw.CreateTime";
            }
            else
            {
                StrSql = string.Format(@"select hw.HomeWork_Id,hw.CreateTime,shw.Student_HomeWork_Id,shw.HomeWork_Id,shw.Student_Id,shw.CreateTime,shwSubmit.Student_HomeWork_Status,shwSubmit.OpenTime,shwSubmit.StudentIP,shwSubmit.Student_Answer_Time 
from Student_HomeWork shw
inner join Student_HomeWork_Submit shwSubmit on shwSubmit.Student_HomeWork_Id=shw.Student_HomeWork_Id and shwSubmit.Student_HomeWork_Status='2'
inner join HomeWork hw on hw.HomeWork_Id=shw.HomeWork_Id
where shw.Student_Id in(select UserId from VW_UserOnClassGradeSchool vw where vw.SchoolId='{0}')
order by hw.CreateTime", SchoolId);
            }

            DataTable dtShw = Rc.Common.DBUtility.DbHelperSQL.Query(StrSql).Tables[0];

            if (dtShw.Rows.Count == 0)
            {
                #region 记录执行结束信息并保存数据
                model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
                model_FileSyncExecRecordDetail.Detail_Status  = "1";
                model_FileSyncExecRecordDetail.Detail_Remark  = "执行完成.没有待执行数据";
                bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
                #endregion
                return;
            }

            try
            {
                #region 自动提交学生答案
                int    sucNum  = 0;
                int    failNum = 0;
                string resInfo = string.Empty;
                foreach (DataRow itemShw in dtShw.Rows)
                {
                    try
                    {
                        #region 提交单份学生作业
                        string         savePath   = string.Empty;
                        Model_HomeWork modelHW    = new BLL_HomeWork().GetModel(itemShw["HomeWork_Id"].ToString());
                        string         homeWorkId = modelHW.HomeWork_Id;
                        string         rtrfId     = modelHW.ResourceToResourceFolder_Id;
                        string         resourceId = itemShw["Student_HomeWork_Id"].ToString(); //学生作业ID
                        string         userId     = itemShw["Student_Id"].ToString();          //学生ID
                        Model_ResourceToResourceFolder modelRTRFolder = new BLL_ResourceToResourceFolder().GetModel(rtrfId);
                        string filePath = pfunction.ConvertToLongDateTime(itemShw["CreateTime"].ToString(), "yyyy-MM-dd") + "\\" + itemShw["HomeWork_Id"] + "\\" + itemShw["Student_HomeWork_Id"].ToString() + ".txt";

                        if (File.Exists(Server.MapPath(uploadAnswerPath) + filePath))
                        {
                            resInfo = File.ReadAllText(Server.MapPath(uploadAnswerPath) + filePath);
                            Rc.Interface.testPaperAnswerSubmitModel resModel = Newtonsoft.Json.JsonConvert.DeserializeObject <Rc.Interface.testPaperAnswerSubmitModel>(resInfo);

                            Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("开始自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit"));
                            #region 学生作业表
                            Model_Student_HomeWork_Submit modelSHWSubmit = new Model_Student_HomeWork_Submit();
                            modelSHWSubmit = new BLL_Student_HomeWork_Submit().GetModel(itemShw["Student_HomeWork_Id"].ToString());
                            modelSHWSubmit.Student_HomeWork_Status = 1;
                            #endregion
                            #region 学生作业答案表
                            if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                            {
                                savePath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\"
                                                         , pfunction.ToShortDate(modelHW.CreateTime.ToString())//作业布置时间
                                                         , modelRTRFolder.ParticularYear, modelRTRFolder.GradeTerm
                                                         , modelRTRFolder.Resource_Version, modelRTRFolder.Subject);
                            }
                            if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源)
                            {
                                savePath = string.Format("{0}\\"
                                                         , pfunction.ToShortDate(modelHW.CreateTime.ToString()));//作业布置时间);
                            }

                            //获取这个试卷的所有试题分值
                            string strSqlScore = string.Empty;
                            strSqlScore = string.Format(@"select [TestQuestions_Score_ID],TestQuestions_ID ,TestQuestions_Score,TestQuestions_OrderNum,TestType
 FROM TestQuestions_Score where ResourceToResourceFolder_Id='{0}'  ", rtrfId);
                            DataTable dtTQ_Score = Rc.Common.DBUtility.DbHelperSQL.Query(strSqlScore).Tables[0];

                            List <Model_Student_HomeWorkAnswer>         listSHWA = new List <Model_Student_HomeWorkAnswer>();
                            List <Rc.Interface.TestPaperAnswerModel>    listTestPaperAnswerModel = resModel.answerJson; //普通题型
                            List <Rc.Interface.TestPaperAnswerModelBig> TestPaperAnswerModelBig  = resModel.listBig;    //综合题型
                            #region 普通题型 list
                            int num = 0;
                            if (listTestPaperAnswerModel != null)
                            {
                                foreach (var item in listTestPaperAnswerModel)
                                {
                                    if (item != null && item.list != null)
                                    {
                                        num++;
                                        int detailNum = 0;
                                        foreach (var itemSub in item.list)
                                        {
                                            if (itemSub != null)
                                            {
                                                detailNum++;
                                                DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format(" TestQuestions_ID='{0}'  and TestQuestions_OrderNum={1} ", item.Testid, detailNum));
                                                if (drTQ_Score != null && drTQ_Score.Length > 0)
                                                {
                                                    #region 学生答题表
                                                    Model_Student_HomeWorkAnswer modelSHWA = new Model_Student_HomeWorkAnswer();
                                                    modelSHWA.TestQuestions_Id = item.Testid;
                                                    string student_HomeWorkAnswer_Id = Guid.NewGuid().ToString();
                                                    modelSHWA.TestQuestions_Score_ID    = drTQ_Score[0]["TestQuestions_Score_ID"].ToString();
                                                    modelSHWA.Student_HomeWorkAnswer_Id = student_HomeWorkAnswer_Id;
                                                    modelSHWA.Student_HomeWork_Id       = resourceId;
                                                    modelSHWA.Student_Id                    = userId;
                                                    modelSHWA.HomeWork_Id                   = homeWorkId;
                                                    modelSHWA.TestQuestions_Num             = num;
                                                    modelSHWA.TestQuestions_Detail_OrderNum = detailNum;

                                                    if (itemSub.isHTML == "F")//是否以HTML提交 F: 文本提交; T: HTML提交(选择题,文本提交, 其余均为HTML提交)
                                                    {
                                                        modelSHWA.Student_Answer = itemSub.answerChooses;
                                                    }
                                                    else if (itemSub.isHTML == "T")//HTML提交
                                                    {
                                                        Model_TestQuestions modelTQ = new BLL_TestQuestions().GetModel(item.Testid);
                                                        if (modelTQ.TestQuestions_Type == "truefalse")//判断题答案保存到数据库
                                                        {
                                                            modelSHWA.Student_Answer = itemSub.answerHTML;
                                                        }
                                                        else
                                                        {
                                                            #region 学生答案 保存文件
                                                            if (!String.IsNullOrEmpty(itemSub.answerHTML))
                                                            {
                                                                pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true);
                                                            }
                                                            if (!String.IsNullOrEmpty(itemSub.answerImageBase64))
                                                            {
                                                                pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true);
                                                            }
                                                            if (!String.IsNullOrEmpty(itemSub.answerDocBase64))
                                                            {
                                                                pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true);
                                                            }
                                                            #endregion
                                                        }
                                                    }
                                                    else //默认存HTML
                                                    {
                                                        #region 学生答案 保存文件
                                                        if (!String.IsNullOrEmpty(itemSub.answerHTML))
                                                        {
                                                            pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true);
                                                        }
                                                        if (!String.IsNullOrEmpty(itemSub.answerImageBase64))
                                                        {
                                                            pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true);
                                                        }
                                                        if (!String.IsNullOrEmpty(itemSub.answerDocBase64))
                                                        {
                                                            pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true);
                                                        }
                                                        #endregion
                                                    }
                                                    //写入客户端的判卷
                                                    modelSHWA.Student_Score = 0;//学生得分默认值(NULL的话统计的时候会出现数据不正确)
                                                    if (itemSub.isRight == "true")
                                                    {
                                                        modelSHWA.Student_Answer_Status = "right";
                                                        decimal temp_decimal = 0;
                                                        decimal.TryParse(drTQ_Score[0]["TestQuestions_Score"].ToString(), out temp_decimal);
                                                        modelSHWA.Student_Score = temp_decimal;
                                                        modelSHWA.isRead        = 1;
                                                    }
                                                    else if (itemSub.isRight == "false")
                                                    {
                                                        modelSHWA.Student_Answer_Status = "wrong";
                                                        modelSHWA.isRead = 1;
                                                    }
                                                    else
                                                    {
                                                        modelSHWA.Student_Answer_Status = "unknown";
                                                        modelSHWA.isRead = 0;
                                                    }
                                                    modelSHWA.CreateTime = DateTime.Now;
                                                    string strTestQuestions_NumStr = item.topicNumber.Filter();
                                                    if (!string.IsNullOrEmpty(strTestQuestions_NumStr))
                                                    {
                                                        if (strTestQuestions_NumStr.Length >= 10)
                                                        {
                                                            strTestQuestions_NumStr = strTestQuestions_NumStr.Substring(0, 10);
                                                        }
                                                    }
                                                    modelSHWA.TestQuestions_NumStr = strTestQuestions_NumStr;//item.topicNumber
                                                    listSHWA.Add(modelSHWA);
                                                    #endregion
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                            #region 综合题型 listBig
                            if (TestPaperAnswerModelBig != null)
                            {
                                num = 0;
                                foreach (var itemBig in TestPaperAnswerModelBig)
                                {
                                    if (itemBig != null && itemBig.list != null)
                                    {
                                        foreach (var item in itemBig.list)
                                        {
                                            if (item != null && item.list != null)
                                            {
                                                num++;
                                                int detailNum = 0;
                                                foreach (var itemSub in item.list)
                                                {
                                                    if (itemSub != null)
                                                    {
                                                        detailNum++;
                                                        DataRow[] drTQ_Score = dtTQ_Score.Select(string.Format(" TestQuestions_ID='{0}'  and TestQuestions_OrderNum={1} ", item.Testid, detailNum));
                                                        if (drTQ_Score != null && drTQ_Score.Length > 0)
                                                        {
                                                            #region 学生答题表
                                                            Model_Student_HomeWorkAnswer modelSHWA = new Model_Student_HomeWorkAnswer();
                                                            modelSHWA.TestQuestions_Id = item.Testid;
                                                            string student_HomeWorkAnswer_Id = Guid.NewGuid().ToString();
                                                            modelSHWA.TestQuestions_Score_ID    = drTQ_Score[0]["TestQuestions_Score_ID"].ToString();
                                                            modelSHWA.Student_HomeWorkAnswer_Id = student_HomeWorkAnswer_Id;
                                                            modelSHWA.Student_HomeWork_Id       = resourceId;
                                                            modelSHWA.Student_Id                    = userId;
                                                            modelSHWA.HomeWork_Id                   = homeWorkId;
                                                            modelSHWA.TestQuestions_Num             = num;
                                                            modelSHWA.TestQuestions_Detail_OrderNum = detailNum;

                                                            //if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.云资源)
                                                            //{
                                                            //    savePath = string.Format("{0}\\{1}\\{2}\\{3}\\{4}\\"
                                                            //       , pfunction.ToShortDate(modelHW.CreateTime.ToString())//作业布置时间
                                                            //       , modelRTRFolder.ParticularYear, modelRTRFolder.GradeTerm
                                                            //       , modelRTRFolder.Resource_Version, modelRTRFolder.Subject);
                                                            //}
                                                            //if (modelRTRFolder.Resource_Class == Rc.Common.Config.Resource_ClassConst.自有资源)
                                                            //{
                                                            //    savePath = string.Format("{0}\\"
                                                            //        , pfunction.ToShortDate(modelHW.CreateTime.ToString()));//作业布置时间);
                                                            //}
                                                            if (itemSub.isHTML == "F")//是否以HTML提交 F: 文本提交; T: HTML提交(选择题,文本提交, 其余均为HTML提交)
                                                            {
                                                                modelSHWA.Student_Answer = itemSub.answerChooses;
                                                            }
                                                            else if (itemSub.isHTML == "T")//HTML提交
                                                            {
                                                                Model_TestQuestions modelTQ = new BLL_TestQuestions().GetModel(item.Testid);
                                                                if (modelTQ.TestQuestions_Type == "truefalse")//判断题答案保存到数据库
                                                                {
                                                                    modelSHWA.Student_Answer = itemSub.answerHTML;
                                                                }
                                                                else
                                                                {
                                                                    #region 学生答案 保存文件
                                                                    if (!String.IsNullOrEmpty(itemSub.answerHTML))
                                                                    {
                                                                        pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true);
                                                                    }
                                                                    if (!String.IsNullOrEmpty(itemSub.answerImageBase64))
                                                                    {
                                                                        pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true);
                                                                    }
                                                                    if (!String.IsNullOrEmpty(itemSub.answerDocBase64))
                                                                    {
                                                                        pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true);
                                                                    }
                                                                    #endregion
                                                                }
                                                            }
                                                            else //默认存HTML
                                                            {
                                                                #region 学生答案 保存文件
                                                                if (!String.IsNullOrEmpty(itemSub.answerHTML))
                                                                {
                                                                    pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerHTML, true);
                                                                }
                                                                if (!String.IsNullOrEmpty(itemSub.answerImageBase64))
                                                                {
                                                                    pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.i.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerImageBase64, true);
                                                                }
                                                                if (!String.IsNullOrEmpty(itemSub.answerDocBase64))
                                                                {
                                                                    pfunction.WriteToFile(string.Format("{0}studentAnswer\\{1}{2}.d.txt", uploadPath, savePath, student_HomeWorkAnswer_Id), itemSub.answerDocBase64, true);
                                                                }
                                                                #endregion
                                                            }
                                                            //写入客户端的判卷
                                                            modelSHWA.Student_Score = 0;//学生得分默认值(NULL的话统计的时候会出现数据不正确)
                                                            if (itemSub.isRight == "true")
                                                            {
                                                                modelSHWA.Student_Answer_Status = "right";
                                                                decimal temp_decimal = 0;
                                                                decimal.TryParse(drTQ_Score[0]["TestQuestions_Score"].ToString(), out temp_decimal);
                                                                modelSHWA.Student_Score = temp_decimal;
                                                                modelSHWA.isRead        = 1;
                                                            }
                                                            else if (itemSub.isRight == "false")
                                                            {
                                                                modelSHWA.Student_Answer_Status = "wrong";
                                                                modelSHWA.isRead = 1;
                                                            }
                                                            else
                                                            {
                                                                modelSHWA.Student_Answer_Status = "unknown";
                                                                modelSHWA.isRead = 0;
                                                            }
                                                            modelSHWA.CreateTime = DateTime.Now;
                                                            string strTestQuestions_NumStr = item.topicNumber.Filter();
                                                            if (!string.IsNullOrEmpty(strTestQuestions_NumStr))
                                                            {
                                                                if (strTestQuestions_NumStr.Length >= 10)
                                                                {
                                                                    strTestQuestions_NumStr = strTestQuestions_NumStr.Substring(0, 10);
                                                                }
                                                            }
                                                            modelSHWA.TestQuestions_NumStr = strTestQuestions_NumStr;//item.topicNumber
                                                            listSHWA.Add(modelSHWA);
                                                            #endregion
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                            #endregion

                            if (new BLL_Student_HomeWorkAnswer().StudentAnswerSubmit(modelSHWSubmit, listSHWA) > 0)
                            {
                                sucNum++;
                                #region 保存学生答题JSON串
                                //重置answerHTML为空,保存分值
                                List <Model_Student_HomeWorkAnswer> listStuScore = new BLL_Student_HomeWorkAnswer().GetModelList("Student_HomeWork_Id='" + resourceId + "'");
                                #region 普通题型 list
                                if (resModel.answerJson != null)
                                {
                                    foreach (var item in resModel.answerJson)
                                    {
                                        if (item != null && item.list != null)
                                        {
                                            int sNum = 0;
                                            foreach (var itemTQ_S in item.list)
                                            {
                                                if (itemTQ_S != null)
                                                {
                                                    itemTQ_S.answerHTML = "";
                                                    sNum++;
                                                    List <Model_Student_HomeWorkAnswer> listStuScoreSub = listStuScore.Where(o => o.TestQuestions_Id == item.Testid && o.TestQuestions_Detail_OrderNum == sNum).ToList();
                                                    if (listStuScoreSub.Count > 0)
                                                    {
                                                        itemTQ_S.studentScore = listStuScoreSub[0].Student_Score.ToString();
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                #endregion
                                #region 综合题型 listBig
                                if (resModel.listBig != null)
                                {
                                    foreach (var item in resModel.listBig)
                                    {
                                        if (item != null && item.list != null)
                                        {
                                            foreach (var itemSub in item.list)
                                            {
                                                if (itemSub != null && itemSub.list != null)
                                                {
                                                    int sNum = 0;
                                                    foreach (var itemTQ_S in itemSub.list)
                                                    {
                                                        if (itemTQ_S != null)
                                                        {
                                                            itemTQ_S.answerHTML = "";
                                                            sNum++;
                                                            List <Model_Student_HomeWorkAnswer> listStuScoreSub = listStuScore.Where(o => o.TestQuestions_Id == itemSub.Testid && o.TestQuestions_Detail_OrderNum == sNum).ToList();
                                                            if (listStuScoreSub.Count > 0)
                                                            {
                                                                itemTQ_S.studentScore = listStuScoreSub[0].Student_Score.ToString();
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                #endregion

                                string savePathForTch = string.Format("{0}\\", pfunction.ToShortDate(modelHW.CreateTime.ToString()));
                                savePathForTch = "{0}{1}\\" + savePathForTch + "{2}\\{2}.txt";
                                object stuAnswer = new
                                {
                                    list    = resModel.answerJson,
                                    listBig = resModel.listBig
                                };
                                pfunction.WriteToFile(string.Format(savePathForTch, uploadPath, "studentAnswerForMarking", resourceId)
                                                      , Newtonsoft.Json.JsonConvert.SerializeObject(stuAnswer), true);
                                #endregion
                                Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("成功-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit"));
                            }
                            else
                            {
                                failNum++;
                                Rc.Common.SystemLog.SystemLog.AddLogFromBS("", resourceId, string.Format("失败-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", userId, resourceId, "testpaperanswersubmit"));
                            }
                        }
                        #endregion
                    }
                    catch (Exception ex)
                    {
                        failNum++;
                        Rc.Common.SystemLog.SystemLog.AddLogFromBS("", itemShw["Student_HomeWork_Id"].ToString()
                                                                   , string.Format("失败-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}。错误:{3}"
                                                                                   , itemShw["Student_Id"].ToString()
                                                                                   , itemShw["Student_HomeWork_Id"].ToString()
                                                                                   , "testpaperanswersubmit"
                                                                                   , ex.Message.ToString().Filter()
                                                                                   )
                                                                   );
                    }


                    Rc.Common.SystemLog.SystemLog.AddLogFromBS("", itemShw["Student_HomeWork_Id"].ToString(), string.Format("完成-自动提交学生作业|操作人{0}|学生作业Id{1}|方法{2}", itemShw["Student_Id"].ToString(), itemShw["Student_HomeWork_Id"].ToString(), "testpaperanswersubmit"));
                }

                #endregion
                #region 记录执行结束信息并保存数据
                model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
                model_FileSyncExecRecordDetail.Detail_Status  = "1";
                model_FileSyncExecRecordDetail.Detail_Remark  = string.Format("执行完成.数据总数{0},成功数{1},失败数{2}", dtShw.Rows.Count, sucNum, failNum);
                bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
                #endregion
            }
            catch (Exception ex)
            {
                model_FileSyncExecRecordDetail.Detail_TimeEnd = DateTime.Now;
                model_FileSyncExecRecordDetail.Detail_Status  = "2";
                model_FileSyncExecRecordDetail.Detail_Remark  = "执行失败:" + ex.Message.ToString();
                bll_FileSyncExecRecordDetail.Update(model_FileSyncExecRecordDetail);
            }
        }
Ejemplo n.º 21
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                bool flag = false;
                Rc.Cloud.Model.Model_VSysUserRole loginUser = HttpContext.Current.Session["LoginUser"] as Rc.Cloud.Model.Model_VSysUserRole;
                if (ddlType.Value == "1")
                {
                    List <Model_HomeWork> listHW = new BLL_HomeWork().GetModelList("HomeWork_Status='1' and HomeWork_FinishTime between '"
                                                                                   + txtSTime.Text.Filter() + "' and '" + txtETime.Text.Filter() + "' ");
                    foreach (var item in listHW)
                    {
                        #region  日期 执行数据分析,记录日志
                        Model_StatsLog modelLog = new Model_StatsLog();
                        modelLog.StatsLogId = Guid.NewGuid().ToString();
                        modelLog.DataId     = item.HomeWork_Id;
                        modelLog.DataName   = item.HomeWork_Name;
                        modelLog.DataType   = "1";
                        modelLog.LogStatus  = "2";
                        modelLog.CTime      = DateTime.Now;
                        modelLog.CUser      = loginUser.SysUser_ID;

                        flag = new BLL_StatsLog().ExecuteStatsAddLog(modelLog);
                        #endregion
                    }
                }
                else
                {
                    string rtrfId = hidtxtRTRFName.Value.Trim().Filter();
                    if (string.IsNullOrEmpty(rtrfId))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('请选择试卷名称!',{ time: 2000,icon:2},function(){});</script>");
                        return;
                    }
                    else
                    {
                        #region  试卷 执行数据分析,记录日志
                        Model_ResourceToResourceFolder modelRTRF = new BLL_ResourceToResourceFolder().GetModel(rtrfId);
                        Model_StatsLog modelLog = new Model_StatsLog();
                        modelLog.StatsLogId = Guid.NewGuid().ToString();
                        modelLog.DataId     = modelRTRF.ResourceToResourceFolder_Id;
                        modelLog.DataName   = txtRTRFName.Value;
                        modelLog.DataType   = "2";
                        modelLog.LogStatus  = "2";
                        modelLog.CTime      = DateTime.Now;
                        modelLog.CUser      = loginUser.SysUser_ID;

                        flag = new BLL_StatsLog().ExecuteStatsAddLog(modelLog);
                        #endregion
                    }
                }
                if (flag)
                {
                    new Rc.Cloud.BLL.BLL_clsAuth().AddLogFromBS("10255000", "手动执行统计成功");
                    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('执行统计成功!',{ time: 2000,icon:1},function(){parent.loadData();parent.layer.close(index);});</script>");
                }
                else
                {
                    new Rc.Cloud.BLL.BLL_clsAuth().AddLogErrorFromBS("10255000", "手动执行统计失败:执行SQL异常");
                    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('执行统计失败!',{ time: 2000,icon:2},function(){parent.loadData();parent.layer.close(index);});</script>");
                }
            }
            catch (Exception ex)
            {
                new Rc.Cloud.BLL.BLL_clsAuth().AddLogErrorFromBS("10255000", "手动执行统计失败:" + ex.Message.ToString());
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('执行统计失败!',{ time: 2000,icon:2},function(){parent.loadData();parent.layer.close(index);});</script>");
            }
        }