Beispiel #1
0
 private void connectionWorker_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         if (connectionWorker.CancellationPending)
         {
             e.Cancel = true;
         }
         else
         {
             var db = new Parise.RaisersEdge.ConnectionMonitor.Data.RecmDataContext(Properties.Settings.Default.DBConnectionString);
             db.LockConnections.Count();
             e.Result = db;
         }
     }
     catch (Exception err)
     {
         if (connectionWorker.CancellationPending)
         {
             e.Cancel = true;
         }
         else
         {
             e.Result = err;
         }
     }
 }
Beispiel #2
0
        public int CountActiveConnections()
        {
            int activeCount = 0;

            using (var db = new Parise.RaisersEdge.ConnectionMonitor.Data.RecmDataContext(base.Settings[MonitorSettings.DBConnectionString]))
            {
                activeCount = db.LockConnections_AllActiveREConnectionsAliveOnly_ClientOnly.Select(a => a.Lock.User.Name).Distinct().Count();
            }

            return(activeCount);
        }
Beispiel #3
0
 void TimedREConnectionMonitor_CleaningUpDeadLocks(Parise.RaisersEdge.ConnectionMonitor.Data.RecmDataContext db)
 {
     logBuffer.AppendFormat("\nDead Locks\n-----------------------\n\tCleaning up dead locks for {0}\n", db.Connection.Database);
 }
Beispiel #4
0
 void TimedREConnectionMonitor_ConnectedToDatabase(Parise.RaisersEdge.ConnectionMonitor.Data.RecmDataContext db)
 {
     logBuffer.AppendFormat("\tSuccessfully connected to database {0}/\n", db.Connection.Database);
 }
Beispiel #5
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            bool noFails = true;

            while (noFails)
            {
                try
                {
                    if (connectionListWorker.CancellationPending)
                    {
                        e.Cancel = true;
                        break;
                    }

                    var db = new Parise.RaisersEdge.ConnectionMonitor.Data.RecmDataContext(Properties.Settings.Default.DBConnectionString);

                    var currentInUse = db.LockConnections_AllActiveREConnectionsAliveOnly_ClientOnly.Select(a => a.Lock.User.Name).Distinct().Count();

                    if (currentInUse != lastActiveCount || settingsChanged)
                    {
                        panelLoadingLicense.Invoke((MethodInvoker) delegate()
                        {
                            panelLoadingLicense.Visible = true;
                        });

                        settingsChanged = false;
                        lastActiveCount = currentInUse;
                        //if (lblLicenseInUse.InvokeRequired)
                        //{
                        //    lblLicenseInUse.Invoke(new SetLicenseInUseLabelCallBack(SetLicenseInUseLabel), lastActiveCount);
                        //}
                        //if (Properties.Settings.Default.MonitoringEnabled) _monitor.FreeConnections(true);


                        var locks     = db.LockConnections_AllActiveREConnections_ClientOnly.OrderByDescending(a => a.REProcess.IdleTime.TotalMilliseconds).ToList();
                        var listItems = locks
                                        .Select(a =>
                                                new ListViewItem()
                        {
                            Text       = a.Lock.User.Name + " - " + a.REProcess.IdleTimeFormatted("{h:D2}:{m:D2}:{s:D2}"),
                            ImageIndex = GetImageIndex(a),
                            Group      = lstViewLicenses.Groups[GetImageIndex(a) - 1]
                        });

                        var users = new List <string> {
                        };

                        //listView1.Invoke(new ClearItemsCallback(ClearItems), null);

                        var filterItems = new List <ListViewItem>();

                        foreach (var item in listItems)
                        {
                            var uName = Regex.Split(item.SubItems[0].Text, " - ")[0];
                            if (!users.Contains(uName))
                            {
                                users.Add(uName);
                                filterItems.Add(item);
                            }
                        }

                        lstViewLicenses.Invoke((MethodInvoker) delegate()
                        {
                            lstViewLicenses.Items.Clear();
                        });

                        lstViewLicenses.Invoke(new AddRangeCallback(AddRangeItems), new object[]
                        {
                            filterItems.ToArray()
                        });

                        lstViewLicenses.Invoke((MethodInvoker) delegate()
                        {
                            var licCount = int.Parse(Properties.Settings.Default.NumLicenses);
                            var imgIdx   = currentInUse >= licCount ? 1 : 0;

                            lstViewLicenses.Items.Add(new ListViewItem(currentInUse.ToString() + " of " + Properties.Settings.Default.NumLicenses, imgIdx, lstViewLicenses.Groups[0]));
                        });
                        //lstViewLicenses.Invoke((MethodInvoker)delegate()
                        //{
                        //    lstViewLicenses.Items.AddRange(filterItems.ToArray());
                        //});

                        //foreach (ListViewItem listItem in listView1.Items)
                        //{
                        //    float perc = float.Parse(listItem.SubItems[3].Text) * 100;
                        //    if (perc >= 50 && perc <= 75)
                        //    {
                        //        listItem.BackColor = Color.Yellow;
                        //    }
                        //    else if (perc > 75)
                        //    {
                        //        listItem.BackColor = Color.Red;
                        //        listItem.ForeColor = Color.White;
                        //    }
                        //}
                    }
                }
                catch (Exception err)
                {
                    //lblMonitorStatus.Text = logoutTimer.Enabled ? "Active" : "Inactive";
                    //lblMonitorStatus.ForeColor = logoutTimer.Enabled ? Color.DarkGreen : Color.Tomato;
                    //panelBadConnection.Invoke(new SetVisibilityCallBack(SetVisibilityLevel), new object[]
                    //{
                    //    panelBadConnection,
                    //    true
                    //});
                    ////outageContainer.Visible = true;
                    //outageContainer.Invoke(new SetVisibilityCallBack(SetVisibilityLevel), new object[]
                    //{
                    //    outageContainer,
                    //    true
                    //});

                    //lblOutageMessage.Invoke(new SetOutageMessageCallBack(SetOutageMessage), new object[]
                    //{
                    //    "There was an error connecting to the server, please check your connection.\n\nBouncing is disabled.\n\n" + err.Message
                    //});
                    //noFails = false;
                    //MessageBox.Show("There was an error connecting to the server, please check your connection.\n\nBouncing is disabled.", "RECM Error", MessageBoxButtons.OK);
                }
                panelLoadingLicense.Invoke((MethodInvoker) delegate()
                {
                    panelLoadingLicense.Visible = false;
                });
                if (connectionListWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
                System.Threading.Thread.Sleep(500);
                if (connectionListWorker.CancellationPending)
                {
                    e.Cancel = true;
                    break;
                }
            }
            //bool noFails = true;
            //while (noFails)
            //{
            //    try
            //    {
            //        IntegrationDataDataContext db = new IntegrationDataDataContext();
            //        var connList = db.RaisersEdgeConnections.ToList();
            //        int activeConn = connList.Select(c => c.hostname).Distinct().Count();
            //        if (this.listView1.InvokeRequired)
            //        {
            //            listView1.Invoke(new ClearItemsCallback(ClearItems), null);
            //            if (lblLicenseInUse.InvokeRequired)
            //            {
            //                lblLicenseInUse.Invoke(new SetLicenseInUseLabelCallBack(SetLicenseInUseLabel), activeConn);
            //            }
            //            ListViewItem[] items = connList.Where(a => a.program_name.Trim().Equals("The Raiser's Edge")).OrderByDescending(a => a.secondsidle).ToList()
            //                .Select(a => new ListViewItem(new string[] { WMIWrapper.GetExplorerOwner(a.hostname.Trim()),
            //            a.minutessidle.Value.ToString("000"),
            //            ((float)((float)a.secondsidle.Value / ((float)Properties.Settings.Default.MaxIdleTime*(float)60))).ToString("00.00%"),
            //            ((float)((float)a.secondsidle.Value / ((float)Properties.Settings.Default.MaxIdleTime*(float)60))).ToString("00.000")})).ToArray();

            //            foreach (ListViewItem listItem in items)
            //            {
            //                float perc = float.Parse(listItem.SubItems[3].Text) * 100;
            //                if (perc >= 50 && perc <= 80)
            //                {
            //                    listItem.BackColor = Color.Yellow;
            //                }
            //                else if (perc > 80)
            //                {
            //                    listItem.BackColor = Color.Red;
            //                    listItem.ForeColor = Color.White;
            //                }
            //            }

            //            listView1.Invoke(new AddRangeCallback(AddRangeItems), new object[]
            //    {
            //        items
            //    });
            //        }
            //        else
            //        {
            //            listView1.Items.Clear();
            //            //IntegrationDataDataContext db = new IntegrationDataDataContext();
            //            listView1.Items.AddRange(
            //                    connList.Where(a => a.program_name.Trim().Equals("The Raiser's Edge")).OrderByDescending(a => a.secondsidle).ToList()
            //                    .Select(a => new ListViewItem(new string[] { a.hostname.Trim(),
            //            a.minutessidle.Value.ToString("000"),
            //            ((float)((float)a.secondsidle.Value / ((float)Properties.Settings.Default.MaxIdleTime*(float)60))).ToString("00.00%"),
            //            ((float)((float)a.secondsidle.Value / ((float)Properties.Settings.Default.MaxIdleTime*(float)60))).ToString("00.000")})).ToArray());

            //            foreach (ListViewItem listItem in listView1.Items)
            //            {
            //                float perc = float.Parse(listItem.SubItems[3].Text) * 100;
            //                if (perc >= 50 && perc <= 75)
            //                {
            //                    listItem.BackColor = Color.Yellow;
            //                }
            //                else if (perc > 75)
            //                {
            //                    listItem.BackColor = Color.Red;
            //                    listItem.ForeColor = Color.White;
            //                }
            //            }
            //        }
            //        System.Threading.Thread.Sleep(1000);
            //    }
            //    catch (Exception err)
            //    {
            //        noFails = false;
            //    }
            //}
        }