Esempio n. 1
0
        public override global::System.Data.DataSet Clone()
        {
            BOMs cln = ((BOMs)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Esempio n. 2
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            BOMs ds = new BOMs();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Esempio n. 3
0
 public static BomHeader ToPowerGateObject(this BOMs bom)
 {
     return(new BomHeader
     {
         Number = bom.No,
         Description = bom.Description,
         State = bom.Status.ToString(),
         UnitOfMeasure = bom.Unit_of_Measure_Code,
         ModifiedDate = bom.Last_Date_Modified,
         Link = GetBomLink(bom.Key),
         BomRows = bom.ProdBOMLine.Select(line => line.ToPowerGateObject(bom.No)).ToList()
     });
 }
Esempio n. 4
0
        public static BOMs ToErpObject(this BomHeader bomHeader, BOMs bom, IEnumerable <ItemCard> items)
        {
            bom.No                   = bomHeader.Number;
            bom.Description          = bomHeader.Description;
            bom.Unit_of_Measure_Code = bomHeader.UnitOfMeasure;
            bom.Last_Date_Modified   = bomHeader.ModifiedDate;

            var lines = new List <Production_BOM_Lines>();

            foreach (var bomRow in bomHeader.BomRows)
            {
                var item = items.First(i => i.No.Equals(bomRow.ChildNumber));
                var line = bom.ProdBOMLine?.FirstOrDefault(p => p.No.Equals(bomRow.ChildNumber) && Convert.ToInt32(p.Position).Equals(bomRow.Position));
                lines.Add(line == null ? bomRow.ToErpObject(new Production_BOM_Lines(), item) : bomRow.ToErpObject(line, item));
            }
            bom.ProdBOMLine = lines.ToArray();

            return(bom);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Parser.Default.ParseArguments <Options>(args)
            .WithParsed(o =>
            {
                if (!File.Exists(o.InputPath))
                {
                    Console.WriteLine("No such file");
                    return;
                }

                byte[] buf;
                using (MemoryStream data = new MemoryStream())
                {
                    using (Stream file = File.OpenRead(o.InputPath))
                    {
                        file.CopyTo(data);
                        buf = data.ToArray();

                        if (o.Range != null)
                        {
                            string rangeStr = o.Range;
                            Regex regex     = new Regex(@"^(\d+)-(\d+)");
                            if (!regex.IsMatch(rangeStr))
                            {
                                Console.WriteLine("Invalid range text format. Check the \"help\" text.");
                                return;
                            }
                            Match match = regex.Match(rangeStr);
                            var groups  = match.Groups;

                            if (groups.Count != 3)
                            {
                                throw new InvalidOperationException($"Regex math count is not 3. but {groups.Count}");
                            }

                            int start = Convert.ToInt32(groups[1].Value);
                            int end   = Convert.ToInt32(groups[2].Value);

                            if (end < start)
                            {
                                Console.WriteLine("The end range value must be bigger than the start range value");
                                return;
                            }

                            buf = buf.ToList().GetRange(start, end - start + 1).ToArray();
                        }
                    }
                }

                if (o.Summary)
                {
                    int pad    = 10;
                    int length = buf.Length;
                    BOMs bom   = BOMDetector.DetectBOM(buf);
                    Console.WriteLine($"{nameof(length).PadRight(pad)} : {length}");
                    Console.WriteLine($"{nameof(bom).PadRight(pad)} : {bom}");
                }

                int baseBit = int.MinValue;
                Func <string, string> converter = null;
                if (o.Binary)
                {
                    baseBit   = 2;
                    converter = (s) => (s.PadLeft(8, '0'));
                }
                else if (o.Decimal)
                {
                    baseBit   = 10;
                    converter = (s) => (s.PadLeft(3, '0'));
                }
                else if (o.Hexadecimal)
                {
                    baseBit   = 16;
                    converter = (s) => ("0x" + s.PadLeft(2, '0'));
                }
                else if (o.Ascii)
                {
                    string contents = Encoding.ASCII.GetString(buf);
                    Console.WriteLine(contents);
                    return;
                }
                else if (o.UTF8)
                {
                    string contents = Encoding.UTF8.GetString(buf);
                    Console.WriteLine(contents);
                    return;
                }
                else if (o.INT)
                {
                    if (buf.Length % 4 != 0)
                    {
                        Console.WriteLine(" if you want to use integer data representation, the length of bytes must be multiples of 4.");
                        return;
                    }

                    int[] vals = null;
                    if (o.endian == "big")
                    {
                        vals = ByteToNumber.ToInt(buf, Endian.Big);
                    }
                    else if (o.endian == "little")
                    {
                        vals = ByteToNumber.ToInt(buf, Endian.Little);
                    }
                    else
                    {
                        Console.WriteLine("endian option must be \"big\" or \"little\"");
                        return;
                    }

                    foreach (var val in vals)
                    {
                        Console.Write(val);
                        Console.Write(" ");
                    }
                    Console.WriteLine();

                    return;
                }
                else if (o.DOUBLE)
                {
                    if (buf.Length % 8 != 0)
                    {
                        Console.WriteLine(" if you want to use integer data representation, the length of bytes must be multiples of 8.");
                        return;
                    }

                    double[] vals = null;
                    if (o.endian == "big")
                    {
                        vals = ByteToNumber.ToDouble(buf, Endian.Big);
                    }
                    else if (o.endian == "little")
                    {
                        vals = ByteToNumber.ToDouble(buf, Endian.Little);
                    }
                    else
                    {
                        Console.WriteLine("endian option must be \"big\" or \"little\"");
                        return;
                    }

                    foreach (var val in vals)
                    {
                        Console.Write(val);
                        Console.Write(" ");
                    }
                    Console.WriteLine();
                    return;
                }
                else
                {
                    baseBit   = 16;
                    converter = (s) => ("0x" + s.PadLeft(2, '0'));
                }

                foreach (var b in buf)
                {
                    var val = converter(Convert.ToString(b, baseBit));
                    Console.Write(val + " ");
                }
                Console.WriteLine();
            });
        }
Esempio n. 6
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                BOMs ds = new BOMs();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "BOMsDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }
Esempio n. 7
0
        public void UpdateStock(Session session, int itemID, int?inventoryID, float quantity, bool updateBOM, int locationID, string lot = "", int?LPNNumber = null, DateTime?ExpirationDate = null, bool IsNewInventory = true)
        {
            double scrapfactor = 0;

            //To do update the stock for the item and bom's associated with it
            if (updateBOM == true)
            {
                if (inventoryID.HasValue)
                {
                    //Dim inventoryBOMs As InventoryBOMsBLL = New InventoryBOMsBLL
                    //Dim inventoryItemBOM As SPG.InventoryBOMsDataTable = inventoryBOMs.GetInventoryBOMsBYInventoryID(inventoryID.Value)
                    XPCollection <InventoryBOMs> inventoryItemBOM = InventoryBOMsBLL.GetInventoryBOMsByInventoryID(session, inventoryID.Value);
                    //If inventoryItemBOM.Rows.Count <> 0 Then
                    if (inventoryItemBOM.Count != 0)
                    {
                        //Dim itemsBOM As SPG.InventoryBOMsRow
                        InventoryBOMs itemsBOM = null;
                        for (int i = 0; i < inventoryItemBOM.Count; i++)
                        {
                            //itemsBOM = CType(inventoryItemBOM.Rows(i), SPG.InventoryBOMsRow)
                            itemsBOM = inventoryItemBOM[i];
                            if (itemsBOM.IsDeleted == false)
                            {
                                //updates the raw material
                                if (itemsBOM.ScrapFactor > 0)
                                {
                                    scrapfactor = itemsBOM.InventoryBOMQuantity * itemsBOM.ScrapFactor;
                                }
                                else
                                {
                                    scrapfactor = 0;
                                }
                                UpdateStock(session, itemsBOM.InventoryBOMRawMatID.ItemID, (Convert.ToSingle(quantity * (itemsBOM.InventoryBOMQuantity + scrapfactor)) * -1), false, locationID);
                            }
                        }
                        updateBOM = false;
                    }
                }
            }

            if (updateBOM == true)
            {
                //The item has a bom attached to it
                BOMBLL boms = new BOMBLL();
                //Dim itemsBOMs As SPG.BOMDataTable = boms.GetBOMBYFGItemID(itemID)
                XPCollection <BOMs> itemsBOMs = BOMBLL.GetBOMByFGItemID(session, itemID);

                //If itemsBOMs.Rows.Count <> 0 Then
                if (itemsBOMs.Count != 0)
                {
                    //Dim itemsBOM As SPG.BOMRow
                    BOMs itemsBOM = null;
                    //For i As Integer = 0 To itemsBOMs.Rows.Count - 1
                    for (int i = 0; i < itemsBOMs.Count; i++)
                    {
                        //itemsBOM = CType(itemsBOMs.Rows(i), SPG.BOMRow)
                        itemsBOM = itemsBOMs[i];
                        //updates the raw material
                        if (itemsBOM.BOMRawMatID.ItemID != itemID)
                        {
                            if (itemsBOM.ScrapFactor > 0)
                            {
                                scrapfactor = itemsBOM.BOMQuantity * (itemsBOM.ScrapFactor / 100);
                            }
                            else
                            {
                                scrapfactor = 0;
                            }
                            UpdateStock(session, itemsBOM.BOMRawMatID.ItemID, (Convert.ToSingle(quantity * (itemsBOM.BOMQuantity + scrapfactor)) * -1), false, locationID);
                        }
                    }
                }
            }

            LocationInventoryBLL.UpdateStock(session, itemID, locationID, quantity, lot, LPNNumber, ExpirationDate, IsNewInventory);

            //Dim item As SPG.ItemsRow = CType(GetItemBYId(itemID).Rows(0), SPG.ItemsRow)
            //item.s ngQuantityOnHand += quantity
            //Adapter.Update(item)
        }