FacultymajorController.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6. using EMIS.ViewModel;
  7. using EMIS.ViewModel.Specialtyclass;
  8. using EMIS.CommonLogic.Specialtyclass;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq.Entity;
  11. using Bowin.Web.Controls.Mvc;
  12. using EMIS.CommonLogic.SystemServices;
  13. using Bowin.Common.Utility;
  14. using EMIS.Web.Controls;
  15. using System.Data;
  16. using Bowin.Common.Data;
  17. using System.Data.SqlClient;
  18. using Bowin.Common.Exceptions;
  19. using EMIS.Utility;
  20. using System.Text;
  21. using EMIS.CommonLogic.DataCenterSynch;
  22. namespace EMIS.Web.Controllers.Specialtyclass
  23. {
  24. [Authorization]
  25. public class FacultymajorController : Controller
  26. {
  27. public IFacultymajorServices FacultymajorServices { get; set; }
  28. public IFacultySynchServices FacultySynchServices { get; set; }
  29. /// <summary>
  30. /// 院系专业页面
  31. /// </summary>
  32. /// <returns></returns>
  33. public ActionResult List()
  34. {
  35. return View();
  36. }
  37. /// <summary>
  38. /// 院系专业页面列表查询
  39. /// </summary>
  40. /// <param name="pararms"></param>
  41. /// <returns></returns>
  42. [HttpPost]
  43. public ActionResult List(QueryParamsModel pararms)
  44. {
  45. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  46. var campusID = pararms.getExtraGuid("CampusDropdown");
  47. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  48. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  49. var educationID = pararms.getExtraInt("DictionaryEducation") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryEducation");
  50. var learningformID = pararms.getExtraInt("DictionaryLearningform") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryLearningform");
  51. var learnSystem = pararms.getExtraString("DictionaryLearnSystem");
  52. var scienceclassID = pararms.getExtraInt("DictionaryScienceclass") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryScienceclass");
  53. //在校状态
  54. var inSchoolStatus = pararms.getExtraInt("DictionaryInschoolStatus") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryInschoolStatus");
  55. return base.Json(FacultymajorServices.GetFacultymajorViewGrid(configuretView, campusID, collegeID, standardID,
  56. educationID, learningformID, learnSystem, scienceclassID, inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  57. }
  58. /// <summary>
  59. /// 查询对应的院系专业信息(带数据范围)
  60. /// </summary>
  61. /// <returns></returns>
  62. [HttpPost]
  63. public ActionResult BindCheckList()
  64. {
  65. var list = FacultymajorServices.GetAllFacultymajorViewList(null).ToList();
  66. return base.Json(list);
  67. }
  68. /// <summary>
  69. /// 查询对应的院系专业信息(带数据范围)
  70. /// </summary>
  71. /// <param name="bindType"></param>
  72. /// <returns></returns>
  73. [HttpPost]
  74. public ActionResult BindDropdownList(DropdownListBindType? bindType)
  75. {
  76. List<DropdownListItem> list = FacultymajorServices.GetAllFacultymajorViewList(null)
  77. .Select(x => new DropdownListItem
  78. {
  79. Text = x.Name,
  80. Value = x.FacultymajorID.ToString()
  81. }).ToList();
  82. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  83. DropdownList.FormatDropdownItemList(dbt, list);
  84. return base.Json(list);
  85. }
  86. /// <summary>
  87. /// 查询院系专业对应的专业信息
  88. /// </summary>
  89. /// <param name="pararms"></param>
  90. /// <returns></returns>
  91. [HttpPost]
  92. public ActionResult FacultymajorBindDropdownList(QueryParamsModel pararms)
  93. {
  94. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  95. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  96. var listFacultymajor = FacultymajorServices.GetStandardViewList(configuretView, collegeID, pararms.page, pararms.rows);
  97. return Json(listFacultymajor);
  98. }
  99. /// <summary>
  100. /// 查询院系专业对应的专业信息
  101. /// </summary>
  102. /// <param name="bindType"></param>
  103. /// <param name="collegeID"></param>
  104. /// <returns></returns>
  105. [HttpPost]
  106. public ActionResult BindStandardDropDownList(DropdownListBindType? bindType, Guid? collegeID)
  107. {
  108. List<DropdownListItem> list = this.FacultymajorServices
  109. .GetFacultymajorViewList(new ConfiguretView(), null, collegeID, null,
  110. null, null, null, null, null)
  111. .GroupBy(x => new { x.StandardID, x.StandardName })
  112. .Select((x, y) => new DropdownListItem { Text = x.Key.StandardName, Value = x.Key.StandardID }).ToList();
  113. DropdownListBindType dbt = bindType == null ? DropdownListBindType.SelectAll : bindType.Value;
  114. DropdownList.FormatDropdownItemList(dbt, list);
  115. return base.Json(list);
  116. }
  117. /// <summary>
  118. /// 查询对应的院系专业信息
  119. /// </summary>
  120. /// <param name="bindType"></param>
  121. /// <param name="collegeID"></param>
  122. /// <returns></returns>
  123. [HttpPost]
  124. public ActionResult BindFacultymajorNameDropDownList(QueryParamsModel pararms)
  125. {
  126. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  127. var collegeID = pararms.getExtraGuid("CollegeDropdown");
  128. var standardID = pararms.getExtraInt("DictionaryStandard") == DropdownList.SELECT_ALL ? null : pararms.getExtraInt("DictionaryStandard");
  129. var listFacultymajor = this.FacultymajorServices.GetFacultymajorNameList(collegeID, standardID).ToList();
  130. if (configuretView.ConditionValue != null)
  131. { //模糊查询
  132. listFacultymajor = listFacultymajor.Where(x => x.Name.Contains(configuretView.ConditionValue)).ToList();
  133. }
  134. return Json(new { total = listFacultymajor.Count, rows = listFacultymajor });
  135. }
  136. /// <summary>
  137. /// 查询院系专业对应的学制信息
  138. /// </summary>
  139. /// <param name="pararms"></param>
  140. /// <returns></returns>
  141. public ActionResult LearnSystem(QueryParamsModel pararms)
  142. {
  143. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  144. var LearnSystem = pararms.getExtraString("DictionaryLearnSystem");
  145. return base.Json(FacultymajorServices.GetLearnSystemViewList(configuretView, LearnSystem, (int)pararms.page, (int)pararms.rows));
  146. }
  147. /// <summary>
  148. /// 复制新增
  149. /// </summary>
  150. /// <param name="facultymajorID"></param>
  151. /// <returns></returns>
  152. public ActionResult CopyAdd(Guid facultymajorID)
  153. {
  154. FacultymajorView facultymajorView = new FacultymajorView();
  155. facultymajorView = FacultymajorServices.GetFacultymajorView(facultymajorID);
  156. return View("Edit", facultymajorView);
  157. }
  158. /// <summary>
  159. /// 复制新增
  160. /// </summary>
  161. /// <param name="facultymajorView"></param>
  162. /// <returns></returns>
  163. [HttpPost]
  164. public ActionResult CopyAdd(FacultymajorView facultymajorView)
  165. {
  166. facultymajorView.FacultymajorID = Guid.Empty;
  167. return this.Edit(facultymajorView);
  168. }
  169. /// <summary>
  170. /// 编辑(新增、修改,业务主键:院系所ID、院系专业编号、专业ID(Value)、培养层次、学习形式、学制唯一)
  171. /// </summary>
  172. /// <returns></returns>
  173. [HttpGet]
  174. public ActionResult Edit(Guid? facultymajorID)
  175. {
  176. ////临时性加参数控制、屏蔽列表进入无保存按钮权限
  177. ViewBag.Type = Request.Params["Type"];
  178. FacultymajorView facultymajorView = new FacultymajorView();
  179. if (facultymajorID.HasValue)
  180. {
  181. facultymajorView = FacultymajorServices.GetFacultymajorView(facultymajorID);
  182. }
  183. return View(facultymajorView);
  184. }
  185. /// <summary>
  186. /// 编辑(新增、修改,业务主键:院系所ID、院系专业编号、专业ID(Value)、培养层次、学习形式、学制唯一)
  187. /// </summary>
  188. /// <param name="facultymajorView"></param>
  189. /// <returns></returns>
  190. [HttpPost]
  191. public ActionResult Edit(FacultymajorView facultymajorView)
  192. {
  193. try
  194. {
  195. FacultymajorServices.FacultymajorEdit(facultymajorView);
  196. return Json(new ReturnMessage()
  197. {
  198. IsSuccess = true,
  199. Message = "保存成功。"
  200. });
  201. }
  202. catch (Exception ex)
  203. {
  204. return Json(new ReturnMessage()
  205. {
  206. IsSuccess = false,
  207. Message = "保存失败:" + ex.Message
  208. });
  209. }
  210. }
  211. /// <summary>
  212. /// 删除
  213. /// </summary>
  214. /// <param name="facultymajorIDs"></param>
  215. /// <returns></returns>
  216. [HttpPost]
  217. public ActionResult Delete(string facultymajorIDs)
  218. {
  219. try
  220. {
  221. List<Guid?> list = facultymajorIDs.Split(',').Where(x => !string.IsNullOrEmpty(x))
  222. .Select(x => (Guid?)new Guid(x)).ToList();
  223. FacultymajorServices.FacultymajorDelete(list);
  224. return base.Json("删除成功。");
  225. }
  226. catch (Exception ex)
  227. {
  228. string mge = ex.Message;
  229. System.Data.SqlClient.SqlException num = ExceptionHelper.GetSqlException(ex);
  230. if (num != null)
  231. {
  232. if (num.Number == 547)
  233. {
  234. mge = "请先删除所有关联的数据,如:年级专业、班级信息、学生信息等";
  235. }
  236. }
  237. return base.Json("删除失败,原因:" + mge);
  238. }
  239. }
  240. /// <summary>
  241. /// 年级专业页面(查询对应的年级专业信息)
  242. /// </summary>
  243. /// <returns></returns>
  244. public ActionResult GrademajorList()
  245. {
  246. return View();
  247. }
  248. /// <summary>
  249. /// 年级专业页面(查询对应的年级专业信息)
  250. /// </summary>
  251. /// <param name="pararms"></param>
  252. /// <returns></returns>
  253. [HttpPost]
  254. public ActionResult GrademajorList(QueryParamsModel pararms)
  255. {
  256. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  257. var facultymajorID = Request["facultymajorID"].ParseStrTo<Guid>();
  258. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  259. return Json(FacultymajorServices.GetGrademajorViewGrid(configuretView, facultymajorID,
  260. inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  261. }
  262. /// <summary>
  263. /// 查询院系专业对应的所有班级学生
  264. /// </summary>
  265. /// <returns></returns>
  266. public ActionResult ClassStudentListView()
  267. {
  268. return View();
  269. }
  270. /// <summary>
  271. /// 查询院系专业对应的所有班级学生
  272. /// </summary>
  273. /// <param name="pararms"></param>
  274. /// <returns></returns>
  275. [HttpPost]
  276. public ActionResult ClassStudentListView(QueryParamsModel pararms)
  277. {
  278. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(pararms);
  279. var facultymajorID = Request["facultymajorID"].ParseStrTo<Guid>();
  280. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  281. return Json(FacultymajorServices.GetBaseStudentViewGrid(configuretView, facultymajorID,
  282. inSchoolStatus, (int)pararms.page, (int)pararms.rows));
  283. }
  284. /// <summary>
  285. /// 导出Excel
  286. /// </summary>
  287. /// <param name="pararms"></param>
  288. /// <returns></returns>
  289. [HttpPost]
  290. public ActionResult Excel()
  291. {
  292. NpoiExcelHelper neh = new NpoiExcelHelper();
  293. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  294. var campusID = Request.Form["CampusDropdown"].ParseStrTo<Guid>();
  295. var collegeID = Request.Form["CollegeDropdown"].ParseStrTo<Guid>();
  296. var standardID = Request.Form["DictionaryStandard"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryStandard"].ParseStrTo<int>();
  297. var educationID = Request.Form["DictionaryEducation"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryEducation"].ParseStrTo<int>();
  298. var learningformID = Request.Form["DictionaryLearningform"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryLearningform"].ParseStrTo<int>();
  299. var learnSystem = Request.Form["DictionaryLearnSystem"].ToString();
  300. var scienceclassID = Request.Form["DictionaryScienceclass"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryScienceclass"].ParseStrTo<int>();
  301. //在校状态
  302. var inSchoolStatus = Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request.Form["DictionaryInschoolStatus"].ParseStrTo<int>();
  303. var dt = FacultymajorServices.GetFacultymajorViewList(configuretView, campusID, collegeID, standardID,
  304. educationID, learningformID, learnSystem, scienceclassID, inSchoolStatus)
  305. .Select(x => new
  306. {
  307. x.Code,
  308. x.Name,
  309. x.CollegeCode,
  310. x.CollegeName,
  311. x.StandardCode,
  312. x.StandardID,
  313. x.StandardName,
  314. LearnSystem = x.LearnSystem.HasValue ? x.LearnSystem.Value.ToString("#.#") : null,
  315. x.EducationName,
  316. x.LearningformName,
  317. x.ScienceclassName,
  318. x.LearningstyleName,
  319. x.LearnPositionName,
  320. x.Remark
  321. }).ToTable();
  322. string[] liststring = {
  323. "院系专业编号", "院系专业名称", RSL.Get("CollegeCode"), RSL.Get("College"),
  324. "专业代码", "专业ID(Value)", "专业名称", "学制", RSL.Get("EducationID"), "学习形式",
  325. "专业科类", "学习方式", "授予学位", "备注"
  326. };
  327. var title = "院系专业信息";
  328. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  329. {
  330. title = "院系专业信息(非在校)";
  331. }
  332. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  333. {
  334. title = "院系专业信息(在校)";
  335. }
  336. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  337. return Json(new ReturnMessage()
  338. {
  339. IsSuccess = true,
  340. Message = "导出成功。"
  341. });
  342. }
  343. /// <summary>
  344. /// 导出年级专业明细Excel
  345. /// </summary>
  346. /// <param name="pararms"></param>
  347. /// <returns></returns>
  348. [HttpPost]
  349. public ActionResult Excel_Grademajor()
  350. {
  351. NpoiExcelHelper neh = new NpoiExcelHelper();
  352. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  353. var facultymajorID = Request["facultymajorID"].ParseStrTo<Guid>();
  354. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  355. var dt = FacultymajorServices.GetGrademajorViewList(configuretView, facultymajorID, inSchoolStatus)
  356. .Select(x => new
  357. {
  358. x.Code,
  359. x.Name,
  360. x.SchoolyearID,
  361. x.SchoolcodeName,
  362. x.GraduatingSemesterCode,
  363. x.StudentCount,
  364. x.FacultymajorCode,
  365. x.FacultymajorName
  366. }).ToTable();
  367. string[] liststring = {
  368. "年级专业编号", "年级专业名称", "年级", "入学学期",
  369. "毕业学期", "人数", "院系专业编号", "院系专业名称"
  370. };
  371. var title = "院系专业年级专业信息";
  372. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  373. {
  374. title = "院系专业年级专业信息(非在校)";
  375. }
  376. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  377. {
  378. title = "院系专业年级专业信息(在校)";
  379. }
  380. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  381. return Json(new ReturnMessage()
  382. {
  383. IsSuccess = true,
  384. Message = "导出成功。"
  385. });
  386. }
  387. /// <summary>
  388. /// 导出学生明细Excel
  389. /// </summary>
  390. /// <param name="pararms"></param>
  391. /// <returns></returns>
  392. [HttpPost]
  393. public ActionResult Excel_ClassStudent()
  394. {
  395. NpoiExcelHelper neh = new NpoiExcelHelper();
  396. ConfiguretView configuretView = ConfiguretExtensions.GetConfiguretermsView(null);
  397. var facultymajorID = Request["facultymajorID"].ParseStrTo<Guid>();
  398. int? inSchoolStatus = Request["DictionaryInschoolStatus"].ParseStrTo<int>() == DropdownList.SELECT_ALL ? null : Request["DictionaryInschoolStatus"].ParseStrTo<int>();
  399. var dt = FacultymajorServices.GetBaseStudentViewList(configuretView, facultymajorID, inSchoolStatus)
  400. .Select(x => new
  401. {
  402. x.LoginID,
  403. x.UserName,
  404. x.SexName,
  405. x.InSchoolStatusName,
  406. x.StudentStatusName,
  407. x.ClassmajorCode,
  408. x.ClassmajorName,
  409. x.SchoolyearID,
  410. x.GrademajorCode,
  411. x.GrademajorName,
  412. x.FacultymajorCode,
  413. x.FacultymajorName
  414. }).ToTable();
  415. string[] liststring = {
  416. "学号", "姓名", "性别", "在校状态", "学籍状态",
  417. "班级编号", "班级名称", "年级","年级专业编号", "年级专业名称",
  418. "院系专业编号", "院系专业名称"
  419. };
  420. var title = "院系专业学生信息";
  421. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.No)
  422. {
  423. title = "院系专业学生信息(非在校)";
  424. }
  425. if (inSchoolStatus == (int)CF_INOrOutSchoolStatus.Yes)
  426. {
  427. title = "院系专业学生信息(在校)";
  428. }
  429. neh.Export(dt, liststring, title + DateTime.Now.ToString("yyyyMMdd"));
  430. return Json(new ReturnMessage()
  431. {
  432. IsSuccess = true,
  433. Message = "导出成功。"
  434. });
  435. }
  436. /// <summary>
  437. /// Excel导入
  438. /// </summary>
  439. /// <param name="errorFile"></param>
  440. /// <param name="operationTips"></param>
  441. /// <returns></returns>
  442. [HttpGet]
  443. public ActionResult Import(string errorFile, string operationTips)
  444. {
  445. ViewBag.ErrorFile = errorFile;
  446. if (string.IsNullOrEmpty(operationTips))
  447. {
  448. operationTips = "点击查看失败原因...";
  449. }
  450. ViewBag.operationTips = operationTips;
  451. return View();
  452. }
  453. /// <summary>
  454. /// Excel导入
  455. /// </summary>
  456. /// <param name="file"></param>
  457. /// <returns></returns>
  458. [HttpPost]
  459. public ActionResult Import(HttpPostedFileBase file)
  460. {
  461. try
  462. {
  463. if (!NpoiExcelHelper.GetIsCompatible(file.FileName))
  464. {
  465. throw new Exception("格式错误,只允许导入xls或xlsx格式的Excel文件。");
  466. }
  467. Dictionary<string, string> cellheader = new Dictionary<string, string>
  468. {
  469. { "Code", "院系专业编号" },
  470. { "Name", "院系专业名称" },
  471. { "Abbreviation", "简称" },
  472. { "EnglishName", "英文名称" },
  473. { "CollegeCode", RSL.Get("CollegeCode") },
  474. { "StandardCodeStr", "专业代码" },
  475. { "StandardNameStr", "专业名称" },
  476. { "EducationStr", RSL.Get("EducationName") },
  477. { "LearningformStr", "学习形式" },
  478. { "LearnSystemStr", "学制" },
  479. { "ScienceclassStr", "专业科类" },
  480. { "LearningstyleStr", "学习方式" },
  481. { "LearnPositionStr", "授予学位" },
  482. { "TeacherIdentification", "师范标识" },
  483. { "SetTimeStr", "设置时间" },
  484. { "Remark", "备注" },
  485. { "ErrorMessage", "未导入原因" }
  486. };
  487. StringBuilder errorMsg = new StringBuilder(); // 错误信息
  488. string sourceWebPath = FileUploadHelper.UploadFile(file);
  489. var sourcePhysicalPath = Server.MapPath(sourceWebPath);
  490. List<FacultymajorView> errList = new List<FacultymajorView>();
  491. List<FacultymajorView> dataList = new List<FacultymajorView>();
  492. int? inCount = 0; //导入个数
  493. int? upCount = 0; //更新个数
  494. int? errCount = 0; //失败个数
  495. //导入
  496. FacultymajorServices.FacultymajorImport(cellheader, out inCount, out upCount, out errList, out errCount, sourcePhysicalPath);
  497. System.IO.File.Delete(sourcePhysicalPath);//删除本地缓存文件
  498. if (errList.Count() > 0)
  499. {
  500. //获取错误数据文件路径
  501. string errorWebPath = string.Format("{0}", NpoiExcelHelper
  502. .EntityListToExcel2003(cellheader, errList, "院系专业信息导入失败文件", sourcePhysicalPath));
  503. ViewBag.ErrorFile = errorWebPath;
  504. string Errinfo = string.Format("提示:{0}条院系专业信息导入成功,{1}条院系专业信息更新成功,{2}条院系专业信息导入失败,点击查看。",
  505. inCount, upCount, errCount);
  506. ViewBag.operationTips = Errinfo;
  507. return RedirectToAction("MsgShow", "Common", new
  508. {
  509. WindowID = "none",
  510. msg = Errinfo,
  511. url = Url.Action("Import").AddMenuParameter() + "&errorFile=" + errorWebPath + "&operationTips="
  512. + Errinfo + "&WindowID=" + Request["WindowID"]
  513. });
  514. }
  515. else
  516. {
  517. string successInfo = string.Format("提示:{0}条院系专业信息导入成功,{1}条院系专业信息更新成功。", inCount, upCount);
  518. return RedirectToAction("MsgShow", "Common", new
  519. {
  520. WindowID = Request["WindowID"],
  521. msg = successInfo,
  522. url = Url.Action("List").AddMenuParameter()
  523. });
  524. }
  525. }
  526. catch (Exception ex)
  527. {
  528. return RedirectToAction("MsgShow", "Common", new
  529. {
  530. WindowID = "none",
  531. msg = "导入失败,原因:" + ex.Message,
  532. url = Url.Action("Import").AddMenuParameter() + "&WindowID=" + Request["WindowID"]
  533. });
  534. }
  535. }
  536. [HttpPost]
  537. public ActionResult Synchr()
  538. {
  539. try
  540. {
  541. FacultySynchServices.Synchr();
  542. return Json(new ReturnMessage { IsSuccess = true, Message = "同步成功。" });
  543. }
  544. catch (Exception ex)
  545. {
  546. return Json(new ReturnMessage { IsSuccess = false, Message = "同步失败:" + ex.Message });
  547. }
  548. }
  549. }
  550. }