Exemplo n.º 1
0
        private void StartProcess()
        {
            try
            {
                timer.Enabled = true;
                _startTime    = DateTime.Now;

                hMailServer.Application application = Globals.GetApp();

                string        dataDirectory = application.Settings.Directories.DataDirectory;
                DirectoryInfo dirInfo       = new DirectoryInfo(dataDirectory);

                // Process the queue first.
                ProcessFilesInFolder(dirInfo, 0);

                // Process all domains
                IterateDomainFolders(dirInfo);

                timer.Enabled = false;

                application.Reinitialize();

                TimerTick();

                labelStatus.Text = "The synchronization has completed.";
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message + Environment.NewLine + e.StackTrace);
            }
        }
Exemplo n.º 2
0
        private static void InitializeInternalDatabase()
        {
            try
            {
                hMailServer.Database database = _application.Database;

                database.CreateInternalDatabase();

                // Database has been upgraded. Reinitialize the connections.
                _application.Reinitialize();

                // Re-initialize to connect to the newly created database.
                _application.Reinitialize();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "hMailServer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        public void DoUpgrade()
        {
            using (new WaitCursor())
            {
                buttonClose.Enabled   = false;
                buttonUpgrade.Enabled = false;

                hMailServer.Database database = _application.Database;

                try
                {
                    database.BeginTransaction();
                }
                catch (Exception e)
                {
                    HandleUpgradeError(database, e, "Transaction");
                    return;
                }

                // Run the prerequisites script.
                string prerequisitesScript = GetPrerequisitesScript();
                if (!string.IsNullOrEmpty(prerequisitesScript))
                {
                    string fullScriptPath = Path.Combine(_scriptPath, prerequisitesScript);

                    try
                    {
                        database.ExecuteSQLScript(fullScriptPath);
                    }
                    catch (Exception ex)
                    {
                        HandleUpgradeError(database, ex, fullScriptPath);
                        return;
                    }
                }


                foreach (ListViewItem item in listRequiredUpgrades.Items)
                {
                    UpgradeScript script = item.Tag as UpgradeScript;

                    string scriptToExecute = GetScriptFileName(script);

                    try
                    {
                        // Make sure the
                        database.EnsurePrerequisites(script.To);

                        database.ExecuteSQLScript(scriptToExecute);

                        item.SubItems.Add("Complete");

                        Application.DoEvents();
                    }
                    catch (Exception e)
                    {
                        item.SubItems.Add("Error");

                        HandleUpgradeError(database, e, scriptToExecute);
                        return;
                    }
                }

                try
                {
                    database.CommitTransaction();
                }
                catch (Exception e)
                {
                    HandleUpgradeError(database, e, "Transaction");
                    return;
                }

                Marshal.ReleaseComObject(database);

                // Database has been upgraded. Reinitialize the connections.
                _application.Reinitialize();

                RemoveErrorLog();

                buttonClose.Enabled = true;
            }
        }
Exemplo n.º 4
0
 public void Reinitialize()
 {
     _object.Reinitialize();
 }