示例#1
0
        public object Get(Project_Time_Logs request)
        {
            ApiUser hdUser = request.ApiUser;

            if (!string.IsNullOrEmpty(request.ticket))
            {
                return(TicketTimeLogs.GetTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket), request.ticket, request.page, request.limit));
            }

            if (!string.IsNullOrEmpty(request.type) &&
                ((request.type.ToLower() == "recent" || request.type.ToLower() == "linked_fb") || request.type.ToLower() == "unlinked_fb" ||
                 request.type.ToLower() == "invoiced" || request.type.ToLower() == "not_invoiced"))
            {
                int accountID = 0;
                int projectID = 0;
                int techID    = 0;
                if (request.account.HasValue)
                {
                    accountID = request.account.Value;
                }
                if (request.project.HasValue)
                {
                    projectID = request.project.Value;
                }
                if (request.tech.HasValue)
                {
                    techID = request.tech.Value;
                }
                return(Models.CommonTimeLogs.GetCommonTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, request.type.ToLower(), accountID, projectID, techID, request.page, request.limit));
            }

            if (!request.project.HasValue)
            {
                throw new HttpError(HttpStatusCode.NotFound, "Incorrect project id");
            }

            ProjectDetail projectDetail = Models.Projects.GetProjectDetails(hdUser.OrganizationId, hdUser.DepartmentId, request.project.Value);

            if (!string.IsNullOrEmpty(request.type) && request.type.ToLower() == "tickets")
            {
                return(Models.ProjectTicketTimeLogs.GetProjectTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, request.project.Value, projectDetail.AccountId, request.page, request.limit));
            }
            return(Models.ProjectTimeLogs.GetProjectTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, request.project.Value, projectDetail.AccountId, request.page, request.limit));
        }
示例#2
0
        private object GetTimeLogs(GET_Time_Logs request)
        {
            ApiUser hdUser = request.ApiUser;

            //v2
            if (request.project_time_id > 0)
            {
                DataRow plRow = bigWebApps.bigWebDesk.Data.Project.SelectProjectTimeByID(hdUser.OrganizationId, hdUser.DepartmentId, request.project_time_id);
                if (plRow == null)
                {
                    throw new HttpError(HttpStatusCode.NotFound, "No data found");
                }
                return(new ProjectTimeLog(plRow));
            }
            else if (request.ticket_time_id > 0)
            {
                DataRow tlRow = bigWebApps.bigWebDesk.Data.Tickets.SelectTicketTimeByID(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket_time_id);
                if (tlRow == null)
                {
                    throw new HttpError(HttpStatusCode.NotFound, "No data found");
                }
                return(new Ticket_Time_Log(tlRow));
            }

            if (!string.IsNullOrEmpty(request.ticket))
            {
                return(request.FilteredResult <Ticket_Time_Log>(TicketTimeLogs.GetTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, Ticket.GetId(hdUser.OrganizationId, hdUser.DepartmentId, request.ticket))));
            }

            int    accountID = request.account ?? 0;
            int    projectID = request.project ?? 0;
            int    techID    = request.tech ?? 0;
            string type      = string.IsNullOrEmpty(request.type) ? "recent" : request.type.ToLower();

            if ((string.IsNullOrEmpty(request.type) || type == "tickets") && request.project.HasValue)
            {
                if (projectID == 0)
                {
                    projectID = -2;
                }

                if (!request.account.HasValue)
                {
                    accountID = -2;
                }

                if (projectID > 0 && accountID < 0)
                {
                    ProjectDetail projectDetail = Models.Projects.GetProjectDetails(hdUser.OrganizationId, hdUser.DepartmentId, projectID);
                    accountID = projectDetail.AccountId;
                }
                if (type == "tickets")
                {
                    return(request.FilteredResult <Ticket_Time_Log>(Models.ProjectTicketTimeLogs.GetProjectTicketTimeLogs(hdUser.OrganizationId, hdUser.DepartmentId, projectID, accountID, techID, request.task_type_id, hdUser.TimeZoneOffset)));
                }
                return(request.FilteredResult <ProjectTimeLog>(Models.ProjectTimeLogs.GetProjectTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, projectID, accountID, techID, request.task_type_id)));
            }

            if (type == "recent" || type == "linked_fb" || type == "unlinked_fb" ||
                type == "invoiced" || type == "not_invoiced" || type == "unlinked_fb_billable" ||
                type == "not_invoiced_billable" || type == "not_invoiced_nonbillable" || type == "linked_qb" ||
                type == "unlinked_qb" || type == "unlinked_qb_billable" || type == "hidden_from_invoice" || type == "no_ticket_assigned")
            {
                return(request.SortedResult <CommonTimeLog>(Models.CommonTimeLogs.GetCommonTimeLog(hdUser.OrganizationId, hdUser.DepartmentId, type, accountID, projectID, techID, request.start_date, request.end_date, hdUser.TimeZoneId)));
            }
            throw new HttpError(HttpStatusCode.NotFound, "Incorrect time type");
        }