コード例 #1
0
        public bool AcceptBidRequest(string userId, string requestId)
        {
            var owner      = freelancerDb.Owners.FirstOrDefault(t => t.OwnerId == userId);
            var bidRequest = freelancerDb.BidRequests
                             .Include(t => t.Project.Owner)
                             .FirstOrDefault(t => t.BidRequestId == requestId);

            if (owner == null || bidRequest == null)
            {
                return(false);
            }

            if (bidRequest.Project.Owner != owner)
            {
                return(false);
            }
            bidRequest.RequestStatus  = RequestStatus.Confirmed;
            bidRequest.Project.Status = Status.Working;

            var bss = freelancerDb.BidRequests.Where(bs => bs.Project.ProjectId == bidRequest.Project.ProjectId)
                      .ToList();

            foreach (var request in bss.Where(request => request.BidRequestId != bidRequest.BidRequestId))
            {
                request.RequestStatus = RequestStatus.Rejected;
            }
            var confirmedRequest = new ConfirmedRequest
            {
                ConfirmedRequestId = Guid.NewGuid().ToString(),
                BidRequest         = bidRequest,
                StartDate          = DateTime.Now,
                EndDate            = DateTime.Now.AddDays(bidRequest.DaysToFinish)
            };

            freelancerDb.ConfirmedRequests.Add(confirmedRequest);
            freelancerDb.SaveChanges();
            return(true);
        }
コード例 #2
0
        private void OnConfirmedRequestReceived(Address fromAddress, OctetString linkService, int invokeId, ConfirmedRequest request)
        {
            if (request.ServiceRequest == null)
            {
                return;
            }

            try
            {
                request.ServiceRequest.handle(this, fromAddress, linkService);
            }
            catch (NotImplementedException e)
            {
                Debug.Print("Unsupported confirmed request: invokeId=" + invokeId + ", from=" + fromAddress + ", request=" + request.ServiceRequest.GetType().FullName);
                throw new BACnetErrorException(ErrorClass.Services, ErrorCode.ServiceRequestDenied);
            }
            catch (BACnetErrorException e)
            {
                throw e;
            }
            catch (System.Exception e)
            {
                throw new BACnetErrorException(ErrorClass.Device, ErrorCode.OperationalProblem);
            }



            // TODO X BACNET Original
            // TODO sendResponse(address, linkService, confAPDU, ackService);

            // TODO X BACNET Maty - oprava NPEx

            /*new Thread(new Runnable() {
             *      @Override
             *      public void run() {
             *          try {
             *              sendResponse(address, linkService, confAPDU, ackService);
             *          }
             *          catch (BACnetException e) {
             *              e.printStackTrace();
             *          }
             *      }
             *  }).start();*/
        }
コード例 #3
0
        public async Task <IActionResult> Confirmed(ConfirmedRequest request)
        {
            var viewModel = await _oversightOrchestrator.GetConfirmedViewModel(request.ApplicationId);

            return(View(viewModel));
        }
コード例 #4
0
        private void incomingApdu(APDU.APDU apdu, Address address, OctetString linkService)
        {
            // if (apdu.expectsReply() != npci.isExpectingReply())
            // throw new MessageValidationAssertionException("Inconsistent message: APDU expectsReply="+
            // apdu.expectsReply() +" while NPCI isExpectingReply="+ npci.isExpectingReply());

            if (apdu is ConfirmedRequest)
            {
                ConfirmedRequest confAPDU = (ConfirmedRequest)apdu;
                byte             invokeId = confAPDU.InvokeId;

                if (confAPDU.IsSegmentedMessage && confAPDU.SequenceNumber > 0)
                {
                    // This is a subsequent part of a segmented message. Notify the waiting room.
                    // TODO waitingRoom.notifyMember(address, linkService, invokeId, false, confAPDU);
                }
                else
                {
                    if (confAPDU.IsSegmentedMessage)
                    {
                        // This is the initial part of a segmented message. Go and receive the subsequent parts.

                        /*WaitingRoomKey key = waitingRoom.enterServer(address, linkService, invokeId);
                         * try
                         * {
                         * receiveSegmented(key, confAPDU);
                         * }
                         * finally
                         * {
                         * waitingRoom.leave(key);
                         * }*/
                    }

                    // Handle the request.
                    try
                    {
                        confAPDU.ParseServiceData();

                        /*if (localDevice.getDCCEnableDisable().equals(EnableDisable.disable))
                         * {
                         * // zpracovavame jenom reset a DCC
                         * // povoleni probiha v handleru DCC
                         * if (!(confAPDU.getServiceRequest() is DeviceCommunicationControlRequest ||
                         * confAPDU.getServiceRequest() is ReinitializeDeviceRequest))
                         * {
                         *  //throw new BACnetException("Communication blocked by DCC.");
                         *  return;
                         * }
                         * else
                         * {
                         *  Debug.Print("DCC/Reinitialize received");
                         * }
                         * }*/


                        ConfirmedRequestReceived?.Invoke(address, linkService, invokeId, confAPDU); // EVENT


                        // TODO Move Handlers to LocalDevice
                    }
                    catch (BACnetErrorException e)
                    {
                        network.sendAPDU(address, linkService, new Error(invokeId, e.Error), false);
                    }
                    catch (BACnetRejectException e)
                    {
                        network.sendAPDU(address, linkService, new Reject(invokeId, e.RejectReason), false);
                    }
                    catch (BACnetException e)
                    {
                        Error error = new Error(confAPDU.InvokeId,
                                                new BaseError((byte)127,
                                                              new BACnetError(ErrorClass.Services, ErrorCode.InconsistentParameters)));
                        network.sendAPDU(address, linkService, error, false);
                        // TODO ExceptionDispatch.fireReceivedException(e);
                    }
                }
            }
            else if (apdu is UnconfirmedRequest)
            {
                //DCC - reakce na prichozi zpravy - blokujeme vsechny Unconfirmed

                /* TODO if (localDevice.getDCCEnableDisable().equals(EnableDisable.disable))
                 * {
                 *  return;
                 * }*/
                UnconfirmedRequestReceived?.Invoke(address, linkService, (UnconfirmedRequest)apdu);
            }
            else
            {
                // An acknowledgement.
                AckAPDU ack = (AckAPDU)apdu;

                // Used for testing only. This is required to test the parsing of service data in an ack.
                // ((ComplexACK) ack).parseServiceData();

                //waitingRoom.notifyMember(address, linkService, ack.getOriginalInvokeId(), ack.isServer(), ack);
            }
        }