Exemple #1
0
        private void approveDenyDailyLeave(bool isApprove, Domain.User currentUser, TimeSheetManager timeSheetManager, DailyLeaveManager dlm, DailyLeave dailyLeave, string userDescription)
        {
            if (dailyLeave.WorkflowStage.Type == "Final")
            {
                throw new Exception("هم اکنون تایید نهایی می باشد");
            }
            var isManager = timeSheetManager.IsUserOrganisationMnager(dailyLeave.UserID, currentUser);

            if (dailyLeave.WorkflowStage.Type == "Manager" && !isManager)
            {
                throw new Exception("آیتم منتظر تایید مدیر ستادی است");
            }

            var data = new ApproveAndDenyJson()
            {
                id              = dailyLeave.ID.ToString(),
                date            = DateTime.Now,
                description     = userDescription,
                workflowStageID = dailyLeave.WorkflowStageID
            };

            if (isApprove)
            {
                dlm.Approve(dailyLeave);
                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);
            }
            else
            {
                dlm.Deny(dailyLeave);
                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);
            }
        }
        public string ApproveWorkHour(ApproveAndDenyJson data)
        {
            IEnumerable <WorkHour> result;
            UnitOfWork             uow = new UnitOfWork();

            TimeSheetManager timeSheetManager = new TimeSheetManager(uow);

            result = timeSheetManager.GetByDateAndTaskId(data.date, Guid.Parse(data.id)).ToList();


            foreach (var item in result)
            {
                if (timeSheetManager.IsUserOrganisationMnager(item, User.Identity.Name) && timeSheetManager.IsUserProjectMnager(item, User.Identity.Name) && item.WorkflowStage.Order == 2)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        timeSheetManager.ApproveWorkHour(item);
                        HistoryUtilities.RegisterApproveHistory(data, item);
                    }
                }
                else
                {
                    timeSheetManager.ApproveWorkHour(item);
                    HistoryUtilities.RegisterApproveHistory(data, item);
                }
            }


            return("عملیات تایید با موفقیت انجام گردید");
        }
Exemple #3
0
        private void approveDenyWorkhour(bool isApprove, Domain.User currentUser, TimeSheetManager timeSheetManager, WorkHour item, string userDescription)
        {
            if (item.WorkflowStage.Type == "Final")
            {
                throw new Exception("هم اکنون تایید نهایی می باشد");
            }

            var data = new ApproveAndDenyJson()
            {
                id          = item.ID.ToString(),
                date        = DateTime.Now,
                description = userDescription
            };

            var isManager        = timeSheetManager.IsUserOrganisationMnager(item.EmployeeID, currentUser);
            var isProjectManager = timeSheetManager.IsUserProjectMnager(item, currentUser.UserName);


            if (isManager && isProjectManager)
            {
                if (isApprove)
                {
                    for (int i = item.WorkflowStage.Order; i < 4; i++)
                    {
                        timeSheetManager.ApproveWorkHour(item);
                        HistoryUtilities.RegisterApproveHistory(data, item, this._uow, currentUser);
                    }
                }
                else
                {
                    for (int i = item.WorkflowStage.Order; i > 1; i++)
                    {
                        timeSheetManager.DenyWorkHour(item);
                        HistoryUtilities.RegisterDenyHistory(data, item, this._uow, currentUser);
                    }
                }
            }
            else
            {
                if (item.WorkflowStage.Type == "Manager" && !isManager)
                {
                    throw new Exception("آیتم منتظر تایید مدیر ستادی است");
                }
                if (item.WorkflowStage.Type == "ProjectManager" && !isProjectManager)
                {
                    throw new Exception("آیتم منتظر تایید مدیر پروژه است");
                }
                if (isApprove)
                {
                    timeSheetManager.ApproveWorkHour(item);
                    HistoryUtilities.RegisterApproveHistory(data, item, this._uow, currentUser);
                }
                else
                {
                    timeSheetManager.DenyWorkHour(item);
                    HistoryUtilities.RegisterDenyHistory(data, item, this._uow, currentUser);
                }
            }
        }