Пример #1
0
        public static ApprovalRequestUpdater.Result TryUpdateExistingApprovalRequest(MessageItem updateMessage)
        {
            updateMessage.Load(ApprovalRequestUpdater.ApprovalRequestUpdateProperties);
            int?       valueAsNullable  = updateMessage.GetValueAsNullable <int>(MessageItemSchema.ApprovalDecision);
            string     valueOrDefault   = updateMessage.GetValueOrDefault <string>(MessageItemSchema.ApprovalDecisionMaker);
            string     valueOrDefault2  = updateMessage.GetValueOrDefault <string>(MessageItemSchema.ApprovalRequestMessageId);
            ExDateTime?valueAsNullable2 = updateMessage.GetValueAsNullable <ExDateTime>(MessageItemSchema.ApprovalDecisionTime);

            if (valueAsNullable == null)
            {
                ApprovalRequestUpdater.diag.TraceDebug(0L, "Invalid update becasue there's no decision.");
                return(ApprovalRequestUpdater.Result.InvalidUpdateMessage);
            }
            if (!ApprovalRequestUpdater.IsDecisionExpiry(valueAsNullable.Value) && string.IsNullOrEmpty(valueOrDefault))
            {
                ApprovalRequestUpdater.diag.TraceDebug(0L, "Invalid update becasue there's no decisionMaker");
                return(ApprovalRequestUpdater.Result.InvalidUpdateMessage);
            }
            if (string.IsNullOrEmpty(valueOrDefault2))
            {
                ApprovalRequestUpdater.diag.TraceDebug(0L, "Invalid update becasue there's no messageId");
                return(ApprovalRequestUpdater.Result.InvalidUpdateMessage);
            }
            if (valueAsNullable2 == null)
            {
                ApprovalRequestUpdater.diag.TraceDebug(0L, "Invalid update becasue there's no decisionTime");
                return(ApprovalRequestUpdater.Result.InvalidUpdateMessage);
            }
            return(ApprovalRequestUpdater.FindAndUpdateExistingApprovalRequest(updateMessage, valueAsNullable.Value, valueOrDefault, valueAsNullable2.Value, valueOrDefault2));
        }
Пример #2
0
 private static bool VerifyAndUpdateApprovalRequest(MailboxSession session, Participant updateMessageSender, int decision, string decisionMaker, ExDateTime decisionTime, MessageItem approvalRequest)
 {
     if (!object.Equals("IPM.Note.Microsoft.Approval.Request", approvalRequest.ClassName))
     {
         ApprovalRequestUpdater.diag.TraceDebug(0L, "not a approval request, ignore.");
         return(false);
     }
     if (!Participant.HasSameEmail(updateMessageSender, approvalRequest.Sender))
     {
         ApprovalRequestUpdater.diag.TraceDebug(0L, "not the same sender, ignore.");
         return(false);
     }
     approvalRequest.OpenAsReadWrite();
     if (ApprovalRequestUpdater.IsDecisionExpiry(decision))
     {
         approvalRequest[MessageItemSchema.ExpiryTime] = decisionTime;
     }
     else
     {
         approvalRequest[MessageItemSchema.ApprovalDecision]      = decision;
         approvalRequest[MessageItemSchema.ApprovalDecisionMaker] = decisionMaker;
         approvalRequest[MessageItemSchema.ApprovalDecisionTime]  = decisionTime;
     }
     return(true);
 }