本文整理汇总了C#中Order.AddTracking方法的典型用法代码示例。如果您正苦于以下问题:C# Order.AddTracking方法的具体用法?C# Order.AddTracking怎么用?C# Order.AddTracking使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.AddTracking方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateTestOrders
/// <summary>
/// Incomplete generation of a finite set of order information
/// </summary>
/// <param name="workgroup"></param>
/// <param name="statusCodes"></param>
/// <param name="session"></param>
/// <returns></returns>
private static List<Order> GenerateTestOrders(Workgroup workgroup, List<OrderStatusCode> statusCodes, ISession session )
{
var orders = new List<Order>();
var requester = statusCodes.Where(a => a.Id == "RQ").First();
var approver = statusCodes.Where(a => a.Id == "AP").First();
var conditional = statusCodes.Where(a => a.Id == "CA").First();
var accountmgr = statusCodes.Where(a => a.Id == "AM").First();
var purchaser = statusCodes.Where(a => a.Id == "PR").First();
var completed = statusCodes.Where(a => a.Id == "CP").First();
var requester1 = workgroup.Permissions.Where(a => a.User.Id == "pjfry").First();
var requester2 = workgroup.Permissions.Where(a => a.User.Id == "moe").First();
var requester3 = workgroup.Permissions.Where(a => a.User.Id == "bender").First();
var approver1 = workgroup.Permissions.Where(a => a.User.Id == "hsimpson").First();
var approver2 = workgroup.Permissions.Where(a => a.User.Id == "zoidberg").First();
var approver3 = workgroup.Permissions.Where(a => a.User.Id == "burns").First();
var accountmgr1 = workgroup.Permissions.Where(a => a.User.Id == "brannigan").First();
var accountmgr2 = workgroup.Permissions.Where(a => a.User.Id == "flanders").First();
var purchaser1 = workgroup.Permissions.Where(a => a.User.Id == "awong").First();
var purchaser2 = workgroup.Permissions.Where(a => a.User.Id == "grimes").First();
// create the aprover level orders
var order = new Order() { Workgroup = workgroup, Organization = workgroup.PrimaryOrganization, StatusCode = approver, CreatedBy = requester1.User };
order.AddTracking(new OrderTracking(){DateCreated = DaysBack(), User = requester1.User, Description = "n/a"});
order.AddApproval(new Approval() { Completed = true, User = requester1.User, StatusCode = requester });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = approver });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = accountmgr });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = purchaser });
orders.Add(order);
order = new Order() { Workgroup = workgroup, Organization = workgroup.PrimaryOrganization, StatusCode = approver, CreatedBy = requester1.User };
order.AddTracking(new OrderTracking() { DateCreated = DaysBack(), User = requester1.User, Description = "n/a" });
order.AddApproval(new Approval() { Completed = true, User = requester1.User, StatusCode = requester });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = approver });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = accountmgr });
order.AddApproval(new Approval() { Completed = false, User = requester1.User, StatusCode = purchaser });
orders.Add(order);
return orders;
}
示例2: GenderateRandomOrder
/// <summary>
/// Generate Random orders
/// </summary>
/// <param name="users">List of users to select from</param>
/// <param name="vendors">List of vendors to select from</param>
/// <param name="statusCode">Status code to set the order approved through</param>
/// <returns></returns>
private static Order GenderateRandomOrder(Workgroup workgroup, OrderStatusCode statusCode, ISession session, WorkgroupPermission user = null, WorkgroupPermission excludeUser = null )
{
var randomizedPerms = workgroup.Permissions.Select(a => new {Permission = a, Key = Guid.NewGuid()});
var requester = user ?? (excludeUser == null ?
randomizedPerms.Where(a=>a.Permission.Role.Id == "RQ").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault()
: randomizedPerms.Where(a=>a.Permission.Role.Id == "RQ" && a.Permission != excludeUser).OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault());
var approver = randomizedPerms.Where(a => a.Permission.Role.Id == "AP" && a.Permission.User.Id !="zoidberg").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var conditionalApprover = session.Load<User>("zoidberg"); //workgroup.Permissions.Where(a => a.User.Id == "zoidberg").FirstOrDefault();
var accountmgr = randomizedPerms.Where(a => a.Permission.Role.Id == "AM").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var purchaser = randomizedPerms.Where(a => a.Permission.Role.Id == "PR").OrderBy(a => a.Key).Select(a => a.Permission).FirstOrDefault();
var order = new Order()
{
Justification = _justifications.Skip(_random.Next() % 5).Take(1).FirstOrDefault(),
OrderType = session.Load<OrderType>("OR"),
Workgroup = workgroup,
Organization = workgroup.PrimaryOrganization,
Vendor = workgroup.Vendors.Skip(_random.Next() % workgroup.Vendors.Count).Take(1).FirstOrDefault(),
Address = workgroup.Addresses.Skip(_random.Next() % workgroup.Addresses.Count).Take(1).FirstOrDefault(),
ShippingType = session.QueryOver<ShippingType>().Skip(_random.Next() % 3).Take(1).SingleOrDefault(),
DeliverTo = "Mr. Smith",
DateNeeded = DateTime.Now.AddDays(_random.Next() % 30),
AllowBackorder = _random.Next() % 2 == 1,
EstimatedTax = 8.89m,
CreatedBy = requester.User,
StatusCode = statusCode
};
order.GenerateRequestNumber();
// add the tracking
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("RQ"), Completed = true, User = requester.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("AP"), Completed = statusCode.Level > 2 , User = approver.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("AM"), Completed = statusCode.Level > 3 , User = accountmgr.User });
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("PR"), Completed = statusCode.Level > 4 , User = purchaser.User });
// add the approvals
var daysBack = ((-1)*(_random.Next()%10)) - 10;
order.AddTracking(new OrderTracking() { User = requester.User, DateCreated = DateTime.Now.AddDays(daysBack), Description = "Order submitted by " + requester.User.FullName, StatusCode = session.Load<OrderStatusCode>("RQ") });
if (statusCode.Level > 2)
{
order.AddTracking(new OrderTracking() { User = approver.User, DateCreated = DateTime.Now.AddDays(daysBack + 1), Description = "Order reviewed by " + approver.User.FullName, StatusCode = session.Load<OrderStatusCode>("AP") });
}
if (statusCode.Level > 3)
{
order.AddTracking(new OrderTracking() { User = accountmgr.User, DateCreated = DateTime.Now.AddDays(daysBack + 3), Description = "Order reviewed by " + accountmgr.User.FullName, StatusCode = session.Load<OrderStatusCode>("AM") });
}
if (statusCode.Level > 4)
{
order.AddTracking(new OrderTracking() { User = purchaser.User, DateCreated = DateTime.Now.AddDays(daysBack + (_random.Next() % 4)+3), Description = "Order reviewed by " + purchaser.User.FullName, StatusCode = session.Load<OrderStatusCode>("PR") });
order.AddTracking(new OrderTracking() { User = purchaser.User, DateCreated = DateTime.Now.AddDays(daysBack + (_random.Next() % 4)+8), Description = "Order marked complete by " + purchaser.User.FullName, StatusCode = session.Load<OrderStatusCode>("CN") });
}
// add the conditional stuff if we feel like it
if (_random.Next() % 2 == 1)
{
order.AddApproval(new Approval() { StatusCode = session.Load<OrderStatusCode>("CA"), Completed = statusCode.Level > 2 , User = conditionalApprover });
if (statusCode.Level > 2)
{
order.AddTracking(new OrderTracking() { User = conditionalApprover, DateCreated = DateTime.Now.AddDays(daysBack + 2), Description = "Order reviewed by " + conditionalApprover.FullName, StatusCode = session.Load<OrderStatusCode>("AP") });
}
}
// add the line items
var numLineItems = (_random.Next()%5) + 1; // minimum of 1 line item
for (var i = 0; i < numLineItems; i++)
{
var item = _items.Skip(_random.Next()%_items.Count()).Take(1).FirstOrDefault();
order.AddLineItem(new LineItem() { Quantity = _random.Next() % 10, UnitPrice = item.Value + (item.Value * ((_random.Next() % 10)+1 / 10)), Unit = "each", Description = item.Key });
}
// account information
var splitType = _random.Next()%2;
if (splitType == 1) {
var numSplits = _random.Next()%2;
var skip = _random.Next()%18;
var accounts = session.QueryOver<Account>().Skip(skip+numSplits>=18 ? 18-numSplits : skip).Take(numSplits);
foreach (var act in accounts.List())
{
order.AddSplit(new Split(){Account = act.Id, Amount = order.Total()/numSplits});
}
}
// set shipping
//.........这里部分代码省略.........