예제 #1
0
        public UnaryResult <BoxTask> UpdateStatus(StatusUpdateRequest code)
        {
            var tosell = 0;
            var doit   = HwDebugRegestry.purchases.TryGetValue(code.HardwareId, out tosell);

            if (doit)
            {
                return(UnaryResult(BoxTask.StartServeing));
            }
            else
            {
                return(UnaryResult(BoxTask.StandBy));
            }
        }
예제 #2
0
        public async Task <IActionResult> UpdateStatus(int accountTicketId, [FromBody] StatusUpdateRequest request)
        {
            // Validate inputs
            string modelError = string.Empty;

            if (!ModelState.IsValid)
            {
                //status code 400
                return(BadRequest());
            }

            if (request == null)
            {
                request = new StatusUpdateRequest();
            }

            request.AccountTicketID = accountTicketId;
            try
            {
                // Check exist data
                var accountTA = await WorksContext.CWX_AccountTicketActivity.Where(c => c.AccountTicketID == accountTicketId).FirstOrDefaultAsync();

                if (accountTA == null)
                {
                    //status code 404
                    return(NotFound());
                }

                accountTA.ActivityStatus = request.ActivityStatus;
                accountTA.StartDate      = request.StartDate;
                accountTA.DueDate        = request.DueDate;
                accountTA.UpdatedBy      = request.UpdatedBy;
                accountTA.UpdatedDate    = request.UpdatedDate;
                accountTA.CompletedBy    = request.CompletedBy;
                accountTA.CompletedDate  = request.CompletedDate;

                WorksContext.SaveChanges();
                return(new ObjectResult(accountTA));
            }
            catch (Exception ex)
            {
                WriteLog(ex, nameof(ActivityController) + "-" + nameof(UpdateStatus), LogLevel.Error, false);

                // status code = 400
                return(BadRequest());

                throw;
            }
        }
 // This method sends StatusUpdateRequest on all available SNPPs (interfaces),
 // if an appropriate method to do so exists.
 public void SendUpdateRequestsCallback(object state)
 {
     try
     {
         foreach (KeyValuePair <byte, uint> kvpair in interfaceDefinitions)
         {
             StatusUpdateRequest request = new StatusUpdateRequest(routerId, asId, snId, kvpair.Key);
             sendPeerMessage(kvpair.Key, request);
             Thread.Sleep(50); // Desync in order to prevent packet merging
         }
     }
     catch (NullReferenceException)
     {
         Log.WriteLine("[LRM] Message callback unassigned");
     }
     //Log.WriteLine("[LRM] Network discovery");
 }
        public void HandleManagementPacket(byte localsnpp, GenericMessage genmsg)
        {
            //Log.WriteLine("[LRM] Processing \"{0}\" from interface {1}", genmsg.messageType, localsnpp);
            switch (genmsg.messageType)
            {
            case "StatusUpdateRequest":
                StatusUpdateRequest request = (StatusUpdateRequest)genmsg;
                uint assignedBw             = BWMgmt.AssignedBandwidthAt(localsnpp);
                uint availableBw            = BWMgmt.AvailableBandwidthAt(localsnpp);
                StatusUpdateResponse resp   = new StatusUpdateResponse(routerId, asId, snId, localsnpp, assignedBw, availableBw);
                try
                {
                    sendPeerMessage(localsnpp, resp);
                }
                catch (NullReferenceException)
                {
                    Log.WriteLine("[LRM] ERROR: No SendPeerMessage delegate assigned");
                }
                break;

            case "StatusUpdateResponse":
                StatusUpdateResponse response = (StatusUpdateResponse)genmsg;

                if (peers[localsnpp] == null)
                {
                    // Create new peer object
                    peers[localsnpp] = new PeerInformation(
                        response.snppId,
                        response.id,
                        response.asId,
                        response.snId,
                        response.assignedBw,
                        response.availableBw,
                        HandleLinkFailureCallback
                        );
                    Log.WriteLine("[LRM] Network discovery: {0}:{1} on iface {2}", response.id, response.snppId, localsnpp);
                }
                else
                {
                    // Update existing peer object
                    PeerInformation peer = peers[localsnpp];
                    peer.remoteRouterId    = response.id;  // TODO - co jeśli zmieni sie ID
                    peer.remoteAsId        = response.asId;
                    peer.remoteSnId        = response.snId;
                    peer.remoteAssignedBw  = response.assignedBw;
                    peer.remoteAvailableBw = response.availableBw;
                    peer.timeoutTimer.Change(5000, 0);
                    if (!peer.isActive)
                    {
                        Log.WriteLine("[LRM] Network discovery: {0}:{1} on iface {2}", response.id, response.snppId, localsnpp);
                        peer.isActive = true;
                    }
                    else
                    {
                        // Log.WriteLine("[LRM] Update on peer {0}", peer.remoteRouterId);
                    }
                }
                break;

            default:
                break;
            }
        }