Пример #1
0
        public void PayscaleEntitlementCheck_InValid()
        {
            #region "Local Var"
            PayscaleEntitlementCheckRequest  payscaleEntitlementCheckRequest  = new PayscaleEntitlementCheckRequest();
            PayscaleEntitlementCheckResponse payscaleEntitlementCheckResponse = new PayscaleEntitlementCheckResponse();
            EntitlementResponse entitlementResponse = null;
            #endregion
            for (int i = 0; i < 5; i++)
            {
                if (i == 0)// Method should return all the courses with in the given ProductCrmId(Course bundle)
                {
                    payscaleEntitlementCheckRequest.crmContactId      = "";
                    payscaleEntitlementCheckRequest.payScaleProductId = "";
                }

                try
                {
                    payscaleEntitlementCheckResponse = target.PayscaleEntitlementCheck(payscaleEntitlementCheckRequest);
                    entitlementResponse = payscaleEntitlementCheckResponse.PayscaleEntitlementCheckResult;
                }
                catch (Exception ex0)
                {
                    throw;
                }
            }
        }
Пример #2
0
 public Entitlement(EntitlementResponse response)
 {
     offerings = new Dictionary <string, Product>();
     foreach (var offering in response.offerings)
     {
         Debug.Log("offering " + offering.product);
         if (offering.product.identifier != null)
         {
             offerings.Add(offering.offeringId, offering.product);
         }
     }
 }
        public List <EntitlementResponse> Provision(FulfillOrderRequest request)
        {
            var resultEntitlements = new List <EntitlementResponse>();

            var entitlementList = flexeraClient.GetEntitlements(request.Account.AccountNumber);

            List <string> LicenseServers = GetLicensServers(request);

            var productFamilies = request.Order.LineItems.Select(c => new { c.EntitlementFamily, c.IsSingleSeat,
                                                                            c.DeployToCloudLicenseServer }).Distinct();

            foreach (var p in productFamilies)
            {
                var ocsProductFamily = p.EntitlementFamily + (p.DeployToCloudLicenseServer ? "_Networked" : "_Local");
                if (!string.IsNullOrWhiteSpace(p.EntitlementFamily))
                {
                    var orderEntitlement = new OrderEntitlement();
                    orderEntitlement.EntitlementFamily = p.EntitlementFamily;

                    orderEntitlement.LineItems = GetLineEntitlementLineItems(request, p.EntitlementFamily, p.DeployToCloudLicenseServer);

                    if (orderEntitlement.LineItems.Count > 0)
                    {
                        var qty     = orderEntitlement.LineItems[0].Quantity;
                        var entResp = new EntitlementResponse();

                        //if (p.IsSingleSeat)
                        //    entResp.EntitlementId = flexeraClient.CreateEntitlement(request.Account.AccountNumber, p.EntitlementFamily);
                        //else
                        entResp.EntitlementId = GetProductFamilyEntitlementId(entitlementList, request.Account.AccountNumber,
                                                                              request.Account.CompanyName, ocsProductFamily);

                        entResp.EntitlementFamily = p.EntitlementFamily;

                        entResp.EntitlementLineItems = new List <EntitlementLineItemResponse>();

                        foreach (var li in orderEntitlement.LineItems)
                        {
                            var entLiResp = new EntitlementLineItemResponse();

                            var existingLineItem = (from i in entitlementList
                                                    from j in i.LineItems
                                                    where j.PartNumber == li.PartNumber
                                                    select j).FirstOrDefault();

                            if (existingLineItem != null)
                            {
                                existingLineItem.ProductRatePlanChargeId = li.ProductRatePlanChargeId;
                                existingLineItem.Quantity += qty;
                                entLiResp = flexeraClient.Update(existingLineItem);
                            }
                            else
                            {
                                if (request.RequestType == FulfillmentRequestType.Renewal)
                                {
                                    if (li.IsPerpertual)
                                    {
                                        li.Quantity = qty;
                                        flexeraClient.Update(li);
                                    }
                                    else
                                    {
                                        flexeraClient.ExpireLineItem(entResp.EntitlementId, li.ActivationId);
                                        li.Quantity = qty;
                                        entLiResp   = flexeraClient.AddLineItemToEntitlement(entResp.EntitlementId, li);
                                    }
                                }
                                else
                                {
                                    li.Quantity = qty;
                                    entLiResp   = flexeraClient.AddLineItemToEntitlement(entResp.EntitlementId, li);
                                }
                            }

                            if (p.DeployToCloudLicenseServer)
                            {
                                entLiResp.CloudLicenseServerId = li.LicenseManagerId;


                                if (LicenseServers.Count > 0)
                                {
                                    var cls = LicenseServers.FirstOrDefault(ls => ls == entLiResp.CloudLicenseServerId);
                                    if (string.IsNullOrWhiteSpace(cls))
                                    {
                                        cls = LicenseServers.Last();
                                    }

                                    flexeraClient.AddEntitlementLineItemToLicenseServer(entLiResp, cls);
                                    entLiResp.CloudLicenseServerId = cls;
                                }
                            }
                            entResp.EntitlementLineItems.Add(entLiResp);
                        }
                        resultEntitlements.Add(entResp);
                    }
                }
            }

            request.setDevices(LicenseServers);

            return(resultEntitlements);
        }