示例#1
0
        public List<JobTrackingItem> GetJobTrackingInfo(int lineId)
        {
            AdminFactory factory = new AdminFactory();
            ItemDetailsModel model = new ItemDetailsModel();

            var lineBuffer = (from s in factory.GetJobTrackingInfo(lineId)
                              select new JobTrackingItem
                              {
                                  Item = s,
                                  ItemDetail = model.GetItemInfo(s.ItemNumber)
                              }).ToList();
            return lineBuffer;
        }
示例#2
0
        public PalletChange GetPalletChange(int palletId)
        {
            DispositionDataContext db = new DispositionDataContext();
            IntegramMESDataContext trackDb = new IntegramMESDataContext();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();
            ReworkFactory reworkFactory = new ReworkFactory();

            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 item = itemDetailModel.GetItemInfo(jobInfo.SKU);
            var convertSkuInfo = reworkFactory.GetSkuInfo(item).OrderBy(s=>s.PartIndex).ToList();

            var palletChangeHistory = trackDb.PalletChangeHistories.Where(p => p.JobId == jobInfo.Job_ID).ToList();

            PalletChange palletChange = new PalletChange
            {
                PalletId = palletId,
                Sku = jobInfo.SKU,
                JobId = jobInfo.Job_ID,
                OrderNumber = jobInfo.Order_Nbr,
                SkuInfo = convertSkuInfo,
                FinishDTM = (DateTime)jobInfo.FinishBld_DTTM,
                PalletChangeHistory = palletChangeHistory
            };

            return palletChange;
        }
示例#3
0
 public void GetSkuInfo()
 {
     ItemDetailsModel model = new ItemDetailsModel();
     var what = model.GetItemInfo("2226");
 }
        private string GetSeatSummaryDescription(string itemNumber, int lineId)
        {
            var items = ItemMasterCacheManager.ItemNumberDescriptions.Where(i => i.ItemNumber.Trim() == itemNumber).ToList();
            string description = "";
            ItemDetailsModel model = new ItemDetailsModel();
            var item = model.GetItemInfo(itemNumber);
            if (items.Count() > 0)
            {
                if (lineId == 1)
                {
                    var first = item.ItemInfos.Where(s => s.PartIndex == 1).FirstOrDefault();
                    var second = item.ItemInfos.Where(s => s.PartIndex == 2).FirstOrDefault();
                    if (first != null)
                    {
                        description = model.GetOptionValue(first, 100) + " " + model.GetOptionValue(first, 101) + " " 
                            + model.GetOptionValue(first, 3) + " " + model.GetOptionValue(first, 10);
                    }
                }
                else if (lineId == 2)
                {
                    var first = item.ItemInfos.Where(s => s.PartIndex == 1).FirstOrDefault();
                    var second = item.ItemInfos.Where(s => s.PartIndex == 2).FirstOrDefault();
                    if (first != null)
                    {
                        if (first.ItemType == "2B")
                            description = "BENCH";
                        else
                        {
                            description = model.GetOptionValue(first, 100) + " " + model.GetOptionValue(first, 101) + " "
                                + model.GetOptionValue(first, 10) + " " + model.GetOptionValue(first, 9) + " "
                                + model.GetOptionValue(first, 13) + " " + model.GetOptionValue(first, 11);
                        }

                    }
                }
                else if (lineId == 3)
                {
                    var third = item.ItemInfos.Where(s => s.PartIndex == 3).FirstOrDefault();
                    var fourth = item.ItemInfos.Where(s => s.PartIndex == 4).FirstOrDefault();
                    if (third != null)
                    {
                        description = model.GetOptionValue(third, 100) + " " + model.GetOptionValue(third, 101) + " "
                            + model.GetOptionValue(third, 3) + " " +  model.GetOptionValue(third, 7) + " " 
                            + model.GetOptionValue(third, 9) + " " + model.GetOptionValue(third, 10);
                    }
                }

                return System.Text.RegularExpressions.Regex.Replace(description, @"\s+", " ");

            }

            return "*Unknown Sku* (" + itemNumber + ")";
        }
        public string GetOptionValue(string itemNumber, int optionNum)
        {
            ItemDetailsModel itemDetailsModel = new ItemDetailsModel();
            var item = itemDetailsModel.GetItemInfo(itemNumber);
            string optionString = "";

            if (item == null)
                return optionString;

            if (item.ItemInfos.Count() > 0)
            {
                var firstpart = item.ItemInfos.FirstOrDefault();
                Option option = firstpart.Options.Where(i => i.OptionNumber == optionNum).FirstOrDefault();
                if (option != null)
                {
                    if (option.OptionValue != null)
                        return option.OptionValue.Trim();
                }
            }

            return optionString;
        }
示例#6
0
        public List<SkuInfo> GetSkuInfo(string sku)
        {
            ItemDetailsModel itemDetailModel = new ItemDetailsModel();
            ReworkFactory reworkFactory = new ReworkFactory();
            var item = itemDetailModel.GetItemInfo(sku);
            if (item == null)
                return null;

            var convertSkuInfo = reworkFactory.GetSkuInfo(item).OrderBy(s => s.PartIndex).ToList();
            return convertSkuInfo;
        }
示例#7
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;
        }
        public JobBuffer ScheduleAdminView(int id)
        {
            PartSequencingDataContext dbSeq = new PartSequencingDataContext();
            MesDataContext dbMes = new MesDataContext();
            ItemDetailsModel itemDetailsModel = new ItemDetailsModel();
            var station = UpdateNextBoxBySequencingId(id);

            var tokens = MessageTokensCacheManager.MessageTokens.Where(t => t.LineId == station.Line.Id || t.LineId == 4).ToList();

            var lineBuffer = GetSequencingBuffer(station);

            var boxBuffer = new JobBuffer
            {
                CurrentBoxNum = station.NextBox.BoxNum,
                CurrentScheduleNum = station.NextBox.ScheduleNum,
                SequencingStation = station,
                Buffer = new List<SequenceItem>()
            };

            var tracking = GetSequencingHistory(station);

            boxBuffer.Buffer = (lineBuffer.GroupJoin(tracking, jb => jb.OrderId, st => st.OrderId, (jb, g) => new { _jb = jb, g }).
            SelectMany(t => t.g.DefaultIfEmpty(), (t, st) => new SequenceItem
            {
                BoxNum = st == null ? 0 : st.BoxNum,
                OrderId = t._jb.OrderId,
                Complete = true,
                OrderNumber = t._jb.OrderNumber == null ? "" : t._jb.OrderNumber,
                ScheduleNum = st == null ? 0 : st.ScheduleNum,
                ItemNumber = t._jb.ItemNumber,
                JobId = (int)t._jb.JobId,
                Region = t._jb.Region.Trim(),
                Type = st == null ? 0 : (int)st.Type,
                Message = GetSequencingMessage(station, t._jb.ItemNumber, tokens),
                Item = itemDetailsModel.GetItemInfo(t._jb.ItemNumber)
            })).ToList();

            boxBuffer.Buffer = boxBuffer.Buffer.OrderBy(s => s.OrderId).ToList();

            var itemsinbox = station.PartsPerBox;
            var boxperschedule = station.BoxPerSchedule;
            var itemsintheschedule = itemsinbox * boxperschedule;
            if (station.NextBox != null)
            {

                var currentbox = station.NextBox.BoxNum;

                var jobs = boxBuffer.Buffer.Where(i => i.OrderId >= station.NextBox.OrderId).Take(itemsintheschedule).OrderBy(s => s.OrderId).ToList();

                foreach (var item in jobs)
                {
                    item.Complete = false;
                    item.BoxNum = currentbox;
                    item.ScheduleNum = station.NextBox.ScheduleNum;

                    if (item.Message.ToUpper().IndexOf("*SKIPPED*") < 0)
                    {
                        item.Skipped = false;
                        --itemsinbox;
                    }
                    else
                        item.Skipped = true;


                    if (itemsinbox > 0 && itemsintheschedule > 0) continue;
                    if (itemsintheschedule <= 1)
                    {
                        break;
                    }

                    itemsinbox = station.PartsPerBox;
                    --boxperschedule;
                    currentbox = currentbox >= station.BoxQty ? 1 : ++currentbox;

                }

            }

            var scheduleNum = -1;
            var boxNum = -1;
            var initialJobId = Int32.MinValue;

            for(var i=0;i<boxBuffer.Buffer.Count(); i++) {
                if (i == 0) {
                    initialJobId = boxBuffer.Buffer[i].JobId;
                }

                if (boxBuffer.Buffer[i].ScheduleNum != scheduleNum)
                {
                    
                    boxBuffer.Buffer[i].StartDrawSchedule = true;
                    boxBuffer.Buffer[i].InitialJobId = initialJobId;

                    var countSchedule = 0;
                    for(var j=i; j<boxBuffer.Buffer.Count();j++) {
                        if (boxBuffer.Buffer[j].ScheduleNum == boxBuffer.Buffer[i].ScheduleNum) {
                            countSchedule++;
                        } else {
                            break;
                        }
                    }

                    if (boxBuffer.Buffer[i].Complete)
                        boxBuffer.Buffer[i].ScheduleCount = countSchedule;
                    else
                    {
                        if (countSchedule > itemsintheschedule)
                            boxBuffer.Buffer[i].ScheduleCount = itemsintheschedule;
                        else
                            boxBuffer.Buffer[i].ScheduleCount = countSchedule;
                    }
                    initialJobId = boxBuffer.Buffer[i].JobId;
                    scheduleNum = boxBuffer.Buffer[i].ScheduleNum;
                }
                else
                {
                    boxBuffer.Buffer[i].StartDrawSchedule = false;

                }
            }

            scheduleNum = -1;
            for (var i = 0; i < boxBuffer.Buffer.Count(); i++)
            {
                if (boxBuffer.Buffer[i].BoxNum != boxNum || boxBuffer.Buffer[i].ScheduleNum != scheduleNum)
                {
                    boxBuffer.Buffer[i].StartDrawBox = true;

                    var countBox = 0;
                    for (var j = i; j < boxBuffer.Buffer.Count(); j++)
                    {
                        if (boxBuffer.Buffer[j].BoxNum == boxBuffer.Buffer[i].BoxNum && boxBuffer.Buffer[j].ScheduleNum == boxBuffer.Buffer[i].ScheduleNum)
                        {
                            countBox++;
                        }
                        else
                            break;
                    }
                    boxBuffer.Buffer[i].BoxCount = countBox;
                    boxNum = boxBuffer.Buffer[i].BoxNum;
                    scheduleNum = boxBuffer.Buffer[i].ScheduleNum;
                }
                else
                {
                    boxBuffer.Buffer[i].StartDrawBox = false;
                }
            }
            
            return boxBuffer;

        }
        public string GetSequencingMessage(SequencingStation station, string itemNumber, IEnumerable<MessageToken> lineTokens)
        {
            ItemDetailsModel itemDetailsModel = new ItemDetailsModel();
            var item = itemDetailsModel.GetItemInfo(itemNumber);

            if (item == null)
                return String.Format("*Unknown Part* ({0})", itemNumber);

            string[] tokens = station.MessageFormat.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            var formattedMsg = station.MessageFormat.Trim();

            if (tokens[0] == null) throw new NotImplementedException();

            var filteredParts = item.ItemInfos.Where(
                                part =>
                                ((part.Buildcode & station.SeatOptions) ==
                                 (part.Buildcode & station.SeatOptions2Check) &&
                                 (part.Buildcode & station.SeatOptions) == (station.SeatOptions & station.SeatOptions2Check) &&
                                 part.LineId == station.Line.Id)).OrderBy(part => part.PartIndex).ToList();

            List<MessageToken> validLineTokens = lineTokens.Where(t => tokens.Contains(t.Token.Trim())).ToList();
            var colourExtensions = MessageTokensCacheManager.ColourExtensions;
            var trimExtensions = MessageTokensCacheManager.TrimExtensions;


            if (filteredParts.Count() > 0)
            {
                ItemInfo part = null;
                if (station.Line.Id == 1 || station.Line.Id == 2)
                    part = filteredParts.Where(p => p.PartIndex == 1).FirstOrDefault();
                else if (station.Line.Id == 3)
                {
                    part = filteredParts.Where(p => p.PartIndex == 3).FirstOrDefault();
                }

                if (part != null)
                {
                    //3Pass ONLY
                    if (part.ItemComponent == "NO-2LH" || part.ItemComponent == "NO-2RH")
                    {
                        return String.Format("NO BUILD ({0})", itemNumber);
                    }

                    //iterate through and look or feneric options number replacement
                    foreach (var specialOption in tokens)
                    {
                        if (specialOption.Contains("OPTION"))
                        {
                            var optionNumberString = new String(specialOption.Where(Char.IsDigit).ToArray());
                            formattedMsg = formattedMsg.Replace(specialOption.Trim(), GetOptionValue(part, int.Parse(optionNumberString)));
                        }
                    }


                    foreach (var token in validLineTokens)
                    {
                        var _trimstyle = GetOptionValue(part, 100);
                        var _colour = GetOptionValue(part, 101);
                        bool ru = isRU(part.ItemType);

                        switch (token.SpecialValue.Trim())
                        {
                            case "3PMANSHIELD":
                                #region 3PMANSHIELD
                                if (_colour.Equals("R4") || _colour.Equals("X9") || GetOptionValue(part, 3) == "PWR")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "3PPWRSHIELD":
                                #region 3PPWRSHIELD
                                if (GetOptionValue(part, 3) == "PWR")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                break;
                                #endregion
                            case "3PMAN!RQ":
                                #region
                                if (GetOptionValue(part, 3) != "PWR")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "3PX9MAN!RQ":
                                #region
                                if (_colour.Equals("R4") || _colour.Equals("X9"))
                                {
                                    if (GetOptionValue(part, 3) != "PWR")
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "RMVQD!RQ":
                                #region
                                if (GetOptionValue(part, 11) == "LXQD")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "PWRCARPET":
                                #region
                                if (GetOptionValue(part, 3) == "PWR")
                                {
                                    if (_colour.Equals("D1"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(X9 Carpet)");
                                    else if (_colour.Equals("X9"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(X9 Carpet)");
                                    else if (_colour.Equals("L9"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(L5 Carpet)");
                                    else if (_colour.Equals("L5"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(L5 Carpet)");
                                    else if (_colour.Equals("TU"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(X9 Carpet)");
                                }
                                else
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "POWERBOLD":
                                #region POWERBOLD
                                if (GetOptionValue(part, 3) == "PWR")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "SIDESHIELDCLR":
                                #region SIDESHIELD
                                var _shldclr = _colour;
                                if (colourExtensions != null)
                                {
                                    var _ext =
                                        colourExtensions.Where(
                                            cExt =>
                                            cExt.ColourCode == _shldclr && cExt.ExtensionName == "Side Shield").ToList();

                                    if (_ext.Count() > 0)
                                        _shldclr = _ext[0].ColourCodeExt.Trim();
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _shldclr);
                                break;
                                #endregion
                            case "TRIMCLR":
                                #region TRIMCLR
                                var _trimclr = _colour;
                                if (colourExtensions != null)
                                {
                                    var _ext =
                                        colourExtensions.Where(
                                            cExt =>
                                            cExt.ColourCode == _trimclr && cExt.ExtensionName == "Trim").ToList();

                                    if (_ext.Count() > 0)
                                        _trimclr = _ext[0].ColourCodeExt.Trim();
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _trimclr);
                                break;
                                #endregion
                            case "FRTSHIELD":
                                #region FRTSHIELD
                                if (_colour.Equals("R4") || _colour.Equals("X9"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "FRTASHIELD":
                                #region
                                if (_colour.Equals("X9") || _colour.Equals("R4"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue);
                                else
                                {
                                    var _drvpart = filteredParts.Where(p => p.PartIndex == 1).FirstOrDefault();
                                    var _paspart = filteredParts.Where(p => p.PartIndex == 2).FirstOrDefault();

                                    string partstring1 = string.Empty;
                                    string partstring2 = string.Empty;

                                    if (GetOptionValue(_drvpart, 1) == "DRV")
                                    {
                                        if (GetOptionValue(_drvpart, 3) == "PWR")
                                            partstring1 = "580298-" + _colour + " PWR (DRV)";
                                        else
                                            partstring1 = "580278-" + _colour + " MAN (DRV)";
                                    }

                                    if (GetOptionValue(_paspart, 1) == "PASS")
                                    {
                                        if (GetOptionValue(_paspart, 3) == "PWR")
                                            partstring2 = "580288-" + _colour + " PWR (PASS)";
                                        else
                                            partstring2 = "580268-" + _colour + " MAN (PASS)";
                                    }

                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), partstring1 + "," + partstring2);
                                }
                                break;
                                #endregion
                            case "FRTCARPET":
                                #region FRTCARPET
                                if (_colour.Equals("D1"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), "550608N-D1,550608N-D1");
                                else if (_colour.Equals("L5"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), "550608N-L5,550608N-L5");
                                else if (_colour.Equals("L9"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), "550608N-L9,550608N-L9");
                                else if (_colour.Equals("TU"))
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), "550608N-TU,550608N-TU");
                                else
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue);
                                break;
                                #endregion
                            case "X9R4!RQ":
                                #region X9R4!RQ
                                var sng = GetOptionValue(part, 13);
                                if (sng == "SNG")
                                {
                                    if (_colour.Equals("X9") || _colour.Equals("R4"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue);
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "ONLYLXQD":
                                #region ONLYLXQD
                                var _lxqd = GetOptionValue(part, 11);
                                if (_lxqd.ToUpper() == "LXQD")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                break;
                                #endregion
                            case "BENCH":
                                #region BENCH
                                if (part.ItemType == "2B")
                                {
                                    if (_colour.Equals("D1") || _colour.Equals("L5") || _colour.Equals("TU"))
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                break;
                                #endregion
                            case "BENCH!RQ":
                                #region
                                if (part.ItemType == "2B")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "TBENCH!RQ":
                                #region TBENCH!RQ
                                if (part.ItemType == "2B")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "TNOBUILD!RQ":
                                #region
                                if (part.ItemComponent.Trim() == "NO-2LH" || part.ItemComponent.Trim() == "NO-2RH")
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "CLOTH!RQ":
                                #region CLOTH!RQ
                                var cloth = GetOptionValue(part, 5);
                                if (cloth.ToUpper() == "CLOTH")
                                {
                                    if (GetOptionValue(part, 10).ToUpper() != "HT")
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "H7N7X9!RQ":
                                #region
                                if (_trimstyle.Equals("H7") || _trimstyle.Equals("N7")) 
                                {
                                    if (_colour.Equals("X9") && GetOptionValue(part, 9) != "BUX")
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "HDRCOLOUR":
                                #region HDRCOLOUR
                                var _hdrcolour = _colour;
                                if (colourExtensions != null)
                                {
                                    var _ext = colourExtensions.Where(cExt => cExt.ColourCode == _hdrcolour && cExt.ExtensionName == "Headrest").ToList();

                                    if (_ext.Count() > 0)
                                        _hdrcolour = _ext[0].ColourCodeExt.Trim();
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _hdrcolour);
                                break;
                                #endregion
                            case "HDRTRIM":
                                #region HDRTRIM
                                var _hdrtrim = _trimstyle;
                                if (trimExtensions != null)
                                {
                                    var _ext = trimExtensions.Where(tExt => tExt.TrimCode == _hdrtrim && tExt.ExtensionName == "Headrest").ToList();
                                    if (_ext.Count() > 0)
                                        _hdrtrim = _ext[0].TrimCodeExt.Trim();
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _hdrtrim);
                                break;
                                #endregion
                            case "SKU":
                                #region SKU
                                //formattedMsg = formattedMsg.Replace(token.Token.Trim(), "*SKIPPED*");
                                //formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), item.ItemNumber);
                                break;
                                #endregion
                            case "X9ARM!RQ":
                                #region X9ARM_NOTREQ
                                //option 101 - colour
                                //option 100 - trim style
                                if ((GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "H7") || (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "AL") ||
                                    (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "ML") || (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "TL") ||
                                    (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "JL"))
                                {
                                    //skip
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                else
                                {
                                    if ((GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "N7") || (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "ZL") ||
                                        (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "CL"))
                                    {
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), "(92)");
                                    }
                                }

                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "SHLDCLR":
                                #region SHLDCLR
                                var _clrshield = _colour;
                                if (colourExtensions != null)
                                {
                                    var _ext =
                                        colourExtensions.Where(
                                            cExt =>
                                            cExt.ColourCode == _clrshield && cExt.ExtensionName == "Side Shield").ToList();

                                    if (_ext.Count() > 0)
                                        _clrshield = _ext[0].ColourCodeExt.Trim();
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _clrshield);
                                break;
                                #endregion
                            case "RHD":
                                #region RHD
                                //option 2 - lhd/rhd
                                var _rhd = (GetOptionValue(part, 2) == "RHD")
                                               ? "RHD"
                                               : String.Empty;
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _rhd);
                                break;
                                #endregion
                            case "LHPWR":
                                #region LHPWR
                                var _lhpart = item.ItemInfos.Where(i => i.PartIndex == 1).FirstOrDefault();
                                if (_lhpart != null)
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), ((_lhpart.Buildcode & 4) == 4)
                                                                        ? token.MessageTrue
                                                                        : token.MessageFalse);
                                }
                                break;
                                #endregion
                            case "RHPWR":
                                #region RHPWR
                                var _rhpart = item.ItemInfos.Where(i => i.PartIndex == 2).FirstOrDefault();
                                if (_rhpart != null)
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), ((_rhpart.Buildcode & 4) == 4)
                                                                        ? token.MessageTrue
                                                                        : token.MessageFalse);
                                }
                                break;
                                #endregion
                            case "BCKPNL":
                                #region BCKPNL
                                //option 330 back panel part number
                                //option 101 - colour
                                var _lhback = "N/A";
                                var _rhback = "N/A";

                                if (item.ItemInfos.Where(prt => prt.PartIndex == 1).Count() > 0)
                                    _lhback = GetOptionValue(item.ItemInfos.Where(prt => prt.PartIndex == 1).First(), 102);

                                if (item.ItemInfos.Where(prt => prt.PartIndex == 2).Count() > 0)
                                    _rhback = GetOptionValue(item.ItemInfos.Where(prt => prt.PartIndex == 2).First(), 102);

                                var _back = String.Format("{0}/{1}", _lhback.Trim(), _rhback.Trim());
                                if (_back.ToUpper().Equals("MESH/MESH") && GetOptionValue(part, 101) == "X9")
                                {
                                    //???
                                    _back += " %LGHT%";
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), _back);
                                break;
                                #endregion
                            case "X9PWR!RQ":
                                #region %9PWR_NOTREQ
                                //option 101 - colour
                                if (GetOptionValue(part, 101) == "X9" || GetOptionValue(part, 101) == "R4")
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), (((part.Buildcode & token.SeatOptions) ==
                                          (token.SeatOptions & token.SeatOptions2Check)) &&
                                         ((part.Buildcode & token.SeatOptions) ==
                                          (part.Buildcode & token.SeatOptions2Check)))
                                            ? token.MessageTrue.Trim()
                                            : token.MessageFalse.Trim());
                                }
                                else
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                }
                                break;
                                #endregion
                            case "X9PASSMAN!RQ":
                                #region X9PASSMAN!RQ
                                var _rhpartpassnotreq = item.ItemInfos.Where(i => i.PartIndex == 2).FirstOrDefault();
                                if (GetOptionValue(_rhpartpassnotreq, 101) == "X9")
                                {
                                    if (GetOptionValue(_rhpartpassnotreq, 104) == "MAN")
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "X9MAN!RQ":
                                #region X9MAN_NOTREQ
                                //option 101 - colour
                                if (GetOptionValue(part, 101) == "X9")
                                {
                                    if (GetOptionValue(part, 3) == "MAN")
                                        formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                    
                                }
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                break;
                                #endregion
                            case "X9H7RT!RQ":
                                #region X9H7RT_NOTREQ
                                //option 101 - colour
                                //option 100 - trim style
                                //option 4 - program
                                //option 9 - BUX
                                if (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "H7"
                                    && GetOptionValue(part, 4) == "RT" && GetOptionValue(part, 9) == "")
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                else if (GetOptionValue(part, 101) == "X9" && GetOptionValue(part, 100) == "N7"
                                    && GetOptionValue(part, 4) == "RT" && GetOptionValue(part, 9) == "")
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageTrue.Trim());
                                }
                                else
                                {
                                    formattedMsg = formattedMsg.Replace(token.Token.Trim(), token.MessageFalse.Trim());
                                }
                                break;
                                #endregion
                            default:
                                #region DEFAULT
                                formattedMsg = formattedMsg.Replace(token.Token.Trim(), (((part.Buildcode & token.SeatOptions) ==
                                                                  (token.SeatOptions & token.SeatOptions2Check)) &&
                                                                 ((part.Buildcode & token.SeatOptions) ==
                                                                  (part.Buildcode & token.SeatOptions2Check)))
                                                                    ? token.MessageTrue.Trim()
                                                                   : token.MessageFalse.Trim());
                                #endregion
                                break;
                        }
                    }

                    return formattedMsg;
                }
            }

            return String.Format("*Skipped* ({0})", itemNumber);
        }
示例#10
0
        public RepairBarcodeValidateResponse ValidateBarcodeFault([FromBody]ReworkBarcodeValidateRequest request, string barcode)
        {
            ItemDetailsModel model = new ItemDetailsModel();
            RequirementsDataContext db = new RequirementsDataContext();
            RepairBarcodeValidateResponse response = new RepairBarcodeValidateResponse();

            if (request.SkuInfo.Count() > 0) {
                var sku = request.SkuInfo[0].Sku;
                var lineId = request.SkuInfo[0].LineId;
                var cstype = request.BarcodeFault.CSType;
                var bcregex = db.BarcodeRegexes.Where(r=>r.CSType == request.BarcodeFault.CSType && r.LineId == lineId).FirstOrDefault();
                if (bcregex != null) {

                    var regex = new Regex(@bcregex.Regex.Trim());
                    var bcmatch = regex.Match(barcode);
                    if (bcmatch.Success)    //validate barcode
                    {
                        //still need to validate barcode
                        var itemInfo = model.GetItemInfo(sku);
                        var partItem = itemInfo.ItemInfos.Where(p => p.PartIndex == bcregex.PartIndex).FirstOrDefault();

                        switch (cstype)
                        {
                            case 1:
                            case 2:
                                var pretensionerPart = bcmatch.Groups["PART"].Value;
                                var pretensionerTrack = bcmatch.Groups["TRACKING"].Value;

                                if (partItem != null)
                                {
                                    string expectedPretPart = model.GetOptionValue(partItem, (int)bcregex.OptionNumber);

                                    if (expectedPretPart == pretensionerPart)
                                    {
                                        //part okay to update and save
                                        response.Success = true;
                                    }
                                    else
                                    {
                                        response.ErrorMessage = "Ops, Wrong Part Expecting: " + expectedPretPart;
                                        response.ExpectedValue = expectedPretPart;
                                        response.Success = false;
                                    }
                                }

                                break;
                            case 7:
                            case 8:
                                var headrestPart = bcmatch.Groups["PARTNO"].Value;
                                string expectedHeadRestPart = model.GetOptionValue(partItem, (int)bcregex.OptionNumber);
                                if (expectedHeadRestPart.IndexOf(headrestPart) != -1)
                                {
                                    //part okay to update and save
                                    response.Success = true;
                                }
                                else
                                {
                                    response.ErrorMessage = "Ops, Wrong Part Expecting: " + expectedHeadRestPart;
                                    response.ExpectedValue = expectedHeadRestPart;
                                    response.Success = false;
                                }

                                break;
                            case 11:
                            case 12:
                                var backDocusew = bcmatch.Groups["BC"].Value;
                                response.Success = true;
                                break;
                            case 23:
                            case 24:
                                var airbagTrack = bcmatch.Groups["AIRBAGTRCK"].Value;
                                response.Success = true;
                                break;
                            default:
                                break;
                        }

                        return response;
                    }
                    else
                    {
                        return new RepairBarcodeValidateResponse
                        {
                            ErrorMessage = "Error: Incorrect Barcode Pattern Match",
                            Success = false,
                        };
                    }
                }
            }

            return new RepairBarcodeValidateResponse
            {
                ErrorMessage = "Error: Cannot Locate Part Info",
                Success = false,
            };
        }
示例#11
0
        public RepairPalletInfo GetPalletInfo(int palletId, int mode, int entryMode)
        {
            RepairFaults faults = new RepairFaults();
            DispositionDataContext db = new DispositionDataContext();
            DispositionDatabase dbDisposition = new DispositionDatabase();
            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) //Check by job id when in manual mode and no ship pallet exists
            {
                if (entryMode == 2)
                {
                    var jobInfo = (from j in dbMes.MasterJobTables
                                   where j.Job_ID == palletId
                                   select j).FirstOrDefault();

                    if (jobInfo == null)
                        return null;

                    var itemMaster = dbMes.ItemMasterTables.Where(c => c.Item_Nbr == jobInfo.SKU).FirstOrDefault();
                    var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

                    var carline = (itemMaster == null) ? "UNKNOWN" : itemMaster.Carline;

                    var convertSkuInfo = GetSkuInfo(item);
                    var lineInfos = GetLineInfo(jobInfo);

                    return new RepairPalletInfo
                    {
                        RULabelVerification = (carline == "RU") ? GetRULabelVerification(jobInfo.Job_ID, item.LineId) : null,
                        Carline = carline,
                        PalletId = 0,
                        JobId = jobInfo.Job_ID,
                        LineInfos = lineInfos,
                        OrderNumber = jobInfo.Order_Nbr.Trim(),
                        SkuInfo = convertSkuInfo,
                        FinalQuestions = new List<FinalQuestionResult>(),
                        RepairFaults = GetEmptyRepairFaults(jobInfo, item, convertSkuInfo, lineInfos, 0, mode),
                        PalletDescription = new PalletDescription(convertSkuInfo, 0, jobInfo.Job_ID, jobInfo.Create_DTTM.ToString("yyyy-mm-dd h:mm:ss tt"), DateTime.Now.ToString("yyyy-mm-dd h:mm:ss tt")),
                    };
                }

                return null;
            }
            else
            {
                var jobInfo = (from j in dbMes.MasterJobTables
                               where j.Job_ID == palletHdr.Job_ID
                               select j).FirstOrDefault();

                if (jobInfo == null)
                    return null;

                var itemMaster = dbMes.ItemMasterTables.Where(c => c.Item_Nbr == jobInfo.SKU).FirstOrDefault();
                var item = itemDetailModel.GetItemInfo(jobInfo.SKU);

                if (item == null)
                {
                    throw new HttpResponseException(
                        HttpErrorResponse.GetHttpErrorResponse(
                        HttpStatusCode.NotFound, "SKU Error", string.Format("SKU = {0} is setup incorrectly", jobInfo.SKU)));
                }

                var carline = (itemMaster == null) ? "UNKNOWN" : itemMaster.Carline;

                var convertSkuInfo = GetSkuInfo(item);
                var lineInfos = GetLineInfo(jobInfo);

                return new RepairPalletInfo
                {
                    RULabelVerification = (carline == "RU") ? GetRULabelVerification(jobInfo.Job_ID, item.LineId) : null,
                    Carline = carline,
                    PalletId = palletId,
                    JobId = jobInfo.Job_ID,
                    LineInfos = lineInfos,
                    OrderNumber = jobInfo.Order_Nbr.Trim(),
                    SkuInfo = convertSkuInfo,
                    FinalQuestions = dbDisposition.GetFinalQuestionsResult(jobInfo.Group),
                    RepairFaults = GetRepairFaults(jobInfo, item, convertSkuInfo, lineInfos, palletId, mode, carline),
                    PalletDescription = new PalletDescription(convertSkuInfo, palletHdr.PalletNbr, jobInfo.Job_ID, jobInfo.Create_DTTM.ToString("yyyy-mm-dd h:mm:ss tt"), palletHdr.Assigned_DTTM.Value.ToString("yyy-mm-dd h:mm:ss tt")),
                };
            }
        }
示例#12
0
        public List<SkuInfo> GetSkuInfoByPalletId(int palletId)
        {
            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 item = itemDetailModel.GetItemInfo(jobInfo.SKU);

            var convertSkuInfo = GetSkuInfo(item);
            return convertSkuInfo;
        }