public void SaveRepairHistory(RepairFaults repairFaults, MasterJobTable jobInfo, PalletInfo palletInfo, string empId)
        {
            REWORK_REPORTINGEntities entities = new REWORK_REPORTINGEntities();
            EmployeeDatabase dbEmp = new EmployeeDatabase();
            var emp = dbEmp.GetEmployeeInfo(int.Parse(empId));

            var history = new RepairHistory
            {
                ArriveDtm = DateTime.Now,
                CompletedDtm = DateTime.Now,
                PalletId = palletInfo.PalletNbr,
                EmployeeId = int.Parse(emp.EmployeeId),
                EmployeeName = emp.Name.Trim(),
                JobId = jobInfo.Job_ID,
                RepairFaultXrefRepairHistories = GetRepairFaultXrefRepairHistories(repairFaults),
                RepairTestRequirements = GetRepairTestRequirements(repairFaults)
            };

            entities.RepairHistories.Add(history);

            try
            {
                entities.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
                    }
                }
                throw dbEx;
            }
        }
Exemple #2
0
        //public void GetRepairInfo(int jobId)
        //{
        //    RepairReportingDataContext db = new RepairReportingDataContext();
        //    var repairHeader = db.RPT_GetRepairInfoHeader(jobId).ToList();
            
        //    foreach(var header in repairHeader)
        //    {
        //        dynamic Repair = new
        //        {
        //            HeaderInfo = header,
        //            RepairHistory = new
        //            {

        //            }
        //        };
        //    }


        //}

        public PalletHistoryInfo GetPalletInfoByJobId(long jobId)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var jobInfo = (from j in dbMes.MasterJobTables
                           where j.Job_ID == jobId
                           select j).FirstOrDefault();

            if (jobInfo == null)
                return null;

            var palletInfo = GetPalletInfo(jobInfo);
            return palletInfo;
        }
Exemple #3
0
        private PalletHistoryInfo GetPalletInfo(MasterJobTable jobInfo)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

            var convertSkuInfo = reworkFactory.GetSkuInfo(item).OrderBy(x => x.PartIndex).ToList();
            var lineInfos = reworkFactory.GetLineInfo(jobInfo);

            //RepairTorqueDetails = Count = 0

            reworkEntities.Configuration.ProxyCreationEnabled = false;
            reworkEntities.Configuration.LazyLoadingEnabled = false;
            var repairHistory = reworkEntities.RepairHistories
                .Include("RepairFaultXrefRepairHistories")
                .Include("RepairFaultXrefRepairHistories.RepairFault")
                .Include("RepairFaultXrefRepairHistories.RepairFault.FaultType")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairFaultDetails")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairDispositionDetails")
                .Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes")
                //.Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes.RepairBarcodeDetails")
                //.Include("RepairFaultXrefRepairHistories.RepairFault.RepairRecipes.RepairTorqueDetails")
                .Include("RepairTestRequirements")
                .Include("RepairTestRequirements.RepairTestRequirementDetails")
                .Where(r => r.JobId == jobInfo.Job_ID)
                .Select(i => new
                {
                    i.ArriveDtm,
                    i.CompletedDtm,
                    i.EmployeeId,
                    i.EmployeeName,
                    i.JobId,
                    i.PalletId,
                    RepairFaultXrefRepairHistories = i.RepairFaultXrefRepairHistories.Select(j => new
                    {
                        RepairFault = new
                        {
                            FaultType = j.RepairFault.FaultType,
                            RepairDispositionDetails = j.RepairFault.RepairDispositionDetails,
                            RepairFaultDetails = j.RepairFault.RepairFaultDetails,
                            RepairRecipes = j.RepairFault.RepairRecipes
                        }
                    }).ToList(),
                    RepairTestRequirements = i.RepairTestRequirements.Select(k => new
                    {
                        k.TestId,
                        k.TestName,
                        k.TestResult,
                        k.TestStatus,
                        k.Buildcode,
                        RepairTestRequirementDetails = k.RepairTestRequirementDetails
                    }).ToList(),
                }).ToList();

            dynamic extract = new List<dynamic>();
            foreach (var j in repairHistory)
            {
                dynamic onejob = new
                {
                    PalletId = j.PalletId,
                    JobId = j.JobId,
                    CompletedDtm = j.CompletedDtm,
                    EmployeeName = j.EmployeeName,
                    RepairTestRequirements = (from t in j.RepairTestRequirements
                                             select new {
                                                 TestId = t.TestId,
                                                 TestName = t.TestName,
                                                 TestResult = t.TestResult,
                                                 TestStatus = t.TestStatus,
                                                 Buildcode = t.Buildcode,
                                                 RepairTestRequirementDetails = (from d in t.RepairTestRequirementDetails
                                                                                select new
                                                                                {
                                                                                    BitNo = d.BitNo,
                                                                                    Description = d.Description,
                                                                                    Result = d.Result
                                                                                }).ToList(),
                                             }).ToList(),
                    RepairFaultXrefRepairHistories = from s in j.RepairFaultXrefRepairHistories
                                                     select new
                                                     {
                                                         RepairFault = new {
                                                             FaultType = new {
                                                                 Id = s.RepairFault.FaultType.Id,
                                                                 Description = s.RepairFault.FaultType.Description,
                                                             },
                                                             RepairRecipes = from r in s.RepairFault.RepairRecipes
                                                                             select new {
                                                                                 Description = r.Description,
                                                                                 RepairBarcodeDetails = (from b in r.RepairBarcodeDetails
                                                                                                        select new
                                                                                                        {
                                                                                                            Description = b.Description,
                                                                                                            OriginalBarcode = b.OriginalBarcode,
                                                                                                            ReplaceBarcode = b.ReplaceBarcode
                                                                                                        }).ToList(),
                                                                                 RepairTorqueDetails = (from t in r.RepairTorqueDetails
                                                                                                        select new
                                                                                                        {
                                                                                                            Angle = t.Angle,
                                                                                                            AngleStatus = t.AngleStatus,
                                                                                                            CompletedDTM = t.CompletedDTM,
                                                                                                            ControllerName = t.ControllerName,
                                                                                                            Pset = t.Pset,
                                                                                                            TighteningID = t.TighteningID,
                                                                                                            TighteningStatus = t.TighteningStatus,
                                                                                                            Torque = t.Torque,
                                                                                                            TorqueStatus = t.TorqueStatus
                                                                                                        }).ToList(),
                                                                             },
                                                             RepairFaultDetails = (from d in s.RepairFault.RepairFaultDetails
                                                                                  select new
                                                                                  {
                                                                                      Station = d.Station,
                                                                                      Description = d.Description
                                                                                  }).ToList(),
                                                             RepairDispositionDetails = (from disp in s.RepairFault.RepairDispositionDetails
                                                                                        select new
                                                                                        {
                                                                                            Type = disp.Type,
                                                                                            Side = disp.Side,
                                                                                            SeatPortion = disp.SeatPortion,
                                                                                            Commodity = disp.Commodity,
                                                                                            Defect = disp.Defect,
                                                                                            DefectDetail = disp.DefectDetail,
                                                                                            Responsibility = disp.Responsibility
                                                                                        }).ToList()
                                                         }
                                                     }
                };
                extract.Add(onejob);
            }

            PalletHistoryInfo palletInfo = new PalletHistoryInfo
            {
                OrderNumber = jobInfo.Order_Nbr,
                FinishDTM = (DateTime)jobInfo.FinishBld_DTTM,
                JobId = jobInfo.Job_ID,
                Sku = jobInfo.SKU,
                PalletId = (int)jobInfo.Ship_Pallet,
                SkuInfo = convertSkuInfo,
                LineInfo = lineInfos,
                RepairHistory = extract
            };

            return palletInfo;
        }
Exemple #4
0
        public PalletHistoryInfo GetPalletInfoByPalletId(int palletId)
        {
            ReworkFactory reworkFactory = new ReworkFactory();
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();

            var palletHdr = (from p in dbMes.PalletInfos
                             where p.PalletNbr == palletId && (p.Pallet_Type == "S1" || p.Pallet_Type == "S2")
                             select p).FirstOrDefault();

            if (palletHdr == null)
                return null;

            var jobInfo = (from j in dbMes.MasterJobTables
                           where j.Job_ID == palletHdr.Job_ID
                           select j).FirstOrDefault();

            if (jobInfo == null)
                return null;

            var palletInfo = GetPalletInfo(jobInfo);
            return palletInfo;
        }
        public RepairFaults GetRepairFaults(MasterJobTable jobInfo, Item item, List<SkuInfo> skuInfo, List<LineInfo> lineInfos, int palletId, int testerMode, string carline)
        {
            MesDataContext db = new MesDataContext();
            RepairFaults repairFaults = new RepairFaults();

            var palletValidationReqs = GetAllValidationRequirements(skuInfo);

            REWORK_REPORTINGEntities reworkEntities = new REWORK_REPORTINGEntities();
            var history = reworkEntities.RepairHistories.Where(j => j.JobId == jobInfo.Job_ID).FirstOrDefault();


            #region Missing Barcodes
            if (history == null)
            {
                if (palletValidationReqs.BarcodeRequirementInfos != null && history == null)
                {
                    foreach (var line in lineInfos)
                    {
                        var bcfaults = (from _bcrq in palletValidationReqs.BarcodeRequirementInfos.Where(s => s.LineId == line.LineId).ToList()
                                        join _bcactual in line.Serials
                                        on new { KEY1 = _bcrq.CSType } equals new { KEY1 = _bcactual.CSType } into _bcgroup
                                        where !_bcgroup.Any()
                                        select new BarcodeFault
                                        {
                                            LineId = line.LineId,
                                            CSType = _bcrq.CSType,
                                            Description = _bcrq.Description,
                                            Repaired = false
                                        }).ToList();

                        repairFaults.BarcodeFaults.AddRange(bcfaults);
                    }
                }
            }
            #endregion

            #region Missing Torques
            if (history == null && !carline.Equals("RU"))
            {
                var trqfaults = (from t in db.IWS_SP_GetMissingTorquesByJobId(jobInfo.Job_ID)
                                 select new TorqueFault
                                 {
                                     LineId = (int)t.LineId,
                                     Repaired = false,
                                     StationId = t.StationId,
                                     PsetNum = (int)t.PsetNum,
                                     TorquesRequired = (int)t.TorqueRequired,
                                     TorquesMissing = (int)t.TorqueCount,
                                     Description = (t.Description == null) ? "UNKNOWN" : t.Description.Trim(),
                                     RepairControllerName = (t.RepairControllerName == null) ? "UNKNOWN" : t.RepairControllerName.Trim(),
                                     RepairPsetNum = (t.RepairPsetNum == null) ? 0 : (int)t.RepairPsetNum,
                                     RepairDetails = new List<RepairDetail>(),
                                     Disposition = new List<IntegramREST.Models.Disposition.Disposition>()
                                 }).ToList();

                repairFaults.TorqueFaults.AddRange(trqfaults);
            }
            #endregion

            #region Failed Tests
            //foreach (var line in lineInfos)
            //{
            //    var testfaults = (from t in line.Tests.Where(c => c.TestStatus != "1").ToList()
            //                      select new TestFault
            //                      {
            //                          LineId = line.LineId,
            //                          TestName = t.TestFunction,
            //                          TestValue = t.TestValue,
            //                          TestDTM = (DateTime)t.StartDTM,
            //                          StationId = t.StationId,
            //                          Repaired = false
            //                      }).ToList();

            //    repairFaults.TestFaults.AddRange(testfaults);
            //}
            #endregion

            #region Test Requirements
            List<TestRepairRequirement> repairTestReqs = null;
            if (jobInfo.Group == "FRONT")
                repairTestReqs = GetFrontRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);
            else
                repairTestReqs = GetRearRepairTestRequirements(item, jobInfo.Job_ID, palletId, testerMode);

            repairFaults.TestRepairs = repairTestReqs;
            #endregion

            #region Defects
            var defectFaults = (from d in db.IWS_SP_GetUnresolvedDefectsByJobId(jobInfo.Job_ID).OrderBy(x => x.Log_DTTM)
                        group d by new {
                            d.DefectId,
                            d.DefectDescription,
                            d.StationId,
                            d.DT_Description
                        }  into g
                        select new DefectFault
                        {
                            Defect = new Defect
                            {
                                DefectID = 0,
                                Description = g.Key.DefectDescription.Trim(),
                                Obsolete = 0
                            },
                            Repaired = false,
                            StationNum = g.Key.DT_Description.Trim(),
                            RepairDetails = new List<RepairDetail>()
                        }).ToList();
            repairFaults.DefectFaults = defectFaults;
            #endregion

            #region ASRS Return
            //if (jobInfo.Curr_Inv_Loc.Trim() == "ASRS")
            //{
            //    defectFaults.Add(new DefectFault
            //    {
            //        Defect = new Defect
            //        {
            //            DefectID = 0,
            //            Description = "ASRS Return. Require Retest.",
            //            Obsolete = 0
            //        },
            //        Repaired = false,
            //        StationNum = (jobInfo.Group == "FRONT") ? "OP1450X" : "OP5200X",
            //        RepairDetails = new List<RepairDetail>()
            //    });
            //}
            #endregion
            
            return repairFaults;
        }