public ActionResult ExcelSchedule(Guid id) { if (!CheckLogin()) { return(RedirectToAction("Login", "User")); } if (id == null) { return(RedirectToAction("Index", "Error")); } RunResultModel runResult = new RunResultModel(); ViewBag.ErrorMessage = string.Empty; ViewBag.ErrorMessage = string.Empty; ViewBag.SErrorMessage = TempData["SErrorMessage"]; ViewBag.SSuccessMessage = TempData["SSuccessMessage"]; try { Source source = _sourceFactory.GetSource(id); if (source != null) { runResult.SourceId = source.SourceId; runResult.SourceName = source.SourceName; runResult.Source = source; } else { return(RedirectToAction("Index", "Error")); } } catch (Exception ex) { log.Error("Get source in Run Data", ex); return(RedirectToAction("Index", "Error")); } return(View(runResult)); }
public ActionResult ExcelManualRunData(Guid id) { if (!CheckLogin()) { return(RedirectToAction("Login", "User")); } RunResultModel runResult = new RunResultModel(); if (id == null) { return(RedirectToAction("Index", "Error")); } try { Source source = _sourceFactory.GetSource(id); Guid userId = (Guid)Session[DSEConstant.UserId]; if (source != null) { runResult.SourceId = source.SourceId; runResult.SourceName = source.SourceName; runResult.Source = source; try { runResult.Success = RunExcel(source, userId); if (runResult.Success) { ViewBag.SuccessMessage = "Process done."; } else { ViewBag.ErrorMessage = "Process to run data from imported data was failed, please see logs for more information"; } } catch (Exception ex) { log.Error("Run data error", ex); ViewBag.ErrorMessage = "Run data progress end with error(s)" + System.Environment.NewLine + ex.Message; } } //if (source != null) //{ // runResult.SourceId = source.SourceId; // runResult.SourceName = source.SourceName; // runResult.Source = source; // try // { // Guid userId = (Guid)Session[DSEConstant.UserId]; // runResult.Success = _sourceFactory.RunData(id, userId) == 1; // if (runResult.Success) // { // ViewBag.SuccessMessage = "Process done."; // source.Status = true; // source.LastRun = DateTime.Now; // _sourceFactory.Update(source); // } // else // { // ViewBag.ErrorMessage = "Process to run data from imported data was failed, please see logs for more information"; // source.Status = false; // source.LastRun = DateTime.Now; // _sourceFactory.Update(source); // } // } // catch (Exception ex) // { // log.Error("Run data error", ex); // ViewBag.ErrorMessage = "Run data progress end with error(s)" + System.Environment.NewLine + ex.Message; // } //} } catch (Exception ex) { log.Error("Get source in Run Data", ex); ViewBag.ErrorMessage = "Run data progress end with error(s)" + System.Environment.NewLine + ex.Message; } return(View("ExcelSchedule", runResult)); }
public ActionResult ExcelRunData(Guid id) { if (!CheckLogin()) { return(RedirectToAction("Login", "User")); } RunResultModel runResult = new RunResultModel(); if (id == null) { return(RedirectToAction("Index", "Error")); } try { Source source = _sourceFactory.GetSource(id); Guid userId = (Guid)Session[DSEConstant.UserId]; if (source != null) { runResult.SourceId = source.SourceId; runResult.SourceName = source.SourceName; runResult.Source = source; try { DataTable resTable = _sourceFactory.GetValidationTable(source.SourceId, userId); if (resTable != null && resTable.Rows.Count > 0) { ViewBag.ErrorMessage = "Process unsuccessfully, please check validation result. "; source.Status = false; source.UpdateBy = userId; source.LastRun = DateTime.Now; _sourceFactory.Update(source); runResult.Success = false; } else { runResult.Success = _sourceFactory.RunData(id, userId) == 1; if (runResult.Success) { ViewBag.SuccessMessage = "Process done."; source.Status = true; source.LastRun = DateTime.Now; _sourceFactory.Update(source); } else { ViewBag.ErrorMessage = "Process to run data from imported data was failed, please see logs for more information"; source.Status = false; source.LastRun = DateTime.Now; _sourceFactory.Update(source); } } } catch (Exception ex) { log.Error("Run data error", ex); ViewBag.ErrorMessage = "Run data progress end with error(s)" + System.Environment.NewLine + ex.Message; } } } catch (Exception ex) { log.Error("Get source in Run Data", ex); ViewBag.ErrorMessage = "Run data progress end with error(s)" + System.Environment.NewLine + ex.Message; } return(View("ExcelSchedule", runResult)); }