Commit 971ee6f4 authored by 黄奎's avatar 黄奎

页面修改

parent 04b0d22a
......@@ -21,6 +21,7 @@ using VT.FW.DB;
using Edu.Repository.Grade;
using Edu.Common.Enum.Question;
using System.Threading.Tasks;
using Edu.Model.Entity.Course;
namespace Edu.Module.Course
{
......@@ -1068,129 +1069,82 @@ namespace Edu.Module.Course
return flag;
}
/// <summary>
/// 重新更新课程章节
/// 重新更新课程单词URL
/// </summary>
public void RunCourseChapterModule()
{
var courseList = chapterRepository.GetCourseChapterListExtRepository();
if (courseList != null && courseList.Count > 0)
{
var tempCourseList = courseList.Where(qitem => qitem.CourseId == 58 || qitem.CourseId == 10);
foreach (var item in tempCourseList)
{
List<RB_Course_Chapter_ViewModel> result = new List<RB_Course_Chapter_ViewModel>();
var chapterQuery = new RB_Course_Chapter_ViewModel() { CourseId = item.CourseId };
var sourceList = GetChapterListModule(chapterQuery,isQueryWords:true);
var treeList= GetChapterTreeListModule(chapterQuery);
if (treeList != null && treeList.Count>0)
public void RunWordsUrlModule(List<RB_Course_Chapter_ViewModel> n5CourseList, List<RB_Course_Chapter_ViewModel> n4CourseList, List<RB_Course_Chapter_ViewModel> n3CourseList)
{
foreach (var tItem in treeList)
var wordsList = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() {CourseId=1 });
var n5WordsList = wordsList.Where(qitem => qitem.ChapterId < 43).ToList();
int n5ChapterId = 6;
var tempN5Words = n5WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem=>qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
foreach (var item in tempN5Words)
{
var rootModel= sourceList.Where(qitem => qitem.ChapterId == tItem.ChapterId).FirstOrDefault();
if (tItem.ChildList == null || (tItem.ChildList != null && tItem.ChildList.Count == 0))
{
var rootModel1 = JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(JsonHelper.Serialize(rootModel));
rootModel1.ChapterName += "(1)";
rootModel1.StudyHours = 2;
rootModel1.StudyMinutes = 90;
result.Add(rootModel1);
var rootModel2 = JsonHelper.DeserializeObject<RB_Course_Chapter_ViewModel>(JsonHelper.Serialize(rootModel));
rootModel2.ChapterName += "(2)";
rootModel2.StudyHours = 2;
rootModel2.StudyMinutes = 90;
rootModel.WordsList = new List<RB_Course_Words_Extend>();
result.Add(rootModel2);
}
else
{
var tempList = new List<RB_Course_Chapter_ViewModel>();
GetCourseChildList(tItem, sourceList,tempList);
if (tempList != null)
var tempList = n5WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
foreach (var subItem in tempList)
{
result.AddRange(tempList);
}
}
subItem.CourseId = n5CourseList.FirstOrDefault().CourseId;
subItem.ChapterId = n5ChapterId;
}
n5ChapterId++;
}
if (result != null && result.Count > 0)
if (n5CourseList != null && n5CourseList.Count > 0)
{
int index = 1;
List<RB_Course_Words_Extend> wordsList = new List<RB_Course_Words_Extend>();
foreach (var sItem in result)
chapterRepository.SetBatchInsertCourseChapterRepository(n5CourseList);
}
if (n5WordsList != null && n5WordsList.Count > 0)
{
sItem.ChapterId = 0;
sItem.SortNum = index;
sItem.ChapterNo = index.ToString();
string pattern = @"第[一二三四五六七八九十]次课";
string newStr = Regex.Replace(sItem.ChapterName, pattern, "");
string newTitle = string.Format("第{0}次课", new WordToNumHelper().NumToChinese(index.ToString())) + " " + newStr.Trim();
sItem.ChapterName = newTitle;
course_WordsRepository.BatchInsertCourseWordsRepository(n5WordsList);
}
foreach (var subItem in sItem.WordsList)
var n4WordsList = wordsList.Where(qitem => qitem.ChapterId >= 43 && qitem.ChapterId<79).ToList();
var tempN4Words = n4WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem => qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
int n4ChapterId = 1;
foreach (var item in tempN4Words)
{
subItem.Id = 0;
subItem.ChapterId = index;
}
if (sItem.WordsList != null && sItem.WordsList.Count > 0)
var tempList = n4WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
foreach (var subItem in tempList)
{
wordsList.AddRange(sItem.WordsList);
subItem.CourseId = n4CourseList.FirstOrDefault().CourseId;
subItem.ChapterId = n4ChapterId;
}
index++;
n4ChapterId++;
}
//chapterRepository.DeleteByCourseIdRepository(item.CourseId);
//course_WordsRepository.DeleteWordsByCourseIdRepository(item.CourseId);
//chapterRepository.SetBatchInsertCourseChapterRepository(result);
//if (wordsList != null && wordsList.Count > 0)
//{
// course_WordsRepository.BatchInsertCourseWordsRepository(wordsList);
//}
}
string str = Common.Plugin.JsonHelper.Serialize(result);
}
if (n4CourseList != null && n4CourseList.Count > 0)
{
chapterRepository.SetBatchInsertCourseChapterRepository(n4CourseList);
}
if (n4WordsList != null && n4WordsList.Count > 0)
{
course_WordsRepository.BatchInsertCourseWordsRepository(n4WordsList);
}
/// <summary>
/// 重新更新课程单词URL
/// </summary>
public void RunWordsUrlModule()
{
var list = course_WordsRepository.GetCourseWordsListRepository(new RB_Course_Words_Extend() { }).Where(qitem => string.IsNullOrEmpty(qitem.FileUrl)).ToList();
string newPath = @"G:\WebFile\EduSystem\CourseWords";
var fileList = Common.Plugin.FileHelper.GetFileList(newPath);
if (list != null && list.Count > 0 && fileList != null && fileList.Count > 0)
{
//Task.Run(() =>
//{
Dictionary<string, object> fileds = new Dictionary<string, object>();
foreach (var item in list.Where(qitem => string.IsNullOrEmpty(qitem.FileUrl)))
{
if (string.IsNullOrEmpty(item.FileUrl))
var n3WordsList = wordsList.Where(qitem => qitem.ChapterId >= 79).ToList();
var tempN3Words = n3WordsList.GroupBy(qitem => new { qitem.ChapterId }).OrderBy(qitem => qitem.Key.ChapterId).Select(qitem => new { qitem.Key.ChapterId });
int n3ChapterId = 1;
foreach (var item in tempN3Words)
{
var tempWords = fileList.Where(qitem => (qitem.FileName.ToLower() ==
item.WordContent.ToLower()
.Replace("(", "(")
.Replace(")", ")")
.Replace("~", "〜")
.Replace("。","")
.Replace(@"\n","") + ".mp3")
)?.FirstOrDefault();
if (tempWords != null)
var tempList = n3WordsList.Where(qitem => qitem.ChapterId == item.ChapterId).ToList();
foreach (var subItem in tempList)
{
fileds.Clear();
string newFileUrl = @"/EduSystem/CourseWords/" + tempWords.FileName;
fileds.Add(nameof(RB_Course_Words_Extend.FileUrl), newFileUrl);
bool flag = course_WordsRepository.Update(fileds, new WhereHelper(nameof(RB_Course_Words_Extend.Id), item.Id));
subItem.CourseId = n3CourseList.FirstOrDefault().CourseId;
subItem.ChapterId = n3ChapterId;
}
n3ChapterId++;
}
if (n3CourseList != null && n3CourseList.Count > 0)
{
chapterRepository.SetBatchInsertCourseChapterRepository(n3CourseList);
}
//});
if (n3WordsList != null && n3WordsList.Count > 0)
{
course_WordsRepository.BatchInsertCourseWordsRepository(n3WordsList);
}
string str = "";
}
/// <summary>
......
......@@ -107,12 +107,12 @@ WHERE 1=1
if (list != null && list.Count > 0)
{
StringBuilder builder = new StringBuilder();
builder.AppendFormat(" INSERT INTO RB_Course_Words(CourseId,ChapterId,WordType,WordContent,WordTone,WordWrite,ChineseMean,Status,Group_Id,CreateBy,CreateTime,UpdateBy,UpdateTime) ");
builder.AppendFormat(" INSERT INTO RB_Course_Words(CourseId,ChapterId,WordType,WordContent,WordTone,WordWrite,ChineseMean,Status,Group_Id,CreateBy,CreateTime,UpdateBy,UpdateTime,FileUrl) ");
builder.AppendFormat(" VALUES ");
string tempStr = "";
foreach (var item in list)
{
tempStr += $",({item.CourseId},{item.ChapterId},'{item.WordType}','{item.WordContent}','{item.WordTone}','{item.WordWrite}','{item.ChineseMean}',0,{item.Group_Id},{item.CreateBy},'{item.CreateTime}',{item.UpdateBy},'{item.UpdateTime}') ";
tempStr += $",({item.CourseId},{item.ChapterId},'{item.WordType}','{item.WordContent}','{item.WordTone}','{item.WordWrite}','{item.ChineseMean}',0,{item.Group_Id},{item.CreateBy},'{item.CreateTime}',{item.UpdateBy},'{item.UpdateTime}','{item.FileUrl}') ";
}
builder.Append(tempStr.TrimStart(','));
flag = base.Execute(builder.ToString()) > 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment