예제 #1
0
        private async Task SaveClickData(int?defectId = null)
        {
            try
            {
                await ShiftControl(DateTime.Now.Hour);

                if (_connectionService.IsConnected)
                {
                    var normHour      = _settingsService.JobNormSettings.ToInteger();
                    var idleClickTime = new TimeSpan(1, 0, 0).TotalMinutes / normHour;
                    var clickTime     = await _jobService.GetServerDateTime();

                    var click = new Click
                    {
                        Adresa      = 0410,
                        Buton       = false,
                        Data        = clickTime,
                        IdRealizare = _settingsService.JobIdSettings.ToInteger(),
                        IdDifetto   = defectId
                    };
                    Counter++;
                    TotalPieces++;
                    await CheckMachineState();
                    await PiecesByHour(clickTime);

                    await _butoaneService.AddClick(click);

                    // await UpdateJobFirstWrite(clickTime);
                    await WeightedAverage(idleClickTime, clickTime);
                    await EfficiencyByHour(clickTime);

                    _settingsService.LastClickSetting = clickTime.ToString();
                    await ShiftControl(clickTime.Hour);
                    await WaitAndExecute((int)TimeSpan.FromMinutes(idleClickTime).TotalMilliseconds / 2, EnableClickPieceButton);

                    _settingsService.CounterSettings         = Counter.ToString();
                    _settingsService.TotalEfficiencySettings = EfficiencyTotal.ToString();
                    _settingsService.TotalPiecesSettings     = TotalPieces.ToString();
                }
                else
                {
                    await _dialogService.ShowDialog(
                        "Connection problem please connect you device to WIFI and try again.",
                        "Internet connection problem",
                        "OK");
                }
            }
            catch (HttpRequestExceptionEx e)
            {
                await _dialogService.ShowDialog(e.HttpCode + "\n" + e.Message, "HttpRequestExceptionEx:SaveData", "OK");
            }
            catch (Exception)
            {
                //ignore
            }
        }
예제 #2
0
        private async void OnSavePiece(object obj)
        {
            try
            {
                if (await _connectionService.CheckConnection())
                {
                    var clickTime = await _jobService.GetServerDateTime();
                    await ShiftControl(clickTime.Hour);

                    int.TryParse(_settingsService.CommessaIdSettings, out int commessaId);
                    int.TryParse(_settingsService.PhaseIdSettings, out int phaseId);
                    string barCode  = _settingsService.CommessaFromBarcode;
                    var    commessa = await _comenziService.GetOrderWithName(barCode);

                    int producedQuantity = await _jobService.GetProducedPieces(commessaId, phaseId);

                    if (producedQuantity >= commessa.Cantitate && !_workPermitOverQuantity)
                    {
                        // await _dialogService.ShowDialog("Test", "Test", "Ok");
                        var result = await _dialogService.ShowPromptDialog("Please enter the pin to continue and make more.", "Maxim Quanity is done!", "Ok", "Cancel", "Pin");

                        if (!result.Ok)
                        {
                            return;
                        }
                        else
                        {
                            string pin = result.Text;
                            if (!string.IsNullOrEmpty(pin))
                            {
                                bool isManager = await _usersService.GetManagerAsync(pin);

                                if (isManager)
                                {
                                    _workPermitOverQuantity = true;
                                }
                                else
                                {
                                    await _dialogService.ShowDialog("Please change JOB!", "Maxim quantity is done", "Ok");

                                    return;
                                }
                            }
                            else
                            {
                                await _dialogService.ShowDialog("Please change JOB!", "Maxim quantity is done", "Ok");

                                return;
                            }
                        }
                    }

                    var normHour      = _settingsService.JobNormSettings.ToInteger();
                    var idleClickTime = new TimeSpan(1, 0, 0).TotalMinutes / normHour;

                    var click = new Click
                    {
                        Adresa      = 0410,
                        Buton       = false,
                        IdRealizare = _settingsService.JobIdSettings.ToInteger(),
                        IdDifetto   = null
                    };
                    Counter++;
                    TotalPieces++;
                    await CheckMachineState();

                    //await PiecesByHour(clickTime); // no pieces
                    await _butoaneService.AddClick(click);

                    //  await UpdateJobFirstWrite(clickTime);
                    //await WeightedAverage(idleClickTime, clickTime);
                    //await EfficiencyByHour(clickTime); //no eff
                    _settingsService.LastClickSetting = clickTime.ToString();
                    await WaitAndExecute(10000, EnableClickPieceButton);

                    _settingsService.CounterSettings         = Counter.ToString();
                    _settingsService.TotalEfficiencySettings = EfficiencyTotal.ToString();
                    _settingsService.TotalPiecesSettings     = TotalPieces.ToString();
                }
                else
                {
                    await _dialogService.ShowDialog(
                        "Connection problem please connect your device to WIFI and try again.",
                        "Internet connection problem",
                        "OK");
                    await WaitAndExecute(1000, EnableClickPieceButton);
                }
            }
            catch (HttpRequestExceptionEx e)
            {
                await _dialogService.ShowDialog(e.HttpCode + "\n" + e.Message, "HttpRequestExceptionEx", "OK");
            }
            catch (Exception)
            {
                //ignore
            }
        }