///<summary>Updates one CentralConnection in the database.</summary>
        public static void Update(CentralConnection centralConnection)
        {
            string command = "UPDATE centralconnection SET "
                             + "ServerName               = '" + POut.String(centralConnection.ServerName) + "', "
                             + "DatabaseName             = '" + POut.String(centralConnection.DatabaseName) + "', "
                             + "MySqlUser                = '******', "
                             + "MySqlPassword            = '******', "
                             + "ServiceURI               = '" + POut.String(centralConnection.ServiceURI) + "', "
                             + "OdUser                   = '******', "
                             + "OdPassword               = '******', "
                             + "Note                     =  " + DbHelper.ParamChar + "paramNote, "
                             + "ItemOrder                =  " + POut.Int(centralConnection.ItemOrder) + ", "
                             + "WebServiceIsEcw          =  " + POut.Bool(centralConnection.WebServiceIsEcw) + ", "
                             + "ConnectionStatus         = '" + POut.String(centralConnection.ConnectionStatus) + "', "
                             + "HasClinicBreakdownReports=  " + POut.Bool(centralConnection.HasClinicBreakdownReports) + " "
                             + "WHERE CentralConnectionNum = " + POut.Long(centralConnection.CentralConnectionNum);

            if (centralConnection.Note == null)
            {
                centralConnection.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(centralConnection.Note));

            Db.NonQ(command, paramNote);
        }
Exemple #2
0
 private bool AreConnsEqual(CentralConnection con1, CentralConnection con2)
 {
     return(con1.ServerName.Equals(con2.ServerName) &&
            con1.DatabaseName.Equals(con2.DatabaseName) &&
            con1.MySqlUser.Equals(con2.MySqlUser) &&
            con1.MySqlPassword.Equals(con2.MySqlPassword));
 }
 ///<summary>Inserts one CentralConnection into the database.  Provides option to use the existing priKey.</summary>
 internal static long Insert(CentralConnection centralConnection,bool useExistingPK)
 {
     if(!useExistingPK && PrefC.RandomKeys) {
         centralConnection.CentralConnectionNum=ReplicationServers.GetKey("centralconnection","CentralConnectionNum");
     }
     string command="INSERT INTO centralconnection (";
     if(useExistingPK || PrefC.RandomKeys) {
         command+="CentralConnectionNum,";
     }
     command+="ServerName,DatabaseName,MySqlUser,MySqlPassword,ServiceURI,OdUser,OdPassword,Note,ItemOrder,WebServiceIsEcw) VALUES(";
     if(useExistingPK || PrefC.RandomKeys) {
         command+=POut.Long(centralConnection.CentralConnectionNum)+",";
     }
     command+=
          "'"+POut.String(centralConnection.ServerName)+"',"
         +"'"+POut.String(centralConnection.DatabaseName)+"',"
         +"'"+POut.String(centralConnection.MySqlUser)+"',"
         +"'"+POut.String(centralConnection.MySqlPassword)+"',"
         +"'"+POut.String(centralConnection.ServiceURI)+"',"
         +"'"+POut.String(centralConnection.OdUser)+"',"
         +"'"+POut.String(centralConnection.OdPassword)+"',"
         +"'"+POut.String(centralConnection.Note)+"',"
         +    POut.Int   (centralConnection.ItemOrder)+","
         +    POut.Bool  (centralConnection.WebServiceIsEcw)+")";
     if(useExistingPK || PrefC.RandomKeys) {
         Db.NonQ(command);
     }
     else {
         centralConnection.CentralConnectionNum=Db.NonQ(command,true);
     }
     return centralConnection.CentralConnectionNum;
 }
 ///<summary>Inserts one CentralConnection into the database.  Returns the new priKey.</summary>
 internal static long Insert(CentralConnection centralConnection)
 {
     if(DataConnection.DBtype==DatabaseType.Oracle) {
         centralConnection.CentralConnectionNum=DbHelper.GetNextOracleKey("centralconnection","CentralConnectionNum");
         int loopcount=0;
         while(loopcount<100){
             try {
                 return Insert(centralConnection,true);
             }
             catch(Oracle.DataAccess.Client.OracleException ex){
                 if(ex.Number==1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")){
                     centralConnection.CentralConnectionNum++;
                     loopcount++;
                 }
                 else{
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else {
         return Insert(centralConnection,false);
     }
 }
        ///<summary>Returns command-line arguments for launching Open Dental based off of the settings for the connection passed in.</summary>
        public static string GetArgsFromConnection(CentralConnection centralConnection)
        {
            string args = "";

            if (centralConnection.DatabaseName != "")
            {
                args += "ServerName=\"" + centralConnection.ServerName + "\" "
                        + "DatabaseName=\"" + centralConnection.DatabaseName + "\" "
                        + "MySqlUser=\"" + centralConnection.MySqlUser + "\" ";
                if (centralConnection.MySqlPassword != "")
                {
                    args += "MySqlPassword=\"" + CentralConnections.Decrypt(centralConnection.MySqlPassword, FormCentralManager.EncryptionKey) + "\" ";
                }
            }
            else if (centralConnection.ServiceURI != "")
            {
                args += "WebServiceUri=\"" + centralConnection.ServiceURI + "\" ";
                if (centralConnection.WebServiceIsEcw)
                {
                    args += "WebServiceIsEcw=True ";
                }
            }
            if (centralConnection.OdUser != "")
            {
                args += "UserName=\"" + Security.CurUser.UserName + "\" ";
            }
            if (centralConnection.OdPassword != "")
            {
                args += "OdPassword=\"" + Security.PasswordTyped + "\" ";
            }
            return(args);
        }
 ///<summary>Inserts one CentralConnection into the database.  Returns the new priKey.</summary>
 internal static long Insert(CentralConnection centralConnection)
 {
     if (DataConnection.DBtype == DatabaseType.Oracle)
     {
         centralConnection.CentralConnectionNum = DbHelper.GetNextOracleKey("centralconnection", "CentralConnectionNum");
         int loopcount = 0;
         while (loopcount < 100)
         {
             try {
                 return(Insert(centralConnection, true));
             }
             catch (Oracle.DataAccess.Client.OracleException ex) {
                 if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated"))
                 {
                     centralConnection.CentralConnectionNum++;
                     loopcount++;
                 }
                 else
                 {
                     throw ex;
                 }
             }
         }
         throw new ApplicationException("Insert failed.  Could not generate primary key.");
     }
     else
     {
         return(Insert(centralConnection, false));
     }
 }
        private void butRefreshConns_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            if (gridMain.SelectedIndices.Length == 0)
            {
                gridMain.SetSelected(true);
            }
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                CentralConnection conn = (CentralConnection)gridMain.Rows[gridMain.SelectedIndices[i]].Tag;
                if (conn.DatabaseName == "" && conn.ServerName == "" && conn.ServiceURI == "")
                {
                    continue;
                }
                ODThread odThread = new ODThread(ConnectAndVerify, new object[] { conn, _progVersion });
                odThread.Name      = "VerifyThread" + i;
                odThread.GroupName = "Verify";
                odThread.Start(false);
            }
            ODThread.JoinThreadsByGroupName(Timeout.Infinite, "Verify");
            List <ODThread> listComplThreads = ODThread.GetThreadsByGroupName("Verify");

            for (int i = 0; i < listComplThreads.Count; i++)
            {
                object[]          obj        = (object[])listComplThreads[i].Tag;
                CentralConnection conn       = ((CentralConnection)obj[0]);
                string            status     = ((string)obj[1]);
                CentralConnection connection = _listConns.Find(x => x.CentralConnectionNum == conn.CentralConnectionNum);
                connection.ConnectionStatus = status;
            }
            ODThread.QuitSyncThreadsByGroupName(100, "Verify");
            Cursor = Cursors.Default;
            FillGrid();
        }
        ///<summary>Converts a DataTable to a list of objects.</summary>
        public static List <CentralConnection> TableToList(DataTable table)
        {
            List <CentralConnection> retVal = new List <CentralConnection>();
            CentralConnection        centralConnection;

            foreach (DataRow row in table.Rows)
            {
                centralConnection = new CentralConnection();
                centralConnection.CentralConnectionNum = PIn.Long(row["CentralConnectionNum"].ToString());
                centralConnection.ServerName           = PIn.String(row["ServerName"].ToString());
                centralConnection.DatabaseName         = PIn.String(row["DatabaseName"].ToString());
                centralConnection.MySqlUser            = PIn.String(row["MySqlUser"].ToString());
                centralConnection.MySqlPassword        = PIn.String(row["MySqlPassword"].ToString());
                centralConnection.ServiceURI           = PIn.String(row["ServiceURI"].ToString());
                centralConnection.OdUser                    = PIn.String(row["OdUser"].ToString());
                centralConnection.OdPassword                = PIn.String(row["OdPassword"].ToString());
                centralConnection.Note                      = PIn.String(row["Note"].ToString());
                centralConnection.ItemOrder                 = PIn.Int(row["ItemOrder"].ToString());
                centralConnection.WebServiceIsEcw           = PIn.Bool(row["WebServiceIsEcw"].ToString());
                centralConnection.ConnectionStatus          = PIn.String(row["ConnectionStatus"].ToString());
                centralConnection.HasClinicBreakdownReports = PIn.Bool(row["HasClinicBreakdownReports"].ToString());
                retVal.Add(centralConnection);
            }
            return(retVal);
        }
        private void ConnectAndVerify(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];

            try {
                string progVersion = (string)odThread.Parameters[1];
                if (!CentralConnectionHelper.UpdateCentralConnection(connection, false))
                {
                    odThread.Tag = new object[] { connection, "OFFLINE" };                 //Can't connect
                    return;
                }
                string progVersionRemote = PrefC.GetStringNoCache(PrefName.ProgramVersion);
                string err = "";
                if (progVersionRemote != progVersion)
                {
                    err = progVersionRemote;
                }
                else
                {
                    err = "OK";
                }
                odThread.Tag = new object[] { connection, err };
            }
            catch (Exception ex) {
                ex.DoNothing();
                odThread.Tag = new object[] { connection, "OFFLINE" };             //Can't connect
            }
        }
Exemple #10
0
        ///<summary>Returns command-line arguments for launching Open Dental based off of the settings for the connection passed in.</summary>
        private static string GetArgsFromConnection(CentralConnection centralConnection, bool useDynamicMode)
        {
            string args = "";

            if (centralConnection.DatabaseName != "")
            {
                args += "ServerName=\"" + centralConnection.ServerName + "\" "
                        + "DatabaseName=\"" + centralConnection.DatabaseName + "\" "
                        + "MySqlUser=\"" + centralConnection.MySqlUser + "\" ";
                if (centralConnection.MySqlPassword != "")
                {
                    args += "MySqlPassword=\"" + CentralConnections.Decrypt(centralConnection.MySqlPassword, FormCentralManager.EncryptionKey) + "\" ";
                }
            }
            else if (centralConnection.ServiceURI != "")
            {
                args += "WebServiceUri=\"" + centralConnection.ServiceURI + "\" ";
                if (centralConnection.WebServiceIsEcw)
                {
                    args += "WebServiceIsEcw=True ";
                }
            }
            args += "DynamicMode=\"" + (useDynamicMode.ToString()) + "\" ";
            return(args);
        }
Exemple #11
0
 public FormCentralPatientTransfer(CentralConnection sourceConn, List <CentralConnection> listConnections)
 {
     _sourceConnection            = sourceConn;
     _listConnections             = listConnections.FindAll(x => x.CentralConnectionNum != sourceConn.CentralConnectionNum);//Remove the source connection from list
     _listPatientDataRows         = new List <DataRow>();
     _listConnectionsToTransferTo = new List <CentralConnection>();
     InitializeComponent();
 }
Exemple #12
0
        private void GetDataFromSourceConnection(ODThread oDThread)
        {
            CentralConnection conn = (CentralConnection)oDThread.Parameters[0];

            _listSheetsForSelectedPats = new List <Sheet>();
            CentralConnectionHelper.SetCentralConnection(conn, false);
            List <long> listPatNumsToTransfer = _listPatientDataRows.Select(x => PIn.Long(x["PatNum"].ToString())).ToList();

            _listSheetsForSelectedPats = GetSheetsForTransfer(listPatNumsToTransfer);
        }
Exemple #13
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            FormCentralConnectionEdit formC = new FormCentralConnectionEdit();
            CentralConnection         cc    = new CentralConnection();

            cc.IsNew = true;;
            formC.CentralConnectionCur = cc;
            formC.ShowDialog();
            FillGrid();
        }
        private void GetDataTablePatForConn(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];
            //Filter the threads by their connection name
            string connName = "";

            if (connection.DatabaseName == "")           //uri
            {
                connName = connection.ServiceURI;
            }
            else
            {
                connName = connection.ServerName + ", " + connection.DatabaseName;
            }
            if (!CentralConnectionHelper.SetCentralConnection(connection, false))
            {
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName;
                    _complConnCount++;
                }
                connection.ConnectionStatus = "OFFLINE";
                BeginInvoke((Action)FillGridPats);
                return;
            }
            List <DisplayField> fields = DisplayFields.GetForCategory(DisplayFieldCategory.CEMTSearchPatients);
            bool      hasNextLastVisit = fields.Any(x => x.InternalName.In("NextVisit", "LastVisit"));
            DataTable table            = new DataTable();

            try {
                PtTableSearchParams ptTableSearchParams = new PtTableSearchParams(checkLimit.Checked, textLName.Text, textFName.Text, textPhone.Text,
                                                                                  textAddress.Text, checkHideInactive.Checked, textCity.Text, textState.Text, textSSN.Text, textPatNum.Text, textChartNumber.Text, 0,
                                                                                  checkGuarantors.Checked, !checkHideArchived.Checked,//checkHideArchived is opposite label for what this function expects, but hideArchived makes more sense
                                                                                  SIn.DateT(textBirthdate.Text), 0, textSubscriberID.Text, textEmail.Text, textCountry.Text, "", "", "", "", hasNextLastVisit: hasNextLastVisit);
                table = Patients.GetPtDataTable(ptTableSearchParams);
            }
            catch (ThreadAbortException tae) {
                throw tae;                //ODThread needs to clean up after an abort exception is thrown.
            }
            catch (Exception) {
                //This can happen if the connection to the server was severed somehow during the execution of the query.
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName + "  -GetPtDataTable";
                    _complConnCount++;
                }
                BeginInvoke((Action)FillGridPats);                //Pops up a message box if this was the last thread to finish.
                return;
            }
            table.TableName = connName;
            odThread.Tag    = table;
            lock (_lockObj) {
                _complConnCount++;
                _dataSetPats.Tables.Add((DataTable)odThread.Tag);
            }
            BeginInvoke((Action)FillGridPats);
        }
        private void ConnectAndSearch(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];

            if (!CentralConnectionHelper.UpdateCentralConnection(connection, false)) //No updating the cache since we're going to be connecting to multiple remote servers at the same time.
            {
                odThread.Tag = new object[] { connection, false };                   //Can't connect, just return false to not include the connection.
                connection.ConnectionStatus = "OFFLINE";
                return;
            }
            List <Provider> listProvs = Providers.GetProvsNoCache();
            //If clinic and provider are both entered is it good enough to find one match among the two?  I'm going to assume yes for now, and maybe later
            //if we decide that if both boxes have something entered that both entries need to be in the db we're searching I can change it.
            bool provMatch = false;

            for (int i = 0; i < listProvs.Count; i++)
            {
                if (textProviderSearch.Text == "")
                {
                    provMatch = true;
                    break;
                }
                if (listProvs[i].Abbr.ToLower().Contains(textProviderSearch.Text.ToLower()) ||
                    listProvs[i].LName.ToLower().Contains(textProviderSearch.Text.ToLower()) ||
                    listProvs[i].FName.ToLower().Contains(textProviderSearch.Text.ToLower()))
                {
                    provMatch = true;
                    break;
                }
            }
            List <Clinic> listClinics = Clinics.GetClinicsNoCache();
            bool          clinMatch   = false;

            for (int i = 0; i < listClinics.Count; i++)
            {
                if (textClinicSearch.Text == "")
                {
                    clinMatch = true;
                    break;
                }
                if (listClinics[i].Description.ToLower().Contains(textClinicSearch.Text.ToLower()))
                {
                    clinMatch = true;
                    break;
                }
            }
            if (clinMatch && provMatch)
            {
                odThread.Tag = new object[] { connection, true };             //Match found
            }
            else
            {
                odThread.Tag = new object[] { connection, false };             //No match found
            }
        }
 private void butOK_Click(object sender, EventArgs e)
 {
     //Add any selected connections to ListConns so that forms outside know which connections to add.
     ListConns.Clear();
     foreach (int i in gridMain.SelectedIndices)
     {
         CentralConnection conn = (CentralConnection)gridMain.Rows[i].Tag;
         ListConns.Add(conn);
     }
     DialogResult = DialogResult.OK;
 }
        private void GetPtDataTableForConn(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];
            //Filter the threads by their connection name
            string connName = "";

            if (connection.DatabaseName == "")           //uri
            {
                connName = connection.ServiceURI;
            }
            else
            {
                connName = connection.ServerName + ", " + connection.DatabaseName;
            }
            if (!CentralConnectionHelper.UpdateCentralConnection(connection, false))
            {
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName;
                    _complConnAmt++;
                }
                connection.ConnectionStatus = "OFFLINE";
                BeginInvoke(new FillGridDelegate(FillGrid));
                return;
            }
            DataTable table = new DataTable();

            try {
                table = Patients.GetPtDataTable(checkLimit.Checked, textLName.Text, textFName.Text, textPhone.Text,
                                                textAddress.Text, checkHideInactive.Checked, textCity.Text, textState.Text,
                                                textSSN.Text, textPatNum.Text, textChartNumber.Text, 0,
                                                checkGuarantors.Checked, !checkHideArchived.Checked,//checkHideArchived is opposite label for what this function expects, but hideArchived makes more sense
                                                PIn.DateT(textBirthdate.Text), 0, textSubscriberID.Text, textEmail.Text, textCountry.Text, "", "", "");
            }
            catch (ThreadAbortException tae) {
                throw tae;                //ODThread needs to clean up after an abort exception is thrown.
            }
            catch (Exception) {
                //This can happen if the connection to the server was severed somehow during the execution of the query.
                lock (_lockObj) {
                    _invalidConnsLog += "\r\n" + connName + "  -GetPtDataTable";
                    _complConnAmt++;
                }
                BeginInvoke(new FillGridDelegate(FillGrid));                //Pops up a message box if this was the last thread to finish.
                return;
            }
            table.TableName = connName;
            odThread.Tag    = table;
            lock (_lockObj) {
                _complConnAmt++;
                _dataConnPats.Tables.Add((DataTable)odThread.Tag);
            }
            BeginInvoke(new FillGridDelegate(FillGrid));
        }
 ///<summary>Returns true if Update(CentralConnection,CentralConnection) would make changes to the database.
 ///Does not make any changes to the database and can be called before remoting role is checked.</summary>
 public static bool UpdateComparison(CentralConnection centralConnection, CentralConnection oldCentralConnection)
 {
     if (centralConnection.ServerName != oldCentralConnection.ServerName)
     {
         return(true);
     }
     if (centralConnection.DatabaseName != oldCentralConnection.DatabaseName)
     {
         return(true);
     }
     if (centralConnection.MySqlUser != oldCentralConnection.MySqlUser)
     {
         return(true);
     }
     if (centralConnection.MySqlPassword != oldCentralConnection.MySqlPassword)
     {
         return(true);
     }
     if (centralConnection.ServiceURI != oldCentralConnection.ServiceURI)
     {
         return(true);
     }
     if (centralConnection.OdUser != oldCentralConnection.OdUser)
     {
         return(true);
     }
     if (centralConnection.OdPassword != oldCentralConnection.OdPassword)
     {
         return(true);
     }
     if (centralConnection.Note != oldCentralConnection.Note)
     {
         return(true);
     }
     if (centralConnection.ItemOrder != oldCentralConnection.ItemOrder)
     {
         return(true);
     }
     if (centralConnection.WebServiceIsEcw != oldCentralConnection.WebServiceIsEcw)
     {
         return(true);
     }
     if (centralConnection.ConnectionStatus != oldCentralConnection.ConnectionStatus)
     {
         return(true);
     }
     if (centralConnection.HasClinicBreakdownReports != oldCentralConnection.HasClinicBreakdownReports)
     {
         return(true);
     }
     return(false);
 }
        ///<summary>Function used by threads to connect to remote databases and sync security lock settings.</summary>
        private static void ConnectAndSyncLocks(ODThread odThread)
        {
            CentralConnection connection = (CentralConnection)odThread.Parameters[0];
            string            serverName = "";

            if (connection.ServiceURI != "")
            {
                serverName = connection.ServiceURI;
            }
            else
            {
                serverName = connection.ServerName + ", " + connection.DatabaseName;
            }
            if (!CentralConnectionHelper.UpdateCentralConnection(connection, false))            //No updating the cache since we're going to be connecting to multiple remote servers at the same time.
            {
                odThread.Tag = new List <string>()
                {
                    serverName + "\r\n", "", ""
                };
                connection.ConnectionStatus = "OFFLINE";
                return;
            }
            string remoteSyncCode = PrefC.GetString(PrefName.CentralManagerSyncCode);

            if (remoteSyncCode != _syncCode)
            {
                if (remoteSyncCode == "")
                {
                    Prefs.UpdateStringNoCache(PrefName.CentralManagerSyncCode, _syncCode);                   //Lock in the sync code for the remote server.
                }
                else
                {
                    odThread.Tag = new List <string>()
                    {
                        serverName + "\r\n", "", remoteSyncCode
                    };
                    return;
                }
            }
            //Push the preferences to the server.
            Prefs.UpdateStringNoCache(PrefName.SecurityLockDate, _securityLockDate);
            Prefs.UpdateIntNoCache(PrefName.SecurityLockDays, _securityLockDays);
            Prefs.UpdateBoolNoCache(PrefName.SecurityLockIncludesAdmin, _securityLockAdmin);
            Prefs.UpdateBoolNoCache(PrefName.CentralManagerSecurityLock, _securityCentralLock);
            Signalods.SetInvalidNoCache(InvalidType.Prefs);
            SecurityLogs.MakeLogEntryNoCache(Permissions.SecurityAdmin, 0, "Enterprise Management Tool updated security settings");
            odThread.Tag = new List <string>()
            {
                "", "", ""
            };                                                       //No errors.
        }
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            CentralConnection conn = (CentralConnection)gridMain.Rows[e.Row].Tag;

            if (conn.ConnectionStatus == "OFFLINE")
            {
                MsgBox.Show(this, "Server Offline.  Fix connection and check status again to connect.");
                return;
            }
            if (conn.ConnectionStatus != "OK")
            {
                MsgBox.Show(this, "Version mismatch.  Either update your program or update the remote server's program and check status again to connect.");
                return;
            }
            string args = "";

            if (conn.DatabaseName != "")
            {
                //ServerName=localhost DatabaseName=opendental MySqlUser=root MySqlPassword=
                args += "ServerName=\"" + conn.ServerName + "\" "
                        + "DatabaseName=\"" + conn.DatabaseName + "\" "
                        + "MySqlUser=\"" + conn.MySqlUser + "\" ";
                if (conn.MySqlPassword != "")
                {
                    args += "MySqlPassword=\"" + CentralConnections.Decrypt(conn.MySqlPassword, EncryptionKey) + "\" ";
                }
            }
            else if (conn.ServiceURI != "")
            {
                args += "WebServiceUri=\"" + conn.ServiceURI + "\" ";          //Command line args expects WebServiceUri explicitly. Case sensitive.
                if (conn.WebServiceIsEcw)
                {
                    args += "WebServiceIsEcw=True ";
                }
            }
            else
            {
                MessageBox.Show("Either a database or a Middle Tier URI must be specified in the connection.");
                return;
            }
            if (checkAutoLog.Checked)
            {
                args += "UserName=\"" + Security.CurUser.UserName + "\" ";
                args += "OdPassword=\"" + Security.PasswordTyped + "\" ";
            }
                        #if DEBUG
            Process.Start("C:\\Development\\OPEN DENTAL SUBVERSION\\head\\OpenDental\\bin\\Debug\\OpenDental.exe", args);
                        #else
            Process.Start("OpenDental.exe", args);
                        #endif
        }
        private void butAdd_Click(object sender, EventArgs e)
        {
            CentralConnection conn = new CentralConnection();

            conn.IsNew = true;
            FormCentralConnectionEdit FormCCS = new FormCentralConnectionEdit();

            FormCCS.CentralConnectionCur = conn;
            if (FormCCS.ShowDialog() == DialogResult.OK)           //Will insert conn on OK.
            {
                _listConns = CentralConnections.GetConnections();
                FillGrid();
            }
        }
        private void butAdd_Click(object sender, EventArgs e)
        {
            CentralConnection conn = new CentralConnection();

            conn.IsNew = true;
            FormCentralConnectionEdit FormCCS = new FormCentralConnectionEdit();

            FormCCS.CentralConnectionCur = conn;
            if (FormCCS.ShowDialog() == DialogResult.OK)     //Will insert conn on OK.
            {
                ListConns.Add(FormCCS.CentralConnectionCur); //IsNew will be false if inserted
            }
            FillGrid();                                      //Refreshing the grid will show any new connections added.
        }
 ///<summary>Inserts one CentralConnection into the database.  Returns the new priKey.  Doesn't use the cache.</summary>
 public static long InsertNoCache(CentralConnection centralConnection)
 {
     if (DataConnection.DBtype == DatabaseType.MySql)
     {
         return(InsertNoCache(centralConnection, false));
     }
     else
     {
         if (DataConnection.DBtype == DatabaseType.Oracle)
         {
             centralConnection.CentralConnectionNum = DbHelper.GetNextOracleKey("centralconnection", "CentralConnectionNum");                  //Cacheless method
         }
         return(InsertNoCache(centralConnection, true));
     }
 }
        ///<summary>Inserts one CentralConnection into the database.  Provides option to use the existing priKey.  Doesn't use the cache.</summary>
        public static long InsertNoCache(CentralConnection centralConnection, bool useExistingPK)
        {
            bool   isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys);
            string command      = "INSERT INTO centralconnection (";

            if (!useExistingPK && isRandomKeys)
            {
                centralConnection.CentralConnectionNum = ReplicationServers.GetKeyNoCache("centralconnection", "CentralConnectionNum");
            }
            if (isRandomKeys || useExistingPK)
            {
                command += "CentralConnectionNum,";
            }
            command += "ServerName,DatabaseName,MySqlUser,MySqlPassword,ServiceURI,OdUser,OdPassword,Note,ItemOrder,WebServiceIsEcw,ConnectionStatus,HasClinicBreakdownReports) VALUES(";
            if (isRandomKeys || useExistingPK)
            {
                command += POut.Long(centralConnection.CentralConnectionNum) + ",";
            }
            command +=
                "'" + POut.String(centralConnection.ServerName) + "',"
                + "'" + POut.String(centralConnection.DatabaseName) + "',"
                + "'" + POut.String(centralConnection.MySqlUser) + "',"
                + "'" + POut.String(centralConnection.MySqlPassword) + "',"
                + "'" + POut.String(centralConnection.ServiceURI) + "',"
                + "'" + POut.String(centralConnection.OdUser) + "',"
                + "'" + POut.String(centralConnection.OdPassword) + "',"
                + DbHelper.ParamChar + "paramNote,"
                + POut.Int(centralConnection.ItemOrder) + ","
                + POut.Bool(centralConnection.WebServiceIsEcw) + ","
                + "'" + POut.String(centralConnection.ConnectionStatus) + "',"
                + POut.Bool(centralConnection.HasClinicBreakdownReports) + ")";
            if (centralConnection.Note == null)
            {
                centralConnection.Note = "";
            }
            OdSqlParameter paramNote = new OdSqlParameter("paramNote", OdDbType.Text, POut.StringParam(centralConnection.Note));

            if (useExistingPK || isRandomKeys)
            {
                Db.NonQ(command, paramNote);
            }
            else
            {
                centralConnection.CentralConnectionNum = Db.NonQ(command, true, "CentralConnectionNum", "centralConnection", paramNote);
            }
            return(centralConnection.CentralConnectionNum);
        }
        ///<summary>Updates one CentralConnection in the database.</summary>
        internal static void Update(CentralConnection centralConnection)
        {
            string command = "UPDATE centralconnection SET "
                             + "ServerName          = '" + POut.String(centralConnection.ServerName) + "', "
                             + "DatabaseName        = '" + POut.String(centralConnection.DatabaseName) + "', "
                             + "MySqlUser           = '******', "
                             + "MySqlPassword       = '******', "
                             + "ServiceURI          = '" + POut.String(centralConnection.ServiceURI) + "', "
                             + "OdUser              = '******', "
                             + "OdPassword          = '******', "
                             + "Note                = '" + POut.String(centralConnection.Note) + "', "
                             + "ItemOrder           =  " + POut.Int(centralConnection.ItemOrder) + ", "
                             + "WebServiceIsEcw     =  " + POut.Bool(centralConnection.WebServiceIsEcw) + " "
                             + "WHERE CentralConnectionNum = " + POut.Long(centralConnection.CentralConnectionNum);

            Db.NonQ(command);
        }
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            CentralConnection conn = (CentralConnection)gridMain.Rows[e.Row].Tag;
            string            args = CentralConnectionHelper.GetArgsFromConnection(conn);

            if (AutoLogIn)
            {
                args += "UserName=\"" + Security.CurUser.UserName + "\" ";
                args += "OdPassword=\"" + Security.PasswordTyped + "\" ";
            }
            args += "PatNum=" + gridMain.Rows[e.Row].Cells[1].Text;        //PatNum
                        #if DEBUG
            Process.Start("C:\\Development\\OPEN DENTAL SUBVERSION\\head\\OpenDental\\bin\\Debug\\OpenDental.exe", args);
                        #else
            Process.Start("OpenDental.exe", args);
                        #endif
        }
Exemple #27
0
        private void FillGridConnections()
        {
            Dictionary <ConnectionNames, CentralConnection> dictConnDefaults = null;

            ODException.SwallowAnyException(() => { dictConnDefaults = DataAction.GetHqConnections(); });
            if (dictConnDefaults == null)
            {
                MsgBox.Show("Error loading default HQ connections.  Please restart Open Dental or log off and log back in.");
                return;
            }
            Dictionary <ConnectionNames, CentralConnection> dictConnOverrides = _siteLink.DictConnectionSettingsHQOverrides;

            gridConnections.BeginUpdate();
            if (gridConnections.ListGridColumns.Count < 1)
            {
                //The order of these columns matter.  See GetConnectionOverrides()
                gridConnections.ListGridColumns.Add(new GridColumn("Conn Name", -1));
                gridConnections.ListGridColumns.Add(new GridColumn("Server", -1, true));
                gridConnections.ListGridColumns.Add(new GridColumn("Database", -1, true));
                gridConnections.ListGridColumns.Add(new GridColumn("User", -1, true));
                gridConnections.ListGridColumns.Add(new GridColumn("Password", -1, true));
            }
            Action <ConnectionNames> actionAddConnection = (connName) => {
                GridRow           row        = new GridRow();
                CentralConnection connection = dictConnDefaults[connName];
                if (dictConnOverrides != null && dictConnOverrides.ContainsKey(connName))
                {
                    connection = dictConnOverrides[connName];
                    row.Bold   = true;
                }
                row.Cells.Add(connName.ToString());
                row.Cells.Add(connection.ServerName ?? "");
                row.Cells.Add(connection.DatabaseName ?? "");
                row.Cells.Add(connection.MySqlUser ?? "");
                row.Cells.Add(connection.MySqlPassword ?? "");
                row.Tag = connName;
                gridConnections.ListGridRows.Add(row);
            };

            gridConnections.ListGridRows.Clear();
            actionAddConnection(ConnectionNames.BugsHQ);
            actionAddConnection(ConnectionNames.CustomersHQ);
            actionAddConnection(ConnectionNames.ManualPublisher);
            actionAddConnection(ConnectionNames.WebChat);
            gridConnections.EndUpdate();
        }
Exemple #28
0
 private bool InsertSheetsToConnection(CentralConnection conn, List <Sheet> listSheets)
 {
     if (!CentralConnectionHelper.SetCentralConnection(conn, false))
     {
         conn.ConnectionStatus = Lans.g(this, "OFFLINE");
         return(false);
     }
     //make sure the sheets have patnum=0 and the sheet is marked as new and sheetnum=0.
     foreach (Sheet sheet in listSheets)
     {
         sheet.SheetNum = 0;
         sheet.PatNum   = 0;
         sheet.IsNew    = true;
     }
     Sheets.SaveNewSheetList(listSheets);
     return(true);
 }
Exemple #29
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            CentralConnection conn = new CentralConnection();

            conn.IsNew = true;
            FormCentralConnectionEdit FormCCE = new FormCentralConnectionEdit();

            FormCCE.CentralConnectionCur = conn;
            FormCCE.LastItemOrder        = 0;
            if (_listConnsAll.Count > 0)
            {
                FormCCE.LastItemOrder = _listConnsAll[_listConnsAll.Count - 1].ItemOrder;
            }
            FormCCE.ShowDialog();
            _listConnsAll = CentralConnections.GetConnections();
            FillGrid();
        }
Exemple #30
0
        ///<summary>Returns a JSON serialized version of a connection override dictionary based off of gridConnection.
        ///Users can edit cells of the grid to change the site overrides and this method returns what should be saved to the db.</summary>
        private string GetConnectionOverrides()
        {
            string retVal = "";
            Dictionary <ConnectionNames, CentralConnection> dictConnDefaults  = DataAction.GetHqConnections();
            Dictionary <ConnectionNames, CentralConnection> dictConnOverrides = new Dictionary <ConnectionNames, CentralConnection>();

            foreach (GridRow row in gridConnections.ListGridRows)
            {
                ConnectionNames connName = (ConnectionNames)row.Tag;
                if (!dictConnDefaults.ContainsKey(connName))
                {
                    continue;                    //Should never happen.
                }
                CentralConnection connectionDefault = dictConnDefaults[connName];
                //Read in the cell text and create an override if any of the values differ from the default.
                string serverName    = row.Cells[1].Text;
                string databaseName  = row.Cells[2].Text;
                string mySqlUser     = row.Cells[3].Text;
                string mySqlPassword = row.Cells[4].Text;
                if (serverName.IsNullOrEmpty() &&
                    databaseName.IsNullOrEmpty() &&
                    mySqlUser.IsNullOrEmpty() &&
                    mySqlPassword.IsNullOrEmpty())
                {
                    continue;                    //Do not add an override, this will cause the connection to go back to using the default.
                }
                if (serverName != connectionDefault.ServerName ||
                    databaseName != connectionDefault.DatabaseName ||
                    mySqlUser != connectionDefault.MySqlUser ||
                    mySqlPassword != connectionDefault.MySqlPassword)
                {
                    dictConnOverrides[connName] = new CentralConnection()
                    {
                        ServerName    = serverName,
                        DatabaseName  = databaseName,
                        MySqlUser     = mySqlUser,
                        MySqlPassword = mySqlPassword
                    };
                }
            }
            if (dictConnOverrides.Count > 0)
            {
                retVal = GetOverridesSerialized(dictConnOverrides);
            }
            return(retVal);
        }
Exemple #31
0
        ///<summary>Sets the current data connection settings of the central manager to the connection settings passed in.  Setting refreshCache to true will cause the entire local cache to get updated with the cache from the connection passed in if the new connection settings are successful.</summary>
        public static bool SetCentralConnection(CentralConnection centralConnection, bool refreshCache)
        {
            UTF8Encoding enc = new UTF8Encoding();

            byte[] EncryptionKey = enc.GetBytes("mQlEGebnokhGFEFV");          //Gotten from FormCentralManager constructor. Only place that does anything like this.
            string computerName  = "";
            string database      = "";
            string user          = "";
            string password      = "";

            if (centralConnection.ServerName != "")           //Direct connection
            {
                computerName = centralConnection.ServerName;
                database     = centralConnection.DatabaseName;
                user         = centralConnection.MySqlUser;
                if (centralConnection.MySqlPassword != "")
                {
                    password = CentralConnections.Decrypt(centralConnection.MySqlPassword, EncryptionKey);
                }
                try {
                    DataConnection.DBtype = DatabaseType.MySql;
                    DataConnection dcon = new DataConnection();
                    dcon.SetDbT(computerName, database, user, password, "", "", DataConnection.DBtype);
                    RemotingClient.SetRemotingRoleT(RemotingRole.ClientDirect);
                    if (refreshCache)
                    {
                        Cache.Refresh(InvalidType.AllLocal);
                    }
                }
                catch {
                    return(false);
                }
            }
            else if (centralConnection.ServiceURI != "")           //Middle tier connection
            {
                RemotingClient.SetServerURIT(centralConnection.ServiceURI);
                RemotingClient.SetRemotingRoleT(RemotingRole.ClientWeb);
            }
            else
            {
                MessageBox.Show("Either a database or a Middle Tier URI must be specified in the connection.");
                return(false);
            }
            return(true);
        }
		///<summary>Converts a DataTable to a list of objects.</summary>
		public static List<CentralConnection> TableToList(DataTable table){
			List<CentralConnection> retVal=new List<CentralConnection>();
			CentralConnection centralConnection;
			for(int i=0;i<table.Rows.Count;i++) {
				centralConnection=new CentralConnection();
				centralConnection.CentralConnectionNum= PIn.Long  (table.Rows[i]["CentralConnectionNum"].ToString());
				centralConnection.ServerName          = PIn.String(table.Rows[i]["ServerName"].ToString());
				centralConnection.DatabaseName        = PIn.String(table.Rows[i]["DatabaseName"].ToString());
				centralConnection.MySqlUser           = PIn.String(table.Rows[i]["MySqlUser"].ToString());
				centralConnection.MySqlPassword       = PIn.String(table.Rows[i]["MySqlPassword"].ToString());
				centralConnection.ServiceURI          = PIn.String(table.Rows[i]["ServiceURI"].ToString());
				centralConnection.OdUser              = PIn.String(table.Rows[i]["OdUser"].ToString());
				centralConnection.OdPassword          = PIn.String(table.Rows[i]["OdPassword"].ToString());
				centralConnection.Note                = PIn.String(table.Rows[i]["Note"].ToString());
				centralConnection.ItemOrder           = PIn.Int   (table.Rows[i]["ItemOrder"].ToString());
				centralConnection.WebServiceIsEcw     = PIn.Bool  (table.Rows[i]["WebServiceIsEcw"].ToString());
				retVal.Add(centralConnection);
			}
			return retVal;
		}
        private void ConnectAndRunProviderReport(ODThread odThread)
        {
            CentralConnection conn         = (CentralConnection)odThread.Parameters[0];
            DataSet           listProdData = null;

            if (!CentralConnectionHelper.UpdateCentralConnection(conn, false))
            {
                odThread.Tag          = new object[] { listProdData, conn };
                conn.ConnectionStatus = "OFFLINE";
                return;
            }
            List <Provider> listProvs   = Providers.GetProvsNoCache();
            List <Clinic>   listClinics = Clinics.GetClinicsNoCache();
            Clinic          unassigned  = new Clinic();

            unassigned.ClinicNum   = 0;
            unassigned.Description = "Unassigned";          //Same issue here as above.
            listClinics.Add(unassigned);
            listProdData = RpProdInc.GetProviderDataForClinics(_dateFrom, _dateTo, listProvs, listClinics, radioWriteoffPay.Checked, true, true, false, checkShowUnearned.Checked, true);
            odThread.Tag = new object[] { listProdData, conn, listProvs };
        }
 ///<summary>Updates one CentralConnection in the database.  Uses an old object to compare to, and only alters changed fields.  This prevents collisions and concurrency problems in heavily used tables.</summary>
 internal static void Update(CentralConnection centralConnection,CentralConnection oldCentralConnection)
 {
     string command="";
     if(centralConnection.ServerName != oldCentralConnection.ServerName) {
         if(command!=""){ command+=",";}
         command+="ServerName = '"+POut.String(centralConnection.ServerName)+"'";
     }
     if(centralConnection.DatabaseName != oldCentralConnection.DatabaseName) {
         if(command!=""){ command+=",";}
         command+="DatabaseName = '"+POut.String(centralConnection.DatabaseName)+"'";
     }
     if(centralConnection.MySqlUser != oldCentralConnection.MySqlUser) {
         if(command!=""){ command+=",";}
         command+="MySqlUser = '******'";
     }
     if(centralConnection.MySqlPassword != oldCentralConnection.MySqlPassword) {
         if(command!=""){ command+=",";}
         command+="MySqlPassword = '******'";
     }
     if(centralConnection.ServiceURI != oldCentralConnection.ServiceURI) {
         if(command!=""){ command+=",";}
         command+="ServiceURI = '"+POut.String(centralConnection.ServiceURI)+"'";
     }
     if(centralConnection.OdUser != oldCentralConnection.OdUser) {
         if(command!=""){ command+=",";}
         command+="OdUser = '******'";
     }
     if(centralConnection.OdPassword != oldCentralConnection.OdPassword) {
         if(command!=""){ command+=",";}
         command+="OdPassword = '******'";
     }
     if(centralConnection.Note != oldCentralConnection.Note) {
         if(command!=""){ command+=",";}
         command+="Note = '"+POut.String(centralConnection.Note)+"'";
     }
     if(centralConnection.ItemOrder != oldCentralConnection.ItemOrder) {
         if(command!=""){ command+=",";}
         command+="ItemOrder = "+POut.Int(centralConnection.ItemOrder)+"";
     }
     if(centralConnection.WebServiceIsEcw != oldCentralConnection.WebServiceIsEcw) {
         if(command!=""){ command+=",";}
         command+="WebServiceIsEcw = "+POut.Bool(centralConnection.WebServiceIsEcw)+"";
     }
     if(command==""){
         return;
     }
     command="UPDATE centralconnection SET "+command
         +" WHERE CentralConnectionNum = "+POut.Long(centralConnection.CentralConnectionNum);
     Db.NonQ(command);
 }
 ///<summary>Updates one CentralConnection in the database.</summary>
 internal static void Update(CentralConnection centralConnection)
 {
     string command="UPDATE centralconnection SET "
         +"ServerName          = '"+POut.String(centralConnection.ServerName)+"', "
         +"DatabaseName        = '"+POut.String(centralConnection.DatabaseName)+"', "
         +"MySqlUser           = '******', "
         +"MySqlPassword       = '******', "
         +"ServiceURI          = '"+POut.String(centralConnection.ServiceURI)+"', "
         +"OdUser              = '******', "
         +"OdPassword          = '******', "
         +"Note                = '"+POut.String(centralConnection.Note)+"', "
         +"ItemOrder           =  "+POut.Int   (centralConnection.ItemOrder)+", "
         +"WebServiceIsEcw     =  "+POut.Bool  (centralConnection.WebServiceIsEcw)+" "
         +"WHERE CentralConnectionNum = "+POut.Long(centralConnection.CentralConnectionNum);
     Db.NonQ(command);
 }