コード例 #1
0
        private void OnSyncClick(object sender, EventArgs e)
        {
            var engine = new SyncEngine(this.configuration);

            try
            {
                engine.Do(this, true);

                this.lblPrgTasks.Text   = string.Empty;
                this.lblPrgDetails.Text = string.Empty;
            }
            catch (LdapException exception)
            {
                MessageBox.Show("Es ist ein Fehler aufgetreten:" + Environment.NewLine + Environment.NewLine + exception.Message, "Fehler...", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.ResetProgess();
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Trace.AutoFlush = true;

            if ((args?.Contains("/headless") ?? false) || (args?.Contains("-headless") ?? false))
            {
                Trace.Listeners.Add(new EventLogTraceListener("OptigemLdapSync"));

                var configuration        = new SyncConfiguration();
                Models.SyncResult result = null;

                try
                {
                    var kernel = new SyncEngine(configuration);

                    result = kernel.Do(null, false);
                }
                catch (Exception exception)
                {
                    Trace.TraceError(exception.ToString());

                    Console.WriteLine(exception);
                    throw;
                }
                finally
                {
                    Trace.TraceInformation(
                        "OPTIGEM LDAP Sync: {0} activated, {1} deactivated, {2} created, {3} updated.",
                        result == null ? 0 : result.Activated,
                        result == null ? 0 : result.Dectivated,
                        result == null ? 0 : result.Created,
                        result == null ? 0 : result.Updated);

                    Trace.Flush();
                }
            }
            else
            {
                Application.ThreadException += ApplicationThreadException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
        }