Beispiel #1
0
        public List <MailNotificationSettings> GetMailNotificationSettings()
        {
            List <MailNotificationSettings> oList = new List <MailNotificationSettings>();
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    String    query    = "SELECT Id,ComolUniqueID,NotifyedOn,ErrorsCount FROM MailNotificationSettings";
                    DbCommand oCommand = oDatabase.GetSqlStringCommand(query);
                    oCommand.Connection = connection;
                    DbDataReader reader = oCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        MailNotificationSettings setting = new MailNotificationSettings();
                        setting.Id            = (long)reader.GetValue(0);
                        setting.ComolUniqueID = (String)reader.GetValue(1);
                        setting.ErrorsCount   = (int)reader.GetValue(3);
                        setting.NotifyedOn    = (DateTime?)reader.GetValue(2);
                        oList.Add(setting);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("ManagerDatabase", ex.Message);
                    throw new Exception(ex.Message, ex);
                }
            }
            return(oList);
        }
Beispiel #2
0
        public void SaveGenericError(GenericError error)
        {
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_GenericError_Add");
                    if (error.UniqueID == System.Guid.Empty)
                    {
                        error.UniqueID = System.Guid.NewGuid();
                    }
                    oDatabase.AddInParameter(oCommand, "@Message", System.Data.DbType.String, error.Message);
                    oDatabase.AddInParameter(oCommand, "@InnerExceptionMessage", System.Data.DbType.String, error.InnerExceptionMessage);
                    oDatabase.AddInParameter(oCommand, "@ComolUniqueID", System.Data.DbType.String, error.ComolUniqueID);
                    oDatabase.AddInParameter(oCommand, "@SentDate", System.Data.DbType.DateTime, error.SentDate);
                    oDatabase.AddInParameter(oCommand, "@Day", System.Data.DbType.Date, error.Day);
                    oDatabase.AddInParameter(oCommand, "@UniqueID", System.Data.DbType.Guid, error.UniqueID);
                    oCommand.Connection = connection;
                    if (oCommand.ExecuteNonQuery() == 0)
                    {
                        throw new Exception("no insert: sp_GenericError_Add");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("ManagerDatabase", ex.Message);
                }
            }
        }
Beispiel #3
0
        public List <MailTemplate> GetTemplates()
        {
            List <MailTemplate> oList     = new List <MailTemplate>();
            Database            oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    String    query    = "SELECT Id,Name,ErrorType,Subject,Body FROM MailTemplate";
                    DbCommand oCommand = oDatabase.GetSqlStringCommand(query);
                    oCommand.Connection = connection;
                    DbDataReader reader = oCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        MailTemplate template = new  MailTemplate();
                        template.Id      = (long)reader.GetValue(0);
                        template.Name    = (String)reader.GetValue(1);
                        template.Type    = (ErrorType)reader.GetValue(2);
                        template.Subject = (String)reader.GetValue(3);
                        template.Body    = (String)reader.GetValue(4);
                        oList.Add(template);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("-GetTemplates", ex.Message);
                }
            }
            return(oList);
        }
Beispiel #4
0
        public void SaveGenericWebError(GenericWebError error)
        {
            System.Diagnostics.EventLog.WriteEntry("DEBUG", "STO PER CREARE LA CONNESSIONE AL DB");
            System.Diagnostics.EventLog.WriteEntry("DEBUG", DataHelpers.ConnectionString());
            Database oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            System.Diagnostics.EventLog.WriteEntry("DEBUG", "STO PER CREARE LA CONNESSIONE AL DB");
            using (DbConnection connection = oDatabase.CreateConnection())
            {
                try
                {
                    connection.Open();
                    System.Diagnostics.EventLog.WriteEntry("DEBUG", "HO APERTO LA CONNESSIONE AL DB");
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("DEBUG", ex.Message);
                }

                try
                {
                    DbCommand oCommand = oDatabase.GetStoredProcCommand("sp_GenericWebError_Add");
                    if (error.UniqueID == System.Guid.Empty)
                    {
                        error.UniqueID = System.Guid.NewGuid();
                    }
                    oDatabase.AddInParameter(oCommand, "@Message", System.Data.DbType.String, error.Message);
                    oDatabase.AddInParameter(oCommand, "@InnerExceptionMessage", System.Data.DbType.String, error.InnerExceptionMessage);
                    oDatabase.AddInParameter(oCommand, "@ComolUniqueID", System.Data.DbType.String, error.ComolUniqueID);
                    oDatabase.AddInParameter(oCommand, "@SentDate", System.Data.DbType.DateTime, error.SentDate);
                    oDatabase.AddInParameter(oCommand, "@Day", System.Data.DbType.Date, error.Day);
                    oDatabase.AddInParameter(oCommand, "@UniqueID", System.Data.DbType.Guid, error.UniqueID);
                    oDatabase.AddInParameter(oCommand, "@ModuleCode", System.Data.DbType.String, error.ModuleCode);
                    oDatabase.AddInParameter(oCommand, "@CommunityID", System.Data.DbType.Int32, error.CommunityID);
                    oDatabase.AddInParameter(oCommand, "@ModuleID", System.Data.DbType.Int32, error.ModuleID);
                    oDatabase.AddInParameter(oCommand, "@UserID", System.Data.DbType.Int32, error.UserID);
                    oDatabase.AddInParameter(oCommand, "@ServerName", System.Data.DbType.String, error.ServerName);
                    oDatabase.AddInParameter(oCommand, "@Url", System.Data.DbType.String, error.Url);
                    oDatabase.AddInParameter(oCommand, "@QueryString", System.Data.DbType.String, error.QueryString);
                    oDatabase.AddInParameter(oCommand, "@ExceptionSource", System.Data.DbType.String, error.ExceptionSource);
                    oDatabase.AddInParameter(oCommand, "@BaseExceptionStackTrace", System.Data.DbType.String, error.BaseExceptionStackTrace);

                    oCommand.Connection = connection;
                    System.Diagnostics.EventLog.WriteEntry("DEBUG", "ASTO PER INSERIRE UN ERRORE");
                    if (oCommand.ExecuteNonQuery() == 0)
                    {
                        throw new Exception("no insert: sp_GenericWebError_Add");
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("ManagerDatabase - GenericWebError", ex.Message);
                    throw new Exception("no insert: sp_GenericWebError_Add");
                }
            }
        }
Beispiel #5
0
 public void SaveFileError(FileError error)
 {
     try
     {
         String subject = string.Format(_template.Subject, error.ComolUniqueID);
         String body    = string.Format(_template.Body, error.SentDate.ToLongDateString(), error.UserID, error.CommunityID, error.CommunityFileID, error.BaseFileID, error.NoticeboardFileID, error.ThesisFileID, error.Message);
         DataHelpers.SendMessage(_setting, subject, body);
     }
     catch (Exception ex)
     {
         System.Diagnostics.EventLog.WriteEntry("Mail - SaveFileError ", ex.Message);
         throw ex;
     }
 }
Beispiel #6
0
 public void SaveGenericModuleError(GenericModuleError error)
 {
     try
     {
         String subject = string.Format(_template.Subject, error.ComolUniqueID);
         String body    = string.Format(_template.Body, error.SentDate.ToLongDateString(), error.ModuleCode, error.Message, error.InnerExceptionMessage);
         DataHelpers.SendMessage(_setting, subject, body);
     }
     catch (Exception ex)
     {
         System.Diagnostics.EventLog.WriteEntry("Mail - GenericModuleError: ", ex.Message);
         throw ex;
     }
 }
Beispiel #7
0
 public void SaveGenericWebError(GenericWebError error)
 {
     try
     {
         String subject = string.Format(_template.Subject, error.ComolUniqueID);
         String body    = string.Format(_template.Body, error.SentDate.ToLongDateString(), error.ServerName, error.UserID, error.ModuleCode, error.ModuleID,
                                        error.CommunityID, error.Url, error.QueryString, error.Message, error.InnerExceptionMessage, error.ExceptionSource, error.BaseExceptionStackTrace);
         System.Diagnostics.EventLog.WriteEntry("DEBUG", "STO PER INVIARE LA MAIL");
         DataHelpers.SendMessage(_setting, subject, body);
     }
     catch (Exception ex)
     {
         System.Diagnostics.EventLog.WriteEntry("Mail - GenericWebError ", ex.Message);
         throw ex;
     }
 }
Beispiel #8
0
        public List <ErrorSettings> GetErrorSettings()
        {
            List <ErrorSettings> oList     = new List <ErrorSettings>();
            Database             oDatabase = DatabaseFactory.CreateDatabase(DataHelpers.ConnectionString());

            using (DbConnection connection = oDatabase.CreateConnection())
            {
                connection.Open();
                try
                {
                    String    query    = "SELECT Id,ComolUniqueID,Name,ServerSMTP,SenderMail,SenderName,RealMailSender,ReplyTo,RecipientMail,NotifyAfterErrors,NotificationDelay,UseAuthentication,AccountName,AccountPassword,Port,UseSSL FROM Settings";
                    DbCommand oCommand = oDatabase.GetSqlStringCommand(query);
                    oCommand.Connection = connection;
                    DbDataReader reader = oCommand.ExecuteReader();
                    while (reader.Read())
                    {
                        ErrorSettings setting = new  ErrorSettings();
                        setting.Id                = (long)reader.GetValue(0);
                        setting.ComolUniqueID     = (String)reader.GetValue(1);
                        setting.Name              = (String)reader.GetValue(2);
                        setting.HostSMTP          = (String)reader.GetValue(3);
                        setting.SenderMail        = (String)reader.GetValue(4);
                        setting.SenderName        = (String)reader.GetValue(5);
                        setting.RealMailSender    = (String)reader.GetValue(6);
                        setting.ReplyTo           = (String)reader.GetValue(7);
                        setting.RecipientMail     = (String)reader.GetValue(8);
                        setting.NotifyAfterErrors = (int)reader.GetValue(9);
                        setting.NotificationDelay = (int)reader.GetValue(10);
                        setting.UseAuthentication = (Boolean)reader.GetValue(11);
                        setting.AccountName       = (String)reader.GetValue(12);
                        setting.AccountPassword   = (String)reader.GetValue(13);
                        setting.Port              = (int)reader.GetValue(14);
                        setting.UseSsl            = (Boolean)reader.GetValue(15);

                        oList.Add(setting);
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("-GetErrorSettings", ex.Message);
                    throw new Exception(ex.Message, ex);
                }
            }
            return(oList);
        }
Beispiel #9
0
 public void SaveDBerror(DBerror error)
 {
     try {
         String subject    = string.Format(_template.Subject, error.ComolUniqueID);
         String parameters = "";
         foreach (String parameter in error.SQLparameters)
         {
             parameters += parameter + Environment.NewLine;
         }
         String body = string.Format(_template.Body, error.SentDate.ToLongDateString(), error.SQLcommand, parameters, error.Message, error.StackTrace);
         DataHelpers.SendMessage(_setting, subject, body);
     }
     catch (Exception ex)
     {
         System.Diagnostics.EventLog.WriteEntry("Mail - DBerror", ex.Message);
         throw ex;
     }
 }