Exemplo n.º 1
0
        public void Handle(RejectPromotionDraftCommand command)
        {
            Editor          editor  = _userInRoleRepository.GetEditor(_currentUserProvider.GetUserId().Value);
            ApprovalProcess process = _approvalRepository.GetApprovalProcess(command.ApprovalProcessId);

            process.RejectFor(editor, command.Reason);
        }
Exemplo n.º 2
0
        public int AddApprovalProcess(ApprovalProcess approvalProcess)
        {
            var result = ApprovalProcess.AddApprovalProcess(approvalProcess);

            if (result > 0)
            {
                ApprovalActivity.AddApprovalActivity();
            }
            return(result);
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 /// <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);
     }
 }
Exemplo n.º 5
0
 /// <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);
     }
 }
Exemplo n.º 6
0
 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());
            }
        }
Exemplo n.º 8
0
        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));
        }
Exemplo n.º 9
0
        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;
            }
        }
Exemplo n.º 10
0
        public int DeleteApprovalProcess(int id)
        {
            var result = ApprovalProcess.DeleteApprovalProcess(id);

            return(result);
        }
Exemplo n.º 11
0
 /// <summary>
 /// 修改审批流程
 /// </summary>
 /// <param name="approvalProcess"></param>
 /// <returns></returns>
 public int UpdateApprovalProcess(ApprovalProcess approvalProcess)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 12
0
 public static ApprovalProcessModel ToModel(this ApprovalProcess entity)
 {
     return(Mapper.Map <ApprovalProcess, ApprovalProcessModel>(entity));
 }
Exemplo n.º 13
0
 public async Task PutEntity(ApprovalProcess entity)
 {
     await Repository.PutEntity(entity);
 }
Exemplo n.º 14
0
        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);
                }
            }
        }
Exemplo n.º 15
0
        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]));
            }
        }
Exemplo n.º 16
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);
                }
            }
        }
Exemplo n.º 17
0
        public List <ApprovalProcess> GetApprovalProcessByID(int id)
        {
            var result = ApprovalProcess.GetApprovalProcessByID(id);

            return(result);
        }
Exemplo n.º 18
0
        public int UpdateApprovalProcess(ApprovalProcess approvalProcess)
        {
            var result = ApprovalProcess.UpdateApprovalProcess(approvalProcess);

            return(result);
        }
Exemplo n.º 19
0
        public async Task <object> GetSingleEntity(int Id)
        {
            ApprovalProcess entity = await Repository.GetSingelEntity(Id);

            return(Ok(entity));
        }
Exemplo n.º 20
0
        public List <ApprovalProcess> GetApprovalProcess()
        {
            var approvalProcessList = ApprovalProcess.GetApprovalProcess();

            return(approvalProcessList);
        }
 public void Store(ApprovalProcess approvalProcess)
 {
     _context.ApprovalProcesses.Add(approvalProcess);
 }