Esempio n. 1
0
        protected override void StampChangesOn(IConfigurable dataObject)
        {
            TaskLogger.LogEnter();
            base.StampChangesOn(dataObject);
            Server        server   = (Server)dataObject;
            MailboxServer instance = this.Instance;

            if (!server.IsProvisionedServer)
            {
                Exception ex = null;
                if (string.IsNullOrEmpty(server.Fqdn))
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, server.Identity.ToString(), ServerSchema.Fqdn.Name)), ErrorCategory.ReadError, server.Identity);
                }
                if (instance.IsModified(MailboxServerSchema.Locale))
                {
                    GetMailboxServer.GetConfigurationFromRegistry(server.Fqdn, out this.oldLocale, out ex);
                    if (ex != null)
                    {
                        base.WriteError(new InvalidOperationException(Strings.ErrorAccessingRegistryRaisesException(server.Fqdn, ex.Message)), ErrorCategory.ReadError, server.Identity);
                    }
                }
                else
                {
                    this.oldLocale = new CultureInfo[0];
                }
            }
            else if (instance.IsModified(MailboxServerSchema.Locale))
            {
                base.WriteError(new InvalidOperationException(Strings.ErrorInvalidOperationOnProvisionedMailboxServer), ErrorCategory.InvalidArgument, server.Identity);
            }
            if (!instance.IsModified(MailboxServerSchema.Locale))
            {
                this.isLocalChanged = false;
                server.Locale       = this.oldLocale;
            }
            else
            {
                server.Locale = instance.Locale;
            }
            TaskLogger.LogExit();
        }
Esempio n. 2
0
        protected sealed override void InternalProcessRecord()
        {
            TaskLogger.LogEnter(new object[]
            {
                this.DataObject
            });
            MailboxServer mailboxServer = new MailboxServer(this.DataObject);
            string        fqdn          = this.DataObject.Fqdn;
            Exception     ex            = null;
            bool          flag          = false;

            if (this.isLocalChanged && !this.DataObject.IsProvisionedServer)
            {
                GetMailboxServer.SetConfigurationFromRegistry(fqdn, mailboxServer.Locale, out ex);
                if (ex != null)
                {
                    base.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(fqdn, ex.Message)), ErrorCategory.WriteError, this.Identity);
                }
                flag = true;
            }
            bool flag2 = false;

            try
            {
                base.InternalProcessRecord();
                flag2 = true;
            }
            finally
            {
                if (!flag2 && flag)
                {
                    GetMailboxServer.SetConfigurationFromRegistry(fqdn, this.oldLocale, out ex);
                    if (ex != null)
                    {
                        this.WriteError(new InvalidOperationException(Strings.ErrorFaildToWriteRegistry(fqdn, ex.Message)), ErrorCategory.WriteError, this.Identity, false);
                    }
                }
                TaskLogger.LogExit();
            }
        }
Esempio n. 3
0
        protected override void WriteResult(IConfigurable dataObject)
        {
            TaskLogger.LogEnter(new object[]
            {
                dataObject.Identity,
                dataObject
            });
            MailboxServer mailboxServer = new MailboxServer((Server)dataObject);
            string        fqdn          = ((Server)dataObject).Fqdn;

            if (this.Status && ((Server)dataObject).IsProvisionedServer)
            {
                this.WriteWarning(Strings.StatusSpecifiedForProvisionedServer);
            }
            if (this.Status && !mailboxServer.IsReadOnly && !((Server)dataObject).IsProvisionedServer)
            {
                if (string.IsNullOrEmpty(fqdn))
                {
                    this.WriteWarning(Strings.ErrorInvalidObjectMissingCriticalProperty(typeof(Server).Name, mailboxServer.Identity.ToString(), ServerSchema.Fqdn.Name));
                }
                else
                {
                    Exception     ex = null;
                    CultureInfo[] array;
                    GetMailboxServer.GetConfigurationFromRegistry(fqdn, out array, out ex);
                    if (ex != null)
                    {
                        this.WriteWarning(Strings.ErrorAccessingRegistryRaisesException(fqdn, ex.Message));
                    }
                    mailboxServer.Locale = array;
                    mailboxServer.ResetChangeTracking();
                }
            }
            base.WriteResult(mailboxServer);
            TaskLogger.LogExit();
        }