public void FlatMergeToolsTest()
        {
            var sbom1 = new Bom
            {
                Metadata = new Metadata
                {
                    Tools = new List <Tool>
                    {
                        new Tool
                        {
                            Name    = "Tool1",
                            Version = "1"
                        }
                    }
                }
            };
            var sbom2 = new Bom
            {
                Metadata = new Metadata
                {
                    Tools = new List <Tool>
                    {
                        new Tool
                        {
                            Name    = "Tool2",
                            Version = "1"
                        }
                    }
                }
            };

            var result = CycloneDXUtils.FlatMerge(sbom1, sbom2);

            Snapshot.Match(result);
        }
Beispiel #2
0
        public static List <string> GetSpdxCreators(this Bom bom)
        {
            var creators = new List <string>();

            if (bom.Metadata?.Tools != null)
            {
                foreach (var tool in bom.Metadata.Tools)
                {
                    creators.Add($"Tool: {tool.Name}-{tool.Version}");
                }
            }

            if (bom.Metadata?.Authors != null)
            {
                var orgs = bom.Metadata.Properties?.GetSpdxElements(PropertyTaxonomy.CREATION_INFO_LICENSE_CREATORS_ORGANIZATIONS) ?? new List <string>();
                foreach (var author in bom.Metadata.Authors)
                {
                    if (orgs.Contains(author.Name))
                    {
                        creators.Add($"Organization: {author.Name} ({author.Email})");
                    }
                    else
                    {
                        creators.Add($"Person: {author.Name} ({author.Email})");
                    }
                }
            }

            return(creators.Count == 0 ? null : creators);
        }
        public void FlatMergeComponentsTest()
        {
            var sbom1 = new Bom
            {
                Components = new List <Component>
                {
                    new Component
                    {
                        Name    = "Component1",
                        Version = "1"
                    }
                }
            };
            var sbom2 = new Bom
            {
                Components = new List <Component>
                {
                    new Component
                    {
                        Name    = "Component2",
                        Version = "1"
                    }
                }
            };

            var result = CycloneDXUtils.FlatMerge(sbom1, sbom2);

            Snapshot.Match(result);
        }
Beispiel #4
0
        /// <summary>
        /// Serializes a CycloneDX BOM returning the output as a string.
        /// </summary>
        /// <param name="bom"></param>
        /// <returns></returns>
        public static string Serialize(Bom bom)
        {
            Contract.Requires(bom != null);
            var jsonBom = JsonSerializer.Serialize(BomUtils.GetBomForSerialization(bom), _options);

            return(jsonBom);
        }
Beispiel #5
0
    // Start is called before the first frame update
    void Start()
    {
        bom = GameObject.Find("Bom").GetComponent <Bom>();

        rb = GetComponent <Rigidbody>();
        rb.AddForce(transform.forward * 2000, ForceMode.Force);
    }
Beispiel #6
0
        public static void AddSpdxFiles(this Bom bom, List <File> files)
        {
            if (files != null && files.Count > 0)
            {
                if (bom.Components == null)
                {
                    bom.Components = new List <Component>();
                }
                foreach (var file in files)
                {
                    var component = new Component
                    {
                        Type       = Component.Classification.File,
                        Name       = file.FileName,
                        Copyright  = file.CopyrightText,
                        Properties = new List <Property>(),
                    };

                    component.Properties.AddSpdxElement(PropertyTaxonomy.SPDXID, file.SPDXID);
                    component.Properties.AddSpdxElement(PropertyTaxonomy.COMMENT, file.Comment);
                    component.Properties.AddSpdxElements(PropertyTaxonomy.FILE_TYPE, file.FileTypes);
                    component.Properties.AddSpdxElements <Annotation>(PropertyTaxonomy.ANNOTATION, file.Annotations);
                    component.Properties.AddSpdxElement(PropertyTaxonomy.LICENSE_COMMENTS, file.LicenseComments);
                    component.Properties.AddSpdxElement(PropertyTaxonomy.LICENSE_CONCLUDED, file.LicenseConcluded);
                    component.Properties.AddSpdxElements(PropertyTaxonomy.FILE_CONTRIBUTOR, file.FileContributors);
                    component.Properties.AddSpdxElement(PropertyTaxonomy.FILE_NOTICE_TEXT, file.NoticeText);

                    component.AddSpdxAttributionTexts(file.AttributionTexts);
                    component.AddSpdxChecksums(file.Checksums);

                    bom.Components.Add(component);
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("BomId,Quantity,PartId,ProductId")] Bom bom)
        {
            if (id != bom.BomId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    _context.Update(bom);
                    await _context.SaveChangesAsync();
                } catch (DbUpdateConcurrencyException) {
                    if (!BomExists(bom.BomId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PartId"]    = new SelectList(_context.Part, "PartId", "Name", bom.PartId);
            ViewData["ProductId"] = new SelectList(_context.Product, "ProductId", "Name", bom.ProductId);
            return(View(bom));
        }
        public static Bom Copy(this Bom bom)
        {
            var protoBom = Protobuf.Serializer.SerializeForDeepCopy(bom);
            var bomCopy  = Protobuf.Serializer.Deserialize(protoBom);

            return(bomCopy);
        }
        public static void EnumerateAllServices(Bom bom, Action <Service> callback)
        {
            var q = new Queue <Service>();

            if (bom.Services != null)
            {
                foreach (var service in bom.Services)
                {
                    q.Enqueue(service);
                }
            }

            while (q.Count > 0)
            {
                var currentService = q.Dequeue();

                callback(currentService);

                if (currentService.Services != null)
                {
                    foreach (var s in currentService.Services)
                    {
                        q.Enqueue(s);
                    }
                }
            }
        }
        /// <summary>
        /// 检测设计与装配基数是否吻合
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckBasicCount_Click(object sender, EventArgs e)
        {
            if (treeView1.SelectedNode == null)
            {
                MessageDialog.ShowPromptMessage("请选择要检测的树节点后再进行此操作!");
                return;
            }

            try
            {
                Bom bom            = treeView1.SelectedNode.Tag as Bom;
                int assemblyAmount = 0;

                if (!m_bomMappingServer.IsCoincideBasicCount(bom.Counts, txtProductName.Text, bom.ParentCode, bom.PartCode, out assemblyAmount))
                {
                    if (assemblyAmount == 0)
                    {
                        MessageDialog.ShowPromptMessage("此零件没有映射信息,无法匹配!");
                    }
                    else
                    {
                        MessageDialog.ShowErrorMessage(string.Format("此零件设计基数为:{0},映射表中此零件装配数之和为:{1},不相匹配,请修改正确否则电子档案数据将不正确!", bom.Counts, assemblyAmount));
                    }
                }
                else
                {
                    MessageDialog.ShowPromptMessage("匹配成功,完全正确!");
                }
            }
            catch (Exception err)
            {
                MessageDialog.ShowErrorMessage(err.Message);
            }
        }
        private void dataGridView1_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0 || e.ColumnIndex < 0 || treeView1.Nodes.Count == 0)
            {
                return;
            }

            DataGridViewRow row = dataGridView1.Rows[e.RowIndex];

            TreeNode[] findNodes = treeView1.Nodes.Find(row.Cells["零件编码"].Value.ToString(), true);

            foreach (TreeNode node in findNodes)
            {
                Bom bom = node.Tag as Bom;

                if (bom.ParentCode == row.Cells["父总成编码"].Value.ToString())
                {
                    m_selecteTreeNodeFromDataGridViewRow = true;
                    treeView1.SelectedNode = node;
                    break;
                }
            }

            ChangeBomMappingPanelPara();
        }
Beispiel #12
0
        public static Bom Deserialize(string xmlBom)
        {
            Contract.Requires(xmlBom != null);

            var bom = new Bom();
            var doc = new XmlDocument();

            doc.LoadXml(xmlBom);

            var nsmgr = new XmlNamespaceManager(doc.NameTable);

            nsmgr.AddNamespace("cdx", doc.DocumentElement.Attributes["xmlns"].InnerText);

            bom.SpecVersion = doc.DocumentElement.Attributes["xmlns"]
                              .InnerText
                              .Replace("http://cyclonedx.org/schema/bom/", "");
            bom.Version      = int.Parse(doc.DocumentElement.Attributes["version"]?.InnerText);
            bom.SerialNumber = doc.DocumentElement.Attributes["serialNumber"]?.InnerText;

            var xmlComponentNodes = doc.SelectNodes("/cdx:bom/cdx:components/cdx:component", nsmgr);

            for (var i = 0; i < xmlComponentNodes.Count; i++)
            {
                bom.Components.Add(GetComponent(xmlComponentNodes[i], nsmgr));
            }

            return(bom);
        }
Beispiel #13
0
        public static Bom ToCycloneDX(this SpdxDocument doc)
        {
            var bom = new Bom()
            {
                Metadata = new Metadata
                {
                    Properties = new List <Property>(),
                }
            };

            // document
            bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.SPDXID, doc.SPDXID);
            bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.DOCUMENT_SPDX_VERSION, doc.SpdxVersion);
            bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.COMMENT, doc.Comment);
            bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.DOCUMENT_NAME, doc.Name);
            bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.DOCUMENT_NAMESPACE, doc.DocumentNamespace);

            // creation info
            if (doc.CreationInfo != null)
            {
                bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.CREATION_INFO_COMMENT, doc.CreationInfo.Comment);
                bom.Metadata.Timestamp = doc.CreationInfo.Created;
                bom.AddSpdxCreators(doc.CreationInfo.Creators);
                bom.Metadata.Properties.AddSpdxElement(PropertyTaxonomy.CREATION_INFO_LICENSE_LIST_VERSION, doc.CreationInfo.LicenseListVersion);
            }

            bom.Metadata.Properties.AddSpdxElements <ExternalDocumentRef>(PropertyTaxonomy.DOCUMENT_EXTERNAL_DOCUMENT_REF, doc.ExternalDocumentRefs);
            bom.Metadata.Properties.AddSpdxElements <Annotation>(PropertyTaxonomy.ANNOTATION, doc.Annotations);
            bom.Metadata.Properties.AddSpdxElements(PropertyTaxonomy.DOCUMENT_DESCRIBES, doc.DocumentDescribes);

            bom.AddSpdxPackages(doc);
            bom.AddSpdxFiles(doc.Files);

            return(bom);
        }
Beispiel #14
0
    protected void ODS_Bom_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        string uom    = ((Controls_TextBox)(this.FV_Bom.FindControl("tbUom"))).Text.Trim();
        string region = ((Controls_TextBox)(this.FV_Bom.FindControl("tbRegion"))).Text.Trim();

        bom  = (Bom)e.InputParameters[0];
        item = TheItemMgr.LoadItem(bom.Code);
        if (item != null)
        {
            //default description and uom
            if (bom.Description.Trim() == "")
            {
                bom.Description = item.Description;
            }
            if (uom.Trim() == "")
            {
                bom.Uom = item.Uom;
            }
            else
            {
                bom.Uom = TheUomMgr.LoadUom(uom);
            }
        }
        if (region == "")
        {
            bom.Region = null;
        }
        else
        {
            bom.Region = TheRegionMgr.LoadRegion(region);
        }
    }
Beispiel #15
0
        //Get BomId
        public IEnumerable <Bom> BomDatas(string packageName, string deviceName, string testerType, string testFlow, string pcMain)
        {
            List <Bom> bomId = new List <Bom>();
            var        conn  = new SqlConnection(Properties.Settings.Default.SPConnecting);

            using (var cmd = conn.CreateCommand())
            {
                cmd.CommandText = "EXEC [StoredProcedureDB].[dbo].[sp_get_setupchecksheet_getbom] " +
                                  "@PackageName = '" + packageName + "', " +
                                  "@CustomerDeviceName = '" + deviceName + "', " +
                                  "@TesterTypeName = '" + testerType + "', " +
                                  "@TestFlowName = '" + testFlow + "', " +
                                  "@PCMain = '" + pcMain + "'";

                conn.Open();
                using (var reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Bom methodBomData = new Bom();

                        if (!(reader["ID"] is DBNull))
                        {
                            methodBomData.BomId = int.Parse(reader["ID"].ToString());
                        }

                        bomId.Add(methodBomData);
                    }
                    conn.Close();
                }
                return(bomId);
            }
        }
    protected void ODS_Bom_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
    {
        string uom = ((Controls_TextBox)(this.FV_Bom.FindControl("tbUom"))).Text.Trim();
        string region = ((Controls_TextBox)(this.FV_Bom.FindControl("tbRegion"))).Text.Trim();

        bom = (Bom)e.InputParameters[0];
        item = TheItemMgr.LoadItem(bom.Code);
        if (item != null)
        {
            //default description and uom
            if (bom.Description.Trim() == "")
            {
                bom.Description = item.Description;
            }
            if (uom.Trim() == "")
            {
                bom.Uom = item.Uom;
            }
            else
            {
                bom.Uom = TheUomMgr.LoadUom(uom);
            }
        }
        if (region == "")
        {
            bom.Region = null;
        }
        else
        {
            bom.Region = TheRegionMgr.LoadRegion(region);
        }
    }
Beispiel #17
0
        public void MergeToolsTest()
        {
            var sbom1 = new Bom
            {
                Metadata = new Metadata
                {
                    Tools = new List <Tool>
                    {
                        new Tool
                        {
                            Name    = "Tool1",
                            Version = "1"
                        }
                    }
                }
            };
            var sbom2 = new Bom
            {
                Metadata = new Metadata
                {
                    Tools = new List <Tool>
                    {
                        new Tool
                        {
                            Name    = "Tool2",
                            Version = "1"
                        }
                    }
                }
            };

            var result = CycloneDXUtils.Merge(sbom1, sbom2);

            Assert.Equal(2, result.Metadata.Tools.Count);
        }
Beispiel #18
0
        public void MergeComponentsTest()
        {
            var sbom1 = new Bom
            {
                Components = new List <Component>
                {
                    new Component
                    {
                        Name    = "Component1",
                        Version = "1"
                    }
                }
            };
            var sbom2 = new Bom
            {
                Components = new List <Component>
                {
                    new Component
                    {
                        Name    = "Component2",
                        Version = "1"
                    }
                }
            };

            var result = CycloneDXUtils.Merge(sbom1, sbom2);

            Assert.Equal(2, result.Components.Count);
        }
        public void MetadataPropertiesTest()
        {
            var bom = new Bom
            {
                Metadata = new Metadata
                {
                    Properties = new List <Property>
                    {
                        new Property
                        {
                            Name  = "cdx:test",
                            Value = "test",
                        },
                        new Property
                        {
                            Name  = "internal:test",
                            Value = "test",
                        },
                    }
                }
            };

            CycloneDXUtils.RemoveInternalProperties(bom);

            Assert.Collection <Property>(
                bom.Metadata.Properties,
                item =>
            {
                Assert.Equal("cdx:test", item.Name);
                Assert.Equal("test", item.Value);
            }
                );
        }
        public static Bom Merge(Bom sbom1, Bom sbom2)
        {
            var result = new Bom();

            var toolsMerger = new ListMergeHelper <Tool>();
            var tools       = toolsMerger.Merge(sbom1.Metadata?.Tools, sbom2.Metadata?.Tools);

            if (tools != null)
            {
                result.Metadata = new Metadata
                {
                    Tools = tools
                };
            }

            var componentsMerger = new ListMergeHelper <Component>();

            result.Components = componentsMerger.Merge(sbom1.Components, sbom2.Components);

            var servicesMerger = new ListMergeHelper <Service>();

            result.Services = servicesMerger.Merge(sbom1.Services, sbom2.Services);

            var extRefsMerger = new ListMergeHelper <ExternalReference>();

            result.ExternalReferences = extRefsMerger.Merge(sbom1.ExternalReferences, sbom2.ExternalReferences);

            var dependenciesMerger = new ListMergeHelper <Dependency>();

            result.Dependencies = dependenciesMerger.Merge(sbom1.Dependencies, sbom2.Dependencies);

            return(result);
        }
Beispiel #21
0
        // Create Node form Entity
        public static Node GetNodeFromEntity(Configuration config, Bom bom = null, bool isPart = true)
        {
            if (config == null)
            {
                return(null);
            }

            var node = new Node()
            {
                Id            = config.Id.GetValueOrDefault(),
                IsRoot        = config.IsRoot.GetValueOrDefault(),
                IsActive      = config.IsActive.GetValueOrDefault(),
                Revision      = config.Revision,
                BomPartNumber = config.BomPartNumber,
                PartNumber    = config.PartNo,
                Preview       = config.Preview,
                Description   = config.Description,
                FileName      = Path.GetFileName(config.FilePath),
                AbsolutePath  = config.FilePath,
                IsPart        = isPart ? Visibility.Visible : Visibility.Hidden,
                IsFile        = isPart ? Visibility.Hidden : Visibility.Visible,
            };

            AddBomInfo(node, bom);

            return(node);
        }
        /// <summary>
        /// Serializes a CycloneDX BOM writing the output to a stream.
        /// </summary>
        /// <param name="bom"></param>
        /// <param name="outputStream"></param>
        public static void Serialize(Bom bom, Stream outputStream)
        {
            Contract.Requires(outputStream != null);
            Contract.Requires(bom != null);

            ProtoBuf.Serializer.Serialize(outputStream, BomUtils.GetBomForSerialization(bom));
        }
        internal static byte[] SerializeForDeepCopy(Bom bom)
        {
            var ms = new MemoryStream();

            ProtoBuf.Serializer.Serialize(ms, bom);
            return(ms.ToArray());
        }
        /// <summary>
        /// Serializes a CycloneDX BOM returning the output as a byte array.
        /// </summary>
        /// <param name="bom"></param>
        /// <returns></returns>
        public static byte[] Serialize(Bom bom)
        {
            var ms = new MemoryStream();

            Serialize(BomUtils.GetBomForSerialization(bom), ms);
            return(ms.ToArray());
        }
        private void radButtonElement1_Click(object sender, EventArgs e)
        {
            try
            {
                if (screen.Equals(1))
                {
                    if (radGridView1.Rows.Count <= 0)
                    {
                        return;
                    }

                    CodeNo_tt.Text = Convert.ToString(radGridView1.CurrentRow.Cells["PartNo"].Value);
                    BomNo_tt.Text  = Convert.ToString(radGridView1.CurrentRow.Cells["BomNo"].Value);
                    this.Close();
                }
                else
                {
                    this.Cursor = Cursors.WaitCursor;
                    Bom sc = new Bom();
                    this.Cursor = Cursors.Default;
                    sc.ShowDialog();
                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    ClassLib.Memory.SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
                    ClassLib.Memory.Heap();
                }
            }catch (Exception ex) { MessageBox.Show(ex.Message); }
        }
Beispiel #26
0
        public static void AddMetadataTool(Bom bom)
        {
            string toolname = "CycloneDX module for .NET";

            if (bom.Metadata == null)
            {
                bom.Metadata = new Metadata();
            }
            if (bom.Metadata.Tools == null)
            {
                bom.Metadata.Tools = new List <Tool>();
            }
            var index = bom.Metadata.Tools.FindIndex(p => p.Name == toolname);

            if (index == -1)
            {
                bom.Metadata.Tools.Add(new Tool
                {
                    Name    = toolname,
                    Vendor  = "CycloneDX",
                    Version = Assembly.GetExecutingAssembly().GetName().Version.ToString()
                }
                                       );
            }
            else
            {
                bom.Metadata.Tools[index].Version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
        }
        /// <summary>
        /// 递归生成Bom表的树型结构
        /// </summary>
        /// <param name="parentNode">父总成编码</param>
        /// <param name="dicBomTable">Bom字典</param>
        /// <param name="edition">版本号</param>
        void RecursionBuildTreeView(TreeNode parentNode, Dictionary <string, List <Bom> > dicBomTable, string edition)
        {
            for (int i = 0; i < dicBomTable[edition].Count; i++)
            {
                Bom bom = dicBomTable[edition][i];

                if (parentNode.Name == bom.ParentCode)
                {
                    TreeNode node = new TreeNode();

                    node.Name        = bom.PartCode;
                    node.Text        = bom.PartName;
                    node.ToolTipText = bom.Spec;
                    node.Tag         = bom;
                    parentNode.Nodes.Add(node);
                    dicBomTable[edition].RemoveAt(i);

                    i = -1;

                    if (bom.AssemblyFlag)
                    {
                        RecursionBuildTreeView(node, dicBomTable, edition);
                    }
                }
            }
        }
Beispiel #28
0
        public IList <BomDetail> GetBomView_Cost(string itemCode, DateTime effDate)
        {
            Item              item            = itemMgr.LoadItem(itemCode);
            string            bomCode         = item.Bom != null ? item.Bom.Code : item.Code;
            IList <BomDetail> bomDetailList   = this.GetFlatBomDetail(bomCode, effDate);
            IList <BomDetail> bomViewList     = new List <BomDetail>();
            IList <BomDetail> costBomViewList = new List <BomDetail>();

            bomViewList = this.GetAllBomDetailTree(bomDetailList, effDate);
            bomViewList = this.GetNoOverloadBomDetail(bomViewList);
            if (bomViewList != null && bomViewList.Count > 0)
            {
                bomViewList = this.GetCostBomDetail(bomViewList);
                Bom bom = bomMgr.LoadBom(bomCode);
                foreach (BomDetail bomDetail in bomViewList)
                {
                    BomDetail costBomDetail = new BomDetail();
                    CloneHelper.CopyProperty(bomDetail, costBomDetail, BomCompDetail);
                    costBomDetail.Bom = bom;

                    costBomViewList.Add(costBomDetail);
                }
            }

            return(this.GetNoOverloadBomDetail(costBomViewList));
        }
Beispiel #29
0
        public Serialization()
        {
            _xmlBom      = File.ReadAllText(Path.Join("Resources", "valid-bom-1.4.xml"));
            _jsonBom     = Json.Serializer.Serialize(_bom);
            _protobufBom = Protobuf.Serializer.Serialize(_bom);

            _bom = Xml.Serializer.Deserialize(_xmlBom);
        }
Beispiel #30
0
 /// <summary>
 /// 获取EasyUiDataGrid数据集
 /// </summary>
 /// <param name="entity"></param>
 /// <returns></returns>
 public EasyUiDataGrid <Bom> GetEasyUiDataList(Bom entity, int pageIndex, int pageSize, string order)
 {
     return(new EasyUiDataGrid <Bom>()
     {
         Total = GetRecordCount(entity),
         Rows = GetList(entity, pageIndex, pageSize, order)
     });
 }
        private void SaveBom()
        {
            try
            {
                if (dtBomItem.Rows.Count == 0)
                {
                    throw new Exception("กรุณาเลือกสินค้าย่อย");
                }

                var bomItems = new List <BomItem>();
                int seq      = 0;
                foreach (DataRow row in dtBomItem.Rows)
                {
                    seq++;
                    bomItems.Add(new BomItem
                    {
                        BomCode = String.IsNullOrEmpty(txtBomCode.Text) == true ? 0 : Convert.ToInt32(txtBomCode.Text),
                        Product = new Product
                        {
                            ProductCode = row[ConstColumns.PRODUCT_CODE].ToString(),
                            ProductName = row[ConstColumns.PRODUCT_NAME].ToString(),
                        },
                        MutiplyQty = 1,
                        MutiplyWgh = 1,
                        //MutiplyQty = row[ConstColumns.ISSUE_UNIT_METHOD].ToString() == "Q" ? Convert.ToInt16(row[ConstColumns.QTY_WGH]) : 0,
                        //MutiplyWgh = row[ConstColumns.ISSUE_UNIT_METHOD].ToString() == "W" ? Convert.ToDecimal(row[ConstColumns.QTY_WGH]) : 0,
                    });
                }

                var bom = new Bom
                {
                    BomCode = string.IsNullOrEmpty(txtBomCode.Text) == true ? 0 : Convert.ToInt32(txtBomCode.Text),
                    Product = new Product
                    {
                        ProductCode = this.productCode,
                        ProductName = txtProductName.Text,
                    },
                    Active     = chkActive.Checked,
                    CreateBy   = "system",
                    ModifiedBy = "system",
                    BomItems   = bomItems
                };

                if (string.IsNullOrEmpty(txtBomCode.Text))
                {
                    BomController.Insert(bom);
                }
                else
                {
                    BomController.Update(bom);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        private object Deserialize(DssImportHistory dssImportHistory, bool isUpdate)
        {
            Bom bom = new Bom();
            bom.Code = dssImportHistory[1]; //Bom代码
            if (isUpdate)
            {
                bom.Description = dssImportHistory[2]; //说明
                bom.Uom = this.uomMgrE.CheckAndLoadUom(dssImportHistory[3]);//单位
            }

            return bom;
        }
    private void UpdateView()
    {
        bom = TheBomMgr.LoadBom(this.code);
        Controls_TextBox tbUom = (Controls_TextBox)(this.FV_Bom.FindControl("tbUom"));
        TextBox tbRegion = (TextBox)(this.FV_Bom.FindControl("tbRegion"));

        if (bom.Uom != null)
        {
            tbUom.Text = bom.Uom.Code;
        }
        if (bom.Region != null)
        {
            tbRegion.Text = bom.Region.Code;
        }
    }
    public void ShowTreeView(object sender)
    {
        string itemCode = ((object[])sender)[0].ToString();
        string date = ((object[])sender)[1].ToString();
        string viewType = ((object[])sender)[2].ToString();
        DateTime effDate = DateTime.Now;

        item = TheItemMgr.LoadItem(itemCode);
        if (item == null || item.Bom == null)
        {
            bom = TheBomMgr.LoadBom(itemCode);
        }
        else
        {
            bom = item.Bom;
        }
        if (bom == null)
        {
            ShowErrorMessage("MasterData.BomDetail.ErrorMessage.BomNotExist");
            this.fld.Visible = false;
            return;
        }
        else
        {
            this.fld.Visible = true;
        }
        try
        {
            effDate = Convert.ToDateTime(date);
        }
        catch (Exception)
        {
            ShowWarningMessage("MasterData.BomView.WarningMessage.DateInvalid");
            return;
        }

        bomDetailList = TheBomDetailMgr.GetTreeBomDetail(bom.Code, effDate);

        if (bomDetailList != null && bomDetailList.Count > 0)
        {
            MyOrgNode RootNode = new MyOrgNode();
            GenChildOrgNode(RootNode);
            OrgChartBomTreeView.Node = RootNode;
        }
    }
 public virtual void UpdateBom(Bom entity)
 {
     Update(entity);
 }
 private Bom LoadBom(string code)
 {
     Bom bom = this.bomMgr.LoadBom(code);
     if (bom == null)
     {
         bom = new Bom();
         bom.Code = code;
         Item item = this.itemMgr.LoadItem(code);
         if (item != null)
         {
             bom.Description = item.Description;
             bom.Uom = item.Uom;
             bom.IsActive = true;
         }
         this.bomMgr.CreateBom(bom);
     }
     return bom;
 }
 public virtual void DeleteBom(Bom entity)
 {
     entityDao.DeleteBom(entity);
 }
 public virtual void UpdateBom(Bom entity)
 {
     entityDao.UpdateBom(entity);
 }
 public virtual void CreateBom(Bom entity)
 {
     entityDao.CreateBom(entity);
 }
Beispiel #40
0
        private void ProcessBomDetailIn(MesScmsTableIndex mesScmsTableIndex)
        {
            IList<MesScmsBom> bomDetailList = mesScmsBomMgr.GetUpdateMesScmsBom();
            if (bomDetailList != null && bomDetailList.Count > 0)
            {
                foreach (MesScmsBom mesScmsBom in bomDetailList)
                {
                    try
                    {
                        Bom bom = bomMgr.LoadBom(mesScmsBom.Bom);
                        if (bom == null)
                        {
                            bom = new Bom();
                            bom.Code = mesScmsBom.Bom;
                            bom.IsActive = true;
                            bom.Uom = itemMgr.LoadItem(mesScmsBom.ItemCode).Uom;
                            bomMgr.CreateBom(bom);
                        }
                        BomDetail bomDetail = LoadBomDetail(mesScmsBom.Bom, mesScmsBom.ItemCode, Int32.Parse(mesScmsBom.Operation), DateTime.Now);
                        if (bomDetail == null && mesScmsBom.Qty > 0)
                        {
                            bomDetail = new BomDetail();
                            bomDetail.Bom = bom;
                            bomDetail.Item = itemMgr.LoadItem(mesScmsBom.ItemCode);
                            Item bomItem = itemMgr.LoadItem(mesScmsBom.Bom);
                            bomDetail.BackFlushMethod = bomDetail.Item.BackFlushMethod;
                            bomDetail.NeedPrint = true;
                            bomDetail.Operation = Convert.ToInt32(mesScmsBom.Operation);
                            bomDetail.RateQty = mesScmsBom.Qty;
                            bomDetail.StructureType = BusinessConstants.CODE_MASTER_BOM_DETAIL_TYPE_VALUE_N;
                            bomDetail.StartDate = DateTime.Now;
                            bomDetail.Uom = itemMgr.LoadItem(mesScmsBom.ItemCode).Uom;
                            if (mesScmsBom.Flag == MesDssConstants.MES_SCMS_FLAG_FTPC_DELETED)
                            {
                                bomDetail.EndDate = DateTime.Now.AddDays(-1);
                            }
                            bomDetailMgr.CreateBomDetail(bomDetail);
                        }
                        else
                        {
                            if (mesScmsBom.Qty == 0)
                            {
                                bomDetail.EndDate = DateTime.Now.AddDays(-1);
                            }
                            bomDetail.RateQty = mesScmsBom.Qty;
                            bomDetailMgr.UpdateBomDetail(bomDetail);
                        }
                        #region ���¹���͹�λ��Ӧ,���ڹ���͹�λΨһ��Ӧ

                        #region ��routing
                        DetachedCriteria criteria = DetachedCriteria.For(typeof(Flow));
                        criteria.Add(Expression.Eq("Code", mesScmsBom.ProductLine));

                        IList<Flow> flowList = criteriaMgr.FindAll<Flow>(criteria);
                        if (flowList == null || flowList.Count == 0)
                        {
                            log.Error(mesScmsBom.ProductLine + " not found");
                            continue;
                        }

                        if (flowList[0].Routing == null)
                        {
                            log.Error(mesScmsBom.ProductLine + " not found routing");
                            continue;
                        }
                        #endregion

                        #region ��routingdet
                        DetachedCriteria rcriteria = DetachedCriteria.For(typeof(RoutingDetail));
                        rcriteria.Add(Expression.Eq("Routing.Code", flowList[0].Routing.Code));
                        rcriteria.Add(Expression.Eq("Operation", Convert.ToInt32(mesScmsBom.Operation)));

                        IList<RoutingDetail> routingDetailList = criteriaMgr.FindAll<RoutingDetail>(rcriteria);
                        if (routingDetailList == null || routingDetailList.Count == 0)
                        {
                            log.Error(flowList[0].Routing.Code + " not found routing detail");
                            continue;
                        }
                        #endregion

                        RoutingDetail rd = routingDetailList[0];
                        rd.TagNo = mesScmsBom.TagNo;
                        routingDetailMgr.UpdateRoutingDetail(rd);
                        #endregion

                        mesScmsBomMgr.Complete(mesScmsBom);
                    }
                    catch (Exception e)
                    {
                        this.CleanSession();
                        log.Error(mesScmsBom.Bom + "," + mesScmsBom.ItemCode + "," + mesScmsBom.ProductLine + "," + mesScmsBom.TagNo + " complete exception", e);
                        continue;
                    }
                }
            }

            mesScmsTableIndexMgr.Complete(mesScmsTableIndex);
        }
Beispiel #41
0
 public void CreateBom(Bom bom)
 {
     BomMgr.CreateBom(bom);
 }
Beispiel #42
0
 public void DeleteBom(Bom bom)
 {
     BomMgr.DeleteBom(bom);
 }
Beispiel #43
0
 public void UpdateBom(Bom bom)
 {
     BomMgr.UpdateBom(bom);
 }
Beispiel #44
0
    protected void ODS_Bom_Updating(object sender, ObjectDataSourceMethodEventArgs e)
    {
        string uom = ((Controls_TextBox)(this.FV_Bom.FindControl("tbUom"))).Text.Trim();
        string region = ((TextBox)(this.FV_Bom.FindControl("tbRegion"))).Text.Trim();

        bom = (Bom)e.InputParameters[0];
        bom.Uom = TheUomMgr.LoadUom(uom);
        if (region == "")
        {
            bom.Region = null;
        }
        else
        {
            bom.Region = TheRegionMgr.LoadRegion(region);
        }
    }
 public virtual void CreateBom(Bom entity)
 {
     Create(entity);
 }
 public virtual void DeleteBom(Bom entity)
 {
     Delete(entity);
 }