예제 #1
0
        private void FillGridAvail()
        {
            _listConnectionsAvail = CentralConnections.GetNotForGroup(ConnectionGroupCur.ConnectionGroupNum);
            gridAvail.BeginUpdate();
            gridAvail.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn("Database", 320);
            gridAvail.ListGridColumns.Add(col);
            col = new GridColumn("Note", 300);
            gridAvail.ListGridColumns.Add(col);
            gridAvail.ListGridRows.Clear();
            GridRow row;

            for (int i = 0; i < _listConnectionsAvail.Count; i++)
            {
                row = new GridRow();
                if (_listConnectionsAvail[i].DatabaseName == "")               //uri
                {
                    row.Cells.Add(_listConnectionsAvail[i].ServiceURI);
                }
                else
                {
                    row.Cells.Add(_listConnectionsAvail[i].ServerName + ", " + _listConnectionsAvail[i].DatabaseName);
                }
                row.Cells.Add(_listConnectionsAvail[i].Note);
                //row.Tag=_listConnections[i];
                gridAvail.ListGridRows.Add(row);
            }
            gridAvail.EndUpdate();
        }
예제 #2
0
        private void FillGrid()
        {
            ConnList = CentralConnections.Refresh();
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn("#", 40);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Database", 320);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Note", 300);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < ConnList.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(ConnList[i].ItemOrder.ToString());
                if (ConnList[i].DatabaseName == "")               //uri
                {
                    row.Cells.Add(ConnList[i].ServiceURI);
                }
                else
                {
                    row.Cells.Add(ConnList[i].ServerName + ", " + ConnList[i].DatabaseName);
                }
                row.Cells.Add(ConnList[i].Note);
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
        }
예제 #3
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);
        }
예제 #4
0
        private void butDown_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MessageBox.Show(Lans.g(this, "Please select a connection, first."));
                return;
            }
            if (gridMain.SelectedIndices.Length > 1)
            {
                MessageBox.Show(Lans.g(this, "Please only select one connection."));
                return;
            }
            int idx = gridMain.SelectedIndices[0];

            if (_listConnsShowing.Count < 2 || idx == _listConnsShowing.Count - 1)
            {
                return;                //nothing to do
            }
            _listConnsShowing[idx].ItemOrder++;
            CentralConnections.Update(_listConnsShowing[idx]);
            _listConnsShowing[idx + 1].ItemOrder--;
            CentralConnections.Update(_listConnsShowing[idx + 1]);
            _listConnsAll = CentralConnections.GetConnections();
            FillGrid();
            gridMain.SetSelected(idx + 1, true);
        }
        ///<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);
        }
예제 #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            //test code

            string server = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWServer"); //this property will not exist if using Oracle, eCW will never use Oracle
            string port   = ProgramProperties.GetPropVal(Programs.GetProgramNum(ProgramName.eClinicalWorks), "eCWPort");   //this property will not exist if using Oracle, eCW will never use Oracle

            string username = "******";                                                                                      //"ecwUser";
            string password = "";                                                                                          //"l69Rr4Rmj4CjiCTLxrIblg==";//encrypted

            CentralConnections.GetConnections();

            string connString =
                "Server=" + server + ";"
                + "Port=" + port + ";"  //although this does seem to cause a bug in Mono.  We will revisit this bug if needed to exclude the port option only for Mono.
                + "Database=mobiledoc;" //ecwMaster;"
                                        //+"Connect Timeout=20;"
                + "User ID=" + username + ";"
                + "Password="******";"
                + "CharSet=utf8;"
                + "Treat Tiny As Boolean=false;"
                + "Allow User Variables=true;"
                + "Default Command Timeout=300;"//default is 30seconds
                + "Pooling=false"
            ;

            string command = "select Description from account;";

            string result = MySql.Data.MySqlClient.MySqlHelper.ExecuteDataRow(connString, command)["Description"].ToString();

            MessageBox.Show(result);
        }
예제 #7
0
 public override void OnPostInit()
 {
     _view.AddDatabaseType("MySQL");
     _view.AddDatabaseType("Oracle");
     _view.SetDatabaseType(0);
     _view.FillComboComputerNames(CentralConnections.GetComputerNames());
 }
 private void butOK_Click(object sender, EventArgs e)
 {
     try {
         int.Parse(textItemOrder.Text);
     }
     catch {
         MessageBox.Show("Item Order invalid");
     }
     CentralConnectionCur.ServerName      = textServerName.Text;
     CentralConnectionCur.DatabaseName    = textDatabaseName.Text;
     CentralConnectionCur.MySqlUser       = textMySqlUser.Text;
     CentralConnectionCur.MySqlPassword   = CentralConnections.Encrypt(textMySqlPassword.Text, FormCentralManager.EncryptionKey);
     CentralConnectionCur.ServiceURI      = textServiceURI.Text;
     CentralConnectionCur.WebServiceIsEcw = checkWebServiceIsEcw.Checked;
     CentralConnectionCur.ItemOrder       = int.Parse(textItemOrder.Text);
     CentralConnectionCur.Note            = textNote.Text;
     if (CentralConnectionCur.IsNew)
     {
         CentralConnections.Insert(CentralConnectionCur);
         CentralConnectionCur.IsNew = false;              //so a double-click immediately in FormCentralConnections doesn't insert again
     }
     else
     {
         CentralConnections.Update(CentralConnectionCur);
     }
     DialogResult = DialogResult.OK;
 }
예제 #9
0
        private void FormChooseDatabase_Load(object sender, EventArgs e)
        {
            //The model can be requested from the form once the form has officially loaded.
            ChooseDatabaseModel chooseDatabaseModel;

            _view.TryGetModelFromView(out chooseDatabaseModel);
            _view.FillComboDatabases(CentralConnections.GetDatabases(chooseDatabaseModel.CentralConnectionCur, chooseDatabaseModel.DbType));
        }
예제 #10
0
        internal void DatabaseDropDown(object sender, EventArgs e)
        {
            ChooseDatabaseModel chooseDatabaseModel;

            _view.TryGetModelFromView(out chooseDatabaseModel);
            _view.FillComboDatabases(CentralConnections.GetDatabases(chooseDatabaseModel.CentralConnectionCur
                                                                     , chooseDatabaseModel.DbType));
        }
        private void FillGrid()
        {
            if (_listSelectedConnNums.Count == 0)           //Could have been set on load.
            {
                foreach (int i in gridMain.SelectedIndices)
                {
                    _listSelectedConnNums.Add(((CentralConnection)gridMain.Rows[i].Tag).CentralConnectionNum);
                }
            }
            _listConnsDisplay = null;
            if (comboConnectionGroups.SelectedIndex > 0)
            {
                _listConnsDisplay = CentralConnections.FilterConnections(ListConns, textSearch.Text, _listConnectionGroups[comboConnectionGroups.SelectedIndex - 1]);
            }
            else
            {
                _listConnsDisplay = CentralConnections.FilterConnections(ListConns, textSearch.Text, null);
            }
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col;

            col = new ODGridColumn("#", 40);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Database", 300);
            gridMain.Columns.Add(col);
            col = new ODGridColumn("Note", 260);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow  row;
            List <int> listSelectedIndices = new List <int>();

            foreach (CentralConnection conn in _listConnsDisplay)
            {
                row = new ODGridRow();
                row.Cells.Add(conn.ItemOrder.ToString());
                if (conn.DatabaseName == "")               //uri
                {
                    row.Cells.Add(conn.ServiceURI);
                }
                else
                {
                    row.Cells.Add(conn.ServerName + ", " + conn.DatabaseName);
                }
                row.Cells.Add(conn.Note);
                //Add the selected index if needed before adding the row to the collection of rows.
                if (_listSelectedConnNums.Exists(x => x == (conn.CentralConnectionNum)))
                {
                    listSelectedIndices.Add(gridMain.Rows.Count);
                }
                row.Tag = conn;
                gridMain.Rows.Add(row);
            }
            gridMain.EndUpdate();
            //Reselect any connections that were selected before re-filling the grid.
            gridMain.SetSelected(listSelectedIndices.ToArray(), true);
            _listSelectedConnNums.Clear();            //Always clear the list out for subsequent Fills will remember selected indicies.
        }
예제 #12
0
        ///<summary>Every optional parameter provided should coincide with a commandline arguement.
        ///The values passed in will typically override any settings loaded in from the config file.
        ///Passing in a value for webServiceUri or databaseName will cause the config file to not even be considered.</summary>
        public static ChooseDatabaseModel GetChooseDatabaseModelFromConfig(string webServiceUri = "", YN webServiceIsEcw  = YN.Unknown, string odUser = ""
                                                                           , string serverName  = "", string databaseName = "", string mySqlUser      = "", string mySqlPassword = "", string mySqlPassHash = "", YN noShow = YN.Unknown)
        {
            ChooseDatabaseModel chooseDatabaseModel = new ChooseDatabaseModel();

            //Even if we are passed a URI as a command line argument we still need to check the FreeDentalConfig file for middle tier automatic log in.
            //The only time we do not need to do that is if a direct DB has been passed in.
            if (string.IsNullOrEmpty(databaseName))
            {
                CentralConnections.GetChooseDatabaseConnectionSettings(out chooseDatabaseModel.CentralConnectionCur, out chooseDatabaseModel.ConnectionString
                                                                       , out chooseDatabaseModel.NoShow, out chooseDatabaseModel.DbType, out chooseDatabaseModel.ListAdminCompNames);
            }
            //Command line args should always trump settings from the config file.
            #region Command Line Arguements
            if (webServiceUri != "")           //if a URI was passed in
            {
                chooseDatabaseModel.CentralConnectionCur.ServiceURI = webServiceUri;
            }
            if (webServiceIsEcw != YN.Unknown)
            {
                chooseDatabaseModel.CentralConnectionCur.WebServiceIsEcw = (webServiceIsEcw == YN.Yes ? true : false);
            }
            if (odUser != "")
            {
                chooseDatabaseModel.CentralConnectionCur.OdUser = odUser;
            }
            //OdPassHash;//not allowed to be used here.  Instead, only used directly in TryToConnect
            //OdPassword//not allowed to be used here.  Instead, only used directly in TryToConnect
            if (serverName != "")
            {
                chooseDatabaseModel.CentralConnectionCur.ServerName = serverName;
            }
            if (databaseName != "")
            {
                chooseDatabaseModel.CentralConnectionCur.DatabaseName = databaseName;
            }
            if (mySqlUser != "")
            {
                chooseDatabaseModel.CentralConnectionCur.MySqlUser = mySqlUser;
            }
            if (mySqlPassword != "")
            {
                chooseDatabaseModel.CentralConnectionCur.MySqlPassword = mySqlPassword;
            }
            if (mySqlPassHash != "")
            {
                string decryptedPwd;
                CDT.Class1.Decrypt(mySqlPassHash, out decryptedPwd);
                chooseDatabaseModel.CentralConnectionCur.MySqlPassword = decryptedPwd;
            }
            if (noShow != YN.Unknown)
            {
                chooseDatabaseModel.NoShow = noShow;
            }
            #endregion
            return(chooseDatabaseModel);
        }
예제 #13
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (CentralConnectionCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     //no prompt
     CentralConnections.Delete(CentralConnectionCur.CentralConnectionNum);
     DialogResult = DialogResult.OK;
 }
예제 #14
0
 private void FormCentralConnectionEdit_Load(object sender, EventArgs e)
 {
     textServerName.Text            = CentralConnectionCur.ServerName;
     textDatabaseName.Text          = CentralConnectionCur.DatabaseName;
     textMySqlUser.Text             = CentralConnectionCur.MySqlUser;
     textMySqlPassword.Text         = CentralConnections.Decrypt(CentralConnectionCur.MySqlPassword, FormCentralManager.EncryptionKey);
     textMySqlPassword.PasswordChar = textMySqlPassword.Text == ""?default(char):'*';        //if password entered, mask it
     textServiceURI.Text            = CentralConnectionCur.ServiceURI;
     checkWebServiceIsEcw.Checked   = CentralConnectionCur.WebServiceIsEcw;
     textNote.Text = CentralConnectionCur.Note;
     checkClinicBreakdown.Checked = CentralConnectionCur.IsNew ? true : CentralConnectionCur.HasClinicBreakdownReports;
 }
예제 #15
0
 private void FormCentralManager_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (_hasFatalError)
     {
         return;                //Don't do any of the below
     }
     ODThread.QuitSyncAllOdThreads();
     foreach (CentralConnection conn in _listConns)             //Reflect connection status changes in the database.
     {
         CentralConnections.UpdateStatus(conn);
     }
 }
 private void FormCentralConnectionEdit_Load(object sender, EventArgs e)
 {
     textServerName.Text          = CentralConnectionCur.ServerName;
     textDatabaseName.Text        = CentralConnectionCur.DatabaseName;
     textMySqlUser.Text           = CentralConnectionCur.MySqlUser;
     textMySqlPassword.Text       = CentralConnections.Decrypt(CentralConnectionCur.MySqlPassword, FormCentralManager.EncryptionKey);
     textServiceURI.Text          = CentralConnectionCur.ServiceURI;
     checkWebServiceIsEcw.Checked = CentralConnectionCur.WebServiceIsEcw;
     textOdUser.Text     = CentralConnectionCur.OdUser;
     textOdPassword.Text = CentralConnections.Decrypt(CentralConnectionCur.OdPassword, FormCentralManager.EncryptionKey);
     textItemOrder.Text  = CentralConnectionCur.ItemOrder.ToString();
     textNote.Text       = CentralConnectionCur.Note;
 }
예제 #17
0
 private void butAlphabetize_Click(object sender, EventArgs e)
 {
     _listConnsShowing.Sort(delegate(CentralConnection x, CentralConnection y){
         return(x.Note.CompareTo(y.Note));
     });
     for (int i = 0; i < _listConnsShowing.Count; i++)
     {
         _listConnsShowing[i].ItemOrder = i;
         CentralConnections.Update(_listConnsShowing[i]);
     }
     _listConnsAll = CentralConnections.GetConnections();
     FillGrid();
 }
예제 #18
0
        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
        }
예제 #19
0
        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();
            }
        }
예제 #20
0
 ///<summary>Attempts to connect to the database (via Middle Tier if necessary).
 ///Returns true if connection settings are valid. Otherwise, false.</summary>
 private bool IsValidConnection()
 {
     SyncModelWithUI();
     try {
         CentralConnections.TryToConnect(Model.CentralConnectionCur, Model.DbType, Model.ConnectionString, noShowOnStartup: (Model.NoShow == YN.Yes),
                                         Model.ListAdminCompNames, useDynamicMode: Model.UseDynamicMode, allowAutoLogin: Model.AllowAutoLogin);
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         return(false);
     }
     //A successful connection was made using the settings within the current choose database model.
     return(true);
 }
예제 #21
0
        internal bool butOK_Click(object sender, EventArgs e)
        {
            ChooseDatabaseModel chooseDatabaseModel;

            _view.TryGetModelFromView(out chooseDatabaseModel);
            try {
                CentralConnections.TryToConnect(chooseDatabaseModel.CentralConnectionCur, chooseDatabaseModel.DbType, chooseDatabaseModel.ConnectionString
                                                , (chooseDatabaseModel.NoShow == YN.Yes), chooseDatabaseModel.ListAdminCompNames);
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return(false);
            }
            //A successful connection was made using the settings within the current choose database model.
            return(true);
        }
예제 #22
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            if (IsSelectionMode)
            {
                ListConnsSelected = new List <CentralConnection>();
                ListConnsSelected.Add(_listConnsShowing[e.Row]);
                DialogResult = DialogResult.OK;
                return;
            }
            FormCentralConnectionEdit FormCCE = new FormCentralConnectionEdit();

            FormCCE.CentralConnectionCur = _listConnsShowing[e.Row];
            FormCCE.ShowDialog();
            _listConnsAll = CentralConnections.GetConnections();
            FillGrid();
        }
예제 #23
0
        private void menuItemSecurity_Click(object sender, EventArgs e)
        {
            if (!Security.IsAuthorized(Permissions.SecurityAdmin))
            {
                return;
            }
            FormCentralSecurity FormCUS = new FormCentralSecurity();

            foreach (CentralConnection conn in _listConns)
            {
                FormCUS.ListConns.Add(conn.Copy());
            }
            FormCUS.ShowDialog();
            _listConns = CentralConnections.GetConnections();          //List may have changed when syncing security settings.
            FillGrid();
        }
예제 #24
0
        private void menuConnSetup_Click(object sender, EventArgs e)
        {
            FormCentralConnections FormCC = new FormCentralConnections();

            foreach (CentralConnection conn in _listConns)
            {
                FormCC.ListConns.Add(conn.Copy());
            }
            FormCC.LabelText.Text = Lans.g("FormCentralConnections", "Double click an existing connection to edit or click the 'Add' button to add a new connection.");
            FormCC.Text           = Lans.g("FormCentralConnections", "Connection Setup");
            if (FormCC.ShowDialog() == DialogResult.OK)
            {
                _listConns = CentralConnections.GetConnections();
                FillGrid();
            }
        }
예제 #25
0
        private void butEdit_Click(object sender, EventArgs e)
        {
            if (gridMain.SelectedIndices.Length == 0)
            {
                MsgBox.Show(this, "Please select a connection to edit first.");
                return;
            }
            FormCentralConnectionEdit FormCCE = new FormCentralConnectionEdit();

            FormCCE.CentralConnectionCur = (CentralConnection)gridMain.Rows[gridMain.SelectedIndices[0]].Tag;          //No support for editing multiple.
            if (FormCCE.ShowDialog() == DialogResult.OK)
            {
                _listConns = CentralConnections.GetConnections();
                FillGrid();
            }
        }
예제 #26
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();
        }
예제 #27
0
 private void FormCentralConnectionGroupEdit_Load(object sender, EventArgs e)
 {
     _listConns    = CentralConnections.GetConnections();
     _listConnsCur = new List <CentralConnection>();
     if (IsNew)
     {
         _listConnGroupAttaches = new List <ConnGroupAttach>();
     }
     else              //Take full list and filter out
     {
         _listConnGroupAttaches = ConnGroupAttaches.GetForGroup(ConnectionGroupCur.ConnectionGroupNum);
         //Grab all the connections associated to the corresponding connection group from the list of all connections.
         _listConnsCur = _listConns.FindAll(x => _listConnGroupAttaches.Exists(y => y.CentralConnectionNum == x.CentralConnectionNum));
     }
     textDescription.Text = ConnectionGroupCur.Description;
     FillGrid();
 }
예제 #28
0
        private void FillGrid()
        {
            //this gets called a lot if typing search.  So just include the following line in other places.
            //_listConnsAll=CentralConnections.GetConnections();
            _listConnsShowing = null;
            if (comboConnectionGroups.SelectedIndex > 0)
            {
                _listConnsShowing = CentralConnections.FilterConnections(_listConnsAll, textSearch.Text, _listConnectionGroups[comboConnectionGroups.SelectedIndex - 1]);
            }
            else
            {
                _listConnsShowing = CentralConnections.FilterConnections(_listConnsAll, textSearch.Text, null);
            }
            gridMain.BeginUpdate();
            gridMain.ListGridColumns.Clear();
            GridColumn col;

            col = new GridColumn("#", 40);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Database", 300);
            gridMain.ListGridColumns.Add(col);
            col = new GridColumn("Note", 260);
            gridMain.ListGridColumns.Add(col);
            gridMain.ListGridRows.Clear();
            GridRow row;

            int[] selectedIndices = gridMain.SelectedIndices;
            for (int i = 0; i < _listConnsShowing.Count; i++)
            {
                row = new GridRow();
                row.Cells.Add(_listConnsShowing[i].ItemOrder.ToString());
                if (_listConnsShowing[i].DatabaseName == "")               //uri
                {
                    row.Cells.Add(_listConnsShowing[i].ServiceURI);
                }
                else
                {
                    row.Cells.Add(_listConnsShowing[i].ServerName + ", " + _listConnsShowing[i].DatabaseName);
                }
                row.Cells.Add(_listConnsShowing[i].Note);
                gridMain.ListGridRows.Add(row);
            }
            gridMain.EndUpdate();
            gridMain.SetSelected(selectedIndices, true);
        }
예제 #29
0
        private void RunTransfer()
        {
            //Get data from the source connection. This will have all the patients selected from the sourceconnection
            string   stringFailedConns = "";
            ODThread odThread          = new ODThread(GetDataFromSourceConnection, new object[] { _sourceConnection });

            odThread.GroupName = "FetchSheets";
            odThread.Start();
            ODThread.JoinThreadsByGroupName(Timeout.Infinite, "FetchSheets");
            if (_listSheetsForSelectedPats.IsNullOrEmpty())
            {
                string connString = CentralConnections.GetConnectionString(_sourceConnection);
                stringFailedConns += connString + "\r\n";
            }
            //Insert the sheets to each of the databases. The sheets will have a patnum=0;
            List <Action> listActions = new List <Action>();
            object        locker      = new object();

            foreach (CentralConnection conn in _listConnectionsToTransferTo)
            {
                List <Sheet> listSheets = _listSheetsForSelectedPats.Select(x => x.Copy()).ToList();
                listActions.Add(() => {
                    if (!InsertSheetsToConnection(conn, listSheets))
                    {
                        string connString = CentralConnections.GetConnectionString(conn);
                        lock (locker) {
                            stringFailedConns += connString + "\r\n";
                        }
                    }
                });
            }
            ODThread.RunParallel(listActions);
            if (stringFailedConns != "")
            {
                stringFailedConns = Lans.g(this, "There were some transfers that failed due to connection issues.  Fix connections and try again.\r\n"
                                           + "Failed Connections:") + "\r\n" + stringFailedConns;
                CodeBase.MsgBoxCopyPaste msgBoxCP = new CodeBase.MsgBoxCopyPaste(stringFailedConns);
                msgBoxCP.ShowDialog();
            }
            else
            {
                MsgBox.Show(this, "Transfers Completed Successfully\r\nGo to each database you transferred patients to and retrieve Webforms to finish the "
                            + "transfer process.");
            }
        }
예제 #30
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);
        }