} //End method
        

        /// <summary> This method returns the Product object that matches the one passed into the function. </summary>
        /// <param name="Product"> A Container Product object. </param>
        /// <returns> The matched object if found, otherwise adds it to the DB and return the object. </returns>
        public void GetProduct(Cont.Product Product)
        {
            var info = Products.FirstOrDefault(x => x.Equals(Product));
            if (info == null)
            {
                Product.ID = Handler.Product.Add(Product);
                Products.Add(Product);
            }
            else
            {
                Product.ID = info.ID;
            }
        } //End method
Beispiel #2
0
        }//end method


        /// <summary> Reads the filtered rows from the data table and instantiates the respective container objects. </summary>
        /// <param name="filteredRows"> A datatable containing the rows we care about per the specified filter criteria. </param>
        private void ReadData(Row[] filteredRows, List<PlatformConfigurationParser.PlatformConfiguration> platformConfigurations)
        {
            Handlers.DatabaseObject dbo = new Handlers.DatabaseObject();

            foreach (var row in filteredRows)
            {
                /* Region */
                Cont.Region regionInfo = new Cont.Region()
                {
                    RegionName = row["Region"].Trim(),
                    Country = row["Country"].Trim(),
                    CountryCode = row["CCN"].Trim()
                };
                dbo.GetRegion(regionInfo);


                /* Configuration */
                string confType = String.Empty;
                string configName = row["Config Name"].Trim();
                if (configName.Contains("_min_"))
                    confType = "Min";
                else if (configName.Contains("_avg_"))
                    confType = "Avg";
                Cont.Configuration configurationInfo = new Cont.Configuration()
                {
                    Name = configName,
                    Type = confType                                                     // We also need to talk about naming scheme going forward.
                };
                dbo.GetConfiguration(configurationInfo);


                /* Product */
                var product = platformConfigurations.FirstOrDefault(x => x.Configuration == configurationInfo.Name);
                Cont.Product productInfo = new Cont.Product()
                {
                    Name = product.Platform,
                    LOB = row["LOB"].Trim(),
                    Model = product.Model,
                    Variant = product.Variant,
                    Phase = this.DEFAULT_PHASE
                };
                dbo.GetProduct(productInfo);


                /* Measure */
                Cont.Measure measureInfo = new Business.Containers.Measure()
                {
                    Name = row["Measure Name"].Trim()
                };
                dbo.GetMeasure(measureInfo);


                /* SKU */
                Cont.SKU skuInfo = new Business.Containers.SKU()
                {
                    Name = row["SKU"].Trim(),
                    Description = row["SKU Description"].Trim(),
                    Commodity = row["Commodity"].Trim()
                };
                dbo.GetSKU(skuInfo);


                /* Iteration */
                Cont.Iteration iterationInfo = new Cont.Iteration()
                {
                    Region = regionInfo,
                    Measure = measureInfo,
                    Configuration = configurationInfo,
                    Product = productInfo,
                    SKU = skuInfo
                };
                iterationInfo.ID = Business.Handlers.Iteration.Add(iterationInfo);


                /* Cost */
                string formatString = "yyyyMMddHHmmss";
                var fileName = Path.GetFileNameWithoutExtension(m_FLCExtractFilePath);
                var date = DateTime.ParseExact(fileName.Split('_').Last(), formatString, CultureInfo.InvariantCulture);
                var currentCost = Convert.ToDouble(row[row.ColumnNames.First(x => x.Contains("Mth 1"))]);
                var Pred1Cost = Convert.ToDouble(row[row.ColumnNames.First(x => x.Contains("Mth 2"))]);
                var Pred2Cost = Convert.ToDouble(row[row.ColumnNames.First(x => x.Contains("Mth 3"))]);
                var Pred3Cost = Convert.ToDouble(row[row.ColumnNames.First(x => x.Contains("Mth 4"))]);
                Cont.Cost costInfo = new Business.Containers.Cost()
                {
                    Iteration = iterationInfo,
                    Date = date,
                    CurrentCost = currentCost,
                    CostNext1 = Pred1Cost,
                    CostNext2 = Pred2Cost,
                    CostNext3 = Pred3Cost
                };
                costInfo.ID = Business.Handlers.Cost.Add(costInfo);
            }//end for
        }//end method