Exemplo n.º 1
0
        public PartialViewResult _LabSheetsHistory(int SamplingPlanID)
        {
            ViewBag.SamplingPlanController          = _SamplingPlanController;
            ViewBag.AdminContactModelList           = null;
            ViewBag.IsSamplingPlanner               = false;
            ViewBag.LabSheetModelList               = null;
            ViewBag.SamplingPlanID                  = SamplingPlanID;
            ViewBag.LabSheetModelList               = null;
            ViewBag.LabSheetSiteMonitoredCountsList = null;

            List <LabSheetModel> labSheetModelList = new List <LabSheetModel>();

            SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User);
            LabSheetService     labSheetService     = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMRunService      mwqmRunService      = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User);

            ContactModel contactModel = _ContactService.GetContactLoggedInDB();

            SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID);

            if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error))
            {
                ViewBag.IsSamplingPlanner = false;
                if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString()))
                {
                    ViewBag.IsSamplingPlanner = true;
                }
                else
                {
                    List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB();
                    ViewBag.AdminContactModelList = adminContactModelList;
                }

                labSheetModelList         = labSheetService.GetLabSheetModelListWithSamplingPlanIDDB(SamplingPlanID);
                ViewBag.LabSheetModelList = labSheetModelList;

                List <LabSheetSiteMonitoredCounts> labSheetSiteMonitoredCountsList = labSheetService.GetLabSheetIDListAndCountSamplesWithSamplingPlanIDDB(SamplingPlanID);
                ViewBag.LabSheetSiteMonitoredCountsList = labSheetSiteMonitoredCountsList;
            }

            return(PartialView());
        }
Exemplo n.º 2
0
        public PartialViewResult _LabSheetsTranferred(int SamplingPlanID)
        {
            ViewBag.SamplingPlanController      = _SamplingPlanController;
            ViewBag.AdminContactModelList       = null;
            ViewBag.IsSamplingPlanner           = false;
            ViewBag.LabSheetModelAndA1SheetList = null;
            ViewBag.LastAnalyzeMethod           = AnalyzeMethodEnum.Error;
            ViewBag.LastSampleMatrix            = SampleMatrixEnum.Error;
            ViewBag.LastLaboratory                  = LaboratoryEnum.Error;
            ViewBag.MWQMSampleModelList             = new List <MWQMSampleModel>();
            ViewBag.SubsectorMWQMSiteModelList      = new List <SubsectorMWQMSiteModel>();
            ViewBag.SamplingPlanModel               = null;
            ViewBag.LabSheetSiteMonitoredCountsList = null;

            List <LabSheetModelAndA1Sheet> labSheetModelAndA1SheetList = new List <LabSheetModelAndA1Sheet>();

            SamplingPlanService SamplingPlanService = new SamplingPlanService(_TVItemService.LanguageRequest, _TVItemService.User);
            LabSheetService     labSheetService     = new LabSheetService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMRunService      mwqmRunService      = new MWQMRunService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMSampleService   mwqmSampleService   = new MWQMSampleService(_TVItemService.LanguageRequest, _TVItemService.User);
            MWQMSiteService     mwqmSiteService     = new MWQMSiteService(_TVItemService.LanguageRequest, _TVItemService.User);

            ContactModel contactModel = _ContactService.GetContactLoggedInDB();

            SamplingPlanModel SamplingPlanModel = SamplingPlanService.GetSamplingPlanModelWithSamplingPlanIDDB(SamplingPlanID);

            if (string.IsNullOrWhiteSpace(SamplingPlanModel.Error))
            {
                ViewBag.SamplingPlanModel = SamplingPlanModel;

                ViewBag.IsSamplingPlanner = false;
                if (contactModel.SamplingPlanner_ProvincesTVItemID.Contains(SamplingPlanModel.ProvinceTVItemID.ToString()))
                {
                    ViewBag.IsSamplingPlanner = true;
                }
                else
                {
                    List <ContactModel> adminContactModelList = _ContactService.GetAdminContactModelListDB();
                    ViewBag.AdminContactModelList = adminContactModelList;
                }

                List <LabSheetModel> labSheetModelList = labSheetService.GetLabSheetModelListWithSamplingPlanIDAndLabSheetStatusDB(SamplingPlanID, LabSheetStatusEnum.Transferred);
                foreach (LabSheetModel labSheetModel in labSheetModelList)
                {
                    LabSheetModelAndA1Sheet labSheetModelAndA1Sheet = new LabSheetModelAndA1Sheet();
                    labSheetModelAndA1Sheet.LabSheetModel   = labSheetModel;
                    labSheetModelAndA1Sheet.LabSheetA1Sheet = labSheetService.ParseLabSheetA1WithLabSheetID(labSheetModel.LabSheetID);
                    labSheetModelAndA1SheetList.Add(labSheetModelAndA1Sheet);
                }
                ViewBag.LabSheetModelAndA1SheetList = labSheetModelAndA1SheetList;

                if (labSheetModelAndA1SheetList.Count > 0)
                {
                    MWQMRunModel mwqmRunModelLast = mwqmRunService.GetMWQMRunModelLastWithSubsectorTVItemIDDB(labSheetModelAndA1SheetList[0].LabSheetModel.SubsectorTVItemID);
                    if (string.IsNullOrWhiteSpace(mwqmRunModelLast.Error))
                    {
                        if (mwqmRunModelLast.AnalyzeMethod != null)
                        {
                            ViewBag.LastAnalyzeMethod = (AnalyzeMethodEnum)mwqmRunModelLast.AnalyzeMethod;
                        }
                        if (mwqmRunModelLast.SampleMatrix != null)
                        {
                            ViewBag.LastSampleMatrix = (SampleMatrixEnum)mwqmRunModelLast.SampleMatrix;
                        }
                        if (mwqmRunModelLast.Laboratory != null)
                        {
                            ViewBag.LastLaboratory = (LaboratoryEnum)mwqmRunModelLast.Laboratory;
                        }
                    }
                }

                List <MWQMSampleModel> mwqmSampleModelList = new List <MWQMSampleModel>();
                foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList)
                {
                    int Year  = 0;
                    int Month = 0;
                    int Day   = 0;
                    if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunYear, out Year))
                    {
                        if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunMonth, out Month))
                        {
                            if (int.TryParse(labSheetModelAndA1Sheet.LabSheetA1Sheet.RunDay, out Day))
                            {
                                MWQMRunModel mwqmRunModelNew = new MWQMRunModel()
                                {
                                    SubsectorTVItemID = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID,
                                    DateTime_Local    = new DateTime(Year, Month, Day),
                                    RunSampleType     = labSheetModelAndA1Sheet.LabSheetA1Sheet.SampleType,
                                    RunNumber         = labSheetModelList[0].RunNumber,
                                };

                                MWQMRunModel mwqmRunModel = mwqmRunService.GetMWQMRunModelExistDB(mwqmRunModelNew);
                                if (string.IsNullOrWhiteSpace(mwqmRunModel.Error))
                                {
                                    List <MWQMSampleModel> mwqmSampleModelList2 = mwqmSampleService.GetMWQMSampleModelListWithMWQMRunTVItemIDDB(mwqmRunModel.MWQMRunTVItemID);
                                    foreach (MWQMSampleModel mwqmSampleModel in mwqmSampleModelList2)
                                    {
                                        mwqmSampleModelList.Add(mwqmSampleModel);
                                    }
                                }
                            }
                        }
                    }
                }
                ViewBag.MWQMSampleModelList = mwqmSampleModelList;


                if (labSheetModelAndA1SheetList.Count > 0)
                {
                    List <SubsectorMWQMSiteModel> subsectorMWQMSiteModelList = new List <SubsectorMWQMSiteModel>();

                    foreach (LabSheetModelAndA1Sheet labSheetModelAndA1Sheet in labSheetModelAndA1SheetList)
                    {
                        List <MWQMSiteModel> mwqmSiteModelList = mwqmSiteService.GetMWQMSiteModelListWithSubsectorTVItemIDDB(labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorTVItemID);
                        subsectorMWQMSiteModelList.Add(new SubsectorMWQMSiteModel()
                        {
                            Subsector = labSheetModelAndA1Sheet.LabSheetA1Sheet.SubsectorName, MWQMSiteModelList = mwqmSiteModelList
                        });
                    }

                    ViewBag.SubsectorMWQMSiteModelList = subsectorMWQMSiteModelList;
                }

                List <LabSheetSiteMonitoredCounts> labSheetSiteMonitoredCountsList = labSheetService.GetLabSheetIDListAndCountSamplesWithSamplingPlanIDDB(SamplingPlanID);
                ViewBag.LabSheetSiteMonitoredCountsList = labSheetSiteMonitoredCountsList;
            }

            return(PartialView());
        }