public void Handle(RejectPromotionDraftCommand command) { Editor editor = _userInRoleRepository.GetEditor(_currentUserProvider.GetUserId().Value); ApprovalProcess process = _approvalRepository.GetApprovalProcess(command.ApprovalProcessId); process.RejectFor(editor, command.Reason); }
public int AddApprovalProcess(ApprovalProcess approvalProcess) { var result = ApprovalProcess.AddApprovalProcess(approvalProcess); if (result > 0) { ApprovalActivity.AddApprovalActivity(); } return(result); }
public async Task <ActionResult> Reject(int ingredientId) { var ingredient = await _ingredientService.Get(new EntityDto(ingredientId)); var wf = new ApprovalProcess(_ingredientService, ingredient); wf.Reject(ingredient); return(new HttpStatusCodeResult(HttpStatusCode.Accepted)); }
/// <summary> /// 修改流程 /// </summary> /// <param name="food"></param> /// <returns></returns> public int UpdateApprovalProcess(ApprovalProcess approvalProcess) { using (OracleConnection conn = DapperHelper.GetConnString()) { conn.Open(); string sql = @"update ApprovalProcess set name=:name,isallowmodity=:isallowmodity,isallowversion=:isallowversion,creator=:creator where id=:id"; var result = conn.Execute(sql, approvalProcess); return(result); } }
/// <summary> /// 添加审批 /// </summary> /// <param name="collect"></param> /// <returns></returns> public int AddApprovalProcess(ApprovalProcess approvalProcess) { using (OracleConnection conn = DapperHelper.GetConnString()) { conn.Open(); string sql = @"insert into ApprovalProcess(name,isallowmodity,isallowversion,creator,createtime) values(:name,:isallowmodity,:isallowversion,:creator,:createtime)"; approvalProcess.CreateTime = DateTime.Now; int result = conn.Execute(sql, approvalProcess); return(result); } }
public bool InsertApprovalProcess(ApprovalProcess approvalProcess) { try { _omsAccessor.Insert(approvalProcess); _omsAccessor.SaveChanges(); return(true); } catch (Exception e) { throw e; } }
public IHttpActionResult FnStartNewProcessTier(ApprovalProcess approvalProcessModel) { var result = _clsApproval.FnStartNewProcessTier(approvalProcessModel); if (result != null) { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK); return(Ok(result)); } else { HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.InternalServerError); return(Ok()); } }
public IActionResult AddApprovalProcess(string name, string ids) { if (IsNullOrEmpty(name) || IsNullOrEmpty(ids)) { return(Error()); } var userIds = ids.Split(","); var l = 1; List <ApprovalProcessDetail> list = new List <ApprovalProcessDetail>(); foreach (var it in userIds) { var uId = Convert.ToInt32(it); ApprovalProcessDetail approvalProcessDetail = new ApprovalProcessDetail { UserId = uId, Sort = l, CreatedBy = WorkContext.CurrentUser.Id, ModifiedBy = WorkContext.CurrentUser.Id, ModifiedTime = DateTime.Now, User = _userService.GetById(uId) }; list.Add(approvalProcessDetail); l++; } ApprovalProcess approvalProcess = new ApprovalProcess { Name = name, CreatedBy = WorkContext.CurrentUser.Id, ModifiedBy = WorkContext.CurrentUser.Id, ModifiedTime = DateTime.Now, ApprovalProcessDetail = list }; _orderService.InsertApprovalProcess(approvalProcess); var data = approvalProcess.ToModel(); return(Success(data)); }
public ResultViewModel FnStartNewProcessTier(ApprovalProcess model) { var result = new ResultViewModel(); try { using (var client = new HttpClient()) { client.BaseAddress = new Uri(ConfigurationManager.AppSettings["SitePathAPI"]); var responseTask = client.PostAsJsonAsync <ApprovalProcess>("FnStartNewProcessTier", model); responseTask.Wait(); var responseResult = responseTask.Result; if (responseResult.IsSuccessStatusCode) { var readTask = responseResult.Content.ReadAsAsync <ResultViewModel>(); readTask.Wait(); result = readTask.Result; } else { glog.Debug("FnStartNewProcessTier: Exit"); result.Status = 0; result.Message = "An error occurred when updating approval process!"; } } return(result); } catch (Exception ex) { glog.Error("FnStartNewProcessTier Exception: " + ex.Message + ex.InnerException); return(result); throw; } }
public int DeleteApprovalProcess(int id) { var result = ApprovalProcess.DeleteApprovalProcess(id); return(result); }
/// <summary> /// 修改审批流程 /// </summary> /// <param name="approvalProcess"></param> /// <returns></returns> public int UpdateApprovalProcess(ApprovalProcess approvalProcess) { throw new NotImplementedException(); }
public static ApprovalProcessModel ToModel(this ApprovalProcess entity) { return(Mapper.Map <ApprovalProcess, ApprovalProcessModel>(entity)); }
public async Task PutEntity(ApprovalProcess entity) { await Repository.PutEntity(entity); }
public ResultViewModel FnStartNewProcessTier(ApprovalProcess model) { var result = new ResultViewModel(); using (var db = new MainDbContext()) { glog.Debug("FnStartNewProcessTier: Entry"); try { int tier = 0; string ApprovingOfficer; if (model.ApprovalHeaderID != 0) { tier = db.Sys_Approval.Where(w => w.ApprovalHeaderID == model.ApprovalHeaderID).Select(s => s.Tier).Max() + 1; } else { tier = db.Sys_Approval.Where(w => w.ApprovalName == model.ApprovalName && w.ModuleID == model.ModuleID).Select(s => s.Tier).Max() + 1; } var PrimaryOfficer = db.Sys_ApprovalDetail.Where(w => w.ApprovalDetailID == model.ApprovalDetailID).Select(s => s.PrimaryApprovingOfficer).FirstOrDefault(); var SecondoryOfficer = db.Sys_ApprovalDetail.Where(w => w.ApprovalDetailID == model.ApprovalDetailID).Select(s => s.SecondaryApprovingOfficer).FirstOrDefault(); if (FnGetApprovingOfficerAvailbility(PrimaryOfficer)) { if (FnGetApprovingOfficerAvailbility(SecondoryOfficer)) { ApprovingOfficer = PrimaryOfficer; } else { ApprovingOfficer = SecondoryOfficer; } } else { ApprovingOfficer = PrimaryOfficer; } var Id = 0; if (model.CurrentTier == 1) { var ApprovalProcess = new Approval_Process() { ApprovalHeaderID = model.ApprovalHeaderID, CompositeKey1 = model.RefNo, Status = "P", CreatedDate = DateTime.Now, CreatedBy = model.UserName, }; db.Approval_Process.Add(ApprovalProcess); db.Entry(ApprovalProcess).State = System.Data.Entity.EntityState.Added; var ProcId = db.SaveChanges(); var ApprovalProcessDtl = new Approval_ProcessDetail() { ApprovalProcessID = Id, Tier = tier, AssignedTo = ApprovingOfficer, CreatedDate = DateTime.Now, CreatedBy = model.UserName, }; db.Approval_ProcessDetail.Add(ApprovalProcessDtl); db.Entry(ApprovalProcessDtl).State = System.Data.Entity.EntityState.Added; Id = db.SaveChanges(); } else { var approvalProcess = db.Approval_Process.Where(w => w.ApprovalHeaderID == model.ApprovalHeaderID).FirstOrDefault(); var ApprovalProcessDtl = new Approval_ProcessDetail() { ApprovalProcessID = approvalProcess.ApprovalProcessID, Tier = model.CurrentTier + 1, AssignedTo = ApprovingOfficer, CreatedDate = DateTime.Now, CreatedBy = model.UserName, ApprovedDate = DateTime.Now, ApprovedBy = model.UserName }; db.Approval_ProcessDetail.Add(ApprovalProcessDtl); db.Entry(ApprovalProcessDtl).State = System.Data.Entity.EntityState.Added; Id = db.SaveChanges(); } if (Id > 0) { result.Status = 1; result.Message = "Data has been approved!"; } else { result.Status = 0; result.Message = "An error occurred when updating approval process!"; } glog.Debug("FnStartNewProcessTier: Exit"); return(result); } catch (Exception ex) { glog.Error("FnStartNewProcessTier Exception: " + ex.Message + ex.InnerException); result.Status = 0; result.Message = "Please contact MIS, error: " + ex.Message; return(result); } } }
public async System.Threading.Tasks.Task <ActionResult> AddApprovalProcess(ApprovalProcessViewModel approvers) { ApplicationDbContext context = new ApplicationDbContext(); if (!ModelState.IsValid) { var UserManager = new UserManager <ApplicationUser>(new UserStore <ApplicationUser>(context)); var RoleManager = new RoleManager <IdentityRole>(new RoleStore <IdentityRole>(context)); List <ApplicationUser> users = new List <ApplicationUser>(); var role = await RoleManager.FindByIdAsync("3a6e2158-8b77-4ff8-9c15-66a48e00248e"); List <ApplicationUser> employees = UserManager.Users.ToList(); foreach (var user in UserManager.Users.ToList()) { if (await UserManager.IsInRoleAsync(user.Id, role.Name)) { users.Add(user); } } ApprovalProcessViewModel model = new ApprovalProcessViewModel { ApproverList = users, Employess = employees }; return(View(model)); } else { List <String> Approvers = approvers.Approver; List <int> Levels = approvers.Level; string appLevels = ""; ApprovalProcess newProcess = new ApprovalProcess(); newProcess.CreatedAt = DateTime.Now; newProcess.UserId = approvers.Employee; int app = 0; foreach (var level in Levels) { Level newLevel = new Level(); string level_approvers = ""; newLevel.CreatedAt = DateTime.Now; for (var i = 0; i < level; i++) { if (level_approvers == "") { level_approvers += Approvers[app]; } else { level_approvers += "," + Approvers[app]; } app++; } newLevel.Approvers = level_approvers; context.Levels.Add(newLevel); context.SaveChanges(); if (appLevels == "") { appLevels += newLevel.Id.ToString(); } else { appLevels += "," + newLevel.Id.ToString(); } } newProcess.Level = appLevels; context.ApprovalProcesses.Add(newProcess); context.SaveChanges(); return(Content(Approvers[0])); } }
public ResultViewModel FnApproveRejectEvent(ApprovalSpotterDetails model, string UserName) { string userMail = ""; int maxTier = 0, currentTier = 0; glog.Debug("InsertSpotterData: Entry"); var result = new ResultViewModel(); using (var db = new MainDbContext()) { using (var transaction = db.Database.BeginTransaction()) { try { userMail = db.Sys_Users.FirstOrDefault(x => x.Name == UserName).Email; bool IsSave = false; if (!string.IsNullOrEmpty(model.RejectReason)) { var RejectedAmount = model.OutstandingFee.Select(s => s.SpotterAmt).Sum(); var ApprovedAmount = model.SpotterSummary.Amount - RejectedAmount; if (FnUpdateCurrentApproval(db, model.IsAllCheck, model.ApprovalProcessID, model.RejectReason, userMail)) { if (FnUpdateSpotterMaster(db, model.IsAllCheck, model.SpotterSummary.SpotterRefNumber, ApprovedAmount, model.RejectReason, userMail)) { if (FnUpdateSpotterDetail(db, model.OutstandingFee, model.ApprovalProcessDetailID, model.RejectReason, userMail)) { if (FnUpdateContractSpotter(db, model.OutstandingFee, model.ApprovalProcessDetailID, model.RejectReason, userMail)) { IsSave = true; } else { IsSave = false; } } else { IsSave = false; } } else { IsSave = false; } } else { IsSave = false; } } else { maxTier = db.Sys_Approval.Where(w => w.ApprovalHeaderID == model.ApprovalHeaderID).Select(s => s.Tier).FirstOrDefault(); currentTier = db.Approval_ProcessDetail.Where(w => w.ApprovalProcessID == model.ApprovalProcessID).Select(s => s.Tier).Max(); var ApprovedAmount = model.OutstandingFee.Select(s => s.SpotterAmt).Sum(); if (currentTier == maxTier) { if (FnUpdateCurrentApproval(db, model.IsAllCheck, model.ApprovalProcessID, model.RejectReason, userMail)) { if (FnUpdateSpotterMaster(db, model.IsAllCheck, model.SpotterSummary.SpotterRefNumber, ApprovedAmount, model.RejectReason, userMail)) { if (FnUpdateSpotterDetail(db, model.OutstandingFee, model.ApprovalProcessDetailID, model.RejectReason, userMail)) { if (FnUpdateContractSpotter(db, model.OutstandingFee, model.ApprovalProcessDetailID, model.RejectReason, userMail)) { IsSave = true; } else { IsSave = false; } } else { IsSave = false; } } else { IsSave = false; } } else { IsSave = false; } } else { var sysApproval = db.Sys_Approval.Where(w => w.ApprovalHeaderID == model.ApprovalHeaderID).FirstOrDefault(); ApprovalProcess approvalProcessModel = new ApprovalProcess() { ApprovalDetailID = model.ApprovalProcessID, CurrentTier = currentTier, ApprovalHeaderID = model.ApprovalHeaderID, ModuleID = sysApproval.ModuleID, ApprovalName = sysApproval.ApprovalName, RefNo = model.SpotterSummary.SpotterRefNumber, UserName = userMail }; result = FnStartNewProcessTier(approvalProcessModel); if (result.Status == 1) { IsSave = true; } else { IsSave = false; } } } if (IsSave) { transaction.Commit(); string EmpEmailId = string.Empty; var employeeCode = ""; if (currentTier == maxTier) { employeeCode = db.Sys_Users.FirstOrDefault(x => x.Name == UserName).EmployeeCode; EmpEmailId = GetEmailByEmpCode(employeeCode); } else { employeeCode = db.Approval_ProcessDetail.FirstOrDefault(x => x.ApprovalProcessID == model.ApprovalProcessID).AssignedTo; EmpEmailId = GetEmailByEmpCode(employeeCode); } var isEmailSend = SendEmailNotificationAPI(model, EmpEmailId, UserName, userMail, currentTier, maxTier, employeeCode); result.Status = 1; if (string.IsNullOrEmpty(model.RejectReason)) { result.Message = "Data has been approved!"; } else { result.Message = "Data has been rejected!"; } } else { transaction.Rollback(); result.Status = 0; result.Message = "An error occurred when updating approval process"; } } catch (Exception ex) { glog.Error("FnApproveRejectEvent Exception: " + ex.Message + ex.InnerException); result.Status = 0; result.Message = "Please contact MIS, error: " + ex.Message; transaction.Rollback(); } finally { transaction.Dispose(); } glog.Debug("FnApproveRejectEvent: Exit"); return(result); } } }
public List <ApprovalProcess> GetApprovalProcessByID(int id) { var result = ApprovalProcess.GetApprovalProcessByID(id); return(result); }
public int UpdateApprovalProcess(ApprovalProcess approvalProcess) { var result = ApprovalProcess.UpdateApprovalProcess(approvalProcess); return(result); }
public async Task <object> GetSingleEntity(int Id) { ApprovalProcess entity = await Repository.GetSingelEntity(Id); return(Ok(entity)); }
public List <ApprovalProcess> GetApprovalProcess() { var approvalProcessList = ApprovalProcess.GetApprovalProcess(); return(approvalProcessList); }
public void Store(ApprovalProcess approvalProcess) { _context.ApprovalProcesses.Add(approvalProcess); }