コード例 #1
0
 public Form1()
 {
     InitializeComponent();
     try {
         ProcessOrders p = new ProcessOrders();
         p.EncryptConfigSection("appSettings");
         p.EncryptConfigSection("connectionStrings");
     } catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
コード例 #2
0
        public void ProcessOrder_BookName_Empty_Test()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.VIDEO).FirstOrDefault();

            OrderProcess      = ProcessOrders.GetPaymentMethod(Models.PaymentType.VIDEO);
            video.Description = string.Empty;

            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(video));

            Assert.That(ex.Message, Is.EqualTo("Video Descrption is missing"));
        }
コード例 #3
0
        public void ProcessOrder_PhysicalProduct_Name_Empty_Test()
        {
            //arrange
            var product = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.PHYSICAL_PRODUCT).FirstOrDefault();

            product.Name = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.PHYSICAL_PRODUCT);

            //assert
            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(product));

            Assert.That(ex.Message, Is.EqualTo("Physical Product Name is missing"));
        }
コード例 #4
0
        private void btnTest_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            ProcessOrders po       = new ProcessOrders();
            string        lsResult = "";

            po.Process(out lsResult);

            MessageBox.Show("Orders have been processed. " + lsResult);

            this.Cursor = Cursors.Default;
        }
コード例 #5
0
        public async Task <IActionResult> Upload(IFormFile file)
        {
            List <Order> orders = await ProcessOrders.ReadOrders(file);

            OrderUploadDTO dto = new OrderUploadDTO
            {
                message = "Data Uploaded Successfully!",
                orders  = orders
            };
            JsonResult jsonResult = Json(dto);

            return(jsonResult);
        }
コード例 #6
0
        /// <summary>
        /// Process 1 or more shipping/cancellation notifications to bol.com
        /// The maximum number of shipments/cancellations in one request is 400.
        /// NOTE: After informing bol.com of shippings / cancellations through the API you may still see your orders as "open" in the seller dashboard.
        /// This has to do with system caches and queues.
        /// The API briefly caches the input it receives and the seller dashboard also has it's own cache to offload the core systems.
        /// The most important feedback is the feedback one gets from the GetProcessStatus() method.
        /// </summary>
        /// <param name="processOrders">The process orders.</param>
        /// <returns>
        /// A ProcessOrdersResult object. This ProcessOrdersResult object was generated by a tool.
        /// The different elements are described on the following XML Schema Definition https://plazaapi.bol.com/services/xsd/plazaapiservice-v1.xsd
        /// </returns>
        public ProcessOrdersResult ProcessOrders(ProcessOrders processOrders)
        {
            HttpWebResponse     response = null;
            ProcessOrdersResult results  = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url + "/services/rest/orders/v1/process/");

                Utils.HandleRequest(request, C.RequestMethods.POST, _publicKey, _privateKey);

                using (Stream reqStream = request.GetRequestStream())
                {
                    XmlSerializer s = new XmlSerializer(typeof(ProcessOrders));
                    s.Serialize(reqStream, processOrders);
                }

                SigningRequest = Utils.StringToSign.Replace("\n", Environment.NewLine);
                response       = (HttpWebResponse)request.GetResponse();

                if (HttpStatusCode.OK == response.StatusCode)
                {
                    XmlSerializer ser = new XmlSerializer(typeof(ProcessOrdersResult));
                    object        obj = ser.Deserialize(response.GetResponseStream());
                    results = (ProcessOrdersResult)obj;

                    var json = new JavaScriptSerializer().Serialize(obj);
                    ResponseOutput = json;
                }
            }
            catch (WebException ex)
            {
                if (ex.Response != null)
                {
                    throw ExceptionHandler.HandleResponseException((HttpWebResponse)ex.Response);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return(results);
        }
        public void Process_Empty_PhysicalProduct()
        {
            //Arrange
            var product = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOKORPHYSICAL).FirstOrDefault();

            product.AgentName = string.Empty;
            OrderProcess      = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOKORPHYSICAL);

            //Act
            var ex = OrderProcess.ProcessPayment(product);

            //Assert
            Assert.AreEqual(ex.Message, "Agent Name is missing.");
        }
コード例 #8
0
        public void Process_Empty_PhysicalProduct()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.VIDEO).FirstOrDefault();

            OrderProcess      = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.VIDEO);
            video.Description = string.Empty;

            //Act
            var ex = OrderProcess.ProcessPayment(video);

            //Assert
            Assert.AreEqual(ex.Message, "Video Descrption is missing");
        }
コード例 #9
0
        public void ProcessOrder_BookName_Empty_Test()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.BOOK).FirstOrDefault();

            book.Name    = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;

            //assert
            var ex = Assert.Throws <InvalidOperationException>(() => OrderProcess.ProcessPayment(book));

            Assert.That(ex.Message, Is.EqualTo("Book Name is missing"));
        }
コード例 #10
0
        public void When_I_Pass_Valid_PhysicalProduct_Order_it_should_process()
        {
            //arrange
            var physcialProduct = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.PHYSICAL_PRODUCT).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.PHYSICAL_PRODUCT);


            //act
            var result = OrderProcess.ProcessPayment(physcialProduct);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Packing slip for shipping generated for physical product", result.Message);
        }
コード例 #11
0
        public void When_I_Pass_Valid_VideoOrder_it_should_process()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.VIDEO).FirstOrDefault();

            OrderProcess        = ProcessOrders.GetPaymentMethod(Models.PaymentType.VIDEO);
            video.Description   = "TestVideos";
            video.PackagingDate = DateTime.Today;

            //act
            var result = OrderProcess.ProcessPayment(video);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Generated Packing slip", result.Message);
        }
コード例 #12
0
        public void Valid_VideoOrder()
        {
            //arrange
            var video = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.VIDEO).FirstOrDefault();

            OrderProcess        = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.VIDEO);
            video.Description   = "learning to msi";
            video.PackagingDate = DateTime.Today;

            //act
            var result = OrderProcess.ProcessPayment(video);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual("Added First Aid video to the packing slip.", result.Message);
        }
コード例 #13
0
        public void When_I_Pass_Valid_BookOrder_it_should_process()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == Models.ProductTypes.BOOK).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(Models.PaymentType.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;
            string message       = "Royalty payment slip created with Amount -" + royaltyAmount;

            //act
            var result = OrderProcess.ProcessPayment(book);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
コード例 #14
0
        public void Valid_BookOrder()
        {
            //Arrange
            var book = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOK).FirstOrDefault();

            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;
            string message       = "Payment slip created with Amount -" + royaltyAmount;

            //Act
            var result = OrderProcess.ProcessPayment(book);

            //Assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
コード例 #15
0
        public void Process_Empty_BookOrder()
        {
            //arrange
            var book = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOK).FirstOrDefault();

            book.Name    = string.Empty;
            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOK);
            double royaltyAmount = book.Price * book.Quantity * book.Commission;

            //Act
            var ex = OrderProcess.ProcessPayment(book);

            //assert

            Assert.AreEqual(ex.Message, "Book Name is missing");
        }
コード例 #16
0
        public void Valid_PhysicalProduct_Order()
        {
            //arrange
            var physcialProduct = GetProductInfo().Where(x => x.ProductType == BL.Models.ProductFor.BOOKORPHYSICAL).FirstOrDefault();

            double Commission = (physcialProduct.Quantity * physcialProduct.Price) / 0.20;

            OrderProcess = ProcessOrders.GetPaymentMethod(BL.Models.PaymentFor.BOOKORPHYSICAL);
            string message = "Commision paid to agent -" + Commission;

            //act
            var result = OrderProcess.ProcessPayment(physcialProduct);

            //assert
            Assert.IsTrue(result.IsSuccess);
            Assert.AreEqual(message, result.Message);
        }
コード例 #17
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                ProcessOrders p = new ProcessOrders();
                p.DecryptConfigSection("appSettings");
                p.DecryptConfigSection("connectionStrings");

                MessageBox.Show("Config file has been decrypted.");
            }catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            this.Cursor = Cursors.Default;
        }
コード例 #18
0
    // Main method where the execution begins
    public static void Main()
    {
        try
        {
            Console.WriteLine("Do you want to test fixed input or user input? Enter 1 for fixed system input, 2 for user input:");
            INPUT_TYPE inputType = (INPUT_TYPE)Convert.ToInt32(Console.ReadLine());
            if (inputType != INPUT_TYPE.SYSTEM && inputType != INPUT_TYPE.USER)
            {
                throw new Exception("Invalid input! Please enter either 1 or 2.");
            }

            List <Product> products = new List <Product>();
            if (inputType == INPUT_TYPE.SYSTEM)            // System input
            {
                Console.WriteLine("Which test case do you want to test? 1, 2, or 3?");

                int intTestCase = Convert.ToInt32(Console.ReadLine());
                if (intTestCase < 1 || intTestCase > 3)
                {
                    throw new Exception("Invalid test case! Please enter either 1, 2 or 3.");
                }

                products = GetFixedInput(intTestCase);
            }
            else             // User input
            {
                products = GetUserInput();
            }

            if (products.Count <= 0)
            {
                throw new Exception("Product list is empty. System is unable to process the orders and generate the invoice.");
            }

            ProcessOrders objProcessOrders = new ProcessOrders(products);
            Invoice       objInvoice       = objProcessOrders.Process();
            objInvoice.Print();
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }
    }
コード例 #19
0
        private static void ProcessPayment(int options)
        {
            int memberShipType = 0;
            var paymentType    = (PaymentType)Enum.Parse(typeof(PaymentType), options.ToString());

            if (options == 3 || options == 6)
            {
                paymentType    = (PaymentType)Enum.Parse(typeof(PaymentType), "3".ToString());
                memberShipType = options == 3 ? 1 : 2;
                var result      = ProcessOrders.GetPaymentMethod(paymentType);
                var sampleInput = SampleInput.GetSampleDataMember(memberShipType);

                if (result != null)
                {
                    var data = result.ProcessPayment(sampleInput);

                    Console.WriteLine($"Order of {paymentType.ToString()} and  {data.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
            else
            {
                IProcessOrder processor = ProcessOrders.GetPaymentMethod(paymentType);
                var           data      = SampleInput.GetSampleDataForOrder(paymentType);
                if (processor != null)
                {
                    var result = processor.ProcessPayment(data);

                    Console.WriteLine($"Order of {paymentType.ToString()} and  {result.Message}\n");
                }
                else
                {
                    Console.WriteLine("Invalid operation");
                }
            }
        }
コード例 #20
0
        private void DoPoll(object state)
        {
            bool started = false;

            try
            {
                if (Util.GetBoolean(Util.AppSettingValue("DebugMessages")))
                {
                    Log.LogError("Enter DoPoll", "OrderImportService.DoPoll");
                }

                if (!polling)
                {
                    started = true;
                    polling = true;

                    if (Util.GetBoolean(Util.AppSettingValue("DebugMessages")))
                    {
                        Log.LogError("Call ProcessOrders.Process()", "OrderImportService.DoPoll", 0);
                    }

                    ProcessOrders loPO      = new ProcessOrders();
                    string        lsMessage = "";
                    bool          lbResult  = loPO.Process(out lsMessage);
                    polling = false;
                }
            }
            catch (Exception ex)
            {
                Log.LogError(ex.ToString(), "OrderImportService.DoPoll", 0);
            }
            finally {
                if (started == true && polling == true)
                {
                    polling = false;
                }
            }
        }
コード例 #21
0
        /// <summary>
        /// This code demonstrates how to send 1 or more shipping/cancellation notifications to bol.com
        /// This code performs a simple POST on the "/services/rest/orders/v1/process/" PlazaAPI.
        /// See the example code below for typical usage instructions.
        /// </summary>
        /// <param name="plazaAPIClient">The plaza API client.</param>
        private static void ProcessOrders(PlazaAPIClient plazaAPIClient)
        {
            // Create a new batch. 
            // This is required before calling the method "PlazaAPIClient.ProcessOrders()"
            
            /*
            ProcessOrders processOrders = new ProcessOrders()
            {
                // Add a shipment
                Shipments = new ProcessOrdersShipment[1] { GenerateShipment() },

                // Add a cancellation
                Cancellations = new ProcessOrdersCancellation[1] { GenerateCancellation() }
            };
            */
            
            ProcessOrders processOrders = new ProcessOrders();

            // Create 5 random shipments
            processOrders.Shipments = new ProcessOrdersShipment[5];

            for (int i = 0; i < processOrders.Shipments.Length; i++)
            {
                processOrders.Shipments[i] = GenerateShipment();
            }

            // Create 5 random cancellations
            processOrders.Cancellations = new ProcessOrdersCancellation[5];

            for (int i = 0; i < processOrders.Cancellations.Length; i++)
            {
                processOrders.Cancellations[i] = GenerateCancellation();
            }

            // Done! Let's push this batch to the server.
            ProcessOrdersResult processOrdersResult = plazaAPIClient.ProcessOrders(processOrders);
        }
コード例 #22
0
        /// <summary>
        /// This code demonstrates how to send 1 or more shipping/cancellation notifications to bol.com
        /// This code performs a simple POST on the "/services/rest/orders/v1/process/" PlazaAPI.
        /// See the example code below for typical usage instructions.
        /// </summary>
        /// <param name="plazaAPIClient">The plaza API client.</param>
        private static void ProcessOrders(PlazaAPIClient plazaAPIClient)
        {
            // Create a new batch.
            // This is required before calling the method "PlazaAPIClient.ProcessOrders()"

            /*
             * ProcessOrders processOrders = new ProcessOrders()
             * {
             *  // Add a shipment
             *  Shipments = new ProcessOrdersShipment[1] { GenerateShipment() },
             *
             *  // Add a cancellation
             *  Cancellations = new ProcessOrdersCancellation[1] { GenerateCancellation() }
             * };
             */

            ProcessOrders processOrders = new ProcessOrders();

            // Create 5 random shipments
            processOrders.Shipments = new ProcessOrdersShipment[5];

            for (int i = 0; i < processOrders.Shipments.Length; i++)
            {
                processOrders.Shipments[i] = GenerateShipment();
            }

            // Create 5 random cancellations
            processOrders.Cancellations = new ProcessOrdersCancellation[5];

            for (int i = 0; i < processOrders.Cancellations.Length; i++)
            {
                processOrders.Cancellations[i] = GenerateCancellation();
            }

            // Done! Let's push this batch to the server.
            ProcessOrdersResult processOrdersResult = plazaAPIClient.ProcessOrders(processOrders);
        }
コード例 #23
0
        /// <summary>
        /// Process 1 or more shipping/cancellation notifications to bol.com
        /// The maximum number of shipments/cancellations in one request is 400.
        /// NOTE: After informing bol.com of shippings / cancellations through the API you may still see your orders as "open" in the seller dashboard.
        /// This has to do with system caches and queues.
        /// The API briefly caches the input it receives and the seller dashboard also has it's own cache to offload the core systems. 
        /// The most important feedback is the feedback one gets from the GetProcessStatus() method.
        /// </summary>
        /// <param name="processOrders">The process orders.</param>
        /// <returns>
        /// A ProcessOrdersResult object. This ProcessOrdersResult object was generated by a tool.
        /// The different elements are described on the following XML Schema Definition https://plazaapi.bol.com/services/xsd/plazaapiservice-v1.xsd
        /// </returns>
        public ProcessOrdersResult ProcessOrders(ProcessOrders processOrders)
        {
            HttpWebResponse response = null;
            ProcessOrdersResult results = null;

            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(_url + "/services/rest/orders/v1/process/");

                Utils.HandleRequest(request, C.RequestMethods.POST, _publicKey, _privateKey);

                using (Stream reqStream = request.GetRequestStream())
                {
                    XmlSerializer s = new XmlSerializer(typeof(ProcessOrders));
                    s.Serialize(reqStream, processOrders);
                }

                SigningRequest = Utils.StringToSign.Replace("\n", Environment.NewLine);
                response = (HttpWebResponse)request.GetResponse();

                if (HttpStatusCode.OK == response.StatusCode)
                {
                    XmlSerializer ser = new XmlSerializer(typeof(ProcessOrdersResult));
                    object obj = ser.Deserialize(response.GetResponseStream());
                    results = (ProcessOrdersResult)obj;

                    var json = new JavaScriptSerializer().Serialize(obj);
                    ResponseOutput = json;
                }
            }
            catch (WebException ex)
            {
                if (ex.Response != null)
                {
                    throw ExceptionHandler.HandleResponseException((HttpWebResponse)ex.Response);
                }
                else
                {
                    throw;
                }
            }
            finally
            {
                if (response != null)
                {
                    response.Close();
                }
            }

            return results;
        }