public EntitlementLineItemResponse Update(OrderEntitlementLineItem lineItem) { var resp = new EntitlementLineItemResponse(); XNamespace soapenv = "http://schemas.xmlsoap.org/soap/envelope/"; XNamespace urn = "urn:v1.webservices.operations.flexnet.com"; XElement soapEnv = new XElement(soapenv + "Envelope", new XAttribute(XNamespace.Xmlns + "soapenv", "http://schemas.xmlsoap.org/soap/envelope/"), new XAttribute(XNamespace.Xmlns + "urn", "urn:v1.webservices.operations.flexnet.com"), new XElement(soapenv + "Header"), new XElement(soapenv + "Body", new XElement(urn + "updateEntitlementLineItemRequest", new XElement(urn + "lineItemData", new XElement(urn + "entitlementIdentifier", new XElement(urn + "primaryKeys", new XElement(urn + "entitlementId", lineItem.EntitlementId))), new XElement(urn + "lineItemData", new XElement(urn + "lineItemIdentifier", new XElement(urn + "primaryKeys", new XElement(urn + "activationId", lineItem.ActivationId))), new XElement(urn + "numberOfCopies", lineItem.Quantity.ToString())), new XElement(urn + "autoDeploy", true) )))); var soapXml = soapEnv.ToString(); var client = new RestClient(EndPointUrl + "EntitlementOrderService"); var request = new RestRequest(Method.POST); byte[] credentialBuffer = new System.Text.UTF8Encoding().GetBytes(UserName + ":" + Password); var authorization = "Basic " + Convert.ToBase64String(credentialBuffer); request.AddHeader("cache-control", "no-cache"); request.AddHeader("accept", "application/json"); request.AddHeader("pragma", "no-cache"); request.AddHeader("soapaction", "updateEntitlementLineItem"); request.AddHeader("authorization", authorization); request.AddHeader("content-type", "text/xml; charset=utf-8"); request.AddParameter("text/xml; charset=utf-8", soapXml, ParameterType.RequestBody); IRestResponse response = client.Execute(request); resp.ActivationCode = lineItem.ActivationId; resp.EntitlementId = lineItem.EntitlementId; resp.TotalQty = lineItem.Quantity; resp.EntitlementLineItemId = lineItem.EntitlementLineItemId; resp.ProductRateChargeId = lineItem.ProductRatePlanChargeId; resp.PartNumber = lineItem.PartNumber; return(resp); }
public bool UpdateEntitlementLineItem(OrderEntitlementLineItem lineItem) { var fnoWs = new v1EntitlementOrderService(); fnoWs.Url = EndPointUrl + "EntitlementOrderService"; fnoWs.PreAuthenticate = true; CredentialCache credCache = new System.Net.CredentialCache(); NetworkCredential netCred = new NetworkCredential(UserName, Password); credCache.Add(new Uri(fnoWs.Url), "Basic", netCred); fnoWs.Credentials = credCache; var updateRq = new updateEntitlementLineItemDataType(); updateRq.entitlementIdentifier = new entitlementIdentifierType { primaryKeys = new entitlementPKType { entitlementId = lineItem.EntitlementId } }; updateRq.autoDeploy = true; updateRq.autoDeploySpecified = true; updateRq.lineItemData = new updateLineItemDataType[] { new updateLineItemDataType { activationId = new idType { id = lineItem.ActivationId, autoGenerate = false, autoGenerateSpecified = true }, numberOfCopies = lineItem.Quantity.ToString(), partNumber = new partNumberIdentifierType { primaryKeys = new partNumberPKType { partId = lineItem.PartNumber } } } }; var resp = fnoWs.updateEntitlementLineItem(new updateEntitlementLineItemDataType[] { updateRq }); if (resp.statusInfo.status == Entitlement.StatusType.SUCCESS) { return(true); } return(false); }
public EntitlementLineItemResponse AddLineItemToEntitlement(string entitlementId, OrderEntitlementLineItem lineItem) { var lineItemResp = new EntitlementLineItemResponse(); var fnoWs = new v1EntitlementOrderService(); fnoWs.Url = EndPointUrl + "EntitlementOrderService"; fnoWs.PreAuthenticate = true; CredentialCache credCache = new System.Net.CredentialCache(); NetworkCredential netCred = new NetworkCredential(UserName, Password); credCache.Add(new Uri(fnoWs.Url), "Basic", netCred); fnoWs.Credentials = credCache; var entLineItem = new addOnlyEntitlementLineItemRequestType(); entLineItem.opType = Entitlement.CreateOrUpdateOperationType.CREATE_OR_UPDATE; entLineItem.lineItem = new addEntitlementLineItemDataType[] { new addEntitlementLineItemDataType { autoDeploy = true, autoDeploySpecified = true, entitlementIdentifier = new entitlementIdentifierType { primaryKeys = new entitlementPKType { entitlementId = entitlementId } }, lineItems = new createEntitlementLineItemDataType[] { new createEntitlementLineItemDataType { activationId = new idType { autoGenerate = true, autoGenerateSpecified = true }, isPermanent = lineItem.IsPerpertual, isPermanentSpecified = true, orderId = lineItem.ProductRatePlanChargeId, numberOfCopies = lineItem.Quantity.ToString(), partNumber = new partNumberIdentifierType { primaryKeys = new partNumberPKType { partId = lineItem.PartNumber } }, startDate = lineItem.EffectiveDate, expirationDate = lineItem.ExpirationDate, expirationDateSpecified = lineItem.IsPerpertual? false : true } } } }; var resp = fnoWs.createEntitlementLineItem(entLineItem); if (resp.statusInfo.status == Entitlement.StatusType.SUCCESS) { lineItemResp.ActivationCode = resp.responseData[0].lineItemIdentifiers[0].primaryKeys.activationId; lineItemResp.EntitlementId = resp.responseData[0].entitlementIdentifier.primaryKeys.entitlementId; lineItemResp.EntitlementLineItemId = resp.responseData[0].lineItemIdentifiers[0].uniqueId; lineItemResp.PartNumber = lineItem.PartNumber; lineItemResp.ProductRateChargeId = lineItem.ProductRatePlanChargeId; lineItemResp.TotalQty = lineItem.Quantity; } return(lineItemResp); }