コード例 #1
0
        public ActionResult Index()
        {
            IEnumerable <ReportDTO> ReportDtos = ReportService.GetReports();
            var mapper  = new MapperConfiguration(cfg => cfg.CreateMap <ReportDTO, ReportViewModel>()).CreateMapper();
            var Reports = mapper.Map <IEnumerable <ReportDTO>, List <ReportViewModel> >(ReportDtos);
            //email = Request.QueryString["email"];

            /// STRATEGY
            var calculatorContext = new Report2(new CalculatorO3());
            var O3Total           = calculatorContext.Calculate(ReportDtos);

            calculatorContext.SetCalculator(new CalculatorNO2());
            var NO2Total = calculatorContext.Calculate(ReportDtos);

            calculatorContext.SetCalculator(new CalculatorSO2());
            var SO2Total = calculatorContext.Calculate(ReportDtos);

            ViewBag.O3Result  = O3Total;
            ViewBag.NO2Result = NO2Total;
            ViewBag.SO2Result = SO2Total;

            /// TEMPLATE
            AbstractClass result = new Formula1();

            result.Calculating(O3Total, NO2Total, SO2Total);
            ViewBag.F1S1 = result.FirstStep(O3Total, NO2Total, SO2Total);
            ViewBag.F1S2 = result.SecondStep(O3Total, NO2Total, SO2Total);
            ViewBag.F1S3 = result.ThirdStep(O3Total, NO2Total, SO2Total);
            result       = new Formula2();
            result.Calculating(O3Total, NO2Total, SO2Total);
            ViewBag.F2S1 = result.FirstStep(O3Total, NO2Total, SO2Total);
            ViewBag.F2S2 = result.SecondStep(O3Total, NO2Total, SO2Total);
            ViewBag.F2S3 = result.ThirdStep(O3Total, NO2Total, SO2Total);

            /// FACADE
            Subsystem1 subsystem1 = new Subsystem1();
            Subsystem2 subsystem2 = new Subsystem2();
            Facade     facade     = new Facade(subsystem1, subsystem2);

            ViewBag.FCD_S1_O1 = subsystem1.operation1(O3Total, NO2Total, SO2Total);
            ViewBag.FCD_S1_ON = subsystem1.operationN(O3Total, NO2Total, SO2Total);
            ViewBag.FCD_S2_O1 = subsystem2.operation1(O3Total, NO2Total, SO2Total);
            ViewBag.FCD_S2_OZ = subsystem2.operationZ(O3Total, NO2Total, SO2Total);



            return(View(Reports));
        }