コード例 #1
0
        public ServiceResponse <GetNonConfDto> EvaluateNonConf(UpdateNonConfDto updateNonConfDto)
        {
            if (NonConfIdValidator(updateNonConfDto.Id) == false)
            {
                return(serviceResponse);
            }

            NonConf nonConf = _context.nonConfs.FirstOrDefault(n => n.Id == updateNonConfDto.Id);

            if (StatusValidator(nonConf.Status) == false)
            {
                return(serviceResponse);
            }

            try
            {
                nonConf.Status = updateNonConfDto.Status;
                _context.nonConfs.Update(nonConf);
                _context.SaveChanges();
                serviceResponse.Message = "Esta NC foi encerrada.";

                CreateNcNewVersion(nonConf);

                serviceResponse.Data = _mapper.Map <GetNonConfDto>(nonConf);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = ex.Message;
            }

            return(serviceResponse);
        }
コード例 #2
0
        public ServiceResponse <GetNonConfDto> AddNonConfCorrActions(NonConfCorrActionsDto nonConfCorrActions)
        {
            NonConf    nonConf    = _context.nonConfs.Find(nonConfCorrActions.NonconfId);
            CorrAction corrAction = _context.corrActions.Find(nonConfCorrActions.CorractionId);

            if (NonConfCorrActionsValidator(nonConf, corrAction) == false)
            {
                return(serviceResponse);
            }

            try
            {
                NonConfCorrActions newNonConfCorrActions = new NonConfCorrActions
                {
                    NonConf    = nonConf,
                    CorrAction = corrAction
                };

                _context.nonConfCorrActions.Add(newNonConfCorrActions);
                _context.SaveChanges();

                serviceResponse.Data = _mapper.Map <GetNonConfDto>(nonConf);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Não foi possível processar a requisição. Exception: " + ex.Message;
            }

            return(serviceResponse);
        }
コード例 #3
0
        public ServiceResponse <GetNonConfDto> AddNonConf(NonConf nonConf)
        {
            try
            {
                _context.nonConfs.Add(nonConf);
                _context.SaveChanges();

                nonConf = _context.nonConfs.OrderByDescending(n => n.Id).First();

                CodeGenerator(nonConf);
                _context.SaveChanges();

                serviceResponse.Message = "NC criada com sucesso.";


                CreateNcNewVersion(nonConf);


                if (StatusValidator(nonConf.Status) == false)
                {
                    return(serviceResponse);
                }

                serviceResponse.Data = _mapper.Map <GetNonConfDto>(nonConf);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Não foi possível criar a nova NC. Exception: " + ex;
            }

            return(serviceResponse);
        }
コード例 #4
0
        private NonConf InsertCorrActions(int id)
        {
            NonConf nonConf = _context.nonConfs
                              .Include(n => n.NonConfCorrActions)
                              .ThenInclude(nc => nc.CorrAction)
                              .FirstOrDefault(n => n.Id == id);

            return(nonConf);
        }
コード例 #5
0
        public IActionResult Post(NonConf nonConf)
        {
            ServiceResponse <GetNonConfDto> serviceResponse = _nonConfService.AddNonConf(nonConf);

            if (serviceResponse.Data == null)
            {
                return(BadRequest(serviceResponse.Message));
            }
            return(Ok(serviceResponse));
        }
コード例 #6
0
        public static void Initialize(DataContext context, IMapper mapper)
        {
            NonConfService            nonConfService            = new NonConfService(context, mapper);
            CorrActionService         corrActionService         = new CorrActionService(context, mapper);
            NonConfCorrActionsService nonConfCorrActionsService = new NonConfCorrActionsService(context, mapper);

            context.Database.EnsureCreated();

            if (context.nonConfs.Any())
            {
                return;
            }

            //Insere as NonConfs
            var newNonConfs = new NonConf[]
            {
                new NonConf(),
                new NonConf {
                    Status = 2
                },
                new NonConf()
            };

            foreach (NonConf n in newNonConfs)
            {
                nonConfService.AddNonConf(n);
            }

            //Insere as CorrActions
            var newCorrActions = new CorrActionDto[]
            {
                new CorrActionDto {
                    Description = "Do Anything 01."
                },
                new CorrActionDto {
                    Description = "Do Anything 02."
                }
            };

            foreach (CorrActionDto c in newCorrActions)
            {
                corrActionService.AddCorrAction(c);
            }


            //Relaciona uma CorrAction com uma NonConf
            nonConfCorrActionsService.AddNonConfCorrActions(new NonConfCorrActionsDto()
            {
                NonconfId    = 1,
                CorractionId = 1
            });
        }
コード例 #7
0
        private ServiceResponse <GetNonConfDto> CreateNcNewVersion(NonConf nonConf)
        {
            if (nonConf.Status == 2)
            {
                NonConf newNonConf = new NonConf()
                {
                    Description = nonConf.Description,
                    Version     = nonConf.Version + 1
                };

                AddNonConf(newNonConf);

                serviceResponse.Message = "Esta NC foi encerrada. Uma nova versão desta NC foi criada com o Código: " + newNonConf.Code;

                return(serviceResponse);
            }

            return(serviceResponse);
        }
コード例 #8
0
ファイル: job.cs プロジェクト: nadeemhussain84/EpicorScraps
        public NonConfListDataSet GetNonConfListDS()
        {
            NonConf            JobNonConf;
            NonConfListDataSet JobNonConfList;
            bool pgs;

            JobNonConf     = new NonConf(this.Session.ConnectionPool);
            JobNonConfList = new NonConfListDataSet();

            try
            {
                JobNonConfList = JobNonConf.GetList("JobNum = \'" + this.Jobnumber + "\'", 0, 0, out pgs);
                return(JobNonConfList);
            }
            catch
            {
                return(null);
            }
        }
コード例 #9
0
        public ServiceResponse <GetNonConfDto> GetNonConfById(int id)
        {
            if (NonConfIdValidator(id) == false)
            {
                return(serviceResponse);
            }

            try
            {
                NonConf nonConf = InsertCorrActions(id);

                serviceResponse.Data = _mapper.Map <GetNonConfDto>(nonConf);
            }
            catch (Exception ex)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Impossível processar a requisição. Exception: " + ex;
            }

            return(serviceResponse);
        }
コード例 #10
0
        private bool NonConfCorrActionsValidator(NonConf nonConf, CorrAction corrAction)
        {
            if (nonConf == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "A NC não existe.";
                return(false);
            }
            else if (corrAction == null)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "A Ação não existe.";
                return(false);
            }
            else if (nonConf.Status != 0)
            {
                serviceResponse.Success = false;
                serviceResponse.Message = "Esta NC está encerrada e não pode ser alterada.";
                return(false);
            }

            return(true);
        }
コード例 #11
0
 private void CodeGenerator(NonConf nonConf)
 {
     nonConf.Code = nonConf.Date.Year.ToString()
                    + ":0" + nonConf.Id.ToString()
                    + ":0" + nonConf.Version.ToString();
 }
コード例 #12
0
        public void Begin(NonConf objNonConformance)
        {
            EndpointBindingType bindingType = EndpointBindingType.BasicHttp;
            string epicorUserID             = userName;
            string epiorUserPassword        = password;
            Guid   sessionId = Guid.Empty;

            svcSessionMod.SessionModSvcContractClient sessionModClient = null;

            //AMIN Start
            string comp = "", plant = "";

            comp  = string.IsNullOrEmpty(objNonConformance.Company) ? Conn.Company : objNonConformance.Company;
            plant = string.IsNullOrEmpty(objNonConformance.Plant) ? Conn.Plant : objNonConformance.Plant;
            //AMIN End

            string scheme = "https";

            if (bindingType == EndpointBindingType.SOAPHttp)
            {
                scheme = "http";
            }
            UriBuilder builder = new UriBuilder(scheme, Conn.hostName);

            builder.Path = $"{Conn.environment}/Ice/Lib/SessionMod.svc";

            try
            {
                sessionModClient = GetClient <svcSessionMod.SessionModSvcContractClient, svcSessionMod.SessionModSvcContract>
                                   (
                    builder.Uri.ToString(),
                    epicorUserID,
                    epiorUserPassword,
                    bindingType
                                   );

                string siteID = "", siteName = "", workstationID = "", workstationDesc = "";
                string employeeID = "", countryGroupCode = "", countryCode = "", tenantID = "";

                sessionId = sessionModClient.Login();

                builder.Path     = $"{Conn.environment}/Ice/Lib/SessionMod.svc";
                sessionModClient = GetClient <svcSessionMod.SessionModSvcContractClient, svcSessionMod.SessionModSvcContract>(builder.Uri.ToString(), epicorUserID, epiorUserPassword, bindingType);

                sessionModClient.Endpoint.EndpointBehaviors.Add(new HookServiceBehavior(sessionId, epicorUserID));


                //** CHANGE configCompany & configPlant to read from input **//
                sessionModClient.SetCompany(comp, out siteID, out siteName, out workstationID,
                                            out workstationDesc, out employeeID, out countryGroupCode,
                                            out countryCode, out tenantID);
                sessionModClient.SetPlant(plant);


                if (sessionId != Guid.Empty)
                {
                    List <NonConf> nonConfs = new List <NonConf>();
                    nonConfs.Add(objNonConformance);

                    // ##### TEST DATA ##### //
                    //List<InvTransfer> invTransfers = new List<InvTransfer>();
                    //invTransfers.Add(objInvTransfer);
                    //invTransfers.Add(new InvTransfer
                    //{
                    //    company = configCompany,
                    //    plant = configPlant,
                    //    id = 1,
                    //    partNum = "1-BAG-GEN-000000-002",
                    //    qty = 1,
                    //    uom = "KG",
                    //    frmWarehouse = "L05",
                    //    frmBinNum = "RS_BTL",
                    //    frmLotNum = "Lot 04", // All from details i can get from PartBin - LotNum
                    //    toWarehouse = "L09", // Default boolean value in Warehse
                    //    toBinNum = "L09", // Default boolean value in WarehseBin
                    //    toLotNum = "Lot 01" // Same as fromLotNum
                    //});

                    NonConformance(epicorUserID, epiorUserPassword, builder, sessionId, nonConfs);
                }
                else
                {
                    //Sessionid is Empty!
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"Epicor Error : {ex.Message.ToString()}");
            }
            finally
            {
                if (sessionId != Guid.Empty)
                {
                    sessionModClient.Logout();
                }
            }
        }