Example #1
0
        static int Main(string[] args)
        {
            if (args.Length == 1)
            {
                switch (Environment.GetCommandLineArgs()[1].ToLower())
                {
                case "--status":
                {
                    IisIntegration.PrintSmtpServerStatus(METABASE);
                    break;
                }

                case "--stop":
                {
                    IisIntegration.StopSmtpServer(METABASE);
                    break;
                }

                case "--start":
                {
                    IisIntegration.StartSmtpServer(METABASE);
                    break;
                }

                case "--restart":
                {
                    IisIntegration.RestartSmtpServer(METABASE);
                    break;
                }

                case "--synchronize":
                {
                    FileSupport.Synchronize();
                    break;
                }

                case "--help":
                {
                    PrintHelp();
                    break;
                }

                default:
                {
                    PrintHelp();
                    return(0);
                }
                }
            }
            else if (args.Length == 2)
            {
                switch (Environment.GetCommandLineArgs()[1].ToLower())
                {
                case "--exportfromims":
                {
                    List <EntityIpDomain> imsList = Ims.GetList();
                    FileSupport.ExportToFile(Environment.GetCommandLineArgs()[2].Trim(), imsList, true);
                    break;
                }

                case "--export":
                {
                    List <EntityIpDomain> relayList = IisIntegration.GetIpSecurityPropertyArray(IisIntegration.METABASE, MethodName.Get, MethodArgument.IPSecurity, Member.IPGrant);
                    FileSupport.ExportToFile(Environment.GetCommandLineArgs()[2].Trim(), relayList, true);
                    break;
                }

                case "--import":
                {
                    FileSupport.ImportFromFile(Environment.GetCommandLineArgs()[2].Trim());
                    break;
                }

                case "--add":
                {
                    FileSupport.AddFromArg(Environment.GetCommandLineArgs()[2].Trim());
                    break;
                }

                case "--compareimstorelay":
                {
                    List <EntityIpDomain> diffList = Lists.GetDifference(Ims.GetList(), IisIntegration.GetIpSecurityPropertyArray(IisIntegration.METABASE, MethodName.Get, MethodArgument.IPSecurity, Member.IPGrant));
                    FileSupport.ExportToFile(Environment.GetCommandLineArgs()[2].Trim(), diffList, true);
                    break;
                }

                case "--comparerelaytoims":
                {
                    List <EntityIpDomain> diffList = Lists.GetDifference(IisIntegration.GetIpSecurityPropertyArray(IisIntegration.METABASE, MethodName.Get, MethodArgument.IPSecurity, Member.IPGrant), Ims.GetList());
                    FileSupport.ExportToFile(Environment.GetCommandLineArgs()[2].Trim(), diffList, true);
                    break;
                }

                default:
                {
                    PrintHelp();
                    return(0);
                }
                }
            }
            else
            {
                PrintHelp();
                return(0);
            }

            return(0);
        }