public RejectedViewModel(Rejected model, Repository repository) { this._model = model; this._repository = repository; IsEdit = true; this._purchased = model.Record; }
private void VerificationForm_FormClosing(object sender, FormClosingEventArgs e) { if (!doneConfirm) { Rejected.Invoke(); } }
void SendSync(Message message, int waitMilliseconds) { ManualResetEvent acked = new ManualResetEvent(false); Outcome outcome = null; OutcomeCallback callback = (l, m, o, s) => { outcome = o; acked.Set(); }; this.SendInternal(message, this.GetTxnState(), callback, acked, true); bool signaled = acked.WaitOne(waitMilliseconds); if (!signaled) { this.OnTimeout(message); throw new TimeoutException(Fx.Format(SRAmqp.AmqpTimeout, "send", waitMilliseconds, "message")); } if (outcome != null) { if (outcome.Descriptor.Code == Codec.Released.Code) { Released released = (Released)outcome; throw new AmqpException(ErrorCode.MessageReleased, null); } else if (outcome.Descriptor.Code == Codec.Rejected.Code) { Rejected rejected = (Rejected)outcome; throw new AmqpException(rejected.Error); } } }
protected override async Task OnSendAsync(IEnumerable <BrokeredMessage> brokeredMessages) { TimeoutHelper timeoutHelper = new TimeoutHelper(this.OperationTimeout, true); using (AmqpMessage amqpMessage = AmqpMessageConverter.BrokeredMessagesToAmqpMessage(brokeredMessages, true)) { SendingAmqpLink amqpLink = await this.SendLinkManager.GetOrCreateAsync(timeoutHelper.RemainingTime()).ConfigureAwait(false); if (amqpLink.Settings.MaxMessageSize.HasValue) { ulong size = (ulong)amqpMessage.SerializedMessageSize; if (size > amqpLink.Settings.MaxMessageSize.Value) { // TODO: Add MessageSizeExceededException throw new NotImplementedException("MessageSizeExceededException: " + Resources.AmqpMessageSizeExceeded.FormatForUser(amqpMessage.DeliveryId.Value, size, amqpLink.Settings.MaxMessageSize.Value)); ////throw Fx.Exception.AsError(new MessageSizeExceededException( ////Resources.AmqpMessageSizeExceeded.FormatForUser(amqpMessage.DeliveryId.Value, size, amqpLink.Settings.MaxMessageSize.Value))); } } Outcome outcome = await amqpLink.SendMessageAsync(amqpMessage, this.GetNextDeliveryTag(), AmqpConstants.NullBinary, timeoutHelper.RemainingTime()).ConfigureAwait(false); if (outcome.DescriptorCode != Accepted.Code) { Rejected rejected = (Rejected)outcome; throw Fx.Exception.AsError(AmqpExceptionHelper.ToMessagingContract(rejected.Error)); } } }
static AmqpConstants() { AmqpConstants.BatchedMessageFormat = "com.microsoft:batched-message-format"; AmqpConstants.SimpleWebTokenPropertyName = "com.microsoft:swt"; AmqpConstants.ContainerId = "container-id"; AmqpConstants.ConnectionId = "connection-id"; AmqpConstants.LinkName = "link-name"; AmqpConstants.ClientMaxFrameSize = "client-max-frame-size"; AmqpConstants.HostName = "hostname"; AmqpConstants.NetworkHost = "network-host"; AmqpConstants.Port = "port"; AmqpConstants.Address = "address"; AmqpConstants.PublisherId = "publisher-id"; AmqpConstants.NullBinary = new ArraySegment <byte>(); AmqpConstants.EmptyBinary = new ArraySegment <byte>(new byte[0]); AmqpConstants.DefaultProtocolVersion = new AmqpVersion(1, 0, 0); DateTime dateTime = DateTime.Parse("1970-01-01T00:00:00.0000000Z", CultureInfo.InvariantCulture); AmqpConstants.StartOfEpoch = dateTime.ToUniversalTime(); DateTime maxValue = DateTime.MaxValue; AmqpConstants.MaxAbsoluteExpiryTime = maxValue.ToUniversalTime() - TimeSpan.FromDays(1); AmqpConstants.AcceptedOutcome = new Accepted(); AmqpConstants.ReleasedOutcome = new Released(); AmqpConstants.RejectedOutcome = new Rejected(); AmqpConstants.RejectedNotFoundOutcome = new Rejected() { Error = AmqpError.NotFound }; }
public static void ReleaseAll(Delivery delivery, Error error) { Outcome outcome; if (error == null) { outcome = new Released(); } else { outcome = new Rejected() { Error = error }; } while (delivery != null) { if (delivery.OnOutcome != null) { delivery.OnOutcome(delivery.Message, outcome, delivery.UserToken); } delivery.Buffer.ReleaseReference(); delivery = (Delivery)delivery.Next; } }
static void DispatchRequest(ListenerLink link, Message message, DeliveryState deliveryState, object state) { RequestProcessor thisPtr = (RequestProcessor)state; ListenerLink responseLink = null; if (message.Properties != null || message.Properties.ReplyTo != null) { thisPtr.responseLinks.TryGetValue(message.Properties.ReplyTo, out responseLink); } Outcome outcome; if (responseLink == null) { outcome = new Rejected() { Error = new Error() { Condition = ErrorCode.NotFound, Description = "Not response link was found. Ensure the link is attached or reply-to is set on the request." } }; } else { outcome = new Accepted(); } link.DisposeMessage(message, outcome, true); RequestContext context = new RequestContext(link, responseLink, message); thisPtr.processor.Process(context); }
private void SendSync(global::Amqp.Message message, DeliveryState deliveryState) { ManualResetEvent manualResetEvent = new ManualResetEvent(false); Outcome outcome = null; senderLink.Send(message, deliveryState, Callback, manualResetEvent); if (!manualResetEvent.WaitOne((int)session.Connection.Provider.SendTimeout)) { throw new TimeoutException(Fx.Format(SRAmqp.AmqpTimeout, "send", session.Connection.Provider.SendTimeout, nameof(message))); } if (outcome == null) { return; } if (outcome.Descriptor.Name.Equals(MessageSupport.RELEASED_INSTANCE.Descriptor.Name)) { Error error = new Error(ErrorCode.MessageReleased); throw ExceptionSupport.GetException(error, $"Message {message.Properties.GetMessageId()} released"); } if (outcome.Descriptor.Name.Equals(MessageSupport.REJECTED_INSTANCE.Descriptor.Name)) { Rejected rejected = (Rejected)outcome; throw ExceptionSupport.GetException(rejected.Error, $"Message {message.Properties.GetMessageId()} rejected"); } void Callback(ILink l, global::Amqp.Message m, Outcome o, object s) { outcome = o; manualResetEvent.Set(); } }
void ThrowIfRejected(DeliveryState deliveryState) { if (deliveryState.DescriptorCode == Rejected.Code) { Rejected rejected = (Rejected)deliveryState; throw AmqpException.FromError(rejected.Error); } }
public void RejectMessage(AmqpMessage message, Exception exception) { Rejected rejected = new Rejected(); rejected.Error = Error.FromException(exception); this.DisposeMessage(message, rejected, true, false); }
public void GetRetryFromRejectedReturnsNullIfNoError() { var rejected = new Rejected(); TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, s_defaultInterval); Assert.IsNull(actual); }
public ActionResult Rejected(int SHId, int studentId) { Rejected item = new Rejected(); item.StudentID = studentId; item.SHomeID = SHId; return(View(item)); }
public string AllValuesAsString() { string participants = string.Join(",", (Participants?.Select(x => string.Concat(x.Key.ToString(), String.Join("|", x.Value?.Select(v => v.AllValuesAsString()).ToList() ?? new List <string>()))).ToList() ?? new List <string>())); string rejected = string.Join(",", (Rejected?.Select(x => x.UsernameOrName()).ToList() ?? new List <string>())); string maybe = string.Join(",", (Maybe?.Select(x => x.UsernameOrName()).ToList() ?? new List <string>())); string done = string.Join(",", (Done?.Select(x => x.UsernameOrName()).ToList() ?? new List <string>())); return($"{UniqueID};{PublicID};{Raid?.AllValuesAsString()};{participants};{rejected};{done};{maybe};{IsPublished};{LastModificationTime}"); }
internal protected sealed override bool Process(ConversationMessage message) { switch (State) { case RequesterState.RequestRecovering: if (message is ConversationRecoverAgreedMessage) { //对方同意恢复会话。 State = RequesterState.Running; OnRecoverAgreed(message as ConversationRecoverAgreedMessage); RecoverAgreed?.Invoke(); } else if (message is ConversationRejectMessage) { var rm = message as ConversationRejectMessage; State = RequesterState.Rejected; End(); OnRecoverRejected(rm); RecoverRejected?.Invoke(rm.RejectCode); } else { //对方再ConversationAgree或者Reject之前发来的消息,到底要不要处理?怎样才能保证对方不在我准备好之前发消息过来? //其他消息,不理会。 OnMessageReceived(message); } break; case RequesterState.RequestStarting: if (message is ConversationAgreeMessage) { WasAgreed = true; State = RequesterState.Running; Agreed?.Invoke(); OnAgreed(); } else if (message is ConversationRejectMessage) { State = RequesterState.Rejected; //终止此会话 End(); Rejected?.Invoke(); } else { //对方再ConversationAgree或者Reject之前发来的消息,到底要不要处理?怎样才能保证对方不在我准备好之前发消息过来? //其他消息,不理会。 OnMessageReceived(message); } break; case RequesterState.Running: OnMessageReceived(message); break; } return(true); }
protected override IEnumerator <IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .AsyncStep> GetAsyncSteps() { try { this.amqpMessage = this.CreateAmqpMessage(); } catch (Exception exception) { base.Complete(exception); goto Label0; } if (!this.parent.sendLink.TryGetOpenedObject(out this.amqpLink)) { AmqpMessageSender.SendAsyncResult sendAsyncResult = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.parent.sendLink.BeginGetInstance(t, c, s); yield return(sendAsyncResult.CallAsync(beginCall, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.amqpLink = thisPtr.parent.sendLink.EndGetInstance(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException == null) { goto Label1; } base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.parent.messagingFactory.RemoteContainerId)); goto Label0; } Label1: if (this.amqpLink.Settings.MaxMessageSize.HasValue) { ulong serializedMessageSize = (ulong)this.amqpMessage.SerializedMessageSize; if (serializedMessageSize <= Convert.ToUInt64(this.amqpLink.Settings.MaxMessageSize)) { goto Label2; } AmqpMessageSender.SendAsyncResult sendAsyncResult1 = this; object value = this.amqpMessage.DeliveryId.Value; object obj = serializedMessageSize; ulong? maxMessageSize = this.amqpLink.Settings.MaxMessageSize; sendAsyncResult1.Complete(new MessageSizeExceededException(SRAmqp.AmqpMessageSizeExceeded(value, obj, maxMessageSize.Value))); goto Label0; } Label2: AmqpMessageSender.SendAsyncResult sendAsyncResult2 = this; IteratorAsyncResult <AmqpMessageSender.SendAsyncResult> .BeginCall beginCall1 = (AmqpMessageSender.SendAsyncResult thisPtr, TimeSpan t, AsyncCallback c, object s) => thisPtr.amqpLink.BeginSendMessage(thisPtr.amqpMessage, thisPtr.parent.GetDeliveryTag(), AmqpConstants.NullBinary, t, c, s); yield return(sendAsyncResult2.CallAsync(beginCall1, (AmqpMessageSender.SendAsyncResult thisPtr, IAsyncResult r) => thisPtr.outcome = thisPtr.amqpLink.EndSendMessage(r), IteratorAsyncResult <TIteratorAsyncResult> .ExceptionPolicy.Continue)); if (base.LastAsyncStepException != null) { base.Complete(ExceptionHelper.GetClientException(base.LastAsyncStepException, this.amqpLink.GetTrackingId())); } else if (this.outcome.DescriptorCode == Rejected.Code) { Rejected rejected = (Rejected)this.outcome; base.Complete(ExceptionHelper.ToMessagingContract(rejected.Error)); } Label0: yield break; }
public void GetRetryFromRejectedReturnsNullIfNoErrorInfoEntries() { Rejected rejected = new Rejected(); rejected.Error = new Error(); rejected.Error.Info = new Fields(); TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, defaultInterval); Assert.IsNull(actual); }
public void Process_SetsProcessedAndStateProperties() { var state = new Rejected(); var delivery = new Delivery(new Amqp.Message()); delivery.Process(state); delivery.ShouldSatisfyAllConditions( () => delivery.Processed.ShouldNotBeNull(), () => delivery.State.ShouldBeSameAs(state) ); }
private void RejectAll() { if (isOutermost) { rejected = true; reject(this); Rejected?.Invoke(this, Subject); } else { outer.RejectAll(); } }
public void Start() { if (!this.link.DisposeDelivery(this.deliveryTag, false, this.outcome, this.batchable)) { WorkCollection <ArraySegment <byte>, ReceivingAmqpLink.DisposeAsyncResult, Outcome> workCollection = this.link.pendingDispositions; ArraySegment <byte> nums = this.deliveryTag; Rejected rejected = new Rejected() { Error = AmqpError.NotFound }; workCollection.CompleteWork(nums, true, rejected); } }
void OnMessage(AmqpMessage message) { Outcome outcome; if (message.ValueBody.Value is Declare) { int txnId = this.CreateTransaction(); outcome = new Declared() { TxnId = new ArraySegment <byte>(BitConverter.GetBytes(txnId)) }; } else if (message.ValueBody.Value is Discharge) { Discharge discharge = (Discharge)message.ValueBody.Value; int txnId = BitConverter.ToInt32(discharge.TxnId.Array, discharge.TxnId.Offset); Transaction txn; if (this.transactions.TryGetValue(txnId, out txn)) { lock (this.transactions) { this.transactions.Remove(txnId); } txn.Discharge(discharge.Fail ?? false); outcome = AmqpConstants.AcceptedOutcome; } else { outcome = new Rejected() { Error = new Error() { Condition = AmqpErrorCode.NotFound } }; } } else { outcome = new Rejected() { Error = new Error() { Condition = AmqpErrorCode.NotAllowed } }; } message.Link.DisposeDelivery(message, true, outcome); }
public void GetRetryFromRejectedSuccess() { int expectedSeconds = 32; Rejected Rejected = new Rejected(); Rejected.Error = new Error(); Rejected.Error.Info = new Fields(); Rejected.Error.Info.Add(new AmqpSymbol("Retry-After"), expectedSeconds); TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(Rejected, defaultInterval); Assert.IsNotNull(actual); Assert.AreEqual(actual?.Seconds, expectedSeconds); }
public void GetRetryFromRejectedFallsBackToDefaultIfRetryAfterProvidedIs0() { int expectedSeconds = 0; Rejected rejected = new Rejected(); rejected.Error = new Error(); rejected.Error.Info = new Fields(); rejected.Error.Info.Add(new Azure.Amqp.Encoding.AmqpSymbol("Retry-After"), expectedSeconds); TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, defaultInterval); Assert.IsNotNull(actual); Assert.AreEqual(actual?.Seconds, defaultInterval.Seconds); }
/// <summary> /// Sends a message and synchronously waits for an acknowledgement. /// </summary> /// <param name="message">The message to send.</param> /// <param name="millisecondsTimeout">The time in milliseconds to wait for the acknowledgement.</param> //chris public void Send(Message message, int millisecondsTimeout = 60000) public void Send(Message message, int millisecondsTimeout) { //chris added //millisecondsTimeout = 60000; ManualResetEvent acked = new ManualResetEvent(false); Outcome outcome = null; OutcomeCallback callback = (m, o, s) => { outcome = o; acked.Set(); }; this.Send(message, callback, acked); bool signaled = acked.WaitOne(millisecondsTimeout, false); //chris bool signaled = acked.WaitOne(millisecondsTimeout); if (!signaled) { lock (this.ThisLock) { this.outgoingList.Remove(message.Delivery); } if (message.Delivery.BytesTransfered > 0) { this.Session.DisposeDelivery(false, message.Delivery, new Released(), true); } throw new TimeoutException(); } if (outcome != null) { if (outcome.Descriptor.Code == Codec.Released.Code) { Released released = (Released)outcome; throw new AmqpException(ErrorCode.MessageReleased, null); } else if (outcome.Descriptor.Code == Codec.Rejected.Code) { Rejected rejected = (Rejected)outcome; throw new AmqpException(rejected.Error); } } }
public static TimeSpan?GetRetryAfterFromRejection(Rejected rejected, TimeSpan defaultInterval) { if (rejected.Error != null && rejected.Error.Info != null) { if (rejected.Error.Info.TryGetValue(RetryAfterKey, out object retryAfter)) { if (int.TryParse(retryAfter.ToString(), out int secondsToWait)) { return(secondsToWait < defaultInterval.Seconds ? defaultInterval : TimeSpan.FromSeconds(secondsToWait)); } } } return(null); }
public void GetRetryFromRejectedFallsBackToDefaultIfRetryAfterProvidedIs0() { int expectedSeconds = 0; var rejected = new Rejected { Error = new Error() }; rejected.Error.Info = new Fields { { new AmqpSymbol("Retry-After"), expectedSeconds } }; TimeSpan?actual = ProvisioningErrorDetailsAmqp.GetRetryAfterFromRejection(rejected, s_defaultInterval); Assert.IsNotNull(actual); Assert.AreEqual(actual?.Seconds, s_defaultInterval.Seconds); }
public ActionResult Rejected(Rejected item) { string comments = item.Comments; int sHid = item.SHomeID; int studentId = item.StudentID; if (comments != "") { StudentHomeworkServices service = new StudentHomeworkServices(); service.Rejected(sHid, comments, studentId); return(RedirectToAction("MyStudents", "Teacher")); } else { ModelState.AddModelError("", "Please add a comment to the reject homework!"); } return(View()); }
public void EndSend(IAsyncResult result) { SendingAmqpLink sendingAmqpLink; Outcome outcome = this.Link.EndSendMessage(result); if (outcome.DescriptorCode != Accepted.Code) { if (this.sharedAmqpLink != null) { this.sharedAmqpLink.Invalidate(out sendingAmqpLink); } Rejected rejected = outcome as Rejected; if (rejected == null) { base.Fault(); throw Fx.Exception.AsWarning(new CommunicationObjectFaultedException(outcome.ToString()), null); } throw ExceptionHelper.ToCommunicationContract(rejected.Error, null); } }
void HandleException(Exception ex, AmqpMessage incoming, IList <AmqpMessage> outgoing) { // Get AmqpException AmqpException amqpException = AmqpExceptionsHelper.GetAmqpException(ex); var rejected = new Rejected { Error = amqpException.Error }; ((IReceivingAmqpLink)this.Link).DisposeMessage(incoming, rejected, true, true); incoming?.Dispose(); if (outgoing != null) { foreach (AmqpMessage message in outgoing) { message.Dispose(); } } Events.ErrorSending(ex, this); }
public override int GetHashCode() { int hash = 1; if (Link.Length != 0) { hash ^= Link.GetHashCode(); } if (Rejected != false) { hash ^= Rejected.GetHashCode(); } if (RejectionReason.Length != 0) { hash ^= RejectionReason.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private Rejected GetRejectedOutcome(IDictionary <string, object> propertiesToModify, string deadLetterReason, string deadLetterErrorDescription) { object obj; Rejected rejectedOutcome = AmqpConstants.RejectedOutcome; if (deadLetterReason != null || deadLetterErrorDescription != null || propertiesToModify != null) { Rejected rejected = new Rejected(); Microsoft.ServiceBus.Messaging.Amqp.Framing.Error error = new Microsoft.ServiceBus.Messaging.Amqp.Framing.Error() { Condition = ClientConstants.DeadLetterName, Info = new Fields() }; rejected.Error = error; rejectedOutcome = rejected; if (deadLetterReason != null) { rejectedOutcome.Error.Info.Add("DeadLetterReason", deadLetterReason); } if (deadLetterErrorDescription != null) { rejectedOutcome.Error.Info.Add("DeadLetterErrorDescription", deadLetterErrorDescription); } if (propertiesToModify != null) { foreach (KeyValuePair <string, object> keyValuePair in propertiesToModify) { if (!MessageConverter.TryGetAmqpObjectFromNetObject(keyValuePair.Value, MappingType.ApplicationProperty, out obj)) { continue; } rejectedOutcome.Error.Info.Add(keyValuePair.Key, obj); } } } return(rejectedOutcome); }