Ejemplo n.º 1
0
        public TierIIData getTierIIData_old(TierIIData.TierIIDataRequest Request)
        {
            BaseUnit = _setBaseUnit("kg", "Unit_Weight");
            CswNbtObjClassUnitOfMeasure PoundsUnit = _setBaseUnit("lb", "Unit_Weight");
            CswNbtUnitConversion        Conversion = (BaseUnit != null && PoundsUnit != null) ?
                                                     new CswNbtUnitConversion(_CswNbtResources, BaseUnit.NodeId, PoundsUnit.NodeId) :
                                                     new CswNbtUnitConversion();

            LocationIds = _setLocationIds(Request.LocationId);
            DataTable MaterialsTable = _getTierIIMaterials(Request);

            foreach (DataRow MaterialRow in MaterialsTable.Rows)
            {
                CswPrimaryKey BaseUnitId = CswConvert.ToPrimaryKey("nodes_" + MaterialRow["unitid"]);
                if (null != BaseUnit && BaseUnit.NodeId != BaseUnitId)
                {
                    //Theoretically, this should never happen
                    //(unless we decide, one day, to change the unit in which we're storing TierII quantity data)
                    BaseUnit = _CswNbtResources.Nodes.GetNode(BaseUnitId);
                    Conversion.setOldUnitProps(BaseUnit);
                }
                Double MaxQty     = Math.Round(Conversion.convertUnit(CswConvert.ToDouble(MaterialRow["maxqty"])), 3);
                Double AverageQty = Math.Round(Conversion.convertUnit(CswConvert.ToDouble(MaterialRow["avgqty"])), 3);

                TierIIData.TierIIMaterial Material = new TierIIData.TierIIMaterial
                {
                    MaterialId          = MaterialRow["materialid"].ToString(),
                    TradeName           = MaterialRow["tradename"].ToString(),
                    CASNo               = MaterialRow["casno"].ToString(),
                    MaterialType        = MaterialRow["materialtype"].ToString(),
                    PhysicalState       = MaterialRow["physicalstate"].ToString(),
                    EHS                 = MaterialRow["specialflags"].ToString().Contains("EHS"),
                    TradeSecret         = MaterialRow["specialflags"].ToString().Contains("Trade Secret"),
                    MaxQty              = MaxQty,
                    MaxQtyRangeCode     = _getRangeCode(MaxQty),
                    AverageQty          = AverageQty,
                    AverageQtyRangeCode = _getRangeCode(AverageQty),
                    DaysOnSite          = CswConvert.ToInt32(MaterialRow["daysonsite"]),
                    Unit                = PoundsUnit != null ? PoundsUnit.Name.Text : "lb"
                };
                CswCommaDelimitedString Hazards = new CswCommaDelimitedString();
                Hazards.FromString(MaterialRow["hazardcategories"].ToString());
                foreach (String Hazard in Hazards)
                {
                    Material.HazardCategories.Add(Hazard);
                }
                DataTable ContainerStorageCodesTable = _getContainerStorageProps(Material.MaterialId, Request);
                foreach (DataRow ContainerPropsRow in ContainerStorageCodesTable.Rows)
                {
                    TierIIData.StorageCodes StorageCodes = new TierIIData.StorageCodes
                    {
                        Pressure    = ContainerPropsRow["pressure"].ToString(),
                        Temperature = ContainerPropsRow["temperature"].ToString(),
                        UseType     = ContainerPropsRow["usetype"].ToString()
                    };
                    Material.Storage.Add(StorageCodes);
                }
                DataTable ContainerLocationsTable = _getContainerLocations(Material.MaterialId, Request);
                foreach (DataRow ContainerLocsRow in ContainerLocationsTable.Rows)
                {
                    TierIIData.StorageLocations Location = new TierIIData.StorageLocations
                    {
                        LocationId = ContainerLocsRow["locationid"].ToString(),
                        Location   = ContainerLocsRow["fulllocation"].ToString()
                    };
                    Material.Locations.Add(Location);
                }
                Data.Materials.Add(Material);
            }

            return(Data);
        }
Ejemplo n.º 2
0
        public TierIIData getTierIIData(TierIIData.TierIIDataRequest Request)
        {
            CswArbitrarySelect TierIISelect = _CswNbtResources.makeCswArbitrarySelect("Tier II Material Select",
                                                                                      "select * from table(TIER_II_DATA_MANAGER.GET_TIER_II_DATA(" + CswConvert.ToPrimaryKey(Request.LocationId).PrimaryKey +
                                                                                      ", " + _CswNbtResources.getDbNativeDate(DateTime.Parse(Request.StartDate)) +
                                                                                      ", " + _CswNbtResources.getDbNativeDate(DateTime.Parse(Request.EndDate)) + ")) where casno is not null");
            DataTable TierIITable = TierIISelect.getTable();

            foreach (DataRow MaterialRow in TierIITable.Rows)
            {
                TierIIData.TierIIMaterial Material = new TierIIData.TierIIMaterial
                {
                    MaterialId          = MaterialRow["materialid"].ToString(),
                    TradeName           = MaterialRow["tradename"].ToString(),
                    CASNo               = MaterialRow["casno"].ToString(),
                    MaterialType        = MaterialRow["materialtype"].ToString(),
                    PhysicalState       = MaterialRow["physicalstate"].ToString(),
                    EHS                 = CswConvert.ToBoolean(MaterialRow["ehs"].ToString()),
                    TradeSecret         = CswConvert.ToBoolean(MaterialRow["tradesecret"].ToString()),
                    MaxQty              = Math.Round(CswConvert.ToDouble(MaterialRow["maxqty"]), 3),
                    MaxQtyRangeCode     = MaterialRow["maxqtyrangecode"].ToString(),
                    AverageQty          = Math.Round(CswConvert.ToDouble(MaterialRow["avgqty"]), 3),
                    AverageQtyRangeCode = MaterialRow["avgqtyrangecode"].ToString(),
                    DaysOnSite          = CswConvert.ToInt32(MaterialRow["daysonsite"]),
                    Unit                = "lb"
                };
                CswCommaDelimitedString Hazards = new CswCommaDelimitedString();
                Hazards.FromString(MaterialRow["hazardcategories"].ToString());
                foreach (String Hazard in Hazards)
                {
                    Material.HazardCategories.Add(Hazard);
                }
                int ContainerPropRows;
                CswCommaDelimitedString Pressures = new CswCommaDelimitedString();
                Pressures.FromString(MaterialRow["pressure"].ToString());
                ContainerPropRows = Pressures.Count;
                CswCommaDelimitedString Temperatures = new CswCommaDelimitedString();
                Temperatures.FromString(MaterialRow["temperature"].ToString());
                ContainerPropRows = Temperatures.Count > ContainerPropRows ? Temperatures.Count : ContainerPropRows;
                CswCommaDelimitedString UseTypes = new CswCommaDelimitedString();
                UseTypes.FromString(MaterialRow["usetype"].ToString());
                ContainerPropRows = UseTypes.Count > ContainerPropRows ? UseTypes.Count : ContainerPropRows;
                for (int i = 0; i < ContainerPropRows; i++)
                {
                    int p = Pressures.Count - 1 < i ? Pressures.Count : i;
                    int t = Pressures.Count - 1 < i ? Pressures.Count : i;
                    int u = Pressures.Count - 1 < i ? Pressures.Count : i;
                    TierIIData.StorageCodes StorageCodes = new TierIIData.StorageCodes
                    {
                        Pressure    = Pressures[p],
                        Temperature = Temperatures[t],
                        UseType     = UseTypes[u]
                    };
                    Material.Storage.Add(StorageCodes);
                }
                CswCommaDelimitedString Locations = new CswCommaDelimitedString();
                Locations.FromString(MaterialRow["storagelocations"].ToString());
                foreach (String Location in Locations)
                {
                    Material.Locations.Add(new TierIIData.StorageLocations
                    {
                        Location = Location
                    });
                }
                Data.Materials.Add(Material);
            }

            return(Data);
        }