public CorrosionStudyResponseDTO GetByLoopNo(string LoopNo)
        {
            CorrosionStudyResponseDTO result = new CorrosionStudyResponseDTO();

            try
            {
                result = _CorrosionStudyService.GetByLoopNo(LoopNo);
                _logger.LogDebug("Result returned");
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "");
            }

            return(result);
        }
        public CorrosionStudyResponseDTO GetPipeClustersByLoopNo([FromBody] CorrosionStudyFilterDTO corrosionStudyFilterDTO)
        {
            CorrosionStudyResponseDTO result = new CorrosionStudyResponseDTO();

            try
            {
                result = _CorrosionStudyService.GetPipeClustersByLoopNo(corrosionStudyFilterDTO);
                _logger.LogDebug("Result returned");
            }
            catch (Exception exception)
            {
                _logger.LogError(exception, "");
            }

            return(result);
        }
Ejemplo n.º 3
0
        public CorrosionStudyResponseDTO GetPipeClustersByLoopNo(CorrosionStudyFilterDTO corrosionStudyFilterDTO)
        {
            CorrosionStudyResponseDTO response = new CorrosionStudyResponseDTO();



            List <CorrosionStudyDTO> list = new List <CorrosionStudyDTO>();

            IQueryable <CorrosionStudyDTO> query = (from p in _unitOfWork.PipeMaster.GenerateEntityAsIQueryable()
                                                    join l in _context.Plant on p.PlantCode equals l.Code
                                                    select new CorrosionStudyDTO
            {
                ID = p.ID,
                ParentPlantCode = l.ParentPlant.Code,
                PlantCode = p.PlantCode,
                LoopNo = p.CorrosionLoopNo,
                FluidCode = p.FluidCode,
                FluidName = p.FluidName,
                SubFluidCode = p.SubFluid,
                ProcessDescription = "",
                MinPressure = p.DesignPressure,
                MaxPressure = p.DesignPressure,
                MinTemperature = p.DesignTemperature,
                MaxTemperature = p.DesignTemperature,
                ClusterNo = p.PipeClusterNo,
                MaterialCode = p.MaterialCode
            });

            if (corrosionStudyFilterDTO != null)
            {
                if (!string.IsNullOrWhiteSpace(corrosionStudyFilterDTO.LoopNo))
                {
                    query = (from re in query
                             where re.LoopNo == corrosionStudyFilterDTO.LoopNo
                             select re);
                }


                if (!string.IsNullOrWhiteSpace(corrosionStudyFilterDTO.PlantCode))
                {
                    query = (from re in query
                             where re.PlantCode == corrosionStudyFilterDTO.PlantCode
                             select re);
                }

                if (!string.IsNullOrWhiteSpace(corrosionStudyFilterDTO.FluidCode))
                {
                    query = (from re in query
                             where re.FluidCode == corrosionStudyFilterDTO.FluidCode
                             select re);
                }

                if (!string.IsNullOrWhiteSpace(corrosionStudyFilterDTO.ParentPlantCode))
                {
                    query = (from re in query
                             where re.ParentPlantCode == corrosionStudyFilterDTO.ParentPlantCode
                             select re);
                }

                list = query.OrderBy(p => p.LoopNo).ToList();
            }

            response.CorrosionStudyDTO = new CorrosionStudyDTO();

            response.COFMasterDTOList = new List <COFMasterDTO>();

            response.IOWDTOList = new List <IOWDTO>();

            response.PipeClusterPOFDTOList = new List <PipeClusterPOFDTO>();

            CorrosionStudyDTO corrosionStudy = new CorrosionStudyDTO();

            if (list != null && list.Count > 0)
            {
                corrosionStudy.ID              = 0;
                corrosionStudy.LoopNo          = list.Min(p => p.LoopNo);
                corrosionStudy.MinPressure     = list.Min(p => p.MinPressure);
                corrosionStudy.MaxPressure     = list.Max(p => p.MinPressure);
                corrosionStudy.MinTemperature  = list.Min(p => p.MinTemperature);
                corrosionStudy.MaxTemperature  = list.Max(p => p.MinTemperature);
                corrosionStudy.FluidCode       = list.Max(p => p.FluidCode);
                corrosionStudy.FluidName       = list.Max(p => p.FluidName);
                corrosionStudy.PlantCode       = list.Max(p => p.PlantCode);
                corrosionStudy.ParentPlantCode = list.Max(p => p.ParentPlantCode);
                corrosionStudy.ClusterNos      = list.Select(p => p.ClusterNo).Distinct().ToList <string>();

                response.CorrosionStudyDTO = corrosionStudy;

                foreach (string cluster in corrosionStudy.ClusterNos)
                {
                    PipeClusterPOFDTO pipeCluster = new PipeClusterPOFDTO();
                    pipeCluster.ID               = 0;
                    pipeCluster.Fluid            = response.CorrosionStudyDTO.FluidCode;
                    pipeCluster.ClusterNo        = cluster;
                    pipeCluster.MaterialCode     = list.Where(c => c.ClusterNo == cluster).Select(c => c.MaterialCode).FirstOrDefault();
                    pipeCluster.MinPressure      = list.Where(c => c.ClusterNo == cluster).Min(c => c.MinPressure);
                    pipeCluster.MaxPressure      = list.Where(c => c.ClusterNo == cluster).Max(c => c.MinPressure);
                    pipeCluster.MinTemperature   = list.Where(c => c.ClusterNo == cluster).Min(c => c.MinTemperature);
                    pipeCluster.MaxTemperature   = list.Where(c => c.ClusterNo == cluster).Max(c => c.MinTemperature);
                    pipeCluster.CorrosionStudyID = 0;
                    pipeCluster.DMGuideList      = new List <DMGuideDTO>();

                    response.PipeClusterPOFDTOList.Add(pipeCluster);
                }
            }


            return(response);
        }
Ejemplo n.º 4
0
        public CorrosionStudyResponseDTO GetByLoopNo(string LoopNo)
        {
            CorrosionStudyResponseDTO response = new CorrosionStudyResponseDTO();

            try
            {
                CorrosionStudy corrosionStudy = (from s in _unitOfWork.CorrosionStudy.GenerateEntityAsIQueryable()
                                                 where s.LoopNo == LoopNo
                                                 select s).FirstOrDefault();

                if (corrosionStudy != null)
                {
                    // Corrosion Study
                    response.CorrosionStudyDTO = _mapper.Map <CorrosionStudyDTO>(corrosionStudy);

                    // Pipe Cluster POF
                    List <PipeClusterPOF> pipeClusterPOFList = (from s in _unitOfWork.PipeClusterPOF.GenerateEntityAsIQueryable()
                                                                where s.CorrosionStudyID == corrosionStudy.ID
                                                                select s).ToList();

                    if (pipeClusterPOFList != null && pipeClusterPOFList.Count > 0)
                    {
                        response.PipeClusterPOFDTOList = new List <PipeClusterPOFDTO>();
                        List <string> clusters = pipeClusterPOFList.Select(c => c.ClusterNo).Distinct().ToList();
                        foreach (string cluster in clusters)
                        {
                            PipeClusterPOFDTO pipeClusterPOFDTO = new PipeClusterPOFDTO();

                            List <PipeClusterPOF> tempPipeClusterPOFList = pipeClusterPOFList.Where(c => c.ClusterNo == cluster).ToList();
                            if (tempPipeClusterPOFList != null && tempPipeClusterPOFList.Count > 0)
                            {
                                pipeClusterPOFDTO.ID               = tempPipeClusterPOFList[0].ID;
                                pipeClusterPOFDTO.Fluid            = tempPipeClusterPOFList[0].Fluid;
                                pipeClusterPOFDTO.ClusterNo        = cluster;
                                pipeClusterPOFDTO.CorrosionStudyID = tempPipeClusterPOFList[0].CorrosionStudyID;
                                pipeClusterPOFDTO.MaterialCode     = tempPipeClusterPOFList[0].MaterialCode;
                                pipeClusterPOFDTO.MinPressure      = tempPipeClusterPOFList[0].MinPressure;
                                pipeClusterPOFDTO.MaxPressure      = tempPipeClusterPOFList[0].MaxPressure;
                                pipeClusterPOFDTO.MinTemperature   = tempPipeClusterPOFList[0].MinTemperature;
                                pipeClusterPOFDTO.MaxTemperature   = tempPipeClusterPOFList[0].MaxTemperature;
                                List <DMGuideDTO> dmGuideList = new List <DMGuideDTO>();
                                foreach (PipeClusterPOF pof in tempPipeClusterPOFList)
                                {
                                    DMGuideDTO dmGuide = new DMGuideDTO();
                                    dmGuide.DMGuideID       = pof.ID;
                                    dmGuide.DMCode          = pof.DMCode;
                                    dmGuide.DMDescription   = pof.DMDescription;
                                    dmGuide.DMRate          = pof.DMRate;
                                    dmGuide.DMSeverity      = pof.DMSeverity;
                                    dmGuide.DMType          = pof.DMType;
                                    dmGuide.DMSuceptability = pof.DMSuceptability;
                                    dmGuideList.Add(dmGuide);
                                }
                                pipeClusterPOFDTO.DMGuideList = dmGuideList;
                                response.PipeClusterPOFDTOList.Add(pipeClusterPOFDTO);
                            }
                        }
                    }
                    else
                    {
                        response.PipeClusterPOFDTOList = new List <PipeClusterPOFDTO>();
                    }

                    // IOW
                    List <IOW> iowList = (from s in _unitOfWork.IOW.GenerateEntityAsIQueryable()
                                          where s.CorrosionStudyID == corrosionStudy.ID
                                          select s).ToList();

                    if (iowList != null && iowList.Count > 0)
                    {
                        response.IOWDTOList = new List <IOWDTO>();
                        foreach (IOW iow in iowList)
                        {
                            IOWDTO iowDTO = _mapper.Map <IOWDTO>(iow);
                            response.IOWDTOList.Add(iowDTO);
                        }
                    }
                    else
                    {
                        response.IOWDTOList = new List <IOWDTO>();
                    }

                    // COFMaster
                    List <COFMaster> COFMasterList = (from s in _unitOfWork.COFMaster.GenerateEntityAsIQueryable()
                                                      where s.CorrosionStudyID == corrosionStudy.ID
                                                      select s).ToList();

                    if (COFMasterList != null && COFMasterList.Count > 0)
                    {
                        response.COFMasterDTOList = new List <COFMasterDTO>();
                        foreach (COFMaster COFMaster in COFMasterList)
                        {
                            COFMasterDTO COFMasterDTO = _mapper.Map <COFMasterDTO>(COFMaster);
                            response.COFMasterDTOList.Add(COFMasterDTO);
                        }
                    }
                    else
                    {
                        response.COFMasterDTOList = new List <COFMasterDTO>();
                    }

                    response.LoopNo        = corrosionStudy.LoopNo;
                    response.Status        = true;
                    response.StatusMessage = "";
                    response.StatusCode    = 200;
                    return(response);
                }
                else
                {
                    return(new CorrosionStudyResponseDTO
                    {
                        LoopNo = LoopNo,
                        Status = false,
                        StatusMessage = "Report donot exist - " + LoopNo,
                        StatusCode = 200
                    });
                }
            }
            catch (Exception ex)
            {
                return(new CorrosionStudyResponseDTO()
                {
                    LoopNo = LoopNo,
                    Status = false,
                    StatusMessage = ex.Message,
                    StatusCode = 200
                });
            }
        }