public void CambiaDescrizioneCiclo(string NoCiclo, string descrizione)
        {
            Cicli c = EstraiTestataCiclo(NoCiclo);

            c.Description = descrizione;
            _nav.UpdateObject(c);
            Salva();
        }
        public void CambiaStatoCiclo(string NoCiclo, string stato)
        {
            Cicli testata = EstraiTestataCiclo(NoCiclo);

            if (testata.Status != stato)
            {
                testata.Status = stato;
                _nav.UpdateObject(testata);
                Salva();
            }
        }
 public Cicli EstraiTestataCiclo(string NoCiclo)
 {
     if (_nav == null)
     {
         return(null);
     }
     try
     {
         Cicli t = _nav.Cicli.Where(x => x.No == NoCiclo).FirstOrDefault();
         return(t);
     }
     catch
     {
         return(null);
     }
 }
        private void AggiornaStatoCicli()
        {
            BCServices bc = new BCServices();

            bc.CreaConnessione();
            foreach (ExpCicloBusinessCentral c in _cicliExport)
            {
                Cicli testata = bc.EstraiTestataCiclo(c.Codice);
                if (testata != null)
                {
                    c.Stato = testata.Status;
                }
                else
                {
                    c.Errore = "Ciclo non trovato";
                }
            }
        }
示例#5
0
 private void btnEstraiCiclo_Click(object sender, EventArgs e)
 {
     txtMessaggio.Text = string.Empty;
     try
     {
         if (string.IsNullOrEmpty(txtDistintaNo.Text))
         {
             txtMessaggio.Text = "Inserire un codice ciclo";
             return;
         }
         BCServices bc = new BCServices();
         bc.CreaConnessione();
         Cicli testata = bc.EstraiTestataCiclo(txtNoCiclo.Text);
         txtDescrizioneCiclo.Text = testata.Description;
         txtVersioneCiclo.Text    = testata.Version_Nos;
         txtMessaggio.Text        = string.Format("{0} {1} {2}", testata.No, testata.Version_Nos, testata.Description);
         txtStatoCiclo.Text       = testata.Status;
     }
     catch (Exception ex)
     {
         txtMessaggio.Text = estraiErrore(ex);
     }
 }
        private void esportaCicli(List <string> cicli, BackgroundWorker worker, DoWorkEventArgs e, ref int contatore)
        {
            BCServices bc = new BCServices();

            bc.CreaConnessione();
            WorkerDTO dto = (WorkerDTO)e.Argument;

            foreach (string ciclo in cicli)
            {
                worker.ReportProgress(contatore, string.Format(string.Empty, ciclo));
                worker.ReportProgress(contatore, string.Format("Ciclo {0}", ciclo));

                contatore++;
                try
                {
                    Cicli testata = bc.EstraiTestataCiclo(ciclo);
                    if (testata != null)
                    {
                        bc.CambiaDescrizioneCiclo(ciclo, testata.Description);

                        testata = bc.EstraiTestataCiclo(ciclo);

                        if (testata.Status != Stato.InSviluppo)
                        {
                            string messaggio = string.Format("Ciclo {0} ignorato perchè in stato {1}", ciclo, testata.Status);
                            worker.ReportProgress(contatore, messaggio);

                            if (worker.CancellationPending)
                            {
                                e.Cancel = true;
                                return;
                            }
                            continue;
                        }

                        List <RigheCICLO> righe = bc.EstraiRigheCICLO(ciclo);
                        foreach (RigheCICLO riga in righe)
                        {
                            bc.RimuoviCommento(ciclo, string.Empty, riga.Operation_No, false);
                            bc.RimuoviFase(ciclo, string.Empty, riga.Operation_No, false);
                        }
                        bc.Salva();

                        foreach (ExpFaseCicloBusinessCentral f in dto.FasiExport.Where(x => x.CodiceCiclo == ciclo).OrderBy(x => x.Operazione))
                        {
                            try
                            {
                                f.Errore = string.Empty;
                                bc.AggiungiFase(ciclo, string.Empty, f.Operazione.ToString(), f.Tipo, f.AreaProduzione, f.Task, (decimal)f.TempoSetup, f.UMSetup, f.SchedaProcesso,
                                                (decimal)f.TempoLavorazione, f.UMLavorazione,
                                                (decimal)f.TempoAttesa, f.UMAttesa, (decimal)f.TempoSpostamento, f.UMSpostamento,
                                                (decimal)f.DimensioneLotto, f.Collegamento, f.Condizione, f.LogicheLavorazione, f.Caratteristica, f.Descrizione);
                                bc.AggiungiCommento(ciclo, string.Empty, f.Operazione.ToString(), f.CommentiConcatenati());
                                f.Esito = "OK";
                            }
                            catch (Exception ex)
                            {
                                string messaggio = string.Format("Ciclo {0} operazione {1} non esportato per il seguente errore: {2}", ciclo, f.Operazione, ex.Message);
                                {
                                    f.Errore = ex.Message;
                                    f.Esito  = "KO";
                                }
                                worker.ReportProgress(contatore, messaggio);
                            }
                        }
                        worker.ReportProgress(contatore, string.Format("Ciclo {0} terminato", ciclo));
                    }
                    else
                    {
                        string messaggio = string.Format("Il ciclo {0} non è stato trovato", ciclo);
                        foreach (ExpFaseCicloBusinessCentral c in dto.FasiExport.Where(x => x.CodiceCiclo == ciclo))
                        {
                            c.Errore = messaggio;
                            c.Esito  = "KO";
                        }
                        worker.ReportProgress(contatore, messaggio);
                    }
                }
                catch (Exception ex)
                {
                    string messaggio = string.Format("Ciclo {0} non esportato per il seguente errore: {1}", ciclo, ex.Message);
                    foreach (ExpFaseCicloBusinessCentral f in dto.FasiExport.Where(x => x.CodiceCiclo == ciclo).OrderBy(x => x.Operazione))
                    {
                        f.Errore = "Eccezione";
                        f.Esito  = "KO";
                    }
                    worker.ReportProgress(contatore, messaggio);
                }
                finally
                {
                    bc.CreaConnessione();
                }

                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }
            }
        }