private static void SaveAuthModelInDB(InstallerDatas install) { //string nonQuery = @"insert into web_api_credentials (client_id,client_secret,access_token,refresh_token,redirect_url,server_url) values // ('{0}','{1}','{2}','{3}','{4}','{5}')"; //SqlCommand command = new SqlCommand(String.Format(nonQuery, authParams.ClientId, authParams.ClientSecret, // authParams.authModel.AccessToken, authParams.authModel.RefreshToken, authParams.RedirectUrl, authParams.ServerUrl)); DBContextFactory.SetConnection(install.ConnectionString); string nonQuery = @"insert into web_api_credentials (clientName,publicToken,secretToken,storeaddress) values ('{0}','{1}','{2}','{3}')"; SqlCommand command = new SqlCommand(String.Format(nonQuery, install.authParameters.ClientName, install.authParameters.PublicToken, install.authParameters.SecretToken, install.authParameters.StoreAddress)); DBContextFactory.DBContext.BeginTransaction(); int result = DBContextFactory.DBContext.NonQuery(command); if (result < 0) { DBContextFactory.DBContext.RollbackTransaction(); } else { DBContextFactory.DBContext.CommitTransaction(); } }
private void button2_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtUser.Text)) { txtUser.Text = "Remplissez ce champ!"; txtUser.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtPublicToken.Text)) { txtPublicToken.Text = "Remplissez ce champ!"; txtPublicToken.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtSecretToken.Text)) { txtSecretToken.Text = "Remplissez ce champ!"; txtSecretToken.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtStoreAddress.Text)) { txtStoreAddress.Text = "Remplissez ce champ!"; txtStoreAddress.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtJournal.Text)) { txtJournal.Text = "Remplissez ce champ!"; txtJournal.ForeColor = Color.Red; return; } if (String.IsNullOrEmpty(txtRepMercator.Text)) { txtRepMercator.Text = "Remplissez ce champ!"; txtRepMercator.ForeColor = Color.Red; return; } AuthorizationController controller = new AuthorizationController(); DataSettings ds = DatabaseManager.LoadSettings(); //AuthParameters authParams = controller.InitiateAuthorization(txtServerUrl.Text,txtClientId.Text,txtClientSecret.Text); InstallerDatas install = new InstallerDatas(); install.JournalMercator = txtJournal.Text; install.RepMercator = txtRepMercator.Text; install.ConnectionString = ds.DataConnectionString; AuthParameters authParams = new AuthParameters(); authParams.ClientName = txtUser.Text; authParams.PublicToken = txtPublicToken.Text; authParams.SecretToken = txtSecretToken.Text; authParams.StoreAddress = txtStoreAddress.Text; install.authParameters = authParams; InstallerProgressBar installPB = new InstallerProgressBar(install); installPB.Show(); this.Hide(); }
public static bool Initiate(ProgressBar progressBar, Label progressText, InstallerDatas install) { try { InitiatePB(progressBar); //Tables if (!DatabaseManager.CheckTableExistence("ADRESSE_WEB")) { Program.log("Inserting table \"ADRESSE_WEB\""); ExecuteQuery(addressTableQuery); } if (!DatabaseManager.CheckTableExistence("PAYS")) { Program.log("Inserting table \"PAYS\""); UdpateLabelText(progressText, "Inserting table \"PAYS\""); ExecuteQuery(paysTableQuery); } else { pb.PerformStep(); } if (!DatabaseManager.CheckTableExistence("WEB_API_CREDENTIALS")) { Program.log("Inserting table \"WEB_API_CREDENTIALS\""); UdpateLabelText(progressText, "Inserting table \"WEB_API_CREDENTIALS\""); ExecuteQuery(webApiTableQuery); } else { pb.PerformStep(); } //Columns Program.log("Ajout de colonnes"); UdpateLabelText(progressText, "Ajout de colonnes: Table PIEDS_V"); ExecuteQuery(String.Format(addIntColumnToTable, "PIEDS_V", "ID_WEB"), timeout: 99999); UdpateLabelText(progressText, "Ajout de colonnes: Table STOCK"); ExecuteQuery(String.Format(addIntColumnToTable, "STOCK", "S_MODIFTAG"), timeout: 99999); ExecuteQuery(String.Format(addBitColumnToTable, "STOCK", "S_WEB"), timeout: 99999); UdpateLabelText(progressText, "Ajout de colonnes: Table CLI"); ExecuteQuery(String.Format(addBitColumnToTable, "CLI", "C_FROM_WEB"), timeout: 99999); ExecuteQuery(String.Format(addIntColumnToTable, "CLI", "C_ID_WEB"), timeout: 99999); UdpateLabelText(progressText, "Ajout de colonnes: Table CAT_STCK"); ExecuteQuery(String.Format(addIntColumnToTable, "CAT_STCK", "ID_WEB")); //Insert Program.log("Ajout de données"); UdpateLabelText(progressText, "Ajout des options"); if (!ExecuteQuery(insertIntoOptions, true)) { Program.log("Inserting mdftag options failed"); } if (!ExecuteQuery(insertRepMercIntoOptions, true)) { Program.log("Inserting rep_merc options failed"); } if (!ExecuteQuery(insertJournalIntoOptions, true)) { Program.log("Inserting journal option failed"); } if (!ExecuteQuery(insertMargeIntoOptions, true)) { Program.log("Inserting stock marge option failed"); } if (!ExecuteQuery(insertCatStck1IntoOptions, true)) { Program.log("Inserting cat stck 1 option failed"); } if (!ExecuteQuery(insertCatStck2IntoOptions, true)) { Program.log("Inserting cat stck 2 option failed"); } if (!ExecuteQuery(insertCatStck3IntoOptions, true)) { Program.log("Inserting cat stck 3 option failed"); } if (!ExecuteQuery(insertDefaultCountryIntoOptions, true)) { Program.log("Inserting default country option failed"); } if (!ExecuteQuery(insertDefaultTarifIntoOptions, true)) { Program.log("Inserting default tarif option failed"); } if (!ExecuteQuery(insertIDLivIntoOptions, true)) { Program.log("Inserting id liv option failed"); } if (!ExecuteQuery(insertPays, true)) { Program.log("Inserting Pays values failed"); } SaveAuthModelInDB(install); OptionsMercator repMerc = new OptionsMercator(); OptionsMercator journal = new OptionsMercator(); string repMercValue = repMerc.GetOptionValue("NOP_REP_M").ToString(); string journalValue = journal.GetOptionValue("NOP_JOURN").ToString(); if (install.RepMercator != repMercValue) { repMerc.SetOptionValue("NOP_REP_M", install.RepMercator); } if (install.JournalMercator != journalValue) { journal.SetOptionValue("NOP_JOURN", install.JournalMercator); } progressBar.PerformStep(); Program.log("Install terminée"); UdpateLabelText(progressText, "Installation terminée"); progressBar.Value = progressBar.Maximum; return(true); } catch (Exception e) { Program.log(e.Message); Program.log(e.StackTrace); return(false); } }
public InstallerProgressBar(InstallerDatas installer) { InitializeComponent(); this.installer = installer; }