Exemplo n.º 1
0
        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();
        }
 private void FormCentralPatientSearch_FormClosing(object sender, FormClosingEventArgs e)
 {
     //User could have closed the window before all threads finished.  Make sure to abort all threads instantly.
     ODThread.QuitSyncThreadsByGroupName(1, "FetchPats");
 }
        private void FillGrid()
        {
            Cursor = Cursors.WaitCursor;
            gridMain.BeginUpdate();
            List <DisplayField> fields = DisplayFields.GetForCategory(DisplayFieldCategory.CEMTSearchPatients);

            if (gridMain.Columns.Count == 0)           //Init only once.
            {
                foreach (DisplayField field in fields)
                {
                    string heading = field.InternalName;
                    if (string.IsNullOrEmpty(heading))
                    {
                        heading = field.Description;
                    }
                    gridMain.Columns.Add(new ODGridColumn(heading, field.ColumnWidth));
                }
            }
            gridMain.Rows.Clear();
            ODGridRow row;

            for (int i = 0; i < _dataConnPats.Tables.Count; i++)
            {
                for (int j = 0; j < _dataConnPats.Tables[i].Rows.Count; j++)
                {
                    row = new ODGridRow();
                    foreach (DisplayField field in fields)
                    {
                        switch (field.InternalName)
                        {
                            #region Row Cell Filling
                        case "Conn":
                            row.Cells.Add(_dataConnPats.Tables[i].TableName);
                            break;

                        case "PatNum":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PatNum"].ToString());
                            break;

                        case "LName":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["LName"].ToString());
                            break;

                        case "FName":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["FName"].ToString());
                            break;

                        case "SSN":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["SSN"].ToString());
                            break;

                        case "PatStatus":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PatStatus"].ToString());
                            break;

                        case "Age":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["age"].ToString());
                            break;

                        case "City":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["City"].ToString());
                            break;

                        case "State":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["State"].ToString());
                            break;

                        case "Address":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Address"].ToString());
                            break;

                        case "Wk Phone":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["WkPhone"].ToString());
                            break;

                        case "Email":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Email"].ToString());
                            break;

                        case "ChartNum":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["ChartNumber"].ToString());
                            break;

                        case "MI":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["MiddleI"].ToString());
                            break;

                        case "Pref Name":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Preferred"].ToString());
                            break;

                        case "Hm Phone":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["HmPhone"].ToString());
                            break;

                        case "Bill Type":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["BillingType"].ToString());
                            break;

                        case "Pri Prov":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["PriProv"].ToString());
                            break;

                        case "Birthdate":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["Birthdate"].ToString());
                            break;

                        case "Site":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["site"].ToString());
                            break;

                        case "Clinic":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["clinic"].ToString());
                            break;

                        case "Wireless Ph":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["WirelessPhone"].ToString());
                            break;

                        case "Sec Prov":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["SecProv"].ToString());
                            break;

                        case "LastVisit":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["lastVisit"].ToString());
                            break;

                        case "NextVisit":
                            row.Cells.Add(_dataConnPats.Tables[i].Rows[j]["nextVisit"].ToString());
                            break;
                            #endregion
                        }
                    }
                    row.Tag = ListConns.Find(x => ((x.ServerName + ", " + x.DatabaseName) == _dataConnPats.Tables[i].TableName || x.ServiceURI == _dataConnPats.Tables[i].TableName));
                    gridMain.Rows.Add(row);
                }
            }
            gridMain.EndUpdate();
            Cursor = Cursors.Default;
            if (_complConnAmt == ListConns.Count)
            {
                ODThread.QuitSyncThreadsByGroupName(1, "FetchPats");               //Clean up finished threads.
                butRefresh.Text    = Lans.g(this, "Refresh");
                labelFetch.Visible = false;
                if (!_hasWarningShown && _invalidConnsLog != "")
                {
                    _hasWarningShown = true;                  //Keeps the message box from showing up for subsequent threads.
                    MessageBox.Show(this, Lan.g(this, "Could not connect to the following servers") + ":" + _invalidConnsLog);
                }
            }
            else
            {
                butRefresh.Text    = Lans.g(this, "Stop Refresh");
                labelFetch.Visible = true;
            }
        }