public void NotifyDeliveryCompletion(Guid pDeliveryId, DeliveryStatus status)
        {
            Order lAffectedOrder = RetrieveDeliveryOrder(pDeliveryId);

            if (lAffectedOrder == null)
            {
                ConsoleHelper.WriteLine(ConsoleColor.Red, "Failed to find order with delivery id='{0}'", pDeliveryId);
                return;
            }

            UpdateDeliveryStatus(pDeliveryId, status);

            switch (status)
            {
            case DeliveryStatus.Delivered:
                EmailProvider.SendMessage(lAffectedOrder.Customer.Email,
                                          "Our records show that your order" + lAffectedOrder.OrderNumber +
                                          " has been delivered. Thank you for shopping at video store");
                break;

            case DeliveryStatus.Failed:
                // Rollback items to stock
                RollbackOrder(pDeliveryId);
                EmailProvider.SendMessage(lAffectedOrder.Customer.Email,
                                          "Our records show that there was a problem" + lAffectedOrder.OrderNumber +
                                          " delivering your order. Please contact Video Store");
                break;
            }
        }
 public UpdateNotificationDeliveryStatusCommand(Guid notificationId, string externalId,
                                                DeliveryStatus deliveryStatus)
 {
     NotificationId = notificationId;
     ExternalId     = externalId;
     DeliveryStatus = deliveryStatus;
 }
        public void PublishToSubscriber(Common.Model.Message pMessage)
        {
            if (pMessage is Common.Model.DeliverProcessedMessage)
            {
                Common.Model.DeliverProcessedMessage lMessage = pMessage as Common.Model.DeliverProcessedMessage;
                string         orderNumber = lMessage.orderNumber;
                Guid           pDeliveryId = lMessage.pDeliveryId;
                DeliveryStatus status      = (DeliveryStatus)lMessage.status;
                string         errorMsg    = lMessage.errorMsg;
                NotificationProvider.NotifyDeliveryProcessed(orderNumber, pDeliveryId, status, errorMsg);
            }

            else if (pMessage is Common.Model.DeliverCompleteMessage)
            {
                Common.Model.DeliverCompleteMessage lMessage = pMessage as Common.Model.DeliverCompleteMessage;
                Guid           pDeliveryId = lMessage.pDeliveryId;
                DeliveryStatus status      = (DeliveryStatus)lMessage.status;
                NotificationProvider.NotifyDeliveryCompletion(pDeliveryId, status);
            }

            else if (pMessage is Common.Model.TransferResultMessage)
            {
                Common.Model.TransferResultMessage lMessage = pMessage as Common.Model.TransferResultMessage;
                Boolean success = lMessage.Success;
                String  Msg     = lMessage.Message;
                Guid    orderId = lMessage.OrderNumber;

                OrderProvider.AfterTransferResultReturns(success, orderId, Msg);
            }
        }
Example #4
0
 public static DeliveryStatus ParamValueStatus(int val, DataTable dtemp)
 {
     try
     {
         if (val != 0)
         {
             DeliveryStatus s1 = (from sta in dtemp.AsEnumerable()
                                  where sta["StatusID"].ToString() == val.ToString()
                                  select new DeliveryStatus()
             {
                 StatusID = Convert.ToInt32(sta["StatusID"]),
                 StatusName = sta["StatusName"].ToString()
             }).First();
             return(new DeliveryStatus {
                 StatusID = s1.StatusID, StatusName = s1.StatusName
             });
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
        /// <summary>
        /// Get a report for specific delivery status of a message you have sent.
        /// </summary>
        /// <param name="id">message id</param>
        /// <param name="status">delivery status to sort by</param>
        /// <returns>list of possible phone numbers which have given status</returns>
        /// <exception cref="EzTextingApiException">in case error has occurred on server side, check provided error description.</exception>
        /// <exception cref="EzTextingClientException">in case error has occurred in client.</exception>
        public IList <long?> GetDetailedReport(long id, DeliveryStatus status)
        {
            var path        = DetailedReportPath.ReplaceFirst(ClientConstants.Placeholder, id.ToString());
            var queryParams = ClientUtils.AsParams("status", status.EnumMemberAttr());

            return(_client.Get <long?>(path, queryParams).Entries);
        }
        /// <summary>
        /// Do all the launch things.
        /// </summary>
        /// <param name="transferList"></param>
        /// <returns></returns>
        protected bool DoLaunchTasks(List <OrbitalLogisticsTransferRequest> transferList)
        {
            if (transferList.Contains(this))
            {
                return(false);
            }

            // Deduct the resources from the origin vessel
            double deductedAmount;

            foreach (var request in ResourceRequests)
            {
                deductedAmount         = Origin.ExchangeResources(request.ResourceDefinition, -request.TransferAmount);
                request.TransferAmount = Math.Abs(deductedAmount);
            }

            // Since the mass and fuel required won't change after launch, cache them
            //   to prevent running the calculations repeatedly
            Status     = DeliveryStatus.PreLaunch; // TotalMass and CalculateFuelUnits will return cached values if Status is not PreLaunch
            _mass      = TotalMass();
            _fuelUnits = CalculateFuelUnits();

            // Perform other launch tasks
            DoFinalLaunchTasks(transferList);

            return(true);
        }
Example #7
0
        public bool ChangeDeliveryStatus(int orderId, DeliveryStatus newStatus)
        {
            var order = db.FirstOrDefault(i => i.OrderId == orderId);

            order.DeliveryStatus = newStatus;
            return(true);
        }
 private DeliveryStatus GetCachedDeliveryStatus(MessagingDbContext dbContext, string statusName)
 {
     return(Caches.DeliveryStatusByName.GetValue(
                statusName,
                () => {
         var deliveryStatus =
             dbContext.DeliveryStatuses.AsNoTracking()
             .SingleOrDefault(
                 x => x.Name == statusName,
                 DebugInfoCollector,
                 "Get delivary status by name");
         if (deliveryStatus.IsNull())
         {
             deliveryStatus = new DeliveryStatus {
                 Name = statusName,
                 Description = statusName
             };
             var dc = CreateMessagingContext(Requirements);
             dc.DeliveryStatuses.Add(deliveryStatus);
             dc.SaveChanges();
         }
         dbContext.Entry(deliveryStatus).State = EntityState.Detached;
         return deliveryStatus;
     }));
 }
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 /// <summary>Depending on the delivery status string, received for the SMS,
 /// this function creates a DeliveryStatus enum for the status property,
 /// and extends the description. To a comprehensive one</summary>
 /// <param name="statusString">The status received from the service.</param>
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 public void SetStatus(string statusString)
 {
     switch (statusString)
     {
         case "DeliveredToNetwork":
             status = DeliveryStatus.DeliveredToNetwork;
             statusDescription = "The message has been delivered to the network. Another state could be available later to inform if the message was finally delivered to the handset.";
             break;
         case "DeliveredToTerminal":
             status = DeliveryStatus.DeliveredToTerminal;
             statusDescription = "The message has been successful delivered to the handset.";
             break;
         case "DeliveryImpossible":
             status = DeliveryStatus.DeliveryImpossible;
             statusDescription = "Unsuccessful delivery; the message could not be delivered before it expired.";
             break;
         case "DeliveryNotificationNotSupported":
             status = DeliveryStatus.DeliveryNotificationNotSupported;
             statusDescription = "Unable to provide delivery status information because it is not supported by the network.";
             break;
         case "DeliveryUncertain":
             status = DeliveryStatus.DeliveryUncertain;
             statusDescription = "Delivery status unknown.";
             break;
         case "MessageWaiting":
             status = DeliveryStatus.MessageWaiting;
             statusDescription = "The message is still queued for delivery. This is a temporary state, pending transition to another state.";
             break;
         default:
             status = DeliveryStatus.None;
             statusDescription = "No status received.";
             break;
     }
 }
        public IHttpActionResult Get(string status = null)
        {
            try
            {
                var allOrders = this.orders.GetAll();
                List <OrderResponseModelWIthUserInfo> ordersToReturn;
                if (!string.IsNullOrWhiteSpace(status))
                {
                    DeliveryStatus statusEnum = (DeliveryStatus)Enum.Parse(typeof(DeliveryStatus), status, true);
                    ordersToReturn = allOrders.Where(x => x.Status == statusEnum)
                                     .OrderByDescending(x => x.CreatedOn)
                                     .ThenBy(x => x.Id)
                                     .To <OrderResponseModelWIthUserInfo>()
                                     .ToList();
                }
                else
                {
                    ordersToReturn = allOrders.OrderBy(x => x.Status)
                                     .ThenByDescending(x => x.CreatedOn)
                                     .ThenBy(x => x.Id)
                                     .To <OrderResponseModelWIthUserInfo>()
                                     .ToList();
                }

                return(this.Ok(ordersToReturn));
            }
            catch (Exception e)
            {
                HandlExceptionLogging(e, "", controllerName);
                return(InternalServerError());
            }
        }
        public void NotifyDeliveryProcessed(string orderNnmber, Guid pDeliveryId, DeliveryStatus status, String errorMsg)
        {
            using (TransactionScope lScope = new TransactionScope())
                using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
                {
                    var      orderN    = Guid.Parse(orderNnmber);
                    Delivery lDelivery = lContainer.Deliveries.Include("Order.Customer").Where((pDel) => pDel.Order.OrderNumber == orderN).FirstOrDefault();
                    if (lDelivery != null)
                    {
                        lDelivery.DeliveryStatus = status;

                        if (status == DeliveryStatus.Submitted)
                        {
                            lDelivery.ExternalDeliveryIdentifier = pDeliveryId;

                            SendOrderPlacedConfirmation(lDelivery.Order);
                        }
                        else if (status == DeliveryStatus.Failed)
                        {
                            SendOrderErrorMessage(lDelivery.Order, errorMsg);
                        }

                        lContainer.SaveChanges();
                    }
                    lScope.Complete();
                }
        }
        public DeliveryProfileBaseFilter(XmlElement node) : base(node)
        {
            foreach (XmlElement propertyNode in node.ChildNodes)
            {
                switch (propertyNode.Name)
                {
                case "idEqual":
                    this._IdEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "idIn":
                    this._IdIn = propertyNode.InnerText;
                    continue;

                case "partnerIdEqual":
                    this._PartnerIdEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "partnerIdIn":
                    this._PartnerIdIn = propertyNode.InnerText;
                    continue;

                case "systemNameEqual":
                    this._SystemNameEqual = propertyNode.InnerText;
                    continue;

                case "systemNameIn":
                    this._SystemNameIn = propertyNode.InnerText;
                    continue;

                case "createdAtGreaterThanOrEqual":
                    this._CreatedAtGreaterThanOrEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "createdAtLessThanOrEqual":
                    this._CreatedAtLessThanOrEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "updatedAtGreaterThanOrEqual":
                    this._UpdatedAtGreaterThanOrEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "updatedAtLessThanOrEqual":
                    this._UpdatedAtLessThanOrEqual = ParseInt(propertyNode.InnerText);
                    continue;

                case "streamerTypeEqual":
                    this._StreamerTypeEqual = (PlaybackProtocol)StringEnum.Parse(typeof(PlaybackProtocol), propertyNode.InnerText);
                    continue;

                case "statusEqual":
                    this._StatusEqual = (DeliveryStatus)ParseEnum(typeof(DeliveryStatus), propertyNode.InnerText);
                    continue;

                case "statusIn":
                    this._StatusIn = propertyNode.InnerText;
                    continue;
                }
            }
        }
        public async Task CheckPurchaseDeliveryFailed()
        {
            ShoppingCart            shoppingCart     = new ShoppingCart(testUser);
            HashSet <ProductInCart> product_quantity = new HashSet <ProductInCart>();
            Guid       storeId       = Guid.NewGuid();
            string     clientPhone   = "0544444444";
            Address    clientAddress = new Address("1", "1", "1", "1", "1");
            CreditCard card          = new CreditCard("1", "1", "1", "1", "1", "1");
            Product    product1      = new Product(new Guid(), 10, 10, 10);
            Product    product2      = new Product(new Guid(), 20, 20, 20);

            product_quantity.Add(new ProductInCart(product1, 1));
            product_quantity.Add(new ProductInCart(product2, 2));
            DeliveryStatus        deliveryStatus  = new DeliveryStatus(Guid.NewGuid().ToString(), testUser.Username, storeId, "storeName", false);
            PaymentStatus         paymentStatus   = new PaymentStatus(Guid.NewGuid().ToString(), testUser.Username, storeId, true);
            Mock <ShoppingBasket> shoppingBasket1 = new Mock <ShoppingBasket>();

            shoppingBasket1.Setup(sb => sb.GetDictionaryProductQuantity()).Returns(product_quantity);
            TransactionStatus transactionStatus = new TransactionStatus("Testusername", storeId, paymentStatus, deliveryStatus, shoppingBasket1.Object, true);
            PurchaseStatus    purchaseStatus    = new PurchaseStatus(true, transactionStatus, storeId);

            Mock <Store> store1 = new Mock <Store>();

            store1.Setup(s => s.Purchase(It.IsAny <ShoppingBasket>(), It.IsAny <string>(), It.IsAny <Address>(), It.IsAny <CreditCard>())).Returns(Task.FromResult(purchaseStatus));
            shoppingBasket1.Setup(basket => basket.GetStore()).Returns(store1.Object);
            shoppingCart.ShoppingBaskets.Add(shoppingBasket1.Object);
            var v1 = await shoppingCart.Purchase(card, clientPhone, clientAddress);

            Assert.AreEqual(false, v1.Status);
        }
 /// <summary>
 /// Cancel the transfer.
 /// </summary>
 public void Abort()
 {
     if (Status == DeliveryStatus.Launched)
     {
         Status = DeliveryStatus.Returning;
     }
 }
        //[IgnoreProperty]
        public static string StatusDescription(DeliveryStatus status, string language)
        {
            switch (language)
            {
            case "NL":
                switch (status)
                {
                case DeliveryStatus.Backorder: return("Backorder");

                case DeliveryStatus.Failed: return("Mislukt");

                case DeliveryStatus.OfferedToDeliverer: return("Aangeboden aan uitleveraar");

                case DeliveryStatus.SendFromDeliverer: return("Verzonden door uitleveraar");

                case DeliveryStatus.ToDeliver: return("Uit te leveren");

                case DeliveryStatus.Unavailable: return("Niet beschikbaar");

                case DeliveryStatus.Cancelled: return("Geannuleerd");
                }
                break;
            }

            return(status.ToString());
        }
        public async Task <IActionResult> Create(DeliveryDetails deliveryDetails)
        {
            if (ModelState.IsValid)
            {
                Delivery delivery = new Delivery();
                Client   client   = company.Clients.SingleOrDefault(c => c.ID == deliveryDetails.ClientID);
                delivery.Client     = client;
                delivery.ItemSize   = deliveryDetails.ItemSize;
                delivery.ItemWeight = deliveryDetails.ItemWeight;
                delivery.DeliverBy  = deliveryDetails.DeliverBy;


                DeliveryStatus status = new DeliveryStatus();
                status.Status = Status.New;
                _context.DeliveryStatus.Add(status);
                delivery.DeliveryStatus = status;
                _context.Add(delivery);
                company.Deliveries.Add(delivery);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["ClientID"] = new SelectList(company.Clients, "ID", "FirstName", deliveryDetails.ClientID);
            return(View(deliveryDetails));
        }
        private OrderStatus GetOrderStatusForDeliveryStatus(DeliveryStatus deliveryStatus)
        {
            switch (deliveryStatus)
            {
            case DeliveryStatus.NotReady:
                return(OrderStatus.Received);

            case DeliveryStatus.ReadyForDelivery:
                return(OrderStatus.Ready);

            case DeliveryStatus.OutForDelivery:
                return(OrderStatus.OutForDelivery);

            case DeliveryStatus.Completed:
                return(OrderStatus.Completed);

            case DeliveryStatus.Failed:
            case DeliveryStatus.Returned:
            case DeliveryStatus.Cancelled:
                return(OrderStatus.Failed);

            default:
                return(OrderStatus.Requested);
            }
        }
        /// <summary>
        /// What does this do?
        /// </summary>
        /// <param name="timeStamp"></param>
        /// <returns></returns>
        public StatisticsVehicle MakeStatistics(int timeStamp)
        {
            DeliveryStatus stat = DeliveryStatus.NOTSTARTED;

            if (deliveryQueue.Count > 0)
            {
                if (deliveryQueue[0] != null)
                {
                    stat = deliveryQueue[0].Status;
                }
            }
            int totalDriven = 0;

            foreach (Delivery d in deliveryQueue)
            {
                totalDriven += d.TotalTravelTime;
            }
            foreach (Delivery d in finishedDeliveries)
            {
                totalDriven += d.TotalTravelTime;
            }
            int resTime = 0;

            foreach (Delivery d in finishedDeliveries)
            {
                resTime += (d.StartTime - d.CreateTime);
            }
            StatisticsVehicle temp = new StatisticsVehicle(timeStamp, this, stat, totalDriven, finishedDeliveries.Count, finishedDeliveries.Count + deliveryQueue.Count, resTime);

            return(temp);
        }
Example #19
0
 public void Update(DeliveryStatus status)
 {
     using (var db = new PostEntities())
     {
         db.Entry(status).State = EntityState.Modified;
     }
 }
Example #20
0
        public ActionResult DeleteConfirmed(long id)
        {
            DeliveryStatus deliveryStatus = db.DeliveryStatus.Find(id);

            db.DeliveryStatus.Remove(deliveryStatus);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #21
0
        public DeliveryModel(dynamic data)
        {
            DeliveryKey  = data.DeliveryKey;
            Notification = new Notification(data);
            Subscription = new Subscription(data);

            Status = (DeliveryStatus)data.Status;
        }
 /// <summary>
 /// Do just the final launch things.
 /// </summary>
 /// <param name="transferList"></param>
 protected void DoFinalLaunchTasks(List <OrbitalLogisticsTransferRequest> transferList)
 {
     CalculateDuration();
     StartTime = Planetarium.GetUniversalTime();
     Status    = DeliveryStatus.Launched;
     transferList.Add(this);
     transferList.Sort();
 }
 public CommonOrderStatuses ToCommonStatus(DeliveryStatus status)
 {
     if (status == DeliveryStatus.Cancelled)
     {
         return(CommonOrderStatuses.Canceled);
     }
     return(CommonOrderStatuses.InProgress);
 }
Example #24
0
 public bool UpdateDeliveryStatus(Guid outboxGuid, string numbers, DeliveryStatus state, long id = 0)
 {
     return(ExecuteSPCommand("UpdateSmsDeliveryStatusManually",
                             "@OutboxGuid", outboxGuid,
                             "@ID", id,
                             "@Numbers", numbers,
                             "@DeliveryStatus", (int)state));
 }
Example #25
0
 public Delivery(Id id, DeliveryType type, Order order, Address address)
 {
     Type           = type;
     Order          = order;
     Address        = address;
     Id             = id;
     DeliveryStatus = DeliveryStatus.New;
 }
Example #26
0
 public Order(DateTimeOffset?date, string comment, DeliveryStatus status, int buyerId, int addressId)
 {
     Date      = date;
     Comment   = comment;
     Status    = status;
     BuyerId   = buyerId;
     AddressId = addressId;
 }
Example #27
0
        public CourierDriver AddCourierDriver(string name, DeliveryStatus status, int speed, int maxDistance, string driverLicense)
        {
            CourierDriver courierDriver = new CourierDriver(name, status, speed, maxDistance, driverLicense); // создание нового водителя

            _dbContext.CourierDrivers.Add(courierDriver);
            _dbContext.SaveChanges();
            return(courierDriver);
        }
Example #28
0
 public void Add(DeliveryStatus status)
 {
     using (var db = new PostEntities())
     {
         db.DeliveryStatus.Add(status);
         db.SaveChanges();
     }
 }
Example #29
0
        /// <summary>
        ///  修改配送状态(info.Status,info.Note),根据配送的订单编号(info.SOSysNo)、配送原因(info.Reason)和配送状态(oldStatus)
        /// </summary>
        /// <param name="info"></param>
        /// <param name="oldStatus">配送状态</param>
        public void UpdateLastOKStatus(DeliveryInfo info, DeliveryStatus oldStatus)
        {
            DataCommand command = DataCommandManager.GetDataCommand("SO_Delivery_Update_StatusBySOSysNoAndReason");

            command.SetParameterValue <DeliveryInfo>(info, true, false);
            command.SetParameterValue("@OldStatus", oldStatus);
            command.ExecuteNonQuery();
        }
Example #30
0
        /// <summary>
        /// Executes the resource transfers between the source and destination vessels.
        /// </summary>
        public IEnumerator Deliver()
        {
            // If either vessel no longer exists, fail.
            if (Origin == null || Destination == null)
            {
                Status = DeliveryStatus.Failed;
                yield break;
            }

            // If the vessels are no longer in the same SoI, fail.
            if (Origin.mainBody != Destination.mainBody)
            {
                Status = DeliveryStatus.Failed;
                yield break;
            }

            // If either of the vessels is no longer in an allowed situation, fail.
            if (Origin.protoVessel.situation != (Origin.protoVessel.situation & ALLOWED_SITUATIONS) ||
                Destination.protoVessel.situation != (Destination.protoVessel.situation & ALLOWED_SITUATIONS))
            {
                Status = DeliveryStatus.Failed;
                yield break;
            }

            // Exchange resources between origin and destination vessels
            bool   deliveredAll = true;
            double deliveredAmount;
            double precisionTolerance;

            foreach (var request in ResourceRequests)
            {
                // If transfer was cancelled, return resources to origin vessel
                if (Status == DeliveryStatus.Returning)
                {
                    deliveredAmount = Origin.ExchangeResources(request.ResourceDefinition, request.TransferAmount);
                }
                // Otherwise, deliver resources to destination vessel
                else
                {
                    deliveredAmount = Destination.ExchangeResources(request.ResourceDefinition, request.TransferAmount);
                }

                // Because with floating point math, 1 minus 1 doesn't necessarily equal 0.  ^_^
                precisionTolerance = Math.Abs(request.TransferAmount) * 0.001;
                deliveredAll      &= Math.Abs(request.TransferAmount - Math.Abs(deliveredAmount)) <= precisionTolerance;

                yield return(null);
            }

            if (Status == DeliveryStatus.Returning)
            {
                Status = DeliveryStatus.Cancelled;
            }
            else
            {
                Status = deliveredAll ? DeliveryStatus.Delivered : DeliveryStatus.Partial;
            }
        }
Example #31
0
        private async Task <DeliveryViewModel> UpdateDeliveryStatus(int id, DeliveryStatus status)
        {
            var delivery = await deliveryService.GetDeliveryById(id);

            delivery.Status = status;
            delivery        = await deliveryService.UpdateDelivery(delivery);

            return(MakeDeliveryViewModel(delivery));
        }
Example #32
0
 private void UpdateDeliveryStatus(Guid pDeliveryId, DeliveryStatus status)
 {
     using (TransactionScope lScope = new TransactionScope())
     using (VideoStoreEntityModelContainer lContainer = new VideoStoreEntityModelContainer())
     {
         Delivery lDelivery = lContainer.Deliveries.Where((pDel) => pDel.ExternalDeliveryIdentifier == pDeliveryId).FirstOrDefault();
         if (lDelivery != null)
         {
             lDelivery.DeliveryStatus = status;
             lContainer.SaveChanges();
         }
         lScope.Complete();
     }
 }