public void TrackTime_ShouldReturnTrue()
        {
            //arrange
            var timesheetRepositoryMock = new Mock <ITimesheetRepository>();

            var timeLog = new TimeLog
            {
                Date         = new DateTime(),
                WorkingHours = 1,
                LastName     = "Иванов",
                Comment      = Guid.NewGuid().ToString()
            };

            timesheetRepositoryMock
            .Setup(x => x.Add(timeLog))
            .Verifiable();



            var service = new TimesheetService(timesheetRepositoryMock.Object);
            //act



            var reuslt = service.TrackTime(timeLog);


            //assert
            timesheetRepositoryMock.Verify(x => x.Add(timeLog), Times.Once);

            Assert.IsTrue(reuslt);
        }
Example #2
0
 public void TestInitialize()
 {
     _storageService        = Substitute.For <IStorageService>();
     _cognitiveService      = Substitute.For <ICognitiveService>();
     _hangoutsChatConnector = Substitute.For <IHangoutsChatConnector>();
     _timesheetService      = new TimesheetService(_storageService, _cognitiveService, _hangoutsChatConnector);
 }
Example #3
0
        public TimesheetServiceTests()
        {
            _timeLogRepositoryMock  = new Mock <ITimeLogRepository>();
            _employeeRepositoryMock = new Mock <IEmployeeRepository>();

            _service = new TimesheetService(_timeLogRepositoryMock.Object, _employeeRepositoryMock.Object);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HomeController" /> class.
 /// </summary>
 /// <param name="leaveService">The leave service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 /// <param name="lookupService">The lookup service.</param>
 /// <param name="releaseService">The release service.</param>
 public HomeController(LeaveService leaveService, TimesheetService timesheetService, LookupService lookupService, ReleaseService releaseService)
 {
     this.leaveService = leaveService;
     this.timesheetService = timesheetService;
     this.lookupService = lookupService;
     this.releaseService = releaseService;
 }
        public override async void ViewDidLoad()
        {
            base.ViewDidLoad();

            AutomaticallyAdjustsScrollViewInsets = false; // NOTE: for iOS7+
            var tableView = new UITableView(View.Bounds);

            tableView.ContentInset   = new UIEdgeInsets(64, 0, 0, 0);
            tableView.SeparatorInset = new UIEdgeInsets(0, 20, 0, 0);
            ShowLoadingOverlay();
            try
            {
                var timesheets = await TimesheetService.GetTimesheetEntries();

                tableView.Source = new OutstandingTimesheetsSource(NavigationController, timesheets);
            }
            catch (Exception ex)
            {
                var okAlertController = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                PresentViewController(okAlertController, true, null);
            }
            LoadingOverlay.Hide();
            View.AddSubview(tableView);
        }
Example #6
0
        protected async Task ExecuteSaveItemCommand()
        {
            if (IsLoading)
            {
                return;
            }
            IsLoading = true;
            try
            {
                Timesheet.Hours     = Hours;
                Timesheet.Comment   = Comment;
                Timesheet.SickLeave = SickLeave;
                await TimesheetService.SubmitTimesheetEntry(Timesheet);

                App.Navigation.PopAsync();
            }
            catch (Exception ex)
            {
                App.MainPage.DisplayAlert("Error", ex.Message, "OK", null);
            }
            finally
            {
                IsLoading = false;
            }
        }
Example #7
0
        protected void InitTasks()
        {
            var iRPCSDbAccessor       = (IRPCSDbAccessor) new RPCSSingletonDbAccessor(_rpcsContextOptions);
            var rPCSRepositoryFactory = (IRepositoryFactory) new RPCSRepositoryFactory(iRPCSDbAccessor);

            var userService = (IUserService) new UserService(rPCSRepositoryFactory, _httpContextAccessor);
            var tsAutoHoursRecordService  = (ITSAutoHoursRecordService) new TSAutoHoursRecordService(rPCSRepositoryFactory, userService);
            var vacationRecordService     = (IVacationRecordService) new VacationRecordService(rPCSRepositoryFactory, userService);
            var reportingPeriodService    = (IReportingPeriodService) new ReportingPeriodService(rPCSRepositoryFactory);
            var productionCalendarService = (IProductionCalendarService) new ProductionCalendarService(rPCSRepositoryFactory);
            var tsHoursRecordService      = (ITSHoursRecordService) new TSHoursRecordService(rPCSRepositoryFactory, userService, _tsHoursRecordServiceLogger);
            var projectService            = (IProjectService) new ProjectService(rPCSRepositoryFactory, userService);
            var departmemtService         = new DepartmentService(rPCSRepositoryFactory, userService);
            var employeeService           = (IEmployeeService) new EmployeeService(rPCSRepositoryFactory, departmemtService, userService);
            var projectMembershipService  = (IProjectMembershipService) new ProjectMembershipService(rPCSRepositoryFactory);
            var projectReportRecords      = new ProjectReportRecordService(rPCSRepositoryFactory);
            var employeeCategoryService   = new EmployeeCategoryService(rPCSRepositoryFactory);
            var applicationUserService    = new ApplicationUserService(rPCSRepositoryFactory, employeeService, userService, departmemtService,
                                                                       _httpContextAccessor, _memoryCache, projectService, _onlyofficeOptions);
            var appPropertyService = new AppPropertyService(rPCSRepositoryFactory, _adOptions, _bitrixOptions, _onlyofficeOptions, _timesheetOptions);
            var financeService     = new FinanceService(rPCSRepositoryFactory, iRPCSDbAccessor, applicationUserService, appPropertyService, _ooService);
            var timesheetService   = new TimesheetService(employeeService, employeeCategoryService, tsAutoHoursRecordService,
                                                          tsHoursRecordService, projectService, projectReportRecords, vacationRecordService, productionCalendarService, financeService, _timesheetOptions);
            var projectExternalWorkspaceService = new ProjectExternalWorkspaceService(rPCSRepositoryFactory);
            var jiraService = new JiraService(userService, _jiraOptions, projectExternalWorkspaceService, projectService);

            _taskTimesheetProcessing = new TimesheetProcessingTask(tsAutoHoursRecordService, vacationRecordService, reportingPeriodService,
                                                                   productionCalendarService, tsHoursRecordService, userService, projectService, employeeService, projectMembershipService,
                                                                   timesheetService, _timesheetOptions, _smtpOptions, _jiraOptions, jiraService, projectExternalWorkspaceService);
        }
        public void TrackTime_ShouldReturnFalse(int workingHours, string lastName)
        {
            //arrange

            var timesheetRepositoryMock = new Mock <ITimesheetRepository>();

            var timeLog = new TimeLog
            {
                Date         = new DateTime(),
                WorkingHours = workingHours,
                LastName     = lastName
            };

            timesheetRepositoryMock
            .Setup(x => x.Add(timeLog))
            .Verifiable();

            var service = new TimesheetService(timesheetRepositoryMock.Object);

            //act

            var reuslt = service.TrackTime(timeLog);

            //assert

            timesheetRepositoryMock.Verify(x => x.Add(timeLog), Times.Never);

            Assert.IsFalse(reuslt);
        }
        private UIButton CreateSubmitButton(UIPickerView hoursField, UITextField commentField, UISwitch sickLeaveField)
        {
            var submitButton = new UIButton(UIButtonType.System)
            {
                Frame = new CGRect(20, 320, View.Bounds.Width - 40, 32),
            };

            submitButton.SetTitle("Submit", UIControlState.Normal);
            submitButton.TouchUpInside += async(sender, e) =>
            {
                var timesheetEntryHoursViewModel = (TimesheetEntryHoursViewModel)hoursField.Model;
                var selectedHours = timesheetEntryHoursViewModel.SelectedValue(hoursField, hoursField.SelectedRowInComponent(0), 0);
                TimesheetEntry.Hours     = Convert.ToDecimal(selectedHours);
                TimesheetEntry.Comment   = commentField.Text;
                TimesheetEntry.SickLeave = sickLeaveField.On;
                ShowLoadingOverlay();
                try
                {
                    await TimesheetService.SubmitTimesheetEntry(TimesheetEntry);

                    NavigationController.PopViewController(true);
                }
                catch (Exception ex)
                {
                    var okAlertController = UIAlertController.Create("Error", ex.Message, UIAlertControllerStyle.Alert);
                    okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
                    PresentViewController(okAlertController, true, null);
                }
                LoadingOverlay.Hide();
            };
            return(submitButton);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DashboardController"/> class.
 /// </summary>
 /// <param name="reportService">The report service.</param>
 /// <param name="releaseService">The release service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 /// <param name="projectComplianceReportService">The project compliance report service.</param>
 /// <param name="projectService">The project service.</param>        
 public DashboardController(ReportService reportService, ReleaseService releaseService, TimesheetService timesheetService, ProjectComplianceReportService projectComplianceReportService, ProjectService projectService)
 {
     this.reportService = reportService;
     this.releaseService = releaseService;
     this.timesheetService = timesheetService;
     this.projectComplianceReportService = projectComplianceReportService;
     this.projectService = projectService;
     this.AddBreadcrumbItem(Resources.Dashboard, string.Empty);
 }
Example #11
0
        public void CronCheckShouldAllowEom()
        {
            var date1 = new DateTime(2020, 10, 30, 9, 0, 0, DateTimeKind.Local);
            var date2 = new DateTime(2020, 10, 31, 9, 0, 0, DateTimeKind.Local);

            Assert.IsFalse(TimesheetService.CronCheck("9 EOM", date1));
            Assert.IsTrue(TimesheetService.CronCheck("9 EOM", date2));
            Assert.IsTrue(TimesheetService.CronCheck("9 Fri,EOM", date1));
            Assert.IsFalse(TimesheetService.CronCheck("9,9:30 Wed,EOM", date1));
            Assert.IsTrue(TimesheetService.CronCheck("9:00 Wed,EOM", date2));
            Assert.IsFalse(TimesheetService.CronCheck("9:30 EOM", date2));
        }
Example #12
0
        public void CronCheckShouldAllowMinutesValues()
        {
            var date  = new DateTime(2020, 7, 1, 9, 30, 5, DateTimeKind.Local);
            var date2 = new DateTime(2021, 11, 5, 17, 45, 0, DateTimeKind.Local);

            Assert.IsFalse(TimesheetService.CronCheck("9 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("9:30 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("9,9:30 *", date));
            Assert.IsTrue(TimesheetService.CronCheck("9:00,9:30 *", date));
            Assert.IsFalse(TimesheetService.CronCheck("9:15 *", date));
            Assert.IsTrue(TimesheetService.CronCheck("17:45 FRI", date2));
        }
 public void SetUp()
 {
     _configuration = Substitute.For <IApiConfiguration>();
     _webFactory    = new TestWebRequestFactory();
     _service       = new TimesheetService(_configuration, _webFactory);
     _configuration.ApiBaseUrl.Returns(ApiRequestHandler.ApiRequestUri.AbsoluteUri);
     _newGuid = Guid.NewGuid();
     _cf      = new CompanyFile
     {
         Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10")
     };
     _getRangeUri = string.Format("{0}/{1}/?StartDate={2}&EndDate={3}", _cf.Uri.AbsoluteUri,
                                  _service.Route, ((DateTime?)new DateTime(2014, 10, 22)).Value.Date.ToString("s"), ((DateTime?)new DateTime(2014, 10, 29)).Value.Date.ToString("s"));
 }
Example #14
0
        public Client(string userName, string password)
        {
            this.UserName = userName;
            this.Password = password;

            ApplicationLoadService  = new ApplicationLoadService(this);
            AuthenticateService     = new AuthenticateService(this);
            AvailabilityService     = new AvailabilityService(this);
            CurrentPayPeriodService = new CurrentPayPeriodService(this);
            MobileCarrierService    = new MobileCarrierService(this);
            NotificationService     = new NotificationService(this);
            OfficeService           = new OfficeService(this);
            PlacementService        = new PlacementService(this);
            TimesheetService        = new TimesheetService(this);
            UserService             = new UserService(this);
        }
        public void TrackTime_ShouldReturnTrue()
        {
            //arrange
            var timeLog = new TimeLog
            {
                Date      = new DateTime(),
                WorkHours = 1,
                LastName  = ""
            };

            var service = new TimesheetService();
            //act
            var result = service.TrackTime(timeLog);

            //assert
            Assert.IsTrue(result);
        }
Example #16
0
        public ActionResult List(CreateTimesheetsModel createModel)
        {
            //Can use DI
            var timesheetsService = new TimesheetService();
            var timesheets        = timesheetsService.GetTimesheets(createModel.StartDate, createModel.EndDate, createModel.PlacementType);

            var model = new ListTimesheetsModel()
            {
                CandidateName     = createModel.CandidateName,
                ClientName        = createModel.ClientName,
                JobTitle          = createModel.JobTitle,
                PlacementTypeName = createModel.PlacementType == PlacementType.Weekly?"Week":"Month",
                Timesheets        = timesheets
            };

            return(View(model));
        }
Example #17
0
        public void CronCheckShouldAllowManyValues()
        {
            var date = new DateTime(2020, 7, 1, 10, 0, 0, DateTimeKind.Local);

            Assert.IsTrue(TimesheetService.CronCheck("10 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("10:00 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("9,10 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("10:00,9 Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("9,10 Wed,Fri", date));
            Assert.IsTrue(TimesheetService.CronCheck("9,10,11 Wed", date));
            Assert.IsFalse(TimesheetService.CronCheck("9 Wed,Fri", date));
            Assert.IsFalse(TimesheetService.CronCheck("10 Fri", date));
            Assert.IsTrue(TimesheetService.CronCheck("* Wed", date));
            Assert.IsTrue(TimesheetService.CronCheck("* *", date));
            Assert.IsTrue(TimesheetService.CronCheck("10 *", date));
            Assert.IsFalse(TimesheetService.CronCheck("* Fri", date));
        }
Example #18
0
        private async Task OnSubmitClick(TextView dateText, TextView customerText, TextView projectText, Spinner hoursInput, EditText commentInput, Switch sickLeaveInput)
        {
            var timesheet = BindTimesheetEntry(dateText, customerText, projectText, hoursInput, commentInput, sickLeaveInput);
            var progress  = CreateProgressDialog();

            progress.Show();
            try
            {
                await TimesheetService.SubmitTimesheetEntry(timesheet);

                Finish();
            }
            catch
            {
                CreateExceptionDialog();
            }
            progress.Hide();
        }
Example #19
0
        protected async override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.OutstandingTimesheets);
            listView            = FindViewById <ListView>(Resource.Id.List);
            listView.ItemClick += OnListViewRowClick;
            var progress = CreateProgressDialog();

            progress.Show();
            try
            {
                adapter          = new OutstandingTimesheetsAdapter(this, (await TimesheetService.GetTimesheetEntries()).ToList());
                listView.Adapter = adapter;
            }
            catch
            {
                CreateExceptionDialog();
            }
            progress.Hide();
        }
        public void SetFixture(MyobArlApiPact data)
        {
            _mockProviderService        = data.MockProviderService;
            _mockProviderServiceBaseUri = data.MockProviderServiceBaseUri;
            _mockProviderService.ClearInteractions(); //NOTE: Clears any previously registered interactions before the test is run

            _configuration = Substitute.For <IApiConfiguration>();
            _service       = new TimesheetService(_configuration, keyService: new SimpleOAuthKeyService {
                OAuthResponse = new OAuthTokens {
                    ExpiresIn = 120
                }
            });

            _cfUid = Guid.NewGuid();
            _uid   = Guid.NewGuid();

            _cf = new CompanyFile
            {
                Uri = new Uri(string.Format("{0}/accountright/{1}", _mockProviderServiceBaseUri, _cfUid))
            };
        }
Example #21
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="usrID"></param>
        private void FillData(int usrID)
        {
            //Tạo Client connect to BIMteam Services
            MemberService    memberClient     = new MemberService();
            ProjectService   projectService   = new ProjectService();
            TimesheetService timesheetService = new TimesheetService();
            //Điền Dự án
            var items = projectService.GetProjectList();

            MemberOutput member        = memberClient.MemberbyID(userID);
            var          myProjectList = items.Where(s => s.BIMmember == member.SoftName).ToList();

            cmbMyProject.ItemsSource         = myProjectList;
            cmbMyProject.IsTextSearchEnabled = true;
            cmbMyProject.DisplayMemberPath   = "TenDuAn";
            cmbMyProject.SelectedValuePath   = "MaDuAn";

            //Hủy kết nối
            memberClient.Dispose();
            projectService.Dispose();
            timesheetService.Dispose();
        }
Example #22
0
        protected async Task ExecuteLoadItemsCommand()
        {
            if (IsLoading)
            {
                return;
            }
            IsLoading = true;
            try
            {
                Timesheets.Clear();
                var timesheets = await TimesheetService.GetTimesheetEntries();

                foreach (var timesheet in timesheets)
                {
                    Timesheets.Add(new TimesheetEntryViewModel(timesheet));
                }
            }
            finally
            {
                IsLoading = false;
            }
        }
 public TimesheetDataController(TimesheetService timesheetService)
 {
     this.timesheetService = timesheetService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="LookupController" /> class.
 /// </summary>
 /// <param name="lookupService">The lookup service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 /// <param name="clientService">the client service</param>
 /// <param name="developerService">the developer service</param>
 /// <param name="ticketService">The ticket service.</param>
 public LookupController(LookupService lookupService, TimesheetService timesheetService, ClientService clientService, DeveloperService developerService, TicketService ticketService)
 {
     this.lookupService = lookupService;
     this.timesheetService = timesheetService;
     this.clientService = clientService;
     this.developerService = developerService;
     this.ticketService = ticketService;
 }
Example #25
0
 public CreateTimesheet(EmployeeService employeeService, TimesheetService timesheetService)
 {
     EmployeeService  = employeeService;
     TimesheetService = timesheetService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ReportController" /> class.
 /// </summary>
 /// <param name="projectHourReportService">The project hour report service.</param>
 /// <param name="lookupService">The lookup service.</param>
 /// <param name="timesheetReportService">The timesheet report service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 /// <param name="teamEngagementReportService">The team engagement report service.</param>
 /// <param name="teamEngagementService">The team engagement service.</param>
 /// <param name="projectService">The project service.</param>
 /// <param name="projectComplianceReportService">The project compliance report service.</param>
 /// <param name="developerService">The developer service.</param>
 /// <param name="reportService">The report service.</param>
 /// <param name="releaseService">The release service.</param>
 /// <param name="feedbackService">The feedback service.</param>
 public ReportController(ProjectHourReportService projectHourReportService, LookupService lookupService, TimesheetReportService timesheetReportService, TimesheetService timesheetService, TeamEngagementReportService teamEngagementReportService, TeamEngagementService teamEngagementService, ProjectService projectService, ProjectComplianceReportService projectComplianceReportService, DeveloperService developerService, ReportService reportService, ReleaseService releaseService, FeedbackService feedbackService)
 {
     this.projectHourReportService = projectHourReportService;
     this.lookupService = lookupService;
     this.timesheetReportService = timesheetReportService;
     this.timesheetService = timesheetService;
     this.teamEngagementReportService = teamEngagementReportService;
     this.projectService = projectService;
     this.projectComplianceReportService = projectComplianceReportService;
     this.developerService = developerService;
     this.releaseService = releaseService;
     this.reportService = reportService;
     this.feedbackService = feedbackService;
     this.teamEngagementService = teamEngagementService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AuthenticationController" /> class.
 /// </summary>
 /// <param name="developerService">The developer service.</param>
 /// <param name="leaveService">The leave service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 /// <param name="releaseService">The release service.</param>
 /// <param name="lookupService">The lookup service.</param>
 public AuthenticationController(DeveloperService developerService, LeaveService leaveService, TimesheetService timesheetService, ReleaseService releaseService, LookupService lookupService)
 {
     this.developerService = developerService;
     this.leaveService = leaveService;
     this.timesheetService = timesheetService;
     this.releaseService = releaseService;
     this.lookupService = lookupService;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TimesheetController"/> class.
 /// </summary>
 /// <param name="lookupService">The lookup service.</param>
 /// <param name="timesheetService">The timesheet service.</param>
 public TimesheetController(LookupService lookupService, TimesheetService timesheetService)
 {
     this.timesheetService = timesheetService;
     this.lookupService = lookupService;
 }
 public ManageImputedDayModule(TimesheetService timesheetService)
 {
     _timesheetService = timesheetService;
 }
Example #30
0
        public Task Execute(IJobExecutionContext context)
        {
            try
            {
                var iRPCSDbAccessor       = (IRPCSDbAccessor) new RPCSSingletonDbAccessor(_dbOptions);
                var rPCSRepositoryFactory = (IRepositoryFactory) new RPCSRepositoryFactory(iRPCSDbAccessor);

                var userService = (IUserService) new UserService(rPCSRepositoryFactory, _httpContextAccessor);
                var tsAutoHoursRecordService  = (ITSAutoHoursRecordService) new TSAutoHoursRecordService(rPCSRepositoryFactory, userService);
                var vacationRecordService     = (IVacationRecordService) new VacationRecordService(rPCSRepositoryFactory, userService);
                var reportingPeriodService    = (IReportingPeriodService) new ReportingPeriodService(rPCSRepositoryFactory);
                var productionCalendarService = (IProductionCalendarService) new ProductionCalendarService(rPCSRepositoryFactory);
                var tsHoursRecordService      = (ITSHoursRecordService) new TSHoursRecordService(rPCSRepositoryFactory, userService, _tsHoursRecordServiceLogger);
                var projectService            = (IProjectService) new ProjectService(rPCSRepositoryFactory, userService);
                var departmentService         = new DepartmentService(rPCSRepositoryFactory, userService);
                var employeeService           = (IEmployeeService) new EmployeeService(rPCSRepositoryFactory, departmentService, userService);
                var projectMembershipService  = (IProjectMembershipService) new ProjectMembershipService(rPCSRepositoryFactory);
                var employeeCategoryService   = new EmployeeCategoryService(rPCSRepositoryFactory);
                var projectReportRecords      = new ProjectReportRecordService(rPCSRepositoryFactory);
                var applicationUserService    = new ApplicationUserService(rPCSRepositoryFactory, employeeService, userService,
                                                                           departmentService, _httpContextAccessor, _memoryCache, projectService, _onlyOfficeOptions);
                var appPropertyService = new AppPropertyService(rPCSRepositoryFactory, _adConfigOptions, _bitrixConfigOptions, _onlyOfficeOptions, _timesheetConfigOptions);
                var ooService          = new OOService(applicationUserService, _onlyOfficeOptions);
                var financeService     = new FinanceService(rPCSRepositoryFactory, iRPCSDbAccessor, applicationUserService, appPropertyService, ooService);
                var timesheetService   = new TimesheetService(employeeService, employeeCategoryService, tsAutoHoursRecordService, tsHoursRecordService,
                                                              projectService, projectReportRecords, vacationRecordService, productionCalendarService, financeService, _timesheetConfigOptions);
                var projectExternalWorkspace = new ProjectExternalWorkspaceService(rPCSRepositoryFactory);
                var jiraService = new JiraService(userService, _jiraConfigOptions, projectExternalWorkspace, projectService);


                var taskTimesheetProcessing = new TimesheetProcessingTask(tsAutoHoursRecordService, vacationRecordService, reportingPeriodService, productionCalendarService,
                                                                          tsHoursRecordService, userService, projectService, employeeService, projectMembershipService, timesheetService, _timesheetConfigOptions, _smtpConfigOptions, _jiraConfigOptions, jiraService, projectExternalWorkspace);

                _timesheetJobLogger.LogInformation("Начало синхронизации с Timesheet!");
                string id = Guid.NewGuid().ToString();
                TimesheetProcessingResult timesheetProcessingResult = null;
                var fileHtmlReport = string.Empty;

                if (taskTimesheetProcessing.Add(id, true) == true)
                {
                    try
                    {
                        bool syncWithExternalTimesheet = false;
                        bool processVacationRecords    = false;
                        bool processTSAutoHoursRecords = false;
                        bool sendTSEmailNotifications  = false;
                        bool syncWithJIRA = false;
                        bool syncWithJIRASendEmailNotifications = false;


                        try
                        {
                            syncWithExternalTimesheet = _timesheetConfig.ProcessingSyncWithExternalTimesheets;
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            processVacationRecords = _timesheetConfig.ProcessingProcessVacationRecords;
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            processTSAutoHoursRecords = _timesheetConfig.ProcessingProcessTSAutoHoursRecords;
                        }
                        catch (Exception)
                        {
                        }
                        try
                        {
                            sendTSEmailNotifications = _timesheetConfig.ProcessingSendTSEmailNotifications;
                        }
                        catch (Exception)
                        {
                        }

                        try
                        {
                            syncWithJIRA = _timesheetConfig.ProcessingSyncWithJIRA;
                        }
                        catch (Exception)
                        {
                        }


                        timesheetProcessingResult = taskTimesheetProcessing.ProcessLongRunningAction("", id,
                                                                                                     syncWithExternalTimesheet, DateTime.MinValue, DateTime.MinValue, false, true, true, true, false, 350,
                                                                                                     processVacationRecords,
                                                                                                     processTSAutoHoursRecords,
                                                                                                     sendTSEmailNotifications, DateTime.Today,
                                                                                                     syncWithJIRA, DateTime.MinValue, DateTime.MinValue, false, DateTime.Today, syncWithJIRASendEmailNotifications);



                        foreach (var html in timesheetProcessingResult.fileHtmlReport)
                        {
                            fileHtmlReport += html;
                        }

                        _memoryCache.Set(timesheetProcessingResult.fileId, fileHtmlReport);
                    }
                    catch (Exception)
                    {
                    }
                    taskTimesheetProcessing.Remove(id);
                }
                if (timesheetProcessingResult != null &&
                    String.IsNullOrEmpty(fileHtmlReport) == false &&
                    !string.IsNullOrEmpty(_timesheetConfig.ProcessingReportEmailReceivers))
                {
                    byte[] binFileHtmlReport = Encoding.UTF8.GetPreamble().Concat(Encoding.UTF8.GetBytes(fileHtmlReport)).ToArray();
                    using (MemoryStream streamFileHtmlReport = new MemoryStream(binFileHtmlReport))
                    {
                        try
                        {
                            string subject  = "Отчет об обработке данных Таймшит " + DateTime.Now.ToString();
                            string bodyHtml = RPCSEmailHelper.GetSimpleHtmlEmailBody("Отчет об обработке данных Таймшит", "Отчет об обработке данных Таймшит во вложении.", null);
                            RPCSEmailHelper.SendHtmlEmailViaSMTP(_timesheetConfig.ProcessingReportEmailReceivers,
                                                                 subject,
                                                                 null,
                                                                 null,
                                                                 bodyHtml,
                                                                 null,
                                                                 null,
                                                                 streamFileHtmlReport,
                                                                 "TimesheetProcessingReport" + DateTime.Now.ToString("ddMMyyHHmmss") + ".html");
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            catch (Exception e)
            {
                _timesheetJobLogger.LogError(e.Message);
                Console.WriteLine(e);
                throw;
            }
            _timesheetJobLogger.LogInformation("Синхронизация с Timesheet закончена!");
            return(Task.CompletedTask);
        }
Example #31
0
 public ShowPayments(EmployeeService employeeService, PaymentService paymentService, TimesheetService timesheetService)
 {
     EmployeeService  = employeeService;
     PaymentService   = paymentService;
     TimesheetService = timesheetService;
 }
 public TimesheetController(TimesheetService timesheetService, IHostingEnvironment hostingEnvironment)
 {
     _timesheetService       = timesheetService;
     this.hostingEnvironment = hostingEnvironment;
 }