void OnGUI() { EditorGUILayout.HelpBox(Content.Description, MessageType.Warning); EditorGUILayout.PropertyField(m_SerializedObject.FindProperty(nameof(m_UpgradeMaterials))); if ( GUILayout.Button(Content.DoItButton) && EditorUtility.DisplayDialog(Content.DialogTitle, Content.DialogMessage, Content.DialogOK, Content.DialogCancel)) { m_Failures.Clear(); m_Successes.Clear(); try { AssetDatabase.StartAssetEditing(); if (m_UpgradeMaterials) { PhysicsMaterialProperties.s_SuppressUpgradeWarnings = true; UpgradeMaterials(); } } finally { AssetDatabase.StopAssetEditing(); PhysicsMaterialProperties.s_SuppressUpgradeWarnings = false; } var upgradeReport = new ReportOutput { Successes = m_Successes.AssetPathsAndStatuses.Keys.ToArray(), Failures = m_Failures.AssetPathsAndStatuses.Select(kv => new ReportFailure { AssetPath = kv.Key, Message = kv.Value }).ToArray() }; using (var sw = new StreamWriter($"Assets/{DateTime.Now:yyyy-dd-M--HH-mm-ss}-PhysicsMaterialUpgradeReport.json")) sw.Write(EditorJsonUtility.ToJson(upgradeReport)); AssetDatabase.SaveAssets(); GUIUtility.ExitGUI(); } m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition); DisplayAssetGroup( m_Failures, Content.Failures, m_Failures.Count == 0 ? Content.NoFailures : string.Format(Content.FailuresFormat, m_Failures.Count), m_Failures.Count == 0 ? MessageType.None : MessageType.Warning ); DisplayAssetGroup( m_Successes, Content.Successes, m_Successes.Count == 0 ? Content.NoUpgradedAssets : string.Format(Content.UpgradedAssetsFormat, m_Successes.Count), MessageType.None ); GUILayout.EndScrollView(); GUILayout.FlexibleSpace(); }
public (bool created, string errorMessage) DistributeReport(ReportOutput reportOutput) { if (reportOutput is null) { throw new System.ArgumentNullException(nameof(reportOutput)); } if (reportOutput.OutputLines.Count <= 0) { return(false, "No output lines in report"); } if (reportOutput.FileName.Length == 0) { return(false, "No filename for report"); } // Open up a file with the name from the reportOutput string path = @"c:\users\ryzen\Desktop\" + reportOutput.FileName; StreamWriter streamWriter = new StreamWriter(path); // Write all lines to the file foreach (var line in reportOutput.OutputLines) { streamWriter.WriteLine(line); } // Close the file streamWriter.Close(); return(true, ""); }
public void Generate_valid() { var reportOutput = new ReportOutput(); var reportData = new ReportData(); _dataGetterMock.Setup(c => c.GetData(3)).Returns(reportData); _dataValidatorMock.Setup(c => c.ValidateData(reportData)).Returns((true, "")); _dataFormatterMock.Setup(c => c.FormatData(reportData)).Returns(reportOutput); _reportDistributorMock.Setup(c => c.DistributeReport(reportOutput)).Returns((true, "")); var result = _report.Generate(3); Assert.AreEqual(true, result.created); Assert.AreEqual("", result.errorMessage); _dataGetterMock.Verify(c => c.GetData(3), Times.Once); _dataValidatorMock.Verify(c => c.ValidateData(reportData), Times.Once); _dataFormatterMock.Verify(c => c.FormatData(reportData), Times.Once); _reportDistributorMock.Verify(c => c.DistributeReport(reportOutput), Times.Once); }
/// <summary> /// Update the current deployment status and service status /// </summary> public bool RefreshStatus() { try { ReportOutput report = this.ExecuteDaemon <ReportOutput>("-r", true); if (report == null) { if (hasStatusChanged) { return(false); } else { hasStatusChanged = true; return(true); } } this.CurrentServiceStatus = (ServiceStatus)report.Status; this.CurrentHashRate = report.HashRate; if (this.CurrentServiceStatus == ServiceStatus.Error) { this.CurrentServiceErrorDetails = report.Details; } hasStatusChanged = true; } catch (Exception ex) { hasStatusChanged = false; } return(hasStatusChanged); }
public void CreateFile_EmptyReportObjectWithFileName() { ReportOutput reportOutput = new ReportOutput { FileName = "junk.txt" }; var result = _reportDistributor.DistributeReport(reportOutput); Assert.AreEqual(false, result.created); Assert.AreEqual("No output lines in report", result.errorMessage); }
public void CreateFile_NoFileName() { ReportOutput reportOutput = new ReportOutput { OutputLines = { "John Smith", "Number", "City", "State" } }; var result = _reportDistributor.DistributeReport(reportOutput); Assert.AreEqual(false, result.created); Assert.AreEqual("No filename for report", result.errorMessage); }
public ReportOutput FormatData(ReportData data) { if (data == null) { throw new ApplicationException("Report data object cannot be null"); } if (data.SummaryDataInfo.Count == 0) { throw new ApplicationException("There must be services provided to the member to format data"); } ReportOutput formattedData = new ReportOutput(); double totalFee = 0; int totalProviders = 0; int totalConsultations = 0; formattedData.FileName = "SummaryReport.txt"; formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add( "Provider name " + "Consultations " + "Fee " ); formattedData.OutputLines.Add("_".PadRight(46, '_')); foreach (var providerConsultations in data.SummaryDataInfo) { totalFee = totalFee + providerConsultations.TotalFee; totalProviders++; totalConsultations = totalConsultations + providerConsultations.TotalNumberOfConsultations; formattedData.OutputLines.Add( providerConsultations.ProviderName.PadRight(30) + providerConsultations.TotalNumberOfConsultations.ToString().PadRight(15) + providerConsultations.TotalFee.ToString("C").PadRight(15) ); } formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("Total number of providers for week: " + totalConsultations.ToString()); formattedData.OutputLines.Add("Total number of consultations for week: " + totalConsultations.ToString()); formattedData.OutputLines.Add("Total Fee for week: " + totalFee.ToString("C")); return(formattedData); }
void setContext(ITypeDescriptorContext context) { _metaConnection = context.Instance as MetaConnection; _metaEnum = context.Instance as MetaEnum; _metaTable = context.Instance as MetaTable; _metaColumn = context.Instance as MetaColumn; _metaJoin = context.Instance as MetaJoin; _reportView = context.Instance as ReportView; _reportOutput = context.Instance as ReportOutput; _reportSchedule = context.Instance as ReportSchedule; _parameter = context.Instance as Parameter; _security = context.Instance as SealSecurity; _emailDevice = context.Instance as OutputEmailDevice; }
/// <summary> /// 编辑或新增一个报表 /// </summary> /// <param name="reportId"></param> /// <returns></returns> public ActionResult EditReport(long?reportId) { if (reportId == null || reportId == 0) { var model = new ReportOutput(); return(View(model)); } else { var report = _reportAppService.GetReport(reportId.Value); report.IsPlaceholder = report.IsPlaceholder == null ? false : report.IsPlaceholder.Value; return(View(report)); } }
public (bool created, string errorMessage) Generate(int id) { var data = _dataGetter.GetData(id); (bool valid, string errorMessage)result = _dataValidator.ValidateData(data); if (!result.valid) { return(result); } ReportOutput reportOutput = _dataFormatter.FormatData(data); return(_reportDistributor.DistributeReport(reportOutput)); }
public ReportOutput FormatData(ReportData data) { if (data == null) { throw new ApplicationException("Report data cannot be null"); } ReportOutput formattedData = new ReportOutput(); formattedData.FileName = data.MemberRecord.Name + ".txt"; formattedData.OutputLines.Add(data.MemberRecord.Name); formattedData.OutputLines.Add(data.MemberRecord.Address); formattedData.OutputLines.Add( data.MemberRecord.City + " " + data.MemberRecord.State + " " + data.MemberRecord.Zip ); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add(data.MemberRecord.Number.ToString()); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add( "Service date " + "Provider name " + "Service name " ); formattedData.OutputLines.Add("_".PadRight(70, '_')); foreach (var providedService in data.ProvidedServices) { string serviceDate = providedService.ServiceDate.Date.ToString("MM-dd-yyyy"); formattedData.OutputLines.Add( serviceDate.PadRight(15) + providedService.ProviderName.PadRight(30) + providedService.ServiceName.PadRight(25) ); } return(formattedData); }
public async Task ReadAsync(TProtocol iprot, CancellationToken cancellationToken) { iprot.IncrementRecursionDepth(); try { TField field; await iprot.ReadStructBeginAsync(cancellationToken); while (true) { field = await iprot.ReadFieldBeginAsync(cancellationToken); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 0: if (field.Type == TType.Struct) { Success = new ReportOutput(); await Success.ReadAsync(iprot, cancellationToken); } else { await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); } break; default: await TProtocolUtil.SkipAsync(iprot, field.Type, cancellationToken); break; } await iprot.ReadFieldEndAsync(cancellationToken); } await iprot.ReadStructEndAsync(cancellationToken); } finally { iprot.DecrementRecursionDepth(); } }
void setContext(ITypeDescriptorContext context) { _metaConnection = context.Instance as MetaConnection; _metaEnum = context.Instance as MetaEnum; _metaTable = context.Instance as MetaTable; _metaColumn = context.Instance as MetaColumn; _metaJoin = context.Instance as MetaJoin; _reportView = context.Instance as ReportView; _reportOutput = context.Instance as ReportOutput; _reportSchedule = context.Instance as ReportSchedule; _parameter = context.Instance as Parameter; _security = context.Instance as SealSecurity; _emailDevice = context.Instance as OutputEmailDevice; _fileServerDevice = context.Instance as OutputFileServerDevice; _model = context.Instance as ReportModel; _configuration = context.Instance as SealServerConfiguration; _widget = context.Instance as DashboardWidget; }
public void Generate_invalid() { var reportOutput = new ReportOutput(); var reportData = new ReportData(); _dataGetterMock.Setup(c => c.GetData(3)).Returns(reportData); _dataValidatorMock.Setup(c => c.ValidateData(reportData)).Returns((false, "")); var result = _report.Generate(3); Assert.AreEqual(false, result.created); Assert.AreEqual("", result.errorMessage); _dataGetterMock.Verify(c => c.GetData(3), Times.Once); _dataValidatorMock.Verify(c => c.ValidateData(reportData), Times.Once); }
void UpdateOutputReport() { if (IsConnected) { if (SendByOutputReport) { if (USB.SpecifiedDevice.OutputReportLength > 0) { ReportOutput.Clear(); for (UInt16 i = 0; i < USB.SpecifiedDevice.OutputReportLength; i++) { ReportOutput.Add(new ReportByte()); } } else { ReportOutput.Clear(); } } else { if (USB.SpecifiedDevice.FeatureReportLength > 0) { ReportOutput.Clear(); for (UInt16 i = 0; i < USB.SpecifiedDevice.FeatureReportLength; i++) { ReportOutput.Add(new ReportByte()); } } else { ReportOutput.Clear(); } } } else { ReportInput.Clear(); ReportOutput.Clear(); } }
public override CommandResult Execute(string parameter) { try { ServiceProvider serviceProvider = ComposeServiceProvider(MinerConfig.GetInstance().InstanceType); int instanceId = MinerConfig.GetInstance().InstanceId; serviceInstance = serviceProvider.AquaireInstance(instanceId); ReportOutput outputResult = new ReportOutput(); outputResult.Status = ReportOutput.StatusEnum.Unknown; if (!serviceInstance.IsServiceExist()) { outputResult.Status = ReportOutput.StatusEnum.NotInstalled; } else if (!serviceInstance.IsServiceRunning()) { outputResult.Status = ReportOutput.StatusEnum.Stopped; } else { // Retrieve the miner status from NamedPipe QueryServiceStatusByNamedPipe(outputResult); } return(CommandResult.CreateResult(outputResult)); } catch (TargetExecutionException ex) { throw ex; } catch (Exception ex) { throw new TargetExecutionException(DaemonErrorCode.UNKNOWN_ERROR, ex); } }
private List <ReportOutput> totalScansandReports(Dictionary <long, ReportStaging> start, Dictionary <long, ReportStaging> end, List <ReportResultAll> resultNew, Dictionary <long, List <ReportResultAll> > lastScan, Dictionary <long, ScanCount> scanCount) { List <ReportOutput> reports = new List <ReportOutput>(); getScans scans = new getScans(); foreach (long key in start.Keys) { ReportOutput report = new ReportOutput(); ReportStaging first = start[key]; ReportStaging last = end[key]; List <ReportResultAll> lastScanResults = lastScan[key]; foreach (ReportResultAll result in resultNew) { if (result.projectId == first.ProjectId) { if (result.status == "New") { if (result.Severity == "High") { report.NewHigh++; } else if (result.Severity == "Medium") { report.NewMedium++; } else if (result.Severity == "Low") { report.NewLow++; } } } } foreach (ReportResultAll result in lastScanResults) { if (result.state == 0) { report.ToVerify++; } else if (result.state == 1) { report.NotExploitable++; } else if (result.state == 2) { report.Confirmed++; } } //report.TeamName = first.TeamName; string[] split; if (first.TeamName.Contains('\\')) { split = first.TeamName.Split('\\'); } else { split = first.TeamName.Split('/'); } if (split.Length > 1) { report.company = split[split.Length - 2]; report.team = split[split.Length - 1]; } report.ProjectName = first.ProjectName; report.StartHigh = first.High; report.StartMedium = first.Medium; report.StartLow = first.Low; report.firstScan = first.dateTime; report.LastHigh = last.High; report.LastMedium = last.Medium; report.LastLow = last.Low; report.lastScan = last.dateTime; report.DiffHigh = first.High - last.High; report.DiffMedium = first.Medium - last.Medium; report.DiffLow = first.Low - last.Low; report.ScanCount = scanCount[key].count; reports.Add(report); } return(reports); }
private List <ReportOutput> totalScansandReports(Dictionary <long, ReportStaging> start, Dictionary <long, ReportStaging> end, List <ReportResultNew> resultNew, Dictionary <long, List <ReportResultNew> > lastScan, Dictionary <long, ScanCount> scanCount) { List <ReportOutput> reports = new List <ReportOutput>(); foreach (long key in start.Keys) { ReportOutput report = new ReportOutput(); ReportStaging first = start[key]; ReportStaging last = end[key]; List <ReportResultNew> lastScanResults = lastScan[key]; foreach (ReportResultNew result in resultNew) { if (result.projectId == first.ProjectId) { if (result.status == "New") { if (result.Severity == "High") { report.NewHigh++; } else if (result.Severity == "Medium") { report.NewMedium++; } else if (result.Severity == "Low") { report.NewLow++; } } } } foreach (ReportResultNew result in lastScanResults) { if (result.state == 0) { report.ToVerify++; } else if (result.state == 1) { report.NotExploitable++; } else if (result.state == 2) { report.Confirmed++; } } report.ProjectName = first.ProjectName; report.StartHigh = first.High; report.StartMedium = first.Medium; report.StartLow = first.Low; report.firstScan = first.dateTime; report.LastHigh = last.High; report.LastMedium = last.Medium; report.LastLow = last.Low; report.lastScan = last.dateTime; report.DiffHigh = first.High - last.High; report.DiffMedium = first.Medium - last.Medium; report.DiffLow = first.Low - last.Low; report.ScanCount = scanCount[key].count; reports.Add(report); } return(reports); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { MetaColumn column = context.Instance as MetaColumn; ReportElement element = context.Instance as ReportElement; ReportOutput output = context.Instance as ReportOutput; SealServerConfiguration config = context.Instance as SealServerConfiguration; List <string> choices = new List <string>(); choices.Add(""); if (element != null) { if (element.IsNumeric) { addNumericChoices(choices); } else if (element.IsDateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(element.FormatEl) && !choices.Contains(element.FormatEl)) { choices.Add(element.FormatEl); } } else if (column != null) { if (column.Type == ColumnType.Numeric) { addNumericChoices(choices); } else if (column.Type == ColumnType.DateTime) { addDateTimeChoices(choices); } else { addStringChoices(choices); } if (!string.IsNullOrEmpty(column.Format) && !choices.Contains(column.Format)) { choices.Add(column.Format); } } else if (output != null) { choices.Clear(); choices.Add(Repository.SealReportDisplayNameKeyword); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd}"); choices.Add(Repository.SealReportDisplayNameKeyword + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Report.ExecutionName); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd}"); choices.Add(output.Report.ExecutionName + "_{0:yyyy_MM_dd HH_mm_ss}"); choices.Add(output.Name); choices.Add(output.Name + "_{0:yyyy_MM_dd}"); choices.Add(output.Name + "_{0:yyyy_MM_dd HH_mm_ss}"); if (!string.IsNullOrEmpty(output.FileName) && !choices.Contains(output.FileName)) { choices.Add(output.FileName); } } else if (config != null) { if (context.PropertyDescriptor.Name == "NumericFormat") { addNumericChoices(choices); } else if (context.PropertyDescriptor.Name == "DateTimeFormat") { addDateTimeChoices(choices); } else { addStringChoices(choices); } } return(new StandardValuesCollection(choices.ToArray())); }
/// <summary> /// Sample return value from Service: /// status : running|disconnected|connected /// hash_rate : [double] /// </summary> /// <param name="hashRate"></param> /// <returns></returns> private void QueryServiceStatusByNamedPipe(ReportOutput outputResult) { outputResult.HashRate = 0; string pipelineOutput = string.Empty; try { using (var client = new NamedPipeClientStream(serviceInstance.NamedPipeName)) { client.Connect(3000); using (StreamReader reader = new StreamReader(client)) { using (StreamWriter writer = new StreamWriter(client)) { string status = ReadFromNamedPipe(reader, writer, "status"); string hashRateStr = ReadFromNamedPipe(reader, writer, "hashrate"); switch (status) { case MinerServiceState.Idle: break; case MinerServiceState.Initialzing: outputResult.Status = ReportOutput.StatusEnum.Initializing; break; case MinerServiceState.Connected: outputResult.Status = ReportOutput.StatusEnum.Connected; break; case MinerServiceState.Disconnected: outputResult.Status = ReportOutput.StatusEnum.Disconnected; break; case MinerServiceState.Error: outputResult.Status = ReportOutput.StatusEnum.Error; outputResult.Details = ReadFromNamedPipe(reader, writer, "details"); break; case MinerServiceState.Mining: outputResult.Status = ReportOutput.StatusEnum.Mining; outputResult.HashRate = Double.Parse(hashRateStr); break; default: throw new TargetExecutionException(DaemonErrorCode.REPORT_NAMEDPIPE_ERROR, "status=" + status); } } } } } catch (Exception ex) { //// outputResult.Status = ReportOutput.StatusEnum.NotInstalled; //TODO: Handle exceptions throw new TargetExecutionException(DaemonErrorCode.REPORT_NAMEDPIPE_ERROR, ex); } }
void LoadSalesReport(object sender, DoWorkEventArgs e) { var results = new ReportOutput(); var dateAmtList = new Dictionary <DateTime, double>(); string formatString = "dd/MM/yyyy"; results.SalesChartValues = new List <KeyValuePair <string, double> >(); results.TotalOrders = this.reportService.GetTotalOrders(this.FromSearchDate, this.ToSearchDate); results.TopCustomers = this.reportService.GetTopCustomers(10, this.FromSearchDate, this.ToSearchDate); results.TopProducts = this.reportService.GetTopProducts(10, this.FromSearchDate, this.ToSearchDate); ReportType repType = (ReportType)Enum.Parse(typeof(ReportType), e.Argument as string); switch (repType) { case ReportType.Daily: this.Title = string.Format(CultureInfo.CurrentUICulture, "Today Sales Report"); var orders = this.orderService.Search(new OrderSearchCondition { FromOrderDate = DateTime.Today, ToOrderDate = DateTime.Today }); if (orders != null && orders.Count > 0) { var hourly = orders.OrderBy(x => x.OrderDate).GroupBy(x => x.OrderDate.Hour); var hcnt = DateTime.Today; foreach (var item in hourly) { var key = item.First().OrderDate; var val = item.Sum(x => x.BillAmount); while (hcnt.Hour < item.Key) { dateAmtList.Add(hcnt, 0.0); hcnt = hcnt.AddHours(1); } dateAmtList.Add(hcnt, val); hcnt = hcnt.AddHours(1); } while (hcnt < DateTime.Today.AddHours(24)) { dateAmtList.Add(hcnt, 0.0); hcnt = hcnt.AddHours(1); } } formatString = "hh:mm tt"; break; case ReportType.Weekly: this.Title = string.Format(CultureInfo.CurrentUICulture, "This Week Sales Report. {0} to {1}", DateTime.Today.AddDays(-7).ToString("dd/MM/yyyy"), DateTime.Today.ToString("dd/MM/yyyy")); var weeklst = this.reportService.GetSalesReport(new OrderSearchCondition { FromOrderDate = DateTime.Today.AddDays(-7), ToOrderDate = DateTime.Today }); if (weeklst != null && weeklst.Count > 0) { var dcnt = DateTime.Today.AddDays(-7); int cnt = 1; foreach (var item in weeklst) { if (dcnt != item.Key) { while (dcnt < item.Key) { dateAmtList.Add(dcnt, 0.0); dcnt = dcnt.AddDays(1); } } dateAmtList.Add(item.Key, item.Value); dcnt = dcnt.AddDays(1); cnt++; } while (dcnt < DateTime.Today) { dateAmtList.Add(dcnt, 0.0); dcnt = dcnt.AddDays(1); } } formatString = "dd/MM/yyyy"; break; case ReportType.Monthly: var frm = DateTime.Parse(DateTime.Today.Month + "/01/" + DateTime.Today.Year); var to = DateTime.Parse(DateTime.Today.Month + "/" + DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month) + "/" + DateTime.Today.Year); this.Title = string.Format(CultureInfo.CurrentUICulture, "This Month Sales Report. {0} to {1}", frm, to.ToString("dd/MM/yyyy")); var daysAmt = this.reportService.GetSalesReport(new OrderSearchCondition { FromOrderDate = frm, ToOrderDate = to }); if (daysAmt != null && daysAmt.Count > 0) { var dcnt = 1; foreach (var item in daysAmt) { var key = item.Key; var value = item.Value; if (dcnt != key.Day) { while (dcnt < key.Day) { dateAmtList.Add(frm.AddDays(dcnt - 1), 0.0); dcnt++; } } dateAmtList.Add(key, value); dcnt++; } while (dcnt < DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month)) { dateAmtList.Add(frm.AddDays(dcnt - 1), 0.0); dcnt++; } } formatString = "dd/MM"; break; case ReportType.Yearly: this.Title = string.Format(CultureInfo.CurrentUICulture, "This Year Sales Report. {0} to {1}", DateTime.Parse("01/01/" + DateTime.Today.Year).ToString("dd/MM/yyyy"), DateTime.Today.ToString("dd/MM/yyyy")); var lst = this.reportService.GetSalesReport(new OrderSearchCondition { FromOrderDate = DateTime.Parse("01/01/" + DateTime.Today.Year), ToOrderDate = DateTime.Today }); if (lst != null && lst.Count > 0) { var monthly = lst.GroupBy(x => x.Key.Month); int mcnt = 1; foreach (var m in monthly) { var key = m.First().Key; var val = m.Sum(x => x.Value); if (mcnt != key.Month) { while (mcnt < key.Month) { dateAmtList.Add(DateTime.Parse(mcnt + "/01/" + key.Year), 0.0); mcnt++; } } dateAmtList.Add(key, val); mcnt++; } while (mcnt <= 12) { dateAmtList.Add(DateTime.Today.AddMonths(mcnt), 0.0); mcnt++; } } formatString = "MMMM"; break; case ReportType.SpecificPeriod: this.Title = string.Format(CultureInfo.CurrentUICulture, "Sales Report from {0} to {1}", this.FromSearchDate.ToString("dd/MM/yyyy"), this.ToSearchDate.ToString("dd/MM/yyyy")); lst = this.reportService.GetSalesReport(new OrderSearchCondition { FromOrderDate = this.FromSearchDate, ToOrderDate = this.ToSearchDate }); if ((this.ToSearchDate.Year - this.FromSearchDate.Year) > 1) { var monthly = lst.GroupBy(x => x.Key.Month); foreach (var m in monthly) { var key = m.First().Key; var val = m.Sum(x => x.Value); dateAmtList.Add(key, val); } formatString = "yyyy"; } else if ((this.ToSearchDate.Month - this.FromSearchDate.Month) > 1) { var monthly = lst.GroupBy(x => x.Key.Month); foreach (var m in monthly) { var key = m.First().Key; var val = m.Sum(x => x.Value); dateAmtList.Add(key, val); } formatString = "MMMM"; } else if ((this.ToSearchDate.Day - this.FromSearchDate.Day) == 0 && (this.ToSearchDate.Month == this.FromSearchDate.Month) && (this.ToSearchDate.Year == this.FromSearchDate.Year)) { orders = this.orderService.Search(new OrderSearchCondition { FromOrderDate = DateTime.Today, ToOrderDate = DateTime.Today }); if (orders != null && orders.Count > 0) { foreach (var item in orders) { dateAmtList.Add(item.OrderDate, item.BillAmount); } } formatString = "hh:mm tt"; } else { dateAmtList = lst; formatString = "dd/MM/yyyy"; } break; } if (dateAmtList != null && dateAmtList.Count > 0) { foreach (var item in dateAmtList) { var key = item.Key.ToString(formatString); results.SalesChartValues.Add(new KeyValuePair <string, double>(key, Math.Round(item.Value))); } } e.Result = results; }
public ReportOutput FormatData(ReportData data) { if (data == null) { throw new ApplicationException("Report data cannot be null"); } ReportOutput formattedData = new ReportOutput(); formattedData.FileName = data.ProviderRecord.Name + ".txt"; formattedData.OutputLines.Add(data.ProviderRecord.Name); formattedData.OutputLines.Add(data.ProviderRecord.Address); formattedData.OutputLines.Add( data.ProviderRecord.City + " " + data.ProviderRecord.State + " " + data.ProviderRecord.Zip ); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add(data.ProviderRecord.Number.ToString()); formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add( "Service date " + "Date record received " + "Member name " + "Member ID " + "Service ID " + "Fee " ); formattedData.OutputLines.Add("_".PadRight(106, '_')); foreach (var providedService in data.ProvidedServices) { string serviceDate = providedService.ServiceDate.ToString("MM-dd-yyyy"); string dateReceived = providedService.DateTimeReceived.ToString("MM-dd-yyyy HH:mm:ss"); _totalFee = _totalFee + providedService.Fee; _totalConsultations++; formattedData.OutputLines.Add( serviceDate.PadRight(15) + dateReceived.PadRight(24) + providedService.MemberName.PadRight(30) + providedService.MemberId.ToString().PadRight(14) + providedService.ServiceId.ToString().PadRight(11) + providedService.Fee.ToString("C").PadRight(12) ); } formattedData.OutputLines.Add("\n"); formattedData.OutputLines.Add(_totalConsultations.ToString()); formattedData.OutputLines.Add(_totalFee.ToString("C")); return(formattedData); }
static async Task Main(string[] args) { ///Start connetion Console.WriteLine("Starting Thrift Client!"); var localost = "10.1.2.12"; var client = new TcpClient(localost, 9095); /// This is the SSL certificate to be used X509Certificate2 certificate = new X509Certificate2("C:/FM/mySrvKeystore.p12", "thrift"); Thrift.Transport.TTransport transport = new TTlsSocketTransport(client, certificate, false, null, null, SslProtocols.Tls12); var protocol = new TBinaryProtocol(transport); ///Create multiple TMultiplexedProtocol for each service that is needed TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "ReportingService"); var reportingClient = new ReportingService.Client(mp); ///the client server is now connected Console.WriteLine("connected"); //Available Report List from FM ///string reportName = "FxCashPnLReport"; ///Sales FXCash P&L ReportASIC Report ///Customer MTM Report ///SpotVolReport ///CptyWiseSpotVolReport ///CashflowReport ///TarnCashflowReport ///PnL Report ///DealSummaryReport ///SpotVolReport ///DealEnquiryReport ///CashflowReport string dealSummaryEndpointURl = "https://localhost:5001/api/Risk/ReadDealSummary"; string spotVolEndpointURl = "https://localhost:5001/api/Risk/ReadSpotVol"; string reportName = "DealSummaryReport"; string Id = string.Empty; DateTime now = DateTime.Now; string nowString = now.ToString("yyyy-mm-dd hh:mm:ss"); string reportDate = "2020-10-10 18:00:00"; ReportOutput output = await reportingClient.getBatchReportsAsync(reportName, reportDate); byte[] result = output.Result; //close the connection Console.WriteLine("done"); transport.Close(); try { Id = FMReports.Services.InsertByteArrayintoSqlDatabase.StoreByteArrayintoSqlDatabase(result, reportName); Console.WriteLine(reportName + " data has been inserted to SQL database " + Id); } catch (Exception e) { Console.WriteLine(e.Message); } ////try ////{ //// FileStream fs = new FileStream("C:\\FM\\" + reportName + ".csv", FileMode.Create, FileAccess.ReadWrite); //// BinaryWriter bw = new BinaryWriter(fs); //// bw.Write(result); //// Console.WriteLine("csv file created"); ////} ////catch (Exception e) ////{ //// Console.WriteLine(e.Message); ////} /// try { if (reportName == "DealSummaryReport") { await PostRequest(dealSummaryEndpointURl, Id); } else { await PostRequest(spotVolEndpointURl, Id); } } catch (Exception e) { Console.WriteLine(e.Message); } }