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("عملیات تایید با موفقیت انجام گردید"); }
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 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 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, "خطا در ذخیره مرخصی روزانه")); } }