本文整理汇总了C#中IShipment类的典型用法代码示例。如果您正苦于以下问题:C# IShipment类的具体用法?C# IShipment怎么用?C# IShipment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IShipment类属于命名空间,在下文中一共展示了IShipment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: RateShipment
public List<IShippingRate> RateShipment(IShipment shipment)
{
decimal totalValue = 0;
foreach (IShippable item in shipment.Items)
{
totalValue += item.BoxValue;
}
decimal amount = 0;
if (Settings != null)
{
if (Settings.GetLevels() != null)
{
amount = RateTableLevel.FindRateFromLevels(totalValue, Settings.GetLevels());
}
}
ShippingRate r = new ShippingRate();
r.ServiceId = this.Id;
r.EstimatedCost = amount;
List<IShippingRate> rates = new List<IShippingRate>();
rates.Add(r);
return rates;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:28,代码来源:RateTableByTotalPrice.cs
示例2: RatePackage
public static ShippingRate RatePackage(FedExGlobalServiceSettings globals,
MerchantTribe.Web.Logging.ILogger logger,
FedExServiceSettings settings,
IShipment package)
{
ShippingRate result = new ShippingRate();
// Get ServiceType
ServiceType currentServiceType = ServiceType.FEDEXGROUND;
currentServiceType = (ServiceType)settings.ServiceCode;
// Get PackageType
PackageType currentPackagingType = PackageType.YOURPACKAGING;
currentPackagingType = (PackageType)settings.Packaging;
// Set max weight by service
CarrierCodeType carCode = GetCarrierCode(currentServiceType);
result.EstimatedCost = RateSinglePackage(globals,
logger,
package,
currentServiceType,
currentPackagingType,
carCode);
return result;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:27,代码来源:RateService.cs
示例3: PerformTask
/// <summary>
/// The perform task.
/// </summary>
/// <param name="value">
/// The value.
/// </param>
/// <returns>
/// The <see cref="Attempt"/>.
/// </returns>
public override Attempt<IShipment> PerformTask(IShipment value)
{
Guid orderStatusKey;
// not fulfilled
if (Order.ShippableItems().All(x => ((OrderLineItem)x).ShipmentKey == null))
{
orderStatusKey = Core.Constants.DefaultKeys.OrderStatus.NotFulfilled;
return this.SaveOrderStatus(value, orderStatusKey);
}
if (Order.ShippableItems().Any(x => ((OrderLineItem)x).ShipmentKey == null))
{
orderStatusKey = Core.Constants.DefaultKeys.OrderStatus.Open;
return this.SaveOrderStatus(value, orderStatusKey);
}
// now we need to look at all of the shipments to make sure the shipment statuses are either
// shipped or delivered. If either of those two, we will consider the shipment as 'Fulfilled',
// otherwise the shipment will remain in the open status
var shipmentKeys = Order.ShippableItems().Select(x => ((OrderLineItem)x).ShipmentKey.GetValueOrDefault()).Distinct();
var shipments = _shipmentService.GetByKeys(shipmentKeys);
orderStatusKey =
shipments.All(x =>
x.ShipmentStatusKey.Equals(Core.Constants.DefaultKeys.ShipmentStatus.Delivered)
|| x.ShipmentStatusKey.Equals(Core.Constants.DefaultKeys.ShipmentStatus.Shipped)) ?
Core.Constants.DefaultKeys.OrderStatus.Fulfilled :
Core.Constants.DefaultKeys.OrderStatus.Open;
return this.SaveOrderStatus(value, orderStatusKey);
}
开发者ID:drpeck,项目名称:Merchello,代码行数:40,代码来源:SetOrderStatusTask.cs
示例4: Build
/// <summary>
/// The build.
/// </summary>
/// <param name="shipment">
/// The shipment.
/// </param>
/// <param name="contacts">
/// The collection of contact addresses
/// </param>
/// <returns>
/// The <see cref="IShipmentResultNotifyModel"/>.
/// </returns>
public IShipmentResultNotifyModel Build(IShipment shipment, IEnumerable<string> contacts)
{
var notifyModel = new ShipmentResultNotifyModel()
{
Shipment = shipment,
Contacts = contacts == null ? new string[] { } : contacts.ToArray()
};
var item = shipment.Items.FirstOrDefault(x => !x.ContainerKey.Equals(Guid.Empty));
if (item != null)
{
var orderKey = item.ContainerKey;
var order = _orderService.GetByKey(orderKey);
if (order != null)
{
var invoice = _invoiceService.GetByKey(order.InvoiceKey);
if (invoice != null)
{
notifyModel.Invoice = invoice;
if (invoice.Items.Any())
{
var currencyCode =
invoice.Items.First()
.ExtendedData.GetValue(Core.Constants.ExtendedDataKeys.CurrencyCode);
var currency = _storeSettingService.GetCurrencyByCode(currencyCode);
notifyModel.CurrencySymbol = currency.Symbol;
}
}
}
}
return notifyModel;
}
开发者ID:rustyswayne,项目名称:Merchello,代码行数:47,代码来源:ShipmentResultNotifyModelFactory.cs
示例5: CalculatePrice
public Attempt<IShipmentRateQuote> CalculatePrice(IShipment shipment, IShipMethod shipMethod, decimal totalWeight, int quantity, IShipProvince province)
{
// First sum up the total weight for the shipment.
// We're assumning that a custom order line property
// was set on the order line prior when the product was added to the order line.
var shippingPrice = 0M;
try
{
var service = new RateService {Url = "https://wsbeta.fedex.com:443/web-services/rate"};
var reply = service.getRates(RateRequest(shipment, totalWeight, quantity));
if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
{
var collection = BuildDeliveryOptions(reply, shipment);
var firstCarrierRate = collection.FirstOrDefault(option => option.Service.Contains(shipMethod.ServiceCode.Split('-').First()));
if (firstCarrierRate != null)
shippingPrice = firstCarrierRate.Rate;
}
}
catch (Exception ex)
{
return Attempt<IShipmentRateQuote>.Fail(
new Exception("An error occured during your request : " +
ex.Message +
" Please contact your administrator or try again."));
}
return Attempt<IShipmentRateQuote>.Succeed(new ShipmentRateQuote(shipment, shipMethod) { Rate = shippingPrice });
}
开发者ID:drpeck,项目名称:Merchello,代码行数:33,代码来源:FedExShippingProcessor.cs
示例6: QuoteShipment
public override Attempt<IShipmentRateQuote> QuoteShipment(IShipment shipment)
{
try
{
var visitor = new FoaShipmentLineItemVisitor() { UseOnSalePriceIfOnSale = false };
shipment.Items.Accept(visitor);
if (visitor.TotalPrice >= _processorSettings.Amount)
{
return Attempt<IShipmentRateQuote>.Succeed(new ShipmentRateQuote(shipment, ShipMethod) { Rate = 0 });
}
else
{
// TODO shouldn't this just fail so that a different method is selected or have a configurable default rate.
return Attempt<IShipmentRateQuote>.Succeed(new ShipmentRateQuote(shipment, ShipMethod) { Rate = 100 });
}
}
catch (Exception ex)
{
return Attempt<IShipmentRateQuote>.Fail(
new Exception("An error occured during your request : " +
ex.Message +
" Please contact your administrator or try again."));
}
}
开发者ID:GaryLProthero,项目名称:Merchello,代码行数:26,代码来源:FOAShippingGatewayMethod.cs
示例7: GetRate
public virtual ShippingRate GetRate(IShipment shipment, ShippingMethodInfoModel shippingMethodInfoModel, IMarket currentMarket)
{
var type = Type.GetType(shippingMethodInfoModel.ClassName);
var shippingGateway = (IShippingGateway)Activator.CreateInstance(type, currentMarket);
string message = null;
return shippingGateway.GetRate(shippingMethodInfoModel.MethodId, (Shipment)shipment, ref message);
}
开发者ID:adrian18hd,项目名称:Quicksilver,代码行数:7,代码来源:ShippingManagerFacade.cs
示例8: CalculatePrice
public Attempt<IShipmentRateQuote> CalculatePrice(IShipment shipment, IShipMethod shipMethod, decimal totalWeight, IShipProvince province)
{
// First sum up the total weight for the shipment.
// We're assumning that a custom order line property
// was set on the order line prior when the product was added to the order line.
var shippingPrice = 0M;
try
{
var http = new UpsHttpRequestHandler();
var rateXml = http.Post(RateRequest(shipment, totalWeight));
var collection = UpsParseRates(rateXml);
var firstCarrierRate = collection.FirstOrDefault(option => option.Service == shipMethod.Name);
if (firstCarrierRate != null)
shippingPrice = firstCarrierRate.Rate;
}
catch (Exception ex)
{
return Attempt<IShipmentRateQuote>.Fail(
new Exception("An error occured during your request : " +
ex.Message +
" Please contact your administrator or try again."));
}
return Attempt<IShipmentRateQuote>.Succeed(new ShipmentRateQuote(shipment, shipMethod) { Rate = shippingPrice });
}
开发者ID:drpeck,项目名称:Merchello,代码行数:28,代码来源:UPSShippingProcessor.cs
示例9: RateShipment
public List<IShippingRate> RateShipment(IShipment shipment)
{
int totalItems = 0;
foreach (IShippable item in shipment.Items)
{
totalItems += item.QuantityOfItemsInBox;
}
decimal amountPerItem = 0;
if (Settings != null)
{
if (Settings.GetLevels() != null)
{
amountPerItem = RateTableLevel.FindRateFromLevels(totalItems, Settings.GetLevels());
}
}
ShippingRate r = new ShippingRate();
r.ServiceId = this.Id;
r.EstimatedCost = amountPerItem * totalItems;
List<IShippingRate> rates = new List<IShippingRate>();
rates.Add(r);
return rates;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:28,代码来源:PerItem.cs
示例10: DefaultShipmentRateQuoteStrategy
/// <summary>
/// Initializes a new instance of the <see cref="DefaultShipmentRateQuoteStrategy"/> class.
/// </summary>
/// <param name="shipment">
/// The shipment.
/// </param>
/// <param name="shippingGatewayMethods">
/// The shipping gateway methods.
/// </param>
/// <param name="runtimeCache">
/// The runtime cache.
/// </param>
public DefaultShipmentRateQuoteStrategy(
IShipment shipment,
IShippingGatewayMethod[] shippingGatewayMethods,
IRuntimeCacheProvider runtimeCache)
: base(shipment, shippingGatewayMethods, runtimeCache)
{
}
开发者ID:jlarc,项目名称:Merchello,代码行数:19,代码来源:DefaultShipmentRateQuoteStrategy.cs
示例11: CloneAddressesFromInterface
public static Shipment CloneAddressesFromInterface(IShipment source)
{
Shipment result = new Shipment();
result.DestinationAddress = MerchantTribe.Web.Geography.SimpleAddress.CloneAddress(source.DestinationAddress);
result.SourceAddress = MerchantTribe.Web.Geography.SimpleAddress.CloneAddress(source.SourceAddress);
return result;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:7,代码来源:Shipment.cs
示例12: GetUPSRatesForShipment
// Gets all rates filtered by service settings
private List<IShippingRate> GetUPSRatesForShipment(IShipment shipment)
{
List<IShippingRate> rates = new List<IShippingRate>();
List<IShippingRate> allrates = GetAllShippingRatesForShipment(shipment);
// Filter all rates by just the ones we want
List<IServiceCode> codefilters = this.Settings.ServiceCodeFilter;
foreach (IShippingRate rate in allrates)
{
if (this.Settings.GetAllRates || codefilters.Count < 1)
{
rates.Add(rate);
continue;
}
else
{
if (codefilters.Where(y => y.Code == (rate.ServiceCodes.TrimStart('0'))).Count() > 0)
{
rates.Add(rate);
continue;
}
}
}
return rates;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:28,代码来源:UPSService.cs
示例13: PerformTask
/// <summary>
/// The perform task.
/// </summary>
/// <param name="value">
/// The value.
/// </param>
/// <returns>
/// The <see cref="Attempt"/>.
/// </returns>
public override Attempt<IShipment> PerformTask(IShipment value)
{
var trackableItems = Order.InventoryTrackedItems().Where(x => KeysToShip.Contains(x.Key)).ToArray();
var variants = _productVariantService.GetByKeys(trackableItems.Select(x => x.ExtendedData.GetProductVariantKey())).ToArray();
if (variants.Any())
{
foreach (var item in trackableItems)
{
var variant = variants.FirstOrDefault(x => x.Key == item.ExtendedData.GetProductVariantKey());
if (variant == null) return Attempt<IShipment>.Fail(new NullReferenceException("A ProductVariant reference in the order could not be found"));
var inventory = variant.CatalogInventories.FirstOrDefault(x => x.CatalogKey == item.ExtendedData.GetWarehouseCatalogKey());
if (inventory == null) return Attempt<IShipment>.Fail(new NullReferenceException("An inventory record could not be found for an order line item"));
inventory.Count -= item.Quantity;
}
if (trackableItems.Any()) _productVariantService.Save(variants);
}
// persist the shipment and update the line items
if (value.ShipMethodKey == Guid.Empty) value.ShipMethodKey = null;
_shipmentService.Save(value);
return Attempt<IShipment>.Succeed(value);
}
开发者ID:drpeck,项目名称:Merchello,代码行数:37,代码来源:RemoveShipmentOrderItemsFromInventoryAndPersistShipmentTask.cs
示例14: PerformTask
public override Attempt<IShipment> PerformTask(IShipment value)
{
return Order.ShippableItems().All(x => ((OrderLineItem)x).ShipmentKey == null)
? SaveOrderStatus(value, Constants.DefaultKeys.OrderStatus.NotFulfilled)
: SaveOrderStatus(value, Order.ShippableItems().All(x => ((OrderLineItem) x).ShipmentKey != null)
? Constants.DefaultKeys.OrderStatus.Fulfilled
: Constants.DefaultKeys.OrderStatus.BackOrder);
}
开发者ID:VDBBjorn,项目名称:Merchello,代码行数:8,代码来源:SetOrderStatusTask.cs
示例15: ShipmentRateQuoteStrategyBase
/// <summary>
/// Initializes a new instance of the <see cref="ShipmentRateQuoteStrategyBase"/> class.
/// </summary>
/// <param name="shipment">
/// The shipment.
/// </param>
/// <param name="shippingGatewayMethods">
/// The shipping gateway methods.
/// </param>
/// <param name="runtimeCache">
/// The runtime cache.
/// </param>
protected ShipmentRateQuoteStrategyBase(IShipment shipment, IShippingGatewayMethod[] shippingGatewayMethods, IRuntimeCacheProvider runtimeCache)
{
Mandate.ParameterNotNull(shipment, "shipment");
Mandate.ParameterNotNull(shippingGatewayMethods, "gatewayShipMethods");
Mandate.ParameterNotNull(runtimeCache, "runtimeCache");
_shipment = shipment;
_shippingGatewayMethods = shippingGatewayMethods;
_runtimeCache = runtimeCache;
}
开发者ID:rustyswayne,项目名称:Merchello,代码行数:22,代码来源:ShipmentRateQuoteStrategyBase.cs
示例16: SaveOrderStatus
private Attempt<IShipment> SaveOrderStatus(IShipment shipment, Guid orderStatusKey)
{
var orderStatus = _orderService.GetOrderStatusByKey(orderStatusKey);
if (orderStatus == null) return Attempt<IShipment>.Fail(new NullReferenceException("Order status was not found"));
Order.OrderStatus = orderStatus;
_orderService.Save(Order);
return Attempt<IShipment>.Succeed(shipment);
}
开发者ID:VDBBjorn,项目名称:Merchello,代码行数:11,代码来源:SetOrderStatusTask.cs
示例17: RateShipment
public List<IShippingRate> RateShipment(IShipment shipment)
{
ShippingRate r = new ShippingRate();
r.ServiceId = this.Id;
r.EstimatedCost = Settings.Amount;
List<IShippingRate> rates = new List<IShippingRate>();
rates.Add(r);
return rates;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:11,代码来源:FlatRatePerOrder.cs
示例18: ShipmentHasAddresses
public bool ShipmentHasAddresses(IShipment shipment)
{
if (shipment.SourceAddress == null)
{
return false;
}
if (shipment.DestinationAddress == null)
{
return false;
}
return true;
}
开发者ID:appliedi,项目名称:MerchantTribe,代码行数:12,代码来源:DomesticProvider.cs
示例19: ShipmentRateQuote
/// <summary>
/// Initializes a new instance of the <see cref="ShipmentRateQuote"/> class.
/// </summary>
/// <param name="shipment">
/// The shipment.
/// </param>
/// <param name="shipMethod">
/// The ship method.
/// </param>
/// <param name="extendedData">
/// The extended data.
/// </param>
public ShipmentRateQuote(IShipment shipment, IShipMethod shipMethod, ExtendedDataCollection extendedData)
{
Mandate.ParameterNotNull(shipment, "shipment");
Mandate.ParameterNotNull(shipMethod, "shipMethod");
Mandate.ParameterNotNull(extendedData, "extendedData");
shipment.ShipMethodKey = shipMethod.Key;
Shipment = shipment;
ShipMethod = shipMethod;
ExtendedData = extendedData;
}
开发者ID:arknu,项目名称:Merchello,代码行数:24,代码来源:ShipmentRateQuote.cs
示例20: QuoteShipment
public override Attempt<IShipmentRateQuote> QuoteShipment(IShipment shipment)
{
try
{
// TODO this should be made configurable
var visitor = new FedExShipmentLineItemVisitor() { UseOnSalePriceIfOnSale = false };
shipment.Items.Accept(visitor);
var province = ShipMethod.Provinces.FirstOrDefault(x => x.Code == shipment.ToRegion);
var shippingPrice = 0M;
try
{
var service = new RateService { Url = "https://wsbeta.fedex.com:443/web-services/rate" };
var collection = GetCollectionFromCache(shipment);
if (collection == null)
{
var reply = service.getRates(RateRequest(shipment, visitor.TotalWeight, visitor.Quantity));
if (reply.HighestSeverity == NotificationSeverityType.SUCCESS || reply.HighestSeverity == NotificationSeverityType.NOTE || reply.HighestSeverity == NotificationSeverityType.WARNING)
{
collection = BuildDeliveryOptions(reply, shipment);
_runtimeCache.InsertCacheItem(MakeCacheKey(shipment), () => collection);
}
}
var firstCarrierRate = collection.FirstOrDefault(option => option.Service.Contains(_shipMethod.ServiceCode));
if (firstCarrierRate != null)
shippingPrice = firstCarrierRate.Rate;
}
catch (Exception ex)
{
return Attempt<IShipmentRateQuote>.Fail(
new Exception("An error occured during your request : " +
ex.Message +
" Please contact your administrator or try again."));
}
return Attempt<IShipmentRateQuote>.Succeed(new ShipmentRateQuote(shipment, _shipMethod) { Rate = shippingPrice });
}
catch (Exception ex)
{
return Attempt<IShipmentRateQuote>.Fail(
new Exception("An error occured during your request : " +
ex.Message +
" Please contact your administrator or try again."));
}
}
开发者ID:arknu,项目名称:Merchello,代码行数:53,代码来源:FedExShippingGatewayMethod.cs
注:本文中的IShipment类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论