public static void saveMaterialProps(ICswResources CswResources, MaterialResponse Response, string PropDefinition) { if (null != CswResources) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswNbtActCreateMaterial CreateMaterialAction = new CswNbtActCreateMaterial(NbtResources); // Convert PropDefintion to JObject JObject PropsObj = CswConvert.ToJObject(PropDefinition); if (PropsObj.HasValues) { // Convert the nodeid to a primary key CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(CswConvert.ToString(PropsObj["NodeId"])); // Convert the Nodetypeid to an Int32 Int32 NodeTypeId = CswConvert.ToInt32(CswConvert.ToString(PropsObj["NodeTypeId"])); // Properties only JObject Properties = CswConvert.ToJObject(PropsObj["Properties"]); // Save the properties JObject PropValues = CreateMaterialAction.saveMaterialProps(NodePk, Properties, NodeTypeId); // Set the return object if (PropValues.HasValues) { if (null != PropValues.Property("PhysicalState")) { Response.Data.Properties.PhysicalState = CswConvert.ToString(PropValues["PhysicalState"]); } } }//if( PropsObj.HasValues ) } }
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; } } }
private MaterialResponse ParseQueryResponse(MaterialByElementsResponseMessage_sync sapMessage) { var res = new MaterialResponse(); BaseResponse tempRes = SapLogParser.ParseSapResponseLog(sapMessage.Log); res.Errors = tempRes.Errors; res.Warnings = tempRes.Warnings; if (sapMessage.Material != null) { res.ExternalId = sapMessage.Material[0].InternalID.Value; } return(res); }
private MaterialResponse ParseMaterialValuationResponse(MaterialValuationDataMaintainConfirmationBundleMessage_sync sapMessage) { var res = new MaterialResponse(); BaseResponse tempRes = SapLogParser.ParseSapResponseLog(sapMessage.Log); res.Errors = tempRes.Errors; res.Warnings = tempRes.Warnings; if (sapMessage.MaterialValuationData != null) { res.ExternalId = sapMessage.MaterialValuationData[0].MaterialInternalID.Value; } return(res); }
public static void getPhysicalState(ICswResources CswResources, MaterialResponse Response, string NodeId) { if (null != CswResources) { CswNbtResources NbtResources = (CswNbtResources)CswResources; CswPrimaryKey pk = CswConvert.ToPrimaryKey(NodeId); if (CswTools.IsPrimaryKey(pk)) { Response.Data.PhysicalState = "n/a"; CswNbtPropertySetMaterial MaterialNode = NbtResources.Nodes[pk]; if (MaterialNode.ObjectClass.ObjectClass == CswEnumNbtObjectClass.ChemicalClass) { CswNbtObjClassChemical ChemicalNode = MaterialNode.Node; Response.Data.PhysicalState = ChemicalNode.PhysicalState.Value; } } } }
private Boolean UploadThumbnail(Item mItem) { MediaParams mediaParams = new MediaParams(); mediaParams.mediatype = "thumb"; var mField = (ImageField)mItem.Fields["Image"]; if (mField == null) { return(false); } MediaItem mediaItem = mField.MediaItem; if (mediaItem == null) { return(false); } mediaParams.filename = mediaItem.Name + "." + mediaItem.Extension; mediaParams.filelength = (int)mediaItem.GetMediaStream().Length; mediaParams.contenttype = mediaItem.MimeType; mediaParams.media = new byte[(int)mediaItem.GetMediaStream().Length]; using (Stream stream = mediaItem.GetMediaStream()) { stream.Read(mediaParams.media, 0, (int)mediaItem.GetMediaStream().Length); } MaterialResponse materialResponse = (MaterialResponse)JsonConvert.DeserializeObject(MsgService.AddMaterial(mediaParams), typeof(MaterialResponse)); using (new Sitecore.SecurityModel.SecurityDisabler()) { mItem.Editing.BeginEdit(); mItem["ThumbnailID"] = materialResponse.Media_Id; mItem["ThumbnailUrl"] = HttpUtility.UrlDecode(materialResponse.Url); mItem.Editing.EndEdit(); } return(true); //return Content(JsonConvert.SerializeObject(materialResponse)); }
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(); } }