예제 #1
0
        //private async Task UpdateJobFirstWrite(DateTime firstClick)
        //{
        //    try
        //    {
        //        if (Counter == 1)
        //        {
        //            var jobId = _settingsService.JobIdSettings;
        //            var job = await _jobService.GetJob(jobId);
        //            job.FirstWrite = firstClick;
        //            await _jobService.UpdateJob(jobId, job);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        throw;
        //    }

        //}
        private async Task UpdateJobLastWrite()
        {
            try
            {
                var job = await _jobService.GetJob(_settingsService.JobIdSettings);

                var machine = await _masiniService.GetMachineAsync(_settingsService.MachineIdSettings);

                var lastWrite = await _jobService.GetLastClickForJob(_settingsService.JobIdSettings);

                var currentTime = await _jobService.GetServerDateTime();

                if (lastWrite == DateTime.Parse("11/11/2011 12:00:00 AM"))
                {
                    job.LastWrite = currentTime;
                    job.Closed    = currentTime;
                }
                else if (DateTime.Parse(_settingsService.UserLoginDateSettings).Day != currentTime.Day)
                {
                    job.LastWrite = lastWrite;
                    job.Closed    = lastWrite;
                }
                else
                {
                    job.LastWrite = lastWrite;
                    job.Closed    = currentTime;
                }
                await _jobService.UpdateJob(job.Id.ToString(), job);
                await AddEfficiencyForJob(job);

                //if (machine.Active)
                //{
                //    machine.Active = false;
                //    await _masiniService.UpdateMachineActivity(machine.Id, machine);
                //}

                _settingsService.JobIdSettings            = null;
                _settingsService.JobNormSettings          = null;
                _settingsService.CounterSettings          = null;
                _settingsService.OneClickWorthSettings    = null;
                _settingsService.IsNormCalculatedSettings = null;
                _settingsService.TotalEfficiencySettings  = null;
                _settingsService.SelectedPhaseSettings    = null;
                _settingsService.LastClickSetting         = null;
                _settingsService.GoodPiecesSettings       = null;
                _settingsService.BadPiecesSettings        = null;
                await _navigationService.NavigateToAsync <HomeViewModel>();
            }
            catch (Exception e)
            {
                await _dialogService.ShowDialog(e.Message, "Exception:UpdateJobLastWrite", "OK");
            }
        }
예제 #2
0
        private async Task FirstWrite()
        {
            try
            {
                var dialog = _dialogService.ShowProgressDialog("Please wait...");
                dialog.Show();
                var currentTime = await _jobDataService.GetServerDateTime();

                var jobId = _settingsService.JobIdSettings;
                var job   = await _jobDataService.GetJob(jobId);

                job.FirstWrite = currentTime;
                await _jobDataService.UpdateJob(jobId, job);

                dialog.Hide();
                await _navigationService.NavigateToAsync <ManichinoViewModel>();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
예제 #3
0
        private async Task FirstWrite()
        {
            try
            {
                if (_settingsService.UserLineSettings != _settingsService.MachineLineSettings)
                {
                    await _dialogService.ShowDialog("You can work only in your line.", "Warning", "OK");

                    return;
                }

                var currentTime = await _jobDataService.GetServerDateTime();

                var machine = await _masiniService.GetMachineAsync(_settingsService.MachineIdSettings);

                var jobId = _settingsService.JobIdSettings;
                var job   = await _jobDataService.GetJob(jobId);

                job.FirstWrite = currentTime;
                Models.MasiniForUpdate machineToUpdate = new Models.MasiniForUpdate()
                {
                    Id       = machine.Id,
                    Occupied = false,
                    Active   = true
                };
                await _masiniService.UpdateMachineActivity(machineToUpdate, machineToUpdate.Id);

                await _jobDataService.UpdateJob(jobId, job);

                await _navigationService.NavigateToAsync <JobViewModel>();
            }
            catch (Exception e)
            {
                await _dialogService.ShowDialog(e.Message, "Exception:" + e.InnerException, "OK");
            }
        }
예제 #4
0
        //private async Task UpdateJobFirstWrite(DateTime firstClick)
        //{
        //    try
        //    {
        //        if (Counter == 1)
        //        {
        //            var jobId = _settingsService.JobIdSettings;
        //            var job = await _jobService.GetJob(jobId);
        //            job.FirstWrite = firstClick;
        //            await _jobService.UpdateJob(jobId, job);
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine(e);
        //        throw;
        //    }
        //}
        private async Task UpdateJobLastWrite(bool isStop)
        {
            try
            {
                var job = await _jobService.GetJob(_settingsService.JobIdSettings);

                var machine = await _masiniService.GetMachineAsync(_settingsService.MachineIdSettings);

                var lastWrite = await _jobService.GetLastClickForJob(_settingsService.JobIdSettings);

                var currentTime = await _jobService.GetServerDateTime();

                DateTime initialdate = DateTime.ParseExact("11/11/2011 00:00:00", "dd/MM/yyyy hh:mm:ss", null);
                if (lastWrite == initialdate)
                {
                    job.LastWrite = currentTime;
                    job.Closed    = currentTime;
                }
                else if (DateTime.Parse(_settingsService.UserLoginDateSettings).Day != currentTime.Day)
                {
                    job.LastWrite = lastWrite;
                    job.Closed    = lastWrite;
                }
                else
                {
                    job.LastWrite = lastWrite;
                    job.Closed    = currentTime;
                }
                await _jobService.UpdateJob(job.Id.ToString(), job);

                //await AddEfficiencyForJob(job);

                if (machine.Active && isStop)
                {
                    MasiniForUpdate machineToUpdate = new MasiniForUpdate()
                    {
                        Id       = machine.Id,
                        Occupied = false,
                        Active   = false
                    };
                    await _masiniService.UpdateMachineActivity(machineToUpdate, machineToUpdate.Id);
                }

                _settingsService.JobIdSettings            = null;
                _settingsService.JobNormSettings          = null;
                _settingsService.CounterSettings          = null;
                _settingsService.OneClickWorthSettings    = null;
                _settingsService.IsNormCalculatedSettings = null;
                _settingsService.TotalEfficiencySettings  = null;
                _settingsService.SelectedPhaseSettings    = null;
                _settingsService.LastClickSetting         = null;
                // MessagingCenter.Send(this, "disconnectFromBT");
                await _navigationService.NavigateToAsync <HomeViewModel>();
            }


            catch (Exception e)
            {
                await _dialogService.ShowDialog(e.Message, "Exception:UpdateJobLastWrite" + e, "OK");
            }
        }