private async Task AddEfficiencyForJob(Job job)
        {
            try
            {
                var span = job.LastWrite - job.FirstWrite;
                if (span != null)
                {
                    var norm        = _settingsService.JobNormSettings.ToInteger();
                    var currentTime = await _jobService.GetServerDateTime();

                    var normForHours  = ((double)_counter / await NormForHours(norm, currentTime) * 100f);
                    var efficiency    = span.Value.Ticks == 0 ? 0.0 : normForHours;
                    var jobEfficiency = new JobEfficiency
                    {
                        Efficiency  = efficiency,
                        RealizariID = job.Id,
                        SpentTime   = span.Value.Ticks
                    };
                    var efficiencyEntity = await _jobEfficiency.AddJobEfficiency(jobEfficiency);

                    _settingsService.EfficiencyIdsSettings += $"{efficiencyEntity.EfficiencyID},";
                }
            }
            catch (Exception e)
            {
                await _dialogService.ShowDialog($"{e.Message}", "", "OK");
            }
        }
Example #2
0
        private async Task AddEfficiencyForJob(Job job)
        {
            try
            {
                var totalpauses = new TimeSpan();
                var pauses      = await _pauseService.GetPauses(job.Id.ToString());

                if (pauses != null)
                {
                    foreach (var pause in pauses)
                    {
                        if (pause.Type == "Pause 1")
                        {
                            totalpauses += pause.EndPause - pause.StartPause;
                        }
                        if (pause.Type == "Pause 2")
                        {
                            totalpauses += pause.EndPause - pause.StartPause;
                        }
                    }
                }
                var span = job.LastWrite - job.FirstWrite - totalpauses;
                if (span != null)
                {
                    var norm = _settingsService.JobNormSettings.ToInteger();
                    // var currentTime = await _jobService.GetServerDateTime();
                    double normForHours  = _counter / norm * 100f;
                    var    efficiency    = span.Value.Ticks == 0 ? 0.0 : normForHours;
                    var    jobEfficiency = new JobEfficiency
                    {
                        Efficiency  = efficiency,
                        RealizariID = job.Id,
                        SpentTime   = span.Value.Ticks
                    };
                    var efficiencyEntity = await _jobEfficiency.AddJobEfficiency(jobEfficiency);

                    _settingsService.EfficiencyIdsSettings += $"{efficiencyEntity.EfficiencyID},";
                }
            }
            catch (Exception e)
            {
                await _dialogService.ShowDialog($"{e.Message}", "", "OK");
            }
        }