Exemple #1
0
        //-------------------------------------------------------------------------------------------------
        /// <summary>
        /// Posts the FTP message.
        /// </summary>
        private void PostFTPMessage()
        {
            configManager.Logger.Debug(EnumMethod.START);
            try
            {
                string            tempFileName = configManager.PostDir + "\\PMA_ALERTS_" + systemName + "_" + configManager.SystemAnalyzerInfo.ClientInstanceName + ".txt";
                PMAMailController mailer       = new PMAMailController(configManager.GetConsolidatedError("System Alert"), AlertType.GENERAL_ALERT, null);
                File.WriteAllText(tempFileName, mailer.GenerateMessageBody());
                FTPTransport  ftpTransport = new FTPTransport();
                List <string> filetoUpload = new List <string>();
                filetoUpload.Add(tempFileName);
                ftpTransport.FTPSend(configManager.FtpInfo, filetoUpload);
                filetoUpload = null;
                File.Delete(tempFileName);
            }
            catch (Exception ex)
            {
                // No Reattempt if FTP upload fail, otherwise it can bombart mails

                //configManager.FlagInfo.FlagedDiscAlert = false;
                //configManager.FlagInfo.FlagedPhysicalMemoryAlert = false;
                //configManager.FlagInfo.FlagedServiceAlert = false;
                //configManager.FlagInfo.FlagedASPStateSizeAlert = false;
                //configManager.FlagInfo.FlagedTempDBMemoryAlert = false;
                configManager.Logger.Error(ex);
            }
            configManager.Logger.Debug(EnumMethod.END);
        }
Exemple #2
0
        //----------------------------------------------------------------------------------------------------------------------------
        /// <summary>
        /// Reportings the task.
        /// </summary>
        public void ReportingTask()
        {
            configManager.Logger.Debug(EnumMethod.START);
            if (configManager.SystemAnalyzerInfo.SetPMA)
            {
                SMTPTransport smtpTransport = new SMTPTransport();
                FTPTransport  ftpTransport  = new FTPTransport();
                try
                {
                    _reportFileName = string.Empty;
                    if (File.Exists(_fileName))
                    {
                        _reportFileName = CreateAllProcessCSVReport(_fileName);
                    }
                    if (DateTime.Now > mailingTime)
                    {
                        mailingTime = mailingTime.AddHours(configManager.PMAInfoObj.ReportsIntervalHours);
                        configManager.PMAInfoObj.MailingTime = mailingTime;
                    }
                    if (File.Exists(_fileName))
                    {
                        if (configManager.PMAInfoObj.UseSMTP)
                        {
                            try
                            {
                                string subject = "PMA System Alerts : PMA Report : " + configManager.SystemAnalyzerInfo.ClientInstanceName + " : " + Environment.MachineName + " : " +
                                                 " at " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();

                                List <string> attachments = new List <string>();
                                attachments.Add(_reportFileName);
                                smtpTransport.SmtpSend(configManager.SmtpInfo, configManager.SystemAnalyzerInfo.ListPMAReportSubscription, null,
                                                       subject, GenerateMailMessageBody(), attachments);
                            }
                            catch (InvalidOperationException ex)
                            {
                                configManager.Logger.Message(ex.Message);
                            }
                            catch (Exception ex)
                            {
                                configManager.Logger.Error(ex);
                            }
                        }
                        if (configManager.PMAInfoObj.UseFTP)
                        {
                            try
                            {
                                List <string> ftpFiles = new List <string>();
                                ftpFiles.Add(_reportFileName);
                                ftpTransport.FTPSend(configManager.FtpInfo, ftpFiles);
                            }
                            catch (Exception ex)
                            {
                                configManager.Logger.Error(ex);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    configManager.Logger.Error(ex);
                }
                finally
                {
                    smtpTransport = null;
                    ftpTransport  = null;
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    _fileName = GenerateNewFileName();
                    SerializedPMAInfo();
                    configManager.Logger.Debug(EnumMethod.END);
                }
            }
        }