public IHttpActionResult GetMyReport(DateTime?fromDate, DateTime toDate, string client, string status, int?priority, string taskId, int?catId) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var employee = User.Identity.GetUserId(); var overallReport = db.LogReport(employee, client, fromDate, toDate, status, priority, taskId, catId).OrderBy(x => x.CreatedDate).ToList(); var myActivityReport = overallReport.GroupBy(x => x.TaskId).Select(x => x.First()).Select(x => new { x.TaskId, x.CreatedDate, Creator = x.CreatedBy, x.Client, x.Department, x.Project, x.ProjectLocation, x.Quantity, x.Category, x.Priority, x.SubCategory, x.EDOC, CreatedBy = x.CreatedById, TaskOwner = x.TaskOwnerId, x.Status, x.CompletedDate, x.Subject, x.Description, Notifications = 0, HoursWorked = overallReport.Where(y => y.TaskId == x.TaskId).Sum(y => (decimal?)y.TaskLogHoursWorked) ?? 0, ExpectedStartDate = overallReport.Where(y => y.TaskId == x.TaskId).GroupBy(y => y.TaskLogId).Select(y => y.First()).ToList().Where(tl => tl.TaskLogStartDate != null).FirstOrDefault(), TaskLog = overallReport.Where(y => y.TaskId == x.TaskId).GroupBy(y => y.TaskLogDate).Select(y => y.First()).Select(y => new { y.TaskLogId, y.TaskLogTaskId, y.TaskLogDate, y.TaskLogDescription, y.TaskLogQuantityWorked, y.TaskLogStartDate, y.TaskLogEndDate, y.TaskLogBudgetedHours, y.TaskLogHoursWorked, y.TaskLogAssignedTo, y.TaskLogAssignedToId, y.TaskLogAssignedBy, y.TaskLogAssignedById, y.TaskLogStatus }).OrderBy(y => y.TaskLogDate).ToList() }).ToList(); return(Content(HttpStatusCode.OK, new { myActivityReport })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }
public IHttpActionResult GetEmployeeDayWiseReport(string empId, string clientId, DateTime fromDate, DateTime toDate, string status, int?priority, string taskId, int?catId) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var overallReport = db.LogReport(empId, clientId, fromDate, toDate, status, priority, taskId, catId).ToList(); // var overallReport = db.EmployeeDayReport(empId, clientId, fromDate, toDate, status, priority, taskId).OrderBy(x=>x.TaskLogDate).ToList(); var employeeReport = overallReport.Where(x => x.TaskLogDate >= fromDate.Date && x.TaskLogDate <= toDate.Date.AddDays(1) && x.TaskLogAssignedById == empId).Select(x => new { x.TaskId, x.CreatedDate, x.CreatedBy, x.Subject, x.Category, x.Department, x.CompletedDate, x.EDOC, x.Priority, x.Project, x.ProjectLocation, x.Client, x.SubCategory, TaskStatus = x.Status, x.Description, x.TaskOwner, x.TaskType, x.TaskLogDate, x.TaskLogDescription, x.TaskLogStatus, HoursWorked = x.TaskLogHoursWorked, QuantityWorked = x.TaskLogQuantityWorked, TotalHoursWorked = overallReport.Where(z => z.TaskId == x.TaskId).Sum(z => (decimal?)z.TaskLogHoursWorked) ?? 0, StartAndEndDate = overallReport.Where(z => z.TaskId == x.TaskId).GroupBy(z => z.TaskLogId).Select(z => z.First()).ToList().Where(tl => tl.TaskLogStartDate != null).FirstOrDefault(), TaskLog = overallReport.Where(y => y.TaskId == x.TaskId).GroupBy(y => y.TaskLogId).Select(y => y.First()).Select(y => new { y.TaskLogId, y.TaskLogDate, y.TaskLogAssignedBy, y.TaskLogAssignedTo, y.TaskLogHoursWorked, y.TaskLogQuantityWorked, y.TaskLogDescription, y.TaskLogStatus }).OrderBy(y => y.TaskLogDate).ToList() }).ToList(); return(Content(HttpStatusCode.OK, new { employeeReport })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }
public IHttpActionResult GetClientLogReport(string empId, string clientId, DateTime fromDate, DateTime toDate, string status, int?priority, string taskId, int?catId) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var overallReport = db.LogReport(empId, clientId, fromDate, toDate, status, priority, taskId, catId).OrderBy(x => x.Client).ToList(); var reportData = overallReport.Where(x => x.Department == null).GroupBy(x => x.Client_Id).Select(x => x.First()).Select(x => new { x.Client, x.Client_Id, Task = overallReport.Where(y => y.Client_Id == x.Client_Id).GroupBy(y => y.TaskId).Select(y => y.First()).Select(y => new { y.TaskId, y.CreatedBy, y.Client, y.CreatedDate, y.EDOC, y.TaskOwner, y.TaskOwnerId, y.Category, y.SubCategory, y.Priority, y.Status, y.Description, y.Subject, y.Quantity, y.Project, y.ProjectLocation, y.AssignedTo, y.AssignedToId, HoursWorked = overallReport.Where(z => z.TaskId == y.TaskId).Sum(z => (decimal?)z.TaskLogHoursWorked) ?? 0, ExpectedStartDate = overallReport.Where(z => z.TaskId == y.TaskId).GroupBy(z => z.TaskLogId).Select(z => z.First()).ToList().Where(tl => tl.TaskLogStartDate != null).FirstOrDefault(), ExpectedEndDate = overallReport.Where(z => z.TaskId == y.TaskId).GroupBy(z => z.TaskLogId).Select(z => z.First()).ToList().Where(tl => tl.TaskLogStartDate != null).FirstOrDefault(), BudgetedHours = overallReport.Where(z => z.TaskId == y.TaskId).GroupBy(z => z.TaskLogId).Select(z => z.First()).ToList().Where(tl => tl.TaskLogStartDate != null).FirstOrDefault(), TaskLog = overallReport.Where(z => z.TaskId == y.TaskId).GroupBy(z => z.TaskLogId).Select(z => z.First()).Select(z => new { z.TaskLogId, z.TaskLogTaskId, z.TaskLogDate, z.TaskLogAssignedTo, z.TaskLogAssignedToId, z.TaskLogAssignedBy, z.TaskLogAssignedById, z.TaskLogBudgetedHours, z.TaskLogStartDate, z.TaskLogEndDate, z.TaskLogHoursWorked, z.TaskLogStatus, z.TaskLogDescription, z.TaskLogQuantityWorked }).OrderBy(z => z.TaskLogDate).ToList() }).ToList() }).ToList(); return(Content(HttpStatusCode.OK, new { reportData })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured, please try again later")); } }