public Boolean UpdateEmployee(GetEmployee emp) { try { Employee employee = new Employee(); employee = _context.Employees.Where(c => c.EmpEmail == emp.EmpEmail).FirstOrDefault(); _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// Hämta en specifik anställd /// </summary> public EmployeeResponse Get(GetEmployee request) { var employee = EmployeeRepository.GetEmployee(request.Id); if (employee == null) { Response.StatusCode = (int)HttpStatusCode.NotFound; return(null); } return(new EmployeeResponse { Employee = employee.ToDto() }); }
public IActionResult EmployeeChangeSate(GetEmployee employee) { try { var result = _service.RemoveEmployee(employee.EmpEmail, employee.IsActive); if (result) { return(Ok(result)); } else { return(BadRequest()); } } catch { return(BadRequest()); } }
public IActionResult UpdateEmployeeByPart([FromForm] GetEmployee employee) { Hash hash = new Hash(); employee.EmpPassword = hash.HashPassword(employee.EmpPassword); if (_service.UpdateEmployeeByPart(employee)) { return(Ok(employee)); } else { return(BadRequest("there error")); } }
private static int GetEmployeeVerb(GetEmployee opts) { var client = new RestClient(opts.BaseUrl) { RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true, }; var request = new RestRequest(_path + "employees/{name}", Method.GET); request.AddUrlSegment("name", opts.CustomEmployeeName); var response = client.Execute <Employee>(request); Console.Write(response.Data); return(0); }
public IActionResult Create([FromForm] GetEmployee emp) { try { string res = ""; if (emp.EmpProfilePicture != null) { // add profile picture res = AddFiles.AddImage(emp.EmpProfilePicture, emp.EmpId); } Hash hash = new Hash(); emp.EmpPassword = hash.HashPassword(emp.EmpPassword); Employee employee = new Employee(); employee.EmpId = emp.EmpId; employee.EmpEmail = emp.EmpEmail; employee.EmpPassword = emp.EmpPassword; employee.EmpName = emp.EmpName; employee.EmpContact = emp.EmpContact; employee.EmpAddress1 = emp.EmpAddress1; employee.EmpAddress2 = emp.EmpAddress2; employee.EmpGender = emp.EmpGender; employee.PositionPId = emp.PositionPId; employee.DepartmentDprtId = emp.DepartmentDprtId; employee.EmpProfilePicture = res; employee.ProjectPrId = emp.ProjectId; int regitercode = _service.AddEmployee(employee); if (regitercode > 0) { // if there register code send it bt email Boolean SendCode = SendMail.SendloginCode(regitercode.ToString(), emp.EmpEmail, emp.EmpName); return(Ok(emp)); } else { return(BadRequest("there error")); } } catch { return(BadRequest()); } }
public HttpResponseMessage InsertData([System.Web.Http.FromBody] GetEmployee getEmployee) { SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["EmployeeDB"].ConnectionString); try { SqlCommand sqlCommand = new SqlCommand("Insert into UserData(FirstName, LastName, Email, DOB) values('" + getEmployee.FirstName + " ," + getEmployee.LastName + " ," + getEmployee.Email + " ," + getEmployee.Dob); int i = sqlCommand.ExecuteNonQuery(); sqlConnection.Close(); var message = Request.CreateResponse(HttpStatusCode.Created, getEmployee); message.Headers.Location = new Uri(Request.RequestUri + getEmployee.Email); return(message); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
///<summary> ///</summary> ///<param name="from"></param> ///<param name="to"></param> ///<param name="accountList"></param> ///<param name="loginUser"></param> public void UpdateAttendanceForOperator(DateTime from, DateTime to, List <Account> accountList, Account loginUser) { //UpdateEmployeeAttendance updateEmployeeAttendance = new UpdateEmployeeAttendance(loginUser); List <Employee> AllEmployeeList = new List <Employee>(); GetEmployee getEmployee = new GetEmployee(); foreach (Account account in accountList) { AllEmployeeList.Add(getEmployee.GetEmployeeBasicInfoByAccountID(account.Id)); } for (int i = 0; i < AllEmployeeList.Count; i++) { //找前一天数据 DateTime tempDate = to; while (DateTime.Compare(Convert.ToDateTime(from.ToShortDateString()), Convert.ToDateTime(tempDate.ToShortDateString())) <= 0) { AllEmployeeList[i] = _DalEmployee.GetEmployeeByAccountID(AllEmployeeList[i].Account.Id); AllEmployeeList[i].EmployeeAttendance = new Model.EmployeeAttendance.AttendanceStatistics.EmployeeAttendance (tempDate.AddDays(-1), tempDate); AllEmployeeList[i].EmployeeAttendance.AttendanceInAndOutRecordList = _DalRecord.GetAttendanceInAndOutRecordByCondition (AllEmployeeList[i].Account.Id, "", Convert.ToDateTime(tempDate.ToShortDateString() + " 00:00:00"), Convert.ToDateTime(tempDate.ToShortDateString() + " 23:59:59"), InOutStatusEnum.All, OutInRecordOperateStatusEnum.All, Convert.ToDateTime("1900-1-1"), Convert.ToDateTime("2900-12-31")); AllEmployeeList[i].EmployeeAttendance.DoorCardNo = _DalEmployee.GetEmployeeBasicInfoByAccountID(AllEmployeeList[i].Account.Id).EmployeeAttendance. DoorCardNo; AllEmployeeList[i].EmployeeAttendance.PlanDutyDetailList = new PlanDutyDal().GetPlanDutyDetailByAccount( AllEmployeeList[i].Account.Id, Convert.ToDateTime(tempDate.ToShortDateString() + " 00:00:00"), Convert.ToDateTime(tempDate.ToShortDateString() + " 23:59:59")); //updateEmployeeAttendance. // UpdateEmployeeDayAttendance(AllEmployeeList[i], tempDate); tempDate = tempDate.AddDays(-1); } } }
/// <summary> /// 为HR获取可申请考核的员工 /// </summary> public List <Account> GetAssessActivityForHRApply(string employeeName, EmployeeTypeEnum employeeType, int positionID, int departmentID, bool recursionDepartment, Account loginUser) { List <Account> retaccount = new List <Account>(); Auth myAuth = loginUser.FindAuth(AuthType.HRMIS, HrmisPowers.A703); if (myAuth == null) { throw new ApplicationException("没有权限访问"); } List <Account> accounts = RemoveInvalidationAccount( _AccountBll.GetAccountByBaseCondition(employeeName, departmentID, positionID, null, recursionDepartment, null)); foreach (Account account in accounts) { Employee employee = new GetEmployee().GetEmployeeByAccountID(account.Id); if (employee == null) { continue; } if (employeeType == EmployeeTypeEnum.All || employeeType == employee.EmployeeType) { retaccount.Add(account); } } if (myAuth.Departments.Count == 0) { return(retaccount); } for (int i = retaccount.Count - 1; i >= 0; i--) { if (!SEP.Model.Utility.Tools.IsDeptListContainsDept(myAuth.Departments, retaccount[i].Dept)) { retaccount.RemoveAt(i); } } return(retaccount); }
public static string GetEmployee(string userid) { LogHelper log = LogFactory.GetLogger("GetEmployee"); string json = ""; try { GetEmployee Result = EmployeeBll.Get(userid); if (Result != null) { if (Result.errcode == "0") { json = Result.ToJson(); //Console.Write(json + "\r\n"); } else if (Result.errcode == "90002") { System.Threading.Thread.Sleep(1500); json = GetEmployee(userid); } else { if (Result.errcode != "60121") { //Console.Write(Result.errmsg); log.Error("\r\n EmployeeForDingTalkBll-GetEmployee() " + Result.errmsg + "\r\n"); } return("-1"); } } else { //Console.Write("无返回数据"); } } catch (Exception ex) { log.Error("\r\n EmployeeForDingTalkBll-GetEmployee() " + ex + "\r\n"); //Console.Write(ex.Message); } return(json); }
public static List <GetEmployee> GetReportingToEmployeeByID(string Employee_ID) { SqlConnection con = new SqlConnection(System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); List <GetEmployee> details = new List <GetEmployee>(); SqlDataAdapter da = new SqlDataAdapter(@" SELECT EmployeeID, Name, Father_Name, Grand_Father_Name, Gender, MaritalStatus FROM HRMIS_VW_EmployeeInformation where EmployeeID='" + Employee_ID + "'", con); DataTable dt = new DataTable(); da.Fill(dt); foreach (DataRow dtrow in dt.Rows) { GetEmployee obj = new GetEmployee(); obj.Employee_ID = dtrow["EmployeeID"].ToString(); obj.Name = dtrow["Name"].ToString(); details.Add(obj); } // Newtonsoft.Json.js return(details); }
public IActionResult UpdateEmployee([FromForm] GetEmployee emp) { string res = ""; if (emp.EmpProfilePicture != null) { // if there profile picture change it res = AddFiles.AddImage(emp.EmpProfilePicture, emp.EmpId); } Hash hash = new Hash(); emp.EmpPassword = hash.HashPassword(emp.EmpPassword); Employee employee = new Employee(); employee.EmpId = emp.EmpId; employee.EmpEmail = emp.EmpEmail; employee.EmpPassword = emp.EmpPassword; employee.EmpName = emp.EmpName; employee.EmpContact = emp.EmpContact; employee.EmpAddress1 = emp.EmpAddress1; employee.EmpAddress2 = emp.EmpAddress2; employee.EmpGender = emp.EmpGender; employee.PositionPId = emp.PositionPId; employee.DepartmentDprtId = emp.DepartmentDprtId; employee.EmpProfilePicture = res; employee.IsActive = emp.IsActive; employee.StartDate = emp.StartDate; employee.ProjectPrId = emp.ProjectId; if (_service.UpdateEmployee(employee) == 1) { return(Ok("Changes success full!")); } if (_service.UpdateEmployee(employee) == 2) { return(BadRequest("Password not match, Try again.")); } else { return(BadRequest("there are error")); } }
public async Task <IActionResult> Details(Guid employeeId) { GetEmployee queryParams = new GetEmployee { EmployeeID = employeeId }; try { var retValue = await _employeeQryReqHdler.Handle <GetEmployee>(queryParams, HttpContext, Response); return(retValue); } catch (Exception ex) { _logger.LogError($"An exception has been thrown: {ex}"); return(BadRequest(ex.Message)); } }
public async Task <IActionResult> CreateEmployeeInfo([FromBody] CreateEmployeeInfo writeModel) { try { await _employeeCmdHdlr.Handle(writeModel); GetEmployee queryParams = new GetEmployee { EmployeeID = writeModel.Id }; IActionResult retValue = await _employeeQryReqHdler.Handle <GetEmployee>(queryParams, HttpContext, Response); return(CreatedAtAction(nameof(Details), new { employeeId = writeModel.Id }, (retValue as OkObjectResult).Value)); } catch (Exception ex) { _logger.LogError(ex.Message); return(BadRequest(ex.Message)); } }
/// <summary> /// 为合同新增界面创建List<EmployeeContractBookMark> /// </summary> public List <EmployeeContractBookMark> GetEmployeeContractBookMarkByContractTypeID(int ContractTypeId, int employeeID) { List <ContractBookMark> contractBookMark = _dalContractBookMark.GetContractBookMarkByContractTypeID(ContractTypeId); Employee employee = new GetEmployee(_dalEmployee, _IAccountBll, _dalEmployeeSkill, _IDepartmentBll, _EmployeeAdjustRuleDal). GetEmployeeByAccountID(employeeID); if (contractBookMark != null && contractBookMark.Count > 0) { List <EmployeeContractBookMark> employeeContractBookMark = new List <EmployeeContractBookMark>(); foreach (ContractBookMark mark in contractBookMark) { employeeContractBookMark.Add(new EmployeeContractBookMark(0, 0, mark.BookMarkName, EmployeeContractBookMark.InitBookMarkValue(mark.BookMarkName, employee))); } return(employeeContractBookMark); } else { return(null); } }
public static void SaveEmpAtDepartment(GetEmployee Employee) { string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection con = new SqlConnection(constr); con.Open(); SqlTransaction tran = con.BeginTransaction(); SqlCommand cmd = new SqlCommand(); cmd.Transaction = tran; cmd.Connection = con; try { cmd.CommandText = "HRMIS_tblEmployeeAtDepartment_Insert"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@Employee_ID", SqlDbType.VarChar).Value = Employee.Employee_ID; cmd.Parameters.Add("@Department_ID", SqlDbType.Int).Value = Employee.Department_ID; cmd.Parameters.Add("@Position_ID", SqlDbType.Int).Value = Employee.Position_ID; cmd.Parameters.Add("@Reporting_To", SqlDbType.VarChar).Value = string.IsNullOrEmpty(Employee.ReportingTo)?"0":Employee.ReportingTo; cmd.Parameters.Add("@Status", SqlDbType.NVarChar).Value = Employee.Status; cmd.Parameters.Add("@User_ID", SqlDbType.NVarChar).Value = Employee.User_ID; cmd.ExecuteNonQuery(); tran.Commit(); } catch (SqlException Sexp) { tran.Rollback(); con.Close(); } catch (Exception ex) { con.Close(); } finally { con.Close(); } }
public static void Main() { Employee employee1 = new Employee { FirstName = "Mohsin", LastName = "Azam", Department = "IT", YearOfResumption = 2014 }; Employee employee2 = new Employee { FirstName = "Ali", LastName = "Hassan", Department = "Software", YearOfResumption = 2018 }; Employee employee3 = new Employee { FirstName = "Humaira", LastName = "Ahmad", Department = "Maths", YearOfResumption = 2018 }; Employee employee4 = new Employee { FirstName = "Alis", LastName = "Ozil", Department = "IT", YearOfResumption = 2017 }; Employee[] employees = new Employee[] { employee1, employee2, employee3, employee4 }; Console.WriteLine("Software Department"); List <Employee> SoftwareEmployees = GetEmployee.GetEmployeeBy(new EmployeeDepartmentSpecification("Software"), employees); foreach (var employee in SoftwareEmployees) { Console.WriteLine(employee.FirstName); } Console.WriteLine(); Console.WriteLine("Employed in 2017"); List <Employee> EmployedIn2017 = GetEmployee.GetEmployeeBy(new EmployeeYearSpecification(2017), employees); foreach (var employee in EmployedIn2017) { Console.WriteLine(employee.FirstName); } Console.ReadKey(); }
/// <summary> /// update position of employee /// </summary> /// <param name="position"></param> /// <returns>boolean</returns> public Boolean UpdateEmployeeByPart(GetEmployee emp) { try { Employee employee = new Employee(); employee = _context.Employees.Where(c => c.EmpEmail == emp.EmpEmail).FirstOrDefault(); if (emp.PositionPId != null) { var count = _context.Employees.Where(c => c.IsActive == true && c.PositionPId == "AD").Count(); if (count == 1 && employee.PositionPId == "AD") { return(false); } employee.PositionPId = emp.PositionPId; } if (emp.DepartmentDprtId != null) { employee.DepartmentDprtId = emp.DepartmentDprtId; } if (emp.ProjectId != 0) { employee.ProjectPrId = emp.ProjectId; } _context.Entry(employee).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _context.SaveChanges(); return(true); } catch { return(false); } }
/// <summary> /// for test /// </summary> public GetSystemError(Account loginUser, ISystemError iSystemError, GetEmployee iAccountBll) : this(loginUser) { _ISystemError = iSystemError; _GetEmployee = iAccountBll; }
public static void UpdateEmployeePhoneByUserId(string userid, string MobilePhone) { SqlSugarClient Edb = DBHelper.Edb; SqlSugarClient Ddb = DBHelper.Ddb; Ddb.CodeFirst.InitTables(typeof(DepartmentResult)); NLogHelper log = NLogFactory.GetLogger("UpdateEmployeePhoneByUserId"); try { GetEmployee emp = EmployeeBll.Get(userid); EmployeeEntity model = JsonConvert.DeserializeObject <EmployeeEntity>(JsonConvert.SerializeObject(emp)); string oldMobile = model.mobile; model.mobile = MobilePhone; string param = JsonConvert.SerializeObject(model); Result Result = EmployeeBll.Update(param); if (Result != null) { if (Result.errcode == "0") { //Console.Write("更新成功\r\n"); } else if (Result.errcode == "40022" || Result.errcode == "40021") { //40021 更换的号码已注册过钉钉,无法使用该号码 //40022 企业中的手机号码和登陆钉钉的手机号码不一致,暂时不支持修改用户信息,可以删除后重新添加 string Deletecode = EmployeeBll.Delete(model.userid).errcode; string Createcode = EmployeeBll.Create(JsonConvert.SerializeObject(model)).errcode; if (Createcode != "0") { Createcode = EmployeeBll.Create(JsonConvert.SerializeObject(model)).errcode; if (Createcode != "0" && Createcode != "40021") { log.Error("\r\n UpdateEmployeePhoneByUserId - 行号666 更新钉钉人员信息时,成功删除员工信息,但是创建员工信息时报错,错误编码如下:" + Createcode); } } if (Deletecode != "0") { InsertErroUpdateEmployee(model.userid, oldMobile, MobilePhone, "删除失败,错误编号:" + Deletecode); } if (Createcode != "0") { InsertErroUpdateEmployee(model.userid, oldMobile, MobilePhone, "执行删除后创建失败,错误编号:" + Createcode); } //Console.Write("更新成功,Userid=" + m.userid + "\r\n"); } else { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + Result.errmsg); Task.Factory.StartNew(() => { InsertErroUpdateEmployee(model.userid, oldMobile, MobilePhone, "更新用户时失败,错误编号:" + Result.errcode); }); } } else { //Console.Write("无返回数据"); } } catch (Exception ex) { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + ex); //Console.Write(ex.Message); } }
//public SeabRes process(SeabReq request) //{ // return TimeKeeping.process(request); //} public SeabRes <EmployeeRes> GetEmployeeProcess(SeabReq <EmployeeReq> request) { return(GetEmployee.process(request)); }
public Boolean UpdateEmployeeByPart(GetEmployee employee) { return(_service.UpdateEmployeeByPart(employee)); }
public static void UpdateEmployeePhoneByUserId(string userid, string MobilePhone) { SqlSugarClient Edb = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ESBConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true }); SqlSugarClient Ddb = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.DingTalkConnectionString, DbType = DbType.SqlServer, IsAutoCloseConnection = true, InitKeyType = InitKeyType.Attribute }); Ddb.CodeFirst.InitTables(typeof(DepartmentResult)); LogHelper log = LogFactory.GetLogger("UpdateEmployeePhoneByUserId"); try { GetEmployee emp = EmployeeBll.Get(userid); EmployeeEntity model = JsonHelper.JsonToModel <EmployeeEntity>(emp.ToJson()); string oldMobile = model.mobile; model.mobile = MobilePhone; string param = model.ToJson(); Result Result = EmployeeBll.Update(param); if (Result != null) { if (Result.errcode == "0") { //Console.Write("更新成功\r\n"); } else if (Result.errcode == "40022" || Result.errcode == "40021") { //40021 更换的号码已注册过钉钉,无法使用该号码 //40022 企业中的手机号码和登陆钉钉的手机号码不一致,暂时不支持修改用户信息,可以删除后重新添加 string Deletecode = EmployeeBll.Delete(model.userid).errcode; string Createcode = EmployeeBll.Create(model.ToJson()).errcode; if (Createcode != "0") { Createcode = EmployeeBll.Create(model.ToJson()).errcode; if (Createcode != "0" && Createcode != "40021") { log.Error("\r\n UpdateEmployeePhoneByUserId - 行号666 更新钉钉人员信息时,成功删除员工信息,但是创建员工信息时报错,错误编码如下:" + Createcode); } } if (Deletecode != "0") { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "删除失败,错误编号:" + Deletecode); } if (Createcode != "0") { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "执行删除后创建失败,错误编号:" + Createcode); } //Console.Write("更新成功,Userid=" + m.userid + "\r\n"); } else { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + Result.errmsg); Task.Factory.StartNew(() => { InsertErroUpdateEmployee(Ddb, model.userid, oldMobile, MobilePhone, "更新用户时失败,错误编号:" + Result.errcode); }); } } else { //Console.Write("无返回数据"); } } catch (Exception ex) { log.Error("\r\n EmployeeForDingTalkBll-UpdateEmployeePhoneByUserId() " + ex); //Console.Write(ex.Message); } }