Exemplo n.º 1
0
        /// <summary>Snippet for CreateEntitlement</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void CreateEntitlementRequestObject()
        {
            // Create client
            CloudChannelServiceClient cloudChannelServiceClient = CloudChannelServiceClient.Create();
            // Initialize request argument(s)
            CreateEntitlementRequest request = new CreateEntitlementRequest
            {
                ParentAsCustomerName = CustomerName.FromAccountCustomer("[ACCOUNT]", "[CUSTOMER]"),
                Entitlement          = new Entitlement(),
                RequestId            = "",
            };
            // Make the request
            Operation <Entitlement, OperationMetadata> response = cloudChannelServiceClient.CreateEntitlement(request);

            // Poll until the returned long-running operation is complete
            Operation <Entitlement, OperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Entitlement result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Entitlement, OperationMetadata> retrievedResponse = cloudChannelServiceClient.PollOnceCreateEntitlement(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Entitlement retrievedResult = retrievedResponse.Result;
            }
        }
        /// <summary>Snippet for ActivateEntitlementAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ActivateEntitlementRequestObjectAsync()
        {
            // Create client
            CloudChannelServiceClient cloudChannelServiceClient = await CloudChannelServiceClient.CreateAsync();

            // Initialize request argument(s)
            ActivateEntitlementRequest request = new ActivateEntitlementRequest
            {
                Name      = "",
                RequestId = "",
            };
            // Make the request
            Operation <Entitlement, OperationMetadata> response = await cloudChannelServiceClient.ActivateEntitlementAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Entitlement, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Entitlement result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Entitlement, OperationMetadata> retrievedResponse = await cloudChannelServiceClient.PollOnceActivateEntitlementAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Entitlement retrievedResult = retrievedResponse.Result;
            }
        }
Exemplo n.º 3
0
        internal NameTagRendererDelegate GetNameTagRenderer(Entity entity)
        {
            EntityPlayer eplr = entity as EntityPlayer;

            var entitlements = eplr?.Player.Entitlements;

            //entitlements = new List<Entitlement>();
            //entitlements.Add(new Entitlement() { Code = "vsteam", Name = "vsteam" });

            if (entitlements?.Count > 0)
            {
                Entitlement ent   = entitlements[0];
                double[]    color = null;

                if (GlobalConstants.playerColorByEntitlement.TryGetValue(ent.Code, out color))
                {
                    TextBackground bg;
                    GlobalConstants.playerTagBackgroundByEntitlement.TryGetValue(ent.Code, out bg);
                    DefaultEntitlementTagRenderer var = new DefaultEntitlementTagRenderer()
                    {
                        color = color, background = bg
                    };

                    return(var.renderTag);
                }
            }

            return(DefaultNameTagRenderer);
        }
Exemplo n.º 4
0
        IEnumerable <Claim> GetRoles(Entitlement entitlement)
        {
            var claims = new List <Claim>();
            var mask   = entitlement.Mask;

            if (mask.HasFlag(RoleMask.Admin))
            {
                claims.Add(new Claim(ClaimTypes.Role, Role.Admin));
            }

            if (mask.HasFlag(RoleMask.Super))
            {
                claims.Add(new Claim(ClaimTypes.Role, Role.Super));
            }

            if (mask.HasFlag(RoleMask.Identified))
            {
                claims.Add(new Claim(ClaimTypes.Role, Role.Phi));
            }

            if (mask.HasFlag(RoleMask.Federated))
            {
                claims.Add(new Claim(ClaimTypes.Role, Role.Fed));
            }

            return(claims);
        }
        public void GetEntitlementRequestObject()
        {
            moq::Mock <CloudChannelService.CloudChannelServiceClient> mockGrpcClient = new moq::Mock <CloudChannelService.CloudChannelServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetEntitlementRequest request = new GetEntitlementRequest
            {
                EntitlementName = EntitlementName.FromAccountCustomerEntitlement("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]"),
            };
            Entitlement expectedResponse = new Entitlement
            {
                EntitlementName    = EntitlementName.FromAccountCustomerEntitlement("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]"),
                CreateTime         = new wkt::Timestamp(),
                UpdateTime         = new wkt::Timestamp(),
                OfferAsOfferName   = OfferName.FromAccountOffer("[ACCOUNT]", "[OFFER]"),
                CommitmentSettings = new CommitmentSettings(),
                ProvisioningState  = Entitlement.Types.ProvisioningState.Unspecified,
                ProvisionedService = new ProvisionedService(),
                SuspensionReasons  =
                {
                    Entitlement.Types.SuspensionReason.TrialEnded,
                },
                PurchaseOrderId = "purchase_order_id4111e034",
                TrialSettings   = new TrialSettings(),
                AssociationInfo = new AssociationInfo(),
                Parameters      = { new Parameter(), },
            };

            mockGrpcClient.Setup(x => x.GetEntitlement(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            CloudChannelServiceClient client = new CloudChannelServiceClientImpl(mockGrpcClient.Object, null);
            Entitlement response             = client.GetEntitlement(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public static void AddFullEntitlementToDynamoDB(Entitlement ent)
        {
            Table table       = Table.LoadTable(client, "Entitlement");
            var   entitlement = new Document();

            // Set the attributes that you wish to update.
            //

            entitlement["Tenant_Customer"] = $"DECE{ent.CustomerIdentifier}";

            System.Xml.Serialization.XmlSerializer writer =
                new System.Xml.Serialization.XmlSerializer(typeof(Entitlement));

            MemoryStream stream = new MemoryStream();

            writer.Serialize(stream, ent);

            var contents = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length);

            // Replace the authors attribute.
            entitlement["Entitlement"] = contents;

            // Add a new attribute.
            entitlement["SerialNumber"] = "xxxx";
            // Delete the existing PageCount attribute.
            entitlement["BackOfficeTimeStamp"] = ent.BackOfficeTimestamp;

            var res = table.UpdateItemAsync(entitlement).Result;

            return;
        }
Exemplo n.º 7
0
        public EntitlementListVirtualTable(EBSVirtualReportTablesPackage package)
            : base(package)
        {
            this.Name        = "EntitlementTable";
            this.Label       = "EBS Entitlement Table";
            this.Description = "EBS Entitlement Table";
            addColumns(Entitlement.getDetailedSchema());

            //add filter
            this.Columns.Add(new ReportColumn()
            {
                DataType   = ReportColumnType.Integer,
                Label      = "HiddenInstanceId",
                Name       = "HiddenInstanceId",
                CanDisplay = false,
                CanFilter  = true
            });

            this.Columns.Add(new ReportColumn()
            {
                DataType   = ReportColumnType.String,
                Label      = "HiddenValidateFlag",
                Name       = "HiddenValidateFlag",
                CanDisplay = false,
                CanFilter  = true
            });
        }
        /// <summary>Snippet for ChangeOfferAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task ChangeOfferRequestObjectAsync()
        {
            // Create client
            CloudChannelServiceClient cloudChannelServiceClient = await CloudChannelServiceClient.CreateAsync();

            // Initialize request argument(s)
            ChangeOfferRequest request = new ChangeOfferRequest
            {
                Name             = "",
                OfferAsOfferName = OfferName.FromAccountOffer("[ACCOUNT]", "[OFFER]"),
                Parameters       = { new Parameter(), },
                PurchaseOrderId  = "",
                RequestId        = "",
            };
            // Make the request
            Operation <Entitlement, OperationMetadata> response = await cloudChannelServiceClient.ChangeOfferAsync(request);

            // Poll until the returned long-running operation is complete
            Operation <Entitlement, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync();

            // Retrieve the operation result
            Entitlement result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Entitlement, OperationMetadata> retrievedResponse = await cloudChannelServiceClient.PollOnceChangeOfferAsync(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Entitlement retrievedResult = retrievedResponse.Result;
            }
        }
        /// <summary>Snippet for ChangeParameters</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public void ChangeParametersRequestObject()
        {
            // Create client
            CloudChannelServiceClient cloudChannelServiceClient = CloudChannelServiceClient.Create();
            // Initialize request argument(s)
            ChangeParametersRequest request = new ChangeParametersRequest
            {
                Name            = "",
                Parameters      = { new Parameter(), },
                RequestId       = "",
                PurchaseOrderId = "",
            };
            // Make the request
            Operation <Entitlement, OperationMetadata> response = cloudChannelServiceClient.ChangeParameters(request);

            // Poll until the returned long-running operation is complete
            Operation <Entitlement, OperationMetadata> completedResponse = response.PollUntilCompleted();
            // Retrieve the operation result
            Entitlement result = completedResponse.Result;

            // Or get the name of the operation
            string operationName = response.Name;
            // This name can be stored, then the long-running operation retrieved later by name
            Operation <Entitlement, OperationMetadata> retrievedResponse = cloudChannelServiceClient.PollOnceChangeParameters(operationName);

            // Check if the retrieved long-running operation has completed
            if (retrievedResponse.IsCompleted)
            {
                // If it has completed, then access the result
                Entitlement retrievedResult = retrievedResponse.Result;
            }
        }
        public static Entitlement ReadXMLFile(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Entitlement));
            StreamReader  reader     = new StreamReader(path);
            Entitlement   ent        = (Entitlement)serializer.Deserialize(reader);

            reader.Close();
            return(ent);
        }
Exemplo n.º 11
0
        public EntitlementTokenGenerator(string[] itemIds, string[] appIds, string[] skus)
        {
            Assert.IsFalse(itemIds == null && appIds == null && skus == null, "Can't create entitlement token generator! all itemIds, appIds and skus parameters are null!");

            this.entitlement = AccelBytePlugin.GetEntitlement();

            this.itemIds = itemIds;
            this.appIds  = appIds;
            this.skus    = skus;
        }
        public ActionResult UnDelete(int id, int thirdPartyUserId)
        {
            ThirdPartyUserGDSAccessRight thirdPartyUserGDSAccessRight = new ThirdPartyUserGDSAccessRight();

            thirdPartyUserGDSAccessRight = thirdPartyUserGDSAccessRightRepository.GetThirdPartyUserGDSAccessRight(id);

            //Check Exists
            if (thirdPartyUserGDSAccessRight == null)
            {
                ViewData["ActionMethod"] = "DeleteGet";
                return(View("RecordDoesNotExistError"));
            }

            //Check AccessRights
            if (!rolesRepository.HasWriteAccessToThirdPartyGDSAccessRights(thirdPartyUserId))
            {
                ViewData["Message"] = "You do not have access to this item";
                return(View("Error"));
            }

            ThirdPartyUserGDSAccessRightVM thirdPartyUserGDSAccessRightVM = new ThirdPartyUserGDSAccessRightVM();

            //System User
            ThirdPartyUser thirdPartyUser = new ThirdPartyUser();

            thirdPartyUser = thirdPartyUserRepository.GetThirdPartyUser(thirdPartyUserGDSAccessRight.ThirdPartyUserId);
            if (thirdPartyUser != null)
            {
                thirdPartyUserRepository.EditForDisplay(thirdPartyUser);
                thirdPartyUserGDSAccessRightVM.ThirdPartyUser = thirdPartyUser;
            }

            //Entitlements (All but this one)
            if (thirdPartyUser.ThirdPartyUserGDSAccessRights != null && thirdPartyUser.ThirdPartyUserGDSAccessRights.Count() > 0)
            {
                List <Entitlement> entitlements = new List <Entitlement>();
                foreach (ThirdPartyUserGDSAccessRight item in thirdPartyUser.ThirdPartyUserGDSAccessRights.Where(x => x.ThirdPartyUserGDSAccessRightId != thirdPartyUserGDSAccessRight.ThirdPartyUserGDSAccessRightId))
                {
                    Entitlement entitlement = new Entitlement()
                    {
                        tpAgentID        = item.GDSSignOnID,
                        tpPCC            = item.PseudoCityOrOfficeId,
                        tpServiceID      = item.GDS.GDSName,
                        DeletedFlag      = item.DeletedFlag == true ? true : false,
                        DeletedTimestamp = item.DeletedDateTime
                    };
                    entitlements.Add(entitlement);
                }
                thirdPartyUserGDSAccessRightVM.Entitlements = entitlements;
            }

            thirdPartyUserGDSAccessRightVM.ThirdPartyUserGDSAccessRight = thirdPartyUserGDSAccessRight;

            return(View(thirdPartyUserGDSAccessRightVM));
        }
 /// <summary>Snippet for GetEntitlement</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GetEntitlementRequestObject()
 {
     // Create client
     CloudChannelServiceClient cloudChannelServiceClient = CloudChannelServiceClient.Create();
     // Initialize request argument(s)
     GetEntitlementRequest request = new GetEntitlementRequest
     {
         EntitlementName = EntitlementName.FromAccountCustomerEntitlement("[ACCOUNT]", "[CUSTOMER]", "[ENTITLEMENT]"),
     };
     // Make the request
     Entitlement response = cloudChannelServiceClient.GetEntitlement(request);
 }
        //Add Data From Linked Tables for Display
        public void EditForDisplay(ThirdPartyUser thirdPartyUser)
        {
            //Flags
            thirdPartyUser.IsActiveFlagNonNullable    = (thirdPartyUser.IsActiveFlag.HasValue) ? thirdPartyUser.IsActiveFlag.Value : false;
            thirdPartyUser.RoboticUserFlagNonNullable = (thirdPartyUser.RoboticUserFlag.HasValue) ? thirdPartyUser.RoboticUserFlag.Value : false;
            thirdPartyUser.CubaBookingAllowanceIndicatorNonNullable = (thirdPartyUser.CubaBookingAllowanceIndicator.HasValue) ? thirdPartyUser.CubaBookingAllowanceIndicator.Value : false;
            thirdPartyUser.MilitaryAndGovernmentUserFlagNonNullable = (thirdPartyUser.MilitaryAndGovernmentUserFlag.HasValue) ? thirdPartyUser.MilitaryAndGovernmentUserFlag.Value : false;

            if (thirdPartyUser.Partner != null)
            {
                thirdPartyUser.PartnerName = thirdPartyUser.Partner.PartnerName;
            }

            if (thirdPartyUser.Country != null)
            {
                thirdPartyUser.CountryName = thirdPartyUser.Country.CountryName;
            }

            if (thirdPartyUser.ClientTopUnit != null)
            {
                thirdPartyUser.ClientTopUnitName = thirdPartyUser.ClientTopUnit.ClientTopUnitName;
            }

            if (thirdPartyUser.ClientSubUnit != null)
            {
                thirdPartyUser.ClientSubUnitName = thirdPartyUser.ClientSubUnit.ClientSubUnitName;
            }

            if (thirdPartyUser.StateProvinceCode != null)
            {
                StateProvinceRepository stateProvinceRepository = new StateProvinceRepository();
                thirdPartyUser.StateProvince = stateProvinceRepository.GetStateProvinceByCountry(thirdPartyUser.CountryCode, thirdPartyUser.StateProvinceCode);
            }

            //ThirdPartyUserGDSAccessRights
            if (thirdPartyUser.ThirdPartyUserGDSAccessRights != null && thirdPartyUser.ThirdPartyUserGDSAccessRights.Count() > 0)
            {
                List <Entitlement> entitlements = new List <Entitlement>();
                foreach (ThirdPartyUserGDSAccessRight thirdPartyUserGDSAccessRight in thirdPartyUser.ThirdPartyUserGDSAccessRights)
                {
                    Entitlement entitlement = new Entitlement()
                    {
                        tpAgentID        = thirdPartyUserGDSAccessRight.GDSSignOnID,
                        tpPCC            = thirdPartyUserGDSAccessRight.PseudoCityOrOfficeId,
                        tpServiceID      = thirdPartyUserGDSAccessRight.GDS.GDSName,
                        DeletedFlag      = thirdPartyUserGDSAccessRight.DeletedFlag == true ? true : false,
                        DeletedTimestamp = thirdPartyUserGDSAccessRight.DeletedDateTime
                    };
                    entitlements.Add(entitlement);
                }
                thirdPartyUser.Entitlements = entitlements;
            }
        }
Exemplo n.º 15
0
 public void Set(Entitlement other)
 {
     if (other != null)
     {
         m_ApiVersion    = EcomInterface.EntitlementApiLatest;
         EntitlementName = other.EntitlementName;
         EntitlementId   = other.EntitlementId;
         CatalogItemId   = other.CatalogItemId;
         ServerIndex     = other.ServerIndex;
         Redeemed        = other.Redeemed;
         EndTimestamp    = other.EndTimestamp;
     }
 }
Exemplo n.º 16
0
    void OnEntitlementsRefreshed()
    {
        foreach (string id in pendingEntitlementIds)
        {
            //notify user of new inventory
            Entitlement ent        = collectionCore.GetEntitlementById(id);
            Asset       info       = collectionCore.GetAssetInfoByName(ent.AssetName);
            string      prefabName = (string)info.GetCustom("prefabName", "");
            string      descript   = (string)info.Description;
            popupPrefab.SetPrefab(prefabName, descript);

            RecipeController ctrler = (RecipeController)AppController.Instance.GetController(Controller.RECIPE);

            //check recipes for completion
            string outcome = ctrler.OnNewInventory((string)info.Name);

            if (!String.IsNullOrEmpty(outcome))
            {
                foreach (Image fuse in fusions)
                {
                    if (fuse.gameObject.name == "icon_fus_" + outcome)
                    {
                        fuse.color = Color.white;
                        break;
                    }
                }
            }

            foreach (Image image in images)
            {
                if (image.gameObject.name == "icon_" + ent.AssetName)
                {
                    image.color = Color.white;

                    foreach (Image fuse in fusions)
                    {
                        if (fuse.gameObject.name == "icon_fus_" + ent.AssetName)
                        {
                            fuse.enabled = false;
                            break;
                        }
                    }

                    break;
                }
            }
        }

        pendingEntitlementIds.Clear();
    }
Exemplo n.º 17
0
            public IEnumerator GetUserEntitlementById_Failed()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> entitlementInfo = null;

                entitlements.GetUserEntitlementById("Invalid", result => { entitlementInfo = result; });

                while (entitlementInfo == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(entitlementInfo.IsError, "Get user entitlement by invalid id is success.");
            }
Exemplo n.º 18
0
            public IEnumerator ConsumeUserEntitlementZero_Failed()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> getEntitlementInfoResult = null;

                entitlements.ConsumeUserEntitlement(expectedEntitlementId, 0, result => { getEntitlementInfoResult = result; });

                while (getEntitlementInfoResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(getEntitlementInfoResult.IsError, "Consume user entitlement success.");
            }
Exemplo n.º 19
0
            public IEnumerator QueryUserEntitlement_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();
                Result <EntitlementPagingSlicedResult> getPagedEntitlementsResult = null;

                entitlements.QueryUserEntitlements("", "", 0, 20, result => { getPagedEntitlementsResult = result; });

                while (getPagedEntitlementsResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!getPagedEntitlementsResult.IsError, "Get user entitlements failed.");
                expectedEntitlementId = getPagedEntitlementsResult.Value.data[0].id;
            }
Exemplo n.º 20
0
            public IEnumerator GetUserEntitlementById_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> entitlementInfo = null;

                entitlements.GetUserEntitlementById(expectedEntitlementId, result => { entitlementInfo = result; });

                while (entitlementInfo == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                TestHelper.Assert.IsTrue(!entitlementInfo.IsError, "Get user entitlement by id failed.");
                TestHelper.Assert.IsTrue(entitlementInfo.Value.id == expectedEntitlementId, "Expected entitlement is not found.");
            }
Exemplo n.º 21
0
            public IEnumerator ConsumeUserEntitlement_Success()
            {
                Entitlement entitlements = AccelBytePlugin.GetEntitlements();

                Result <EntitlementInfo> getEntitlementInfoResult = null;

                entitlements.ConsumeUserEntitlement(expectedEntitlementId, 1, result => { getEntitlementInfoResult = result; });

                while (getEntitlementInfoResult == null)
                {
                    Thread.Sleep(100);

                    yield return(null);
                }

                bool bConsumeUserEntitlement = (getEntitlementInfoResult.Value.status == EntitlementStatus.CONSUMED);

                TestHelper.Assert.IsTrue(!getEntitlementInfoResult.IsError, "Consume user entitlement failed.");
                TestHelper.Assert.IsTrue(bConsumeUserEntitlement, "Consume user entitlement failed.");
            }
Exemplo n.º 22
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = Rarity;
         hashCode = (hashCode * 397) ^ (Entitlement != null ? Entitlement.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ EntitlementRequired.GetHashCode();
         hashCode = (hashCode * 397) ^ ExcludeFromCardGeneration.GetHashCode();
         hashCode = (hashCode * 397) ^ (Faction?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Leader != null ? Leader.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (ForegroundImage != null ? ForegroundImage.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (DisplayInfo != null ? DisplayInfo.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (GameObject != null ? GameObject.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ LastStandNumber.GetHashCode();
         hashCode = (hashCode * 397) ^ EnergyCost;
         hashCode = (hashCode * 397) ^ (PlayType?.GetHashCode() ?? 0);
         hashCode = (hashCode * 397) ^ (Keywords?.GetHashCode() ?? 0);
         return(hashCode);
     }
 }
Exemplo n.º 23
0
        public override IList <IReportRow> GetRows(IList <string> columns, IReportFilterNode filterNode)
        {
            decimal hiddenInstanceId = 0;
            object  filter_value     = getEqualsFilterValue(filterNode, "HiddenInstanceId", true);

            if (null != filter_value)
            {
                hiddenInstanceId = Convert.ToDecimal(filter_value);
            }
            IList <IReportRow> reportRows = new List <IReportRow>();

            Entitlement[] entitlements = Entitlement.LookupEntitlementList(hiddenInstanceId, getValidateFlag(filterNode));
            foreach (Entitlement e in entitlements)
            {
                ReportDataRow reportDataRow = new ReportDataRow(this.Columns.Count);
                if (e != null)
                {
                    addItem(ref columns, ref reportDataRow, ref reportRows, e);
                }
            }
            return(reportRows);
        }
Exemplo n.º 24
0
        /// <summary>
        ///     Buy all entitlemens of a given type.
        ///     Will Grant resources as needed. Does 3 things
        ///     1. Buys all the resources
        ///     2. Get the log and then "undoes" each of the actions
        ///     3. Gets the log and "redoes" each of the actions
        ///     4. verifies that the Undo/Redo path yeilds the same results as the intial buy path.
        /// </summary>
        /// <param name="helper">The Test Helper that holds the CatanProxy and the GameName</param>
        /// <param name="entitlement">The Entitlement to buy</param>
        /// <param name="tr">The Traderesource that represents the cost of the entitlement</param>
        /// <returns></returns>
        private async Task <PlayerResources> PurchaseAll(TestHelper helper, Entitlement entitlement, TradeResources tr)
        {
            string player = (await helper.CreateGame())[0];

            Assert.NotNull(player);
            Assert.NotEmpty(player);
            PlayerResources startingResources = await helper.Proxy.GetResources(helper.GameName, player);

            List <LogHeader> logCollection = await helper.Proxy.Monitor(helper.GameName, player); // this wipes out any logs up till now -- just a player log

            PlayerResources resources;

            do
            {
                resources = await helper.GrantResourcesAndAssertResult(player, tr);

                Assert.NotNull(resources);
                resources = await helper.Proxy.BuyEntitlement(helper.GameName, player, entitlement);
            } while (resources != null);

            Assert.Equal(CatanError.LimitExceeded, helper.Proxy.LastError.Error);
            PlayerResources resourcesAfterPurchaseLoop = await helper.Proxy.GetResources(helper.GameName, player);

            Assert.NotNull(resourcesAfterPurchaseLoop);


            //
            //  get the log records -- normally this is done in a monitor
            logCollection = await helper.Proxy.Monitor(helper.GameName, player); // this are only the ones we just added

            //
            //  now undo everything
            PlayerResources resourcesAfterUndo = null;

            for (int i = 0; i < logCollection.Count; i++)
            {
                LogHeader logEntry = logCollection[^ (i + 1)] as LogHeader;
        public static void AddSoftwareToDynamoDB(Entitlement ent)
        {
            foreach (EntitlementSoftware item in ent.Software)
            {
                Table table       = Table.LoadTable(client, "Entitlement");
                var   entitlement = new Document();

                // Set the attributes that you wish to update.
                // german serial numbers are guids so contain hyphens
                string Tenant = item.SoftwareSerialNumber.Contains("-") ? "DE" : "CE";

                entitlement["Tenant_Customer"] = $"{Tenant}#{ent.CustomerIdentifier}";

                // xml serialise
                // System.Xml.Serialization.XmlSerializer writer =
                //     new System.Xml.Serialization.XmlSerializer(typeof(EntitlementSoftware));


                MemoryStream stream = new MemoryStream();

                writer.Serialize(stream, item);

                var contents = Encoding.UTF8.GetString(stream.GetBuffer(), 0, (int)stream.Length);

                // Replace the authors attribute.
                entitlement["Software"] = contents;

                // Add a new attribute.
                entitlement["SerialNumber"] = item.SoftwareSerialNumber;
                // Delete the existing PageCount attribute.
                entitlement["BackOfficeTimeStamp"] = ent.BackOfficeTimestamp;

                var res = table.UpdateItemAsync(entitlement).Result;
            }

            return;
        }
        internal NameTagRendererDelegate GetNameTagRenderer(Entity entity)
        {
            EntityPlayer eplr = entity as EntityPlayer;

            if (eplr?.Player != null && eplr.Player.Entitlements.Count > 0)
            {
                Entitlement ent   = eplr.Player.Entitlements[0];
                double[]    color = null;

                if (GlobalConstants.playerColorByEntitlement.TryGetValue(ent.Code, out color))
                {
                    TextBackground bg;
                    GlobalConstants.playerTagBackgroundByEntitlement.TryGetValue(ent.Code, out bg);
                    DefaultEntitlementTagRenderer var = new DefaultEntitlementTagRenderer()
                    {
                        color = color, background = bg
                    };

                    return(var.renderTag);
                }
            }

            return(DefaultNameTagRenderer);
        }
Exemplo n.º 27
0
        List <Claim> IdClaims(IScopedIdentity identity, Entitlement entitlement)
        {
            if (!entitlement.Mask.HasFlag(RoleMask.User))
            {
                throw new LeafAuthenticationException($"{identity.Identity} is not a Leaf user.");
            }

            var idNonce = Guid.NewGuid().ToString();
            var claims  = new List <Claim>
            {
                new Claim(ClaimTypes.Name, identity.ScopedIdentity),
                IssuedAt,
                new Claim(JwtRegisteredClaimNames.Aud, jwtOptions.Issuer),
                new Claim(TokenType.Key, TokenType.Id),
                new Claim(Nonce.Id, idNonce),
                new Claim(AuthType.Key, authenticationOptions.Mechanism.ToString()),
                new Claim(LeafVersion.Key, versionOptions.Version.ToString())
            };

            claims.AddRange(GetRoles(entitlement));
            claims.AddRange(GetGroups(entitlement));

            return(claims);
        }
        private static void ValidateEntitlements(ShopperContext context, Order order, Customer customer, int count, Type type = null)
        {
            var entitlementsComponent = order.Components.OfType <EntitlementsComponent>().FirstOrDefault();

            entitlementsComponent.Should().NotBeNull();
            entitlementsComponent?.Entitlements.Should().NotBeEmpty();
            entitlementsComponent?.Entitlements.Count.Should().Be(count);

            if (customer != null)
            {
                entitlementsComponent = customer.Components.OfType <EntitlementsComponent>().FirstOrDefault();
                entitlementsComponent.Should().NotBeNull();
                entitlementsComponent?.Entitlements.Should().NotBeEmpty();
                entitlementsComponent?.Entitlements.Count.Should().Be(count);
            }

            foreach (var entitlementReference in entitlementsComponent.Entitlements)
            {
                Entitlement entitlement = null;

                if (entitlementReference.EntityTarget.StartsWith("Entity-GiftCard-"))
                {
                    entitlement = Proxy.GetValue(context.ShopsContainer().GiftCards.ByKey(entitlementReference.EntityTarget));
                }
                else if (entitlementReference.EntityTarget.StartsWith("Entity-DigitalProduct-"))
                {
                    entitlement = Proxy.GetValue(context.ShopsContainer().DigitalProducts.ByKey(entitlementReference.EntityTarget));
                }
                else if (entitlementReference.EntityTarget.StartsWith("Entity-Installation-"))
                {
                    entitlement = Proxy.GetValue(context.ShopsContainer().Installations.ByKey(entitlementReference.EntityTarget));
                }
                else if (entitlementReference.EntityTarget.StartsWith("Entity-Warranty-"))
                {
                    entitlement = Proxy.GetValue(context.ShopsContainer().Warranties.ByKey(entitlementReference.EntityTarget));
                }

                entitlement.Should().NotBeNull();
                entitlement.Order.Should().NotBeNull();
                entitlement.Order?.EntityTarget.Should().Be(order.Id);

                if (type != null)
                {
                    (entitlement.GetType() == type).Should().BeTrue();
                }

                if (customer != null)
                {
                    entitlement.Customer.Should().NotBeNull();
                    entitlement.Customer?.EntityTarget.Should().Be(customer.Id);
                }
                else if (type != null && type == typeof(GiftCard) || type == null && entitlementReference.EntityTarget.StartsWith("Entity-GiftCard-"))
                {
                    entitlement.Customer.Should().NotBeNull();
                    entitlement.Customer?.EntityTarget.Should().Be("DefaultUser");
                }
                else
                {
                    entitlement.Customer.Should().BeNull();
                }
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PSEntitlement" /> class.
 /// </summary>
 /// <param name="entitlement">The base customer for this instance.</param>
 public PSEntitlement(Entitlement entitlement)
 {
     this.CopyFrom(entitlement);
 }
Exemplo n.º 30
0
        public Entitlement[] LookupEntitlementList(decimal instance_id, string validate_flag)
        {
            Entitlement[] retvals = new Entitlement[0];
            string logMessage, logNote;

            if (String.IsNullOrWhiteSpace(EntitlementListURL) || 
                String.IsNullOrWhiteSpace(EntitlementServiceUsername) ||
                String.IsNullOrWhiteSpace(EntitlementServicePassword))
            {
                throw new Exception("Provider's InitForEntitlement not run.");
            }
            ENTITLEMENT.OKS_ENTITLEMENTS_PUB_Service client = EBSProxyFactory.GetEntitlementInstance(EntitlementListURL, EntitlementServiceUsername, EntitlementServicePassword, EntitlementServiceTimeout);
            ENTITLEMENT.SOAHeader hdr = new ENTITLEMENT.SOAHeader();
            hdr.Responsibility = "OKS_MANAGER";
            hdr.RespApplication = "OKS";
            hdr.SecurityGroup = "STANDARD";
            hdr.NLSLanguage = "AMERICAN";
            hdr.Org_Id = "204";

            client.SOAHeaderValue = hdr;

            ENTITLEMENT.InputParameters5 ip = new ENTITLEMENT.InputParameters5();
            ip.P_API_VERSION = 1;
            ip.P_API_VERSIONSpecified = true;
            ip.P_INIT_MSG_LIST = "T";
            ip.P_INP_REC = new Accelerator.EBS.SharedServices.ProxyClasses.Entitlement.APPSOKS_ENTITLEMENTS_X226932X4X3(); 
            ip.P_INP_REC.VALIDATE_FLAG = validate_flag;
            ip.P_INP_REC.CONTRACT_NUMBER = "";
            //log input parameters
            string parameters = String.Format("GET_CONTRACTS__1 for instance_id {0}", instance_id.ToString());

            if (instance_id > 0)
            {
                ip.P_INP_REC.PRODUCT_ID = instance_id;
                ip.P_INP_REC.PRODUCT_IDSpecified = true;
            }
            else
            {
                logMessage = parameters + ". No valid parameters found. No search performed.";
                logNote = null;
                ConfigurationSetting.logWrap.DebugLog(logMessage: logMessage, logNote: logNote);
                return retvals;
            }
            
            logMessage = parameters + ". Request payload.";
            logNote = serializer.Serialize(ip);
            ConfigurationSetting.logWrap.DebugLog(logMessage: logMessage, logNote: logNote);
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            
            StringBuilder response = new StringBuilder("[{}");
            try
            {
                ENTITLEMENT.OutputParameters5 opList = client.GET_CONTRACTS__1(ip);
                List<Entitlement> entitlements = new List<Entitlement>();

                foreach (ENTITLEMENT_LIST op in opList.X_ENT_CONTRACTS)
                {
                    Entitlement e = new Entitlement(getPropertyValues(op), instance_id, validate_flag);
                    entitlements.Add(e);
                    response.Append(",").Append(e.ToJSON());
                }
                retvals = entitlements.ToArray();
            }

            catch (Exception ex)
            {
                handleEBSException(ex, parameters);
                throw;
            }

            stopwatch.Stop();
            int timeElapsed = stopwatch.Elapsed.Milliseconds;
            logMessage = new StringBuilder(parameters)
                .Append(" returned ").Append(retvals.Count()).Append(" records in ")
                .Append(timeElapsed).Append("ms")
                .ToString();
            logNote = response.Append(",{\"Count\":").Append("\"")
                .Append(retvals.Count()).Append("\"}]").ToString();
            ConfigurationSetting.logWrap.DebugLog(logMessage: logMessage, logNote: logNote, timeElapsed: timeElapsed);
            return retvals;
        }
Exemplo n.º 31
0
 IEnumerable <Claim> GetGroups(Entitlement entitlement)
 {
     return(entitlement.Groups.Select(g => new Claim(Group.Key, g)));
 }