Exemplo n.º 1
0
        private bool GetOutOfOfficeMessage(int traceId, MailboxSession session, MailTips mailTips)
        {
            bool flag = false;

            MailTipsLocalQuery.GetMailTipsTracer.TraceFunction <object, EmailAddress>((long)traceId, "{0} / {1}: Getting OutOfOffice", TraceContext.Get(), mailTips.EmailAddress);
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                object obj   = session.Mailbox.TryGetProperty(MailboxSchema.MailboxOofState);
                bool   flag2 = true;
                if (!(obj is PropertyError))
                {
                    flag2 = (bool)obj;
                }
                if (flag2)
                {
                    UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(session);
                    this.ParseUserOofSettings(userOofSettings, mailTips, traceId);
                }
                flag = true;
            }
            catch (InvalidParameterException ex)
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug((long)traceId, "{0} / {1}: GetOofMailTip InvalidParameterException: {2}, {3}", new object[]
                {
                    TraceContext.Get(),
                    mailTips.EmailAddress,
                    ex.GetType().Name,
                    ex.Message
                });
                mailTips.OutOfOfficeMessage = null;
                flag = true;
            }
            finally
            {
                stopwatch.Stop();
                MailTipsPerfCounters.OutOfOfficeAnsweredWithinOneSecond_Base.Increment();
                if (stopwatch.ElapsedMilliseconds < 1000L)
                {
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinOneSecond.Increment();
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinThreeSeconds.Increment();
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinTenSeconds.Increment();
                }
                else if (stopwatch.ElapsedMilliseconds < 3000L)
                {
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinThreeSeconds.Increment();
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinTenSeconds.Increment();
                }
                else if (stopwatch.ElapsedMilliseconds < 10000L)
                {
                    MailTipsPerfCounters.OutOfOfficeAnsweredWithinTenSeconds.Increment();
                }
                if (flag)
                {
                    MailTipsPerfCounters.OutOfOfficePositiveResponses.Increment();
                }
            }
            return(flag);
        }
Exemplo n.º 2
0
        protected void CreateOutOfOfficeNotification()
        {
            this.shouldShowOofDialog = ((base.UserContext.MailboxSession.Mailbox.TryGetProperty(MailboxSchema.MailboxOofState) as bool?) ?? false);
            if (!this.shouldShowOofDialog || base.UserContext.IsWebPartRequest)
            {
                return;
            }
            UserOofSettings userOofSettings = null;

            try
            {
                userOofSettings = UserOofSettings.GetUserOofSettings(base.UserContext.MailboxSession);
            }
            catch (QuotaExceededException ex)
            {
                ExTraceGlobals.CoreTracer.TraceDebug <string>(0L, "BasicMessageView.CreateOutOfOfficeNotification: Failed. Exception: {0}", ex.Message);
                return;
            }
            switch (userOofSettings.OofState)
            {
            case OofState.Enabled:
                this.shouldShowOofDialog = base.UserContext.MessageViewFirstRender;
                break;

            case OofState.Scheduled:
            {
                this.shouldShowOofDialog = false;
                if (RenderingFlags.HideOutOfOfficeInfoBar(base.UserContext))
                {
                    return;
                }
                DateTime utcNow = DateTime.UtcNow;
                DateTime t      = DateTime.MinValue;
                DateTime t2     = DateTime.MinValue;
                if (userOofSettings.Duration != null)
                {
                    t  = userOofSettings.Duration.StartTime;
                    t2 = userOofSettings.Duration.EndTime;
                }
                if (utcNow > t && t2 > utcNow)
                {
                    ExDateTime exDateTime = new ExDateTime(base.UserContext.TimeZone, userOofSettings.Duration.EndTime);
                    SanitizingStringBuilder <OwaHtml> sanitizingStringBuilder = new SanitizingStringBuilder <OwaHtml>();
                    sanitizingStringBuilder.AppendFormat(LocalizedStrings.GetHtmlEncoded(-1261886615), new object[]
                        {
                            exDateTime.ToLongDateString() + " " + exDateTime.ToString(base.UserContext.UserOptions.TimeFormat)
                        });
                    sanitizingStringBuilder.Append(" <a href=# onclick=\"onClkHdOof()\">");
                    sanitizingStringBuilder.Append(LocalizedStrings.GetNonEncoded(1303059585));
                    sanitizingStringBuilder.Append("</a>");
                    base.Infobar.AddMessageHtml(sanitizingStringBuilder.ToSanitizedString <SanitizedHtmlString>(), InfobarMessageType.Informational);
                }
                return;
            }

            default:
                this.shouldShowOofDialog = false;
                return;
            }
        }
Exemplo n.º 3
0
        public void DisableOof()
        {
            ExTraceGlobals.UserOptionsCallTracer.TraceDebug((long)this.GetHashCode(), "OptionsEventHandler.DisableOof");
            UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(base.UserContext.MailboxSession);

            userOofSettings.OofState = OofState.Disabled;
            userOofSettings.Save(base.UserContext.MailboxSession);
        }
		// Token: 0x06001BCB RID: 7115 RVA: 0x0006B1A4 File Offset: 0x000693A4
		protected override bool InternalExecute()
		{
			MailboxSession mailboxIdentityMailboxSession = base.CallContext.SessionCache.GetMailboxIdentityMailboxSession();
			UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(mailboxIdentityMailboxSession);
			userOofSettings.OofState = (this.userOofSettings.IsOofOn ? OofState.Enabled : OofState.Disabled);
			userOofSettings.ExternalAudience = this.userOofSettings.ExternalAudience;
			userOofSettings.InternalReply.Message = UserOofSettingsType.ConvertTextToHtml(this.userOofSettings.InternalReply);
			userOofSettings.ExternalReply.Message = UserOofSettingsType.ConvertTextToHtml(this.userOofSettings.ExternalReply);
			userOofSettings.Save(mailboxIdentityMailboxSession);
			return true;
		}
Exemplo n.º 5
0
        // Token: 0x0600113F RID: 4415 RVA: 0x00042194 File Offset: 0x00040394
        public UserOofSettingsType(UserOofSettings userOofSettings, ExTimeZone timeZone)
        {
            this.ExternalAudience = userOofSettings.ExternalAudience;
            this.ExternalReply    = UserOofSettingsType.ConvertHtmlToText(userOofSettings.ExternalReply.Message);
            this.InternalReply    = UserOofSettingsType.ConvertHtmlToText(userOofSettings.InternalReply.Message);
            this.IsScheduled      = (userOofSettings.OofState == OofState.Scheduled);
            if (userOofSettings.OofState == OofState.Enabled || (userOofSettings.OofState == OofState.Scheduled && DateTime.UtcNow >= userOofSettings.Duration.StartTime && DateTime.UtcNow <= userOofSettings.Duration.EndTime))
            {
                this.IsOofOn = true;
            }
            else
            {
                this.IsOofOn = false;
            }
            ExDateTime exDateTime = new ExDateTime(timeZone, userOofSettings.Duration.EndTime);

            this.EndTime = exDateTime.ToISOString();
        }
        protected override void InternalSave(ConfigurableObject instance)
        {
            MailboxAutoReplyConfiguration mailboxAutoReplyConfiguration = (MailboxAutoReplyConfiguration)instance;
            UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(base.MailboxSession);

            if (userOofSettings == null)
            {
                userOofSettings = UserOofSettings.CreateDefault();
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.AutoReplyState))
            {
                userOofSettings.OofState = mailboxAutoReplyConfiguration.AutoReplyState;
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.ExternalAudience))
            {
                userOofSettings.ExternalAudience = mailboxAutoReplyConfiguration.ExternalAudience;
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.ExternalMessage))
            {
                userOofSettings.ExternalReply.Message     = mailboxAutoReplyConfiguration.ExternalMessage;
                userOofSettings.ExternalReply.LanguageTag = Thread.CurrentThread.CurrentCulture.Name;
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.InternalMessage))
            {
                userOofSettings.InternalReply.Message     = mailboxAutoReplyConfiguration.InternalMessage;
                userOofSettings.InternalReply.LanguageTag = Thread.CurrentThread.CurrentCulture.Name;
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.StartTime))
            {
                userOofSettings.Duration.StartTime = mailboxAutoReplyConfiguration.StartTime.ToUniversalTime();
            }
            if (mailboxAutoReplyConfiguration.IsModified(MailboxAutoReplyConfigurationSchema.EndTime))
            {
                userOofSettings.Duration.EndTime = mailboxAutoReplyConfiguration.EndTime.ToUniversalTime();
            }
            try
            {
                userOofSettings.Save(base.MailboxSession);
            }
            catch (ObjectExistedException)
            {
                userOofSettings.Save(base.MailboxSession);
            }
        }
        protected override IEnumerable <T> InternalFindPaged <T>(QueryFilter filter, ObjectId rootId, bool deepSearch, SortBy sortBy, int pageSize)
        {
            if (filter != null && !(filter is FalseFilter))
            {
                throw new NotSupportedException("filter");
            }
            if (rootId != null && rootId is ADObjectId && !ADObjectId.Equals((ADObjectId)rootId, base.MailboxSession.MailboxOwner.ObjectId))
            {
                throw new NotSupportedException("rootId");
            }
            if (!typeof(MailboxAutoReplyConfiguration).IsAssignableFrom(typeof(T)))
            {
                throw new NotSupportedException("FindPaged: " + typeof(T).FullName);
            }
            MailboxAutoReplyConfiguration configObject = (MailboxAutoReplyConfiguration)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));

            configObject.MailboxOwnerId = base.MailboxSession.MailboxOwner.ObjectId;
            UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(base.MailboxSession);

            if (userOofSettings == null)
            {
                userOofSettings = UserOofSettings.CreateDefault();
            }
            configObject.AutoReplyState   = userOofSettings.OofState;
            configObject.ExternalAudience = userOofSettings.ExternalAudience;
            configObject.ExternalMessage  = userOofSettings.ExternalReply.Message;
            configObject.InternalMessage  = userOofSettings.InternalReply.Message;
            if (userOofSettings.Duration != null)
            {
                configObject.StartTime = userOofSettings.Duration.StartTime.ToLocalTime();
                configObject.EndTime   = userOofSettings.Duration.EndTime.ToLocalTime();
            }
            yield return((T)((object)configObject));

            yield break;
        }
Exemplo n.º 8
0
        internal void ParseUserOofSettings(UserOofSettings oofSettings, MailTips mailTips, int traceId)
        {
            if (oofSettings.OofState == OofState.Disabled)
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: OutOfOffice is disabled", TraceContext.Get(), mailTips.EmailAddress);
                mailTips.OutOfOfficeMessage = string.Empty;
                return;
            }
            DateTime utcNow = DateTime.UtcNow;

            if (oofSettings.OofState == OofState.Scheduled && (utcNow > oofSettings.EndTime || utcNow < oofSettings.StartTime))
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: OutOfOffice is Scheduled, but we're outside the scheduled interval", TraceContext.Get(), mailTips.EmailAddress);
                mailTips.OutOfOfficeMessage = string.Empty;
                return;
            }
            ReplyBody replyBody;

            if (MailTipsAccessLevel.All != mailTips.Permission.AccessLevel)
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: MailTipsAccessLevel is not All, retrieving external auto reply.", TraceContext.Get(), mailTips.EmailAddress);
                replyBody = oofSettings.ExternalReply;
            }
            else if (this.clientContext is InternalClientContext)
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: InternalClientContext detected, retrieving internal auto reply.", TraceContext.Get(), mailTips.EmailAddress);
                replyBody = oofSettings.InternalReply;
            }
            else
            {
                ExternalClientContext externalClientContext = (ExternalClientContext)this.clientContext;
                if (mailTips.Configuration.Domains.IsInternal(externalClientContext.EmailAddress.Domain))
                {
                    MailTipsLocalQuery.GetMailTipsTracer.TraceDebug((long)traceId, "{0} / {1}: ExternalClientContext detected and caller domain {2} is internal to recipient organization {3}, retrieving internal auto reply.", new object[]
                    {
                        TraceContext.Get(),
                        mailTips.EmailAddress,
                        externalClientContext.EmailAddress.Domain,
                        mailTips.Configuration.OrganizationConfiguration.Configuration.OrganizationId
                    });
                    replyBody = oofSettings.InternalReply;
                }
                else
                {
                    MailTipsLocalQuery.GetMailTipsTracer.TraceDebug((long)traceId, "{0} / {1}: ExternalClientContext detected and caller domain {2} is not internal to recipient organization {3}, retrieving external auto reply.", new object[]
                    {
                        TraceContext.Get(),
                        mailTips.EmailAddress,
                        externalClientContext.EmailAddress.Domain,
                        mailTips.Configuration.OrganizationConfiguration.Configuration.OrganizationId
                    });
                    replyBody = oofSettings.ExternalReply;
                }
            }
            if (replyBody == null || replyBody.RawMessage == null || RuleGenerator.IsEmptyString(replyBody.RawMessage))
            {
                MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress>((long)traceId, "{0} / {1}: OutOfOfficeMessage is null or empty", TraceContext.Get(), mailTips.EmailAddress);
                mailTips.OutOfOfficeMessage = string.Empty;
                return;
            }
            MailTipsLocalQuery.GetMailTipsTracer.TraceDebug <object, EmailAddress, string>((long)traceId, "{0} / {1}: OutOfOffice message has been retrieved: {2}", TraceContext.Get(), mailTips.EmailAddress, replyBody.Message);
            string outOfOfficeMessage = MailTipsUtility.MakeSafeHtml(traceId, replyBody.Message);

            mailTips.OutOfOfficeMessage         = outOfOfficeMessage;
            mailTips.OutOfOfficeMessageLanguage = replyBody.LanguageTag;
            if (oofSettings.OofState == OofState.Scheduled)
            {
                mailTips.OutOfOfficeDuration = oofSettings.Duration;
            }
        }
        // Token: 0x06001B12 RID: 6930 RVA: 0x00066B68 File Offset: 0x00064D68
        public static UserOofSettingsType GetSetting(MailboxSession mailboxSession, ExTimeZone timeZone)
        {
            UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(mailboxSession);

            return(new UserOofSettingsType(userOofSettings, timeZone));
        }
Exemplo n.º 10
0
        // Token: 0x06000D76 RID: 3446 RVA: 0x0004A270 File Offset: 0x00048470
        private void ProcessSet(XmlNode setNode)
        {
            using (Command.CurrentCommand.Context.Tracker.Start(TimeId.OOFSettingsProcessSet))
            {
                AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing Oof - Set");
                UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(this.mailboxSession);
                bool            flag            = false;
                bool            flag2           = false;
                bool            flag3           = false;
                bool            flag4           = false;
                bool            flag5           = false;
                bool            flag6           = false;
                bool            flag7           = false;
                foreach (object obj in setNode.ChildNodes)
                {
                    XmlNode xmlNode = (XmlNode)obj;
                    if (this.status != SettingsBase.ErrorCode.Success)
                    {
                        break;
                    }
                    string localName;
                    if ((localName = xmlNode.LocalName) != null)
                    {
                        if (localName == "OofState")
                        {
                            string innerText = xmlNode.InnerText;
                            string a;
                            if ((a = innerText) != null)
                            {
                                if (a == "0")
                                {
                                    userOofSettings.OofState = OofState.Disabled;
                                    continue;
                                }
                                if (a == "1")
                                {
                                    userOofSettings.OofState = OofState.Enabled;
                                    continue;
                                }
                                if (a == "2")
                                {
                                    userOofSettings.OofState = OofState.Scheduled;
                                    continue;
                                }
                            }
                            this.status = SettingsBase.ErrorCode.ProtocolError;
                            continue;
                        }
                        if (localName == "StartTime")
                        {
                            string innerText2 = xmlNode.InnerText;
                            if (userOofSettings.Duration == null)
                            {
                                userOofSettings.Duration = new Duration((DateTime)ExDateTime.UtcNow, (DateTime)ExDateTime.UtcNow);
                            }
                            userOofSettings.Duration.StartTime = this.DecodeDateTime(innerText2);
                            flag = true;
                            continue;
                        }
                        if (localName == "EndTime")
                        {
                            string innerText3 = xmlNode.InnerText;
                            if (userOofSettings.Duration == null)
                            {
                                userOofSettings.Duration = new Duration((DateTime)ExDateTime.UtcNow, (DateTime)ExDateTime.UtcNow);
                            }
                            userOofSettings.Duration.EndTime = this.DecodeDateTime(innerText3);
                            flag2 = true;
                            continue;
                        }
                        if (localName == "OofMessage")
                        {
                            OofSetting.OofMessage oofMessage;
                            oofMessage.Enabled                  = false;
                            oofMessage.ReplyMessage             = null;
                            oofMessage.BodyType                 = null;
                            oofMessage.AppliesToInternal        = false;
                            oofMessage.AppliesToExternalKnown   = false;
                            oofMessage.AppliesToExternalUnknown = false;
                            foreach (object obj2 in xmlNode.ChildNodes)
                            {
                                XmlNode xmlNode2 = (XmlNode)obj2;
                                if (this.status != SettingsBase.ErrorCode.Success)
                                {
                                    break;
                                }
                                string localName2;
                                switch (localName2 = xmlNode2.LocalName)
                                {
                                case "AppliesToInternal":
                                    if (flag3)
                                    {
                                        this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                        continue;
                                    }
                                    flag3 = true;
                                    oofMessage.AppliesToInternal = true;
                                    continue;

                                case "AppliesToExternalKnown":
                                    if (flag4)
                                    {
                                        this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                        continue;
                                    }
                                    oofMessage.AppliesToExternalKnown = true;
                                    continue;

                                case "AppliesToExternalUnknown":
                                    if (flag6)
                                    {
                                        this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                        continue;
                                    }
                                    oofMessage.AppliesToExternalUnknown = true;
                                    continue;

                                case "Enabled":
                                    if (xmlNode2.InnerText.Equals("1", StringComparison.OrdinalIgnoreCase))
                                    {
                                        oofMessage.Enabled = true;
                                        continue;
                                    }
                                    continue;

                                case "ReplyMessage":
                                    oofMessage.ReplyMessage = xmlNode2.InnerText;
                                    continue;

                                case "BodyType":
                                    oofMessage.BodyType = xmlNode2.InnerText;
                                    continue;
                                }
                                this.status = SettingsBase.ErrorCode.ProtocolError;
                            }
                            if (this.status != SettingsBase.ErrorCode.Success)
                            {
                                continue;
                            }
                            if (oofMessage.ReplyMessage != null)
                            {
                                if (oofMessage.BodyType == null)
                                {
                                    this.status = SettingsBase.ErrorCode.ProtocolError;
                                    continue;
                                }
                                if (oofMessage.BodyType.Equals("TEXT", StringComparison.OrdinalIgnoreCase))
                                {
                                    oofMessage.ReplyMessage = OofSetting.InternalTextToHtml(oofMessage.ReplyMessage);
                                    oofMessage.BodyType     = "HTML";
                                }
                                if (!oofMessage.BodyType.Equals("HTML", StringComparison.OrdinalIgnoreCase))
                                {
                                    this.status = SettingsBase.ErrorCode.InvalidArguments;
                                    continue;
                                }
                            }
                            if (oofMessage.AppliesToInternal)
                            {
                                if (oofMessage.Enabled)
                                {
                                    userOofSettings.InternalReply.Message = oofMessage.ReplyMessage;
                                }
                                else
                                {
                                    userOofSettings.InternalReply.Message = string.Empty;
                                }
                            }
                            if (oofMessage.AppliesToExternalKnown && oofMessage.AppliesToExternalUnknown)
                            {
                                if (flag4 || flag6)
                                {
                                    this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                    continue;
                                }
                                if (oofMessage.Enabled)
                                {
                                    userOofSettings.ExternalReply.Message = oofMessage.ReplyMessage;
                                    userOofSettings.ExternalAudience      = ExternalAudience.All;
                                    flag5 = true;
                                    flag7 = true;
                                    flag4 = true;
                                    flag6 = true;
                                    continue;
                                }
                                userOofSettings.ExternalReply.Message = string.Empty;
                                userOofSettings.ExternalAudience      = ExternalAudience.None;
                                flag4 = true;
                                flag6 = true;
                                continue;
                            }
                            else if (oofMessage.AppliesToExternalKnown)
                            {
                                if (oofMessage.Enabled)
                                {
                                    if (flag6)
                                    {
                                        if (!string.Equals(oofMessage.ReplyMessage, userOofSettings.ExternalReply.Message, StringComparison.Ordinal))
                                        {
                                            this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                            continue;
                                        }
                                        userOofSettings.ExternalAudience = ExternalAudience.All;
                                    }
                                    else
                                    {
                                        userOofSettings.ExternalReply.Message = oofMessage.ReplyMessage;
                                        userOofSettings.ExternalAudience      = ExternalAudience.Known;
                                    }
                                    flag5 = true;
                                    flag4 = true;
                                    continue;
                                }
                                if (flag6 && flag7)
                                {
                                    this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                    continue;
                                }
                                userOofSettings.ExternalAudience = ExternalAudience.None;
                                flag4 = true;
                                continue;
                            }
                            else
                            {
                                if (!oofMessage.AppliesToExternalUnknown)
                                {
                                    continue;
                                }
                                if (oofMessage.Enabled)
                                {
                                    if (flag4)
                                    {
                                        if (!string.Equals(oofMessage.ReplyMessage, userOofSettings.ExternalReply.Message, StringComparison.Ordinal))
                                        {
                                            this.status = SettingsBase.ErrorCode.ConflictingArguments;
                                            continue;
                                        }
                                        userOofSettings.ExternalAudience = ExternalAudience.All;
                                    }
                                    else
                                    {
                                        userOofSettings.ExternalReply.Message = oofMessage.ReplyMessage;
                                        userOofSettings.ExternalAudience      = ExternalAudience.All;
                                    }
                                    flag7 = true;
                                    flag6 = true;
                                    continue;
                                }
                                if (flag4 && flag5)
                                {
                                    userOofSettings.ExternalAudience = ExternalAudience.Known;
                                }
                                else
                                {
                                    userOofSettings.ExternalAudience = ExternalAudience.None;
                                }
                                flag6 = true;
                                continue;
                            }
                        }
                    }
                    this.status = SettingsBase.ErrorCode.ProtocolError;
                }
                if (this.status == SettingsBase.ErrorCode.Success && (flag ^ flag2))
                {
                    this.status = SettingsBase.ErrorCode.ProtocolError;
                }
                if (this.status == SettingsBase.ErrorCode.Success && userOofSettings.OofState == OofState.Scheduled && (userOofSettings.Duration == null || userOofSettings.Duration.EndTime <= userOofSettings.Duration.StartTime || userOofSettings.Duration.EndTime <= DateTime.UtcNow))
                {
                    this.status = SettingsBase.ErrorCode.ConflictingArguments;
                }
                if (this.status == SettingsBase.ErrorCode.Success)
                {
                    userOofSettings.Save(this.mailboxSession);
                    AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing Oof - Set.");
                }
            }
        }
Exemplo n.º 11
0
 // Token: 0x06000D75 RID: 3445 RVA: 0x00049D24 File Offset: 0x00047F24
 private void ProcessGet(XmlNode getNode)
 {
     using (Command.CurrentCommand.Context.Tracker.Start(TimeId.OOFSettingsProcessGet))
     {
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Processing Oof - Get");
         XmlNode firstChild = getNode.FirstChild;
         string  innerText  = firstChild.InnerText;
         bool    flag;
         if (string.Equals(innerText, "html", StringComparison.OrdinalIgnoreCase))
         {
             flag = true;
         }
         else
         {
             if (!string.Equals(innerText, "text", StringComparison.OrdinalIgnoreCase))
             {
                 this.status = SettingsBase.ErrorCode.ProtocolError;
                 return;
             }
             flag = false;
         }
         XmlNode         xmlNode         = base.Response.OwnerDocument.CreateElement("Get", "Settings:");
         XmlNode         xmlNode2        = base.Response.OwnerDocument.CreateElement("OofState", "Settings:");
         XmlNode         xmlNode3        = base.Response.OwnerDocument.CreateElement("StartTime", "Settings:");
         XmlNode         xmlNode4        = base.Response.OwnerDocument.CreateElement("EndTime", "Settings:");
         XmlNode         xmlNode5        = base.Response.OwnerDocument.CreateElement("OofMessage", "Settings:");
         XmlNode         newChild        = base.Response.OwnerDocument.CreateElement("AppliesToInternal", "Settings:");
         XmlNode         xmlNode6        = base.Response.OwnerDocument.CreateElement("ReplyMessage", "Settings:");
         XmlNode         xmlNode7        = base.Response.OwnerDocument.CreateElement("Enabled", "Settings:");
         XmlNode         xmlNode8        = base.Response.OwnerDocument.CreateElement("BodyType", "Settings:");
         XmlNode         xmlNode9        = base.Response.OwnerDocument.CreateElement("OofMessage", "Settings:");
         XmlNode         newChild2       = base.Response.OwnerDocument.CreateElement("AppliesToExternalKnown", "Settings:");
         XmlNode         xmlNode10       = base.Response.OwnerDocument.CreateElement("ReplyMessage", "Settings:");
         XmlNode         xmlNode11       = base.Response.OwnerDocument.CreateElement("Enabled", "Settings:");
         XmlNode         xmlNode12       = base.Response.OwnerDocument.CreateElement("BodyType", "Settings:");
         XmlNode         xmlNode13       = base.Response.OwnerDocument.CreateElement("OofMessage", "Settings:");
         XmlNode         newChild3       = base.Response.OwnerDocument.CreateElement("AppliesToExternalUnknown", "Settings:");
         XmlNode         xmlNode14       = base.Response.OwnerDocument.CreateElement("ReplyMessage", "Settings:");
         XmlNode         xmlNode15       = base.Response.OwnerDocument.CreateElement("Enabled", "Settings:");
         XmlNode         xmlNode16       = base.Response.OwnerDocument.CreateElement("BodyType", "Settings:");
         UserOofSettings userOofSettings = UserOofSettings.GetUserOofSettings(this.mailboxSession);
         xmlNode.AppendChild(xmlNode2);
         xmlNode2.InnerText = ((int)userOofSettings.OofState).ToString(CultureInfo.InvariantCulture);
         if (userOofSettings.Duration != null && !userOofSettings.SetByLegacyClient)
         {
             xmlNode.AppendChild(xmlNode3);
             xmlNode.AppendChild(xmlNode4);
             xmlNode3.InnerText = OofSetting.EncodeDateTime(userOofSettings.Duration.StartTime);
             xmlNode4.InnerText = OofSetting.EncodeDateTime(userOofSettings.Duration.EndTime);
         }
         xmlNode.AppendChild(xmlNode5);
         xmlNode5.AppendChild(newChild);
         xmlNode5.AppendChild(xmlNode7);
         string message = userOofSettings.InternalReply.Message;
         if (!string.IsNullOrEmpty(message))
         {
             xmlNode7.InnerText = "1";
             xmlNode5.AppendChild(xmlNode6);
             xmlNode5.AppendChild(xmlNode8);
             if (flag)
             {
                 xmlNode6.InnerText = message;
                 xmlNode8.InnerText = "HTML";
             }
             else
             {
                 xmlNode6.InnerText = OofSetting.InternalHtmlToText(message);
                 xmlNode8.InnerText = "TEXT";
             }
         }
         else
         {
             xmlNode7.InnerText = "0";
         }
         xmlNode.AppendChild(xmlNode9);
         string message2 = userOofSettings.ExternalReply.Message;
         if (!string.IsNullOrEmpty(message2))
         {
             xmlNode9.AppendChild(newChild2);
             xmlNode9.AppendChild(xmlNode11);
             xmlNode9.AppendChild(xmlNode10);
             xmlNode9.AppendChild(xmlNode12);
             if (userOofSettings.ExternalAudience != ExternalAudience.None)
             {
                 xmlNode11.InnerText = "1";
             }
             else
             {
                 xmlNode11.InnerText = "0";
             }
             if (flag)
             {
                 xmlNode10.InnerText = message2;
                 xmlNode12.InnerText = "HTML";
             }
             else
             {
                 xmlNode10.InnerText = OofSetting.InternalHtmlToText(message2);
                 xmlNode12.InnerText = "TEXT";
             }
         }
         else
         {
             xmlNode9.AppendChild(newChild2);
             xmlNode9.AppendChild(xmlNode11);
             xmlNode11.InnerText = "0";
         }
         xmlNode.AppendChild(xmlNode13);
         if (!string.IsNullOrEmpty(message2))
         {
             xmlNode13.AppendChild(newChild3);
             xmlNode13.AppendChild(xmlNode15);
             xmlNode13.AppendChild(xmlNode14);
             xmlNode13.AppendChild(xmlNode16);
             if (userOofSettings.ExternalAudience == ExternalAudience.All)
             {
                 xmlNode15.InnerText = "1";
             }
             else
             {
                 xmlNode15.InnerText = "0";
             }
             xmlNode14.InnerText = xmlNode10.InnerText;
             xmlNode16.InnerText = xmlNode12.InnerText;
         }
         else
         {
             xmlNode13.AppendChild(newChild3);
             xmlNode13.AppendChild(xmlNode15);
             xmlNode15.InnerText = "0";
         }
         this.verbResponseNodes.Add(xmlNode);
         AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Done processing Oof - Get.");
     }
 }
Exemplo n.º 12
0
        /// <summary>
        /// Set user mailbox Out of Office state.
        /// </summary>
        /// <param name="mailAddress">User's email address.</param>
        /// <param name="password">Password of user mailbox.</param>
        /// <param name="isOOF">If true, set OOF state, else make sure OOF state is not set (clear OOF state).</param>
        /// <returns>If the operation succeed then return true, otherwise return false.</returns>
        public bool SetUserOOFSettings(string mailAddress, string password, bool isOOF)
        {
            using (ExchangeServiceBinding service = new ExchangeServiceBinding())
            {
                service.Url = Common.GetConfigurationPropertyValue(Constants.SetOOFWebServiceURL, this.Site);
                if (service.Url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
                {
                    this.AcceptServerCertificate();
                }

                service.Credentials = new System.Net.NetworkCredential(mailAddress, password);

                EmailAddress emailAddress = new EmailAddress
                {
                    Address = mailAddress, Name = string.Empty
                };
                UserOofSettings userSettings = new UserOofSettings
                {
                    // Identify the external audience.
                    ExternalAudience = ExternalAudience.Known
                };

                // Create the OOF reply messages.
                ReplyBody replyBody = new ReplyBody
                {
                    Message = Constants.MessageOfOOFReply
                };

                userSettings.ExternalReply = replyBody;
                userSettings.InternalReply = replyBody;

                // Set OOF state.
                if (isOOF)
                {
                    userSettings.OofState = OofState.Enabled;
                }
                else
                {
                    userSettings.OofState = OofState.Disabled;
                }

                // Create the request.
                SetUserOofSettingsRequest request = new SetUserOofSettingsRequest
                {
                    Mailbox         = emailAddress,
                    UserOofSettings = userSettings
                };

                bool success = false;

                try
                {
                    SetUserOofSettingsResponse response = service.SetUserOofSettings(request);
                    if (response.ResponseMessage.ResponseCode == ResponseCodeType.NoError)
                    {
                        success = true;
                    }
                }
                catch (System.Xml.Schema.XmlSchemaValidationException e)
                {
                    // Catch the following critical exceptions, other unexpected exceptions will be emitted to protocol test framework.
                    Site.Log.Add(LogEntryKind.Debug, "An XML schema exception happened. The exception type is {0}.\n The exception message is {1}.", e.GetType().ToString(), e.Message);
                }
                catch (System.Xml.XmlException e)
                {
                    Site.Log.Add(LogEntryKind.Debug, "An XML schema exception happened. The exception type is {0}.\n The exception message is {1}.", e.GetType().ToString(), e.Message);
                }
                catch (System.Reflection.TargetException e)
                {
                    Site.Log.Add(LogEntryKind.Debug, "An operation exception happened when invoke Soap operation. The exception type is {0}.\n The exception message is {1}.", e.GetType().ToString(), e.Message);
                    throw;
                }
                catch (System.IO.IOException e)
                {
                    Site.Log.Add(LogEntryKind.Debug, "An IO exception happened when invoke Soap operation. The exception type is {0}.\n The exception message is {1}.", e.GetType().ToString(), e.Message);
                    throw;
                }

                return(success);
            }
        }
Exemplo n.º 13
0
        private void CommitAndLoad()
        {
            this.oofSettings = UserOofSettings.GetUserOofSettings(this.userContext.MailboxSession);
            this.Load();
            bool flag = false;

            if (Utilities.IsPostRequest(this.request) && !string.IsNullOrEmpty(base.Command))
            {
                string formParameter = Utilities.GetFormParameter(this.request, "rdoOof", false);
                if (!string.IsNullOrEmpty(formParameter))
                {
                    bool flag2 = formParameter == 1.ToString();
                    bool flag3 = Utilities.GetFormParameter(this.request, "chkTmd", false) != null;
                    if (!flag2)
                    {
                        if (this.oofSettings.OofState != OofState.Disabled)
                        {
                            this.oofSettings.OofState = OofState.Disabled;
                            flag = true;
                        }
                    }
                    else if (flag3)
                    {
                        if (this.oofSettings.OofState != OofState.Scheduled)
                        {
                            this.oofSettings.OofState = OofState.Scheduled;
                            flag = true;
                        }
                        string formParameter2 = Utilities.GetFormParameter(this.request, "selSM", false);
                        string formParameter3 = Utilities.GetFormParameter(this.request, "selSD", false);
                        string formParameter4 = Utilities.GetFormParameter(this.request, "selSY", false);
                        string formParameter5 = Utilities.GetFormParameter(this.request, "selST", false);
                        string formParameter6 = Utilities.GetFormParameter(this.request, "selEM", false);
                        string formParameter7 = Utilities.GetFormParameter(this.request, "selED", false);
                        string formParameter8 = Utilities.GetFormParameter(this.request, "selEY", false);
                        string formParameter9 = Utilities.GetFormParameter(this.request, "selET", false);
                        if (string.IsNullOrEmpty(formParameter2) || string.IsNullOrEmpty(formParameter3) || string.IsNullOrEmpty(formParameter4) || string.IsNullOrEmpty(formParameter5) || string.IsNullOrEmpty(formParameter6) || string.IsNullOrEmpty(formParameter7) || string.IsNullOrEmpty(formParameter8) || string.IsNullOrEmpty(formParameter9))
                        {
                            base.SetInfobarMessage(string.Format(LocalizedStrings.GetNonEncoded(1140546334), this.userContext.UserOptions.DateFormat), InfobarMessageType.Error);
                            return;
                        }
                        int num = int.Parse(formParameter3);
                        if (num > ExDateTime.DaysInMonth(int.Parse(formParameter4), int.Parse(formParameter2)))
                        {
                            num = ExDateTime.DaysInMonth(int.Parse(formParameter4), int.Parse(formParameter2));
                        }
                        ExDateTime t = new ExDateTime(this.userContext.TimeZone, int.Parse(formParameter4), int.Parse(formParameter2), num);
                        num = int.Parse(formParameter7);
                        if (num > ExDateTime.DaysInMonth(int.Parse(formParameter8), int.Parse(formParameter6)))
                        {
                            num = ExDateTime.DaysInMonth(int.Parse(formParameter8), int.Parse(formParameter6));
                        }
                        ExDateTime t2 = new ExDateTime(this.userContext.TimeZone, int.Parse(formParameter8), int.Parse(formParameter6), num);
                        t  = t.AddHours((double)int.Parse(formParameter5));
                        t2 = t2.AddHours((double)int.Parse(formParameter9));
                        if (t > t2)
                        {
                            base.SetInfobarMessage(LocalizedStrings.GetNonEncoded(107113300), InfobarMessageType.Error);
                            this.isInvalidDuration = true;
                        }
                        if (this.oofSettings.Duration == null)
                        {
                            this.oofSettings.Duration = new Duration();
                        }
                        if (this.oofSettings.Duration.StartTime != (DateTime)t.ToUtc())
                        {
                            this.oofSettings.Duration.StartTime = (DateTime)t.ToUtc();
                            flag = true;
                        }
                        if (this.oofSettings.Duration.EndTime != (DateTime)t2.ToUtc())
                        {
                            this.oofSettings.Duration.EndTime = (DateTime)t2.ToUtc();
                            flag = true;
                        }
                    }
                    else if (this.oofSettings.OofState != OofState.Enabled)
                    {
                        this.oofSettings.OofState = OofState.Enabled;
                        flag = true;
                    }
                    string formParameter10 = Utilities.GetFormParameter(this.request, "txtInt", false);
                    string formParameter11 = Utilities.GetFormParameter(this.request, "chkInt", false);
                    if (((formParameter11 == null && string.IsNullOrEmpty(this.oofToInternal)) || !string.IsNullOrEmpty(formParameter11)) && !Utilities.WhiteSpaceOnlyOrNullEmpty(formParameter10))
                    {
                        this.oofSettings.InternalReply.Message = BodyConversionUtilities.ConvertTextToHtml(formParameter10);
                        flag = true;
                    }
                    string formParameter12 = Utilities.GetFormParameter(this.request, "txtExt", false);
                    string formParameter13 = Utilities.GetFormParameter(this.request, "chkExt", false);
                    if (((formParameter13 == null && string.IsNullOrEmpty(this.oofToExternal)) || !string.IsNullOrEmpty(formParameter13)) && !Utilities.WhiteSpaceOnlyOrNullEmpty(formParameter12))
                    {
                        this.oofSettings.ExternalReply.Message = BodyConversionUtilities.ConvertTextToHtml(formParameter12);
                        flag = true;
                    }
                    if (Utilities.GetFormParameter(this.request, "chkExtSnd", false) != null)
                    {
                        string formParameter14 = Utilities.GetFormParameter(this.request, "rdoAll", false);
                        if (!string.IsNullOrEmpty(formParameter14))
                        {
                            if (formParameter14 == 3.ToString())
                            {
                                if (this.oofSettings.ExternalAudience != ExternalAudience.All)
                                {
                                    this.oofSettings.ExternalAudience = ExternalAudience.All;
                                    flag = true;
                                }
                            }
                            else if (this.oofSettings.ExternalAudience != ExternalAudience.Known)
                            {
                                this.oofSettings.ExternalAudience = ExternalAudience.Known;
                                flag = true;
                            }
                        }
                    }
                    else if (this.oofSettings.ExternalAudience != ExternalAudience.None)
                    {
                        this.oofSettings.ExternalAudience = ExternalAudience.None;
                        flag = true;
                    }
                    if (flag)
                    {
                        try
                        {
                            this.oofSettings.Save(this.userContext.MailboxSession);
                            base.SetSavedSuccessfully(true);
                        }
                        catch (InvalidScheduledOofDuration)
                        {
                            base.SetInfobarMessage(LocalizedStrings.GetNonEncoded(-561991348), InfobarMessageType.Error);
                            this.isInvalidDuration = true;
                        }
                        this.Load();
                    }
                }
            }
        }