public BaseResponse DelLeave(string id) { var userInfo = UserManager.getUserById(User.Identity.Name); var info = new LeaveInfo(id); info.Del(); UserLog.create("删除请假申请", "请假申请", userInfo, info); return(BaseResponse.getResult("删除成功")); }
/// <summary> /// 添加请假信息 /// </summary> /// <param name="leave"></param> /// <returns></returns> public ActionResult AddLeave(LeaveInfo leave) { db.LeaveInfo.Add(leave); if (db.SaveChanges() > 0) { return(Content("1")); } return(Content("0")); }
//获取审批人 private void BtnCUser_Click(object sender, EventArgs e) { //获取审批人 btn = sender; LeaveInfo Leave = new LeaveInfo(); DataTable table = Leave.GetConfirmUser(); PopList1.Groups.Clear(); PopListGroup poli = new PopListGroup(); PopList1.Groups.Add(poli); switch (((Button)sender).Name) { case "btnCUser": case "BtnCUser2": PopList1.MultiSelect = false; poli.Text = "审批人"; break; case "Btnccuser2": case "btnccuser1": PopList1.MultiSelect = true; poli.Text = "抄送人"; break; } //显示选择列表中key和values foreach (DataRow rowli in table.Rows) { poli.Items.Add(rowli["USER_ID"].ToString(), rowli["USER_ID"].ToString()); switch (((Button)sender).Name) { case "btnCUser": case "BtnCUser2": if (CUser.Trim().Length > 0) { if (CUser.Trim().ToUpper() == rowli["USER_ID"].ToString().Trim().ToUpper()) { PopList1.SetSelections(poli.Items[(poli.Items.Count - 1)]); } } break; case "Btnccuser2": case "btnccuser1": if (CCUser.Trim().Length > 0) { if (CCUser.Trim().ToUpper() == rowli["USER_ID"].ToString().Trim().ToUpper()) { PopList1.SetSelections(poli.Items[(poli.Items.Count - 1)]); } } break; } } PopList1.Show(); }
/// <summary> /// 根据工单的ID获取 其对应的具体的工单对象 /// </summary> /// <param name="id">工单的ID</param> /// <returns></returns> private BaseWorkOrder GetWorkOrderById(string id) { BaseWorkOrder info = new BaseWorkOrder(id); if (info.OrderType == WorkOrderType.请假申请) { info = new LeaveInfo(id); } return(info); }
/// <summary> /// /// </summary> /// <param name="employeeID"></param> /// <param name="reason"></param> /// <param name="leaveType"></param> /// <param name="description"></param> /// <param name="durationList"></param> /// <returns></returns> public LeaveInfo ApplyLeave(string employeeID, string reason, string leaveType, string description, List <TimeDurationInfo> durationList) { Log.Info(GlobalParams.StartApplyLeave); LeaveInfo result = null; try { result = LeaveBLL.ApplyLeave(employeeID, reason, leaveType, description, durationList); EmailConfig.SetRootPath(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath); Employee employee = EmployeeBLL.GetEmployeeByID(employeeID); if (result != null && EmailConfig.EmailTemplates.ContainsKey(EmailType.ApplyLeave.ToString())) { Log.Info(GlobalParams.StartMail); EmailContent ec = EmailConfig.EmailTemplates[EmailType.ApplyLeave.ToString()]; // {0} - Manager First Name // {1} - First Name // {2} - Hours // {3} - Leave Type // {4} - Reason // {5} - Description // {6} - Start // {7} - End // {8} - CARSAddress string emailBody = string.Format(ec.Body, employee.Manager.FirstName, employee.FirstName, result.Hours, result.Type.Name + " Leave", result.Reason, result.Description, result.FirstStartTime.ToString(EmailConfig.TimeFormatInEmail), result.LastEndTime.ToString(EmailConfig.TimeFormatInEmail), EmailConfig.CARSAddress); // {0} - First Name // {1} - Hours // {2} - Leave Type string emailTitle = string.Format(ec.Title, employee.FirstName, result.Hours, result.Type.Name + " Leave"); string employeeEmail = GetEmail(employee.Email); string managerEmail = GetEmail(employee.Manager.Email); List <string> ccList = new List <string>(); ccList.Add(employeeEmail); #if DEBUG managerEmail = "*****@*****.**"; #endif SendMail sender = new SendMail(managerEmail, ccList, EmailConfig.EmailAccount, emailBody, emailTitle, EmailConfig.Password, EmailConfig.Host); sender.Send(); Log.Info(GlobalParams.EndMail); } else { Log.Warn(GlobalParams.MailError); throw new Exception(GlobalParams.MailError); } } catch (Exception ex) { Log.Exception(ex.StackTrace); Log.Exception(ex.Message); throw ex; } Log.Info(GlobalParams.EndApplyLeave); return(result); }
/// <summary> /// Approve leave /// </summary> /// <param name="managerID">GUID of supervisor</param> /// <param name="leaveID">GUID of leave</param> /// <param name="status">Leave status</param> /// <returns>Approved leave</returns> public LeaveInfo ApproveLeave(string managerID, string leaveID, LeaveStatus status) { Log.Info(GlobalParams.StartApproveLeave); LeaveInfo result = null; try { result = LeaveBLL.ApproveLeave(managerID, leaveID, status); Employee employee = EmployeeBLL.GetEmployeeByID(result.FKSubmitEmployeeID.ToString()); Employee manager = EmployeeBLL.GetEmployeeByID(result.FKReportManagerID.ToString()); if (result != null) { Log.Info(GlobalParams.StartMail); EmailConfig.SetRootPath(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath); EmailContent ec = EmailConfig.EmailTemplates[EmailType.ApproveLeave.ToString()]; // {0} - First Name // {1} - Manager First Name // {2} - Hours // {3} - Leave Type // {4} - Reason // {5} - Description // {6} - Start // {7} - End // {8} - "Approved" // {9} - "" // {10} - CARSAddress string emailBody = string.Format(ec.Body, employee.FirstName, manager.FirstName, result.Hours, result.Type.Name + " Leave", result.Reason, result.Description, result.FirstStartTime.ToString(EmailConfig.TimeFormatInEmail), result.LastEndTime.ToString(EmailConfig.TimeFormatInEmail), "Approved", "", EmailConfig.CARSAddress); // {0} - First Name // {1} - Hours // {2} - Leave Type // {3} - Manager First Name // {4} - "Approved" string emailTitle = string.Format(ec.Title, employee.FirstName, result.Hours, result.Type.Name + " Leave", manager.FirstName, "Approved"); string employeeEmail = GetEmail(employee.Email); string managerEmail = GetEmail(employee.Manager.Email); #if DEBUG managerEmail = "*****@*****.**"; #endif List <string> ccList = new List <string>(); ccList.Add(managerEmail); SendMail sender = new SendMail(employeeEmail, ccList, EmailConfig.EmailAccount, emailBody, emailTitle, EmailConfig.Password, EmailConfig.Host); sender.Send(); Log.Info(GlobalParams.EndMail); } } catch (Exception ex) { Log.Exception(ex.StackTrace); Log.Exception(ex.Message); throw ex; } Log.Info(GlobalParams.EndApproveLeave); return(result); }
/// <summary> /// مانده مرخصی تا انتهای ماه جاری /// </summary> /// <param name="personId"></param> /// <param name="year"></param> /// <param name="month"></param> /// <param name="day"></param> /// <param name="minutes"></param> public void GetRemainLeaveToEndOfMonth(decimal personId, int year, int month, out int day, out int minutes) { try { PersonRepository prsRep = new PersonRepository(); DateTime endYear = new DateTime(); DateTime startYear = new DateTime(); DateTime endMonth = new DateTime(); if (BLanguage.CurrentSystemLanguage == LanguagesName.Parsi) { endMonth = Utility.ToMildiDate(String.Format("{0}/{1}/{2}", year, month, Utility.GetEndOfPersianMonth(year, month))); startYear = Utility.ToMildiDate(String.Format("{0}/1/1", year)); endYear = Utility.ToMildiDate(String.Format("{0}/12/{1}", year, Utility.GetEndOfPersianMonth(year, 12))); } else { endMonth = new DateTime(year, month, Utility.GetEndOfMiladiMonth(year, month)); startYear = new DateTime(year, 1, 1); endYear = new DateTime(year, 12, Utility.GetEndOfMiladiMonth(year, 12)); } day = 0; minutes = 0; try { Person prs = prsRep.GetById(personId, false); prs.CalcDateZone = new DateRange(startYear, endYear, startYear, endYear); prsRep.EnableEfectiveDateFilter(prs.ID, prs.CalcDateZone.FromDate, prs.CalcDateZone.ToDate, startYear, endYear, prs.CalcDateZone.FromDate.AddDays(-20), prs.CalcDateZone.ToDate.AddDays(+20)); LeaveInfo linfo = prs.GetRemainLeaveToDateUI(endMonth); day = linfo.Day; minutes = linfo.Minute; } catch (InvalidDatabaseStateException ex) { if (ex.FatalExceptionIdentifier == UIFatalExceptionIdentifiers.LeaveLCRDoesNotExists) { day = 0; minutes = 0; LogException(ex); } else { throw ex; } } } catch (Exception ex) { LogException(ex); throw ex; } }
public Data.Leave ConvertToDb(LeaveInfo leaveInfo) { return(new Data.Leave { Id = leaveInfo.Id, Allowed = leaveInfo.Allowed, Availed = leaveInfo.Availed, LeaveType = leaveInfo.LeaveType, EmployeeInfoId = leaveInfo.EmployeeInfoId }); }
/// <summary> /// 工单详情 /// </summary> /// <param name="id">工单的ID</param> /// <param name="pageId"></param> /// <returns></returns> public ActionResult WorkFlowOrderInfo(string id, string pageId) { ViewBag.pageId = getPageId(pageId); var info = new BaseWorkOrder(id); if (info.OrderType == WorkOrderType.请假申请) { info = new LeaveInfo(id); } return(View(info)); }
/// <summary> /// 请假申请 新增/编辑界面 /// </summary> /// <param name="id">请假申请的ID 新增传空字符串</param> /// <param name="pageId"></param> /// <returns></returns> public ActionResult LeaveEdit(string id, string pageId) { ViewBag.pageId = getPageId(pageId); LeaveInfo info = new LeaveInfo(); if (!string.IsNullOrEmpty(id)) { info = new LeaveInfo(id); } return(View(info)); }
public ActionResult Verify(int verifyType, params int[] Ids) { var res = new OperationResult(OperationResultType.Error); int countSuccess = 0; int countFail = 0; foreach (var item in Ids) { LeaveInfo info = _leaveInfoContract.LeaveInfos.Where(x => x.Id == item).FirstOrDefault(); if (info != null && info.VerifyType == 0) { LeaveInfoDto dto = new LeaveInfoDto(); dto.Id = item; dto.LeaveReason = info.LeaveReason; dto.VacationType = info.VacationType; dto.StartTime = info.StartTime; dto.EndTime = info.EndTime; dto.LeaveDays = info.LeaveDays; dto.VerifyType = verifyType; dto.AdminId = info.AdminId; dto.VerifyAdminId = AuthorityHelper.OperatorId; dto.AnnualLeaveDays = info.AnnualLeaveDays; dto.RestHours = info.RestHours; dto.LeaveMethod = info.LeaveMethod; dto.UseAnnualLeaveDay = info.UseAnnualLeaveDay; res = _leaveInfoContract.Verify(dto); if (res.ResultType == OperationResultType.Success) { countSuccess++; string content = string.Empty; string title = "请假通知"; if (dto.VerifyType == (int)VerifyFlag.NoPass) { content = "审核不通过"; } else { content = "审核通过"; } EntityContract._notificationContract.SendNotice(dto.AdminId, title, content, sendNotificationAction); } else { countFail++; } } } var strResult = string.Format("操作完成:成功{0}个,失败{1}个", countSuccess, countFail); var oper = new OperationResult(OperationResultType.Success, strResult); return(Json(res)); }
public static LeaveInfo GetLeaveInfoByID(string leaveID) { LeaveInfo leave = null; if (!string.IsNullOrEmpty(leaveID)) { List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.PKLeaveInfoID, leaveID, SearchComparator.Equal, SearchType.SearchString)); leave = CommonDAL <LeaveInfo> .GetSingleObject(conditions); } return(leave); }
public LeaveItem(LeaveInfo li) { list = new List <DateRecords>(); if (li.TimeDurationInfoList != null) { foreach (TimeDurationInfo tdi in li.TimeDurationInfoList) { DateRecords dr = new DateRecords(tdi); list.Add(dr); } mLI = li; } }
public void UpdateLeave(LeaveInfo leaveInfo) { Data.Leave leave = _context.Leaves.Find(leaveInfo.Id); if (leave != null) { ConvertToDb(leaveInfo); _context.SaveChanges(); } else { throw new ArgumentNullException(); } }
public static LeaveInfo ApproveLeave(string managerID, string leaveID, LeaveStatus status) { LeaveInfo leave = null; if (!string.IsNullOrEmpty(managerID) && !string.IsNullOrEmpty(leaveID) && status != LeaveStatus.None) { leave = LeaveBLL.GetLeaveInfoByID(leaveID); leave.FKReportManagerID = Guid.Parse(managerID); leave.PreStatus = leave.Status; // get previous status leave.Status = status; leave.Save(); } return(leave); }
public static bool RecallLeave(string leaveID) { bool result = false; LeaveInfo leave = null; try { if (!string.IsNullOrEmpty(leaveID)) { List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition(GlobalParams.PKLeaveInfoID, leaveID, SearchComparator.Equal, SearchType.SearchString)); leave = CommonDAL <LeaveInfo> .GetSingleObject(conditions); } if (leave == null) { throw new DataException("Record not found in DB"); } else if (leave.Status != LeaveStatus.Applying) { throw new DataException(string.Format("Record has been locked since it's {0} already.", leave.Status.ToString())); } // delete FK time duration first List <SearchCondition> conditionsTimeDuration = new List <SearchCondition>(); conditionsTimeDuration.Add(SearchCondition.CreateSearchCondition(GlobalParams.FKLeaveInfoID, leaveID, SearchComparator.Equal, SearchType.SearchString)); List <TimeDurationInfo> timeDurations = CommonDAL <TimeDurationInfo> .GetObjects(conditionsTimeDuration); for (int i = timeDurations.Count - 1; i >= 0; i--) { CommonDAL <TimeDurationInfo> .Delete(timeDurations[i]); } // delete leave info CommonDAL <LeaveInfo> .Delete(leave); result = true; } catch (Exception ex) { result = false; throw new Exception(ex.Message); } return(result); }
/// <summary> /// 初始化事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> private void frmRBRowType_Load(object sender, EventArgs e) { try { LeaveInfo Leave = new LeaveInfo(); DataTable typetable = Leave.GetLeaveType(); if (typetable.Rows.Count > 0) { this.GridView1.DataSource = typetable; this.GridView1.DataBind(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnLeave_Click(object sender, EventArgs e) { LeaveInfo leaveInfo = new LeaveInfo(); leaveInfo.PatientID = int.Parse(txPatientID.Text); leaveInfo.Date = dateTimePicker1.Value.ToString("yyyy/MM/dd"); leaveInfo.BedNumber = int.Parse(txBedID.Text); AddLeavePatient addLeavePatient = new AddLeavePatient(); if (addLeavePatient.AddInfo(leaveInfo)) { MessageBox.Show("插入成功"); } else { MessageBox.Show("插入失败"); } }
public static List <LeaveInfo> FindLeaves(string manager, string employee, string leaveTypeId, int leaveStatus, DateTime start, DateTime end, string supervisorIDs) { List <LeaveInfo> leaves = new List <LeaveInfo>(); DataTable table = new DataTable(); using (SqlConnection conn = CommonConnection.Conn) { conn.Open(); using (SqlCommand cmd = new SqlCommand("FindLeaves", conn)) { cmd.Parameters.Add(new SqlParameter("@SubmitEmployeeID", employee)); cmd.Parameters.Add(new SqlParameter("@ReportManagerID", manager)); cmd.Parameters.Add(new SqlParameter("@LeaveTypeID", leaveTypeId)); cmd.Parameters.Add(new SqlParameter("@LeaveStatus", leaveStatus)); cmd.Parameters.Add(new SqlParameter("@StartTime", start)); cmd.Parameters.Add(new SqlParameter("@EndTime", end)); cmd.Parameters.Add(new SqlParameter("@SupervisorIDs", supervisorIDs)); cmd.CommandType = CommandType.StoredProcedure; using (SqlDataAdapter adapter = new SqlDataAdapter()) { adapter.SelectCommand = cmd; adapter.Fill(table); } } conn.Close(); } if (null != table.Rows) { foreach (DataRow row in table.Rows) { LeaveInfo info = new LeaveInfo(523); info.SetIsNewFlag(false); info.Init(row); leaves.Add(info); } } return(leaves); }
/// <summary> /// 初始化方法 /// </summary> /// <remarks></remarks> private void Bind() { try { LeaveInfo Leave = new LeaveInfo(); DataTable table = Leave.GetConfirmUser(); if (table.Rows.Count > 0) { this.GridView1.Rows.Clear(); this.GridView1.DataSource = table; this.GridView1.DataBind(); } else { this.GridView1.Rows.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void AvailLeaves(LeaveInfo leaveInfo) { Data.Leave casualLeaves = (from l in _context.Leaves.ToList() where l.EmployeeInfoId == leaveInfo.EmployeeInfoId && l.LeaveType == "Casual" select l).FirstOrDefault(); Data.Leave annualLeaves = (from l in _context.Leaves.ToList() where l.EmployeeInfoId == leaveInfo.EmployeeInfoId && l.LeaveType == "Annual" select l).FirstOrDefault(); int remainingCasualLeaves = casualLeaves.Allowed - casualLeaves.Availed; if (remainingCasualLeaves == 0) { int availedAnnualLeaves = annualLeaves.Availed + leaveInfo.Availed; annualLeaves.Availed = availedAnnualLeaves; _context.SaveChanges(); } else { if (remainingCasualLeaves > leaveInfo.Availed || remainingCasualLeaves == leaveInfo.Availed) { int availedCasualLeaves = casualLeaves.Availed + leaveInfo.Availed; casualLeaves.Availed = availedCasualLeaves; _context.SaveChanges(); } else if (remainingCasualLeaves < leaveInfo.Availed) { int availedCasualLeaves = casualLeaves.Availed + remainingCasualLeaves; casualLeaves.Availed = availedCasualLeaves; _context.SaveChanges(); annualLeaves.Availed = annualLeaves.Availed + (leaveInfo.Availed - remainingCasualLeaves); _context.SaveChanges(); } } }
public IActionResult CreateLeaveInfo([FromBody] LeaveInfo info) { var emp = JsonConvert.SerializeObject(_leaveRepo.CreateLeaveInfo(info)); return(Created("", emp)); }
public static void ApplyLeave(object seed) { LeaveInfo leave = seed as LeaveInfo; LeaveBLL.ApproveLeave(leave.FKReportManagerID.ToString(), leave.PKLeaveInfoID.ToString(), LeaveStatus.Accepted); }
public void TestUpdateLeaveInfoTransact() { // Insert an employee role Role employeeRole = Role.CreateRole(Guid.NewGuid().ToString()); employeeRole.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Tian", DateTime.Now, "Liu"); employee.IsActive = true; employee.ServiceYears = 10; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, employeeRole.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); // Insert a leave info LeaveInfo leaveInfo = LeaveInfo.CreateLeaveInfo(employeeGuid, managerGuid, leaveTypeGuid, LeaveStatus.Accepted, "For Test", "Test Description", timeDurationList); leaveInfo.Save(); Guid leaveGuid = leaveInfo.PKLeaveInfoID; // Get the leave info inserted just now List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKLeaveInfoID", leaveGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); LeaveInfo testLeaveInfo = CommonDAL <LeaveInfo> .GetSingleObject(conditions); // Update the leave info testLeaveInfo.Reason = "Update test leave reason"; try { testLeaveInfo.Save(); } catch { Console.WriteLine("Throw exception for transact unit test"); } // Get the updated leave info LeaveInfo updatedLeaveInfo = CommonDAL <LeaveInfo> .GetSingleObject(conditions); Assert.AreNotEqual(testLeaveInfo.Reason, updatedLeaveInfo.Reason); // Delete the leave, leave type, employees and roles leaveInfo.Delete(); leaveType.Delete(); employee.Delete(); manager.Delete(); employeeRole.Delete(); managerRole.Delete(); }
public void TestGetMyTeamLeaves() { // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a role Role role = Role.CreateRole(Guid.NewGuid().ToString()); role.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Hui", DateTime.Now, "Ji"); employee.IsActive = true; employee.ServiceYears = 10; employee.FKReportManagerID = managerGuid; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, role.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); DateTime durationStartTime2 = Convert.ToDateTime("02/02/2011"); DateTime durationEndTime2 = Convert.ToDateTime("02/05/2011"); TimeDurationInfo timeDurationInfo2 = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime2, durationEndTime2); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); timeDurationList.Add(timeDurationInfo2); LeaveInfo leave = LeaveBLL.ApplyLeave(employeeGuid.ToString(), "Test", leaveType.Name, "Test Desc", timeDurationList); // Get the employee's leave list List <LeaveInfo> leaveList = LeaveBLL.GetMyTeamLeaves(managerGuid.ToString(), true); // Compare these two list bool result = leave.PKLeaveInfoID == leaveList[0].PKLeaveInfoID; if (result) { //foreach (LeaveInfo leave in leave) //{ // bool existAndEqual = false; // foreach (LeaveInfo leaveItem in leaveList) // { // if (leave.FirstStartTime == leaveItem.FirstStartTime && leave.LastEndTime == leaveItem.LastEndTime) // { // existAndEqual = true; // break; // } // } // result = existAndEqual; // if (!result) break; //} } Assert.IsTrue(result); //foreach (LeaveInfo leave in leave) //{ leave.Delete(); //} leaveType.Delete(); employee.Delete(); role.Delete(); manager.Delete(); managerRole.Delete(); }
public void TestApproveLeave() { // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a role Role role = Role.CreateRole(Guid.NewGuid().ToString()); role.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Hui", DateTime.Now, "Ji"); employee.IsActive = true; employee.ServiceYears = 10; employee.FKReportManagerID = managerGuid; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, role.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); DateTime durationStartTime2 = Convert.ToDateTime("02/02/2011"); DateTime durationEndTime2 = Convert.ToDateTime("02/05/2011"); TimeDurationInfo timeDurationInfo2 = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime2, durationEndTime2); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); timeDurationList.Add(timeDurationInfo2); LeaveInfo leave = LeaveBLL.ApplyLeave(employeeGuid.ToString(), "Test", leaveType.Name, "Test Desc", timeDurationList); // Approve the applying leave. LeaveBLL.ApproveLeave(managerGuid.ToString(), leave.PKLeaveInfoID.ToString(), LeaveStatus.Accepted); // Get the employee's leave list List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("FKSubmitEmployeeID", employeeGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); List <LeaveInfo> leaveList = CommonDAL <LeaveInfo> .GetObjects(conditions); Assert.IsTrue(leaveList[0].PKLeaveInfoID == leave.PKLeaveInfoID && leaveList[0].Status == LeaveStatus.Accepted); leave.Delete(); leaveType.Delete(); employee.Delete(); role.Delete(); manager.Delete(); managerRole.Delete(); }
public BaseResponse <BaseResponseList <LeaveInfo> > GetMyLeavesList(BaseRequest condtion) { return(BaseResponse.getResult(LeaveInfo.SearchMyLeavesList(User.Identity.Name, condtion))); }
public async Task <ModifyInfo> UpdateExamineStatus(string modifyId, ExamineStatusEnum status, CancellationToken cancellationToken = default(CancellationToken)) { var modify = await GetModifyAsync(a => a.Where(b => b.ID == modifyId)); if (modify != null) { switch (modify.Type) { case CreateHumanModifyType: { HumanInfo buildings = new HumanInfo() { Id = modify.Ext1, StaffStatus = StaffStatus.Entry }; Context.Attach(buildings); var entry = Context.Entry(buildings); entry.Property(x => x.StaffStatus).IsModified = true; } break; case BecomeHumanModifyType: { SocialInsurance responinfo = JsonHelper.ToObject <SocialInsurance>(modify.Ext2); await BecomeHuman(responinfo, modify.Ext1, cancellationToken); } break; case ChangeHumanModifyType: { ChangeInfo responinfo = JsonHelper.ToObject <ChangeInfo>(modify.Ext2); await ChangeHuman(responinfo, modify.Ext1, cancellationToken); } break; case LeaveHumanModifyType: { LeaveInfo responinfo = JsonHelper.ToObject <LeaveInfo>(modify.Ext2); await LeaveHuman(responinfo, modify.Ext1, cancellationToken); } break; default: break; } ///////////////////// ModifyInfo mbuildings = new ModifyInfo() { ID = modifyId, ExamineTime = DateTime.Now, ExamineStatus = status, }; Context.Attach(mbuildings); var mentry = Context.Entry(mbuildings); mentry.Property(x => x.ExamineStatus).IsModified = true; mentry.Property(x => x.ExamineTime).IsModified = true; await Context.SaveChangesAsync(cancellationToken); } return(modify); }
/// <summary> /// 更新所屬學生畢業級離校資訊(離校科別、離校班級) /// </summary> /// <param name="ClassItems"></param> public static void UpdateStudentLeaveInfo(List <ClassItem> ClassItems) { List <string> classIDListt = new List <string>(); Dictionary <string, string> studClassNameDict = new Dictionary <string, string>(); Dictionary <string, string> classNameDict = new Dictionary <string, string>(); foreach (ClassItem ci in ClassItems) { classIDListt.Add(ci.ClassID); classNameDict.Add(ci.ClassID, ci.ClassName); } // 取得學生ID List <string> studentIDList = new List <string>(); QueryHelper qh1 = new QueryHelper(); string str1 = "select student.id,class.class_name from student inner join class on student.ref_class_id=class.id where student.status=1 and ref_class_id in(" + string.Join(",", classIDListt.ToArray()) + ")"; DataTable dt1 = qh1.Select(str1); foreach (DataRow dr in dt1.Rows) { string id = dr["id"].ToString(); studentIDList.Add(id); studClassNameDict.Add(id, dr["class_name"].ToString()); } // 建立來自班級科別 Dictionary <string, string> deptByClassDict = new Dictionary <string, string>(); QueryHelper qh2 = new QueryHelper(); string str2 = "select student.id,dept.name from student inner join class on student.ref_class_id=class.id inner join dept on class.ref_dept_id=dept.id where class.id in(" + string.Join(",", classIDListt.ToArray()) + ");"; DataTable dt2 = qh2.Select(str2); foreach (DataRow dr in dt2.Rows) { deptByClassDict.Add(dr["id"].ToString(), dr["name"].ToString()); } // 建立來自學生科別 Dictionary <string, string> deptrByStudDict = new Dictionary <string, string>(); QueryHelper qh3 = new QueryHelper(); string str3 = "select student.id,dept.name from student inner join dept on student.ref_dept_id=dept.id where student.id in(" + string.Join(",", studentIDList.ToArray()) + ");"; DataTable dt3 = qh3.Select(str3); foreach (DataRow dr in dt3.Rows) { deptrByStudDict.Add(dr["id"].ToString(), dr["name"].ToString()); } // 取得畢業及離校資訊 List <LeaveInfoRecord> leaveInfoList = LeaveInfo.SelectByStudentIDs(studentIDList); foreach (LeaveInfoRecord lif in leaveInfoList) { // 學生班級 if (studClassNameDict.ContainsKey(lif.RefStudentID)) { lif.ClassName = studClassNameDict[lif.RefStudentID]; } // 學生班級科別 if (deptByClassDict.ContainsKey(lif.RefStudentID)) { lif.DepartmentName = deptByClassDict[lif.RefStudentID]; } // 學生本身科別 if (deptrByStudDict.ContainsKey(lif.RefStudentID)) { lif.DepartmentName = deptrByStudDict[lif.RefStudentID]; } } // 更新畢業及離校資訊 LeaveInfo.Update(leaveInfoList); }
public void TestTimeDurationInfoTimeStamp() { // Insert an employee role Role employeeRole = Role.CreateRole(Guid.NewGuid().ToString()); employeeRole.Save(); // Insert an employee. Employee employee = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Male, "Tian", DateTime.Now, "Liu"); employee.IsActive = true; employee.ServiceYears = 10; List <EmployeeRoleRL> employeeRoleList = new List <EmployeeRoleRL>(); employeeRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, employeeRole.PKRoleID)); employee.SetRoleList(employeeRoleList); employee.Save(); Guid employeeGuid = employee.PKEmployeeID; // Insert a manager role Role managerRole = Role.CreateRole(Guid.NewGuid().ToString()); managerRole.Save(); // Insert an employee who is a manager Employee manager = Employee.CreateEmployee(Guid.NewGuid().ToString(), "123", Sex.Female, "Helen", DateTime.Now, "Niu"); manager.IsActive = true; manager.ServiceYears = 8; List <EmployeeRoleRL> managerRoleList = new List <EmployeeRoleRL>(); managerRoleList.Add(EmployeeRoleRL.CreateEmployeeRoleRL(Guid.Empty, managerRole.PKRoleID)); manager.SetRoleList(managerRoleList); manager.Save(); Guid managerGuid = manager.PKEmployeeID; // Insert a leave type DateTime leaveTypeStartTime = Convert.ToDateTime("01/01/2000"); DateTime leaveTypeEndTime = Convert.ToDateTime("01/01/3000"); LeaveType leaveType = LeaveType.CreateLeaveType(Guid.NewGuid().ToString(), 100, leaveTypeStartTime, leaveTypeEndTime); leaveType.PKLeaveTypeID = Guid.NewGuid(); leaveType.SetKnowledgeDate(DateTime.Now); leaveType.Save(); Guid leaveTypeGuid = leaveType.PKLeaveTypeID; // Insert a leave time duration for this leave DateTime durationStartTime = Convert.ToDateTime("02/02/2001"); DateTime durationEndTime = Convert.ToDateTime("02/05/2001"); TimeDurationInfo timeDurationInfo = TimeDurationInfo.CreateTimeDurationInfo(durationStartTime, durationEndTime); List <TimeDurationInfo> timeDurationList = new List <TimeDurationInfo>(); timeDurationList.Add(timeDurationInfo); // Insert a leave info LeaveInfo leaveInfo = LeaveInfo.CreateLeaveInfo(employeeGuid, managerGuid, leaveTypeGuid, LeaveStatus.Accepted, "For Test", "Test Description", timeDurationList); leaveInfo.Save(); Guid leaveGuid = leaveInfo.PKLeaveInfoID; timeDurationInfo.FKLeaveInfoID = leaveGuid; timeDurationInfo.KnowledgeDate = DateTime.Now; timeDurationInfo.IsDeleted = false; timeDurationInfo.Save(); Guid tdGuid = timeDurationInfo.PKTDInfoID; // Get the inserted time duration info List <SearchCondition> conditions = new List <SearchCondition>(); conditions.Add(SearchCondition.CreateSearchCondition("PKTDInfoID", tdGuid.ToString(), SearchComparator.Equal, SearchType.SearchString)); TimeDurationInfo testTimeDuration1 = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); TimeDurationInfo testTimeDuration2 = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); // Update the inseted time duratioin info testTimeDuration1.EndTime = Convert.ToDateTime("02/10/2001"); testTimeDuration1.Save(); testTimeDuration2.EndTime = Convert.ToDateTime("02/11/2002"); testTimeDuration2.Save(); // Get the updated time duration info TimeDurationInfo updatedTimeDuration = CommonDAL <TimeDurationInfo> .GetSingleObject(conditions); Assert.AreEqual(testTimeDuration1.EndTime, updatedTimeDuration.EndTime); Assert.AreNotEqual(testTimeDuration2.EndTime, updatedTimeDuration.EndTime); // Delete inserted items timeDurationInfo.Delete(); leaveInfo.Delete(); leaveType.Delete(); employee.Delete(); manager.Delete(); employeeRole.Delete(); managerRole.Delete(); }