Example #1
0
 public static void getCreateMaterialViews(ICswResources CswResources, MaterialResponse Response, object Request)
 {
     if (null != CswResources)
     {
         CswNbtResources         NbtResources = (CswNbtResources)CswResources;
         CswNbtActCreateMaterial act          = new CswNbtActCreateMaterial(NbtResources);
         CswNbtView SupplierView = act.getMaterialSuppliersView();
         if (null != SupplierView)
         {
             Response.Data.SuppliersView.SessionViewId = SupplierView.SessionViewId;
         }
     }
 }
Example #2
0
        public static void initializeCreateMaterial(ICswResources CswResources, MaterialResponse Response, string NodeId)
        {
            if (null != CswResources)
            {
                CswNbtResources         NbtResources         = (CswNbtResources)CswResources;
                CswNbtActCreateMaterial CreateMaterialAction = new CswNbtActCreateMaterial(NbtResources);

                // Get/Create a node
                CswPrimaryKey NodePk   = CreateMaterialAction.makeTemp(NodeId);
                CswNbtNode    TempNode = NbtResources.getNode(NodePk, null);
                Response.Data.TempNode           = new CswNbtNode.Node(TempNode);
                Response.Data.TempNodeObjClassId = CswConvert.ToString(TempNode.getObjectClassId());

                // Suppliers view
                CswNbtView SupplierView = CreateMaterialAction.getMaterialSuppliersView();
                if (null != SupplierView)
                {
                    Response.Data.SuppliersView.SessionViewId = SupplierView.SessionViewId;
                }

                // CIS-53353 - Allow adding suppliers if the user has Create on any Vendor nodetype
                Response.Data.AllowSupplierAdd = false;
                CswNbtMetaDataObjectClass VendorOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.VendorClass);
                foreach (CswNbtMetaDataNodeType VendorNT in VendorOC.getNodeTypes())
                {
                    if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, VendorNT))
                    {
                        Response.Data.AllowSupplierAdd = true;
                    }
                }

                //Determine the steps
                int StepNo = 1;
                MaterialResponse.WizardStep TypeAndIdentity = new MaterialResponse.WizardStep()
                {
                    StepNo   = StepNo,
                    StepName = "Choose Type and Identity"
                };
                Response.Data.Steps.Add(TypeAndIdentity);
                StepNo++;

                MaterialResponse.WizardStep AdditionalProps = new MaterialResponse.WizardStep()
                {
                    StepNo   = StepNo,
                    StepName = "Additional Properties"
                };
                Response.Data.Steps.Add(AdditionalProps);
                StepNo++;

                #region Alert wizard to active modules

                bool ContainersEnabled = NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers);
                if (ContainersEnabled)
                {
                    bool CanSize = false;
                    CswNbtMetaDataObjectClass SizeOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SizeClass);
                    foreach (CswNbtMetaDataNodeType SizeNT in SizeOC.getNodeTypes())
                    {
                        if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, SizeNT))
                        {
                            CanSize = true;
                        }
                    }
                    if (CanSize)
                    {
                        MaterialResponse.WizardStep Sizes = new MaterialResponse.WizardStep()
                        {
                            StepNo   = StepNo,
                            StepName = "Size(s)"
                        };
                        Response.Data.Steps.Add(Sizes);
                        Response.Data.ContainerLimit = CswConvert.ToInt32(NbtResources.ConfigVbls.getConfigVariableValue(CswEnumNbtConfigurationVariables.container_receipt_limit.ToString()));
                        StepNo++;
                    }
                    else
                    {
                        ContainersEnabled = false;
                    }
                }
                Response.Data.ContainersModuleEnabled = ContainersEnabled;

                bool SDSEnabled = NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.SDS);
                if (SDSEnabled)
                {
                    MaterialResponse.WizardStep AttachSDS = new MaterialResponse.WizardStep()
                    {
                        StepNo   = StepNo,
                        StepName = "Attach SDS"
                    };
                    Response.Data.Steps.Add(AttachSDS);

                    // Permission is a separate check now because we still want to show the Attach SDS step
                    // even if the User doesn't have permission. If they don't have permission, we display
                    // a message on the client.
                    CswNbtMetaDataNodeType SDSNT = NbtResources.MetaData.getNodeType("SDS Document");
                    Response.Data.addSDSPermission = null != SDSNT && NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Create, SDSNT);
                }
                Response.Data.SDSModuleEnabled = SDSEnabled;

                #endregion Alert wizard to active modules

                // Get the ChemicalObjClassId
                CswNbtMetaDataObjectClass ChemicalOC = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass);
                Response.Data.ChemicalObjClassId = CswConvert.ToString(ChemicalOC.ObjectClassId);

                // Determine Constituent NodeTypes
                CswCommaDelimitedString ConstituentNodeTypeIds = new CswCommaDelimitedString();
                foreach (CswNbtMetaDataNodeType ChemicalNT in ChemicalOC.getNodeTypes())
                {
                    CswNbtMetaDataNodeTypeProp IsConstituentNTP = ChemicalNT.getNodeTypePropByObjectClassProp(CswNbtObjClassChemical.PropertyName.IsConstituent);
                    // Yes this is a weird way to know whether a nodetype is a Constituent nodetype,
                    // but as long as this property remains servermanaged, this will work
                    if (IsConstituentNTP.HasDefaultValue() &&
                        CswEnumTristate.True == IsConstituentNTP.getDefaultValue(false).AsLogical.Checked)
                    {
                        ConstituentNodeTypeIds.Add(ChemicalNT.NodeTypeId.ToString());
                    }
                }
                Response.Data.ConstituentNodeTypeIds = ConstituentNodeTypeIds.ToString();
            }
        }