예제 #1
0
        /// <summary>
        /// Gets Time Entries week details for employee
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="employeeId"></param>
        /// <param name="startdate"></param>
        /// <param name="endDate"></param>
        /// <returns>TimeEntryWeekHoursDetailsBO</returns>
        public TimeEntryWeekHoursDetailsBO GetTimeEntriesWeekHoursDetails(string dataAccessToken, string apiVersion, int employeeId, DateTime startdate, DateTime?endDate = null)
        {
            TimeEntryWeekHoursDetailsBO weekHoursDetailsData = new TimeEntryWeekHoursDetailsBO();

            try
            {
                // Calls GetTimeEntries of Integration layer to fetch time entries data
                TimeEntryService integrationService = new TimeEntryService();
                TimeEntryListBO  timeEntriesData    = new TimeEntryListBO();
                timeEntriesData.timeEntries = integrationService.GetTimeEntries(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, employeeId,
                                                                                startdate, endDate);

                // Loop thru the days and fill week total
                weekHoursDetailsData.IsSubmitted    = true;
                weekHoursDetailsData.WeekHoursTotal = timeEntriesData.timeEntries.Sum(x => System.Double.Parse(x.TotalHours)).ToString("0.##");
                while (startdate <= endDate)
                {
                    // Check the status of sheet. If "N" then set Submitted time to false
                    var sheetStatusForNotSubmitted = timeEntriesData.timeEntries.Where(x => System.DateTime.Parse(x.Date) == startdate).Any(x => x.Sheet.Status.Equals("N"));
                    if (sheetStatusForNotSubmitted)
                    {
                        weekHoursDetailsData.IsSubmitted = false;
                    }

                    // Check the status of sheet. If "R" then set Submitted time to false
                    var sheetStatusForRejected = timeEntriesData.timeEntries.Where(x => System.DateTime.Parse(x.Date) == startdate).Any(x => x.Sheet.Status.Equals("R"));
                    if (sheetStatusForRejected)
                    {
                        weekHoursDetailsData.IsSubmitted = false;
                    }

                    startdate = startdate.AddDays(1);
                }
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                weekHoursDetailsData.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                weekHoursDetailsData.ErrorMessage = "Error Fetching Time Entries Week Total Data.";
            }

            return(weekHoursDetailsData);
        }
예제 #2
0
        /// <summary>
        /// Saves the Time Entry
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="timeEntrySubmissionDetails"></param>
        /// <returns>TimeEntryListBO</returns>
        public TimeEntryListBO SaveTimeEntry(string dataAccessToken, string apiVersion, TimeEntrySubmissionBO timeEntrySubmissionDetails)
        {
            ErrorBO         output            = null;
            TimeEntryListBO outputTimeEntries = new TimeEntryListBO();

            try
            {
                // Calls the Validations before submitting data
                output = SubmitValidation(dataAccessToken, apiVersion, timeEntrySubmissionDetails);

                // If validations pass
                if (output != null && string.IsNullOrEmpty(output.Message))
                {
                    // Call SaveTimeEntry / UpdateTimeEntry of Integration layer based on timeentryId
                    TimeEntryService integrationService = new TimeEntryService();
                    if (String.IsNullOrEmpty(timeEntrySubmissionDetails.TimeEntryId))
                    {
                        outputTimeEntries.timeEntries = integrationService.SaveTimeEntry(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                         apiVersion, timeEntrySubmissionDetails);
                    }
                    else
                    {
                        outputTimeEntries.timeEntries = integrationService.UpdateTimeEntry(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                           apiVersion, timeEntrySubmissionDetails);
                    }
                }
                else
                {
                    outputTimeEntries.ErrorMessage = output.Message;
                }
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = "Error Saving Time Entry.";
            }

            return(outputTimeEntries);
        }
예제 #3
0
        /// <summary>
        /// Get Time Entry details for specific time entry
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="timeEntryId"></param>
        /// <returns>TimeEntryListBO</returns>
        public TimeEntryListBO GetSingleTimeEntry(string dataAccessToken, string apiVersion, string timeEntryId)
        {
            TimeEntryListBO outputTimeEntries = new TimeEntryListBO();

            try
            {
                // Calls GetSingleTimeEntry of Integration layer to fetch time entry details for a specific timeEntryId
                TimeEntryService integrationService = new TimeEntryService();
                outputTimeEntries.timeEntries = integrationService.GetSingleTimeEntry(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, timeEntryId);
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = "Error Fetching Time Entries Data.";
            }

            return(outputTimeEntries);
        }
예제 #4
0
        /// <summary>
        /// Submits the Time Entries
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="employeeId"></param>
        /// <param name="startDateOfWeek"></param>
        /// <param name="endDateOfWeek"></param>
        /// <returns>TimeEntryListBO</returns>
        public TimeEntryListBO SubmitWeekTimeEntryForApproval(string dataAccessToken, string apiVersion, int employeeId, DateTime startDateOfWeek, DateTime endDateOfWeek)
        {
            TimeEntryListBO outputTimeEntries = new TimeEntryListBO();

            try
            {
                // Calls SubmitWeekTimeEntryForApproval of Integration layer to submit the time
                TimeEntryService integrationService = new TimeEntryService();
                outputTimeEntries.timeEntries = integrationService.SubmitWeekTimeEntryForApproval(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken),
                                                                                                  apiVersion, employeeId, startDateOfWeek, endDateOfWeek);
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = "Error Submitting Time Entries.";
            }

            return(outputTimeEntries);
        }
예제 #5
0
        /// <summary>
        /// Get Time Entries for employee
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="employeeId"></param>
        /// <param name="startdate"></param>
        /// <param name="endDate"></param>
        /// <returns>TimeEntryListBO</returns>
        public TimeEntryListBO GetTimeEntries(string dataAccessToken, string apiVersion, int employeeId, DateTime startdate, DateTime?endDate = null)
        {
            TimeEntryListBO outputTimeEntries = new TimeEntryListBO();

            try
            {
                // Calls GetTimeEntries of Integration layer to fetch Time Entries
                TimeEntryService integrationService = new TimeEntryService();
                outputTimeEntries.timeEntries = integrationService.GetTimeEntries(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, employeeId,
                                                                                  startdate, endDate);
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                outputTimeEntries.ErrorMessage = "Error Fetching Time Entries Data.";
            }

            return(outputTimeEntries);
        }
예제 #6
0
        /// <summary>
        /// Gets Time Entries daily total for employee
        /// </summary>
        /// <param name="dataAccessToken"></param>
        /// <param name="employeeId"></param>
        /// <param name="startdate"></param>
        /// <param name="endDate"></param>
        /// <returns>TimeEntryDailyHoursBO</returns>
        public TimeEntryDailyHoursBO GetTimeEntriesDailyTotal(string dataAccessToken, string apiVersion, int employeeId, DateTime startdate, DateTime?endDate = null)
        {
            TimeEntryDailyHoursBO dailyHoursData = new TimeEntryDailyHoursBO();

            try
            {
                // Calls GetTimeEntries of Integration layer to fetch time entries data
                TimeEntryService integrationService = new TimeEntryService();
                TimeEntryListBO  timeEntriesData    = new TimeEntryListBO();
                timeEntriesData.timeEntries = integrationService.GetTimeEntries(Constants.CONSUMER_SECRET_TOKEN, UtilityService.DecryptedText(dataAccessToken), apiVersion, employeeId,
                                                                                startdate, endDate);

                // Loop thru the days and fill daily total
                dailyHoursData.DailyHoursList = new Dictionary <string, string>();
                while (startdate <= endDate)
                {
                    // Add hours
                    double hours = timeEntriesData.timeEntries.Where(x => System.DateTime.Parse(x.Date) == startdate).Sum(x => System.Double.Parse(x.TotalHours));
                    dailyHoursData.DailyHoursList.Add(Convert.ToString(startdate), Convert.ToString(hours));

                    startdate = startdate.AddDays(1);
                }
            }
            catch (DovicoException e)
            {
                logger.Log(LogLevel.Error, e);
                dailyHoursData.ErrorMessage = e.Message;
            }
            catch (Exception e)
            {
                logger.Log(LogLevel.Error, e);
                dailyHoursData.ErrorMessage = "Error Fetching Time Entries Daily Total Data.";
            }

            return(dailyHoursData);
        }