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
            }
        }
Example #2
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);
        }
        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 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 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));
        }
Example #6
0
        ///<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.
        }
Example #7
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);
 }
        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
        }
        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 };
        }
        private void ConnectAndRunAnnualReport(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";          //Is this how we should do this?  Will there always be different clinics? (I assume so, otherwise CEMT is kinda worthless)
            listClinics.Add(unassigned);
            listProdData = RpProdInc.GetAnnualData(_dateFrom, _dateTo, listProvs, listClinics, radioWriteoffPay.Checked, true, true, false, checkShowUnearned.Checked, true);
            odThread.Tag = new object[] { listProdData, conn };
        }
Example #11
0
        ///<summary>Function used by threads to connect to remote databases and sync user settings.</summary>
        private static void ConnectAndSyncUsers(ODThread odThread)
        {
            CentralConnection      connection          = (CentralConnection)odThread.Parameters[0];
            List <CentralUserData> listCentralUserData = (List <CentralUserData>)odThread.Parameters[1];
            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.GetStringNoCache(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;
                }
            }
            //Get remote users, usergroups, associated permissions, and alertsubs
            List <Userod> listRemoteUsers = Userods.GetUsersNoCache();

            #region Detect Conflicts
            //User conflicts
            bool   nameConflict  = false;
            string nameConflicts = "";
            for (int i = 0; i < _listCEMTUsers.Count; i++)
            {
                for (int j = 0; j < listRemoteUsers.Count; j++)
                {
                    if (listRemoteUsers[j].UserName == _listCEMTUsers[i].UserName && listRemoteUsers[j].UserNumCEMT == 0)                 //User doesn't belong to CEMT
                    {
                        nameConflicts += listRemoteUsers[j].UserName + " already exists in " + serverName + "\r\n";
                        nameConflict   = true;
                        break;
                    }
                }
            }
            if (nameConflict)
            {
                odThread.Tag = new List <string>()
                {
                    serverName + "\r\n", nameConflicts, ""
                };
                return;                //Skip on to the next connection.
            }
            #endregion Detect Conflicts
            List <UserGroup> listRemoteCEMTUserGroups = UserGroups.GetCEMTGroupsNoCache();
            List <UserGroup> listCEMTUserGroups       = new List <UserGroup>();
            List <AlertSub>  listRemoteAlertSubs      = AlertSubs.GetAll();
            List <Clinic>    listRemoteClinics        = Clinics.GetClinicsNoCache();
            List <AlertSub>  listAlertSubsToInsert    = new List <AlertSub>();
            for (int i = 0; i < listCentralUserData.Count; i++)
            {
                listCEMTUserGroups.Add(listCentralUserData[i].UserGroup.Copy());
            }
            //SyncUserGroups returns the list of UserGroups for deletion so it can be used after syncing Users and GroupPermissions.
            List <UserGroup> listRemoteCEMTUserGroupsForDeletion = CentralUserGroups.Sync(listCEMTUserGroups, listRemoteCEMTUserGroups);
            listRemoteCEMTUserGroups = UserGroups.GetCEMTGroupsNoCache();
            for (int i = 0; i < listCentralUserData.Count; i++)
            {
                List <GroupPermission> listGroupPerms = new List <GroupPermission>();
                for (int j = 0; j < listRemoteCEMTUserGroups.Count; j++)
                {
                    if (listCentralUserData[i].UserGroup.UserGroupNumCEMT == listRemoteCEMTUserGroups[j].UserGroupNumCEMT)
                    {
                        for (int k = 0; k < listCentralUserData[i].ListGroupPermissions.Count; k++)
                        {
                            listCentralUserData[i].ListGroupPermissions[k].UserGroupNum = listRemoteCEMTUserGroups[j].UserGroupNum;                          //fixing primary keys to be what's in remote db
                        }
                        listGroupPerms = GroupPermissions.GetPermsNoCache(listRemoteCEMTUserGroups[j].UserGroupNum);
                    }
                }
                CentralUserods.Sync(listCentralUserData[i].ListUsers, listRemoteUsers);
                CentralGroupPermissions.Sync(listCentralUserData[i].ListGroupPermissions, listGroupPerms);
            }
            //Sync usergroup attaches
            SyncUserGroupAttaches(listCentralUserData);
            for (int j = 0; j < listRemoteCEMTUserGroupsForDeletion.Count; j++)
            {
                UserGroups.DeleteNoCache(listRemoteCEMTUserGroupsForDeletion[j]);
            }
            if (_listAlertSubs.Count > 0)
            {
                listRemoteUsers = Userods.GetUsersNoCache();              //Refresh users so we can do alertsubs.
            }
            //For each AlertSub, make a copy of that AlertSub for each Clinic.
            foreach (AlertSub alertSub in _listAlertSubs)
            {
                foreach (Clinic clinic in listRemoteClinics)
                {
                    AlertSub alert = new AlertSub();
                    alert.ClinicNum = clinic.ClinicNum;
                    alert.Type      = alertSub.Type;
                    alert.UserNum   = listRemoteUsers.Find(x => x.UserName == _listCEMTUsers.Find(y => y.UserNum == alertSub.UserNum).UserName).UserNum;
                    listAlertSubsToInsert.Add(alert);
                }
            }
            AlertSubs.DeleteAndInsertForSuperUsers(_listCEMTUsers, listAlertSubsToInsert);
            //Refresh server's cache of userods
            Signalods.SetInvalidNoCache(InvalidType.Security);
            SecurityLogs.MakeLogEntryNoCache(Permissions.SecurityAdmin, 0, "Enterprise Management Tool synced users.");
            odThread.Tag = new List <string>()
            {
                "", "", ""
            };                                                       //No errors.
        }