static void Main(string[] args) { // configure logging { RollingFileAppender a = new RollingFileAppender(); a.DatePattern = "yyyy-MM-dd"; a.AppendToFile = true; a.StaticLogFileName = false; a.File = FileUtil.CatDir(new string[]{ Program.DataDirectory, "log", "log-"}); // Directory.GetParent(a.File).Create(); a.RollingStyle = RollingFileAppender.RollingMode.Date; a.Layout = new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); a.ActivateOptions(); log4net.Config.BasicConfigurator.Configure(a); Hierarchy repository = log4net.LogManager.GetRepository() as Hierarchy; repository.Root.Level = Level.Debug; } log.Info("Startup"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Sidi.Net.Pop3.Server server = new Sidi.Net.Pop3.Server(); server.MailboxProvider = delegate(TcpClient client, string user, string pass) { Account a = new Account(user, pass); if (a.Exists && a.Read()) { Account.DefaultAccount = a; // start collector thread Thread collectorThread = new Thread ( new ParameterizedThreadStart(delegate(object p) { Account account = (Account)p; account.CheckCollect(); }) ); collectorThread.SetApartmentState(ApartmentState.STA); collectorThread.Start(a); return new PaymentMailBox(a); } else { return null; } }; try { server.StartLoopback(); } catch (SocketException e) { log.Error("POP3 server cannot be started. Check if another POP3 server is already running.", e); MessageBox.Show("POP3 server cannot be started. Check if another POP3 server is already running.", Sammy.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.Run(new MyApplicationContext()); server.Stop(); log.Info("Shutdown"); }
static void Main(string[] args) { // configure logging { RollingFileAppender a = new RollingFileAppender(); a.DatePattern = "yyyy-MM-dd"; a.AppendToFile = true; a.StaticLogFileName = false; a.File = FileUtil.CatDir(new string[] { Program.DataDirectory, "log", "log-" }); // Directory.GetParent(a.File).Create(); a.RollingStyle = RollingFileAppender.RollingMode.Date; a.Layout = new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline"); a.ActivateOptions(); log4net.Config.BasicConfigurator.Configure(a); Hierarchy repository = log4net.LogManager.GetRepository() as Hierarchy; repository.Root.Level = Level.Debug; } log.Info("Startup"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Sidi.Net.Pop3.Server server = new Sidi.Net.Pop3.Server(); server.MailboxProvider = delegate(TcpClient client, string user, string pass) { Account a = new Account(user, pass); if (a.Exists && a.Read()) { Account.DefaultAccount = a; // start collector thread Thread collectorThread = new Thread ( new ParameterizedThreadStart(delegate(object p) { Account account = (Account)p; account.CheckCollect(); }) ); collectorThread.SetApartmentState(ApartmentState.STA); collectorThread.Start(a); return(new PaymentMailBox(a)); } else { return(null); } }; try { server.StartLoopback(); } catch (SocketException e) { log.Error("POP3 server cannot be started. Check if another POP3 server is already running.", e); MessageBox.Show("POP3 server cannot be started. Check if another POP3 server is already running.", Sammy.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Application.Run(new MyApplicationContext()); server.Stop(); log.Info("Shutdown"); }