コード例 #1
0
        public static string GeneratePoCxmlCblForEudc(PoXmlFormat poXmlFormat, string identityName, string deploymentMode, string orderId, string unitPrice, string supplierPartId, string b2BCrtEndUserId)
        {
            var fileName = poXmlFormat + "Template.xml";

            if (poXmlFormat == PoXmlFormat.Cxml)
            {
                return(GeneratePoCxml(
                           fileName,
                           identityName,
                           deploymentMode,
                           orderId,
                           unitPrice,
                           supplierPartId,
                           b2BCrtEndUserId));
            }

            return(GeneratePoCbl(
                       fileName,
                       identityName,
                       orderId,
                       unitPrice,
                       supplierPartId,
                       b2BCrtEndUserId));
        }
コード例 #2
0
        /* How to create 'E-Quote' or 'OrQuote'
         * Call CompleteEQuoteGeneration() with 5 arguments -
         * i) quoteType(equote/OrQuote)     <-- Note pass only "equote" for E-Quote and "OrQuote" for OR-Quote
         * ii) environment - "Preview" or "Prod"
         * iii) profileId - In String
         * iv) name - any name      <- will be used in equote
         * v) email - any email     <- will be used in equote
         */

        public bool CompleteQuoteGeneration(
            string profileId,
            string name,
            string email,
            RunEnvironment environment,
            Workflow workflow,
            PoXmlFormat format,
            string deploymentMode,
            string orderIdBase,
            string poTargetUrl,
            string configFilterVal,
            string testEnvironment,
            List <QuoteDetail> listOfQuoteDetail,
            out string poNumber,
            out List <QuoteDetail> quoteDetail)
        {
            string responseCode = "0";
            var    parentWindow = webDriver.CurrentWindowHandle;

            B2BHomePage.SelectEnvironment(environment.ToString());

            // Quote Details are not available - Quote creation steps will be Executed else directly executes PO submission
            if (listOfQuoteDetail == null || !listOfQuoteDetail.Any() ||
                string.IsNullOrEmpty(listOfQuoteDetail.FirstOrDefault().SupplierPartId))
            {
                B2BHomePage.ClickQaTools3();
                webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                webDriver.SwitchTo().Window(webDriver.WindowHandles.Last());
                var QaToolsWindow = webDriver.CurrentWindowHandle;
                B2BQaToolsPage.SelectLocationAndEnvironment(environment.ToString(), testEnvironment);
                B2BQaToolsPage.ClickPunchoutCreate();
                B2BQaToolsPage.ClickCxml();
                B2BQaToolsPage.ClickCxmlMainCreate();
                B2BQaToolsPage.IdentityForProfileCorrelator(profileId);
                B2BQaToolsPage.IdentityForUserId(profileId);
                B2BQaToolsPage.ClickApplyParameter();
                B2BQaToolsPage.ClickSubmitMessage();
                responseCode = B2BQaToolsPage.GetSubmissionResult();
                Console.WriteLine("Response Code is :- " + responseCode);

                if (responseCode.Contains("200"))
                {
                    string temp = B2BQaToolsPage.GetStoreLinkText();
                    Console.WriteLine("Link value is " + temp);
                    B2BQaToolsPage.ClickStoreLink();
                    webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                    webDriver.Close();
                    string newwindow = webDriver.WindowHandles.LastOrDefault();
                    webDriver.SwitchTo().Window(newwindow);
                    //webDriver.SwitchTo().Window(webDriver.WindowHandles.Last());
                    var premierWindow = webDriver.CurrentWindowHandle;

                    webDriver.Manage().Window.Maximize();
                    B2BPremierDashboardPage.WaitForTitle();
                    B2BPremierDashboardPage.OpenShop();
                    B2BPremierDashboardPage.ClickStandardConfiguration();
                    if (workflow == Workflow.Asn)
                    {
                        B2BStandardConfigurationPage.SelectSpecificConfiguration(configFilterVal, listOfQuoteDetail.FirstOrDefault().ItemDescription);
                    }
                    else
                    {
                        B2BStandardConfigurationPage.SelectFirstConfiguration();
                    }
                    webDriver.WaitForPageLoad(new TimeSpan(0, 0, 20));
                    B2BStandardConfigurationPage.ClickAddSelectedToCartButton();
                    Console.WriteLine("Shoping Cart Page Title is :- " + ShopingCartPage.ReturnShopingCartTitle());
                    ShopingCartPage.ClickSaveQuote(listOfQuoteDetail.FirstOrDefault().QuoteType);

                    // Starting EQuote Generation
                    if (listOfQuoteDetail.FirstOrDefault().QuoteType == QuoteType.EQuote)
                    {
                        Console.WriteLine("EQuote Page Details Page Title is :-" + eQuoteDetailsPage.ReturnTitle());
                        eQuoteDetailsPage.EquoteNameSetting(name);
                        eQuoteDetailsPage.SavedBySetting(email);
                        eQuoteDetailsPage.ClickContinueButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        eQuoteSummaryPage.ClickContinueButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        finalEquoteSummaryPage.ClickSaveButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        listOfQuoteDetail.FirstOrDefault().SupplierPartId = "EQ:" + eQuoteGenerationPage.ReturnNumber();
                        listOfQuoteDetail.FirstOrDefault().Price          = eQuoteGenerationPage.ReturnPrice().Replace("$", "");
                        Console.WriteLine("Your Equote Number is :- " + listOfQuoteDetail.FirstOrDefault().SupplierPartId);
                        Console.WriteLine("Price is :- " + listOfQuoteDetail.FirstOrDefault().Price);
                        webDriver.SwitchTo().Window(parentWindow);
                    }

                    // Starting OrQuote Generation
                    else if (listOfQuoteDetail.FirstOrDefault().QuoteType == QuoteType.OrQuote)
                    {
                        B2BSecureCheckoutPage.EnterContactAndBillingInfo();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        listOfQuoteDetail.FirstOrDefault().Price = B2BTermsOfSalesPage.FindPrice().Replace("$", "");
                        B2BTermsOfSalesPage.ClickSubmitButton();
                        webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
                        Console.WriteLine("Price is :- " + listOfQuoteDetail.FirstOrDefault().Price);
                        listOfQuoteDetail.FirstOrDefault().SupplierPartId = B2BOrQuoteGenerationPage.FindOrQuote();
                        webDriver.SwitchTo().Window(parentWindow);
                    }

                    else
                    {
                        Console.WriteLine("Quote Type is not Specified");
                        poNumber    = string.Empty;
                        quoteDetail = listOfQuoteDetail;
                        return(false);
                    }
                }
            }

            // Generates PO Template
            var    orderId = orderIdBase + DateTime.Today.ToString("yyMMdd") + DateTime.Now.ToString("HHmmss");
            string poXml;

            if (workflow == Workflow.Eudc)
            {
                poXml = PoXmlGenerator.GeneratePoCxmlCblForEudc(
                    format,
                    profileId,
                    deploymentMode,
                    orderId,
                    listOfQuoteDetail.FirstOrDefault().Price,
                    listOfQuoteDetail.FirstOrDefault().SupplierPartId,
                    listOfQuoteDetail.FirstOrDefault().CrtId);
            }
            else
            {
                poXml = PoXmlGenerator.GeneratePoCblForAsn(format, orderId, profileId, listOfQuoteDetail);
            }

            // Submits PO
            B2BHomePage.ClickQaTools3();
            if (!poOperations.SubmitXmlForPoCreation(poXml, environment.ToString(), poTargetUrl, testEnvironment, out poNumber))
            {
                quoteDetail = listOfQuoteDetail;
                return(false);
            }

            // verifies all validation after submiting PO
            webDriver.Close();
            webDriver.SwitchTo().Window(parentWindow);
            webDriver.WaitForPageLoad(TimeSpan.FromSeconds(40));
            quoteDetail = listOfQuoteDetail;
            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Use this method to generate the PO CBL for B2B ASN
        /// </summary>
        /// <param name="poXmlFormat"></param>
        /// <param name="orderId"></param>
        /// <param name="identityName"></param>
        /// <param name="quoteDetails"></param>
        /// <returns></returns>
        public static string GeneratePoCblForAsn(
            PoXmlFormat poXmlFormat,
            string orderId,
            string identityName,
            IList <QuoteDetail> quoteDetails,
            bool removeInternalVendorNumber = false)
        {
            var fileName = poXmlFormat + "Template.xml";
            var doc      = XDocument.Load(fileName);

            doc.XPathSelectElement("//BuyerRefNum/Reference/RefNum").SetValue(orderId);
            doc.XPathSelectElement("//BuyerParty/Party/ListOfIdentifier/Identifier/Agency")
            .Attribute("AgencyOther")
            .SetValue(identityName);

            var orderDetailNode = doc.XPathSelectElement("//ListOfOrderDetail/OrderDetail");
            var newDoc          = new XDocument(orderDetailNode);

            newDoc.Save("OrderDetailNode.xml");
            orderDetailNode.Remove();

            for (var i = quoteDetails.Count() - 1; i > -1; i--)
            {
                if (string.IsNullOrEmpty(quoteDetails[i].SupplierPartId) || string.IsNullOrEmpty(quoteDetails[i].CrtId) ||
                    string.IsNullOrEmpty(quoteDetails[i].Quantity) || string.IsNullOrEmpty(quoteDetails[i].Price))
                {
                    continue;
                }

                var orderDetailDoc = XDocument.Load("OrderDetailNode.xml");
                orderDetailDoc.XPathSelectElement("//BaseItemDetail/LineItemNum").SetValue((i + 1).ToString("D2"));
                switch (quoteDetails[i].QuoteType)
                {
                case QuoteType.EQuote:
                case QuoteType.Doms:
                    orderDetailDoc.XPathSelectElement("//SupplierPartNum/PartNum/PartID")
                    .SetValue(quoteDetails[i].SupplierPartId);
                    break;

                case QuoteType.OrQuote:
                case QuoteType.Bhc:
                    orderDetailDoc.XPathSelectElement("//SupplierPartNum/PartNum/PartIDExt")
                    .SetValue(quoteDetails[i].SupplierPartId);
                    break;

                case QuoteType.Cif:
                    orderDetailDoc.XPathSelectElement("//SupplierPartNum/PartNum/PartID")
                    .SetValue(quoteDetails[i].SupplierPartId);
                    orderDetailDoc.XPathSelectElement("//SupplierPartNum/PartNum/PartIDExt")
                    .SetValue(quoteDetails[i].SupplierPartId);
                    break;

                default:
                    throw new ArgumentException("Quote type not specified");
                }

                orderDetailDoc.XPathSelectElement("//BuyerPartNum/PartNum/PartID").SetValue(quoteDetails[i].CrtId);
                orderDetailDoc.XPathSelectElement("//ManufacturerPartNum/PartNum/PartID").SetValue(quoteDetails[i].CrtId);

                orderDetailDoc.XPathSelectElement("//BaseItemDetail/Quantity/Qty").SetValue(quoteDetails[i].Quantity);
                orderDetailDoc.XPathSelectElement("//BuyerExpectedUnitPrice/Price/UnitPrice").SetValue(quoteDetails[i].Price);

                doc.XPathSelectElement("//ListOfOrderDetail").AddFirst(orderDetailDoc.XPathSelectElement("//OrderDetail"));
            }

            if (removeInternalVendorNumber)
            {
                doc.XPathSelectElement("//InternalVendorNumber").Value = string.Empty;
            }

            doc.Save(fileName);
            var inputXml = "<?xml version='1.0' encoding='utf-8'?>" + doc.ToString();

            return(inputXml);
        }