|
|
@@ -298,13 +298,77 @@ namespace YZXYH2017.Controllers
|
|
|
var lotteries = ExcelHelper.ExcelToEntityList<Lottery>(new Dictionary<string, string>() {{"LotteryName", "姓名"},{"Mobile","手机"}},
|
|
|
virtualPath, out errorMsg);
|
|
|
UnitOfWork.LotteryRepository.Delete(i=>i.LotteryGroup==group);
|
|
|
- foreach (var lottery in lotteries)
|
|
|
+
|
|
|
+
|
|
|
+ try
|
|
|
{
|
|
|
- lottery.LotteryGroup = group;
|
|
|
- lottery.ExpLotteryType = "N";
|
|
|
- UnitOfWork.LotteryRepository.Insert(lottery);
|
|
|
- }
|
|
|
- return Json(new { Success = UnitOfWork.Save() });
|
|
|
+ foreach (var lottery in lotteries)
|
|
|
+ {
|
|
|
+ if (lottery == null||lottery.LotteryName==null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // lottery.LotteryName = lottery.LotteryName.Replace(" ", " ");
|
|
|
+ string name=lottery.LotteryName.Replace(" ","");
|
|
|
+ if (name.Contains("届"))
|
|
|
+ {
|
|
|
+ var arr = name.Split('届');
|
|
|
+ if (arr.Length <2)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ name = arr[0]+ "届 ";
|
|
|
+ if (arr[1].Length == 2)
|
|
|
+ {
|
|
|
+ name += $"{arr[1][0]} {arr[1][1]}";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ name += arr[1];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name.StartsWith("老师"))
|
|
|
+ {
|
|
|
+ name = name.Replace("老师", "老师 ");
|
|
|
+ }
|
|
|
+ else if (name.EndsWith("老师"))
|
|
|
+ {
|
|
|
+ name = name.Replace("老师", " 老师");
|
|
|
+ }
|
|
|
+ else if (name.EndsWith("先生"))
|
|
|
+ {
|
|
|
+ name = name.Replace("先生", " 先生");
|
|
|
+ }
|
|
|
+ else if (name.EndsWith("女士"))
|
|
|
+ {
|
|
|
+ name = name.Replace("女士", " 女士");
|
|
|
+ }
|
|
|
+ else if (name.StartsWith("嘉宾"))
|
|
|
+ {
|
|
|
+ name = name.Replace("嘉宾", "嘉宾 ");
|
|
|
+ }
|
|
|
+ else if (name.EndsWith("嘉宾"))
|
|
|
+ {
|
|
|
+ name = name.Replace("嘉宾", " 嘉宾");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ lottery.LotteryName=name;
|
|
|
+ lottery.LotteryGroup = group;
|
|
|
+ lottery.ExpLotteryType = "N";
|
|
|
+ lottery.Mobile = lottery.Mobile ?? "";
|
|
|
+ UnitOfWork.LotteryRepository.Insert(lottery);
|
|
|
+ UnitOfWork.Save();
|
|
|
+ }
|
|
|
+ return Json(new { Success = true });
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ return Json(new { Success = false });
|
|
|
+ }
|
|
|
}
|
|
|
#endregion
|
|
|
|