예제 #1
0
        /// <summary>
        /// Gets valid and visible Tasks
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="tasks"></param>
        /// <returns>IList<AssignmentBO></returns>
        private IList <AssignmentBO> GetVisibleTasks(string dataAccessToken, string apiVersion, IList <AssignmentBO> tasks)
        {
            IList <AssignmentBO> outputTasks        = new List <AssignmentBO>();
            TimeEntryService     integrationService = new TimeEntryService();

            if (tasks.Any())
            {
                foreach (AssignmentBO task in tasks)
                {
                    // If Task is TaskGroup then fetch Tasks for that TaskGroup
                    if (task.AssignmentID.StartsWith("G"))
                    {
                        // Fetch Assignments for TaskGroup
                        var taskRelatedAssignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                       apiVersion, task.GetAssignmentsURI).ToList();
                        IList <AssignmentBO> taskList = taskRelatedAssignments.Any() ? taskRelatedAssignments.ToList() : new List <AssignmentBO>();
                        // Call visible Tasks for that TaskGroup
                        IList <AssignmentBO> visibleTasks = GetVisibleTasks(dataAccessToken, apiVersion, taskList);
                        ((List <AssignmentBO>)outputTasks).AddRange(visibleTasks);
                    }
                    else
                    {
                        // Fetch Assignments for Task
                        var taskRelatedAssignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                       apiVersion, task.GetAssignmentsURI).ToList();
                        AssignmentBO tasksdetails = taskRelatedAssignments.Any() ? taskRelatedAssignments.SingleOrDefault() : new AssignmentBO();
                        // Add Task if not hidden
                        if (apiVersion == Constants.VERSION_5)
                        {
                            if (tasksdetails.Hide == "F")
                            {
                                task.TimeBillableByDefault = tasksdetails.TimeBillableByDefault;
                                outputTasks.Add(task);
                            }
                        }
                        else
                        {
                            task.TimeBillableByDefault = tasksdetails.TimeBillableByDefault;
                            outputTasks.Add(task);
                        }
                    }
                }
            }

            return(outputTasks);
        }
예제 #2
0
        /// <summary>
        /// Get Tasks under Project
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="project"></param>
        /// <returns>AssignmentListBO</returns>
        public AssignmentListBO GetTasks(string dataAccessToken, string apiVersion, AssignmentBO project)
        {
            AssignmentListBO outputTasks        = new AssignmentListBO();
            TimeEntryService integrationService = new TimeEntryService();

            try
            {
                if (project != null)
                {
                    // Fetch Tasks for Project
                    var projectRelatedAssignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                      apiVersion, project.GetAssignmentsURI);
                    outputTasks.Assignments = new List <AssignmentBO>();
                    foreach (AssignmentBO assignment in projectRelatedAssignments)
                    {
                        // If Assignment is TaskGroup
                        if (assignment.AssignmentID.StartsWith("G"))
                        {
                            // Fetch Assignments for TaskGroup
                            var taskRelatedAssignment = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                          apiVersion, assignment.GetAssignmentsURI);
                            taskRelatedAssignment.ToList().ForEach(outputTasks.Assignments.Add);
                        }
                        else
                        {
                            outputTasks.Assignments.Add(assignment);
                        }
                    }

                    // Call GetVisibleTasks method to fetch valid Tasks to show
                    outputTasks.Assignments = GetVisibleTasks(dataAccessToken, apiVersion, outputTasks.Assignments);
                }
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputTasks.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputTasks.ErrorMessage = "Error Fetching Tasks.";
            }

            return(outputTasks);
        }
예제 #3
0
        /// <summary>
        /// Gets data for Clients
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="employeeId"></param>
        /// <returns>AssignmentListBO</returns>
        public AssignmentListBO GetClients(string dataAccessToken, string apiVersion, int employeeId)
        {
            AssignmentListBO outputClients      = new AssignmentListBO();
            TimeEntryService integrationService = new TimeEntryService();

            try
            {
                // Fetch Assignments available to Employee
                IList <AssignmentBO> assignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                     apiVersion, employeeId);

                // Take out Clients from all Assignments
                var clientListTemp = assignments.Where(client => client.AssignmentID.StartsWith("C")).Select(p => p);
                var clientList     = clientListTemp as IList <AssignmentBO> ?? clientListTemp.ToList();
                outputClients.Assignments = clientList.Any() ? clientList.ToList() : new List <AssignmentBO>();

                // Check for extra Assignments that are not Clients and add [None] client to tackle those
                var remainingAssignments = assignments.Except((IList <AssignmentBO>)outputClients.Assignments);
                if (remainingAssignments.Count() > 0)
                {
                    // Add [None]
                    AssignmentBO client = new AssignmentBO {
                        AssignmentID = "0", ItemID = "-1", Name = "[None]"
                    };
                    outputClients.Assignments.Add(client);
                }

                // Call GetClientsVisible method to fetch valid Clients to show
                //outputClients.Assignments = GetVisibleClients(dataAccessToken, outputClients.Assignments);
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputClients.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputClients.ErrorMessage = "Error Fetching Clients.";
            }

            return(outputClients);
        }
예제 #4
0
        /// <summary>
        /// Get Projects under Client
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="client"></param>
        /// <param name="employeeAssignments"></param>
        /// <returns>AssignmentListBO</returns>
        public AssignmentListBO GetProjects(string dataAccessToken, string apiVersion, int employeeId, AssignmentBO client)
        {
            AssignmentListBO outputProjects     = new AssignmentListBO();
            TimeEntryService integrationService = new TimeEntryService();

            try
            {
                if (client != null)
                {
                    if (client.Name.Equals(Constants.NONE_TEXT))
                    {
                        // Fetch Assignments available to Employee
                        IList <AssignmentBO> assignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                             apiVersion, employeeId);

                        // Take out Projects from all Assignments
                        var projectListTemp = assignments.Where(project => !project.AssignmentID.StartsWith("C")).Select(project => project);
                        var projectList     = projectListTemp as IList <AssignmentBO> ?? projectListTemp.ToList();
                        outputProjects.Assignments = projectList.Any() ? projectList.ToList() : new List <AssignmentBO>();
                    }
                    else
                    {
                        // Calls GetAssignments of Integration layer to fetch assignments
                        outputProjects.Assignments = integrationService.GetAssignments(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion,
                                                                                       client.GetAssignmentsURI).ToList();
                    }

                    // Call GetProjectsVisible method to fetch valid Projects to show
                    //outputProjects.Assignments = GetVisibleProjects(dataAccessToken, outputProjects.Assignments);
                }
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputProjects.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputProjects.ErrorMessage = "Error Fetching Projects.";
            }

            return(outputProjects);
        }