public ApiResult <ListOutput> Bill([FromQuery] ListInput parameter) { var moneyTypes = Resolve <IAutoConfigService>().MoneyTypes(); var billApiInput = new BillApiInput { UserId = parameter.LoginUserId, PageIndex = parameter.PageIndex, PageSize = parameter.PageSize }; var billList = Resolve <IFinanceAdminService>().GetApiBillPageList(billApiInput, out var count); var result = new ListOutput { StyleType = 1, //采用第一种样式 TotalSize = count / parameter.PageSize }; foreach (var item in billList.ToList()) { var index = new Random().Next(1, 8); var apiData = new ListItem { Id = item.Id, Intro = $"账后{item.AfterAmount} 时间{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", Title = $"{moneyTypes.FirstOrDefault(e => e.Id == item.MoneyTypeId)?.Name}-{item.Type.GetDisplayName()}", Image = Resolve <IApiService>().ApiImageUrl($"/assets/mobile/images/icon/demo{index}.png"), Url = $"/finance/bill/view?id={item.Id}".ToClientUrl(ClientType.WapH5), Extra = item.Amount.ToStr() }; result.ApiDataList.Add(apiData); } return(ApiResult.Success(result)); }
public override int Execute() { var installedList = _workloadRecordRepo.GetInstalledWorkloads(_sdkFeatureBand); if (_machineReadableOption) { var updateAvailable = MockUpdateAvailable(); var listOutput = new ListOutput(Installed: installedList.Select(id => id.ToString()).ToArray(), UpdateAvailable: updateAvailable); _reporter.WriteLine("==workloadListJsonOutputStart=="); _reporter.WriteLine( JsonSerializer.Serialize(listOutput, options: new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase })); _reporter.WriteLine("==workloadListJsonOutputEnd=="); } else { var table = new PrintableTable <WorkloadId>(); table.AddColumn(LocalizableStrings.WorkloadIdColumn, workloadId => workloadId.ToString()); table.PrintRows(installedList, l => _reporter.WriteLine(l)); _reporter.WriteLine(); } return(0); }
public ApiResult <ListOutput> TopHelpList() { var parameter = new ArticleInput { ChannelId = ChannelType.Help.GetFieldAttribute().GuidId, ClientType = ClientType.WapH5, OrderType = 1, TotalCount = 5 }; var model = Resolve <IArticleService>().GetArticleList(parameter); var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"{item.Title}", Intro = $"{item.SubTitle} {item.CreateTime:yyyy-MM-dd hh:ss}", Extra = $"{item.CreateTime:yyyy-MM-dd hh:ss}", Id = item.Id, Url = $"/pages/index?path=articles_show&id={item.Id}" }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
public ApiResult <ListOutput> List(ArticleInput parameter) { parameter.ChannelId = ChannelType.Help.GetFieldAttribute().GuidId; var model = Resolve <IArticleService>().GetArticleList(parameter); var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"{item.Title}", Intro = $"{item.SubTitle} {item.CreateTime:yyyy-MM-dd hh:ss}", Extra = $"{item.CreateTime:yyyy-MM-dd hh:ss}", Id = item.Id, Url = $"Api/Transfer/Get?loginUserId={parameter.LoginUserId}&id={item.Id}" }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); } }
public ApiResult <ListOutput> List([FromQuery] ListInput parameter) { var rewardInput = new RewardInput { PageIndex = parameter.PageIndex, UserId = parameter.LoginUserId, PageSize = parameter.PageSize }; var model = Resolve <IRewardService>().GetViewRewardPageList(rewardInput, HttpContext); var apiOutput = new ListOutput { TotalSize = model.PageCount, StyleType = 1 }; var users = Resolve <IUserService>().GetList(); foreach (var item in model) { var orderUser = users.FirstOrDefault(u => u.Id == item.OrderUserId); var apiData = new ListItem { Id = item.Reward.Id, Intro = $"{item.Reward.CreateTime:yyyy-MM-dd hh:ss}", Title = $"{orderUser.UserName}", Image = Resolve <IApiService>().ApiUserAvator((item.OrderUser?.Id).ConvertToLong()), Url = $"/pages/index?path=share_show&id={item.Reward.Id}", Extra = item.Reward.Amount.ToStr() }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
public ApiResult <ListOutput> Recommend([FromQuery] RecommendInput parameter) { var userInput = new UserInput { PageIndex = parameter.PageIndex, ParentId = parameter.LoginUserId, GradeId = parameter.GradeId, PageSize = parameter.PageSize }; var apiOutput = new ListOutput(); var model = Resolve <IUserService>().GetViewUserPageList(userInput); apiOutput.TotalSize = model.PageCount; foreach (var item in model) { var apiData = new ListItem { Title = item.UserName.ReplaceHtmlTag(), Intro = $"{item.Mobile} {item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", Extra = item.GradeName, Image = Resolve <IApiService>().ApiUserAvator(item.Id), Id = item.Id, Url = $"/pages/user?path=user_view&id={item.Id}".ToClientUrl(ClientType.WapH5) }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
private ListOutput <T> _create_outputs_for_shapes <T>(IList <int> shapeids, T[] values) { var output_for_all_shapes = new ListOutput <T>(); int cursor = 0; for (int shape_index = 0; shape_index < shapeids.Count; shape_index++) { var shapeid = shapeids[shape_index]; var subqueryinfo = this._safe_get_subquery_output_for_shape(shape_index); var output_for_shape = this._create_output_for_shape <T>((short)shapeid, values, subqueryinfo, ref cursor); output_for_all_shapes.Add(output_for_shape); } return(output_for_all_shapes); }
public void ToString_SingleItemListInput_ReturnsString() { //arrange List <String> inputs = new List <string>() { "item1" }; IOutput output = new ListOutput(inputs); //act string result = output.ToString(); //assert Assert.NotNull(output); Assert.NotNull(result); Assert.Equal("item1", result); }
public void ToString_MultipleItemListInput_ReturnsDelimitedString() { //arrange List <String> inputs = new List <string>() { "item1", "item2", "item3" }; IOutput output = new ListOutput(inputs); //act string result = output.ToString(); //assert Assert.NotNull(output); Assert.NotNull(result); Assert.Equal("item1|item2|item3", result); }
public void ToList_SingleItemListInput_ReturnsList() { //arrange List <String> inputs = new List <string>() { "item1" }; IOutput output = new ListOutput(inputs); //act List <String> results = output.ToList(); //assert Assert.NotNull(output); Assert.NotNull(results); Assert.NotEmpty(results); Assert.True(results.Count == 1); }
public ApiResult <ListOutput> PayCheckList([FromQuery] ListInput parameter) { var model = Resolve <IPayService>().GetList(u => u.UserId == parameter.LoginUserId).ToList(); var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"金额{item.Amount}元", Intro = $"{item.CreateTime.ToString("yyyy-MM-dd hh:ss")}", // Extra = "编号" + item.Serial, Image = Resolve <IApiService>().ApiUserAvator(item.Id), Id = item.Id, Url = $"/pages/user?path=Asset_pay_view&id={item.Id}" }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
public ApiResult <ListOutput> TopLineList(ArticleInput parameter) { parameter.ChannelId = ChannelType.TopLine.GetFieldAttribute().GuidId; var webSite = Resolve <IAutoConfigService>().GetValue <WebSiteConfig>(); var model = Resolve <IArticleService>().GetArticleList(parameter); var articleList = new List <ArticleItem>(); if (!parameter.RelationIds.IsNullOrEmpty()) { var relationList = Resolve <IRelationIndexService>() .GetList(u => u.RelationId.ToString() == parameter.RelationIds); relationList.Foreach(u => { var temp = model.FirstOrDefault(z => z.RelationId == u.EntityId); articleList.Add(temp); }); model = articleList; } var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"{item.Title}", Intro = $"{item.SubTitle} {item.CreateTime:yyyy-MM-dd hh:ss}", Extra = $"{item}", Id = item.Id, Url = $"/pages/index?path=articles_topline_show&id={item.Id}".ToClientUrl(parameter.ClientType), Image = Resolve <IApiService>().ApiImageUrl(item.ImageUrl) }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
public ApiResult <ListOutput> ArticleList(ArticleInput parameter) { parameter.ChannelId = ChannelType.Article.GetFieldAttribute().GuidId; var model = Resolve <IArticleService>().GetArticleList(parameter); var articleList = new List <ArticleItem>(); if (!parameter.RelationIds.IsNullOrEmpty()) { var relationList = Resolve <IRelationIndexService>() .GetList(u => u.RelationId.ToString() == parameter.RelationIds); relationList.Foreach(u => { var temp = model.FirstOrDefault(z => z.RelationId == u.EntityId); articleList.Add(temp); }); model = articleList; } var apiOutput = new ListOutput { TotalSize = model.Count() / parameter.PageSize }; foreach (var item in model) { var apiData = new ListItem { Title = $"{item.Title}", Intro = $"{item.SubTitle} {item.CreateTime:yyyy-MM-dd hh:ss}", Extra = $"{item.CreateTime:yyyy-MM-dd hh:ss}", Id = item.Id, Url = $"Api/Transfer/Get?loginUserId={parameter.LoginUserId}&id={item.Id}" }; apiOutput.ApiDataList.Add(apiData); } return(ApiResult.Success(apiOutput)); }
private static DataTable querytable_to_datatable <T>(VisioAutomation.ShapeSheet.Queries.Query cellQuery, ListOutput <T> query_output) { // First Construct a Datatable with a compatible schema var dt = new DataTable(); dt.Columns.Add("ShapeID", typeof(int)); foreach (var col in cellQuery.Cells) { dt.Columns.Add(col.Name, typeof(T)); } // Then populate the rows of the datatable dt.BeginLoadData(); int colcount = cellQuery.Cells.Count; var rowbuf = new object[colcount + 1]; for (int r = 0; r < query_output.Count; r++) { // populate the row buffer rowbuf[0] = query_output[r].ShapeID; for (int i = 0; i < colcount; i++) { rowbuf[i + 1] = query_output[r].Cells[i]; } // load it into the table dt.Rows.Add(rowbuf); } dt.EndLoadData(); return(dt); }
public C GetEntry(IBehaviourContext context) { if (SourceSocket == null) { if (defaultEntry == null) { defaultEntry = new C { Value = defaultValue }; } return(defaultEntry); } if (contextCahce == null) { contextCahce = new Dictionary <IBehaviourContext, C> (); } C foundEntry; bool result = contextCahce.TryGetValue(context, out foundEntry); if (!result || ContextUtility.currentIndex != -1) { foundEntry = new C(); if (ContextUtility.currentIndex == -1) { contextCahce.Add(context, foundEntry); } if (typeof(ListOutput).IsAssignableFrom(SourceSocket.GetType())) { ListOutput list = (ListOutput)SourceSocket; EntryCollection entries = list.GetEntry(context); // If this is a root thing if (ContextUtility.currentIndex == -1) { for (int i = 0; i < entries.Count; i++) { C entry = entries[i]; int index = i; ContextUtility.currentIndex = index; ParentNode.SetupContext(context); } ContextUtility.currentIndex = -1; entries.OnAddEntry += (C entry) => { ContextUtility.currentIndex = entries.Count - 1; ParentNode.SetupContext(context); ContextUtility.currentIndex = -1; }; entries.OnRemoveEntry += (C entry) => { entry.Value = default(T); //ContextUtility.currentIndex = entries.Count - 1; //ParentNode.Remove (context); //ContextUtility.currentIndex = -1; }; } else { ConnectionEntry connectionEntry = entries[ContextUtility.currentIndex]; if (!typeof(ISocketConvertable <T>).IsAssignableFrom(connectionEntry.GetType())) { Debug.Log(SourceSocket.GetType().Name + " is not convertable to " + GetType().Name); } ISocketConvertable <T> socket = (ISocketConvertable <T>)connectionEntry; connectionEntry.OnAfterChanged += () => { foundEntry.Value = socket.Convert; }; foundEntry.Value = socket.Convert; } } else { Socket sourceOutput = (Socket)SourceSocket; ConnectionEntry connectionEntry = sourceOutput.GetBaseEntry(context); if (!typeof(ISocketConvertable <T>).IsAssignableFrom(connectionEntry.GetType())) { Debug.Log(SourceSocket.GetType().Name + " is not convertable to " + GetType().Name); } ISocketConvertable <T> socket = (ISocketConvertable <T>)connectionEntry; connectionEntry.OnAfterChanged += () => { foundEntry.Value = socket.Convert; }; foundEntry.Value = socket.Convert; } } return(foundEntry); }
/// <summary> /// 列出文件的具体实现 /// </summary> /// <param name="input"></param> /// <returns></returns> public override async Task <ListOutput> ListCoreAsync(ListInput input) { var output = new ListOutput() { Size = input.Size, Start = input.Start }; try { //非首次请求时获取上次保存的分页标记 var marker = ""; if (input.Start > 0) { marker = GetMarker(); } await Task.Run(() => { var req = new ListObjectsRequest(_ossConfig.BucketName) { Marker = marker, //获取超过当前请求数量的数据,如果返回的比请求的多说明有下一页 MaxKeys = input.Size + 1, Prefix = $"{_ossConfig.ObjectNamePrefix}/{input.ListPath}" }; var listResult = _ossClient.ListObjects(req); if (listResult.HttpStatusCode == System.Net.HttpStatusCode.OK) { var items = listResult.ObjectSummaries.ToList(); var returnItems = new List <ListItemOutput>(); returnItems.AddRange(items.Select(p => new ListItemOutput() { //拼接OSS可访问路径 Url = $"{(string.IsNullOrWhiteSpace(_ossConfig.CustomerDomain) ? $"{_ossConfig.BucketName}.{_ossConfig.EndPoint}/{p.Key}" : $"{_ossConfig.CustomerDomain}/{p.Key}")}", Original = Path.GetFileName(p.Key), Key = p.Key })); output.Total = returnItems.Count; if (returnItems.Count > input.Size) { output.Total = input.Start + input.Size + 1; //获取请求数量的数据 returnItems = returnItems.GetRange(0, input.Size); //获取下一页的分页标记 marker = returnItems.Last().Key; } else { //如果当前为最后一页则清除分页标记 marker = ""; } output.List = returnItems; output.State = "SUCCESS"; //保存分页标记用于请求后续数据 SetMarker(marker); } else { throw new UEditorServiceException("列出OSS文件失败"); } });
/// <inheritdoc /> public IListOutput Parse(string[] rawOutput) { var output = new ListOutput(); ArchiveListOutput?currentArchive = null; bool inParsingFilesMode = false; var fileMatcher = new Regex(@"(?<datetime>[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2})\s(?<attr>.{5})\s+(?<size>[0-9]+)\s+(?<compressed>[0-9]+)\s+(?<name>.*)", RegexOptions.Compiled | RegexOptions.Singleline); foreach (var line in rawOutput) { if (string.IsNullOrWhiteSpace(line)) { continue; } if (string.IsNullOrEmpty(output.Information)) { output.Information = line; continue; } if (line.StartsWith("Path = ", StringComparison.Ordinal)) { currentArchive = new ArchiveListOutput { Path = line.Substring(7).Trim(), }; output.Archives.Add(currentArchive); inParsingFilesMode = false; continue; } if (currentArchive != null && line.StartsWith("Type = ", StringComparison.Ordinal)) { currentArchive.Type = line.Substring(7).Trim(); continue; } if (currentArchive != null && line.StartsWith("Physical Size = ", StringComparison.Ordinal)) { currentArchive.PhysicalSize = long.Parse(line.Substring(16).Trim(), CultureInfo.InvariantCulture); continue; } if (currentArchive != null && line.StartsWith("---", StringComparison.Ordinal)) { inParsingFilesMode = !inParsingFilesMode; continue; } var match = fileMatcher.Match(line); if (match.Success) { var fileDate = DateTime.Parse(match.Groups["datetime"].Value, CultureInfo.InvariantCulture); var compressedSize = long.Parse(match.Groups["compressed"].Value, CultureInfo.InvariantCulture); var size = long.Parse(match.Groups["size"].Value, CultureInfo.InvariantCulture); var name = match.Groups["name"].Value.Trim(); var attr = match.Groups["attr"].Value.Trim(); if (inParsingFilesMode) { currentArchive !.Files.Add(new ArchivedFileListOutput { FileDate = fileDate, CompressedSize = compressedSize, Size = size, Name = name, Attributes = attr, }); } else { // now, this is either the last line for an archive or the summary (last line) for multiple archives if (currentArchive != null) { currentArchive.ArchiveDate = fileDate; currentArchive.CompressedSize = compressedSize; currentArchive.Size = size; currentArchive = null; } else { output.CompressedSize = compressedSize; output.Size = size; } } } } // if there was only one archive listed, there was no summary line if (output.Archives.Count == 1) { output.CompressedSize = output.Archives[0].CompressedSize; output.Size = output.Archives[0].Size; } return(output); }