Beispiel #1
0
        /// <summary>
        /// 获取物料对应关系
        /// </summary>
        /// <returns>0:partNumber;1:materialCode;2:出熱mes物料編碼</returns>
        public String[] getMaterialMapping(String materialOrPart)
        {
            // 0:partNumber;1:materialCode;2:出熱mes物料編碼
            String[]          materialMapping = new String[3];
            DirectoryResource material        = MDManager.GetMaterialDefinition(materialOrPart);

            // 物料编码
            if (material.Exists)
            {
                materialMapping[0] = this.ServiceDirManager.IMaterial.ReadMaterialValue(material, "partNumber").StringValue(CultureInfo.CurrentCulture);
                materialMapping[1] = material.DisplayName;
                materialMapping[2] = this.ServiceDirManager.IMaterial.ReadMaterialValue(material, "heatingOutCode").StringValue(CultureInfo.CurrentCulture);
            }
            else
            {
                // 零件号
                DirectoryResource code = MDManager.GetMaterialDefinitionIdWithPartNumber(materialOrPart);
                if (code != null)
                {
                    materialMapping[0] = materialOrPart;
                    materialMapping[1] = code.DisplayName;
                    materialMapping[2] = this.ServiceDirManager.IMaterial.ReadMaterialValue(code, "heatingOutCode").StringValue(CultureInfo.CurrentCulture);
                }
                else
                {
                    // 出热物料编码,目前不做考虑
                }
            }
            return(materialMapping);
        }
Beispiel #2
0
        /// <summary>
        /// 创建物料
        /// </summary>
        /// <param name="materialName">物料号</param>
        /// <param name="description">描述</param>
        public bool createMaterial(String materialName, string description)
        {
            bool result = false;

            try
            {
                MaterialDefinitionAttributes attr = new MaterialDefinitionAttributes()
                {
                    S95Id       = materialName,
                    Description = description
                };
                AspectChangeRequest request = new AspectChangeRequest();

                this.ServiceDirManager.IMaterial.CreateMaterialDefinition(attr, request);

                DirectoryResource material = MDManager.GetMaterialDefinition(materialName);
                if (material == null)
                {
                    return(false);
                }
                //根据setid去查找码表项
                List <string> itemList = MDManager.GetCodeItemsBySetIdFromDB("MA01");
                if (itemList != null && itemList.Count > 0)
                {
                    DirectoryResource dir_class = null;
                    foreach (var item in itemList)
                    {
                        dir_class = MDManager.GetMaterialClass(item);
                        if (dir_class != null)
                        {
                            this.ServiceDirManager.IMaterial.AddClass(material, dir_class);
                        }
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                throw;
            }
            return(result);
        }
Beispiel #3
0
 public Dictionary <String, String> GetAllProperty(String materialName)
 {
     try
     {
         DirectoryResource material = MDManager.GetMaterialDefinition(materialName);
         if (material == null)
         {
             return(null);
         }
         NameDataValueCollection     allValues = this.ServiceDirManager.IMaterial.ReadAllMaterialValues(material);
         Dictionary <String, String> res       = new Dictionary <String, String>();
         foreach (var iV in allValues)
         {
             res.Add(iV.Key, iV.Value.StringValue(CultureInfo.CurrentCulture));
         }
         return(res);
     }
     catch (Exception)
     {
         throw;
     }
 }
Beispiel #4
0
        /// <summary>
        /// 批量修改物料属性值
        /// </summary>
        /// <param name="materialName">物料号</param>
        /// <param name="propDict">物料属性字典集合</param>
        public bool batchWriteProperty(String materialName, IDictionary <string, string> propDict)
        {
            bool result = false;

            try
            {
                DirectoryResource material = MDManager.GetMaterialDefinition(materialName);
                if (material != null && propDict != null)
                {
                    IMaterial iMaterial = this.ServiceDirManager.IMaterial;
                    foreach (var item in propDict.Keys)
                    {
                        iMaterial.WriteMaterialValue(material, item, propDict[item]);
                    }
                    result = true;
                }
            }
            catch
            {
                throw;
            }
            return(result);
        }
Beispiel #5
0
        public void writeProperty(String materialName, String propNmae, String value)
        {
            DirectoryResource material = MDManager.GetMaterialDefinition(materialName);

            this.ServiceDirManager.IMaterial.WriteMaterialValue(material, propNmae, value);
        }