Example #1
0
        public bool GetDataFromReader(FrmNotable_Importazione.LeggiFile Reader, out WebUser WU, out FlowChartUser FCU)
        {
            Reader.GetNext();
            WU  = null;
            FCU = null;
            if (!Reader.DataPresent())
            {
                return(false);
            }
            WU  = new WebUser();
            FCU = new FlowChartUser();

            WU.cf           = Reader.getCurrField("cf");
            WU.cognome      = Reader.getCurrField("cognome");
            WU.email        = Reader.getCurrField("email");
            WU.idcustomuser = Reader.getCurrField("idcustomuser");
            WU.login        = Reader.getCurrField("login");
            WU.nome         = Reader.getCurrField("nome");
            WU.tipoutente   = Reader.getCurrField("tipoutente");

            FCU.all_sorkind01 = Reader.getCurrField("all_attr01");
            FCU.all_sorkind02 = Reader.getCurrField("all_attr02");
            FCU.all_sorkind03 = Reader.getCurrField("all_attr03");
            FCU.all_sorkind04 = Reader.getCurrField("all_attr04");
            FCU.all_sorkind05 = Reader.getCurrField("all_attr05");

            FCU.flagdefault   = Reader.getCurrField("flagdefault");
            FCU.flowchartcode = Reader.getCurrField("flowchartcode");
            FCU.idcustomuser  = Reader.getCurrField("idcustomuser").ToString();

            FCU.sorkind01_withchilds = Reader.getCurrField("attr01_childs");
            FCU.sorkind02_withchilds = Reader.getCurrField("attr02_childs");
            FCU.sorkind03_withchilds = Reader.getCurrField("attr03_childs");
            FCU.sorkind04_withchilds = Reader.getCurrField("attr04_childs");
            FCU.sorkind05_withchilds = Reader.getCurrField("attr05_childs");

            FCU.title = Reader.getCurrField("ruolo");

            FCU.idsor01 = attr_id_fromcode(1, Reader.getCurrField("codiceattr01"));
            FCU.idsor02 = attr_id_fromcode(2, Reader.getCurrField("codiceattr02"));
            FCU.idsor03 = attr_id_fromcode(3, Reader.getCurrField("codiceattr03"));
            FCU.idsor04 = attr_id_fromcode(4, Reader.getCurrField("codiceattr04"));
            FCU.idsor05 = attr_id_fromcode(5, Reader.getCurrField("codiceattr05"));

            FCU.start = Reader.getCurrField("datainizio");
            return(true);
        }
Example #2
0
        private void btnImportaUtenti_Click(object sender, EventArgs e)
        {
            DataAccess WebConn = GetWebConnection();

            if (WebConn == null)
            {
                MessageBox.Show(this, "Errore nella connessione al db di sistema web.", "Errore");
                return;
            }
            if (!CheckConnection(WebConn, true))
            {
                return;
            }

            myOpenFile.RestoreDirectory = true;
            DialogResult DR = myOpenFile.ShowDialog(this);

            if (DR != DialogResult.OK)
            {
                WebConn.Destroy();
                return;
            }
            WebConn.Open();
            FrmNotable_Importazione.LeggiFile Reader = new FrmNotable_Importazione.LeggiFile();
            Reader.Init(tracciato_importautenti, myOpenFile.FileName);
            txtResult.Text = "";
            WebUser       WU;
            FlowChartUser FCU;
            bool          err          = false;
            int           nrighe_lette = 0;

            while (GetDataFromReader(Reader, out WU, out FCU))
            {
                nrighe_lette++;
                if (WU.login == null || WU.login == DBNull.Value || WU.login.ToString() == "")
                {
                    txtResult.Text += "Utente  privo di login trovato e ignorato.\r\n";
                    err             = true;
                    Application.DoEvents();
                    continue;
                }
                string utente = WU.login + "(tipo " + WU.tipoutente + ")";

                if (WU.idcustomuser == null || WU.idcustomuser.ToString() == "")
                {
                    txtResult.Text += utente + " privo di idcustomuser quindi non creato.\r\n";
                    err             = true;
                    Application.DoEvents();
                    continue;
                }

                if (CollegaUtenteWeb(WebConn, WU, FCU))
                {
                    //txtResult.Text += utente + " creato con successo \r\n";
                }
                else
                {
                    txtResult.Text += utente + " non creato o creato con problemi.\r\n";
                    err             = true;
                    Application.DoEvents();
                }
            }
            Reader.Close();
            if (!err)
            {
                txtResult.Text += "Nessun problema riscontrato.\r\n";
            }

            WebConn.Close();
            WebConn.Destroy();
            MessageBox.Show(this, "Operazione completata. Dal file sono state lette:" + nrighe_lette + " righe.", "Avviso");
        }