Exemplo n.º 1
0
        public ActionResult DeleteVideo(int id)
        {
            //confirm that the video belongs to the user
            User  loggedUser = (User)Session["User"];
            Video check      = db.Users.Where(x => x.Id == loggedUser.Id).FirstOrDefault().Videos.Where(x => x.Id == id).FirstOrDefault();

            if (check == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //delete the video with all the references
            Video          video   = db.Videos.Find(id);
            List <History> history = db.Histories.Where(x => x.videoId == id).ToList();

            foreach (var item in history)
            {
                db.Histories.Remove(item);
            }

            if (video.Rejected != null)
            {
                RejectMessage rejectMsg = db.RejectMessages.FirstOrDefault(x => x.Id == video.Rejected);
                db.RejectMessages.Remove(rejectMsg);
            }

            db.Videos.Remove(video);
            db.SaveChanges();
            return(RedirectToAction("MyProfile"));
        }
Exemplo n.º 2
0
 public void Reject()
 {
     if (!channel.IsInitiative && _state == ConnectionState.Connecting)
     {
         RejectMessage msg = new RejectMessage();
         msg.TransferCompleted.Observers += (sendable) => State = ConnectionState.Rejected;
         Post(msg);
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Called whenever a reject message is
 /// received for this transaction
 /// </summary>
 /// <param name="message">The reject message</param>
 public void OnReject(RejectMessage message)
 {
     lock (_lock)
     {
         if (_state == ClientState.AwaitConfirmation)
         {
             _handle.FeedReject((RejectReason)message.RejectReason);
             _transitionTo(ClientState.Disposed);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Processes a received rejection
        /// </summary>
        /// <param name="source">The address of the device that sent the rejection</param>
        /// <param name="message">The rejection</param>
        public void ProcessReject(Address source, RejectMessage message)
        {
            ClientTransaction tx = null;

            lock (_lock)
            {
                tx = _getClientTransaction(source, message.InvokeId);
            }
            if (tx != null)
            {
                tx.OnReject(message);
            }
        }
Exemplo n.º 5
0
 public void Reject(int?rejectCode = null)
 {
     if (IsRequester)
     {
         throw new Exception("Reject is only available when the others connect to you.");
     }
     else
     {
         //设备列表中显示的设备,处于被拒绝的状态,如果我不解除这个状态,那么对方没机会在发请求过来。
         State = DeviceState.Rejected;
         var msg = new RejectMessage();
         msg.RejectCode = rejectCode;
         //不要直接调用Post,因为那个会检查是否已经连接,没连接,会调用Connect.
         channelWrapper.Post(msg);
     }
 }
Exemplo n.º 6
0
        private void OnReceivedReject(RejectMessage queueMessage, CancellationToken cancellationToken)
        {
            Execute(() =>
            {
                var rejectCode = (RejectionCode)queueMessage.SmevRejectCode;

                var parentMessage = _databaseLog.GetMessage(Guid.Parse(queueMessage.MessageId));

                var status = _storage.Reject(rejectCode, parentMessage);

                if (status != null)
                {
                    _databaseLog.UpdateStatus(status);
                }

                eventLog.WriteEntry($"Отклонено сообщение с messageId {queueMessage.MessageId}",
                                    EventLogEntryType.Information);
            });
        }
        public ActionResult RejectVideo(string message, int Id)
        {
            //Get the rejection msg and save it to db
            RejectMessage msg = new RejectMessage();

            msg.Message = message;
            db.RejectMessages.Add(msg);
            db.SaveChanges();

            //Reference the rejection message to the video
            Video video = db.Videos.Find(Id);

            video.isApproved      = false;
            video.Rejected        = msg.Id;
            db.Entry(video).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("ManageVideos"));
        }
Exemplo n.º 8
0
 private void OnErrorReject(RejectMessage queueMessage)
 {
     eventLog.WriteEntry($"Ошибка при отклонении сообщения с messageId {queueMessage.MessageId}", EventLogEntryType.Information);
 }
Exemplo n.º 9
0
            async Task HandshakeAsync(int port)
            {
                var versionMessage = new VersionMessage()
                {
                    ProtocolVersion       = ProtocolVersion,
                    NetworkServicesLocal  = (long)NetworkServicesLocal,
                    UnixTimeSeconds       = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
                    NetworkServicesRemote = (long)NetworkServicesRemoteRequired,
                    IPAddressRemote       = IPAddress.Loopback.MapToIPv6(),
                    PortRemote            = (ushort)port,
                    IPAddressLocal        = IPAddress.Loopback.MapToIPv6(),
                    PortLocal             = (ushort)port,
                    Nonce            = Nonce,
                    UserAgent        = UserAgent,
                    BlockchainHeight = Blockchain.HeaderTip.Height,
                    RelayOption      = RelayOption
                };

                versionMessage.SerializePayload();

                await SendMessage(versionMessage);

                CancellationToken cancellationToken =
                    new CancellationTokenSource(TimeSpan.FromSeconds(5))
                    .Token;

                bool verAckReceived  = false;
                bool versionReceived = false;

                while (!verAckReceived || !versionReceived)
                {
                    await ReadMessage(cancellationToken);

                    switch (Command)
                    {
                    case "verack":
                        verAckReceived = true;
                        break;

                    case "version":
                        var versionMessageRemote = new VersionMessage(Payload);

                        versionReceived = true;
                        string rejectionReason = "";

                        if (versionMessageRemote.ProtocolVersion < ProtocolVersion)
                        {
                            rejectionReason = string.Format(
                                "Outdated version '{0}', minimum expected version is '{1}'.",
                                versionMessageRemote.ProtocolVersion,
                                ProtocolVersion);
                        }

                        if (!((ServiceFlags)versionMessageRemote.NetworkServicesLocal)
                            .HasFlag(NetworkServicesRemoteRequired))
                        {
                            rejectionReason = string.Format(
                                "Network services '{0}' do not meet requirement '{1}'.",
                                versionMessageRemote.NetworkServicesLocal,
                                NetworkServicesRemoteRequired);
                        }

                        if (versionMessageRemote.UnixTimeSeconds -
                            DateTimeOffset.UtcNow.ToUnixTimeSeconds() > 2 * 60 * 60)
                        {
                            rejectionReason = string.Format(
                                "Unix time '{0}' more than 2 hours in the " +
                                "future compared to local time '{1}'.",
                                versionMessageRemote.NetworkServicesLocal,
                                NetworkServicesRemoteRequired);
                        }

                        if (versionMessageRemote.Nonce == Nonce)
                        {
                            rejectionReason = string.Format(
                                "Duplicate Nonce '{0}'.",
                                Nonce);
                        }

                        if (rejectionReason != "")
                        {
                            await SendMessage(
                                new RejectMessage(
                                    "version",
                                    RejectMessage.RejectCode.OBSOLETE,
                                    rejectionReason));

                            throw new ProtocolException(
                                      "Remote peer rejected: " + rejectionReason);
                        }

                        await SendMessage(new VerAckMessage());

                        break;

                    case "reject":
                        RejectMessage rejectMessage = new RejectMessage(Payload);

                        throw new ProtocolException(
                                  string.Format("Peer rejected handshake: '{0}'",
                                                rejectMessage.RejectionReason));

                    default:
                        throw new ProtocolException(string.Format(
                                                        "Received improper message '{0}' during handshake session.",
                                                        Command));
                    }
                }
            }
Exemplo n.º 10
0
 private void OnReceivedRejectMessage(RejectMessage message)
 {
     Console.WriteLine($"move {_model.Id} rejected.");
     _stationCoordinator.Tell(new StationCoordinatorActor.TransferRejectedMessage(_model));
     Self.Tell(PoisonPill.Instance);
 }