コード例 #1
0
ファイル: IVTestDataViewModels.cs プロジェクト: 88886/jnmmes
        /// <summary> 获取层压机信息 </summary>
        /// <param name="lotNumber">批次号</param>
        /// <returns></returns>
        public LotAttribute GetLaminator(string lotNumber)
        {
            LotAttribute LotAttribute = null;       //批次属性
            Equipment    Equipment    = null;       //批次设备

            //获取批次属性
            using (LotAttributeServiceClient client = new LotAttributeServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key.LotNumber='{0}' AND Key.AttributeName ='LayerEquipmentNo'", lotNumber)
                };
                MethodReturnResult <IList <LotAttribute> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
                {
                    LotAttribute = result.Data[0];

                    //获取批次设备
                    Equipment = GetEquipment(LotAttribute.AttributeValue);

                    if (Equipment != null)
                    {
                        LotAttribute.AttributeValue = Equipment.Name;
                    }
                    else
                    {
                        LotAttribute.AttributeValue = LotAttribute.AttributeValue;
                    }
                }
            }
            return(LotAttribute);
        }
コード例 #2
0
        internal static LotAttribute SetValues(this LotAttribute lotAttribute, ILotKey lotKey = null, IAttributeNameKey attributeNameKey = null, double?value = null, bool?computed = null)
        {
            if (lotKey != null)
            {
                lotAttribute.Lot             = null;
                lotAttribute.LotDateCreated  = lotKey.LotKey_DateCreated;
                lotAttribute.LotDateSequence = lotKey.LotKey_DateSequence;
                lotAttribute.LotTypeId       = lotKey.LotKey_LotTypeId;
            }

            if (attributeNameKey != null)
            {
                lotAttribute.AttributeName      = null;
                lotAttribute.AttributeShortName = attributeNameKey.AttributeNameKey_ShortName;
            }

            if (value != null)
            {
                lotAttribute.AttributeValue = (double)value;
            }

            if (computed != null)
            {
                lotAttribute.Computed = computed.Value;
            }

            return(lotAttribute);
        }
コード例 #3
0
 public LotAttributeModel Create(LotAttribute lotAttribute)
 {
     if (lotAttribute == null)
     {
         return(null);
     }
     return(new LotAttributeModel()
     {
         Company = lotAttribute.Company,
         PONum = lotAttribute.PONum,
         POLine = lotAttribute.POLine,
         AttBatch = lotAttribute.AttBatch,
         Batch = lotAttribute.Batch,
         AttMfgBatch = lotAttribute.AttMfgBatch,
         MBatch = lotAttribute.MBatch,
         AttMfgLot = lotAttribute.AttMfgLot,
         MLot = lotAttribute.MLot,
         AttHeat = lotAttribute.AttHeat,
         Heat = lotAttribute.Heat,
         AttFirmware = lotAttribute.AttFirmware,
         Firm = lotAttribute.Firm,
         AttBeforeDt = lotAttribute.AttBeforeDt,
         BestBefore = lotAttribute.BestBefore,
         AttMfgDt = lotAttribute.AttMfgDt,
         OrigMfg = lotAttribute.OrigMfg,
         AttCureDt = lotAttribute.AttCureDt,
         Cure = lotAttribute.Cure,
         AttExpDt = lotAttribute.AttExpDt,
         Expire = lotAttribute.Expire
     });
 }
コード例 #4
0
        private IResult UpdateLotAttribute(LotAttribute lotAttribute, IAttributeValueParameters attributeValue)
        {
            var range = _parameters.ChileProductAttributeRanges.FirstOrDefault(r => r.AttributeShortName == lotAttribute.AttributeShortName);

            if (range != null)
            {
                if (range.ValueOutOfRange(attributeValue.NewValue.Value))
                {
                    var updateLotDefectsResult = UpdateOrCreateLotDefects(lotAttribute, attributeValue, range);
                    if (!updateLotDefectsResult.Success)
                    {
                        return(updateLotDefectsResult);
                    }
                }
                else
                {
                    var resolveOpenDefectsResult = ResolveOpenDefectsForAttribute(lotAttribute, attributeValue);
                    if (!resolveOpenDefectsResult.Success)
                    {
                        return(resolveOpenDefectsResult);
                    }
                }
            }

            lotAttribute.EmployeeId     = _parameters.Employee.EmployeeId;
            lotAttribute.TimeStamp      = _parameters.TimeStamp;
            lotAttribute.AttributeValue = attributeValue.NewValue.Value;
            lotAttribute.AttributeDate  = attributeValue.AttributeDate;
            lotAttribute.Computed       = false;

            return(new SuccessResult());
        }
コード例 #5
0
        private IResult ResolveOpenDefectsForAttribute(LotAttribute lotAttribute, IAttributeValueParameters attributeValue)
        {
            var unresolvedDefects = _parameters.LotAttributeDefects.GetUnresolvedDefects(lotAttribute.AttributeShortName).ToList();

            if (!unresolvedDefects.Any())
            {
                return(new SuccessResult());
            }

            if (attributeValue.Resolution == null)
            {
                return(new InvalidResult(string.Format(UserMessages.AttributeDefectRequiresResolution, lotAttribute.AttributeShortName)));
            }

            if (!lotAttribute.IsValidResolution(attributeValue.Resolution.ResolutionType))
            {
                return(new InvalidResult(string.Format(UserMessages.InvalidDefectResolutionType, attributeValue.Resolution.ResolutionType, lotAttribute.AttributeName.DefectType)));
            }

            IResult result;

            if (attributeValue.Resolution.ResolutionType == ResolutionTypeEnum.Treated && !ValidateTreatmentResolution(_parameters, lotAttribute, out result))
            {
                return(result);
            }

            return(ResolveDefects(unresolvedDefects, _parameters, attributeValue.Resolution, _lotUnitOfWork));
        }
コード例 #6
0
        private IResult UpdateOrCreateLotDefects(LotAttribute lotAttribute, IAttributeValueParameters attributeValue, ChileProductAttributeRange range)
        {
            var unresolvedDefects = _parameters.LotAttributeDefects.Where(d => d.AttributeShortName == lotAttribute.AttributeShortName && d.LotDefect.Resolution == null).ToList();

            if (unresolvedDefects.Any())
            {
                unresolvedDefects.ForEach(d =>
                {
                    d.OriginalAttributeValue    = attributeValue.NewValue.Value;
                    d.OriginalAttributeMinLimit = range.RangeMin;
                    d.OriginalAttributeMaxLimit = range.RangeMax;
                });
            }
            else
            {
                int defectId;
                lock (LotDefectLock)
                {
                    defectId = new EFUnitOfWorkHelper(_lotUnitOfWork).GetNextSequence <LotDefect>(d => d.LotDateCreated == _parameters.Lot.LotDateCreated && d.LotDateSequence == _parameters.Lot.LotDateSequence && d.LotTypeId == _parameters.Lot.LotTypeId, d => d.DefectId);
                }

                var lotDefect = _lotUnitOfWork.LotDefectRepository.Add(new LotDefect
                {
                    LotDateCreated  = _parameters.Lot.LotDateCreated,
                    LotDateSequence = _parameters.Lot.LotDateSequence,
                    LotTypeId       = _parameters.Lot.LotTypeId,
                    DefectId        = defectId,
                    DefectType      = lotAttribute.AttributeName.DefectType,
                    Description     = lotAttribute.AttributeName.Name,
                });
                _lotUnitOfWork.LotAttributeDefectRepository.Add(new LotAttributeDefect
                {
                    LotDateCreated     = lotDefect.LotDateCreated,
                    LotDateSequence    = lotDefect.LotDateSequence,
                    LotTypeId          = lotDefect.LotTypeId,
                    DefectId           = lotDefect.DefectId,
                    AttributeShortName = lotAttribute.AttributeShortName,

                    OriginalAttributeValue    = attributeValue.NewValue.Value,
                    OriginalAttributeMinLimit = range.RangeMin,
                    OriginalAttributeMaxLimit = range.RangeMax,
                    AttributeName             = lotAttribute.AttributeName,
                });
            }

            return(new SuccessResult());
        }
コード例 #7
0
            private void UpdateExistingLotAttribute(LotAttribute existingLotAttribute, AttributeName attributeName, AttributeCommonData attributeData, ChileProductAttributeRange range, double value, ref List <LotAttributeDefect> lotAttributeDefects)
            {
                if (range.ValueOutOfRange(value))
                {
                    CreateOrUpdateOpenAttributeDefect(existingLotAttribute.Lot, attributeName, value, range, ref lotAttributeDefects);
                }
                else
                {
                    CloseOpenAttributeDefects(existingLotAttribute, lotAttributeDefects);
                }

                if (Math.Abs(existingLotAttribute.AttributeValue - value) > 0.0001)
                {
                    existingLotAttribute.AttributeValue = value;
                    existingLotAttribute.Computed       = attributeData.NullTestDate;
                    existingLotAttribute.AttributeDate  = attributeData.DeterminedTestDate;
                }
            }
コード例 #8
0
        public static LotAttribute AddNewAttribute(this Lot lot, ILotAttributes oldLot, IAttributeNameKey attributeNameKey, CreateChileLotHelper.AttributeCommonData attributeData, ILotMother lotMother)
        {
            var getter = oldLot.AttributeGet(attributeNameKey);

            if (getter == null)
            {
                return(null);
            }

            var setter = oldLot.AttributeSet(attributeNameKey, true);
            var value  = setter(getter());

            if (value == null)
            {
                return(null);
            }

            lotMother.AddRead(EntityTypes.LotAttribute);
            if (attributeData.EntryDate == null)
            {
                return(null);
            }

            var lotAttribute = new LotAttribute
            {
                LotDateCreated     = lot.LotDateCreated,
                LotDateSequence    = lot.LotDateSequence,
                LotTypeId          = lot.LotTypeId,
                AttributeShortName = attributeNameKey.AttributeNameKey_ShortName,

                AttributeValue = (double)value,
                AttributeDate  = attributeData.DeterminedTestDate,

                EmployeeId = attributeData.TesterId,
                TimeStamp  = attributeData.EntryDate.Value,
                Computed   = attributeData.NullTestDate
            };

            lot.Attributes.Add(lotAttribute);
            return(lotAttribute);
        }
コード例 #9
0
        private IResult UpdateLotAttribute(LotAttribute lotAttribute, IAttributeValueParameters attributeValue, out bool inSpec)
        {
            var range = _parameters.ProductAttributeRanges.FirstOrDefault(r => r.AttributeNameKey_ShortName == lotAttribute.AttributeShortName);

            inSpec = !range.ValueOutOfRange(attributeValue.AttributeInfo.Value);
            if (!inSpec)
            {
                var updateLotDefectsResult = UpdateOrCreateLotDefects(lotAttribute, attributeValue, range);
                if (!updateLotDefectsResult.Success)
                {
                    return(updateLotDefectsResult);
                }
            }

            lotAttribute.EmployeeId     = _parameters.Employee.EmployeeId;
            lotAttribute.TimeStamp      = _parameters.TimeStamp;
            lotAttribute.AttributeValue = attributeValue.AttributeInfo.Value;
            lotAttribute.AttributeDate  = attributeValue.AttributeInfo.Date;
            lotAttribute.Computed       = false;

            return(new SuccessResult());
        }
コード例 #10
0
 private void RemoveExistingLotAttribute(LotAttribute existingLotAttribute, ref List <LotAttributeDefect> lotAttributeDefects)
 {
     CloseOpenAttributeDefects(existingLotAttribute, lotAttributeDefects);
     existingLotAttribute.Lot.Attributes.Remove(existingLotAttribute);
 }
コード例 #11
0
        private static bool TreatmentResolutionIsValidForPickedInventoryItems(IEnumerable <PickedInventoryItem> pickedInventory, LotAttribute lotAttribute, out IResult result)
        {
            result = null;
            var pickedInventoryWithInvalidTreatment = pickedInventory.FirstOrDefault(i => lotAttribute.AttributeName.ValidTreatments.All(t => t.TreatmentId != i.TreatmentId));

            if (pickedInventoryWithInvalidTreatment == null)
            {
                return(true);
            }

            result = new InvalidResult(string.Format(UserMessages.TreatmentOnUnarchivedPickedInventoryDoesNotResolveDefect,
                                                     pickedInventoryWithInvalidTreatment.Treatment.ShortName,
                                                     pickedInventoryWithInvalidTreatment.ToPickedInventoryItemKey(),
                                                     lotAttribute.AttributeName.Name));
            return(false);
        }
コード例 #12
0
        /// <summary>
        /// 将图片数据上传到MES中。
        /// </summary>
        /// <param name="element">图片设备配置。</param>
        /// <returns>true:转置成功。false:转置失败。</returns>
        public bool Execute(ImageDeviceElement element)
        {
            try
            {
                //获取源文件夹路径。
                string sourcePath = this.GetSourcePath(element);
                if (string.IsNullOrEmpty(sourcePath))
                {
                    EventLog.WriteEntry(EVENT_SOURCE_NAME
                                        , string.Format("获取 {0} 源文件夹路径失败。", element.Name)
                                        , EventLogEntryType.Error);
                    return(false);
                }
                //获取目标文件夹路径。
                string sourceRootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar);
                string targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar);
                //string targetPath = sourcePath.Replace(sourceRootPath, targetRootPath);
                string targetPath = this.GetTargetPath(element);

                if (Directory.Exists(targetPath) == false)
                {
                    EventLog.WriteEntry(EVENT_SOURCE_NAME
                                        , string.Format("{0} 目标文件夹路径({1})不存在。", element.Name, targetPath)
                                        , EventLogEntryType.Warning);
                    Directory.CreateDirectory(targetPath);
                }
                //获取源文件夹下的未移转图片。
                DirectoryInfo diSourcePath  = new DirectoryInfo(sourcePath);
                string        searchPattern = string.Format("*.{0}", element.FileExtensionName);
                FileInfo[]    fileInfos     = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories);
                DateTime      dtMaxTime     = DateTime.MinValue;
                //移除最新的更新时间问题

                /*
                 * using (ClientConfigAttributeServiceClient client = new ClientConfigAttributeServiceClient())
                 * {
                 *  MethodReturnResult<ClientConfigAttribute> rst = client.Get(new ClientConfigAttributeKey()
                 *  {
                 *      ClientName = element.Name,
                 *      AttributeName = string.Format("{0}ImageDateTime", element.Type)
                 *  });
                 *  if (rst.Code <= 0 && rst.Data != null)
                 *  {
                 *      dtMaxTime = DateTime.Parse(rst.Data.Value);
                 *  }
                 *  client.Close();
                 * }
                 * var lnq = from item in fileInfos
                 *        where item.LastWriteTime > dtMaxTime
                 *        orderby item.LastWriteTime
                 *        select item;
                 */
                //遍历文件夹文件。
                IList <LotAttribute> lstLotAttribute = new List <LotAttribute>();
                foreach (FileInfo fiItem in fileInfos)
                {
                    string targetFileName = fiItem.FullName.Replace(sourcePath, targetPath);
                    Directory.CreateDirectory(Path.GetDirectoryName(targetFileName));
                    //复制源文件到目标文件夹下。
                    File.Copy(fiItem.FullName, targetFileName, true);
                    dtMaxTime = fiItem.LastWriteTime.AddMilliseconds(1);
                    #region  //更新批次属性数据。
                    try
                    {
                        string lotNumber = fiItem.Name.Replace(fiItem.Extension, string.Empty).ToUpper().Split('_', '-')[0];
                        lotNumber = lotNumber.Trim();
                        string attributeName  = string.Format("{0}ImagePath", element.Type);
                        string attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot);
                        attributeValue = attributeValue.Replace('\\', '/');
                        LotAttribute obj = new LotAttribute()
                        {
                            Key = new LotAttributeKey()
                            {
                                LotNumber     = lotNumber,
                                AttributeName = attributeName
                            },
                            AttributeValue = attributeValue,
                            Editor         = "system",
                            EditTime       = DateTime.Now
                        };
                        using (LotAttributeServiceClient client = new LotAttributeServiceClient())
                        {
                            MethodReturnResult result = client.Modify(obj);
                            if (result.Code > 0)
                            {
                                EventLog.WriteEntry(EVENT_SOURCE_NAME
                                                    , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, result.Message)
                                                    , EventLogEntryType.Warning);
                                client.Close();
                                continue;
                            }
                            client.Close();
                        }
                    }
                    catch (Exception ex)
                    {
                        EventLog.WriteEntry(EVENT_SOURCE_NAME
                                            , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, ex.Message)
                                            , EventLogEntryType.Error);
                        System.Threading.Thread.Sleep(500);
                        return(false);
                    }
                    #endregion

                    #region //进行原文件的后续处理。
                    int count = 0;
                    while (count < 5)
                    {
                        count++;
                        try
                        {
                            //如设置删除源文件,则删除。
                            if (element.IsDeleteSourceFile)
                            {
                                File.Delete(fiItem.FullName);
                            }
                            else
                            {//否则,移动到LocalFiles下。
                             //string copyFilePath = sourcePath.TrimEnd(Path.DirectorySeparatorChar) + Path.DirectorySeparatorChar + "LocalFiles";
                             //if (Directory.Exists(copyFilePath) == false)
                             //{
                             //    Directory.CreateDirectory(copyFilePath);
                             //}
                             //string copyFileName = fiItem.FullName.Replace(sourcePath, copyFilePath);
                             //File.Copy(fiItem.FullName, copyFileName,true);
                             //File.Delete(fiItem.FullName);
                            }
                            break;
                        }
                        catch (Exception ex)
                        {
                            EventLog.WriteEntry(EVENT_SOURCE_NAME
                                                , string.Format("{0}:{1} {2}", element.Name, fiItem.FullName, ex.Message)
                                                , EventLogEntryType.Error);
                            System.Threading.Thread.Sleep(500);
                            continue;
                        }
                    }
                    #endregion

                    #region 更新ClientConfig的最新更新时间

                    /*
                     * using (ClientConfigServiceClient client = new ClientConfigServiceClient())
                     * {
                     *  MethodReturnResult<ClientConfig> rst = client.Get(element.Name);
                     *  if (rst.Data == null)
                     *  {
                     *      ClientConfig obj = new ClientConfig()
                     *      {
                     *          ClientType = EnumClientType.Other,
                     *          CreateTime = DateTime.Now,
                     *          Creator = "system",
                     *          Description = string.Empty,
                     *          Editor = "system",
                     *          EditTime = DateTime.Now,
                     *          IPAddress = element.Name,
                     *          Key = element.Name,
                     *          LocationName = null
                     *      };
                     *      client.Add(obj);
                     *  }
                     *  client.Close();
                     * }
                     * using (ClientConfigAttributeServiceClient client = new ClientConfigAttributeServiceClient())
                     * {
                     *  ClientConfigAttribute obj = null;
                     *  ClientConfigAttributeKey ccaKey = new ClientConfigAttributeKey()
                     *  {
                     *      ClientName = element.Name,
                     *      AttributeName = string.Format("{0}ImageDateTime",element.Type)
                     *  };
                     *  MethodReturnResult<ClientConfigAttribute> rst = client.Get(ccaKey);
                     *  if (rst.Code <= 0 && rst.Data != null)
                     *  {
                     *      obj = rst.Data;
                     *  }
                     *  if (obj != null)
                     *  {
                     *      obj.Value = dtMaxTime.ToString("yyyy-MM-dd HH:mm:ss.fff");
                     *      obj.Editor = "system";
                     *      obj.EditTime = DateTime.Now;
                     *      client.Modify(obj);
                     *  }
                     *  else
                     *  {
                     *      obj = new ClientConfigAttribute()
                     *      {
                     *          Key = ccaKey,
                     *          Value = dtMaxTime.ToString("yyyy-MM-dd HH:mm:ss.fff"),
                     *          Editor = "system",
                     *          EditTime = DateTime.Now
                     *      };
                     *      client.Add(obj);
                     *  }
                     *  client.Close();
                     * }
                     */
                    #endregion
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(EVENT_SOURCE_NAME
                                    , string.Format("{0}:{1}", element.Name, ex.Message)
                                    , EventLogEntryType.Error);
                return(false);
            }
            return(true);
        }
コード例 #13
0
 public static bool IsValidResolution(this LotAttribute attribute, ResolutionTypeEnum resolutionType)
 {
     return(attribute.AttributeName.IsValidResolution(resolutionType));
 }
コード例 #14
0
        public IResult Execute(ChileLot chileLot, List <PickedInventoryItem> pickedItems, DateTime timestamp)
        {
            if (chileLot == null)
            {
                throw new ArgumentNullException("chileLot");
            }
            if (pickedItems == null)
            {
                throw new ArgumentNullException("pickedItems");
            }

            var actualsRequired = new HashSet <AttributeNameKey>(_lotUnitOfWork.AttributeNameRepository
                                                                 .All().Where(a => a.ActualValueRequired)
                                                                 .ToList()
                                                                 .Select(a => a.ToAttributeNameKey()));

            foreach (var item in pickedItems)
            {
                item.PackagingProduct = _lotUnitOfWork.PackagingProductRepository.FindByKey(item.ToPackagingProductKey());
                item.Lot = _lotUnitOfWork.LotRepository.FindByKey(item.ToLotKey(), i => i.Attributes.Select(a => a.AttributeName));
            }

            var weightedAverages = CalculateAttributeWeightedAveragesCommand.Execute(pickedItems);

            if (!weightedAverages.Success)
            {
                return(weightedAverages);
            }

            var attributesToRemove = chileLot.Lot.Attributes.ToList();
            var attributesToSet    = weightedAverages.ResultingObject.Where(a => !actualsRequired.Contains(a.Key.Attribute.ToAttributeNameKey())).ToList();

            foreach (var weightedAttribute in attributesToSet)
            {
                var namePredicate = weightedAttribute.Key.AttributeNameKey.FindByPredicate.Compile();
                var lotAttribute  = attributesToRemove.FirstOrDefault(a => namePredicate(a.AttributeName));
                if (lotAttribute != null)
                {
                    attributesToRemove.Remove(lotAttribute);
                }
                else
                {
                    lotAttribute = new LotAttribute
                    {
                        LotDateCreated     = chileLot.LotDateCreated,
                        LotDateSequence    = chileLot.LotDateSequence,
                        LotTypeId          = chileLot.LotTypeId,
                        AttributeShortName = weightedAttribute.Key.AttributeNameKey.AttributeNameKey_ShortName,
                        Computed           = true
                    };
                    chileLot.Lot.Attributes.Add(lotAttribute);
                }

                if (lotAttribute.Computed)
                {
                    lotAttribute.AttributeValue = weightedAttribute.Value;
                    lotAttribute.EmployeeId     = chileLot.Production.PickedInventory.EmployeeId;
                    lotAttribute.AttributeDate  = (lotAttribute.TimeStamp = timestamp).Date;
                }
            }

            foreach (var attribute in attributesToRemove.Where(a => a.Computed))
            {
                _lotUnitOfWork.LotAttributeRepository.Remove(attribute);
            }

            return(new SuccessResult());
        }
コード例 #15
0
ファイル: IVTestDataViewModels.cs プロジェクト: 88886/jnmmes
        /// <summary> 获取层压机信息 </summary>
        /// <param name="lotNumber">批次号</param>
        /// <returns></returns>
        public LotAttribute GetLaminator(string lotNumber)
        {
            LotAttribute LotAttribute = null;

            using (LotAttributeServiceClient client = new LotAttributeServiceClient())
            {
                PagingConfig cfg = new PagingConfig()
                {
                    PageNo   = 0,
                    PageSize = 1,
                    Where    = string.Format("Key.LotNumber='{0}' AND Key.AttributeName ='LayerEquipmentNo'", lotNumber)
                };
                MethodReturnResult <IList <LotAttribute> > result = client.Get(ref cfg);
                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0)
                {
                    LotAttribute = result.Data[0];

                    if (LotAttribute.AttributeValue == "EMCY2001")
                    {
                        LotAttribute.AttributeValue = "102B-1#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2002")
                    {
                        LotAttribute.AttributeValue = "102B-2#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2003")
                    {
                        LotAttribute.AttributeValue = "102B-3#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2004")
                    {
                        LotAttribute.AttributeValue = "102B-4#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2005")
                    {
                        LotAttribute.AttributeValue = "102B-5#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2006")
                    {
                        LotAttribute.AttributeValue = "102B-6#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2007")
                    {
                        LotAttribute.AttributeValue = "102B-7#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2008")
                    {
                        LotAttribute.AttributeValue = "102B-8#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2009")
                    {
                        LotAttribute.AttributeValue = "102B-9#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY2010")
                    {
                        LotAttribute.AttributeValue = "102B-10#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1001")
                    {
                        LotAttribute.AttributeValue = "102A-1#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1002")
                    {
                        LotAttribute.AttributeValue = "102A-2#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1003")
                    {
                        LotAttribute.AttributeValue = "102A-3#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1004")
                    {
                        LotAttribute.AttributeValue = "102A-4#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1005")
                    {
                        LotAttribute.AttributeValue = "102A-5#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1006")
                    {
                        LotAttribute.AttributeValue = "102A-6#";
                    }
                    else if (LotAttribute.AttributeValue == "EMCY1007")
                    {
                        LotAttribute.AttributeValue = "102A-7#";
                    }
                    else if (LotAttribute.AttributeValue == "")
                    {
                        LotAttribute.AttributeValue = "null";
                    }
                }
                else
                {
                    result.Data = null;
                }
                return(LotAttribute);
            }
        }
コード例 #16
0
 private static bool ValidateTreatmentResolution(Parameters parameters, LotAttribute lotAttribute, out IResult result)
 {
     return(TreatmentResolutionIsValidForInventory(parameters.Inventory, lotAttribute, out result) &&
            TreatmentResolutionIsValidForPickedInventoryItems(parameters.LotPickedInventoryItems, lotAttribute, out result));
 }
コード例 #17
0
 internal static LotAttribute SetValues(this LotAttribute lotAttribute, IAttributeNameKey attributeNameKey = null, double?value = null, bool?computed = null)
 {
     return(lotAttribute.SetValues(null, attributeNameKey, value, computed));
 }
コード例 #18
0
        private static bool TreatmentResolutionIsValidForInventory(IEnumerable <Data.Models.Inventory> inventory, LotAttribute lotAttribute, out IResult result)
        {
            result = null;
            var inventoryWithInvalidTreatment = inventory.FirstOrDefault(i => lotAttribute.AttributeName.ValidTreatments.All(t => t.TreatmentId != i.TreatmentId));

            if (inventoryWithInvalidTreatment == null)
            {
                return(true);
            }

            result = new InvalidResult(string.Format(UserMessages.TreatmentOnInventoryDoesNotResolveDefect,
                                                     inventoryWithInvalidTreatment.Treatment.ShortName,
                                                     inventoryWithInvalidTreatment.ToInventoryKey(),
                                                     lotAttribute.AttributeName.Name));
            return(false);
        }
コード例 #19
0
 public PickingValidatorAttributeAndDefects(LotAttribute attribute, IEnumerable <LotAttributeDefect> defects)
 {
     AttributeValue   = attribute.AttributeValue;
     DefectResolution = defects.Select(d => d.LotDefect.Resolution != null).ToList();
 }
コード例 #20
0
        /// <summary>
        /// 将图片数据上传到MES中。
        /// </summary>
        /// <param name="element">图片设备配置。</param>
        /// <returns>true:转置成功。false:转置失败。</returns>
        public void Execute(ImageDeviceElement element)
        {
            bool   blFindFiles          = false;
            bool   blTransferDataResult = true;
            string strTransferDataMsg   = "";

            try
            {
                //获取源文件夹路径。
                string sourcePath = this.GetSourcePath(element);
                if (string.IsNullOrEmpty(sourcePath))
                {
                    blTransferDataResult = false;
                    strTransferDataMsg   = string.Format("获取 {0} 源文件夹路径失败。", element.Name);
                }
                //获取目标文件夹路径。
                string sourceRootPath = element.SourcePathRoot.TrimEnd(Path.DirectorySeparatorChar);
                string targetRootPath = element.TargetPathRoot.TrimEnd(Path.DirectorySeparatorChar);
                //string targetPath = sourcePath.Replace(sourceRootPath, targetRootPath);
                string targetPath = this.GetTargetPath(element);

                if (Directory.Exists(targetPath) == false)
                {
                    Directory.CreateDirectory(targetPath);
                }
                //获取源文件夹下的未移转图片。
                DirectoryInfo diSourcePath  = new DirectoryInfo(sourcePath);
                string        searchPattern = string.Format("*.{0}", element.FileExtensionName);
                FileInfo[]    fileInfos     = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories);
                if (fileInfos != null && fileInfos.Length > 0)
                {
                    blFindFiles = true;
                }
                DateTime dtMaxTime = DateTime.MinValue;
                //遍历文件夹文件。
                int maxNumberForLoop = 5;
                int nIndexOfFile     = 0;
                if (fileInfos.Length > maxNumberForLoop)
                {
                    SortAsFileCreationTime(ref fileInfos);
                }
                IList <LotAttribute> lstLotAttribute = new List <LotAttribute>();
                foreach (FileInfo fiItem in fileInfos)
                {
                    if (nIndexOfFile > maxNumberForLoop)
                    {
                        break;
                    }
                    nIndexOfFile = nIndexOfFile + 1;

                    string targetFileName = fiItem.FullName.Replace(sourcePath, targetPath);
                    Directory.CreateDirectory(Path.GetDirectoryName(targetFileName));

                    #region  //更新批次属性数据。
                    try
                    {
                        bool blFlag = true;
                        //复制源文件到目标文件夹下。
                        // blFlag = this.MoveFile(element, fiItem.FullName, targetFileName);
                        string lotNumber = "";

                        if (blFlag)
                        {
                            #endregion

                            #region //更新 Lot属性
                            lotNumber = fiItem.Name.Replace(fiItem.Extension, string.Empty).ToUpper().Split('_', '-')[0];
                            lotNumber = lotNumber.Trim();

                            #region//获取批次所在工序及状态
                            using (LotQueryServiceClient client = new LotQueryServiceClient())
                            {
                                PagingConfig cfg = new PagingConfig()
                                {
                                    Where   = string.Format("LOT_NUMBER = '{0} '", lotNumber),
                                    OrderBy = "EditTime Desc"
                                };
                                MethodReturnResult <IList <LotTransaction> > result = client.GetTransaction(ref cfg);
                                if (result.Code <= 0 && result.Data != null && result.Data.Count > 0 && result.Data[0].RouteStepName == "功率测试" && result.Data[0].Activity == EnumLotActivity.TrackOut)
                                {
                                    string attributeName  = string.Format("{0}ImagePath", element.Type);
                                    string attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot);
                                    attributeValue = attributeValue.Replace('\\', '/');

                                    //获取批次属性是否已存在EL3的属性,如果不存在,则更新EL3图片属性
                                    using (LotAttributeServiceClient client2 = new LotAttributeServiceClient())
                                    {
                                        PagingConfig cfg1 = new PagingConfig()
                                        {
                                            Where   = string.Format("Key.LotNumber = '{0}'and Key.AttributeName='ELImagePath'", lotNumber),
                                            OrderBy = "EditTime Desc"
                                        };
                                        MethodReturnResult <IList <LotAttribute> > result2 = client.GetAttribute(ref cfg1);
                                        if (result2.Code <= 0 && result2.Data != null && result2.Data.Count > 0)
                                        {
                                            blFlag = this.MoveFile(element, fiItem.FullName, targetFileName);
                                            FileInfo[] fileInfos1 = diSourcePath.GetFiles(searchPattern, SearchOption.AllDirectories);
                                            foreach (FileInfo fiItem1 in fileInfos1)
                                            {
                                                if (nIndexOfFile > maxNumberForLoop)
                                                {
                                                    break;
                                                }
                                                nIndexOfFile = nIndexOfFile + 1;

                                                targetFileName = fiItem1.FullName.Replace(sourcePath, targetPath);
                                                Directory.CreateDirectory(Path.GetDirectoryName(targetFileName));
                                                File.Delete(fiItem1.FullName);
                                            }
                                            attributeValue = targetFileName.Replace(targetRootPath, element.HttpPathRoot);
                                            LotAttribute obj = new LotAttribute()
                                            {
                                                Key = new LotAttributeKey()
                                                {
                                                    LotNumber     = lotNumber,
                                                    AttributeName = attributeName
                                                },
                                                AttributeValue = attributeValue,
                                                Editor         = "system",
                                                EditTime       = DateTime.Now
                                            };
                                            using (LotAttributeServiceClient client1 = new LotAttributeServiceClient())
                                            {
                                                MethodReturnResult result1 = client1.Modify(obj);
                                                if (result.Code > 0)
                                                {
                                                    strTransferDataMsg = string.Format("更新批次号{0}错误:{1}", lotNumber, result.Message);
                                                    LogMessage(false, element.Type + ":" + strTransferDataMsg);
                                                    client.Close();
                                                }
                                                else
                                                {
                                                    LogMessage(true, element.Type + ":" + lotNumber);
                                                }
                                                client.Close();
                                            }
                                        }
                                        else
                                        {
                                            LotAttribute obj = new LotAttribute()
                                            {
                                                Key = new LotAttributeKey()
                                                {
                                                    LotNumber     = lotNumber,
                                                    AttributeName = attributeName
                                                },
                                                AttributeValue = attributeValue,
                                                Editor         = "system",
                                                EditTime       = DateTime.Now
                                            };
                                            using (LotAttributeServiceClient client1 = new LotAttributeServiceClient())
                                            {
                                                MethodReturnResult result1 = client1.Modify(obj);
                                                if (result.Code > 0)
                                                {
                                                    strTransferDataMsg = string.Format("更新批次号{0}错误:{1}", lotNumber, result.Message);
                                                    LogMessage(false, element.Type + ":" + strTransferDataMsg);
                                                    client.Close();
                                                }
                                                else
                                                {
                                                    LogMessage(true, element.Type + ":" + lotNumber);
                                                }
                                                client.Close();
                                            }
                                            blFlag = this.MoveFile(element, fiItem.FullName, targetFileName);
                                            File.Delete(fiItem.FullName);
                                        }
                                    }
                                }
                                else
                                {
                                    result.Message     = "组件批次不在功率测试出站";
                                    strTransferDataMsg = string.Format("批次号{0}错误:{1}", lotNumber, result.Message);
                                    blFlag             = this.MoveFile(element, fiItem.FullName, targetFileName);
                                    File.Delete(fiItem.FullName);
                                }

                                #endregion
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        LogMessage(false, element.Type + ":" + ex.Message);
                    }
                    #endregion
                }
            }
            catch (Exception ex)
            {
                blTransferDataResult = false;
                LogMessage(false, element.Type + ":" + ex.Message);
            }

            if (blFindFiles == false)
            {
                strTransferDataMsg = "";
                LogMessage(true, element.Type + ":" + strTransferDataMsg);
            }
        }