public ActionResult Initiate(int id, String from) { if (getCurrentUser() == null) { return(RedirectToAction("Index", "Login")); } else { Documents documents = idocuments.GetDocument(1); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); int nextStatus = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus); WorkflowTracker workflowTracker = new WorkflowTracker(); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = nextStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "Initiate"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = nextStatus; ioverTimeRequest.Update(overTimeRequest); return(RedirectToAction(from)); } }
public Result JQ_Reject(int id, string reason) { Result result = new Result(); try { OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); WorkflowTracker workflowTracker = new WorkflowTracker(); Documents documents = idocuments.GetDocument(1); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, getCurrentUser().u_role_id); int previousStatus = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int previousStatusByRole = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, rolePriority); if (previousStatus == previousStatusByRole) { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, previousStatus); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = previousStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "rejected"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = previousStatus; ioverTimeRequest.Update(overTimeRequest); if (!reason.Equals("")) { Insight insight = new Insight(); insight.in_fun_doc_id = overTimeRequest.rq_id; insight.in_doc_id = overTimeRequest.rq_doc_id; insight.in_remarks = reason; insight.in_cre_by = getCurrentUser().u_id; insight.in_cre_date = DateTime.Now; iinsight.Add(insight); } result.Message = "Success"; } else { result.Message = "Already Approved Or You Have No Privilege to Approve"; } } catch (Exception ex) { result.Message = ex.Message + " " + ex.InnerException; } return(result); }
public Result JQ_Approve(int id) { Result result = new Result(); try { Documents documents = idocuments.GetDocument(1); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); int nextStatus = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, getCurrentUser().u_role_id); int nextStatusbyUser = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, rolePriority); int MinofWorkflow = iworkflowDetail.getMinOfWorkFlow(overTimeRequest.rq_workflow_id); if (nextStatus == nextStatusbyUser) { if (overTimeRequest.rq_hold_yn == "Y") { result.Message = "This Document is Hold by Someone,Click Hold Details For more Information"; return(result); } else { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus); WorkflowTracker workflowTracker = new WorkflowTracker(); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = nextStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "Approved"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = nextStatus; ioverTimeRequest.Update(overTimeRequest); result.Message = "Success"; } } else { result.Message = "Already Approved Or You Have No Privilege to Approve"; } } catch (Exception ex) { result.Message = ex.Message + " " + ex.InnerException; } return(result); }
public ActionResult Reject(int id, string reason) { if (getCurrentUser() == null) { return(RedirectToAction("Index", "Login")); } else { OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); WorkflowTracker workflowTracker = new WorkflowTracker(); Documents documents = idocuments.GetDocument(1); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, getCurrentUser().u_role_id); int previousStatus = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int previousStatusByRole = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, rolePriority); if (previousStatus == previousStatusByRole) { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, previousStatus); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = previousStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "rejected"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = previousStatus; ioverTimeRequest.Update(overTimeRequest); if (!reason.Equals("")) { Insight insight = new Insight(); insight.in_fun_doc_id = overTimeRequest.rq_id; insight.in_doc_id = overTimeRequest.rq_doc_id; insight.in_remarks = reason; insight.in_cre_by = getCurrentUser().u_id; insight.in_cre_date = DateTime.Now; iinsight.Add(insight); } return(RedirectToAction("Approval")); } return(RedirectToAction("Approval")); } }
public ActionResult Approve(int id, String from) { if (getCurrentUser() == null) { return(RedirectToAction("Index", "Login")); } else { Documents documents = idocuments.GetDocument(1); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); int nextStatus = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, getCurrentUser().u_role_id); int nextStatusbyUser = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, rolePriority); int MinofWorkflow = iworkflowDetail.getMinOfWorkFlow(overTimeRequest.rq_workflow_id); if (nextStatus == nextStatusbyUser) { if (overTimeRequest.rq_hold_yn == "Y") { TempData["errorMessage"] = ("This Document is Hold by Someone,Click Hold Details For more Information"); return(RedirectToAction(nameof(Approval))); } else { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus); WorkflowTracker workflowTracker = new WorkflowTracker(); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = nextStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "Approved"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = nextStatus; ioverTimeRequest.Update(overTimeRequest); return(RedirectToAction(from)); } } else { return(RedirectToAction(from)); } } }
public ActionResult EndWork(int id, String from) { if (getCurrentUser() == null) { return(RedirectToAction("Index", "Login")); } else { try { Documents documents = idocuments.GetDocument(1); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); int nextStatus = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, 0); WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus); if (overTimeRequest.rq_status != nextStatus) { WorkflowTracker workflowTracker = new WorkflowTracker(); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = getCurrentUser().u_role_id; workflowTracker.wt_role_description = getCurrentUser().u_role_description; workflowTracker.wt_status_to = nextStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "WorkDone"; workflowTracker.wt_cre_by = getCurrentUser().u_id; workflowTracker.wt_cre_by_name = getCurrentUser().u_name + "-" + getCurrentUser().u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = nextStatus; overTimeRequest.rq_end_time = DateTime.Now; ioverTimeRequest.Update(overTimeRequest); } return(RedirectToAction(nameof(Start))); } catch (Exception ex) { TempData["errorMessage"] = ex.Message; return(RedirectToAction(nameof(Start))); } } }
public void Remove(int id) { WorkflowTracker workflowTracker = db.workflowTrackers.Find(id); db.workflowTrackers.Remove(workflowTracker); }
public WorkflowTracker GetWorkflowTracker(int id) { WorkflowTracker workflowTracker = db.workflowTrackers.Find(id); return(workflowTracker); }
public void Add(WorkflowTracker workflowTracker) { db.workflowTrackers.Add(workflowTracker); db.SaveChanges(); }
public string Reject(int id, String reason, int u_id) { Result result = new Result(); try { if (reason != null) { User user = iuser.GetUser(u_id); Role role = irole.GetRole(user.u_role_id); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); WorkflowTracker workflowTracker = new WorkflowTracker(); Documents documents = idocuments.GetDocument(1); int previousStatus = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, role.r_id); int previousStatusByRole = iworkflowDetail.getPreviousWorkflow(overTimeRequest.rq_workflow_id, rolePriority); if (previousStatus == previousStatusByRole) { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, previousStatus); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = user.u_role_id; workflowTracker.wt_role_description = role.r_description; workflowTracker.wt_status_to = previousStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "rejected"; workflowTracker.wt_cre_by = user.u_id; workflowTracker.wt_cre_by_name = user.u_name + "-" + user.u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = previousStatus; ioverTimeRequest.Update(overTimeRequest); if (!reason.Equals("")) { Insight insight = new Insight(); insight.in_fun_doc_id = overTimeRequest.rq_id; insight.in_doc_id = overTimeRequest.rq_doc_id; insight.in_remarks = reason; insight.in_cre_by = user.u_id; insight.in_cre_date = DateTime.Now; iinsight.Add(insight); } result.Objects = null; result.Message = "Success"; return(JsonConvert.SerializeObject(result)); } else { result.Objects = null; result.Message = "You have no priviage"; return(JsonConvert.SerializeObject(result)); } } else { result.Objects = null; result.Message = "Please enter Remarks"; return(JsonConvert.SerializeObject(result)); } } catch (Exception ex) { /* var st = new StackTrace(ex, true); * // Get the top stack frame * var frame = st.GetFrame(0); * // Get the line number from the stack frame * var line = frame.GetFileLineNumber();*/ result.Objects = null; result.Message = ex.Message; return(JsonConvert.SerializeObject(result)); } }
public string Approve(int id, String reason, int u_id) { // reason = ""; Result result = new Result(); try { User user = iuser.GetUser(u_id); Role role = irole.GetRole(user.u_role_id); Documents documents = idocuments.GetDocument(1); OverTimeRequest overTimeRequest = ioverTimeRequest.GetOverTimeRequest(id); WorkflowDetail workflow = iworkflowDetail.GetWorkFlowDetail(overTimeRequest.rq_workflow_id); int nextStatus = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, overTimeRequest.rq_status); int rolePriority = iworkflowDetail.getPriorityByRole(overTimeRequest.rq_workflow_id, role.r_id); int nextStatusbyUser = iworkflowDetail.getNextWorkflow(overTimeRequest.rq_workflow_id, rolePriority); int MinofWorkflow = iworkflowDetail.getMinOfWorkFlow(overTimeRequest.rq_workflow_id); if (nextStatus == nextStatusbyUser) { if (overTimeRequest.rq_hold_yn == "Y") { result.Objects = null; result.Message = "You have No privilage to unHold"; return(JsonConvert.SerializeObject(result)); } else { WorkflowDetail workflowDetail = iworkflowDetail.getWorkflowDetlByWorkflowCodeAndPriority(overTimeRequest.rq_workflow_id, nextStatus); WorkflowTracker workflowTracker = new WorkflowTracker(); workflowTracker.wt_doc_id = documents.dc_id; workflowTracker.wt_fun_doc_id = overTimeRequest.rq_id; workflowTracker.wt_status = overTimeRequest.rq_status; workflowTracker.wt_workflow_id = overTimeRequest.rq_workflow_id; workflowTracker.wt_role_id = user.u_role_id; workflowTracker.wt_role_description = role.r_description; workflowTracker.wt_status_to = nextStatus; workflowTracker.wt_assign_role = workflowDetail.wd_role_id; workflowTracker.wt_assigned_role_name = workflowDetail.wd_role_description; workflowTracker.wt_approve_status = "Approved"; workflowTracker.wt_cre_by = user.u_id; workflowTracker.wt_cre_by_name = user.u_name + "-" + user.u_full_name; workflowTracker.wt_cre_date = DateTime.Now; iworkflowTracker.Add(workflowTracker); overTimeRequest.rq_status = nextStatus; ioverTimeRequest.Update(overTimeRequest); result.Objects = null; result.Message = "Success"; return(JsonConvert.SerializeObject(result)); } } else { result.Objects = null; result.Message = "You have No privilage to Approve"; return(JsonConvert.SerializeObject(result)); } } catch (Exception ex) { var st = new StackTrace(ex, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); result.Objects = null; result.Message = ex.Message + "" + line; return(JsonConvert.SerializeObject(result)); } }