public async Task <IActionResult> GenerateReport() { var report = await _itemRepository.Report(); var previousReport = (await _reportHistoryRepository.ListAllAsync()).LastOrDefault() ?? new ReportHistory(); var itemReportSummaryViewModel = new ItemReportSummaryViewModel(); foreach (Item i in report) { var _itemReportViewModel = new ItemReportViewModel(); _itemReportViewModel.ItemName = i.Name; _itemReportViewModel.BoughtAt = i.CostPrice; _itemReportViewModel.SoldAt = i.SellPrice; _itemReportViewModel.AvailableQty = i.Quantity; _itemReportViewModel.Value = i.CostPrice * i.Quantity; itemReportSummaryViewModel.itemReportViewModels.Add(_itemReportViewModel); } itemReportSummaryViewModel.TotalValue = report.Select(x => x.CostPrice * x.Quantity).Sum(); itemReportSummaryViewModel.ProfitSincePreviousReport = previousReport.CurrentProfit; var reporthistory = new ReportHistory(); reporthistory.LastProfit = previousReport.CurrentProfit; reporthistory.LastTotal = report.Select(x => x.CostPrice * x.Quantity).Sum(); reporthistory.CurrentProfit = 0; await _reportHistoryRepository.AddAsync(reporthistory); return(Ok(itemReportSummaryViewModel)); }
//會員報表轉換 public static List <ReportHistory> ConvertReportHistoryMemberModel(List <UsersHistoryReport> models) { List <ReportHistory> reportMembers = new List <ReportHistory>(); foreach (var model in models) { ReportHistory reportMember = new ReportHistory() { User_name = model.UserName, groups = model.GroupId.ToString(), ruknum = model.InCount, chuknum = model.OutCount, totalruk = model.InMoney, totalchuk = model.OutMoney, totalplay = model.BetMoney, totalwin = model.WinMoney, totalfd = model.RebateMoney, totalyh = model.ActivityMoney, TotalReward = model.RewardMoney, Deficit = model.ProfitMoney, zctime = model.RegisterTime }; reportMembers.Add(reportMember); } return(reportMembers); }
public void GenerateReport(GenerateReportModel generateReport, Guid userId, string nameFile) { try { nameFile = Helpers.Helpers.GetNameFileWithCurrentDate(nameFile); Report report = new Report { ReportTypeId = generateReport.ReportTypeId, SignerUserId = userId, Name = nameFile }; _docFlowContext.Reports.Add(report); ReportHistory reportHistory = new ReportHistory { ReportId = report.Id, CreateUserId = userId, CreateDate = DateTime.Now }; _docFlowContext.ReportHistory.Add(reportHistory); foreach (ReportLabelModel label in generateReport.Values) { ReportValue reportValue = new ReportValue { ReportId = report.Id, ReportLabelId = label.Id, Value = label.Value }; _docFlowContext.ReportValues.Add(reportValue); ReportValuesHistory reportValuesHistory = new ReportValuesHistory { ReportValueId = reportValue.Id, ReportHistoryId = reportHistory.Id, NewValue = reportValue.Value }; _docFlowContext.ReportValuesHistory.Add(reportValuesHistory); } _docFlowContext.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
protected override void GenerateXml(XmlTextWriter writer) { QuickGraph.Operations.OperationsResourceManager.DumpResources( Path.GetDirectoryName(this.OutputFileName) ); UnitResourceManager.DumpResources( Path.GetDirectoryName(this.OutputFileName) ); ReportHistory history = new ReportHistory( this.OutputFolderName, this.EntryAssemblyName); XmlDocument doc = history.LoadReportHistory(); doc.Save(writer); }
private void LoadPreviousResult() { if (!this.Arguments.UseLatestHistory) { return; } if (!System.IO.Directory.Exists(this.Arguments.ReportOutputPath)) { return; } do { string latestResultFile = new ReportHistory( this.Arguments.ReportOutputPath, this.BatchFactory.MainAssembly).GetLatestXmlReport(); if (latestResultFile != null) { this.TestListeners.Message( MessageImportance.Low, "Found previous report: {0}", latestResultFile); System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); try { this.report.TestListener.SetPreviousTestBatch(latestResultFile); this.TestListeners.Message( MessageImportance.Low, "Loaded {0} fixtures and {1} tests in previous report", this.report.TestListener.TestBatchSearcher.Fixtures.Count, this.report.TestListener.TestBatchSearcher.TestCases.Count); break; } catch (Exception ex) { this.TestListeners.Warning("Failure while loading previous report"); this.TestListeners.Message( MessageImportance.Low, "Error: {0}", ex.Message); // deleting previous report ReportCleaner cleaner = new ReportCleaner(this.BatchFactory.MainAssembly); cleaner.Clean(Path.GetDirectoryName(latestResultFile), this); } } else { this.TestListeners.Message( MessageImportance.Low, "Could not find previous result"); break; } } while (true); }
public async Task <IActionResult> Delete(string itemName) { try { var item = await _itemRepository.deleteAsync(itemName); if (item != null) { var currentReport = (await _reportHistoryRepository.ListAllAsync()).LastOrDefault() ?? new ReportHistory(); currentReport.CurrentProfit -= item.Quantity * item.CostPrice; var reporthistory = new ReportHistory(); reporthistory.CurrentProfit = currentReport.CurrentProfit; reporthistory.LastProfit = currentReport.LastProfit; reporthistory.LastTotal = currentReport.LastTotal; await _reportHistoryRepository.AddAsync(reporthistory); } return(Ok(item)); } catch (Exception exDel) { return(NotFound()); } }
public async Task <IActionResult> UpdateSell(string itemName, [FromBody] ItemUpdateDto exItem) { try { var item = await _itemRepository.UpdateSell(itemName, exItem.Quantity); if (item != null) { var currentReport = (await _reportHistoryRepository.ListAllAsync()).LastOrDefault() ?? new ReportHistory(); currentReport.CurrentProfit += exItem.Quantity * (item.SellPrice - item.CostPrice); var reporthistory = new ReportHistory(); reporthistory.CurrentProfit = currentReport.CurrentProfit; reporthistory.LastProfit = currentReport.LastProfit; reporthistory.LastTotal = currentReport.LastTotal; await _reportHistoryRepository.AddAsync(reporthistory); } return(Ok(item)); } catch (Exception exUpdateSell) { return(NotFound()); } }
public void UpdateReport(UpdateReportModel updateReport, Guid userId) { try { ReportHistory reportHistory = new ReportHistory { ReportId = updateReport.ReportId, CreateUserId = userId, CreateDate = DateTime.Now }; _docFlowContext.ReportHistory.Add(reportHistory); List <ReportValue> reportValues = GetReportValues(updateReport.ReportId); foreach (ReportValue reportValue in reportValues) { ReportLabelModel reportLabelModel = updateReport.Values.FirstOrDefault(x => x.Id == reportValue.ReportLabelId); _docFlowContext.ReportValuesHistory.Add(new ReportValuesHistory { ReportValueId = reportValue.Id, ReportHistoryId = reportHistory.Id, OldValue = reportValue.Value, NewValue = reportLabelModel.Value }); reportValue.Value = reportLabelModel.Value; } _docFlowContext.SaveChanges(); } catch (Exception ex) { throw new Exception(ex.Message, ex); } }
private void LoadPreviousResult() { if (!this.Arguments.UseLatestHistory) return; if (!System.IO.Directory.Exists(this.Arguments.ReportOutputPath)) return; do { string latestResultFile = new ReportHistory( this.Arguments.ReportOutputPath, this.BatchFactory.MainAssembly).GetLatestXmlReport(); if (latestResultFile != null) { this.TestListeners.Message( MessageImportance.Low, "Found previous report: {0}", latestResultFile); System.Runtime.CompilerServices.RuntimeHelpers.PrepareConstrainedRegions(); try { this.report.TestListener.SetPreviousTestBatch(latestResultFile); this.TestListeners.Message( MessageImportance.Low, "Loaded {0} fixtures and {1} tests in previous report", this.report.TestListener.TestBatchSearcher.Fixtures.Count, this.report.TestListener.TestBatchSearcher.TestCases.Count); break; } catch (Exception ex) { this.TestListeners.Warning("Failure while loading previous report"); this.TestListeners.Message( MessageImportance.Low, "Error: {0}", ex.Message); // deleting previous report ReportCleaner cleaner = new ReportCleaner(this.BatchFactory.MainAssembly); cleaner.Clean(Path.GetDirectoryName(latestResultFile), this); } } else { this.TestListeners.Message( MessageImportance.Low, "Could not find previous result"); break; } } while (true); }