示例#1
0
        static void Main(string[] args)
        {
            if (initBS())
            {
                //Check First Run (-1)
                if (BS.Port != -1 && !BitAPIserver.init(BS))
                {
                    MessageBox.Show(@"Error reading API values.
Check if keys.dat is present and API values are set.
Also verify the API File Path in BitServer.ini is valid.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    AuxMessages = new List <POP3message>();
                    AckMessage  = new List <string>();

                    tDSN = new Thread(new ThreadStart(checkMSG));
                    tDSN.IsBackground = true;
                    tDSN.Start();

                    if (BS.Port == -1)
                    {
                        Settings_Click(null, null);
                        Application.Run(GUI = new frmLoop());
                    }
                    else
                    {
                        Application.Run(GUI = new frmLoop());
                    }
                }
            }
            else
            {
                var Parts = new INI.INIPart[] { new INI.INIPart(), new INI.INIPart() };
                var NVC   = new System.Collections.Specialized.NameValueCollection();

                Parts[0].Section = "API";
                NVC.Add("FILE", "keys.dat");
                NVC.Add("NAME", "AyrA");
                NVC.Add("PASS", "BitMailServer");
                NVC.Add("DEST", "127.0.0.1");
                NVC.Add("PORT", "-1");
                Parts[0].Settings = NVC;

                Parts[1].Section = "MAIL";
                NVC = new System.Collections.Specialized.NameValueCollection();
                NVC.Add("RANDOM", "TRUE");
                NVC.Add("STRIP", "TRUE");
                Parts[1].Settings = NVC;

                INI.RewriteINI(CONFIG, Parts);

                MessageBox.Show("Error reading BitServer.ini Values.\r\nA File with Default Settings was created.\r\nPlease change its settings in the folowing Window.", "Initialization Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Restart();
            }

            cont = false;

            Console.WriteLine("Exiting...");
            if (NFI != null)
            {
                NFI.Visible = false;
                NFI.Dispose();
                CMS.Dispose();
            }
            tDSN.Join();
        }