Beispiel #1
0
 ///<summary>Only called at startup if this dialog is not supposed to be shown.  Must call GetConfig first.</summary>
 public bool TryToConnect()
 {
     if (checkConnectServer.Checked)            // && checkUsingEcw.Checked){
     //js commented this portion out in version 12.0 on 1/7/11.  Must hunt down resulting bugs.
     //if(!checkUsingEcw.Checked) {//Can't silently connect unless using eCW.
     //	return false;
     //}
     {
         RemotingClient.ServerURI = textURI.Text;
         try{
             //ecw requires hash, but non-ecw requires actual password
             if (checkUsingEcw.Checked)
             {
                 //this handles situation where an eCW user passes in an actual OdPassword
                 string password = OdPassHash;
                 if (OdPassword != "")
                 {
                     password = Userods.EncryptPassword(OdPassword, true);
                 }
                 Security.CurUser       = Security.LogInWeb(textUser2.Text, password, "", Application.ProductVersion, true);
                 Security.PasswordTyped = password;                      //so we really store the encrypted pw if ecw user passes in their real password?
             }
             else
             {
                 Security.CurUser       = Security.LogInWeb(textUser2.Text, OdPassword, "", Application.ProductVersion, false);
                 Security.PasswordTyped = OdPassword;
             }
             RemotingClient.RemotingRole = RemotingRole.ClientWeb;
             return(true);
         }
         catch {
             return(false);
         }
     }
     OpenDentBusiness.DataConnection dcon = new OpenDentBusiness.DataConnection();
     //Try to connect to the database directly
     try {
         if (textConnectionString.Text.Length > 0)
         {
             dcon.SetDb(textConnectionString.Text, "", DataConnection.DBtype);
         }
         else
         {
             dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DataConnection.DBtype);
         }
         //a direct connection does not utilize lower privileges.
         RemotingClient.RemotingRole = RemotingRole.ClientDirect;
         return(true);
     }
     catch (Exception ex) {
         return(false);
     }
 }
        private void butOK_Click(object sender, System.EventArgs e)
        {
            string originalURI = RemotingClient.ServerURI;

            RemotingClient.ServerURI = textURI.Text;
            try {
                string password = textPassword2.Text;
                string username = textUser2.Text;
                Userod user     = Security.LogInWeb(username, password, "", Application.ProductVersion, false);
                Security.CurUser            = user;
                Security.PasswordTyped      = password;
                RemotingClient.RemotingRole = RemotingRole.ClientWeb;
            }
            catch (Exception ex) {
                RemotingClient.ServerURI = originalURI;
                MessageBox.Show(ex.Message);
                return;
            }
            DialogResult = DialogResult.OK;
        }
Beispiel #3
0
 private void butOK_Click(object sender, System.EventArgs e)
 {
     if (checkConnectServer.Checked)
     {
         string originalURI = RemotingClient.ServerURI;
         RemotingClient.ServerURI = textURI.Text;
         bool useEcwAlgorithm = checkUsingEcw.Checked;
         try{
             string password = textPassword2.Text;
             if (useEcwAlgorithm)
             {
                 password = Userods.EncryptPassword(password, true);
             }
             //ecw requires hash, but non-ecw requires actual password
             Userod user = Security.LogInWeb(textUser2.Text, password, "", Application.ProductVersion, useEcwAlgorithm);
             Security.CurUser            = user;
             Security.PasswordTyped      = password;             //for ecw, this is already encrypted.//textPassword2.Text;
             RemotingClient.RemotingRole = RemotingRole.ClientWeb;
         }
         catch (Exception ex) {
             RemotingClient.ServerURI = originalURI;
             MessageBox.Show(ex.Message);
             return;
         }
     }
     else
     {
         OpenDentBusiness.DataConnection dcon;
         //Try to connect to the database directly
         try {
             DataConnection.DBtype = DatabaseType.MySql;
             if (listType.SelectedIndex == 1)
             {
                 DataConnection.DBtype = DatabaseType.Oracle;
             }
             dcon = new OpenDentBusiness.DataConnection(DataConnection.DBtype);
             if (textConnectionString.Text.Length > 0)
             {
                 dcon.SetDb(textConnectionString.Text, "", DataConnection.DBtype);
             }
             else
             {
                 dcon.SetDb(comboComputerName.Text, comboDatabase.Text, textUser.Text, textPassword.Text, "", "", DataConnection.DBtype);
             }
             //a direct connection does not utilize lower privileges.
         }
         catch (Exception ex) {
             MessageBox.Show(                    //Lan.g(this,"Could not establish connection to database."));
                 ex.Message);
             return;
         }
         RemotingClient.RemotingRole = RemotingRole.ClientDirect;
     }
     try{
         XmlWriterSettings settings = new XmlWriterSettings();
         settings.Indent      = true;
         settings.IndentChars = ("    ");
         using (XmlWriter writer = XmlWriter.Create(ODFileUtils.CombinePaths(Application.StartupPath, "FreeDentalConfig.xml"), settings)) {
             writer.WriteStartElement("ConnectionSettings");
             if (textConnectionString.Text != "")
             {
                 writer.WriteStartElement("ConnectionString");
                 writer.WriteString(textConnectionString.Text);
                 writer.WriteEndElement();
             }
             else if (RemotingClient.RemotingRole == RemotingRole.ClientDirect)
             {
                 writer.WriteStartElement("DatabaseConnection");
                 writer.WriteStartElement("ComputerName");
                 writer.WriteString(comboComputerName.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Database");
                 writer.WriteString(comboDatabase.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("User");
                 writer.WriteString(textUser.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("Password");
                 writer.WriteString(textPassword.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("NoShowOnStartup");
                 if (checkNoShow.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             else if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
             {
                 writer.WriteStartElement("ServerConnection");
                 writer.WriteStartElement("URI");
                 writer.WriteString(textURI.Text);
                 writer.WriteEndElement();
                 writer.WriteStartElement("UsingEcw");
                 if (checkUsingEcw.Checked)
                 {
                     writer.WriteString("True");
                 }
                 else
                 {
                     writer.WriteString("False");
                 }
                 writer.WriteEndElement();
                 writer.WriteEndElement();
             }
             writer.WriteStartElement("DatabaseType");
             if (listType.SelectedIndex == 0)
             {
                 writer.WriteString("MySql");
             }
             else
             {
                 writer.WriteString("Oracle");
             }
             writer.WriteEndElement();
             writer.WriteEndElement();
             writer.Flush();
         }                //using writer
     }
     catch {
         //data not saved.
     }
     //fyiReporting.RDL.DataSource.SetOpenDentalConnectionString(
     //	"Server="+ComputerName+";Database="+Database+";User ID="+DbUser+";Password="******";CharSet=utf8");
     DialogResult = DialogResult.OK;
 }