|
|
@@ -10,8 +10,6 @@ using CommonTool;
|
|
|
|
|
|
using Microsoft.AspNet.SignalR;
|
|
|
|
|
|
-using NPOI.HSSF.Record;
|
|
|
-
|
|
|
using YZXYH.Repository.Interface;
|
|
|
using YZXYH.Repository.Models;
|
|
|
|
|
|
@@ -20,6 +18,7 @@ using YZXYH2017.Hubs;
|
|
|
|
|
|
namespace YZXYH2017.Controllers
|
|
|
{
|
|
|
+
|
|
|
public class LuckDrawController : BaseController
|
|
|
{
|
|
|
// GET
|
|
|
@@ -39,7 +38,6 @@ namespace YZXYH2017.Controllers
|
|
|
}
|
|
|
|
|
|
#region Lottery CRUD
|
|
|
-
|
|
|
public ActionResult GetAllLottery()
|
|
|
{
|
|
|
string name = Request["LotteryName"];
|
|
|
@@ -113,8 +111,7 @@ namespace YZXYH2017.Controllers
|
|
|
UnitOfWork.LotteryRepository.Delete(i => idList.Contains(i.Id));
|
|
|
return Json(new { Success = UnitOfWork.Save() });
|
|
|
}
|
|
|
-
|
|
|
- #endregion Lottery CRUD
|
|
|
+ #endregion
|
|
|
|
|
|
#region LotteryRecord CRUD
|
|
|
|
|
|
@@ -124,6 +121,7 @@ namespace YZXYH2017.Controllers
|
|
|
/// <returns></returns>
|
|
|
public ActionResult ShowAllLotteryRecord()
|
|
|
{
|
|
|
+
|
|
|
string type = Request["LotteryType"];
|
|
|
string lotteryGroup = Request["LotteryGroup"];
|
|
|
//int pageSize = Convert.ToInt32(Request["pageSize"] ?? "0");
|
|
|
@@ -143,7 +141,6 @@ namespace YZXYH2017.Controllers
|
|
|
context.Clients.All.ShowLotteryMsg(JsonHelper.Instance.Serialize(result));
|
|
|
return Json(new { Success = true, Items = query.ToList() });
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 抽奖开始
|
|
|
/// </summary>
|
|
|
@@ -163,7 +160,6 @@ namespace YZXYH2017.Controllers
|
|
|
context.Clients.All.StartLotteryMsg(JsonHelper.Instance.Serialize(result));
|
|
|
return Json(new { Success = true });
|
|
|
}
|
|
|
-
|
|
|
/// <summary>
|
|
|
/// 抽奖
|
|
|
/// </summary>
|
|
|
@@ -193,7 +189,6 @@ namespace YZXYH2017.Controllers
|
|
|
{
|
|
|
continue;
|
|
|
}
|
|
|
-
|
|
|
var record = new LotteryRecord
|
|
|
{
|
|
|
LotteryName = f1.LotteryName,
|
|
|
@@ -228,8 +223,7 @@ namespace YZXYH2017.Controllers
|
|
|
UnitOfWork.LotteryRecordRepository.Delete(i => i.LotteryGroup == lotteryGroup);
|
|
|
return Json(new { Success = true });
|
|
|
}
|
|
|
-
|
|
|
- #endregion LotteryRecord CRUD
|
|
|
+ #endregion
|
|
|
|
|
|
#region SettingCrud
|
|
|
|
|
|
@@ -240,7 +234,6 @@ namespace YZXYH2017.Controllers
|
|
|
context.Clients.All.getMusic(offOn);
|
|
|
return Json(new { Success = true });
|
|
|
}
|
|
|
-
|
|
|
public ActionResult InsertGroup()
|
|
|
{
|
|
|
string group = Request["group"];
|
|
|
@@ -261,7 +254,6 @@ namespace YZXYH2017.Controllers
|
|
|
string newTypes = UnitOfWork.LotterySettingRepository.AddLotteryType(type);
|
|
|
return Json(new { Success = UnitOfWork.Save() });
|
|
|
}
|
|
|
-
|
|
|
public ActionResult DeleteType()
|
|
|
{
|
|
|
string type = Request["type"];
|
|
|
@@ -271,6 +263,7 @@ namespace YZXYH2017.Controllers
|
|
|
|
|
|
public ActionResult SetImageMusic()
|
|
|
{
|
|
|
+
|
|
|
string textColor = Request["textColor"] ?? "";
|
|
|
|
|
|
if (!string.IsNullOrEmpty(textColor) && textColor != "#000000")
|
|
|
@@ -295,7 +288,9 @@ namespace YZXYH2017.Controllers
|
|
|
return Json(new { Success = UnitOfWork.Save() });
|
|
|
}
|
|
|
|
|
|
- #endregion SettingCrud
|
|
|
+
|
|
|
+ #endregion
|
|
|
+
|
|
|
|
|
|
#region Upload
|
|
|
|
|
|
@@ -311,64 +306,80 @@ 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
|
|
|
{
|
|
|
- if (lottery == null || string.IsNullOrEmpty(lottery.LotteryName))
|
|
|
+ foreach (var lottery in lotteries)
|
|
|
{
|
|
|
- continue;
|
|
|
- }
|
|
|
- var name = lottery.LotteryName.Replace(" ", "");
|
|
|
- if (name.Contains("届"))
|
|
|
- {
|
|
|
- var arr = name.Split('届');
|
|
|
- name = arr[0] + "届 ";
|
|
|
- if (arr[1].Length > 2)
|
|
|
+ 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 += arr[1];
|
|
|
+ name = name.Replace("嘉宾", "嘉宾 ");
|
|
|
+ }
|
|
|
+ else if (name.EndsWith("嘉宾"))
|
|
|
+ {
|
|
|
+ name = name.Replace("嘉宾", " 嘉宾");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- name += $"{arr[1][0]} {arr[1][0]}";
|
|
|
+ continue;
|
|
|
}
|
|
|
- }
|
|
|
- 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";
|
|
|
- UnitOfWork.LotteryRepository.Insert(lottery);
|
|
|
+ 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 });
|
|
|
}
|
|
|
- return Json(new { Success = UnitOfWork.Save() });
|
|
|
}
|
|
|
+ #endregion
|
|
|
|
|
|
- #endregion Upload
|
|
|
}
|
|
|
|
|
|
public class StartLotteryDto
|
|
|
@@ -379,7 +390,6 @@ namespace YZXYH2017.Controllers
|
|
|
|
|
|
public int LotteryCount { get; set; }
|
|
|
}
|
|
|
-
|
|
|
public class ShowLotteryDto
|
|
|
{
|
|
|
public string LotteryType { get; set; }
|
|
|
@@ -388,4 +398,6 @@ namespace YZXYH2017.Controllers
|
|
|
|
|
|
public List<LotteryRecord> LotteryRecord { get; set; }
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|