Ejemplo n.º 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("عملیات تایید با موفقیت انجام گردید");
        }
        public List <string> SendWorkHours(WorkHourJson workHourJson)//JObject jsonObject
        {
            UnitOfWork       uow         = new UnitOfWork();
            UserManager      userManager = new UserManager(uow);
            TimeSheetManager WHM         = new TimeSheetManager(uow);
            User             currUser    = new UserHelper().GetCurrent();
            Validations      validate    = new Validations();
            var           WorkHours      = WHM.GetBydateAndUserId(workHourJson.Date, currUser.ID);
            List <string> result         = new List <string>();

            foreach (var wh in WorkHours.ToList())
            {
                if (wh.WorkflowStage.IsFirst)
                {
                    result = validate.ValidateRegisterWorkHour(wh);
                    if (result.Count() > 0)
                    {
                        return(result);
                    }

                    WHM.SendWorkHour(wh);
                    HistoryUtilities.RegisterSendHistory(wh);
                    result.Add("عملیات ارسال کارکرد ها با موفقیت انجام گردید");
                }
            }

            return(result);
        }
        public List <string> SaveWorkHours(WorkHourJson workHourJson)
        {
            List <string> result = new List <string>();

            try
            {
                UnitOfWork       uow         = new UnitOfWork();
                UserManager      userManager = new UserManager(uow);
                TaskManager      taskManager = new TaskManager(uow);
                ProjectManager   prjManager  = new ProjectManager(uow);
                TimeSheetManager tsManager   = new TimeSheetManager(uow);
                Validations      validate    = new Validations();
                User             currUser    = new UserHelper().GetCurrent();
                WorkHour         workHour    = workHourJson.ToWorkHour();
                workHour.Task            = taskManager.GetByID(workHour.TaskID);
                workHour.TaskID          = workHour.Task.ID;
                workHour.Project         = prjManager.GetByID(workHourJson.ProjectID);
                workHour.ProjectId       = workHour.Project.ID;
                workHour.EmployeeID      = currUser.ID;
                workHour.Employee        = userManager.GetByID(currUser.ID);
                workHour.WorkflowStage   = new WorkflowManager(uow).FirstStage();
                workHour.WorkflowStageID = workHour.WorkflowStage.ID;
                workHour.Description     = workHourJson.Description;
                tsManager.SaveWorkHour(workHour);
                HistoryUtilities.RegisterSaveHistory(workHour);
            }

            catch (ValidationException ex)
            {
                result = ex.Errors;
            }
            return(result);
        }
Ejemplo n.º 5
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);
                }
            }
        }
        public string DenyWorkHour(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)
            {
                timeSheetManager.DenyWorkHour(item);
                HistoryUtilities.RegisterDenyHistory(data, item);
            }


            return("عملیات رد با موفقیت انجام گردید");
        }
Ejemplo n.º 7
0
        public IActionResult SaveHourlyMission(HourlyMission hourlyMission)
        {
            try
            {
                if (hourlyMission == null)
                {
                    throw new Exception("اطلاعات ماموریت ارسال نشده است");
                }
                var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName);

                HourlyMissionManager hm = new HourlyMissionManager(this._uow);
                //ProjectManager pm = new ProjectManager(this._uow);
                //UserManager um = new UserManager(this._uow);
                hourlyMission.UserID         = currentUser.ID;
                hourlyMission.OrganisationId = currentUser.OrganizationUnitID;

                //if (hourlyMission.ProjectID == Guid.Empty)
                hourlyMission.ProjectID = null;

                if (hourlyMission.ID == Guid.Empty)
                {
                    hm.Add(hourlyMission);
                }
                else
                {
                    hm.Edit(hourlyMission);
                }

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



                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(this.ReturnError(ex, "خطا در ذخیره ماموریت ساعتی"));
            }
        }
        public List <string> SendWorkHour(WorkHourJson workHourJson)//JObject jsonObject
        {
            UnitOfWork       uow         = new UnitOfWork();
            UserManager      userManager = new UserManager(uow);
            TimeSheetManager WHM         = new TimeSheetManager(uow);
            User             currUser    = new UserHelper().GetCurrent();
            Validations      validate    = new Validations();
            var           WorkHour       = WHM.GetByID(workHourJson.ID);
            List <string> result         = new List <string>();

            result = validate.ValidateRegisterWorkHour(WorkHour);

            if (result.Count() == 0)
            {
                if (WorkHour.WorkflowStage.IsFirst)
                {
                    WHM.SendWorkHour(WorkHour);
                    HistoryUtilities.RegisterSendHistory(WorkHour);
                    result.Add("ارسال کارکرد با موفقیت انجام گردید");
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
        public IActionResult SaveDailyLeave(DailyLeave dailyLeave)
        {
            try
            {
                if (dailyLeave == null)
                {
                    throw new Exception("اطلاعات مرخصی ارسال نشده است");
                }
                if (string.IsNullOrEmpty(dailyLeave.PersianDateFrom))
                {
                    throw new Exception("تاریخ شروع ارسال نشده است");
                }
                if (string.IsNullOrEmpty(dailyLeave.PersianDateTo))
                {
                    throw new Exception("تاریخ پایان ارسال نشده است");
                }

                var currentUser = new UserHelper().GetCurrent(this._uow, this.UserName);

                DailyLeaveManager dlm = new DailyLeaveManager(this._uow);
                ProjectManager    pm  = new ProjectManager(this._uow);
                UserManager       um  = new UserManager(this._uow);
                dailyLeave.UserID         = currentUser.ID;
                dailyLeave.OrganisationId = currentUser.OrganizationUnitID;

                if (dailyLeave.ProjectID == Guid.Empty)
                {
                    dailyLeave.ProjectID = null;
                }
                if (dailyLeave.SuccessorID == Guid.Empty)
                {
                    dailyLeave.SuccessorID = null;
                }

                if (dailyLeave.ID == Guid.Empty)
                {
                    dlm.Add(dailyLeave);
                }
                else
                {
                    dlm.Edit(dailyLeave);
                }

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


                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(this.ReturnError(ex, "خطا در ذخیره مرخصی روزانه"));
            }
        }