Example #1
0
        public static void AddOrderItemComment(Order order, int orderItemId, int userId, string comment)
        {
            OrderItemComment orderItemComment = OrderItemComment.New();

            orderItemComment.OrderItemId = orderItemId;
            orderItemComment.UserId      = userId;
            orderItemComment.CommentText = comment;
            orderItemComment.CommentDate = DateTime.Now;
            OrderItemComment.Update(orderItemComment);

            // Fire event
            if (NewUserOrderItemComment != null)
            {
                NewUserOrderItemComment(null, new OrderItemCommentEventArgs(order, orderItemComment));
            }
        }
Example #2
0
        public static void NewOrderItemComment(Order order, OrderItemComment comment)
        {
            Email email = NotifyEngine.GetEmailTemplate("Admin.NewOrderItemComment");

            email.Recipients.Add(comment.OrderItem.AssignedToUser.Email);
            email.Subject = NotifyEngine.GetSubject("User response to request for further information about an order item");

            string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/AUO/O{0}/", order.OrderId));

            email.AddBodyParameter("url", url);

            email.AddBodyParameter("order-id", order.OrderId);
            email.AddBodyParameter("asset-id", comment.OrderItem.Asset.AssetId);
            email.AddBodyParameter("comment-text", comment.CommentText);
            email.AddBodyParameter("comment-date", comment.CommentDate.ToString(Global.DateTimeFormat));
            email.AddBodyParameter("comment-user-name", comment.User.FullName);

            NotifyEngine.SendMessage(email);
        }
Example #3
0
        protected void ConversationRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:

                OrderItemComment orderItemComment = (OrderItemComment)e.Item.DataItem;

                Label UserNameLabel = (Label)e.Item.FindControl("UserNameLabel");
                UserNameLabel.Text = orderItemComment.UserFullName;

                Label DateLabel = (Label)e.Item.FindControl("DateLabel");
                DateLabel.Text = orderItemComment.CommentDate.ToString(Global.DateTimeFormat);

                Label CommentTextLabel = (Label)e.Item.FindControl("CommentTextLabel");
                CommentTextLabel.Text = SiteUtils.ConvertTextToHtml(orderItemComment.CommentText, e.Item.ItemType == ListItemType.Item ? "PosTxt" : "BodyTxt");

                break;
            }
        }
Example #4
0
        public static void NewOrderItemComment(Order order, OrderItemComment comment)
        {
            Email email = NotifyEngine.GetEmailTemplate("User.NewOrderItemComment");

            email.Recipients.Add(order.User.Email);

            switch (comment.OrderItem.OrderItemStatus)
            {
            case OrderItemStatus.Approved:
                email.Subject = NotifyEngine.GetSubject(string.Format("The request for asset with reference '{0}' has been approved", comment.OrderItem.AssetId));
                break;

            case OrderItemStatus.AwaitingApproval:
                email.Subject = NotifyEngine.GetSubject(string.Format("Further information is required about your request for asset with reference: {0}", comment.OrderItem.AssetId));
                break;

            case OrderItemStatus.Rejected:
                email.Subject = NotifyEngine.GetSubject(string.Format("The request for asset with reference '{0}' has been denied", comment.OrderItem.AssetId));
                break;

            case OrderItemStatus.Preapproved:
                throw new SystemException("Comments cannot be left on order items that are pre-approved");
            }

            string url = SiteUtils.GetWebsiteUrl(string.Format("~/Go.ashx/VOI/O{0}-OI{1}/", order.OrderId, comment.OrderItemId));

            email.AddBodyParameter("url", url);

            email.AddBodyParameter("first-name", order.User.FirstName);
            email.AddBodyParameter("order-id", order.OrderId);
            email.AddBodyParameter("asset-id", comment.OrderItem.Asset.AssetId);
            email.AddBodyParameter("comment-text", comment.CommentText);
            email.AddBodyParameter("comment-date", comment.CommentDate.ToString(Global.DateTimeFormat));
            email.AddBodyParameter("comment-user-name", comment.User.FullName);
            email.AddBodyParameter("current-status", comment.OrderItem.OrderItemStatus.ToString().ToLower());

            NotifyEngine.SendMessage(email);
        }
Example #5
0
 public OrderItemCommentEventArgs(Order order, OrderItemComment orderItemComment) : base(order)
 {
     OrderItemComment = orderItemComment;
 }
Example #6
0
        public static void ProcessOrderItems(EntityList <OrderItem> orderItems, User user)
        {
            if (orderItems.Count == 0)
            {
                throw new SystemException("No order items");
            }

            // Ensure that we have valid items
            ValidateOrderItemsForProcessing(orderItems);

            // Get the parent of the first order (all order items should be from the same order)
            Order order = orderItems[0].Order;

            // Create list to hold processed items
            EntityList <OrderItem> processedOrderItems = new EntityList <OrderItem>();

            // Flag to tell us whether we need to fire the 'order completion' event
            bool notifyIfComplete = false;

            // Iterate through all of the processed order items and save changes to database
            foreach (OrderItem orderItem in orderItems)
            {
                if (orderItem.IsDirty)
                {
                    notifyIfComplete = true;
                }

                // Update database
                OrderItem.Update(orderItem);

                // Save comments
                foreach (OrderItemComment orderItemComment in orderItem.NewOrderItemCommentList)
                {
                    // Save the comment
                    OrderItemComment.Update(orderItemComment);

                    // Fire event so user gets notified that a new comment has been made
                    if (NewAdminOrderItemComment != null)
                    {
                        NewAdminOrderItemComment(null, new OrderItemCommentEventArgs(order, orderItemComment));
                    }
                }

                // All new comments saved
                orderItem.NewOrderItemCommentList.Clear();

                switch (orderItem.OrderItemStatus)
                {
                case (OrderItemStatus.Approved):

                    // Order items which are approved are processed so add these to the processedOrderItems list
                    processedOrderItems.Add(orderItem);

                    // Log that a request for this asset was approved in the asset audit history
                    AuditLogManager.LogAssetAction(orderItem.AssetId, user, AuditAssetAction.ApprovedForDownload, string.Format("Approved for download for OrderId: {0} made by {1}", orderItem.OrderId, order.User.FullName));

                    // Log in user audit
                    AuditLogManager.LogUserAction(user, AuditUserAction.AuthoriseOrder, string.Format("Approved request for asset with AssetId: {0} for download in OrderId: {1} made by {2} (UserId: {3})", orderItem.AssetId, orderItem.OrderId, order.User.FullName, order.User.UserId));

                    break;

                case (OrderItemStatus.Rejected):

                    // Order items which are rejected are processed so add these to the processedOrderItems list
                    processedOrderItems.Add(orderItem);

                    // Log that a request for this asset was rejected in the asset audit history
                    AuditLogManager.LogAssetAction(orderItem.AssetId, user, AuditAssetAction.RejectedForDownload, string.Format("Rejected for download for OrderId: {0} made by {1}.  Reason: {2}", orderItem.OrderId, order.User.FullName, orderItem.LastComment));

                    // Log in user audit
                    AuditLogManager.LogUserAction(user, AuditUserAction.AuthoriseOrder, string.Format("Rejected request for asset with AssetId: {0} for download in OrderId: {1} made by {2} (UserId: {3})", orderItem.AssetId, orderItem.OrderId, order.User.FullName, order.User.UserId));

                    break;
                }
            }

            // Complete the order if everything has been processed
            if (AllOrderItemsProcessed(order))
            {
                CompleteOrder(order);
            }
            else
            {
                // Otherwise, fire the order items processed event to trigger
                // any notifications to this user that order items have been processed.
                // We only want to fire this if order items have actually been changed though
                // so we look through the order items and check that at least one is dirty

                if (notifyIfComplete)
                {
                    if (OrderItemsProcessed != null)
                    {
                        OrderItemsProcessed(null, new OrderItemEventArgs(order, processedOrderItems));
                    }
                }
            }

            // Update user audit with how many order items were processed in which order
            AuditLogManager.LogUserAction(user, AuditUserAction.AuthoriseOrder, string.Format("Processed {0} items in order with OrderId: {1}", processedOrderItems.Count, order.OrderId));
        }