// GET: Organizations/Details/5 public ActionResult Details(long?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Organization organization = _organizationManager.GetById((long)id); if (organization == null) { return(HttpNotFound()); } return(View(organization)); }
public void Execute(int databaseId) { try { Logger.Info($"{GetType().Name} - [Common Background Tasks] Starting job for organization with database id: {databaseId}"); //should get older background tasks with status new and one by one to try processing it before processing try to change status and after processing update status //processing itself should happen like listener.Process method var org = _orgManager.GetById(databaseId); if (!string.IsNullOrEmpty(org.ConnectionString)) { IBackgroundTaskManager taskManager = new BackgroundTaskManager(org.ConnectionString, Process.GetCurrentProcess().ProcessName); var repo = new Common.Repository.PricingRepository(org.ConnectionString, Constants.TIMEOUT_MSMQ_EXEC_STOREDPROC); var engine = new PriceEngine(repo, Logger); var tasks = taskManager.ListTasks(Fourth.StarChef.Invariables.Enums.BackgroundTaskStatus.New, null, null, false, 100, 0); BackgroundTaskProcessor processor = new BackgroundTaskProcessor(databaseId, org.ConnectionString, _databaseManager, engine, Logger); foreach (var t in tasks) { try { Logger.Info($"Task {t.Id} Processing"); var res = taskManager.UpdateTaskStatus(t.Id, t.Status, Fourth.StarChef.Invariables.Enums.BackgroundTaskStatus.InProgress, string.Empty).Result; processor.ProcessMessage(t); res = taskManager.UpdateTaskStatus(t.Id, Fourth.StarChef.Invariables.Enums.BackgroundTaskStatus.InProgress, Fourth.StarChef.Invariables.Enums.BackgroundTaskStatus.Completed, string.Empty).Result; Logger.Info($"Task {t.Id} Processing Complete"); } catch (Exception ex) { var res = taskManager.UpdateTaskStatus(t.Id, null, Fourth.StarChef.Invariables.Enums.BackgroundTaskStatus.Failed, ex.Message).Result; } } } else { Logger.Warn($"OrganizationId {databaseId} not found"); } Logger.Info($"{GetType().Name} - [Common Background Tasks] Finishing job for organization with database id: {databaseId}"); } catch (Exception ex) { var errorMessage = new StringBuilder(); errorMessage.AppendFormat($"{GetType().Name} - [Common Background Tasks] error for organization with database id: {databaseId} "); if (!string.IsNullOrEmpty(ex.Message)) { errorMessage.AppendFormat($"Exception message is: {ex.Message} "); } if (ex.InnerException != null && (!string.IsNullOrEmpty(ex.InnerException.Message))) { errorMessage.AppendFormat($"Inner Exception message is: {ex.InnerException.Message}"); } Logger.Error(errorMessage.ToString()); } }
// GET: /Organization/Details/5 public ActionResult Details(int?id) { if (Session["LogedUserID"] != null) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Organization organization = _organizationManager.GetById((int)id); if (organization == null) { return(HttpNotFound()); } return(View(organization)); } return(RedirectToAction("Login", "Admin")); }
public ActionResult OrganizationList() { if (Session["username"] == null) { return(RedirectToAction("HomePage", "Home")); } int id = Convert.ToInt32(Request.QueryString["delete"]); if (id != 0) { Organization organization = organizationManager.GetById(id); organizationManager.Delete(organization); return(RedirectToAction("OrganizationList")); } return(View()); }
public JsonResult GetOrganizationById(int?id) { Organization organization = null; if (id != null) { organization = _organizationManager.GetById((int)id); } return(Json(organization, JsonRequestBehavior.AllowGet)); }
public ActionResult Delete(int id) { var organization = _manager.GetById(id); try { if (_manager.Remove(organization)) { ViewBag.Msg = "Deleted successfully!"; return(View("Search")); } } catch (Exception exception) { //return HttpNotFound(); ViewBag.Msg = exception.GetType().ToString(); } return(View("Search")); }
public string GetOrganizationShortName(Branch branch) { Organization organization = _organizationManager.GetById((long)branch.OrganizationId); return(organization.ShortName + "_" + branch.ShortName); }