Ejemplo n.º 1
0
        static void DoSqlSample()
        {
            var sql = @"select ITEM_CODE
                from ITIS_PRJ.PRJ_PROJECT_ITEM pi
                left join ITIS_PRJ.PRJ_CONTRACT_ITEM ci on pi.CONTRACT_ITEM_ID = ci.CONTRACT_ITEM_ID"
                      //+ " where pi.PROJECT_ID = '481AE79FFF2747B983E8F1576C8C4FDD'";
                      + " where pi.PROJECT_ID = :projectId";

            using var conn = new OracleConnection(ConnectionString);
            using (var cmd = new OracleCommand(sql, conn))
            {
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new OracleParameter("projectId", "481AE79FFF2747B983E8F1576C8C4FDD"));
                conn.Open();

                var dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    var raw = dr["ITEM_CODE"].ToString();
                    System.Console.Write($"{raw}, ");
                    BoqItemCode itemCode;
                    try
                    {
                        itemCode = BoqItemCode.Parse(raw);
                        System.Console.WriteLine(itemCode.StringValue);
                    }
                    catch (ArgumentException ax)
                    {
                        System.Console.WriteLine($"Invalid item code: {ax.Message}");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static void DoMasterList()
        {
            var lines = File.ReadAllLines("ItemCodes.txt");

            foreach (var line in lines)
            {
                System.Console.Write($"{line}, ");
                BoqItemCode itemCode;
                try
                {
                    itemCode = BoqItemCode.Parse(line);
                    System.Console.WriteLine(itemCode.StringValue);
                }
                catch (ArgumentException ax)
                {
                    System.Console.WriteLine($"Invalid item code: {ax.Message}");
                }
            }
        }
Ejemplo n.º 3
0
        public static BoqItemCode Parse(string value)
        {
            var itemCode = new BoqItemCode();

            itemCode.StringValue = value;
            string first;

            if (value.Length == 4)
            {
                first = value.Substring(0, 4);
                itemCode._sections.Add(new BoqItemCodeFirstSection {
                    Content = first
                });
                return(itemCode);
            }

            first = value.Substring(0, 7);
            itemCode._sections.Add(new BoqItemCodeFirstSection {
                Content = first
            });

            var remaining = value.Substring(7, value.Length - 7).Trim();

            if (remaining.Length == 0)
            {
                return(itemCode);
            }

            var parts  = remaining.Split('(');
            var second = "(" + parts[1].Replace("(", "").Replace(")", "") + ")";

            itemCode._sections.Add(new BoqItemCodeSecondSection {
                Content = second
            });

            foreach (var part in parts[2..])