public JsonResult SaveDetailUnitReport(UnitReport objReport) { try { UnitReportDAL objCtrl = new UnitReportDAL(); if (objReport.DayReport != null) { objReport.DayReport = objReport.DayReport.ToLocalTime(); } if (objReport.Id > 0) { objReport.UpdatedBy = SysBaseInfor.GetCurrentUserId(); objCtrl.UpdateItem(objReport); return(Json(new { Msg = "Success", Type = "Edit" })); } else { objReport.Status = 0; objReport.CreatedBy = SysBaseInfor.GetCurrentUserId(); objReport.UnitId = SysBaseInfor.GetCurrentUnitId().ToInt32(); objCtrl.CreateItem(objReport); return(Json(new { Msg = "Success", Type = "Create" })); } } catch (Exception ex) { return(Json(new { Msg = "Fail" })); } }
public JsonResult PublishUnitReport(int reportId, int?TypeSelect) { try { UnitReportDAL objCtrl = new UnitReportDAL(); UnitReport obj = objCtrl.GetItemByID("Id", reportId); if (obj.Id > 0) { obj.PublishedBy = SysBaseInfor.GetCurrentUserId(); obj.PublishedAt = DateTime.Now; if (TypeSelect > 0) { obj.Status = 0; } else { obj.Status = 1; } objCtrl.UpdateItem(obj); } return(Json(new { Msg = "Success" })); } catch (Exception ex) { return(Json(new { Msg = "Fail" })); } }
private Task HandleSuccess(string username, UnitReport unitReport, IMessageHandlerContext context) { var data = unitReport.SerializeMessage(); return context.Publish<IUnitPlanPromoted>(e => { e.Username = username; e.Organization = unitReport.Organization; e.UnitReport = unitReport; e.SerializedData = data; }); }
public ActionResult ShowDetailUnitReport(int reportId, int?TypeSelect) { try { UnitReportDAL unitReportCtrl = new UnitReportDAL(); var vnFormat = new CultureInfo("VI-vi"); var listDayForSelect = new List <SelectListItem>(); if (TypeSelect > 0) { DateTime startOfWeek = DateTime.Today.AddDays(-1 * (int)(DateTime.Today.DayOfWeek) + 1); DateTime endOfWeek = startOfWeek.AddDays(5); for (int tmpI = (int)DateTime.Today.DayOfWeek; tmpI < 7; tmpI++) { var tmpDow = DateTime.Today.AddDays(tmpI - (int)DateTime.Today.DayOfWeek); listDayForSelect.Add(new SelectListItem() { Text = vnFormat.DateTimeFormat.GetDayName(tmpDow.DayOfWeek) + " " + tmpDow.ToString("dd/MM/yyyy"), Value = tmpDow.ToString() }); } } else { listDayForSelect.Add(new SelectListItem() { Text = vnFormat.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek) + " " + DateTime.Now.ToString("dd/MM/yyyy"), Value = DateTime.Now.ToString("dd/MM/yyyy") }); } ViewBag.ListDayForSelect = new SelectList(listDayForSelect, "Value", "Text"); var roleManager = HttpContext.GetOwinContext().Get <ApplicationRoleManager>(); ViewBag.ListGroupRoles = new SelectList(roleManager.GetListRoleByUnitIdAndType(SysBaseInfor.GetCurrentUnitCode() + SysBaseInfor.SignProject, SysBaseInfor.GetCurrentUnitId().ToInt32(), 2), "Id", "Name"); var result = new UnitReport(); if (reportId > 0) { result = unitReportCtrl.GetItemByID("Id", reportId); } return(PartialView("~/Views/UnitReport/_DetailUnitReport.cshtml", result)); } catch (Exception ex) { return(PartialView(blankViewUrl)); } }
public static UnitReport BuildAndPersistUnitReport(bool submitted, Organization organization, ReportingPeriod reportingPeriod, ISession s) { string description = DataProvider.Get <string>(); var reportingData = new ReportDataBuilder().Build(); var report = new UnitReport(description, organization, reportingPeriod, reportingData); if (submitted) { report.MarkStatusAsSubmitted(); } s.Save(report); return(report); }
public ActionResult UnitReport(string designation, string title, int?semester, DateTime?beginDate, DateTime?endDate, int?lecturerId, string status) { UnitSearch unitSearch = new UnitSearch(this.DatabaseContext); unitSearch.Designation = designation; unitSearch.Title = title; unitSearch.Semester = semester; unitSearch.BeginDate = beginDate; unitSearch.EndDate = endDate; unitSearch.LecturerId = lecturerId; unitSearch.SetStatus(status); UnitReport report = new UnitReport(); report.Search = unitSearch; return(Content(report.CreateReport(), "text/html")); }
public void PromotePlanToUnitReport_SavesCorrectlyWhenLastYearSubmitted(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var organizationType = OrganizationType.Unit; var description = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, organizationType) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var period1 = new ReportingPeriod(reportingFrequency, reportingTerm, year); var period1ReportingData = new ReportDataBuilder().Build(); var period1UnitReport = new UnitReport(description, organization, period1, period1ReportingData); s.Save(period1UnitReport); return(new { period1UnitReport, }); }); var result = Endpoint.Act(AssemblySetupFixture.EndpointTestContainer, c => { var unitReport = c.GetInstance <UnitReportService>() .PromotePlanToUnitReport(testParams.period1UnitReport.Id); return(new { unitReport }); }); result.unitReport.Should().NotBeNull(); result.unitReport.Should().BeEquivalentTo(testParams.period1UnitReport, e => e.Excluding(p => p.ReportStatus)); result.unitReport.ReportStatus.Should().Be(ReportStatus.PlanPromoted); }
private UnitReport CreateNew(string description, OrganizationReference organizationRef, ReportingTerm reportingTerm, int year, ReportingFrequency reportingFrequency, bool isAi = false) { var organization = _session.Query <Organization>().Single(o => o.Id == organizationRef.Id); if (organization.OrganizationType != OrganizationType.Unit) { throw new ArgumentException("Invalid Organization Type"); } if (reportingFrequency != organization.ReportingFrequency) { throw new ArgumentException("Invalid Reporting Frequency"); } var reportingPeriod = new ReportingPeriod(reportingFrequency, reportingTerm, year); var reportData = isAi ? GetReportDataAi(organization, reportingPeriod) : ReportData.Default(); var report = new UnitReport(description, organization, reportingPeriod, reportData); _session.Save(report); return(report); }
public void CreateNewUnitPlanAi_SavesCorrectlyWhenLastYearSubmitted(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var organizationType = OrganizationType.Unit; var description = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, organizationType) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); OrganizationReference organizationRef = organization; var reportingPeriod = new ReportingPeriod(reportingFrequency, reportingTerm, year); var lastPeriod1 = reportingPeriod.GetReportingPeriodOfPreviousTerm(); var lastPeriod1ReportingData = new ReportDataBuilder().Build(); var lastPeriod1UnitReport = new UnitReport(description, organization, lastPeriod1, lastPeriod1ReportingData); lastPeriod1UnitReport.MarkStatusAsSubmitted(); s.Save(lastPeriod1UnitReport); var lastPeriod2 = lastPeriod1.GetReportingPeriodOfPreviousTerm(); var lastPeriod2ReportingData = new ReportDataBuilder().Build(); var lastPeriod2UnitReport = new UnitReport(description, organization, lastPeriod2, lastPeriod2ReportingData); lastPeriod2UnitReport.MarkStatusAsSubmitted(); s.Save(lastPeriod2UnitReport); var expected = new UnitReportBuilder() .SetDescription(description) .SetOrganization(organization) .SetReportingPeriod(new ReportingPeriod(reportingFrequency, reportingTerm, year)) .Build(); return(new { description, organizationRef, reportingPeriod, lastPeriod1UnitReport, expected }); }); var result = Endpoint.Act(AssemblySetupFixture.EndpointTestContainer, c => { var unitReport = c.GetInstance <UnitReportFactory>() .CreateNewUnitPlanAi(testParams.description, testParams.organizationRef, testParams.reportingPeriod.ReportingTerm, testParams.reportingPeriod.Year, reportingFrequency); return(new { unitReport }); }); result.unitReport.Should().NotBeNull(); result.unitReport.Should().BeEquivalentTo(testParams.expected, e => e.Excluding(p => p.Id) .Excluding(p => p.AssociateMemberData) .Excluding(p => p.PreliminaryMemberData) .Excluding(p => p.WorkerMeetingProgramData) .Excluding(p => p.SupporterMemberData) .Excluding(p => p.DawahMeetingProgramData) .Excluding(p => p.MemberMemberData)); TestHelper.MemberDataForCreateUnitPlanShouldBeEquivalent(result.unitReport.AssociateMemberData, testParams.lastPeriod1UnitReport.AssociateMemberData); TestHelper.MemberDataForCreateUnitPlanShouldBeEquivalent(result.unitReport.PreliminaryMemberData, testParams.lastPeriod1UnitReport.PreliminaryMemberData); result.unitReport.PreliminaryMemberData.Should().BeEquivalentTo(testParams.lastPeriod1UnitReport.WorkerMeetingProgramData); }
public static ReportData GetCalculatedReportData(UnitReport[] onlyRecentUnitReports, UnitReport[] allUnitReports, ZoneReport[] onlyRecentZoneReports = null, ZoneReport[] allZoneReports = null, StateReport[] onlyRecentStateReports = null, StateReport[] allStateReports = null, CentralReport[] onlyRecentCentralReports = null, CentralReport[] allCentralReports = null ) { if (onlyRecentUnitReports == null) { onlyRecentUnitReports = new UnitReport[0]; } if (onlyRecentZoneReports == null) { onlyRecentZoneReports = new ZoneReport[0]; } if (onlyRecentStateReports == null) { onlyRecentStateReports = new StateReport[0]; } if (onlyRecentCentralReports == null) { onlyRecentCentralReports = new CentralReport[0]; } if (allUnitReports == null) { allUnitReports = new UnitReport[0]; } if (allZoneReports == null) { allZoneReports = new ZoneReport[0]; } if (allStateReports == null) { allStateReports = new StateReport[0]; } if (allCentralReports == null) { allCentralReports = new CentralReport[0]; } return(Calculator.GetCalculatedReportData(onlyRecentUnitReports.Select(o => { ReportData r = o; return r; }).ToArray(), allUnitReports.Select(o => { ReportData r = o; return r; }).ToArray(), onlyRecentZoneReports.Select(o => { ReportData r = o; return r; }).ToArray(), allZoneReports.Select(o => { ReportData r = o; return r; }).ToArray(), onlyRecentStateReports.Select(o => { ReportData r = o; return r; }).ToArray(), allStateReports.Select(o => { ReportData r = o; return r; }).ToArray(), onlyRecentCentralReports.Select(o => { ReportData r = o; return r; }).ToArray(), allCentralReports.Select(o => { ReportData r = o; return r; }).ToArray())); }
private void timer_Main_Tick(object sender, EventArgs e) { String str_actualTrayIconText = this.TrayIcon.Text; this.TrayIcon.Text = "Working. Be patient."; foreach (FileInfo actFI in this.SearchDirectory.GetFiles()) { if (actFI.Extension.ToLower() != ".txt") { continue; } StreamReader sr = new StreamReader(actFI.OpenRead()); SpeaReport[] SpeaFileReports = { }; while (!sr.EndOfStream) { String[] ar_LineElements = sr.ReadLine().Split(';'); if (ar_LineElements[0] != "START") { continue; } SpeaReport actSpeaReport = new SpeaReport(); if (sr.EndOfStream) { continue; } /* * String[] ar_NextLE = sr.ReadLine().Split(';'); * if (ar_NextLE[0] != "SN") * { * * } */ actSpeaReport.ReportHeader.ProductID = ar_LineElements[1]; actSpeaReport.ReportHeader.OperatorID = ar_LineElements[5]; DateTime startTime; try { startTime = new DateTime( Convert.ToInt32(ar_LineElements[6].Substring(6, 4)), Convert.ToInt32(ar_LineElements[6].Substring(0, 2)), Convert.ToInt32(ar_LineElements[6].Substring(3, 2)), Convert.ToInt32(ar_LineElements[7].Substring(0, 2)), Convert.ToInt32(ar_LineElements[7].Substring(3, 2)), Convert.ToInt32(ar_LineElements[7].Substring(6, 2))); } catch { startTime = new DateTime( Convert.ToInt32(ar_LineElements[6].Substring(6, 4)), Convert.ToInt32(ar_LineElements[6].Substring(3, 2)), Convert.ToInt32(ar_LineElements[6].Substring(0, 2)), Convert.ToInt32(ar_LineElements[7].Substring(0, 2)), Convert.ToInt32(ar_LineElements[7].Substring(3, 2)), Convert.ToInt32(ar_LineElements[7].Substring(6, 2))); } if (startTime < new DateTime(2017, 4, 6, 4, 0, 0)) { continue; // only new reports are allowed to process } actSpeaReport.ReportHeader.StartTime = startTime.ToString(); ar_LineElements = sr.ReadLine().Split(';'); if (ar_LineElements[0] == "SN") { actSpeaReport.ReportHeader.SerialNumber = ar_LineElements[1]; ar_LineElements = sr.ReadLine().Split(';'); } else { actSpeaReport.ReportHeader.SerialNumber = "0000000000000"; } if (actSpeaReport.ReportHeader.SerialNumber.Length != 13) { continue; } if (DoubleResultCheck.IsWritten(actSpeaReport.ReportHeader.SerialNumber, startTime)) { actSpeaReport.Dispose(); continue; } while (!(ar_LineElements[0] == "BOARDRESULT")) { TestRunSpea actTRS = ParserFunctions.FormatLine(ar_LineElements); Array.Resize(ref actSpeaReport.ReportBody.TestRuns, actSpeaReport.ReportBody.TestRuns.Length + 1); actSpeaReport.ReportBody.TestRuns.SetValue(actTRS, actSpeaReport.ReportBody.TestRuns.Length - 1); ar_LineElements = sr.ReadLine().Split(';'); } actSpeaReport.ReportHeader.Grade = ar_LineElements[1]; ar_LineElements = sr.ReadLine().Split(';'); DateTime endTime = new DateTime( Convert.ToInt32(ar_LineElements[2].Substring(6, 4)), Convert.ToInt32(ar_LineElements[2].Substring(0, 2)), Convert.ToInt32(ar_LineElements[2].Substring(3, 2)), Convert.ToInt32(ar_LineElements[3].Substring(0, 2)), Convert.ToInt32(ar_LineElements[3].Substring(3, 2)), Convert.ToInt32(ar_LineElements[3].Substring(6, 2))); actSpeaReport.ReportHeader.EndTime = endTime.ToString(); Array.Resize(ref SpeaFileReports, SpeaFileReports.Length + 1); SpeaFileReports.SetValue(actSpeaReport, SpeaFileReports.Length - 1); } SpeaReport[] SpeaReportsToProcess = { }; if (SpeaFileReports.Length == 0) { continue; } for (Int32 i = 0; i < SpeaFileReports.Length; i++) { if ((SpeaFileReports[i].ReportHeader.SerialNumber == "0000000000000") && (SpeaReportsToProcess.Length == 0)) { continue; } if ((SpeaFileReports[i].ReportHeader.Grade == "PASS") && (SpeaFileReports[i].ReportHeader.SerialNumber != "0000000000000")) { Array.Resize(ref SpeaReportsToProcess, SpeaReportsToProcess.Length + 1); SpeaReportsToProcess.SetValue(SpeaFileReports[i], SpeaReportsToProcess.Length - 1); continue; } if (i < SpeaFileReports.Length - 1) { if (SpeaFileReports[i + 1].ReportHeader.SerialNumber == "0000000000000") { if (SpeaFileReports[i + 1].ReportHeader.Grade == "PASS") { SpeaFileReports[i].ReportHeader.Grade = "PASS"; } for (Int32 j = 0; j < SpeaFileReports[i].ReportBody.TestRuns.Length; j++) { if (SpeaFileReports[i].ReportBody.TestRuns[j].TestGrade == "FAIL") { for (Int32 k = 0; k < SpeaFileReports[i + 1].ReportBody.TestRuns.Length; k++) { if (SpeaFileReports[i].ReportBody.TestRuns[j].TestName == SpeaFileReports[i + 1].ReportBody.TestRuns[k].TestName) { SpeaFileReports[i].ReportBody.TestRuns[j] = SpeaFileReports[i + 1].ReportBody.TestRuns[k]; k = SpeaFileReports[i + 1].ReportBody.TestRuns.Length; } } } } } Array.Resize(ref SpeaReportsToProcess, SpeaReportsToProcess.Length + 1); SpeaReportsToProcess.SetValue(SpeaFileReports[i], SpeaReportsToProcess.Length - 1); continue; } } foreach (SpeaReport actSRTP in SpeaReportsToProcess) { UnitReport UR = new UnitReport(); UR.starttime = Convert.ToDateTime(actSRTP.ReportHeader.StartTime); UR.endtime = Convert.ToDateTime(actSRTP.ReportHeader.EndTime); UR.Operator = new _Operator(ConfigFile.GetOperatorPersonalNumber(actSRTP.ReportHeader.OperatorID)); UR.Cathegory.Product.SerialNo = actSRTP.ReportHeader.SerialNumber; UR.Cathegory.Product.PartNo = actSRTP.ReportHeader.ProductID; UR.AddProperty("Work Order", UR.Cathegory.Product.SerialNo.Substring(0, 8)); UR.TestRun.name = "ICT"; foreach (TestRunSpea actTRS in actSRTP.ReportBody.TestRuns) { UR.TestRun.AddTestRunChild(actTRS.TestName, Convert.ToDateTime(actSRTP.ReportHeader.StartTime), Convert.ToDateTime(actSRTP.ReportHeader.EndTime), actTRS.TestGrade, actTRS.MeasUnit, actTRS.MeasValue, actTRS.LowLimit, actTRS.HighLimit); } UR.Cathegory.name = "Default"; UR.mode = "P"; UR.TestNumberPrefix = false; Array actReport = UR.GetXMLReport(); String str_actReport = ""; foreach (String actLine in actReport) { str_actReport = String.Concat(str_actReport, actLine); } DoubleResultCheck.WriteResult(UR.Cathegory.Product.SerialNo, UR.starttime); if (!this.BelMesObj.EmployeeVerification(UR.Operator.ToString())) { ErrorHandling.Create("Neznamy operator.", false, false); } else { if (this.BelMesObj.BelMESAuthorization(UR.Cathegory.Product.SerialNo, "ICT", UR.Cathegory.Product.PartNo, "")) { Thread.Sleep(500); if (this.BelMesObj.SetActualResult(UR.Cathegory.Product.SerialNo, "ICT", UR.TestRun.grade, str_actReport)) { //DoubleResultCheck.WriteResult(UR.Cathegory.Product.SerialNo, UR.starttime); } } } } this.TrayIcon.Text = str_actualTrayIconText; } }
private Boolean GenerateReport(String SerialNumber, DateTime StartTime) { try { DateTime starttime = StartTime; DateTime endtime = StartTime.AddSeconds(5); UnitReport myReport = new UnitReport(starttime, endtime, "D", "", false); myReport.Operator.name = this.str_OperatorNr; myReport.Cathegory = new _Cathegory("Default"); myReport.Cathegory.Product = new _Product("", SerialNumber); //mozno pridam stlpec s PartNumberom, ktory vrati autorizacia belmesu myReport.TestRun.name = this.cb_TestTypes.Text; myReport.starttime = starttime; myReport.endtime = endtime; myReport.AddProperty("Work Order", SerialNumber.Substring(0, 8)); String URMode = myStationConfig.GetMode(); if (URMode == "") { URMode = "D"; } else { myReport.mode = URMode; } XmlNode assembliesNode = ProductsConfig.XmlFile.LastChild.SelectSingleNode("./Assemblies"); foreach (XmlNode actAssNode in assembliesNode.ChildNodes) { if (actAssNode.SelectSingleNode("./Name").InnerText == myReport.Cathegory.Product.PartNo) { XmlNode propertiesNode = actAssNode.SelectSingleNode("./Properties"); if (propertiesNode != null) { foreach (XmlNode actPropNode in propertiesNode) { myReport.AddProperty(actPropNode.Name, actPropNode.InnerText); } } } } XmlNode familyProperties = ProductsConfig.XmlFile.LastChild.SelectSingleNode("./Families"); foreach (XmlNode actFamilyNode in familyProperties.ChildNodes) { if (actFamilyNode.SelectSingleNode("./Name").InnerText == myReport.Cathegory.Product.PartNo) { XmlNode propertiesNode = actFamilyNode.SelectSingleNode("./Properties"); if (propertiesNode != null) { foreach (XmlNode actPropNode in propertiesNode) { myReport.AddProperty(actPropNode.Name, actPropNode.InnerText); } } } } Array commonProperties = myStationConfig.GetProperties(); for (int i = 0; i < commonProperties.GetLength(0); i++) { String actNameNode = commonProperties.GetValue(i, 0).ToString().Trim().Replace('_', ' '); myReport.AddProperty(actNameNode, commonProperties.GetValue(i, 1).ToString().Trim()); } StationConfig.StationInfos actSI = myStationConfig.GetStationInfosForTest(this.cb_TestTypes.Text); foreach (StationConfig.StationInfos.StationProperty actProp in actSI.StationProperties) { String actNameNode = actProp.Name.Replace('_', ' '); myReport.AddProperty(actNameNode, actProp.Value); } String StationName = actSI.Name; String StationGUID = actSI.GUID; myReport.TestRun.grade = "PASS"; myReport.Station = new _Station(StationGUID, StationName); if (this.act_SNS != null) { if (myReport.Cathegory.Product.SerialNo == this.act_SNS.SerialNumber) { foreach (StepInfo actFSI in this.act_SNS.Steps) { if (actFSI.Name.Trim() == "CustomerSerialNumber") { myReport.AddProperty("CustomerSN", actFSI.ResultValue); myReport.TestRun.AddTestRunChild(actFSI.Name, myReport.starttime, myReport.endtime, actFSI.Grade, actFSI.ResultValue, "*$*", actFSI.ResultValue); } else { myReport.TestRun.AddTestRunChild(actFSI.Name, myReport.starttime, myReport.endtime, actFSI.Grade, actFSI.ResultValue, "", "*$*"); } if (actFSI.Grade == "FAIL") { myReport.TestRun.grade = "FAIL"; } } } if (myReport.TestRun.grade == "FAIL") { myReport.AddProperty("To Repair", "Yes"); } } this.act_SNS = null; String strReportPath = this.myStationConfig.GetReportPathDirectory(); Array XmlReportLines; String XmlReportContent = ""; try { XmlReportLines = myReport.GetXMLReport(strReportPath, true); if (myReport.TestRun.grade == "") { MessageBox.Show("Problem pri vytvarani reportu. Zavolajte prosim technika."); this.Close(); } foreach (String ActLine in XmlReportLines) { XmlReportContent = String.Concat(XmlReportContent, ActLine); } } catch (Exception ex) { MessageBox.Show(ex.Message); } // if (this.objBelMes.Activated) { try { String testKind = this.cb_TestTypes.Text; if (testKind == "Adjustement") { testKind = "Adjustment"; } if (myReport.TestRun.grade.ToUpper().Trim() == "PASS") { myReport.TestRun.grade = "Pass"; } if (myReport.TestRun.grade.ToUpper().Trim() == "FAIL") { myReport.TestRun.grade = "Fail"; } if (this.objBelMes.SetActualResult(myReport.Cathegory.Product.SerialNo, testKind, String.Concat(myReport.TestRun.grade, "ed"), XmlReportContent)) { if (this.objBelMes.Authorization.intReturnCode == 0) { this.lbl_Info.ForeColor = System.Drawing.Color.Green; } else { if (this.objBelMes.Authorization.blnMustTraced) { this.lbl_Info.ForeColor = System.Drawing.Color.Red; } else { this.lbl_Info.ForeColor = System.Drawing.Color.FromArgb(255, 150, 0); } } //this.Authorization.TryAuthorization(myReport.Cathegory.Product.SerialNo, testKind, String.Concat(myReport.TestRun.grade, "ED"), this.Env, false, false, XmlReportContent); } else { return(false); } this.lbl_Info.Text = this.objBelMes.Authorization.strResult; } catch { return(false); } } return(true); } catch { return(false); } }
public async Task Handle_Publishes_ExpectedResult() { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var username = DataProvider.Get <string>(); var organizations = IntegrationTestOrganizationHelper.SetupOrzanizations(); var central = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.Central).Value; var nswState = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.NswState).Value; var nswZone1 = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.NswZoneOne).Value; var lakemba = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.Lakemba).Value; var year1 = 2019; var year2 = 2020; var period1 = new ReportingPeriod(ReportingFrequency.Monthly, ReportingTerm.One, year1); var period2 = new ReportingPeriod(ReportingFrequency.Monthly, ReportingTerm.One, year2); var period1ReportingData = new ReportDataBuilder().Build(); var period2ReportingData = new ReportDataBuilder().Build(); var period1UnitReport = new UnitReport(DataProvider.Get <string>(), lakemba, period1, period1ReportingData); s.Save(period1UnitReport); var period2UnitReport = new UnitReport(DataProvider.Get <string>(), lakemba, period2, period2ReportingData); s.Save(period2UnitReport); var period1ZoneReport = new ZoneReport(DataProvider.Get <string>(), nswZone1, period1, period1ReportingData); s.Save(period1ZoneReport); var period2ZoneReport = new ZoneReport(DataProvider.Get <string>(), nswZone1, period2, period2ReportingData); s.Save(period2ZoneReport); var period1StateReport = new StateReport(DataProvider.Get <string>(), nswState, period1, period1ReportingData); s.Save(period1StateReport); var period2StateReport = new StateReport(DataProvider.Get <string>(), nswState, period2, period2ReportingData); s.Save(period2StateReport); var period1CentralReport = new CentralReport(DataProvider.Get <string>(), central, period1, period1ReportingData); s.Save(period1CentralReport); var period2CentralReport = new CentralReport(DataProvider.Get <string>(), central, period2, period2ReportingData); s.Save(period2CentralReport); var reportIds = new[] { period1UnitReport.Id, period2UnitReport.Id, period1ZoneReport.Id, period2ZoneReport.Id, period1StateReport.Id, period2StateReport.Id, period1CentralReport.Id, period2CentralReport.Id, }; var expectedReportData = ReportDataCalculator.GetCalculatedReportData(new[] { period2UnitReport }, new[] { period1UnitReport, period2UnitReport }, new[] { period2ZoneReport }, new[] { period1ZoneReport, period2ZoneReport }, new[] { period2StateReport }, new[] { period1StateReport, period2StateReport }, new[] { period2CentralReport }, new[] { period1CentralReport, period2CentralReport }); return(new { username, expectedReportData, cmd = new ConsolidateReportCommand(reportIds), }); }); var context = await Endpoint.Act <ConsolidateReportCommandHandler>(AssemblySetupFixture.EndpointTestContainer, (h, ctx) => { ctx.SetUsernameOnHeader(testParams.username); return(h.Handle(testParams.cmd, ctx)); }); var evt = context.ExpectPublish <IConsolidateReportSucceeded>(); evt.ReportIds.Should().BeEquivalentTo(testParams.cmd.ReportIds); evt.ReportData.Should().BeEquivalentTo(testParams.expectedReportData); evt.Username.Should().BeEquivalentTo(testParams.username); }
public void PromotePlanToUnitReportAi_SavesCorrectlyWhenLastYearSubmitted(ReportingFrequency reportingFrequency) { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var organizationType = OrganizationType.Unit; var description = DataProvider.Get <string>(); var year = 2019; var reportingTerm = ReportingTerm.One; var organization = new TestObjectBuilder <Organization>() .SetArgument(o => o.OrganizationType, organizationType) .SetArgument(o => o.ReportingFrequency, reportingFrequency) .BuildAndPersist(s); var period1 = new ReportingPeriod(reportingFrequency, reportingTerm, year); var period1ReportingData = new ReportDataBuilder().Build(); var period1UnitReport = new UnitReport(description, organization, period1, period1ReportingData); s.Save(period1UnitReport); var lastPeriod2 = period1.GetReportingPeriodOfPreviousTerm(); var lastPeriod2ReportingData = new ReportDataBuilder().Build(); var lastPeriod2UnitReport = new UnitReport(description, organization, lastPeriod2, lastPeriod2ReportingData); lastPeriod2UnitReport.MarkStatusAsSubmitted(); s.Save(lastPeriod2UnitReport); return(new { period1UnitReport, lastPeriod2UnitReport }); }); var result = Endpoint.Act(AssemblySetupFixture.EndpointTestContainer, c => { var unitReport = c.GetInstance <UnitReportService>() .PromotePlanToUnitReportAi(testParams.period1UnitReport.Id); return(new { unitReport }); }); result.unitReport.Should().NotBeNull(); result.unitReport.Should().BeEquivalentTo(testParams.period1UnitReport, e => e.Excluding(p => p.ReportStatus) .Excluding(p => p.AssociateMemberData) .Excluding(p => p.PreliminaryMemberData) .Excluding(p => p.WorkerMeetingProgramData)); result.unitReport.ReportStatus.Should().Be(ReportStatus.PlanPromoted); result.unitReport.AssociateMemberData.UpgradeTarget.Should() .Be(testParams.period1UnitReport.AssociateMemberData.UpgradeTarget); result.unitReport.AssociateMemberData.LastPeriod.Should() .Be(testParams.period1UnitReport.AssociateMemberData.LastPeriod); result.unitReport.AssociateMemberData.ThisPeriod.Should() .Be(testParams.lastPeriod2UnitReport.AssociateMemberData.ThisPeriod); result.unitReport.PreliminaryMemberData.UpgradeTarget.Should() .Be(testParams.period1UnitReport.PreliminaryMemberData.UpgradeTarget); result.unitReport.PreliminaryMemberData.LastPeriod.Should() .Be(testParams.period1UnitReport.PreliminaryMemberData.LastPeriod); result.unitReport.PreliminaryMemberData.ThisPeriod.Should() .Be(testParams.lastPeriod2UnitReport.PreliminaryMemberData.ThisPeriod); //Worker meeting values should be initial values. Should not set last period values (as that will be irrelevant) result.unitReport.WorkerMeetingProgramData.Target.Should() .Be(testParams.period1UnitReport.WorkerMeetingProgramData.Target); result.unitReport.WorkerMeetingProgramData.Actual.Should() .Be(testParams.period1UnitReport.WorkerMeetingProgramData.Actual); result.unitReport.WorkerMeetingProgramData.AverageAttendance.Should() .Be(testParams.period1UnitReport.WorkerMeetingProgramData.AverageAttendance); }
public void GetConsolidatedReportData_Returns_ExpectedReportData() { DateTimeDbTestExtensions.SetUtcNowToRandomDate(); var testParams = Endpoint.ArrangeOnSqlSession(AssemblySetupFixture.EndpointTestContainer, s => { var organizations = IntegrationTestOrganizationHelper.SetupOrzanizations(); var central = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.Central).Value; var nswState = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.NswState).Value; var nswZone1 = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.NswZoneOne).Value; var lakemba = organizations.First(o => o.Key == IntegrationTestOrganizationHelper.Lakemba).Value; var year1 = 2019; var year2 = 2020; var period1 = new ReportingPeriod(ReportingFrequency.Monthly, ReportingTerm.One, year1); var period2 = new ReportingPeriod(ReportingFrequency.Monthly, ReportingTerm.One, year2); var period1ReportingData = new ReportDataBuilder().Build(); var period2ReportingData = new ReportDataBuilder().Build(); var period1UnitReport = new UnitReport(DataProvider.Get <string>(), lakemba, period1, period1ReportingData); s.Save(period1UnitReport); var period2UnitReport = new UnitReport(DataProvider.Get <string>(), lakemba, period2, period2ReportingData); s.Save(period2UnitReport); var period1ZoneReport = new ZoneReport(DataProvider.Get <string>(), nswZone1, period1, period1ReportingData); s.Save(period1ZoneReport); var period2ZoneReport = new ZoneReport(DataProvider.Get <string>(), nswZone1, period2, period2ReportingData); s.Save(period2ZoneReport); var period1StateReport = new StateReport(DataProvider.Get <string>(), nswState, period1, period1ReportingData); s.Save(period1StateReport); var period2StateReport = new StateReport(DataProvider.Get <string>(), nswState, period2, period2ReportingData); s.Save(period2StateReport); var period1CentralReport = new CentralReport(DataProvider.Get <string>(), central, period1, period1ReportingData); s.Save(period1CentralReport); var period2CentralReport = new CentralReport(DataProvider.Get <string>(), central, period2, period2ReportingData); s.Save(period2CentralReport); var reportIds = new[] { period1UnitReport.Id, period2UnitReport.Id, period1ZoneReport.Id, period2ZoneReport.Id, period1StateReport.Id, period2StateReport.Id, period1CentralReport.Id, period2CentralReport.Id, }; var expectedReportData = ReportDataCalculator.GetCalculatedReportData(new[] { period2UnitReport }, new[] { period1UnitReport, period2UnitReport }, new[] { period2ZoneReport }, new[] { period1ZoneReport, period2ZoneReport }, new[] { period2StateReport }, new[] { period1StateReport, period2StateReport }, new[] { period2CentralReport }, new[] { period1CentralReport, period2CentralReport }); return(new { reportIds, expectedReportData }); }); var result = Endpoint.Act(AssemblySetupFixture.EndpointTestContainer, c => c.GetInstance <ConsolidatedReportService>().GetConsolidatedReportData(testParams.reportIds)); result.Should().NotBeNull(); result.Should().BeEquivalentTo(testParams.expectedReportData); }