コード例 #1
0
        private void SaveScanSettings()
        {
            SettingsDAO settingsDao = new SettingsDAO();

            settingsDao.SetSetting("AutoScanIntervalValue", tbScanInterval.Text, false);
            settingsDao.SetSetting("AutoScanNetwork", Convert.ToString(cbEnableScan.Checked), false);
            settingsDao.SetSetting("AutoScanDeployAgent", Convert.ToString(cbDeployAgent.Checked), false);
            settingsDao.SetSetting("AutoScanIntervalUnits", Convert.ToString(cbScanInterval.SelectedItem.ToString()), false);

            AuditWizardServiceController _serviceController = new Layton.AuditWizard.Common.AuditWizardServiceController();

            LaytonServiceController.ServiceStatus serviceStatus = _serviceController.CheckStatus();

            if (serviceStatus == LaytonServiceController.ServiceStatus.Running)
            {
                _serviceController.RestartService();
            }
            else
            {
                if (serviceStatus != LaytonServiceController.ServiceStatus.NotInstalled)
                {
                    _serviceController.Start();
                }
            }

            DesktopAlert.ShowDesktopAlert("Settings have been updated.");
        }
コード例 #2
0
        /// <summary>
        /// Called when we change the state of any fields on this tab to force a change on exit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void uploadOptions_changed(object sender, EventArgs e)
        {
            _uploadConfigurationChanged = true;

            // Save the settings into the database
            SettingsDAO lwDataAccess = new SettingsDAO();

            lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_DeleteAfterUpload, rbDeleteAfterUpload.Checked.ToString(), false);
            lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_BackupAfterUpload, rbBackupAfterUpload.Checked.ToString(), false);
        }
コード例 #3
0
        private void bnSave_Click(object sender, EventArgs e)
        {
            SettingsDAO lSettingsDAO = new SettingsDAO();

            lSettingsDAO.SetSetting("NewsFeedDiskSpace", tbDiskSpace.Value.ToString(), false);
            lSettingsDAO.SetSetting("NewsFeedLicenses", tbLicenses.Value.ToString(), false);
            lSettingsDAO.SetSetting("NewsFeedPrinters", tbPrinterSupplies.Value.ToString(), false);
            lSettingsDAO.SetSetting("NewsFeedUpdateAsset", cbAssetUpdated.Checked);

            Close();
        }
コード例 #4
0
 /// <summary>
 /// Save any data entered on the Upload tab
 /// </summary>
 private void SaveUploadTab()
 {
     // If we have made any changes, save them back to the database
     if (_uploadConfigurationChanged)
     {
         // Save the settings into the database
         SettingsDAO lwDataAccess = new SettingsDAO();
         lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_DeleteAfterUpload, rbDeleteAfterUpload.Checked.ToString(), false);
         lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_BackupAfterUpload, rbBackupAfterUpload.Checked.ToString(), false);
         lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_OverwriteUserData, cbOverwriteUserData.Checked.ToString(), false);
         lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_FindAssetByName, cbFindAssetByName.Checked.ToString(), false);
     }
 }
コード例 #5
0
        public void Save()
        {
            string filePath = Path.Combine(Application.StartupPath, "Scanners");

            filePath = Path.Combine(filePath, AlertMonitorDefinitionsFile);

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(AlertMonitorSettings));
                TextWriter    textWriter = new StreamWriter(filePath);
                serializer.Serialize(textWriter, this);

                // We now need to serialize the AlertDefinitions
                textWriter.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save the Alert Monitor Definitions to '" + filePath + "'.  reason: " + ex.Message, "Save Failed");
            }

            // Save enabled/disabled to the database also
            SettingsDAO lwDataAccess = new SettingsDAO();

            lwDataAccess.SetSetting(DatabaseSettings.Setting_AlertMonitorEnable, _enabled.ToString(), false);
        }
コード例 #6
0
        /// <summary>
        /// v8.3.3
        /// Called as we change the daily/hourly email selector
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void hourlyRadioButton_CheckedChanged(object sender, EventArgs e)
        {
            panelEmailAt.Visible = (dailyRadioButton.Checked);

            // Save the change
            SettingsDAO lSettingsDao = new SettingsDAO();

            if (dailyRadioButton.Checked)
            {
                lSettingsDao.SetSetting(DatabaseSettings.Setting_AlertMonitorEmailFrequency, DatabaseSettings.Setting_AlertMonitorEmailDaily, false);
                lSettingsDao.SetSetting(DatabaseSettings.Setting_AlertMonitorEmailTime, udteEmailAtTime.DateTime.ToString("HH:mm"), false);
            }
            else
            {
                lSettingsDao.SetSetting(DatabaseSettings.Setting_AlertMonitorEmailFrequency, DatabaseSettings.Setting_AlertMonitorEmailHourly, false);
            }
        }
コード例 #7
0
        private void SaveSettings()
        {
            SettingsDAO lSettingsDAO = new SettingsDAO();

            lSettingsDAO.SetSetting("UseADCustomString", rbCustomLocation.Checked);

            if (rbCustomLocation.Checked)
            {
                StringBuilder sb = new StringBuilder();
                foreach (string communityString in lbReadStrings.Items)
                {
                    sb.Append(communityString + "|");
                }

                lSettingsDAO.SetSetting("ADCustomString", sb.ToString().TrimEnd('|'), false);
            }
        }
コード例 #8
0
ファイル: NewsFeedWidget.cs プロジェクト: windygu/AW-master
        private void CheckTasks()
        {
            UltraCalendarInfo ultraCalendarInfo = new UltraCalendarInfo();

            ultraCalendarInfo.AllowRecurringAppointments = true;
            TaskSchedulesDAO lTaskSchedulesDAO = new TaskSchedulesDAO();
            SettingsDAO      lSettingsDAO      = new SettingsDAO();
            Appointment      appointment;
            object           rawAppointmentData;

            try
            {
                foreach (DataRow row in lTaskSchedulesDAO.GetAllAppointments().Rows)
                {
                    rawAppointmentData = row["_APPOINTMENTDATA"];

                    if (rawAppointmentData is byte[] == false)
                    {
                        continue;
                    }

                    appointment         = Appointment.FromBytes(rawAppointmentData as byte[]);
                    appointment.DataKey = row[0];
                    ultraCalendarInfo.Appointments.Add(appointment);
                }

                string strLastReportRunTime = lSettingsDAO.GetSetting("LastTaskReportRun", false);

                DateTime lLastReportRunDateTime = (strLastReportRunTime == "") ? DateTime.MinValue : Convert.ToDateTime(strLastReportRunTime);
                DateTime lReportRunTime         = DateTime.Now;

                AppointmentsSubsetCollection expiredAppointments = ultraCalendarInfo.GetAppointmentsInRange(lLastReportRunDateTime, lReportRunTime);
                lSettingsDAO.SetSetting("LastTaskReportRun", DateTime.Now.ToString(), false);

                foreach (Appointment expiredAppointment in expiredAppointments)
                {
                    // need to re-check that this appointment is between the LastTaskReportRun date and DateTime.Now
                    // there is a hole in the ultraCalendarInfo.GetAppointmentsInRange logic above
                    if ((lLastReportRunDateTime < expiredAppointment.StartDateTime) && (lReportRunTime > expiredAppointment.StartDateTime))
                    {
                        string lSubject = String.Format("The following task is due at {0}." + Environment.NewLine + Environment.NewLine +
                                                        expiredAppointment.Subject, expiredAppointment.StartDateTime.ToString());

                        DesktopAlert.ShowDesktopAlertForTasks(lSubject, (int)expiredAppointment.DataKey);

                        NewsFeed.AddNewsItem(NewsFeed.Priority.Information, "Task due: " + expiredAppointment.Subject);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
            }
        }
コード例 #9
0
ファイル: FormSNMPSettings.cs プロジェクト: windygu/AW-master
        private void SaveChanges()
        {
            SettingsDAO     settingsDAO  = new SettingsDAO();
            LayIpAddressDAO ipAddressDao = new LayIpAddressDAO();
            StringBuilder   sb           = new StringBuilder();

            // delete all existing before adding new ones
            ipAddressDao.DeleteAllSnmp();

            foreach (UltraListViewItem item in tcpipListView.Items)
            {
                IPAddressRange ipAddressRange = new IPAddressRange(item.Text, item.SubItems[0].Text, item.CheckState == CheckState.Checked, IPAddressRange.IPType.Snmp);
                ipAddressDao.Add(ipAddressRange);
            }

            foreach (string communityString in lbReadStrings.Items)
            {
                sb.Append(communityString + ",");
            }

            settingsDAO.SetSetting("SNMPRead", sb.ToString().TrimEnd(','), false);
        }
コード例 #10
0
        /// <summary>
        /// Save any data entered on the Options tab
        /// </summary>
        public void SaveEmailSettings()
        {
            // Save the settings
            SettingsDAO lSettingsDao = new SettingsDAO();

            if (doSaveAdvancedSettings)
            {
                lSettingsDao.SetSetting(MailSettingsKeys.MailRequiresAuthentication, emailForm.UseAuthentication.ToString(), false);
                lSettingsDao.SetSetting(MailSettingsKeys.MailPort, emailForm.Port.ToString(), false);
                if (emailForm.UseAuthentication)
                {
                    lSettingsDao.SetSetting(MailSettingsKeys.MailUserName, emailForm.Username, false);
                    lSettingsDao.SetSetting(MailSettingsKeys.MailPassword, emailForm.Password, true);
                }

                lSettingsDao.SetSetting(MailSettingsKeys.MailSSLEnabled, emailForm.EnabledSSL.ToString(), false); // Added for ID 66125/66652
            }

            // Save general email settings
            lSettingsDao.SetSetting(MailSettingsKeys.MailSender, tbSendingEmailAddress.Text, false);
            lSettingsDao.SetSetting(MailSettingsKeys.MailServer, smtpTextBox.Text, false);
            lSettingsDao.SetSetting(MailSettingsKeys.MailAddress, tbRecipientEmailAddress.Text, false);
            lSettingsDao.SetSetting("EmailAsHtml", rbHtml.Checked);

            if (dailyRadioButton.Checked)
            {
                lSettingsDao.SetSetting(MailSettingsKeys.MailFrequency, MailFrequencyValues.Daily, false);
            }
            else if (weeklyRadioButton.Checked)
            {
                lSettingsDao.SetSetting(MailSettingsKeys.MailFrequency, MailFrequencyValues.Weekly, false);
            }
            else if (monthlyRadioButton.Checked)
            {
                lSettingsDao.SetSetting(MailSettingsKeys.MailFrequency, MailFrequencyValues.Monthly, false);
            }
            else
            {
                lSettingsDao.SetSetting(MailSettingsKeys.MailFrequency, MailFrequencyValues.Never, false);
            }
        }
コード例 #11
0
        /// <summary>
        /// Save any data entered on the tools tab
        /// </summary>
        private void SaveToolsTab()
        {
            SettingsDAO lwDataAccess = new SettingsDAO();

            lwDataAccess.SetSetting("RemoteDesktopCommand", tbRemoteDesktop.Text, false);
        }
コード例 #12
0
        private void udteEmailAtTime_ValueChanged(object sender, EventArgs e)
        {
            SettingsDAO lSettingsDao = new SettingsDAO();

            lSettingsDao.SetSetting(DatabaseSettings.Setting_AlertMonitorEmailTime, udteEmailAtTime.DateTime.ToString("HH:mm"), false);
        }
コード例 #13
0
        private void cbAlwaysShowLog_CheckedChanged(object sender, EventArgs e)
        {
            SettingsDAO lwDataAccess = new SettingsDAO();

            lwDataAccess.SetSetting(DatabaseSettingsKeys.Setting_ShowNewAlertsAtStartup, cbShowNewAtStartup.Checked);
        }
コード例 #14
0
        private void HandleCalendarEvent()
        {
            LogFile ourLog = new LogFile();

            try
            {
                SettingsDAO        lSettingsDAO        = new SettingsDAO();
                ReportSchedulesDAO lReportSchedulesDAO = new ReportSchedulesDAO();
                Appointment        appointment;
                object             rawAppointmentData;
                ultraCalendarInfo.Appointments.Clear();

                foreach (DataRow row in lReportSchedulesDAO.GetAllAppointments().Rows)
                {
                    rawAppointmentData = row["_APPOINTMENTDATA"];

                    if (rawAppointmentData is byte[] == false)
                    {
                        continue;
                    }

                    appointment = Appointment.FromBytes(rawAppointmentData as byte[]);
                    ultraCalendarInfo.Appointments.Add(appointment);
                }

                string strLastReportRunTime = lSettingsDAO.GetSetting("LastReportRun", false);

                DateTime lLastReportRunDateTime = (strLastReportRunTime == "") ? DateTime.MinValue : Convert.ToDateTime(strLastReportRunTime);
                DateTime lReportRunTime         = DateTime.Now;

                AppointmentsSubsetCollection expiredAppointments = ultraCalendarInfo.GetAppointmentsInRange(lLastReportRunDateTime, lReportRunTime);
                lSettingsDAO.SetSetting("LastReportRun", lReportRunTime.ToString(), false);

                foreach (Appointment expiredAppointment in expiredAppointments)
                {
                    // need to re-check that this appointment is between the LastTaskReportRun date and DateTime.Now
                    // there is a hole in the ultraCalendarInfo.GetAppointmentsInRange logic above
                    if ((lLastReportRunDateTime < expiredAppointment.StartDateTime) && (lReportRunTime > expiredAppointment.StartDateTime))
                    {
                        string[] lSubject        = expiredAppointment.Subject.Split('|');
                        string   lReportCategory = "";
                        string   lReportName     = "";

                        if (lSubject.Length == 2)
                        {
                            lReportCategory = lSubject[0];
                            lReportName     = lSubject[1];
                        }
                        else if (lSubject.Length == 3)
                        {
                            lReportCategory = lSubject[0];
                            lReportName     = lSubject[1] + " | " + lSubject[2];
                        }

                        if (lReportCategory.StartsWith("Custom Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendCustomReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else if (lReportCategory.StartsWith("Compliance Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendComplianceReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else if (lReportCategory.StartsWith("User-Defined SQL Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendSQLReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else
                        {
                            emailController.SendReportByEmail(expiredAppointment.Subject, expiredAppointment.Location);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ourLog.Write(ex.Message, true);
            }
        }
コード例 #15
0
        /// <summary>
        /// Called as the alert timer expires to check for any alerts having been generated and reporting them
        /// optionally sending emails if these have been configured
        ///
        /// Alert checking is done daily and will result in a number of entries being added to the ALERT table
        /// These entries are in turn
        /// </summary>
        public void CheckForAlerts()
        {
            LogFile ourLog = LogFile.Instance;

            ourLog.Write("CheckForAlerts", true);

            //
            try
            {
                SettingsDAO lSettingsDao = new SettingsDAO();

                string fileName         = String.Empty;
                string selectedFileName = String.Empty;
                System.Xml.Serialization.XmlSerializer serializer;
                AlertDefinition definition;

                // We need to be sure that we do not email the same alerts multiple times so we recover the date at
                // which we last send an email alert and only add alerts which occurred after that date to our email
                DateTime dateLastAlertEmail;
                string   lastAlertDate = lSettingsDao.GetSettingAsString(DatabaseSettings.Setting_LastAlertEmailDate, "");

                // If we have not previously checked alerts then look for alerts in the last day
                if (lastAlertDate == "")
                {
                    dateLastAlertEmail = DateTime.Now.AddDays(-1);
                }
                else
                {
                    dateLastAlertEmail = Convert.ToDateTime(lastAlertDate);
                }

                // Log the last alert date (if any)
                ourLog.Write("Checking For Alerts generated since " + dateLastAlertEmail.ToString(), true);

                // Allocate a list to hold the alerts so that they can be emailed in one go
                AlertList listAlerts = new AlertList();

                // +8.3.3
                // Now check the email frequency as if this is set to daily and we have already emailed today then we do not email again
                string mailFrequency = lSettingsDao.GetSetting(DatabaseSettings.Setting_AlertMonitorEmailFrequency, false);
                if (mailFrequency == DatabaseSettings.Setting_AlertMonitorEmailDaily)
                {
                    string mailtime = lSettingsDao.GetSetting(DatabaseSettings.Setting_AlertMonitorEmailTime, false);
                    if (mailtime == "")
                    {
                        mailtime = "18:00";
                    }
                    DateTime emailTime = DateTime.Parse(mailtime);
                    ourLog.Write("Daily checking set for " + emailTime.ToString("HH:mm") + " - Current time is " + DateTime.Now.ToString("HH:mm") + " Last Check Date was " + dateLastAlertEmail.Date.ToShortDateString(), true);

                    // Are we still prior to the checking time?
                    if (DateTime.Now.TimeOfDay < emailTime.TimeOfDay)
                    {
                        ourLog.Write("Check time not reached so exiting", true);
                        return;
                    }

                    // We are past the check date - we check if we have not previously checked today
                    else if (dateLastAlertEmail.Date == DateTime.Now.Date)
                    {
                        ourLog.Write("Check yime reached but already checked today so exiting", true);
                        return;
                    }
                }

                // Populate the Alert date so that we do not re-do this process
                lSettingsDao.SetSetting(DatabaseSettings.Setting_LastAlertEmailDate, DateTime.Now.ToString(), false);

                // Now we read all alerts created since the specified date
                listAlerts.Populate(dateLastAlertEmail);

                if (listAlerts.Count != 0)
                {
                    // read the alert definitions as we need to know which if any of these alerts should be emailed
                    // first get the AuditScanner object
                    // Loop through the alerts and weed out any AM alerts which do not require email
                    for (int index = 0; index < listAlerts.Count;)
                    {
                        Alert alert = listAlerts[index];
                        if (alert.Type == Alert.AlertType.alertmonitor)
                        {
                            fileName         = alert.AlertName;
                            selectedFileName = Path.Combine(System.Windows.Forms.Application.StartupPath, "scanners\\alertmonitors\\") + fileName + ".xml";
                            serializer       = new System.Xml.Serialization.XmlSerializer(typeof(AlertDefinition));
                            definition       = (AlertDefinition)serializer.Deserialize(new StreamReader(selectedFileName));

                            //if ((definition.Name != alert.AlertName) || (!definition.EmailAlert))
                            if (!definition.EmailAlert)
                            {
                                listAlerts.Remove(alert);
                                continue;
                            }
                        }

                        index++;
                    }

                    // If we still have some alerts left then email them
                    if (listAlerts.Count != 0)
                    {
                        // get the Email Controller Task
                        EmailController emailController = _service.GetEmailController();

                        // and request it to send an Alerts email on our behalf
                        ourLog.Write("....an alerts email is required", true);
                        emailController.SendStatusEmail(true, false, listAlerts);
                    }
                }
            }

            catch (Exception ex)
            {
                ourLog.Write("Exception occurred in [CheckForAlerts], Exception Text is " + ex.Message, true);
            }
        }