本文整理汇总了C#中Common.List.Select方法的典型用法代码示例。如果您正苦于以下问题:C# List.Select方法的具体用法?C# List.Select怎么用?C# List.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Common.List
的用法示例。
在下文中一共展示了List.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
public static void Initialize(HttpConfiguration config)
{
var builder = new ContainerBuilder();
//some base interface register
//like dbcontext IRespository
IList<Assembly> assemblies = new List<Assembly>()
{
Assembly.Load("BaseService"),
Assembly.Load("SystematicWebApi")
};
var types = new List<Type>();
foreach (var item in assemblies)
{
types.AddRange(item.DefinedTypes.Where(o => typeof(IDependenceRegister).IsAssignableFrom(o)));
}
var registers = types.Select(type =>
type.Assembly.CreateInstance(type.FullName) as IDependenceRegister).ToList();
registers = registers.OrderBy(o => o.Order()).ToList();
foreach (var register in registers)
{
register.Register(builder);
}
var assembly = Assembly.GetCallingAssembly();
builder.RegisterApiControllers(assembly);
var container = builder.Build();
config.DependencyResolver = new AutofacWebApiDependencyResolver(container);
//DependencyResolver.SetResolver(new AutofacWebApiDependencyResolver(container));
}
示例2: SetRoots
internal void SetRoots(List<string> _rootPaths)
{
Debug.Assert(_rootPaths != null);
Roots = _rootPaths.Select(rootPath => new DirectoryInfo(rootPath)).ToList();
Update();
}
示例3: AddMostRecentEvent
public async Task AddMostRecentEvent()
{
ServiceCancellation cancelSource = new ServiceCancellation(CancellationToken.None);
MockReliableStateManager stateManager = new MockReliableStateManager();
IReliableDictionary<string, DeviceEvent> store =
await stateManager.GetOrAddAsync<IReliableDictionary<string, DeviceEvent>>(DataService.EventDictionaryName);
IReliableQueue<DeviceEventSeries> queue =
await stateManager.GetOrAddAsync<IReliableQueue<DeviceEventSeries>>(DataService.EventQueueName);
string expectedDeviceId = "some-device";
List<DeviceEvent> expectedDeviceList = new List<DeviceEvent>();
DeviceEvent expectedDeviceEvent = new DeviceEvent(new DateTimeOffset(100, TimeSpan.Zero));
for (int i = 0; i < 10; ++i)
{
expectedDeviceList.Add(new DeviceEvent(new DateTimeOffset(i, TimeSpan.Zero)));
}
expectedDeviceList.Insert(4, expectedDeviceEvent);
EventsController target = new EventsController(stateManager, statefulServiceContext, cancelSource);
IActionResult result = await target.Post(expectedDeviceId, expectedDeviceList);
Assert.True(result is OkResult);
using (ITransaction tx = stateManager.CreateTransaction())
{
ConditionalValue<DeviceEvent> actualStoredEvent = await store.TryGetValueAsync(tx, expectedDeviceId);
ConditionalValue<DeviceEventSeries> actualQueuedEvent = await queue.TryDequeueAsync(tx);
Assert.True(actualStoredEvent.HasValue);
Assert.Equal(expectedDeviceEvent.Timestamp, actualStoredEvent.Value.Timestamp);
Assert.True(actualQueuedEvent.HasValue);
Assert.True(actualQueuedEvent.Value.Events.Select(x => x.Timestamp).SequenceEqual(expectedDeviceList.Select(x => x.Timestamp)));
await tx.CommitAsync();
}
}
示例4: InitInheritanceMapping
internal void InitInheritanceMapping()
{
var mappingAttrs = _mappingSchema.GetAttributes<InheritanceMappingAttribute>(ObjectType, a => a.Configuration, false);
InheritanceMapping = new List<InheritanceMapping>(mappingAttrs.Length);
if (mappingAttrs.Length > 0)
{
foreach (var m in mappingAttrs)
{
var mapping = new InheritanceMapping
{
Code = m.Code,
IsDefault = m.IsDefault,
Type = m.Type,
};
var ed = _mappingSchema.GetEntityDescriptor(mapping.Type);
foreach (var column in ed.Columns)
{
if (Columns.All(f => f.MemberName != column.MemberName))
Columns.Add(column);
if (column.IsDiscriminator)
mapping.Discriminator = column;
}
InheritanceMapping.Add(mapping);
}
var discriminator = InheritanceMapping.Select(m => m.Discriminator).FirstOrDefault(d => d != null);
if (discriminator == null)
throw new LinqException("Inheritance Discriminator is not defined for the '{0}' hierarchy.", ObjectType);
foreach (var mapping in InheritanceMapping)
if (mapping.Discriminator == null)
mapping.Discriminator = discriminator;
}
}
示例5: WorkflowToStoreLibraryAndActivitiesRequestDC
/// <summary>
/// Take a WorkflowItem and the computed list of ActivityAssemblyItems it depends on and translate them into DC form for an upload
/// </summary>
/// <param name="workflow"></param>
/// <param name="assemblyItemsUsed">Assemblies list (computed by WorkflowUploader.ComputeDependencies())</param>
/// <returns></returns>
public static StoreLibraryAndActivitiesRequestDC WorkflowToStoreLibraryAndActivitiesRequestDC(WorkflowItem workflow, IEnumerable<ActivityAssemblyItem> assemblyItemsUsed, List<TaskAssignment> tasks)
{
string libraryName = workflow.Name;
var library = GetActivityLibraryDC(libraryName, workflow.Category, workflow.Description, workflow.CreatedBy, workflow.Version, workflow.Status);
var dependencyList = new List<StoreActivityLibraryDependenciesGroupsRequestDC>(
assemblyItemsUsed.Select(asm => new StoreActivityLibraryDependenciesGroupsRequestDC
{
Name = asm.Name,
Version = asm.Version.ToString(),
}.SetIncaller())
);
return new StoreLibraryAndActivitiesRequestDC
{
Incaller = Utility.GetCallerName(),
IncallerVersion = Utility.GetCallerVersion(),
InInsertedByUserAlias = !String.IsNullOrEmpty(workflow.CreatedBy) ? workflow.CreatedBy : Utility.GetCurrentUserName(),
InUpdatedByUserAlias = Utility.GetCurrentUserName(),
EnforceVersionRules = true,
ActivityLibrary = library,
StoreActivitiesList = new List<StoreActivitiesDC> {
// There is only one activity in this "library", = the workflow itself
ActivityItemToStoreActivitiyDC(workflow)
},
StoreActivityLibraryDependenciesGroupsRequestDC = new StoreActivityLibraryDependenciesGroupsRequestDC()
{
Name = libraryName,
Version = workflow.Version,
List = dependencyList
}.SetIncaller(),
TaskActivitiesList = tasks.Select(t => new StoreLibraryAndTaskActivityRequestDC()
{
EnforceVersionRules = true,
ActivityLibrary = GetActivityLibraryDC(t.GetFriendlyName(workflow.Name), workflow.Category, workflow.Description, workflow.CreatedBy, t.Version, workflow.Status),
StoreActivityLibraryDependenciesGroupsRequestDC = new StoreActivityLibraryDependenciesGroupsRequestDC()
{
Name = t.GetFriendlyName(workflow.Name),
Version = t.Version,
List = dependencyList
},
TaskActivitiesList = new List<TaskActivityDC>()
{
new TaskActivityDC()
{
Guid = t.TaskId,
AssignedTo = t.AssignTo,
Activity = ActivityItemToStoreActivitiyDC(workflow, t),
Status = t.TaskStatus == TaskActivityStatus.Unassigned ? TaskActivityStatus.Unassigned : TaskActivityStatus.Assigned,
}
}
}.SetIncaller()).ToList()
};
}
示例6: Index
public ActionResult Index(string keywords, bool? finish, int pageIndex = 1, int pageSize = 10)
{
var model = _iProjectInfoService.GetAll(a => a.ProjectUsers.Any(b => b.SysUserId == _iUserInfo.UserId && b.Leader));
if (!string.IsNullOrEmpty(keywords))
{
model =
model.Where(
a =>
a.ProjectName.Contains(keywords) || a.ProjectObjective.Contains(keywords) ||
a.Tag.Contains(keywords) || a.ProjectUsers.Any(b => b.SysUser.UserName == keywords));
}
if (finish.HasValue)
{
model = model.Where(a => a.Finish == finish);
}
//子项目
var subModel = model.Where(a => a.LastProjectInfoId != null);
//主项目
var mainModel = model.Where(a => a.LastProjectInfoId == null).ToPagedList(pageIndex, pageSize);
var mainList = new List<ProjectInfo>() { };
foreach (var item in mainModel)
{
mainList.Add(item);
mainList.AddRange((subModel as IQueryable<ProjectInfo>).Where(a => a.LastProjectInfoId == item.Id));
}
var result = mainList.Select(
a => new
{
a.Id,
a.UserId,
Leader = a.ProjectUsers != null ? a.ProjectUsers.Where(b => b.Leader).Select(b => b.SysUser.DisplayName) : null,
ProjectInfoState = a.ProjectInfoState != null ? a.ProjectInfoState.ProjectInfoStateName : null,
Follow = a.Public && (a.ProjectUsers != null ? a.ProjectUsers.Any(b => b.SysUserId == _iUserInfo.UserId && b.Follow) : false),
a.LastProjectInfoId,
a.Raty,
a.Public,
PlanCount = a.Plans.Count(p => !p.Deleted),
TaskCount = a.ProjectTasks.Count(t => !t.Deleted),
ReplyCount = a.ProjectInfoReplys.Count(r => !r.Deleted),
MemberCount = a.ProjectUsers != null ? a.ProjectUsers.Count(b => !b.Follow) : 0,
a.CustomerId,
a.Tag,
a.StarTime,
a.EndTime,
a.Finish,
a.ProjectName,
a.ProjectObjective,
a.CreatedDate
});
return Content(JsonConvert.SerializeObject(result));
}
示例7: FetchAvailablePublishedProcesses
public IPagedList<PublishedProcessInfoDTO> FetchAvailablePublishedProcesses(string filter, int pageNumber, int pageSize, string filterExpression, bool isAdmin, IEnumerable<int> personRoles)
{
var result = new PagedList<PublishedProcessInfoDTO>();
var roles = new List<int> { Constants.AllRolesId };
if (personRoles != null)
{
roles.AddRange(personRoles);
}
var rolesString = string.Join(",", roles.Select(r => r.ToString(CultureInfo.InvariantCulture)));
var adminFilter = string.Format(
CultureInfo.InvariantCulture,
@"WHERE ISNULL(p.[IsRemoved], 0) = 0 AND ISNULL(p.IsInactive, 0) = 0");
const string NonAdminFilterFormat = @"
WHERE
(
EXISTS
(
SELECT nisc.[Id]
FROM [dbo].[NavigationItemSecurityConfigurations] nisc
WHERE nisc.[NavigationItemId] = ni.Id AND nisc.[CanView] = 1 AND nisc.[RoleId] IN ({0})
)
AND
ISNULL(p.[IsRemoved], 0) = 0 AND ISNULL(p.IsInactive, 0) = 0
)
OR
ng.[SystemName] = '{1}'
";
var nonAdminFilter = string.Format(
CultureInfo.InvariantCulture,
NonAdminFilterFormat,
rolesString,
Constants.AdminMenu);
var whereString = isAdmin ? adminFilter : nonAdminFilter;
const string IdsQueryFormat = @"
SELECT
pp.[ProcessId]
FROM
[dbo].[NavigationGroups] ng
INNER JOIN [dbo].[NavigationItems] ni
ON ng.[Id] = ni.[NavigationGroupId]
INNER JOIN [dbo].[PublishedProcesses] pp
ON pp.[Id] = ni.[PublishedProcessId]
INNER JOIN [dbo].[Processes] p
ON p.[Id] = pp.[ProcessId]
{0}";
var idsQuery = string.Format(
CultureInfo.InvariantCulture,
IdsQueryFormat,
whereString);
using (var ctx = ConnectionManager<SqlConnection>.GetManager(Database.VeyronMeta, false))
{
var cn = ctx.Connection;
const string Sql =
@"
DECLARE @p0 AS INT
SET @p0 = {1}
DECLARE @p1 AS INT
SET @p1 = {2};
SELECT [t1].[Id],
[t1].[Name],
[t1].[SystemName],
[t1].[IconId],
[t1].[Guid]
FROM (
SELECT ROW_NUMBER() OVER(ORDER BY [t0].[Name], [t0].[Id]) AS
[ROW_NUMBER],
ISNULL(pl.ProcessName,[t0].[Name]) AS [Name],
[t0].SystemName,
[t0].[Guid],
[t0].Id,
[i].Id as IconId
FROM [dbo].[Processes] AS [t0]
JOIN [dbo].PublishedProcesses AS [t1] ON [t1].ProcessId = [t0].Id
INNER JOIN Processes p2 ON [t0].Guid = p2.Guid AND p2.IsPublishedCopy = 0
LEFT OUTER JOIN Icons i ON [t0].IconId = [i].Id
LEFT OUTER JOIN Colors c ON [t0].ColorId = [c].Id
LEFT OUTER JOIN dbo.Localizations l ON l.CultureName = '{3}'
LEFT OUTER JOIN dbo.ProcessLocalizations pl ON pl.LocalizationId = l.Id AND p2.Id = pl.ProcessId
{0}
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY
[t1].[ROW_NUMBER]
";
var fieldFilterWhere = AdoHelper.BuildFilterStatement(FilterDescriptor.GetFilterList(filterExpression), "Processes", tableAlias: "[t0]");
var globalFilterWhere = AdoHelper.BuildFilterStatement(filter, new[] { "[t0].Name" });
var where = string.Format(CultureInfo.InvariantCulture, "WHERE [t0].IsRemoved = 0 {0} {1} AND [t1].[ProcessId] IN ({2})", globalFilterWhere, fieldFilterWhere, idsQuery);
if (pageSize == 0)
{
//.........这里部分代码省略.........
示例8: SetScenarioOrder
private static void SetScenarioOrder(int scenarioIndex, List<MethodForScenario> tempselectedMethods)
{
List<ScenarioOrder> scOrder = tempselectedMethods.Select((t, si) => new ScenarioOrder()
{
MethodName = t.MethodName,
MethodGuid = t.MethodGuid,
AssemblyGuid = t.AssemblyGuid,
IsRest = t.IsRest,
Order = si
}).ToList();
Test.TestPackage.Scenarios.ElementAt(scenarioIndex).ScenarioOrder = scOrder;
}
示例9: DeleteFinishedWorkflows
public void DeleteFinishedWorkflows(ref List<Tuple<string, IEnumerable<ActiveEstimatedTask>, IEnumerable<EstimatedTask>, IEnumerable<TasksDepenendency>>> wfs)
{
try
{
List<string> keysToRemove = new List<string>();
// if workflow was already scheduled, but it is not active now (actually, it means that it is finished)
// we remove it from the list
// logger.Info("Scheduled wf ids: ");
foreach (var scheduled in _scheduledWfs)
{
// find count of finished tasks
var finished = finishedTasks.Select(w => w.Item1 == wfIDs[scheduled.Key]).ToList();
int finishedCount = 0;
foreach (var v in finished)
{
if (v) finishedCount++;
}
// if count of finished tasks is equal to total tasks count
if (finishedCount == tasksCount[scheduled.Key])
keysToRemove.Add(scheduled.Key);
else
{
//logger.Info(scheduled.Key);
var ids = wfs.Select(w => w.Item1 == scheduled.Key);
if (!ids.Contains(true))
keysToRemove.Add(scheduled.Key);
// delete tasks
}
}
// logger.Info("Keys to remove: ");
for (int i = 0; i < keysToRemove.Count; i++ )
{
var key = keysToRemove[i];
//logger.Info("Key to remove: " + key);
//logger.Info(key);
if (_scheduledWfs.ContainsKey(key))
_scheduledWfs.Remove(key);
//logger.Info("_scheduledWF success");
if (schedule.ContainsKey(wfIDs[key]))
schedule.Remove(wfIDs[key]);
//logger.Info("schedule success");
int wfID = wfIDs[key];
// find all tasks of workflow to remove
var tasks = taskIDs.Where(t => t.Value.Item1 == wfID).ToList();
for (var j = 0; j < tasks.Count(); j++ )
{
var keyToRemove = tasks[j].Key;
taskIDs.Remove(keyToRemove);
}
if (wfIDs.ContainsKey(key))
wfIDs.Remove(key);
//logger.Info("wfIDs success");
}
}
catch (Exception ex)
{
logger.ErrorException("DeleteFinishedWorkflows() error. " + ex.Message, ex);
}
}
示例10: AskForCompetitors
public void AskForCompetitors(string gameTypeName, List<ICompetitor> emptyCompetitors)
{
IsPlayButtonAvailable = false;
OutputText += string.Format("Waiting for players ({0})\n", emptyCompetitors.Count);
Task.Run(() =>
{
var competitorsTasks = emptyCompetitors.Select(async bot =>
{
try
{
await bot.VerifyAsync(gameTypeName);
lock (_lock)
{
OutputText += string.Format("Bot \"{0}\" connected!\n", bot.Name);
Elimination.Bots.First(f => f.Id == bot.Id).Name = bot.Name;
}
}
catch (Exception e)
{
bot.Name = "Not connected";
OutputText += string.Format("ERROR: Url: {0} - couldn't verify bot!\nError message:\n{1}\n", bot.Url, e.Message);
}
return bot;
}).ToList();
Task.WhenAll(competitorsTasks).ContinueWith(task =>
{
IsPlayButtonAvailable = true;
if (emptyCompetitors.All(competitor => competitor.IsVerified))
{
OutputText += "All players connected!\n";
}
else
{
OutputText += "WARNING: Not all players were succesfully verified.\nTry reconnecting or play tournament without them\n";
}
});
});
}
示例11: FileViewerViewModel_SelectionChanged
private void FileViewerViewModel_SelectionChanged(object sender, List<FileRowViewModel> e)
{
if (sender == FileViewers[0])
{
var fileNames = e.Select(file => file.FileInfo.FullName);
var list = new ObservableRangeCollection<string>(fileNames);
RenamerViewModel.InputItems = list;
}
}
示例12: SalesByCountryItem
public ActionResult SalesByCountryItem(DateTime date)
{
if (!GlobalUtilities.VerifySqlTableExists(GlobalSettings.Exigo.Api.Sql.ConnectionStrings.SqlReporting, "Custom_DailyItemSalesbyCountry"))
{
return new JsonNetResult(new
{
success = false,
error = "Report not configured"
});
}
ViewBag.Date = date;
ViewBag.BeginningOfMonthDate = new DateTime(date.Year, date.Month, 1);
ViewBag.BeginningOfYearDate = new DateTime(date.Year, 1, 1);
var webCategoryItems = new List<WebCategoryItem>();
var itemSales = new List<ItemSalesRecord>();
var itemRefunds = new List<ItemSalesRecord>();
using (var context = Exigo.Sql())
{
var data = context.QueryMultiple(@"
set transaction isolation level read uncommitted
-- Categories
select
Category = wc.WebCategoryDescription,
i.ItemCode
from WebCategoryItems wci
inner join Items i
on i.ItemID = wci.ItemID
inner join WebCategories wc
on wc.WebCategoryID = wci.WebCategoryID
and wc.WebID = wci.WebID
where
wci.WebID = 1
and wc.ParentID = 77
order by
wc.SortOrder,
wci.SortOrder
-- Sales
Select
i.ItemDescription AS ItemDescription,
i.ItemCode AS ItemCode,
Country,
COALESCE(QuantityPerDay, 0) as QuantityPerDay,
COALESCE(AmountPerDay, 0) as AmountPerDay,
COALESCE(TaxPerDay, 0) as TaxPerDay,
COALESCE(TotalPerDay, 0) as TotalPerDay,
COALESCE(QuantityPerMonth, 0) as QuantityPerMonth,
COALESCE(AmountPerMonth, 0) as AmountPerMonth,
COALESCE(TaxPerMonth, 0) as TaxPerMonth,
COALESCE(TotalPerMonth, 0) as TotalPerMonth,
COALESCE(QuantityPerYear, 0) as QuantityPerYear,
COALESCE(AmountPerYear, 0) as AmountPerYear,
COALESCE(TaxPerYear, 0) as TaxPerYear,
COALESCE(TotalPerYear, 0) as TotalPerYear,
COALESCE(QuantityPerLastYear, 0) as QuantityPerLastYear,
COALESCE(AmountPerLastYear, 0) as AmountPerLastYear,
COALESCE(TaxPerLastYear, 0) as TaxPerLastYear,
COALESCE(TotalPerLastYear, 0) as TotalPerLastYear
from items i
inner join
(select itemid,
Country,
sum(case when SalesDate = @Date then Quantity else 0 end) as Quantityperday,
sum(case when SalesDate = @Date then pricetotal else 0 end) as amountperday,
sum(case when SalesDate = @Date then TaxTotal else 0 end) as Taxperday,
sum(case when SalesDate = @Date then TaxTotal + PriceTotal else 0 end) as Totalperday,
sum(case when month(SalesDate) = month(@Date) then Quantity else 0 end) as QuantityperMonth,
sum(case when month(SalesDate) = month(@Date) then pricetotal else 0 end) as amountperMonth,
sum(case when month(SalesDate) = month(@Date) then TaxTotal else 0 end) as TaxperMonth,
sum(case when month(SalesDate) = month(@Date) then TaxTotal + PriceTotal else 0 end) as TotalperMonth,
sum(case when year(SalesDate) = year(@Date) then Quantity else 0 end) as QuantityperYear,
sum(case when year(SalesDate) = year(@Date) then pricetotal else 0 end) as amountperYear,
sum(case when year(SalesDate) = year(@Date) then TaxTotal else 0 end) as TaxperYear,
sum(case when year(SalesDate) = year(@Date) then TaxTotal + PriceTotal else 0 end) as TotalperYear,
sum(case when year(SalesDate) = year(@Date) - 1 then Quantity else 0 end) as QuantityperLastYear,
sum(case when year(SalesDate) = year(@Date) - 1 then pricetotal else 0 end) as amountperLastYear,
sum(case when year(SalesDate) = year(@Date) - 1 then TaxTotal else 0 end) as TaxperLastYear,
sum(case when year(SalesDate) = year(@Date) - 1 then TaxTotal + PriceTotal else 0 end) as TotalperLastYear
from Custom_DailyItemSalesbyCountry
where year(SalesDate) = year(@date)
and Isreturn = 0
group by itemid
, Country
) d on d.itemid = i.itemid
order by i.ItemDescription
-- Returns
//.........这里部分代码省略.........
示例13: GetCustomerOrders
public static IEnumerable<Order> GetCustomerOrders(GetCustomerOrdersRequest request)
{
if (request.CustomerID == 0)
{
throw new ArgumentException("CustomerID is required.");
}
var context = Exigo.CreateODataContext<ExigoContext>(GlobalSettings.Exigo.Api.SandboxID);
// Clear the OrderDetailModels
if (OrderDetailModels != null) OrderDetailModels = new List<ExigoService.OrderDetail>();
var orders = new List<Order>();
// Setup the base orders query
var ordersBaseQuery = context.Orders;
if (request.IncludePayments) ordersBaseQuery = ordersBaseQuery.Expand("Payments");
var ordersQuery = ordersBaseQuery.Where(c => c.CustomerID == request.CustomerID);
// Apply the request variables
if (request.OrderID != null)
{
ordersQuery = ordersQuery.Where(c => c.OrderID == ((int)request.OrderID));
}
if (request.OrderStatuses.Length > 0)
{
ordersQuery = ordersQuery.Where(request.OrderStatuses.ToList().ToOrExpression<Common.Api.ExigoOData.Order, int>("OrderStatusID"));
}
if (request.OrderTypes.Length > 0)
{
ordersQuery = ordersQuery.Where(request.OrderTypes.ToList().ToOrExpression<Common.Api.ExigoOData.Order, int>("OrderTypeID"));
}
if (request.StartDate != null)
{
ordersQuery = ordersQuery.Where(c => c.OrderDate >= (DateTime)request.StartDate);
}
// Get the orders
var odataOrders = ordersQuery
.OrderByDescending(c => c.OrderDate)
.Skip(request.Skip)
.Take(request.Take)
.Select(c => c)
.ToList();
// If we don't have any orders, stop here.
if (odataOrders.Count == 0) yield break;
// Collect our orders together
foreach (var order in odataOrders)
{
var model = (Order)order;
orders.Add(model);
}
// Get the order details if applicable
if (request.IncludeOrderDetails)
{
// Get the order IDs
var orderIDs = orders.Select(c => c.OrderID).Distinct().ToList();
// Get the order details (Results are saved via the ReadingEntity delegate to the private OrderDetailModels property.
context.ReadingEntity += context_ReadingEntity;
context.OrderDetails
.Where(orderIDs.ToOrExpression<Common.Api.ExigoOData.OrderDetail, int>("OrderID"))
.ToList();
// Get a unique list of item IDs in the orders
var itemIDs = OrderDetailModels.Select(c => c.ItemID).Distinct().ToList();
// Get the extra data we need for each detail
var apiItems = new List<Common.Api.ExigoOData.Item>();
if (itemIDs.Count > 0)
{
apiItems = context.Items
.Where(itemIDs.ToOrExpression<Common.Api.ExigoOData.Item, int>("ItemID"))
.Select(c => new Common.Api.ExigoOData.Item
{
ItemCode = c.ItemCode,
SmallImageUrl = c.SmallImageUrl,
IsVirtual = c.IsVirtual
})
.ToList();
}
// Format the data to our models
foreach (var order in orders)
{
// Get the order details
var details = OrderDetailModels.Where(c => c.OrderID == order.OrderID);
foreach (var detail in details)
{
var apiItem = apiItems.Where(c => c.ItemCode == detail.ItemCode).FirstOrDefault();
if (apiItem != null)
{
detail.ImageUrl = apiItem.SmallImageUrl;
detail.IsVirtual = apiItem.IsVirtual;
}
}
order.Details = details;
//.........这里部分代码省略.........
示例14: GetGroupByMID
/// <summary>
/// 根据 短信任务id 查询对应的群组列表
/// </summary>
/// <param name="mid"></param>
/// <returns></returns>
public ActionResult GetGroupByMID(int mid/*, int userid*/)
{
int userId = int.Parse(Request["uid"]);
//1获取传入的任务id
//1.1根据任务id查找对应的任务对象并查找对应的群组集合
List<PMS.Model.P_Group> list_owned_group = new List<PMS.Model.P_Group>();
//根据短信任务查找短信任务所拥有的群组(在R_Group_Mission表中),并只拿取isPass为true的所对应的群组
smsMissionBLL.GetListBy(m => m.SMID == mid).FirstOrDefault().R_Group_Mission.Where(r => r.isPass == true).ToList().ForEach(r => list_owned_group.Add(r.P_Group));
list_owned_group = list_owned_group.Select(g => g.ToMiddleModel()).ToList();
var list_owned_Ids = list_owned_group.Select(g => g.GID).ToList();
//8月31日
//之前的备份
var list = ToEasyUICombogrid_Group.ToEasyUIDataGrid(list_owned_group, true);
//var list = ToEasyUICombogrid_Group.ToEasyUIDataGrid(list_owned_group, false);
//2 从所有的群组中删除该任务所拥有的群组集合
//2.1 获取当前用户所拥有的常用群组(通过User查询对应的Group)
var list_excludeOwned_group = userBLL.GetRestGroupListByIds(list_owned_Ids, userId, true);
//var list_excludeOwned_group = groupBLL.GetListBy(g => g.isDel == false).ToList().Where(g => !list_owned_group.Contains(g)).Select(g=>g.ToMiddleModel()).ToList();
list.AddRange(ToEasyUICombogrid_Group.ToEasyUIDataGrid(list_excludeOwned_group, false));
//将该任务拥有的群组设置为选中状态
PMS.Model.EasyUIModel.EasyUIDataGrid model = new PMS.Model.EasyUIModel.EasyUIDataGrid()
{
total = 0,
rows = list,
footer = null
};
var temp = Common.SerializerHelper.SerializerToString(model);
temp = temp.Replace("Checked", "checked");
return Content(temp);
}
示例15: Solve
public static void Solve(int r = 4)
{
int max = -1;
foreach (var perm in CombinatoricsUtilities.Permutations(Enumerable.Range(1, 9), 4))
{
var accessible = new List<decimal>();
foreach (var d1 in perm)
{
Gen(new decimal[] { d1 }, perm, new List<int>() { d1 }, accessible);
}
int cur = accessible
.Select(x => (int)x)
.MaxConsequentive();
//.Dump();
if (cur > max)
{
cur.Dump("Max conseq");
perm.Dump();
max = cur;
}
}
}