Esempio n. 1
0
        public async Task ProcessMessageFeedbackAsync(string messageId, FeedbackStatus feedbackStatus)
        {
            if (string.IsNullOrWhiteSpace(messageId))
            {
                Events.MessageFeedbackWithNoMessageId(this.Identity);
                return;
            }

            Events.MessageFeedbackReceived(this.Identity, messageId, feedbackStatus);
            if (this.messageTaskCompletionSources.TryRemove(messageId, out TaskCompletionSource <bool> taskCompletionSource))
            {
                if (feedbackStatus == FeedbackStatus.Complete)
                {
                    // TaskCompletionSource.SetResult causes the continuation of the underlying task
                    // to happen on the same thread. So calling Task.Yield to let go of the current thread
                    // That way the underlying task will be scheduled to complete asynchronously on a different thread
                    await Task.Yield();

                    taskCompletionSource.SetResult(true);
                }
                else
                {
                    taskCompletionSource.SetException(new EdgeHubIOException($"Message not completed by client {this.Identity.Id}"));
                }
            }
            else
            {
                Option <ICloudProxy> cloudProxy = await this.connectionManager.GetCloudConnection(this.Identity.Id);

                await cloudProxy.ForEachAsync(cp => cp.SendFeedbackMessageAsync(messageId, feedbackStatus));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Allows set a sensor (for manual activation).
        /// </summary>
        /// <param name="element">Affected element.</param>
        /// <param name="status">Status.</param>
        public override void SetSensorStatus(Element element, FeedbackStatus status)
        {
            Logger.LogDebug(this, "[CLASS].SetSensorStatus([{0}], {1})", element, status);

            if (element.AccessoryConnections?.Count <= 0)
            {
                this.OnInformationReceived(new SystemConsoleEventArgs(SystemConsoleEventArgs.MessageType.Warning,
                                                                      "Feedback sensor {0} not connected: command discarded",
                                                                      element));
                return;
            }

            foreach (FeedbackEncoderConnection connection in element.FeedbackConnections)
            {
                if (connection != null)
                {
                    // Execute the command to set the accessory
                    this.OnInformationReceived(new SystemConsoleEventArgs(SystemConsoleEventArgs.MessageType.Information,
                                                                          "SetSensorStatus: {0:0000} → T:{1}",
                                                                          connection.EncoderInput.Address,
                                                                          status));
                }
                else
                {
                    this.OnInformationReceived(new SystemConsoleEventArgs(SystemConsoleEventArgs.MessageType.Warning,
                                                                          "Sensor {0:0000} not connected: signal discarded",
                                                                          element.ToString()));
                }
            }

            System.Windows.Forms.Application.DoEvents();
        }
        public Task ProcessMessageFeedbackAsync(string messageId, FeedbackStatus feedbackStatus)
        {
            if (string.IsNullOrWhiteSpace(messageId))
            {
                Events.MessageFeedbackWithNoMessageId(this.Identity);
                return(Task.CompletedTask);
            }

            Events.MessageFeedbackReceived(this.Identity, messageId, feedbackStatus);
            if (this.messageTaskCompletionSources.TryRemove(messageId, out TaskCompletionSource <bool> taskCompletionSource))
            {
                if (feedbackStatus == FeedbackStatus.Complete)
                {
                    taskCompletionSource.SetResult(true);
                }
                else
                {
                    taskCompletionSource.SetException(new EdgeHubIOException($"Message not completed by client {this.Identity.Id}"));
                }
                return(Task.CompletedTask);
            }
            else
            {
                return(this.connectionManager.GetCloudConnection(this.Identity.Id).ForEachAsync(cp => cp.SendFeedbackMessageAsync(messageId, feedbackStatus)));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Set feedback status for the element.
        /// </summary>
        /// <param name="status">New feedback status to be adopted by the element.</param>
        public void SetFeedbackStatus(FeedbackStatus status)
        {
            this.FeedbackStatus = (FeedbackStatus)status;

            this.OnImageChanged(new ElementEventArgs(this));

            this.OnFeedbackStatusChanged(new FeedbackEventArgs(status));
        }
        public IActionResult CategoriseFeedback(long feedbackId, FeedbackStatus status)
        {
            Feedback feedback = dataRepository.Get <Feedback>(feedbackId);

            feedback.FeedbackStatus = status;

            dataRepository.SaveChanges();

            return(RedirectToAction("ViewFeedback", "AdminFeedback"));
        }
        public void GetFeedbackStatusTest(ulong descriptorCode, FeedbackStatus expectedFeedbackStatus)
        {
            // Arrange
            var deliveryState = new Mock <DeliveryState>(new AmqpSymbol(string.Empty), descriptorCode);
            var delivery      = Mock.Of <Delivery>(d => d.State == deliveryState.Object);

            // Act
            FeedbackStatus feedbackStatus = SendingLinkHandler.GetFeedbackStatus(delivery);

            // Assert
            Assert.Equal(feedbackStatus, expectedFeedbackStatus);
        }
Esempio n. 7
0
        public void ValidateFeedbackStatus_WithValidData()
        {
            //Arrange
            Validator      validator      = new Validator();
            string         statusAsString = "Scheduled";
            FeedbackStatus status         = FeedbackStatus.Scheduled;
            //Act
            FeedbackStatus sut = validator.ValidateFeedbackStatus(statusAsString);

            //Assert
            Assert.AreEqual(status, sut);
        }
Esempio n. 8
0
        public void SetCorrectRating()
        {
            //Arrange
            var            customName        = "FeedbackName";
            string         customDescription = "Some right description.";
            int            customRating      = 2;
            FeedbackStatus customStatus      = FeedbackStatus.Done;
            //Act
            var sut = new Feedback(customName, customDescription, customRating, customStatus);

            //Assert
            Assert.AreEqual(sut.Rating, customRating);
        }
Esempio n. 9
0
        /// <summary>
        /// Дает обратную связь с пользователем.
        /// Возможные значения обратной связи являются (в виде строки): trust, positive, neutral, block, block_without_feedback.
        /// Вы можете также установить сообщение обратной связи, используя поле Сообщ с некоторыми исключениями.
        /// Обратная связь block_without_feedback очищает сообщение и с блоком сообщение является обязательным.
        /// </summary>
        /// <param name="username">Имя пользователя</param>
        /// <param name="feedback">Режим обратной связи</param>
        /// <param name="message">Сообщение</param>
        /// <returns></returns>
        protected string postFeedbackToUser_as_string(string username, FeedbackStatus feedback, string message = "")
        {
            Dictionary <string, string> _params = new Dictionary <string, string>()
            {
                { "feedback", Enum.GetName(typeof(FeedbackStatus), feedback) }
            };

            if (message != "")
            {
                _params.Add("msg", message);
            }
            return(sendRequest("/api/feedback/" + username + "/", _params, "post"));
        }
Esempio n. 10
0
        public void AddToHistory()
        {
            //Arrange
            var            customName        = "FeedbackName";
            string         customDescription = "Some right description.";
            int            customRating      = 2;
            FeedbackStatus customStatus      = FeedbackStatus.Done;
            //Act
            var sut = new Feedback(customName, customDescription, customRating, customStatus);

            sut.Status = FeedbackStatus.New;
            //Assert
            Assert.AreEqual(sut.History.Count, 5);
        }
        public void CreateFeedback()
        {
            //Arrange
            IFactory       factory     = new Factory();
            string         title       = "TestFeedback";
            string         description = "valid description";
            int            rating      = 2;
            FeedbackStatus status      = FeedbackStatus.New;
            //Act
            var sut = new Feedback(title, description, rating, status);

            //Assert
            Assert.IsInstanceOfType(sut, typeof(Feedback));
        }
Esempio n. 12
0
 public void FeedbackStatusChanged(FeedbackStatus status)
 {
     if (status == FeedbackStatus.Errors)
     {
         FeedbackStatusEllipse.Fill = new SolidColorBrush(Colors.Red);
     }
     else if (status == FeedbackStatus.ChangedButNotChecked)
     {
         FeedbackStatusEllipse.Fill = new SolidColorBrush(Colors.Yellow);
     }
     else
     {
         FeedbackStatusEllipse.Fill = new SolidColorBrush(Colors.Green);
     }
 }
Esempio n. 13
0
        async void DisposeMessageAsync(Delivery delivery)
        {
            try
            {
                Preconditions.CheckNotNull(delivery, nameof(delivery));
                Preconditions.CheckArgument(delivery.State != null, "Delivery.State should not be null");
                Preconditions.CheckArgument(delivery.DeliveryTag.Array != null, "DeliveryTag.Array should not be null");
                string         lockToken      = new Guid(delivery.DeliveryTag.Array).ToString();
                FeedbackStatus feedbackStatus = GetFeedbackStatus(delivery);
                await this.DeviceListener.ProcessMessageFeedbackAsync(lockToken, feedbackStatus);

                this.SendingAmqpLink.DisposeDelivery(delivery, true, new Accepted());
            }
            catch (Exception ex)
            {
                Events.ErrorDisposingMessage(ex, this);
            }
        }
Esempio n. 14
0
        public Task SendFeedbackMessageAsync(string messageId, FeedbackStatus feedbackStatus)
        {
            Preconditions.CheckNonWhiteSpace(messageId, nameof(messageId));
            Events.SendFeedbackMessage(this);
            switch (feedbackStatus)
            {
            case FeedbackStatus.Complete:
                return(this.client.CompleteAsync(messageId));

            case FeedbackStatus.Abandon:
                return(this.client.AbandonAsync(messageId));

            case FeedbackStatus.Reject:
                return(this.client.RejectAsync(messageId));

            default:
                throw new InvalidOperationException("Feedback status type is not supported");
            }
        }
Esempio n. 15
0
        public void InputFeedbackNameIsNULL_Should()
        {
            string feedbackTitle = null;
            string description   = "MegaBadFeedback";
            int    rating        = 4;
            var    feedback      = new Feedback(feedbackTitle, description, rating);

            database.Feedbacks.Add(feedback);

            FeedbackStatus feedbackStatus = FeedbackStatus.Scheduled;

            List <string> parameters = new List <string>
            {
                feedbackTitle,
                feedbackStatus.ToString()
            };

            ChangeFeedbackStatusCommand command = new ChangeFeedbackStatusCommand(parameters);

            command.Execute();
        }
        public void ThrowExeptionWhenCommandParametersAreMoreThanItShould()
        {
            string feedbackTitle = "FeedbackShould";
            string description   = "MegaBadFeedback";
            int    rating        = 4;
            var    feedback      = new Feedback(feedbackTitle, description, rating);

            database.Feedbacks.Add(feedback);

            FeedbackStatus feedbackStatus = FeedbackStatus.Scheduled;

            List <string> parameters = new List <string>
            {
                feedbackTitle,
                feedbackStatus.ToString(),
                feedbackTitle
            };

            ChangeFeedbackRatingCommand command = new ChangeFeedbackRatingCommand(parameters);

            command.Execute();
        }
Esempio n. 17
0
        public void ValidChangeFeedbackStatus_Should()
        {
            string feedbackTitle = "FeedbackNameShould";
            string description   = "MegaBadFeedback";
            int    rating        = 4;
            var    feedback      = new Feedback(feedbackTitle, description, rating);

            database.Feedbacks.Add(feedback);

            FeedbackStatus feedbackStatus = FeedbackStatus.Scheduled;

            List <string> parameters = new List <string>
            {
                feedbackTitle,
                feedbackStatus.ToString()
            };

            ChangeFeedbackStatusCommand command = new ChangeFeedbackStatusCommand(parameters);

            command.Execute();
            Assert.IsTrue(feedback.FeedbackStatus.Equals(feedbackStatus));
        }
Esempio n. 18
0
        public async Task SendFeedbackMessageAsync(string messageId, FeedbackStatus feedbackStatus)
        {
            Preconditions.CheckNonWhiteSpace(messageId, nameof(messageId));
            Events.SendFeedbackMessage(this, messageId);
            await this.ResetTimerAsync();

            try
            {
                switch (feedbackStatus)
                {
                case FeedbackStatus.Complete:
                    await this.client.CompleteAsync(messageId);

                    return;

                case FeedbackStatus.Abandon:
                    await this.client.AbandonAsync(messageId);

                    return;

                case FeedbackStatus.Reject:
                    await this.client.RejectAsync(messageId);

                    return;

                default:
                    throw new InvalidOperationException("Feedback status type is not supported");
                }
            }
            catch (Exception e)
            {
                Events.ErrorSendingFeedbackMessageAsync(this, e);
                await this.HandleException(e);

                throw;
            }
        }
Esempio n. 19
0
 public static void UnknownFeedbackMessage(IIdentity identity, string messageId, FeedbackStatus feedbackStatus)
 {
     Log.LogWarning((int)EventIds.UnknownFeedbackMessage, Invariant($"Received unknown feedback message from {identity.Id} with lock token {messageId} and status {feedbackStatus}. Abandoning message."));
 }
Esempio n. 20
0
 public static void MessageFeedbackReceived(IIdentity identity, string lockToken, FeedbackStatus status)
 {
     Log.LogDebug((int)EventIds.MessageFeedbackReceived, Invariant($"Received feedback {status} for message {lockToken} from device/module {identity.Id}"));
 }
 public Task SendFeedbackMessageAsync(IIdentity identity, string messageId, FeedbackStatus feedbackStatus)
 {
     // TODO: when M2M/C2D is implemented, this may need to do something
     return(Task.CompletedTask);
 }
Esempio n. 22
0
        private Task<int> CountByStatus(string appcode, FeedbackStatus statusToCount)
        {
            using (var db = this.DBFactory())
            {
                var baseQry = db.feedbacks.Where(p => p.status == statusToCount);

                if (appcode != "lms-allapps")
                {
                    baseQry = baseQry.Where(p => p.applicationid == appcode);
                }

                return baseQry.CountAsync();
            }
        }
Esempio n. 23
0
        public bool SetStatus(long id, FeedbackStatus newStatus)
        {
            using (var db = this.DBFactory())
            {
                try
                {
                    db.BeginTransaction(IsolationLevel.ReadUncommitted);

                    db.feedbacks
                        .Where(p => p.id == id)
                        .Set(p => p.status, newStatus)
                        .Update();

                    db.CommitTransaction();
                    return true;
                }
                catch (Exception)
                {
                    db.RollbackTransaction();
                    throw;
                }
            }
        }
Esempio n. 24
0
 public Task SendFeedbackMessageAsync(string messageId, FeedbackStatus feedbackStatus) => this.ExecuteOperation(c => c.SendFeedbackMessageAsync(messageId, feedbackStatus), "SendFeedbackMessageAsync");
Esempio n. 25
0
 public MqttFeedbackMessage(IMessage message, FeedbackStatus status)
 {
     this.message        = message;
     this.FeedbackStatus = status;
 }
 public IFeedback CreateFeedback(string title, string description, int rating, FeedbackStatus status)
 {
     return(new Feedback(title, description, rating, status));
 }
Esempio n. 27
0
 /// <summary>
 /// Allows set a sensor (for manual activation).
 /// </summary>
 /// <param name="element">Affected element.</param>
 /// <param name="status">Status.</param>
 public abstract void SetSensorStatus(Element element, FeedbackStatus status);
Esempio n. 28
0
            public void Bind(IFeedback model)
            {
                CellContentRootView?.SetBackgroundColor(ColorConstants.TransparentColor, 4);

                if (ServiceText != null)
                {
                    ServiceText.Text = "";
                    ServiceText.SetTextColor(ColorConstants.WhiteColor);
                    ServiceText.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size12);
                }

                if (Service2Text != null)
                {
                    Service2Text.Text = model.NameCategory;
                    Service2Text.SetTextColor(ColorConstants.WhiteColor);
                    Service2Text.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size12);
                }

                if (FeedbackStatus != null)
                {
                    FeedbackStatus.SetFont(FontsConstant.OpenSansBold, FontsConstant.Size18);
                    FeedbackStatus.SetTextColor(ColorConstants.WhiteColor);
                }

                if (FeedbackVotes != null)
                {
                    FeedbackVotes.Text = "";
                    FeedbackVotes.SetTextColor(ColorConstants.BackgroundGray);
                    FeedbackVotes.SetFont(FontsConstant.OpenSansRegular, FontsConstant.Size12);
                }

                ServiceImage?.SetImageFromResource(model.ImagePathCategory);
                ProgressView?.SetBackgroundColor(ColorConstants.WhiteColor.SelectorTransparence(ColorConstants.Procent20), 5);

                if (model.Rating == 0)
                {
                    ResetView();

                    FeedbackStatus.Text = RFeedback.TerribleText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(0).ImagePath);
                }
                else if (model.Rating <= 20)
                {
                    FeedbackStatus.Text = RFeedback.TerribleText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(0).ImagePath);
                    ProgressView20?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView20.Visibility = ViewState.Visible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 40)
                {
                    FeedbackStatus.Text = RFeedback.BadText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(1).ImagePath);
                    ProgressView40?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView40.Visibility = ViewState.Visible;
                    ProgressView20.Visibility = ViewState.Invisible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 60)
                {
                    FeedbackStatus.Text = RFeedback.OkayText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(2).ImagePath);
                    ProgressView60?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView60.Visibility = ViewState.Visible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView20.Visibility = ViewState.Invisible;
                    ProgressView80.Visibility = ViewState.Invisible;
                }
                else if (model.Rating <= 80)
                {
                    FeedbackStatus.Text = RFeedback.GoodText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(3).ImagePath);
                    ProgressView80?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ProgressView80.Visibility = ViewState.Visible;
                    ProgressView60.Visibility = ViewState.Invisible;
                    ProgressView40.Visibility = ViewState.Invisible;
                    ProgressView20.Visibility = ViewState.Invisible;
                }
                else if (model.Rating == 100)
                {
                    FeedbackStatus.Text = RFeedback.GreatText.ToUpperInvariant();
                    ImageStatus?.SetImageFromResource(FeedbackManager.Instance.GetItem().ElementAtOrDefault(4).ImagePath);
                    ProgressView?.SetBackgroundColor(ColorConstants.SelectorHome, 5);

                    ResetView();
                }

                ImageStatus?.SetImageColorFilter(ColorConstants.WhiteColor.SelectorTransparence(ColorConstants.Procent84));
            }
Esempio n. 29
0
 public Task SendFeedbackMessageAsync(string messageId, FeedbackStatus feedbackStatus) => this.cloudProxyDispatcher.SendFeedbackMessageAsync(this.identity, messageId, feedbackStatus);
Esempio n. 30
0
 public Task ProcessMessageFeedbackAsync(string messageId, FeedbackStatus feedbackStatus)
 {
     this.ConfirmAction?.Invoke(messageId, feedbackStatus);
     return(Task.CompletedTask);
 }
 /// <summary>
 /// Constructor of Feedback
 /// </summary>
 /// <param name="title">Title of the feedback</param>
 /// <param name="description">Description of the feedback</param>
 /// <param name="rating">Rating of feedback</param>
 /// <param name="status">Status of the feedback</param>
 public Feedback(string title, string description, int rating, FeedbackStatus status) : base(title, description)
 {
     this.Rating = rating;
     this.Status = status;
 }
Esempio n. 32
0
 public void SetSensorStatus(Element element, FeedbackStatus status)
 {
     throw new NotImplementedException();
 }