public static string UpdateTQ(string ChapterAssembly_TQ_Id, string TestQuestions_id)
 {
     try
     {
         Model_ChapterAssembly_TQ ChapterTQ = new BLL_ChapterAssembly_TQ().GetModel(ChapterAssembly_TQ_Id);
         Model_TestQuestions      TQ        = new BLL_TestQuestions().GetModel(TestQuestions_id);
         string sqlUpdate   = string.Empty;
         int    m           = 0;
         int    RetrunValue = 0;
         int    changeType  = 0;//换题类型(1普通题换综合题,2综合题换普通题)
         if (ChapterTQ != null && TQ != null)
         {
             if (ChapterTQ.type.TrimEnd() == "simple" && TQ.type.TrimEnd() == "complex")//普通题换成综合题
             {
                 changeType = 1;
                 sqlUpdate  = string.Format("update ChapterAssembly_TQ set TestQuestions_id='{0}',type='complex'  where ChapterAssembly_TQ_Id='{1}'", TestQuestions_id, ChapterAssembly_TQ_Id);
                 m          = Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(sqlUpdate);
                 DataTable dtList = new BLL_ChapterAssembly_TQ().GetList(ChapterTQ.Identifier_Id, ChapterAssembly_TQ_Id, "1", out RetrunValue).Tables[0];
             }
             if (ChapterTQ.type.TrimEnd() == "complex" && TQ.type.TrimEnd() == "simple")//综合题换成普通题
             {
                 changeType = 2;
                 sqlUpdate  = string.Format("update ChapterAssembly_TQ set TestQuestions_id='{0}', type='simple'  where ChapterAssembly_TQ_Id='{1}'", TestQuestions_id, ChapterAssembly_TQ_Id);
                 m          = Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(sqlUpdate);
                 DataTable dtList = new BLL_ChapterAssembly_TQ().GetList(ChapterTQ.Identifier_Id, ChapterAssembly_TQ_Id, "2", out RetrunValue).Tables[0];
             }
             if (ChapterTQ.type.TrimEnd() == TQ.type.TrimEnd())//相同题型互换
             {
                 sqlUpdate = string.Format("update ChapterAssembly_TQ set TestQuestions_id='{0}' where ChapterAssembly_TQ_Id='{1}'", TestQuestions_id, ChapterAssembly_TQ_Id);
                 m         = Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(sqlUpdate);
             }
             if (m > 0)
             {
                 string strJson = JsonConvert.SerializeObject(new
                 {
                     err         = "",
                     RetrunValue = RetrunValue,
                     ChangeType  = changeType
                 });
                 return(strJson.ToString());
             }
             else
             {
                 string strJson = JsonConvert.SerializeObject(new
                 {
                     err = "null"
                 });
                 return(strJson.ToString());
             }
         }
         else
         {
             string strJson = JsonConvert.SerializeObject(new
             {
                 err = "null"
             });
             return(strJson.ToString());
         }
     }
     catch (Exception ex)
     {
         string strJson = JsonConvert.SerializeObject(new
         {
             err = "null"
         });
         return(strJson.ToString());
     }
 }
Exemplo n.º 2
0
        public static string ChangeComplexityText(string scoreId, string tqId, string Source, string ResourceToResourceFolder_Id)
        {
            try
            {
                Model_TestQuestions tq = new BLL_TestQuestions().GetModel(tqId);

                Rc.Cloud.Model.Model_VSysUserRole loginUser = (Rc.Cloud.Model.Model_VSysUserRole)HttpContext.Current.Session["LoginUser"];
                scoreId = scoreId.Filter();
                Source  = Source.Filter();
                tqId    = tqId.Filter();
                ResourceToResourceFolder_Id = ResourceToResourceFolder_Id.Filter();
                string sql = string.Empty;
                if (tq.type == "simple")
                {
                    if (Source == "0")//删除空和题的难易度
                    {
                        sql  = string.Format(@" delete from S_TQ_Score_AttrExtend where AttrEnum='{0}' and TestQuestions_Score_Id='{1}' and ResourceToResourceFolder_Id='{2}' and TestQuestions_Id='{3}'", TQ_Score_AttrExtend.ComplexityText.ToString(), scoreId, ResourceToResourceFolder_Id, tqId);
                        sql += string.Format(@"delete from S_TQ_AttrExtend where AttrEnum='{0}' and ResourceToResourceFolder_Id='{1}' and TestQuestions_Id='{2}';", TQ_Score_AttrExtend.ComplexityText.ToString(), ResourceToResourceFolder_Id, tqId);
                    }
                    else
                    {
                        sql  = string.Format(@" delete from S_TQ_Score_AttrExtend where AttrEnum='{0}' and TestQuestions_Score_Id='{1}' and ResourceToResourceFolder_Id='{2}' and TestQuestions_Id='{3}'", TQ_Score_AttrExtend.ComplexityText.ToString(), scoreId, ResourceToResourceFolder_Id, tqId);
                        sql += string.Format(@"delete from S_TQ_AttrExtend where AttrEnum='{0}' and ResourceToResourceFolder_Id='{1}' and TestQuestions_Id='{2}';", TQ_Score_AttrExtend.ComplexityText.ToString(), ResourceToResourceFolder_Id, tqId);
                        sql += string.Format(@"insert into S_TQ_Score_AttrExtend values(newId(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{5}',getdate())"
                                             , ResourceToResourceFolder_Id
                                             , tqId
                                             , scoreId
                                             , TQ_Score_AttrExtend.ComplexityText.ToString()
                                             , Source
                                             , loginUser.SysUser_ID
                                             );
                        sql += string.Format(@"insert into S_TQ_AttrExtend values(newid(),'{0}','{1}','{2}',(select top 1 Common_Dict_ID  from S_TQ_Score_AttrExtend t
left join Common_Dict cd on cd.Common_Dict_ID=t.Attr_Value 
where AttrEnum='{2}' and TestQuestions_Id='{1}'  order by d_order desc),'{3}','{4}',getdate(),'{4}',getdate())"
                                             , ResourceToResourceFolder_Id
                                             , tqId
                                             , TQ_Score_AttrExtend.ComplexityText.ToString()
                                             , ""
                                             , loginUser.SysUser_ID);
                    }
                }
                else
                {
                    if (Source == "0")//删除空和题的难易度
                    {
                        sql  = string.Format(@" delete from S_TQ_Score_AttrExtend where AttrEnum='{0}' and TestQuestions_Score_Id='{1}' and ResourceToResourceFolder_Id='{2}' and TestQuestions_Id='{3}'", TQ_Score_AttrExtend.ComplexityText.ToString(), scoreId, ResourceToResourceFolder_Id, tqId);
                        sql += string.Format(@"delete from S_TQ_AttrExtend where AttrEnum='{0}' and ResourceToResourceFolder_Id='{1}' and TestQuestions_Id='{2}';", TQ_Score_AttrExtend.ComplexityText.ToString(), ResourceToResourceFolder_Id, tq.Parent_Id);
                    }
                    else
                    {
                        sql  = string.Format(@" delete from S_TQ_Score_AttrExtend where AttrEnum='{0}' and TestQuestions_Score_Id='{1}' and ResourceToResourceFolder_Id='{2}' and TestQuestions_Id='{3}'", TQ_Score_AttrExtend.ComplexityText.ToString(), scoreId, ResourceToResourceFolder_Id, tqId);
                        sql += string.Format(@"delete from S_TQ_AttrExtend where AttrEnum='{0}' and ResourceToResourceFolder_Id='{1}' and TestQuestions_Id='{2}';", TQ_Score_AttrExtend.ComplexityText.ToString(), ResourceToResourceFolder_Id, tq.Parent_Id);
                        sql += string.Format(@"insert into S_TQ_Score_AttrExtend values(newId(),'{0}','{1}','{2}','{3}','{4}','{5}',getdate(),'{5}',getdate())"
                                             , ResourceToResourceFolder_Id
                                             , tqId
                                             , scoreId
                                             , TQ_Score_AttrExtend.ComplexityText.ToString()
                                             , Source
                                             , loginUser.SysUser_ID
                                             );
                        sql += string.Format(@"insert into S_TQ_AttrExtend values(newid(),'{0}','{1}','{2}',(select top 1 Common_Dict_ID  from S_TQ_Score_AttrExtend t
left join Common_Dict cd on cd.Common_Dict_ID=t.Attr_Value 
where AttrEnum='{2}' and TestQuestions_Id in (select TestQuestions_Id from TestQuestions where Parent_Id='{1}')  order by d_order desc),'{3}','{4}',getdate(),'{4}',getdate())"
                                             , ResourceToResourceFolder_Id
                                             , tq.Parent_Id
                                             , TQ_Score_AttrExtend.ComplexityText.ToString()
                                             , ""
                                             , loginUser.SysUser_ID);
                    }
                }
                Rc.Common.DBUtility.DbHelperSQL.ExecuteSql(sql);
                return("1");
            }
            catch (Exception ex)
            {
                return("");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取资源对应文件路径 17-06-07TS
        /// </summary>
        private List <string> GetResourceFile(Model_ResourceToResourceFolder modelRTRF, string uploadPath)
        {
            try
            {
                List <string> listReturn = new List <string>();
                //生成存储路径
                string savePath    = string.Empty;
                string savePathOwn = string.Empty;
                if (modelRTRF.Resource_Class == Resource_ClassConst.云资源)
                {
                    savePath = string.Format("{0}\\{1}\\{2}\\{3}\\", modelRTRF.ParticularYear, modelRTRF.GradeTerm,
                                             modelRTRF.Resource_Version, modelRTRF.Subject);
                }
                if (modelRTRF.Resource_Class == Resource_ClassConst.自有资源)
                {
                    DateTime dateTime = Convert.ToDateTime(modelRTRF.CreateTime);
                    savePathOwn = string.Format("{0}\\", dateTime.ToString("yyyy-MM-dd"));
                }

                if (modelRTRF.Resource_Type == Rc.Common.Config.Resource_TypeConst.testPaper类型文件)
                {
                    string fileUrl = uploadPath + savePathOwn + "{0}\\" + savePath + "{1}.{2}";
                    #region 习题集文件
                    DataTable dtTQ       = new BLL_TestQuestions().GetList("ResourceToResourceFolder_Id='" + modelRTRF.ResourceToResourceFolder_Id + "'").Tables[0];
                    DataTable dtTQ_Score = new BLL_TestQuestions_Score().GetList("ResourceToResourceFolder_Id='" + modelRTRF.ResourceToResourceFolder_Id + "'").Tables[0];
                    foreach (DataRow item in dtTQ.Rows)
                    {
                        listReturn.Add(string.Format(fileUrl, "testQuestionBody", item["TestQuestions_Id"], "txt"));
                        listReturn.Add(string.Format(fileUrl, "testQuestionBody", item["TestQuestions_Id"], "htm"));
                        listReturn.Add(string.Format(fileUrl, "textTitle", item["TestQuestions_Id"], "htm"));
                    }
                    foreach (DataRow item in dtTQ_Score.Rows)
                    {
                        listReturn.Add(string.Format(fileUrl, "testQuestionCurrent", item["TestQuestions_Score_Id"], "txt"));
                        listReturn.Add(string.Format(fileUrl, "testQuestionOption", item["TestQuestions_Score_Id"], "txt"));

                        listReturn.Add(string.Format(fileUrl, "AnalyzeData", item["TestQuestions_Score_Id"], "txt"));
                        listReturn.Add(string.Format(fileUrl, "AnalyzeHtml", item["TestQuestions_Score_Id"], "htm"));

                        listReturn.Add(string.Format(fileUrl, "TrainData", item["TestQuestions_Score_Id"], "txt"));
                        listReturn.Add(string.Format(fileUrl, "TrainHtml", item["TestQuestions_Score_Id"], "htm"));

                        listReturn.Add(string.Format(fileUrl, "bodySub", item["TestQuestions_Score_Id"], "txt"));
                    }
                    #endregion
                }
                else
                {
                    #region 教案文件
                    string filePath = string.Empty;//文件存储路径
                    //判断产品类型
                    switch (modelRTRF.Resource_Type)
                    {
                    case Resource_TypeConst.ScienceWord类型文件:
                        filePath += "swDocument\\";
                        break;

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

                    case Resource_TypeConst.class类型文件:
                        filePath += "classDocument\\";
                        break;
                    }
                    #region 文件及图片
                    filePath += savePath;
                    filePath  = savePathOwn + filePath;

                    listReturn.Add(uploadPath + filePath + modelRTRF.ResourceToResourceFolder_Id + "." + modelRTRF.File_Suffix);
                    listReturn.Add(uploadPath + filePath + modelRTRF.ResourceToResourceFolder_Id + ".htm");

                    DataTable dtImg = new BLL_ResourceToResourceFolder_img().GetList("ResourceToResourceFolder_Id='" + modelRTRF.ResourceToResourceFolder_Id + "'").Tables[0];
                    foreach (DataRow item in dtImg.Rows)
                    {
                        listReturn.Add(uploadPath + item["ResourceToResourceFolderImg_Url"].ToString());
                    }

                    #endregion

                    #endregion
                }

                return(listReturn);
            }
            catch (Exception ex)
            {
                Rc.Common.SystemLog.SystemLog.AddLogErrorFromBS("", Request.Url.ToString(), string.Format("获取资源对应所有文件路径失败。{0}", ex.Message.ToString()));
                return(null);
            }
        }
Exemplo n.º 4
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
        }
        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);
            }
        }
Exemplo n.º 6
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());
            }
        }
        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
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string userId = FloginUser.UserId;

            try
            {
                BLL_Student_HomeWorkAnswer bll = new BLL_Student_HomeWorkAnswer();
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("开始解析按试题批改数据|操作人{0}|作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect"));
                string correctData                   = hidCorrect.Value;
                JavaScriptSerializer     json        = new JavaScriptSerializer();
                List <StudentAnswerData> listCorrect = json.Deserialize <List <StudentAnswerData> >(correctData);
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("完成解析按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect"));
                List <Model_Student_HomeWorkAnswer> listSHWA = new List <Model_Student_HomeWorkAnswer>();

                Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("开始处理按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect"));
                foreach (var item in listCorrect)
                {
                    #region 学生答题表
                    Model_Student_HomeWorkAnswer modelSHWA = bll.GetModel(item.Student_HomeWorkAnswer_Id);
                    modelSHWA.Student_Score = item.score;
                    modelSHWA.Comment       = item.comment.Filter();
                    if (item.score == item.actualscore)
                    {
                        modelSHWA.Student_Answer_Status = "right";//对
                    }
                    else if (item.score == 0)
                    {
                        modelSHWA.Student_Answer_Status = "wrong";//错
                    }
                    else
                    {
                        modelSHWA.Student_Answer_Status = "partright";//部分对
                    }
                    listSHWA.Add(modelSHWA);
                    #endregion
                }
                #region 作业试题批改确认表
                Model_HomeWorkQuestionConfirm modelHWQC = new Model_HomeWorkQuestionConfirm();
                modelHWQC.HomeWorkQuestionConfirm_ID = Guid.NewGuid().ToString();
                modelHWQC.HomeWork_Id      = HomeWork_Id;
                modelHWQC.TestQuestions_Id = TestQuestions_Id;
                modelHWQC.Confirm_Status   = "1";
                modelHWQC.CreateUser       = userId;
                modelHWQC.CreateTime       = DateTime.Now;
                #endregion

                int result = bll.TeacherCorrectStuHomeWorkByTQ(listSHWA, modelHWQC);

                if (result > 0)
                {
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("完成处理按试题批改数据|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect"));
                    string strWhere = string.Format(@"TestQuestions_Type!='title' and ResourceToResourceFolder_Id='{0}' and 
TestQuestions_Num>(select TestQuestions_Num from TestQuestions where TestQuestions_Id='{1}')
and TestQuestions_Id not in( select TestQuestions_Id from HomeWorkQuestionConfirm hwqc where hwqc.HomeWork_Id='{2}' ) order by TestQuestions_Num", ResourceToResourceFolder_Id, TestQuestions_Id, HomeWork_Id);
                    List <Model_TestQuestions> listTQ = new BLL_TestQuestions().GetModelList(strWhere);
                    if (listTQ.Count == 0)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>window.opener.loadHomeWorkTQData('" + HomeWork_Id + "');window.close();</script>");
                    }
                    else
                    {
                        Response.Redirect("ExerciseCorrectView.aspx?HomeWork_Id=" + HomeWork_Id + "&ResourceToResourceFolder_Id=" + ResourceToResourceFolder_Id + "&TestQuestions_Id=" + listTQ[0].TestQuestions_Id);
                    }
                }
                else
                {
                    Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("按试题批改失败:result 为0,|操作人{0}|学生作业Id{1}|方法{2}", userId, HomeWork_Id, "ExerciseCorrect"));
                    ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('批改失败',{icon:2,time:2000});</script>");
                }
            }
            catch (Exception ex)
            {
                Rc.Common.SystemLog.SystemLog.AddLogFromBS(HomeWork_Id, "", string.Format("按试题批改失败:|操作人{0}|学生作业Id{1}|方法{2}|错误信息{3}", userId, HomeWork_Id, "ExerciseCorrect", ex.Message.ToString()));
                ClientScript.RegisterStartupScript(this.GetType(), "save", "<script type='text/javascript'>layer.msg('批改失败err',{icon:2,time:2000});</script>");
            }
        }
Exemplo n.º 9
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());
            }
        }