Ejemplo n.º 1
0
        public void SelectCountryItem(string locator, string item)
        {
            string newLocator = locator.Replace("foo", item);

            HelperUtils.ScrollToElement(driver.FindElement(By.XPath(newLocator)), driver);
        }
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                base.ExecuteCmdlet();

                ResourceIdentifier resourceIdentifier = new ResourceIdentifier(VaultId);
                string vaultName         = resourceIdentifier.ResourceName;
                string resourceGroupName = resourceIdentifier.ResourceGroupName;

                string shouldProcessName = InputItem.Id;

                string itemType     = "";
                string itemName     = "";
                string containerUri = "";
                if (ShouldProcess(shouldProcessName, VerbsLifecycle.Disable))
                {
                    Dictionary <UriEnums, string> keyValueDict =
                        HelperUtils.ParseUri(InputItem.Id);

                    itemType = HelperUtils.GetProtectableItemUri(
                        keyValueDict, InputItem.Id).Split(';')[0];
                    itemName = HelperUtils.GetProtectableItemUri(
                        keyValueDict, InputItem.Id).Split(';')[1];
                    containerUri = HelperUtils.GetContainerUri(
                        keyValueDict, InputItem.Id);

                    bool isDisableAutoProtectionSuccessful = false;

                    try
                    {
                        ODataQuery <ServiceClientModel.ProtectionIntentQueryObject> queryParams = null;
                        string backupManagementType = ServiceClientModel.BackupManagementType.AzureWorkload;
                        queryParams = new ODataQuery <ServiceClientModel.ProtectionIntentQueryObject>(
                            q => q.ItemType == itemType &&
                            q.ItemName == itemName &&
                            q.ParentName == containerUri &&
                            q.BackupManagementType == backupManagementType);

                        var itemResponses = ServiceClientAdapter.ListProtectionIntent(
                            queryParams,
                            vaultName: vaultName,
                            resourceGroupName: resourceGroupName);

                        string intentName = null;
                        foreach (var itemResponse in itemResponses)
                        {
                            string itemNameResponse      = "";
                            string containerNameResponse = "";

                            Dictionary <UriEnums, string> keyValueDictResponse =
                                HelperUtils.ParseUri(itemResponse.Properties.ItemId);
                            itemNameResponse = HelperUtils.GetProtectableItemUri(
                                keyValueDictResponse, itemResponse.Properties.ItemId).ToLower();
                            containerNameResponse = HelperUtils.GetContainerUri(
                                keyValueDictResponse, itemResponse.Properties.ItemId);

                            if ((String.Compare(itemNameResponse, itemName, true) == 0) &&
                                ((itemType.Contains("sqlavailabilitygroup") && String.Compare(containerUri.Split(';')[1], containerNameResponse, true) == 0) ||
                                 (String.Compare(containerUri.Split(';')[3], containerNameResponse.Split(';')[2], true) == 0)))
                            {
                                intentName = itemResponse.Name;
                                break;
                            }
                        }

                        var deleteResponse = ServiceClientAdapter.DeleteProtectionIntent(
                            intentName,
                            vaultName: vaultName,
                            resourceGroupName: resourceGroupName);

                        isDisableAutoProtectionSuccessful = true;
                    }
                    catch
                    {
                    }
                    if (PassThru.IsPresent)
                    {
                        WriteObject(isDisableAutoProtectionSuccessful);
                    }
                }
            });
        }
Ejemplo n.º 3
0
        private async Task CompositToLogisticsCompositeAsync()
        {
            if (AllScores != null)
            {
                var Compo = (from mydata in AllScores.AsParallel()
                             select new
                {
                    SessionID = mydata.Barcode.ToString(),
                    NBTNumber = mydata.RefNo.ToString(),
                    Surname = mydata.Surname,
                    Name = mydata.Name,
                    Initial = mydata.Initials,
                    SouthAfricanID = mydata.SAID.ToString(),
                    Passport = mydata.ForeignID,
                    Birth = (mydata.SAID != null ? HelperUtils.DOBfromSAID(mydata.SAID.ToString()) :
                             String.Format("{0:dd/MM/yyyy}", mydata.DOB)),

                    W_AL = mydata.WroteAL,
                    W_QL = mydata.WroteQL,
                    W_Mat = mydata.WroteMat,
                    StNo = "",
                    Faculty = "",
                    Programme = "",
                    DateTest = String.Format("{0:yyyyMMdd}", mydata.DOT),
                    Venue = mydata.VenueName,
                    Sex = (mydata.Gender == "1" ? "M" :
                           mydata.Gender == "2" ? "F" : mydata.Gender),

                    ALScore = mydata.ALScore,
                    ALLevel = mydata.ALLevel,
                    QLScore = mydata.QLScore,
                    QLLevel = mydata.QLLevel,
                    MatScore = mydata.MATScore,
                    MatLevel = mydata.MATLevel,
                    AQL_Lang = mydata.AQLLanguage,
                    Mat_Lang = mydata.MatLanguage,
                    mm = mydata.Batch,
                    TestType = MytestType(mydata.Batch),
                    province = getProvince(mydata.VenueCode)
                });

                // create the collection
                foreach (var a in Compo)
                {
                    LogisticsComposite FC = new LogisticsComposite();


                    FC.SessionId      = a.SessionID;
                    FC.NBT            = a.NBTNumber;
                    FC.Surname        = a.Surname;
                    FC.Name           = a.Name;
                    FC.MiddleInitials = a.Initial;
                    FC.SouthAfricanID = a.SouthAfricanID;
                    FC.Passport       = a.Passport;
                    FC.Birth          = a.Birth;
                    FC.WroteAL        = a.W_AL;
                    FC.WroteQL        = a.W_QL;
                    FC.WroteMat       = a.W_Mat;
                    FC.StudentNo      = a.StNo;
                    FC.Faculty        = a.Faculty;
                    FC.Programme      = a.Programme;
                    FC.TestDate       = a.DateTest;
                    FC.Venue          = a.Venue;
                    FC.Sex            = a.Sex;
                    FC.ALScore        = a.ALScore.ToString();
                    FC.ALLevel        = a.ALLevel;
                    FC.QLScore        = a.QLScore.ToString();
                    FC.QLLevel        = a.QLLevel;
                    FC.MatScore       = a.MatScore.ToString();
                    FC.MatLevel       = a.MatLevel;
                    FC.AQLLanguage    = a.AQL_Lang;
                    FC.MatLanguage    = a.Mat_Lang;
                    FC.TestType       = a.TestType;
                    FC.VenueProvince  = a.province;
                    //FC.RefNo = a.RefNo;


                    LComposite.Add(FC);
                }
            }
        }
Ejemplo n.º 4
0
        private async Task CompositToFullCompositeAsync()
        {
            if (AllScores != null)
            {
                var Compo = from mydata in AllScores.AsParallel()
                            select new
                {
                    RefNo          = mydata.RefNo.ToString(),
                    Barcode        = mydata.Barcode.ToString(),
                    LastName       = mydata.Surname,
                    FName          = mydata.Name,
                    Initials       = mydata.Initials,
                    SAID           = HelperUtils.ToSAID(mydata.SAID),
                    FID            = mydata.ForeignID,
                    DOB            = String.Format("{0:yyyyMMdd}", mydata.DOB),
                    IDType         = mydata.ID_Type,
                    Citizenship    = (mydata.Citizenship != null ? mydata.Citizenship : null),
                    Classification = mydata.Classification,
                    Gender         = mydata.Gender,
                    faculty1       = HelperUtils.GetFacultyName(mydata.Faculty),
                    Testdate       = String.Format("{0:yyyyMMdd}", mydata.DOT),
                    VenueCode      = mydata.VenueCode.ToString("D5"),
                    VenueName      = mydata.VenueName,
                    Hlanguage      = mydata.HomeLanguage,
                    G12L           = mydata.GR12Language,
                    AQLLang        = mydata.AQLLanguage,
                    AQLCode        = mydata.AQLCode,
                    MatLang        = mydata.MatLanguage,
                    MatCode        = mydata.MatCode,
                    Faculty2       = HelperUtils.GetFacultyName(mydata.Faculty2),
                    Faculty3       = HelperUtils.GetFacultyName(mydata.Faculty3),
                    SessionID      = mydata.Barcode.ToString(),
                    NBTNumber      = mydata.RefNo.ToString(),
                    Surname        = mydata.Surname,
                    Name           = mydata.Name,
                    Initial        = mydata.Initials,
                    SouthAfricanID = HelperUtils.ToSAID(mydata.SAID),
                    Passport       = mydata.ForeignID,
                    Birth          = (mydata.SAID != null ? HelperUtils.DOBfromSAID(mydata.SAID.ToString()) :
                                      String.Format("{0:dd/MM/yyyy}", mydata.DOB)),

                    W_AL      = mydata.WroteAL,
                    W_QL      = mydata.WroteQL,
                    W_Mat     = mydata.WroteMat,
                    StNo      = "",
                    Faculty   = "",
                    Programme = "",
                    DateTest  = String.Format("{0:yyyyMMdd}", mydata.DOT),
                    Venue     = mydata.VenueName,
                    Sex       = (mydata.Gender == "1" ? "M" :
                                 mydata.Gender == "2" ? "F" : mydata.Gender),
                    street1  = "",
                    street2  = "",
                    Suburb   = "",
                    City     = "",
                    Province = "",
                    Postal   = "",
                    Email    = "",
                    Landline = "",
                    Mobile   = "",
                    ALScore  = mydata.ALScore,
                    ALLevel  = mydata.ALLevel,
                    QLScore  = mydata.QLScore,
                    QLLevel  = mydata.QLLevel,
                    MatScore = mydata.MATScore,
                    MatLevel = mydata.MATLevel,
                    AQL_Lang = mydata.AQLLanguage,
                    Mat_Lang = mydata.MatLanguage
                };

                foreach (var a in Compo)
                {
                    FullComposite FC = new FullComposite();

                    FC.RefNo          = a.RefNo;
                    FC.Barcode        = a.Barcode;
                    FC.LastName       = a.LastName;
                    FC.FirstName      = a.FName;
                    FC.Initials       = a.Initials;
                    FC.SAID           = a.SAID;
                    FC.FID            = a.FID;
                    FC.DOB            = a.DOB;
                    FC.IDType         = a.IDType;
                    FC.Citizenship    = a.Citizenship.ToString();
                    FC.Classification = a.Classification;
                    FC.Gender         = a.Gender;
                    FC.Faculty1       = a.faculty1;
                    FC.DOT            = a.Testdate;
                    FC.VenueCode      = a.VenueCode;
                    FC.VenueName      = a.VenueName;
                    FC.HomeLanguage   = a.Hlanguage.ToString();
                    FC.SchLanguage    = a.G12L;
                    FC.AQLLang        = a.AQLLang;
                    FC.AQLCode        = a.AQLCode.ToString();
                    FC.MATLang        = a.MatLang;
                    FC.MATCode        = a.MatCode.ToString();
                    FC.Faculty2       = a.Faculty2;
                    FC.Faculty3       = a.Faculty3;
                    FC.SessionId      = a.SessionID;
                    FC.NBT            = a.NBTNumber;
                    FC.Surname        = a.Surname;
                    FC.Name           = a.Name;
                    FC.MiddleInitials = a.Initial;
                    FC.SouthAfricanID = a.SouthAfricanID;
                    FC.Passport       = a.Passport;
                    FC.Birth          = a.Birth;
                    FC.WroteAL        = a.W_AL;
                    FC.WroteQL        = a.W_QL;
                    FC.WroteMat       = a.W_Mat;
                    FC.StudentNo      = a.StNo;
                    FC.Faculty        = a.Faculty;
                    FC.Programme      = a.Programme;
                    FC.TestDate       = a.DateTest;
                    FC.Venue          = a.Venue;
                    FC.Sex            = a.Sex;
                    FC.Street1        = a.street1;
                    FC.Street2        = a.street2;
                    FC.Suburb         = a.Suburb;
                    FC.City           = a.City;
                    FC.Province       = a.Province;
                    FC.Postal         = a.Postal;
                    FC.Email          = a.Email;
                    FC.Landline       = a.Landline;
                    FC.Mobile         = a.Mobile;
                    FC.ALScore        = a.ALScore.ToString();
                    FC.ALLevel        = a.ALLevel;
                    FC.QLScore        = a.QLScore.ToString();
                    FC.QLLevel        = a.QLLevel;
                    FC.MatScore       = a.MatScore.ToString();
                    FC.MatLevel       = a.MatLevel;
                    FC.AQLLanguage    = a.AQL_Lang;
                    FC.MatLanguage    = a.Mat_Lang;

                    FComposite.Add(FC);
                }
            }
        }
Ejemplo n.º 5
0
        public override void ExecuteCmdlet()
        {
            ExecutionBlock(() =>
            {
                // fetch source vault and target vault subscription
                Dictionary <CmdletModel.UriEnums, string> SourceVaultDict = HelperUtils.ParseUri(SourceVault.ID);
                string sourceSub = SourceVaultDict[CmdletModel.UriEnums.Subscriptions];

                Dictionary <CmdletModel.UriEnums, string> TargetVaultDict = HelperUtils.ParseUri(TargetVault.ID);
                string targetSub = TargetVaultDict[CmdletModel.UriEnums.Subscriptions];

                // change subscription for HTTP requests
                string subscriptionContext = ServiceClientAdapter.BmsAdapter.Client.SubscriptionId;
                ServiceClientAdapter.BmsAdapter.Client.SubscriptionId = targetSub;

                // Check if the Target vault is empty
                /// Check the containers count in target vault
                var protectionContainersCount = BackupUtils.GetProtectionContainersCount(TargetVault.Name, TargetVault.ResourceGroupName, ServiceClientAdapter);

                Logger.Instance.WriteDebug("Protection Containers within vault: " + TargetVault.Name + " and resource Group: "
                                           + TargetVault.ResourceGroupName + " are " + protectionContainersCount);

                if (protectionContainersCount > 0)
                {
                    throw new ArgumentException(string.Format(Resources.TargetVaultNotEmptyException));
                }

                /// check the count for VM backupItems
                int vmItemsCount = BackupUtils.GetProtectedItems(TargetVault.Name, TargetVault.ResourceGroupName,
                                                                 BackupManagementType.AzureIaasVM, WorkloadType.VM, ServiceClientAdapter).Count;

                Logger.Instance.WriteDebug("Protected VMs within vault: " + TargetVault.Name + " and resource Group: "
                                           + TargetVault.ResourceGroupName + " are " + vmItemsCount);

                if (vmItemsCount > 0)
                {
                    throw new ArgumentException(string.Format(Resources.TargetVaultNotEmptyException));
                }

                // Confirm the target vault storage type
                BackupResourceConfigResource getStorageResponse = ServiceClientAdapter.GetVaultStorageType(
                    TargetVault.ResourceGroupName, TargetVault.Name);

                Logger.Instance.WriteDebug("Storage Type: " + getStorageResponse.Properties.StorageType);

                string correlationId = "";
                ConfirmAction(
                    Force.IsPresent,
                    string.Format(Resources.TargetVaultStorageRedundancy, TargetVault.Name, getStorageResponse.Properties.StorageType),
                    Resources.TargetVaultStorageRedundancy,
                    getStorageResponse.Properties.StorageType, () =>
                {
                    base.ExecuteCmdlet();

                    if (string.Compare(ParameterSetName, AzureRSVaultDataMoveParameterSet) == 0)
                    {
                        // Prepare Data Move
                        ServiceClientAdapter.BmsAdapter.Client.SubscriptionId = sourceSub;
                        PrepareDataMoveRequest prepareMoveRequest             = new PrepareDataMoveRequest();
                        prepareMoveRequest.TargetResourceId = TargetVault.ID;
                        prepareMoveRequest.TargetRegion     = TargetVault.Location;

                        /// currently only allowing vault level data move
                        prepareMoveRequest.DataMoveLevel = "Vault";

                        if (RetryOnlyFailed.IsPresent)
                        {
                            prepareMoveRequest.IgnoreMoved = true;
                        }
                        else
                        {
                            prepareMoveRequest.IgnoreMoved = false;
                        }

                        Logger.Instance.WriteDebug("Retry only with failed items : " + prepareMoveRequest.IgnoreMoved);
                        Logger.Instance.WriteDebug("Location of Target vault: " + TargetVault.Location);

                        correlationId = ServiceClientAdapter.PrepareDataMove(SourceVault.Name, SourceVault.ResourceGroupName, prepareMoveRequest);
                    }
                    else
                    {
                        correlationId = CorrelationIdForDataMove;
                    }

                    // Trigger Data Move
                    ServiceClientAdapter.BmsAdapter.Client.SubscriptionId = targetSub;
                    TriggerDataMoveRequest triggerMoveRequest             = new TriggerDataMoveRequest();
                    triggerMoveRequest.SourceResourceId = SourceVault.ID;
                    triggerMoveRequest.SourceRegion     = SourceVault.Location;

                    /// currently only allowing vault level data move
                    triggerMoveRequest.DataMoveLevel = "Vault";
                    triggerMoveRequest.CorrelationId = correlationId;
                    triggerMoveRequest.PauseGC       = false;

                    Logger.Instance.WriteDebug("Location of Source vault: " + SourceVault.Location);
                    ServiceClientAdapter.TriggerDataMove(TargetVault.Name, TargetVault.ResourceGroupName, triggerMoveRequest);

                    // set subscription to original
                    ServiceClientAdapter.BmsAdapter.Client.SubscriptionId = subscriptionContext;

                    WriteObject(ParamHelpMsgs.DSMove.CmdletOutput);
                }
                    );
            }, ShouldProcess(TargetVault.Name, VerbsCommon.Set));
        }
        /// <summary>
        /// Lists protected items protected by the recovery services vault according to the provider data
        /// </summary>
        /// <returns>List of protected items</returns>
        public List <ItemBase> ListProtectedItems()
        {
            ContainerBase container =
                (ContainerBase)this.ProviderData[ItemParams.Container];
            string name = (string)this.ProviderData[ItemParams.AzureVMName];
            ItemProtectionStatus protectionStatus =
                (ItemProtectionStatus)this.ProviderData[ItemParams.ProtectionStatus];
            ItemProtectionState status =
                (ItemProtectionState)this.ProviderData[ItemParams.ProtectionState];

            Models.WorkloadType workloadType =
                (Models.WorkloadType) this.ProviderData[ItemParams.WorkloadType];

            ProtectedItemListQueryParam queryParams = new ProtectedItemListQueryParam();

            queryParams.DatasourceType       = ServiceClientModel.WorkloadType.VM;
            queryParams.BackupManagementType = ServiceClientModel.BackupManagementType.AzureIaasVM.ToString();

            List <ProtectedItemResource> protectedItems = new List <ProtectedItemResource>();
            string            skipToken         = null;
            PaginationRequest paginationRequest = null;

            do
            {
                var listResponse = ServiceClientAdapter.ListProtectedItem(queryParams, paginationRequest);
                protectedItems.AddRange(listResponse.ItemList.Value);

                ServiceClientHelpers.GetSkipTokenFromNextLink(listResponse.ItemList.NextLink, out skipToken);
                if (skipToken != null)
                {
                    paginationRequest           = new PaginationRequest();
                    paginationRequest.SkipToken = skipToken;
                }
            } while (skipToken != null);

            // 1. Filter by container
            if (container != null)
            {
                protectedItems = protectedItems.Where(protectedItem =>
                {
                    Dictionary <UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
                    string containerUri = HelperUtils.GetContainerUri(dictionary, protectedItem.Id);
                    return(containerUri.Contains(container.Name));
                }).ToList();
            }

            List <ProtectedItemResponse> protectedItemGetResponses = new List <ProtectedItemResponse>();

            // 2. Filter by item's friendly name
            if (!string.IsNullOrEmpty(name))
            {
                protectedItems = protectedItems.Where(protectedItem =>
                {
                    Dictionary <UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItem.Id);
                    string protectedItemUri = HelperUtils.GetProtectedItemUri(dictionary, protectedItem.Id);
                    return(protectedItemUri.ToLower().Contains(name.ToLower()));
                }).ToList();

                GetProtectedItemQueryParam getItemQueryParams = new GetProtectedItemQueryParam();
                getItemQueryParams.Expand = "extendedinfo";

                for (int i = 0; i < protectedItems.Count; i++)
                {
                    Dictionary <UriEnums, string> dictionary = HelperUtils.ParseUri(protectedItems[i].Id);
                    string containerUri     = HelperUtils.GetContainerUri(dictionary, protectedItems[i].Id);
                    string protectedItemUri = HelperUtils.GetProtectedItemUri(dictionary, protectedItems[i].Id);

                    var getResponse = ServiceClientAdapter.GetProtectedItem(containerUri, protectedItemUri, getItemQueryParams);
                    protectedItemGetResponses.Add(getResponse);
                }
            }

            List <ItemBase> itemModels = ConversionHelpers.GetItemModelList(protectedItems);

            if (!string.IsNullOrEmpty(name))
            {
                for (int i = 0; i < itemModels.Count; i++)
                {
                    AzureVmItemExtendedInfo extendedInfo = new AzureVmItemExtendedInfo();
                    var serviceClientExtendedInfo        = ((AzureIaaSVMProtectedItem)protectedItemGetResponses[i].Item.Properties).ExtendedInfo;
                    if (serviceClientExtendedInfo.OldestRecoveryPoint.HasValue)
                    {
                        extendedInfo.OldestRecoveryPoint = serviceClientExtendedInfo.OldestRecoveryPoint;
                    }
                    extendedInfo.PolicyState                  = serviceClientExtendedInfo.PolicyInconsistent.ToString();
                    extendedInfo.RecoveryPointCount           = serviceClientExtendedInfo.RecoveryPointCount;
                    ((AzureVmItem)itemModels[i]).ExtendedInfo = extendedInfo;
                }
            }

            // 3. Filter by item's Protection Status
            if (protectionStatus != 0)
            {
                itemModels = itemModels.Where(itemModel =>
                {
                    return(((AzureVmItem)itemModel).ProtectionStatus == protectionStatus);
                }).ToList();
            }

            // 4. Filter by item's Protection State
            if (status != 0)
            {
                itemModels = itemModels.Where(itemModel =>
                {
                    return(((AzureVmItem)itemModel).ProtectionState == status);
                }).ToList();
            }

            // 5. Filter by workload type
            if (workloadType != 0)
            {
                itemModels = itemModels.Where(itemModel =>
                {
                    return(itemModel.WorkloadType == workloadType);
                }).ToList();
            }

            return(itemModels);
        }
Ejemplo n.º 7
0
        public void CheckLicenseQuantityWhenUserAddTheSameProductTwiceToCard()
        {
            yourOrderPage = new YourOrderPage(CmdDriver.Driver);
            productsPage  = new ProductsPage(CmdDriver.Driver);

            extentReportUtils.createATestCase("Check license quantity when user add the same product twice to card");
            extentReportUtils.addTestLog(Status.Info, "CheckLicenseQuantityWhenUserAddTheSameProductTwiceToCard");

            productsPage.ClickAcceptAllCookies();

            // Click on Buy Now button per Product name
            productsPage.ClickBuyNowButtonByProductName(ProductsEnum.DEVCRAFT_COMPLETE);

            yourOrderPage.ClickAcceptAllCookies();

            string productName = HelperUtils.GetDescription(ProductsEnum.DEVCRAFT_COMPLETE);

            Assert.IsTrue(yourOrderPage.IsProductDisplayedByProductName(productName));

            // Assert only one product is displayed on the page
            Assert.AreEqual(1, yourOrderPage.GetProductsCountFromPage());

            // Assert default License quantity value
            Assert.AreEqual(1, yourOrderPage.GetSelectedLicenceQuantityValue());

            Product product = new Product(ProductType.LICENSE_AND_YEARLY_DISCOUNT);
            int     qty     = 1;

            product.LicenseQuantity = qty;
            product.YearlyQuantity  = qty;

            // Set Unit Price and M & S subscription price
            product.InitialUnitPrice     = yourOrderPage.GetUnitPrice();
            product.MNsSubscriptionPrice = yourOrderPage.GetMnSSubscriptionPrice();

            // Set license discount
            product.LicenseDiscount = yourOrderPage.GetQuantityDiscounts(product.LicenseQuantity);

            // Calculate discount
            yourOrderPage.SetLicenseQuantity(product.LicenseQuantity);

            product.YearlyDiscount = (yourOrderPage.GetYearQuantityDiscounts(qty));
            yourOrderPage.SetMaintenanceAndSupportQuantity(product.YearlyQuantity);

            // Calculations
            product.CalculateValues();

            // Assert actual and expected unit price
            double actualUnitPrice = yourOrderPage.GetUnitPrice();

            Assert.AreEqual(product.UnitPrice, actualUnitPrice);

            // Assert subtotal value
            double actualSubtotal = yourOrderPage.GetSubtotalValue();

            Assert.AreEqual(product.SubtotalValue, actualSubtotal);

            // Assert renewal price
            double actualRenewalPrice = yourOrderPage.GetMnSSubscriptionPrice();

            Assert.AreEqual(product.ExpectedRenewalPrice, actualRenewalPrice);

            // Assert Total value
            double actualTotalValue = yourOrderPage.GetTotalValue();

            Assert.AreEqual(product.ExpectedTotalValue, actualTotalValue);

            // Assert Subtotal and Total value
            Assert.AreEqual(product.SubtotalValue, product.ExpectedTotalValue);

            // Click 'Continue Shopping' button
            yourOrderPage.ClickContinueShoppingButton();

            // Click on 'Buy now" button for same product
            productsPage.ClickBuyNowButtonByProductName(ProductsEnum.DEVCRAFT_COMPLETE);

            // Assert only one product is displayed on the page
            Assert.AreEqual(1, yourOrderPage.GetProductsCountFromPage());

            int expectedLicenseQty2 = 2;

            // Assert license Qty is incresed
            Assert.AreEqual(expectedLicenseQty2, yourOrderPage.GetSelectedLicenceQuantityValue());

            product.LicenseQuantity = expectedLicenseQty2;

            // Calculate discount
            yourOrderPage.SetLicenseQuantity(product.LicenseQuantity);

            product.CalculateValues();

            // Assert Subtotal and Total value
            Assert.AreEqual(product.SubtotalValue, product.ExpectedTotalValue);
        }
Ejemplo n.º 8
0
        private string AddItem(string[] args, Player sender)
        {
            if (sender.GMLevel < 2)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Nope.");
            }

            byte   category;
            byte   subCategory;
            ushort itemID;
            byte   productID;
            ulong  accountID;
            var    nickname = "";

            if (args.Length < 6)
            {
                return(_commandDescriptions["additem"]);
            }

            if (!byte.TryParse(args[1], out category))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!byte.TryParse(args[2], out subCategory))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!ushort.TryParse(args[3], out itemID))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!byte.TryParse(args[4], out productID))
            {
                return(_commandDescriptions["additem"]);
            }
            if (!ulong.TryParse(args[5], out accountID))
            {
                nickname = args[5];
            }

            var time = DateTime.Now;
            var item = new Item
            {
                Category     = category,
                SubCategory  = subCategory,
                ItemID       = itemID,
                ProductID    = productID,
                PurchaseTime = HelperUtils.GetUnixTimestamp(time)
            };

            var shopItem = GameDatabase.Instance.GetShopItem(item.Category, item.SubCategory, item.ItemID, item.ProductID);

            if (shopItem == null)
            {
                item.ProductID  = 1;
                item.Energy     = 2400;
                item.ExpireTime = -1;
                //return HelperUtils.GetS4Color(255, 0, 0) + "ShopItem not found.";
            }
            else
            {
                item.Energy     = shopItem.Energy;
                item.ExpireTime = (shopItem.Time == -1) ? -1 : HelperUtils.GetUnixTimestamp(time.AddSeconds(shopItem.Time));
            }

            var targetPlr = accountID > 0 ? GameServer.Instance.Players.GetPlayerByID(accountID) : GameServer.Instance.Players.GetPlayerByNickname(nickname);

            if (targetPlr == null)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Player not found.");
            }

            var id = GameDatabase.Instance.CreateItem(item, targetPlr.AccountID);

            if (id == 0)
            {
                return(HelperUtils.GetS4Color(255, 0, 0) + "Failed to create item.");
            }
            item.ID = id;
            item.SetupAPWeapon();
            targetPlr.AddItem(item);

            return(HelperUtils.GetS4Color(0, 255, 0) + "Done.");
        }
Ejemplo n.º 9
0
Archivo: Window.cs Proyecto: wluluxiu/W
 public void destroy()
 {
     HelperUtils.hlpUILayoutGroupEnable(gameObject, false);
     StartCoroutine(_destroy());
 }
Ejemplo n.º 10
0
        public override string GetVideoUrl(VideoInfo video)
        {
            string  url         = string.Format("http://player.yle.fi/api/v1/media.jsonp?protocol=HDS&client=areena-flash-player&id={0}", video.VideoUrl);
            string  subtitleUrl = string.Empty;
            JObject json        = GetWebData <JObject>(url, cache: false);
            JToken  hdsStream   = json["data"]["media"]["HDS"].FirstOrDefault(h => h["subtitles"] != null && h["subtitles"].Count() > 0);

            if (hdsStream == null)
            {
                hdsStream = json["data"]["media"]["HDS"].First;
            }
            else
            {
                JToken subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value <string>() == ApiLanguage);
                if (subtitle == null && ApiLanguage == "fi")
                {
                    subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value <string>() == "fih");                                         //Hearing impaired
                }
                if (subtitle == null)
                {
                    subtitle = hdsStream["subtitles"].FirstOrDefault(s => s["lang"].Value <string>() == ApiOtherLanguage);
                }
                if (subtitle != null && subtitle["uri"] != null)
                {
                    subtitleUrl = subtitle["uri"].Value <string>();
                }
            }
            if (!string.IsNullOrEmpty(subtitleUrl))
            {
                video.SubtitleText = GetWebData(subtitleUrl, encoding: Encoding.UTF8, forceUTF8: true);
            }
            string data   = hdsStream["url"].Value <string>();
            string result = DecryptData(data);
            Regex  r;
            bool   useHls = !result.Contains(".f4m") && !result.Contains("*~hmac");

            if (useHls)
            {
                url    = string.Format("http://player.yle.fi/api/v1/media.jsonp?protocol=HLS&client=areena-flash-player&id={0}", video.VideoUrl);
                json   = GetWebData <JObject>(url, cache: false);
                data   = json["data"]["media"]["HLS"].First["url"].Value <string>();
                result = DecryptData(data);
                r      = new Regex(@"(?<url>.*\.m3u8)");
                Match m = r.Match(result);
                if (m.Success)
                {
                    result = m.Groups["url"].Value;
                    video.PlaybackOptions = HlsPlaylistParser.GetPlaybackOptions(GetWebData(result), result);
                    result = video.PlaybackOptions.Last().Value;
                }
            }
            else
            {
                r = new Regex(@"(?<url>.*hmac=[a-z0-9]*)");
                Match m = r.Match(result);
                if (m.Success)
                {
                    result = m.Groups["url"].Value + "&g=" + HelperUtils.GetRandomChars(12) + "&hdcore=3.8.0&plugin=flowplayer-3.8.0.0";
                }
            }
            return(result);
        }
        public void FetchNodesListAndAutoProtectionPolicy(List <ProtectableItemBase> itemModels, string vaultName, string resourceGroupName)
        {
            foreach (var itemModel in itemModels)
            {
                AzureWorkloadProtectableItem protectableItem = ((AzureWorkloadProtectableItem)itemModel);

                string itemType             = "";
                string itemName             = "";
                string containerUri         = "";
                string backupManagementType = "";

                Dictionary <UriEnums, string> keyValueDict = HelperUtils.ParseUri(protectableItem.Id);

                itemType     = HelperUtils.GetProtectableItemUri(keyValueDict, protectableItem.Id).Split(';')[0];
                itemName     = HelperUtils.GetProtectableItemUri(keyValueDict, protectableItem.Id).Split(';')[1];
                containerUri = HelperUtils.GetContainerUri(keyValueDict, protectableItem.Id);

                // fetch AutoProtectionPolicy for non DBs
                if (protectableItem.ProtectableItemType != "SQLDataBase")
                {
                    // fetch the policy using backup intent
                    ODataQuery <ServiceClientModel.ProtectionIntentQueryObject> queryParams = null;
                    backupManagementType = ServiceClientModel.BackupManagementType.AzureWorkload;

                    queryParams = new ODataQuery <ServiceClientModel.ProtectionIntentQueryObject>(
                        q => q.ItemType == itemType &&
                        q.ItemName == itemName &&
                        q.ParentName == containerUri &&
                        q.BackupManagementType == backupManagementType);

                    var intentList = ServiceClientAdapter.ListProtectionIntent(
                        queryParams,
                        vaultName: vaultName,
                        resourceGroupName: resourceGroupName);

                    foreach (var intent in intentList)
                    {
                        protectableItem.AutoProtectionPolicy = intent.Properties.PolicyId;
                    }
                }

                //  fetch Nodelist for SQLAGs
                if (protectableItem.ProtectableItemType == "SQLAvailabilityGroup")
                {
                    try
                    {
                        // add the NodeList
                        ProtectionContainerResource sqlAGContainer = ServiceClientAdapter.GetContainer(vaultName, resourceGroupName, containerUri);

                        if (sqlAGContainer != null)
                        {
                            AzureSQLAGWorkloadContainerProtectionContainer protectionContainer = (AzureSQLAGWorkloadContainerProtectionContainer)sqlAGContainer.Properties;

                            if (protectionContainer != null && protectionContainer.ExtendedInfo != null)
                            {
                                protectableItem.NodesList = protectionContainer.ExtendedInfo.NodesList;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        WriteDebug(e.Message);
                    }
                }
            }
        }