public FleetRequest GetRequestsDetails(string service_ref) { var objReturn = new FleetRequest(); var eecEmployees = new EECEmployee(); using (var con = new MySqlConnection(ConnectionHelper.MyDirectoryConnection())) { con.Open(); var cmd = new MySqlCommand(); cmd = new MySqlCommand("SELECT * FROM fleet_request " + "WHERE service_ref=@service_ref", con); cmd.Parameters.AddWithValue("@service_ref", service_ref); var dr = cmd.ExecuteReader(); while (dr.Read()) { var fleetServeDetails = GetFleetServeDetails(dr["service_ref"].ToString()); var result = new List <EECEmployee>(); result = eecEmployees.GetEmployeeDetails(dr["emp_id"].ToString()); if (result.Count == 0) { var nonEEC = new NonEECEmployee(); var nonEECEmployeeDetails = nonEEC.GetEmployeeDetails(dr["emp_id"].ToString()); result.Add(new EECEmployee { cost_Center = nonEECEmployeeDetails.cost_center, department = nonEECEmployeeDetails.department, e_Mail = nonEECEmployeeDetails.email, line_Manager_Name = nonEECEmployeeDetails.manager, line_Manager_No = nonEECEmployeeDetails.manager_id }); } else { result = eecEmployees.GetEmployeeDetails(dr["emp_id"].ToString()); } if (result.Count != 0) { foreach (var employeeDetails in result) { //if (employeeDetails.line_Manager_No == line_manager_id) //{ var driverName = string.Empty; var driverMobile = string.Empty; var driverDetails = eecEmployees.GetEmployeeDetails(dr["driver_id"].ToString()); foreach (var details in driverDetails) { driverName = dr["nature"].ToString().ToLower().Contains("chauffeur") ? "WPS Driver" : details.employee_Name_English; driverMobile = details.mobile; } objReturn = new FleetRequest { cost_center = employeeDetails.cost_Center, department = employeeDetails.department, driver = driverName, driver_mobile = driverMobile, email = employeeDetails.e_Mail, line_manager = employeeDetails.line_Manager_Name, line_manager_email = employeeDetails.line_Manager_Email, line_manager_id = employeeDetails.line_Manager_No, code = dr["code"].ToString(), contact = dr["contact"].ToString(), driver_id = dr["driver_id"].ToString(), drop = dr["drop"].ToString(), emp_id = dr["emp_id"].ToString(), from_date = Convert.ToDateTime(dr["from_date"].ToString()), grade = int.Parse(dr["grade"].ToString()), id = int.Parse(dr["id"].ToString()), ip = dr["ip"].ToString(), justification = dr["justification"].ToString(), name = dr["name"].ToString(), nature = dr["nature"].ToString(), pax = dr["pax"].ToString(), pick = dr["pick"].ToString(), random = dr["random"].ToString(), randomize = dr["randomize"].ToString(), remarks = dr["remarks"].ToString(), service_ref = dr["service_ref"].ToString(), session = dr["session"].ToString(), specific_pick = dr["specific_pick"].ToString(), timestamp = dr["timestamp"].ToString(), to_date = nature.ToLower().Contains("chauffeur") ? Convert.ToDateTime(dr["from_date"].ToString()) : Convert.ToDateTime(dr["to_date"].ToString()), type = dr["type"].ToString(), complaint = fleetServeDetails.complaint, end_km = fleetServeDetails.end_km, note = fleetServeDetails.note, plate = fleetServeDetails.plate, sar = fleetServeDetails.sar, }; break; //} } } } } //var request = new TemplateRequest(); ////request.registration_ids = listReturn.ToArray(); //request.data = new TemplateRequest.Data(listReturn); //string json = new JavaScriptSerializer().Serialize(request); return(objReturn); }
public List <FleetRequestData> GetApprovalsData(string line_manager_id) { var eecEmployees = new EECEmployee(); if (!line_manager_id.Contains("@")) { line_manager_id = line_manager_id + "@kaec.net"; } line_manager_id = eecEmployees.GetEmployeeDetails(line_manager_id)[0].emp_ID; var listReturn = new List <FleetRequest>(); var tempList = new List <FleetRequest>(); using (var con = new MySqlConnection(ConnectionHelper.MyDirectoryConnection())) { con.Open(); var cmd = new MySqlCommand(); cmd = new MySqlCommand("SELECT * FROM fleet_request " + "WHERE code='0' AND randomize!='9' ORDER BY from_date DESC", con); cmd.Parameters.AddWithValue("@line_manager_id", line_manager_id); using (var dr = cmd.ExecuteReader()) { tempList = PopulateFleetRequest(dr); dr.Close(); } con.Close(); } foreach (var items in tempList) { var result = new List <EECEmployee>(); result = eecEmployees.GetEmployeeDetails(items.emp_id); var fleetServeDetails = GetFleetServeDetails(items.service_ref); if (result.Count == 0) { var nonEEC = new NonEECEmployee(); var nonEECEmployeeDetails = nonEEC.GetEmployeeDetails(items.emp_id); result.Add(new EECEmployee { cost_Center = nonEECEmployeeDetails.cost_center, department = nonEECEmployeeDetails.department, e_Mail = nonEECEmployeeDetails.email, line_Manager_Name = nonEECEmployeeDetails.manager, line_Manager_No = nonEECEmployeeDetails.manager_id }); } else { result = eecEmployees.GetEmployeeDetails(items.emp_id); } if (result.Count != 0) { foreach (var employeeDetails in result) { if (employeeDetails.line_Manager_No == line_manager_id) { var driverName = string.Empty; var driverMobile = string.Empty; var driverDetails = eecEmployees.GetEmployeeDetails(items.driver_id); foreach (var details in driverDetails) { driverName = items.nature.ToLower().Contains("chauffeur") ? "WPS Driver" : details.employee_Name_English; driverMobile = details.mobile; } items.cost_center = employeeDetails.cost_Center; items.department = employeeDetails.department; items.driver = driverName; items.driver_mobile = driverMobile; items.email = employeeDetails.e_Mail; items.line_manager = employeeDetails.line_Manager_Name; items.line_manager_email = employeeDetails.line_Manager_Email; items.line_manager_id = employeeDetails.line_Manager_No; items.complaint = fleetServeDetails.complaint; items.end_km = fleetServeDetails.end_km; items.note = fleetServeDetails.note; items.plate = fleetServeDetails.plate; items.sar = fleetServeDetails.sar; listReturn.Add(items); break; } } } } var request = new List <FleetRequestData>(); request.Add(new FleetRequestData { data = listReturn }); return(request); }
public FleetNotification GetRequestsForApprovals(string line_manager_id) { var notificationReturn = new FleetNotification(); var ctr = 0; if (!line_manager_id.Contains("@")) { line_manager_id = line_manager_id + "@kaec.net"; } var eecEmployees = new EECEmployee(); line_manager_id = eecEmployees.GetEmployeeDetails(line_manager_id)[0].emp_ID; var tempList = new List <FleetRequest>(); using (var con = new MySqlConnection(ConnectionHelper.MyDirectoryConnection())) { con.Open(); var cmd = new MySqlCommand(); cmd = new MySqlCommand("SELECT * FROM fleet_request " + "WHERE code='0' AND randomize!='9' ORDER BY from_date DESC", con); cmd.Parameters.AddWithValue("@line_manager_id", line_manager_id); using (var dr = cmd.ExecuteReader()) { tempList = FleetRequest.PopulateFleetRequest(dr); dr.Close(); } con.Close(); } foreach (var items in tempList) { var result = new List <EECEmployee>(); result = eecEmployees.GetEmployeeDetails(items.emp_id); if (result.Count == 0) { var nonEEC = new NonEECEmployee(); var nonEECEmployeeDetails = nonEEC.GetEmployeeDetails(items.emp_id); result.Add(new EECEmployee { line_Manager_No = nonEECEmployeeDetails.manager_id }); } else { result = eecEmployees.GetEmployeeDetails(items.emp_id); } if (result.Count != 0) { foreach (var employeeDetails in result) { if (employeeDetails.line_Manager_No == line_manager_id) { ctr = ctr + 1; break; } } } } notificationReturn = new FleetNotification { Notifications = ctr, Tag = "fleet approvals", }; return(notificationReturn); }