public void FirearmLicenseReporterCorrectlyResetsControls() { var formA = new HashSet <IRejection>(); var formB = new HashSet <IRejection>(); var tstRej = new Rejection("Code1", "Desc1", "Reason1", RejectionState.REAPPLY); formA.Add(tstRej); formA.Add(new Rejection("Code2", "Desc2", "Reason2", RejectionState.AMENDIT)); formB.Add(new Rejection("Code3", "Desc3", "Reason3", RejectionState.FOREVER)); formB.Add(new Rejection("Code4", "Desc4", "Reason4", RejectionState.TMPCRIM)); mockRejList.SetupGet(f => f.FormA).Returns(formA); mockRejList.SetupGet(f => f.FormB).Returns(formB); var ctrlr = new FirearmLicenseController(ctrls, typeof(FakeReporter), typeof(FakeReporter), mockRejList.Object); ctrls.FormA.SetItemChecked(0, true); ctrls.FormB.SetItemChecked(1, true); ctrls.FormA.Enabled = false; ctrls.FormB.Enabled = false; ctrls.ActiveOffence.Visible = true; ctrls.Underage.Visible = true; ctrls.GenBkgndChk.Enabled = true; genReport.SimulateMouseUp(MouseButtons.Right); Assert.IsFalse(ctrls.FormA.GetItemChecked(0)); Assert.IsFalse(ctrls.FormB.GetItemChecked(1)); Assert.IsTrue(ctrls.FormA.Enabled); Assert.IsTrue(ctrls.FormB.Enabled); Assert.IsFalse(ctrls.ActiveOffence.Visible); Assert.IsFalse(ctrls.Underage.Visible); Assert.IsFalse(ctrls.GenBkgndChk.Enabled); }
public IActionResult GetRejection(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); if (timecard != null) { if (timecard.Status == TimecardStatus.Rejected) { var transition = timecard.Transitions .Where(t => t.TransitionedTo == TimecardStatus.Rejected) .OrderByDescending(t => t.OccurredAt) .FirstOrDefault(); return(Ok(transition)); } else { return(StatusCode(409, new MissingTransitionError() { })); } } else { return(NotFound()); } }
public IActionResult Close(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } //Verify that timecard resource is consistent if (timecard.Resource == rejection.Resource) { return(StatusCode(409, new InvalidStateError() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(NotFound()); } }
public IActionResult Close(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); if (timecard != null) { if (timecard.Resource == rejection.Resource) { return(StatusCode(409)); // Conflict! Resource who created timecard cannot reject it. } if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(NotFound()); } }
/// <summary> /// Creates TradeHub Rejection from user input /// </summary> /// <returns></returns> /// <param name="message">Incoming string message</param> private void CreateTradeHubRejection(string[] message) { try { if (ValidateRejectionFields(message)) { Rejection rejection = new Rejection(new Security(), TradeHubConstants.OrderExecutionProvider.Simulated); // Add Order ID from User Input rejection.OrderId = message[1]; // Add rejection reason from User Input rejection.RejectioReason = message[2]; // Raise Event if (RejectionArrived != null) { RejectionArrived(rejection); } } } catch (Exception exception) { ConsoleWriter.WriteLine(ConsoleColor.DarkRed, exception.ToString()); Logger.Error(exception, _type.FullName, "CreateTradeHubRejection"); } }
/// <summary> /// Called when OEE-Client receives rejection event from OEE-Server /// </summary> /// <param name="rejection">TradeHub Rejection containing rejection message details</param> private void OnRejectionArrived(Rejection rejection) { try { if (_asyncClassLogger.IsDebugEnabled) { _asyncClassLogger.Debug("Rejection event received: " + rejection, _type.FullName, "OnRejectionArrived"); } Order clientOrder; _ordersMap.TryRemove(rejection.OrderId, out clientOrder); if (_asyncClassLogger.IsDebugEnabled) { _asyncClassLogger.Debug("No client order available for the arrived order id: " + rejection.OrderId, _type.FullName, "OnRejectionArrived"); } if (_rejectionArrived != null) { _rejectionArrived(rejection); } } catch (Exception exception) { _asyncClassLogger.Error(exception, _type.FullName, "OnRejectionArrived"); } }
public IActionResult Close(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } //Can't reject your own timecard if (timecard.Resource != rejection.Resource) { var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(StatusCode(409, new NotAuthorizedError() { })); } } else { return(NotFound()); } }
public void RejectDocument(string userName, string documentId, string manCo, string docType, string subDocType) { var document = _documentService.GetDocument(documentId); if (document == null) { _documentService.AddDocument(documentId, docType, subDocType, manCo, null); document = _documentService.GetDocument(documentId); } if (document.Approval != null) { throw new DocumentAlreadyApprovedException("Document is already approved"); } if (document.Rejection != null) { throw new DocumentAlreadyRejectedException("Document is already rejected"); } var rejection = new Rejection { RejectedBy = userName, RejectionDate = DateTime.Now, DocumentId = document.Id }; _rejectionRepository.Create(rejection); }
internal async Task <JsonResult> RejectionWork(Rejection rejection) { SqlConnection cn = null; try { DataTable dt = new DataTable(); cn = Connection.GetConnection(); SqlCommand smd = new SqlCommand("rejection_all_in_one", cn) { CommandType = CommandType.StoredProcedure }; smd.Parameters.AddWithValue("@flag", rejection.Flag); smd.Parameters.AddWithValue("@rejection_type", rejection.RejectionType); smd.Parameters.AddWithValue("@rejection_description", rejection.RejectionDescription); smd.Parameters.AddWithValue("@rejection_code", rejection.RejectionCode); SqlDataAdapter da = new SqlDataAdapter(smd); da.Fill(dt); return(new JsonResult(dt)); } catch (Exception) { throw; } finally { Connection.CloseConnection(ref cn); } }
/// <summary> /// /// </summary> /// <param name="message"></param> /// <param name="sessionId"></param> private void OnMessage(QuickFix.FIX44.OrderCancelReject message, SessionID sessionId) { try { Rejection rejection = new Rejection(new Security() { Symbol = String.Empty }, _provider, message.TransactTime.getValue()); rejection.OrderId = message.OrigClOrdID.getValue(); rejection.RejectioReason = message.CxlRejReason.getValue().ToString(); if (RejectionArrived != null) { RejectionArrived(rejection); } if (Logger.IsInfoEnabled) { Logger.Info("Cancel / CancelReplace rejection arrived : " + rejection.OrderId, _type.FullName, "OnMessage"); } } catch (Exception exception) { Logger.Error(exception.ToString(), _type.FullName, "OnMessage"); } }
public IActionResult Close(string ownId, string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); Timecard approversTimecard = Database.Find(ownId); if (approversTimecard.Resource == timecard.Resource) { return(StatusCode(403, new UnauthorizedActionError() { })); } else { if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(NotFound()); } } }
public WorkflowInfo(IWorkflow workflow, IEnumerable <ReleaseInfo> releases, string releaseName, Rejection rejectionType, ReleaseType workflowReactionTypeResponsibleForRejection, RejectionSkippableType rejectionSkippability, int escalationTimeoutInHours, IEnumerable <INote> notes) { Releases = releases; ReleaseName = releaseName; RejectionType = rejectionType; WorkflowReactionTypeResponsibleForRejection = workflowReactionTypeResponsibleForRejection; RejectionSkippability = rejectionSkippability; EscalationTimeoutInHours = escalationTimeoutInHours; Notes = notes; Workflow = workflow; IsEscalationProcedureSet = EscalationTimeoutInHours > 0; switch (rejectionSkippability) { case RejectionSkippableType.NotApplicable: IsRejectionSkippable = null; break; case RejectionSkippableType.RejectionCannotBeSkipped: IsRejectionSkippable = false; break; case RejectionSkippableType.RejectionCanBeSkipped: IsRejectionSkippable = true; break; default: throw new ArgumentException("Unknown rejection skippability type"); } }
public IActionResult Reject(Guid id, [FromBody] Rejection rejection) { logger.LogInformation($"Looking for timesheet {id}"); Timecard timecard = repository.Find(id); if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); logger.LogInformation($"Adding rejection transition {transition}"); timecard.Transitions.Add(transition); repository.Update(timecard); return(Ok(transition)); } else { return(NotFound()); } }
/// <summary> /// Called when requested order is rejected /// </summary> /// <param name="rejection">Contains rejection details</param> private void OnRejectionArrived(Rejection rejection) { if (_rejectionArrivedEvent != null) { _rejectionArrivedEvent(rejection); } }
public IActionResult Close(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); //Verify that timecard approver is not timecard resource if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } //it is resource equal == error //only the supervisor can reject the submitted timesheet if (timecard.Resource == rejection.Resource) { return(StatusCode(409, new UnauthorizedOperation() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(NotFound()); } }
/// <summary> /// Called when Rejection event is received from Order Execution Provider /// </summary> /// <param name="rejection">TradeHub Rejection object containing Rejection details</param> /// <param name="applicationId">Unique Application ID</param> private void OnExecutionProviderRejectionArrived(Rejection rejection, string applicationId) { try { if (Logger.IsInfoEnabled) { Logger.Info( "Order rejection received from: " + rejection.OrderExecutionProvider + " for: " + applicationId, _type.FullName, "OnExecutionProviderRejectionArrived"); } Dictionary <string, ClientMqParameters> strategyInfo; if (_strategiesInfoMap.TryGetValue(applicationId, out strategyInfo)) { if (Logger.IsDebugEnabled) { Logger.Debug("Publishing Message for: " + applicationId, _type.FullName, "OnExecutionProviderRejectionArrived"); } // Create EasyNetQ message to be published Message <Rejection> message = new Message <Rejection>(rejection); // Publish Messages on the exchange PublishMessages(strategyInfo["Rejection"], message); } } catch (Exception exception) { Logger.Error(exception, _type.FullName, "OnExecutionProviderRejectionArrived"); } }
public IActionResult Close(string id, [FromBody] Rejection rejection) { Timecard timecard = Database.Find(id); if (timecard != null) { if (rejection.Resource == null || timecard.Resource == rejection.Resource) //resource should be different { return(StatusCode(409, new InvalidResource() { })); } if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } if (timecard.Lines.Count < 1) { return(StatusCode(409, new EmptyTimecardError() { })); } var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } else { return(NotFound()); } }
/// <summary> /// Called when new limit order is recieved /// </summary> /// <param name="limitOrder">TradeHub LimitOrder</param> public void NewLimitOrderArrived(LimitOrder limitOrder) { try { if (ValideLimitOrder(limitOrder)) { var order = new Order(limitOrder.OrderID, limitOrder.OrderSide, limitOrder.OrderSize, limitOrder.OrderTif, limitOrder.OrderCurrency, limitOrder.Security, limitOrder.OrderExecutionProvider); //change order status to open order.OrderStatus = OrderStatus.OPEN; order.StrategyId = limitOrder.StrategyId; if (Logger.IsInfoEnabled) { Logger.Info("New Arrived :" + order, _type.FullName, "NewLimitOrderArrived"); } // get index int index; int.TryParse(limitOrder.Remarks.Split('-')[1], out index); //add limit order to list _limitOrders.Add(index, limitOrder); if (NewOrderArrived != null) { NewOrderArrived(order); } } else { Rejection rejection = new Rejection(limitOrder.Security, OrderExecutionProvider.SimulatedExchange) { OrderId = limitOrder.OrderID, DateTime = DateTime.Now, RejectioReason = "Invaild Price Or Size" }; limitOrder.OrderStatus = OrderStatus.REJECTED; if (Logger.IsInfoEnabled) { Logger.Info("Rejection :" + rejection, _type.FullName, "NewLimitOrderArrived"); } if (RejectionArrived != null) { RejectionArrived.Invoke(rejection); } } } catch (Exception exception) { Logger.Error(exception, _type.FullName, "NewLimitOrderArrived"); } }
private void RoomClient_OnJoinRejected(Rejection rejection) { if (rejection.joincode != lastRequestedJoincode) { return; } textEntry.SetText(failMessage, textEntry.defaultTextColor, true); textInputArea.color = failTextInputAreaColor; }
public async Task <JsonResult> RejectionWork([FromBody] Rejection rejection) { try { return(await _rejectionLogic.RejectionWork(rejection).ConfigureAwait(false)); } catch (Exception ee) { return(await _rejectionLogic.SendRespose("False", ee.Message).ConfigureAwait(false)); } }
/// <summary> /// Called when Custom Strategy's order is rejected /// </summary> /// <param name="rejection">Contains rejection details</param> private void OnRejectionReceived(Rejection rejection) { OrderDetails orderDetails = new OrderDetails(rejection.OrderExecutionProvider); orderDetails.ID = rejection.OrderId; orderDetails.Security = rejection.Security; orderDetails.Status = OrderStatus.REJECTED; // Update UI AddOrderDetails(orderDetails); }
/// <summary> /// Extracts the rejection details from the incoming message /// </summary> /// <param name="executionReport"></param> /// <returns></returns> private Rejection ExtractOrderRejection(ExecutionReport executionReport) { Rejection rejection = new Rejection(new Security() { Symbol = executionReport.Symbol.getValue() }, _provider, executionReport.TransactTime.getValue()); rejection.OrderId = executionReport.OrderID.getValue(); rejection.RejectioReason = executionReport.OrdRejReason.getValue().ToString(); return(rejection); }
/// <summary> /// Adds new MarketOrder to list /// If validation of order is successful it sends NewArrived Message. /// In case of failure it sends sends rejection. /// </summary> /// <param name="marketOrder"></param> public void NewMarketOrderArrived(MarketOrder marketOrder) { try { if (ValidateMarketOrder(marketOrder)) { var order = new Order(marketOrder.OrderID, marketOrder.OrderSide, marketOrder.OrderSize, marketOrder.OrderTif, marketOrder.OrderCurrency, marketOrder.Security, marketOrder.OrderExecutionProvider); if (Logger.IsInfoEnabled) { Logger.Info("New Market Order Received :" + marketOrder, _type.FullName, "NewMarketOrderArrived"); } if (NewArrived != null) { NewArrived(order); } // Execute Market Order ExecuteMarketOrder(marketOrder); //// Add to collection //_marketOrders.Add(marketOrder); } else { Rejection rejection = new Rejection(marketOrder.Security, OrderExecutionProvider.SimulatedExchange) { OrderId = marketOrder.OrderID, DateTime = DateTime.Now, RejectioReason = "Invaild Price Or Size" }; if (Logger.IsInfoEnabled) { Logger.Info("Rejection :" + rejection, _type.FullName, "NewMarketOrderArrived"); } if (MarketOrderRejection != null) { MarketOrderRejection.Invoke(rejection); } } } catch (Exception exception) { Logger.Error(exception, _type.FullName, "NewMarketOrderArrived"); } }
/// <summary> /// Publishes Order Rejection /// </summary> public void PublishOrderRejection(Rejection rejection) { try { // Message to be published IMessage <Rejection> message = new Message <Rejection>(rejection); // Publish message _easyNetQBus.Publish(_easyNetQExchange, _rejectionOrderQueueRoutingKey, true, false, message); } catch (Exception exception) { Logger.Error(exception, _type.FullName, "PublishOrderRejection"); } }
public void FirearmLicenseControllerCorrectlyGeneratesReport() { var formA = new HashSet <IRejection>(); var formB = new HashSet <IRejection>(); var tstRej = new Rejection("Code1", "Desc1", "Reason1", RejectionState.REAPPLY); formA.Add(tstRej); formA.Add(new Rejection("Code2", "Desc2", "Reason2", RejectionState.AMENDIT)); formB.Add(new Rejection("Code3", "Desc3", "Reason3", RejectionState.FOREVER)); formB.Add(new Rejection("Code4", "Desc4", "Reason4", RejectionState.TMPCRIM)); mockRejList.SetupGet(f => f.FormA).Returns(formA); mockRejList.SetupGet(f => f.FormB).Returns(formB); var ctrlr = new FirearmLicenseController(ctrls, typeof(FakeReporter), typeof(FakeReporter), mockRejList.Object); Assert.IsTrue(formA.SetEquals(ctrls.FormA.Items.Cast <IRejection>())); Assert.IsTrue(formB.SetEquals(ctrls.FormB.Items.Cast <IRejection>())); Assert.IsFalse(ctrls.GenReport.Enabled); ctrls.PrevDenial.Checked = true; Assert.IsTrue(ctrls.GenReport.Enabled); ctrls.LastOffence.Value = DateTime.UtcNow.AddMonths(-1); Assert.IsTrue(ctrls.ActiveOffence.Visible); ctrls.DateOfBirth.Value = DateTime.UtcNow.AddYears(-20); Assert.IsTrue(ctrls.Underage.Visible); ctrls.FormA.SetItemChecked(0, true); Assert.IsFalse(ctrls.FormB.Enabled); ctrls.FormB.SetItemChecked(0, true); Assert.IsFalse(ctrls.FormA.Enabled); Assert.IsTrue(ctrls.IsFormB.Checked); ctrls.FormB.SetItemChecked(0, false); ctrls.IsFormB.Checked = false; ctrls.FormA.Enabled = true; ctrls.Name.Text = "Joe Smith"; genReport.SimulateMouseUp(MouseButtons.Left); Assert.AreEqual(1, FakeReporter.ctorCalls.Count); var args = FakeReporter.ctorCalls[0]; Assert.AreEqual("Joe Smith", args[0] as string); Assert.IsFalse((bool)args[1]); Assert.AreEqual(ctrls.LastOffence.Value, (DateTime)args[2]); var rej = (args[3] as IEnumerable <object>).Cast <IRejection>(); Assert.AreEqual(1, rej.Count()); Assert.AreEqual(tstRej, rej.First()); }
/// <summary> /// Rejection Arrived /// </summary> /// <param name="rejection"></param> private void RejectionArrived(Rejection rejection) { if (Logger.IsInfoEnabled) { Logger.Info("Sending Rejection To OEE", _type.FullName, "RejectionArrived"); } try { _communicationController.PublishOrderRejection(rejection); } catch (Exception exception) { Logger.Error(exception, _type.FullName, "RejectionArrived"); } }
public PurchaseApplication( Id id, IReadOnlyList <Product> products, Client client, Option <AdditionalInformation> additionalInformation, DateTime creationDateTime, Rejection rejection) { Id = id; Products = products; Client = client; AdditionalInformation = additionalInformation; CreationDateTime = creationDateTime; Rejection = rejection; }
public IActionResult Rejection(string id, [FromBody] Rejection rejection) { if (UserDB.Find(rejection.Resource) != null) { Timecard timecard = Database.Find(id); if (timecard != null) { if (timecard.Status != TimecardStatus.Submitted) { return(StatusCode(409, new InvalidStateError() { })); } if (timecard.Lines.Count < 1) { return(StatusCode(409, new EmptyTimecardError() { })); } /* * Rejection cannot be performed by same user who has submitted the time card. * and rejection should be done by superviser. */ if (timecard.Resource != rejection.Resource && UserDB.Find(rejection.Resource).Role == Roles.Superviser) { var transition = new Transition(rejection, TimecardStatus.Rejected); timecard.Transitions.Add(transition); return(Ok(transition)); } /* * user is not authroized to perform this task. */ return(StatusCode(403, new NotAuthorized { })); } else { return(NotFound()); } } return(StatusCode(401, new InvalidUser() { })); }
public Either <Error, PurchaseApplication> Reject(DateTime dateTime, RejectionReason rejectionReason) { if (Rejection.IsSome) { return(Error.PurchaseApplicationIsAlreadyRejected); } var rejection = new Rejection(dateTime: dateTime, reason: rejectionReason); return(new PurchaseApplication( id: Id, products: Products, client: Client, additionalInformation: AdditionalInformation, creationDateTime: CreationDateTime, rejection: rejection)); }
/// <summary> /// Called when requested order is rejected /// </summary> /// <param name="rejection">Contains rejection details</param> private void OnRejectionArrived(Rejection rejection) { OrderExecutionProvider provider; // Get Order Execution Provider if (_providersMap.TryGetValue(rejection.OrderExecutionProvider, out provider)) { OrderDetails orderDetails = provider.GetOrderDetail(rejection.OrderId, OrderStatus.REJECTED); // Update order parameters if (orderDetails != null) { orderDetails.Status = OrderStatus.REJECTED; } } }
public WorkflowInfo(IWorkflow workflow, IEnumerable<ReleaseInfo> releases, string releaseName, Rejection rejectionType, ReleaseType workflowReactionTypeResponsibleForRejection, RejectionSkippableType rejectionSkippability, int escalationTimeoutInHours, IEnumerable<INote> notes) { Releases = releases; ReleaseName = releaseName; RejectionType = rejectionType; WorkflowReactionTypeResponsibleForRejection = workflowReactionTypeResponsibleForRejection; RejectionSkippability = rejectionSkippability; EscalationTimeoutInHours = escalationTimeoutInHours; Notes = notes; Workflow = workflow; IsEscalationProcedureSet = EscalationTimeoutInHours > 0; switch (rejectionSkippability) { case RejectionSkippableType.NotApplicable: IsRejectionSkippable = null; break; case RejectionSkippableType.RejectionCannotBeSkipped: IsRejectionSkippable = false; break; case RejectionSkippableType.RejectionCanBeSkipped: IsRejectionSkippable = true; break; default: throw new ArgumentException("Unknown rejection skippability type"); } }