Esempio n. 1
0
        public void Transitions()
        {
            var initial = new OrderObjectStates(this.Session).Initial;
            var confirmed = new OrderObjectStates(this.Session).Confirmed;
            var cancelled = new OrderObjectStates(this.Session).Cancelled;

            var order = new OrderBuilder(this.Session).Build();

            this.Session.Derive(true);

            order.CurrentObjectState.ShouldBeNull();
            order.LastObjectState.ShouldBeNull();
            order.PreviousObjectState.ShouldBeNull();

            order.Amount = 10;
            order.CurrentObjectState = initial;

            this.Session.Derive(true);

            order.CurrentObjectState.ShouldEqual(initial);
            order.LastObjectState.ShouldEqual(initial);
            order.PreviousObjectState.ShouldBeNull();

            order.CurrentObjectState = confirmed;

            this.Session.Derive(true);

            order.CurrentObjectState.ShouldEqual(confirmed);
            order.LastObjectState.ShouldEqual(confirmed);
            order.PreviousObjectState.ShouldEqual(initial);

            order.Amount = 0;

            this.Session.Derive(true);

            order.CurrentObjectState.ShouldEqual(cancelled);
            order.LastObjectState.ShouldEqual(cancelled);
            order.PreviousObjectState.ShouldEqual(confirmed);
        }
Esempio n. 2
0
 public void order_items_should_not_be_zero_or_null()
 {
     Assert.Throws <ArgumentException>(() => OrderBuilder.New().WithItems(null).Build()).WithMessage(ExceptionMessage.DOMAIN_ORDER_ITEMS_INVALID);
 }
Esempio n. 3
0
 public void order_description_should_not_be_empty_or_null(string description)
 {
     Assert.Throws <ArgumentException>(() => OrderBuilder.New().WithDescription(description).Build()).WithMessage(ExceptionMessage.DOMAIN_ORDER_DESCRIPTION_INVALID);
 }
Esempio n. 4
0
        public void IsZeroForNewOrder()
        {
            var order = new OrderBuilder().WithNoItems();

            Assert.Equal(0, order.Total());
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            Order order = new Order();

            Product[] products = new Product[]
            {
                new Product("Helmet", 50.69f),
                new Product("Hammer", 15.30f),
                new Product("Nails", 5.00f)
            };

            var rng = new Random();

            // basic builder
            var orderBuilder = new OrderBuilder();

            orderBuilder.Number(100);
            orderBuilder.For(new Person("John", "Doe"));
            orderBuilder.ShipTo(new Address("Baker", 65, 28, "Los Angeles", "00-000"));
            foreach (var product in products)
            {
                orderBuilder.AddProduct(product, rng.Next(1, 10));
            }

            order = orderBuilder.Build();
            orderBuilder.Billing(new Address("Jefferson", 13, null, "New York", "11-111"));
            var order2 = orderBuilder.Build();

            Console.WriteLine(order);
            Console.WriteLine(order2);


            // fluent api builder
            var fluentBuilder = new FluentOrderBuilder();

            order = fluentBuilder
                    .Number(25)
                    .For(new Person("Jane", "Doe"))
                    .ShipTo(new Address("Baker", 65, 28, "Los Angeles", "00-000"))
                    .AddProduct(products[0], rng.Next(1, 10))
                    .AddProduct(products[1], rng.Next(1, 10))
                    .Build();

            Console.WriteLine(order);


            // inherited fluent builder
            var inheritedBuilder = Order.CreateBuilder();

            order = inheritedBuilder
                    .IsSpecial()
                    .Number(25)
                    .For(new Person("Jane", "Doe"))
                    .ShipTo(new Address("Baker", 65, 28, "Los Angeles", "00-000"))
                    .AddProduct(products[0], rng.Next(1, 10))
                    .AddProduct(products[1], rng.Next(1, 10))
                    .Build();

            Console.WriteLine(order);


            // functional builder
            var funcBuilder = new FunctionalOrderBuilder();

            order = funcBuilder
                    .Number(911)
                    .Do(o => o.SpecialOrder = true)
                    .Build();

            Console.WriteLine(order);
        }
 public WebServiceRowFormatter(OrderBuilder <T> order, bool useIncVatRequestIfPossible)
 {
     _order = order;
     _useIncVatRequestIfPossible = useIncVatRequestIfPossible;
 }
Esempio n. 7
0
 public CustomerOrderEditorSubMenu(ref OrderBuilder orderBuilder, ref IRepository repo) : base(ref repo)
 {
     Log.Logger.Information("Instantiated Customer Order Editor Submenu.");
     OrderBuilder = orderBuilder;
 }
Esempio n. 8
0
 public void Should_Not_Create_An_Order_Without_OrderItems()
 {
     Assert.Throws <DomainException>(() => OrderBuilder.New().WithOrderItems(null).Build()).WithMessage("OrderItems is required");
 }
        public async Task GivenTheOrderIsCompleteEnoughSoThatTheCompleteOrderButtonIsEnabled(string fsValue)
        {
            bool fs = fsValue.ToLower() == "yes";

            await new CommonSteps(Test, Context).GivenAnIncompleteOrderExists();

            var order = Context.Get <Order>(ContextKeys.CreatedOrder);

            var supplier = await DbContext.Supplier.SingleOrDefaultAsync(s => s.Id == "100000")
                           ?? (await SupplierInfo.GetSupplierWithId("100000", Test.BapiConnectionString)).ToDomain();

            var orderBuilder = new OrderBuilder(order)
                               .WithExistingSupplier(supplier)
                               .WithSupplierContact(ContactHelper.Generate())
                               .WithCommencementDate(DateTime.Today)
                               .WithOrderingPartyContact(ContactHelper.Generate())
                               .WithFundingSource(fs);

            var associatedServices = await SupplierInfo.GetPublishedCatalogueItemsNoTieredAsync(Test.BapiConnectionString, supplier.Id, CatalogueItemType.AssociatedService);

            var selectedItem = associatedServices.First();

            var catalogueItem = await DbContext.FindAsync <CatalogueItem>(CatalogueItemId.ParseExact(selectedItem.CatalogueItemId))
                                ?? selectedItem.ToDomain();

            var pricingUnitName = "per banana";

            var pricingUnit = await DbContext.FindAsync <PricingUnit>(pricingUnitName) ?? new PricingUnit
            {
                Name = pricingUnitName,
            };

            pricingUnit.Description = pricingUnitName;

            var recipients = new List <OrderItemRecipient>();

            var recipient = await DbContext.ServiceRecipient.SingleOrDefaultAsync(s => s.OdsCode == order.OrderingParty.OdsCode)
                            ?? new ServiceRecipient(order.OrderingParty.OdsCode, order.OrderingParty.Name);

            var orderItemRecipient = new OrderItemRecipient()
            {
                Recipient    = recipient,
                DeliveryDate = DateTime.UtcNow,
                Quantity     = 1,
            };

            recipients.Add(orderItemRecipient);

            var orderItem = new OrderItemBuilder(order.Id)
                            .WithCatalogueItem(catalogueItem)
                            .WithCataloguePriceType(CataloguePriceType.Flat)
                            .WithCurrencyCode()
                            .WithDefaultDeliveryDate(DateTime.Today)
                            .WithPrice(0.01M)
                            .WithPricingTimeUnit(TimeUnit.PerMonth)
                            .WithProvisioningType(ProvisioningType.Declarative)
                            .WithPricingUnit(pricingUnit)
                            .WithRecipients(recipients)
                            .Build();

            order.AddOrUpdateOrderItem(orderItem);

            await OrderProgressHelper.SetProgress(
                context : DbContext,
                order : order,
                catalogueSolutionsViewed : true,
                additionalServicesViewed : true,
                associatedServicesViewed : true);

            DbContext.Update(order);

            await DbContext.SaveChangesAsync();

            Context.Remove(ContextKeys.CreatedOrder);
            Context.Add(ContextKeys.CreatedOrder, order);

            Test.Driver.Navigate().Refresh();
        }
 public WeightBasedCalculatorTests()
 {
     _orderBuilder     = new OrderBuilder();
     _orderItemBuilder = new OrderItemBuilder();
 }
Esempio n. 11
0
        public static void MenuBuildOrder(OrderBuilder ob)
        {
            string input    = "";
            bool   exitMenu = false;

            do
            {
                if (ob.GetPizzas().Count == 0)
                {
                    Console.WriteLine("Your order is currently empty.");
                }
                else
                {
                    Console.WriteLine("Your current order:");
                    Console.WriteLine($"Order Prpared for username: {ob.CurOrder.UserID}");
                    Console.WriteLine($"Order location: {ob.CurOrder.Store}");
                    PrintPizzaList(ob.CurOrder.Pizzas);
                    Console.WriteLine($"---------------------\n   Total Price: ${ob.CurOrder.Price.ToString("F")}\n");
                }

                Console.WriteLine("Please enter the number for your selection");
                Console.WriteLine("1: Add a new pizza to order");
                Console.WriteLine("2: Duplicate a pizza already in your order");
                Console.WriteLine("3: Modify a pizza in your order");
                Console.WriteLine("4: Remove a pizza from your order");
                Console.WriteLine("5: Change location");
                Console.WriteLine("6: Place order");
                Console.WriteLine("0: Cancel order");
                Console.Write("->");
                input = Console.ReadLine();
                switch (input)
                {
                case "1":      //add new pizza
                    MenuAddNewPizza(ob);
                    break;

                case "2":      // duplicate pizza
                    MenuDuplicatePizza(ob);
                    break;

                case "3":      //modify pizza
                    MenuModifyExistingPizza(ob);
                    break;

                case "4":      //remove pizza from order
                    MenuRemovePizza(ob);
                    break;

                case "5":      //change location
                    MenuChangeLocation(ob);
                    break;

                case "6":      //(attempt to) place order
                    if (MenuFinalizeOrder(ob))
                    {
                        exitMenu = true;
                    }
                    break;

                case "0":     //Go back
                    exitMenu = true;
                    break;

                default:      //Invalid Input
                    Console.WriteLine("Input invalid.  Please try again.");
                    break;
                }
            }while (!exitMenu);
        }
Esempio n. 12
0
        public void placeOrder(OrderDirections directions)
        {
            cancelOrder();
              cache = new OrderCache(app);
              this.directions = directions;
              OrderBuilder bld = new OrderBuilder(cache);
              state = State.ConnectionPending;
              using (OrderWatcher watch = new OrderWatcher(cache, bld.OrderTag)) {
            cache.Start();
            while (state != State.ConnectionDead && state != State.OrderFinished) {
              if (!WaitAny(10000, watch.WaitHandles) ) {
            WriteLine("TIMED OUT WaitAny(10000) WAITING FOR RESPONSE");
            break;
              }
              OrderWatcher.Action action;
              while (watch.GetNext(out action, out ord)) {
            switch (action) {
            case OrderWatcher.Action.Live:
              if (state == State.ConnectionPending) {
            WriteLine("SUBMITTING ORDER");
            state = State.OrderPending;
            bld.SetAccount(Configuration.getValue("Configuration/Account/Bank"),
                   Configuration.getValue("Configuration/Account/Branch"),
                   Configuration.getValue("Configuration/Account/Customer"),
                   Configuration.getValue("Configuration/Account/Deposit"));
            bld.SetBuySell(OrderBuilder.BuySell.BUY);
            bld.SetExpiration(OrderBuilder.Expiration.DAY);
            bld.SetRoute(directions.Route);
            bld.SetSymbol(directions.Symbol, getExchange(directions), OrderBuilder.SecurityType.STOCKOPT);
            bld.SetVolume(directions.Size);
            bld.SetPriceLimit(directions.LimitPrice);
            if (directions.Simulated) {
              WriteLine("Am sending simulated order");
            }
            else {
              WriteLine("Am sending real order");
              cache.SubmitOrder(bld);
            }
              }
              break;
            case OrderWatcher.Action.Dead:
              WriteLine("CONNECTION FAILED");
              state = State.ConnectionDead;
              break;
            case OrderWatcher.Action.Order:
              DisplayOrder(ord);
              if( state==State.OrderPending && ord.Type=="UserSubmitOrder" ) {
            if( ord.CurrentStatus=="COMPLETED") {
            WriteLine("Order Completed");
            state = State.OrderFinished;
            }
            else {
              WriteLine("Order UNEXPECTEDLY FINISHED" );
              state = State.OrderFinished;
            }
              }
              else if (state == State.CancelPending) {
            if( ord.CurrentStatus=="COMPLETED" || ord.CurrentStatus=="DELETED" )
              state = State.OrderFinished;
              }

              if (ord.Type == "ExchangeTradeOrder")
            WriteLine("GOT FILL FOR {0} {1} AT {2}", ord.Buyorsell, ord.Volume, ord.Price);
              if (ord.Type == "ExchangeKillOrder")
            WriteLine("GOT KILL");

              break;
            } // end switch
              } // end while getNext
            } // end while state
              } // end using watch
              WriteLine("DONE PLACING ORDER");
        }
Esempio n. 13
0
        /// <summary>
        /// Install plugin
        /// </summary>
        public override async Task Install()
        {
            //Create index
            await _databaseContext.CreateIndex(_pictureSliderRepository, OrderBuilder <PictureSlider> .Create().Ascending(x => x.SliderTypeId).Ascending(x => x.DisplayOrder), "SliderTypeId_DisplayOrder");

            //pictures
            var sampleImagesPath = CommonPath.MapPath("Plugins/Widgets.Slider/Assets/slider/sample-images/");
            var byte1            = File.ReadAllBytes(sampleImagesPath + "banner1.png");
            var byte2            = File.ReadAllBytes(sampleImagesPath + "banner2.png");

            var pictureSlider1 = new PictureSlider()
            {
                DisplayOrder = 0,
                Link         = "",
                Name         = "Sample slider 1",
                FullWidth    = true,
                Published    = true,
                Description  = "<div class=\"row slideRow justify-content-start\"><div class=\"col-lg-6 d-flex flex-column justify-content-center align-items-center\"><div><div class=\"animate-top animate__animated animate__backInDown\" >exclusive - modern - elegant</div><div class=\"animate-center-title animate__animated animate__backInLeft animate__delay-05s\">Smart watches</div><div class=\"animate-center-content animate__animated animate__backInLeft animate__delay-1s\">Go to collection and see more...</div><a href=\"/smartwatches\" class=\"animate-bottom btn btn-info animate__animated animate__backInUp animate__delay-15s\"> SHOP NOW </a></div></div></div>"
            };

            var pic1 = await _pictureService.InsertPicture(byte1, "image/png", "banner_1", reference : Grand.Domain.Common.Reference.Widget, objectId : pictureSlider1.Id, validateBinary : false);

            pictureSlider1.PictureId = pic1.Id;
            await _pictureSliderRepository.InsertAsync(pictureSlider1);


            var pictureSlider2 = new PictureSlider()
            {
                DisplayOrder = 1,
                Link         = "https://grandnode.com",
                Name         = "Sample slider 2",
                FullWidth    = true,
                Published    = true,
                Description  = "<div class=\"row slideRow\"><div class=\"col-md-6 offset-md-6 col-12 offset-0 d-flex flex-column justify-content-center align-items-start px-0 pr-md-3\"><div class=\"slide-title text-dark animate__animated animate__fadeInRight animate__delay-05s\"><h2 class=\"mt-0\">Redmi Note 9</h2></div><div class=\"slide-content animate__animated animate__fadeInRight animate__delay-1s\"><p class=\"mb-0\"><span>Equipped with a high-performance octa-core processor <br/> with a maximum clock frequency of 2.0 GHz.</span></p></div><div class=\"slide-price animate__animated animate__fadeInRight animate__delay-15s d-inline-flex align-items-center justify-content-start w-100 mt-2\"><p class=\"actual\">$249.00</p><p class=\"old-price\">$399.00</p></div><div class=\"slide-button animate__animated animate__fadeInRight animate__delay-2s mt-3\"><a class=\"btn btn-outline-info\" href=\"/redmi-note-9\">BUY REDMI NOTE 9</a></div></div></div>",
            };
            var pic2 = await _pictureService.InsertPicture(byte2, "image/png", "banner_2", reference : Grand.Domain.Common.Reference.Widget, objectId : pictureSlider2.Id, validateBinary : false);

            pictureSlider2.PictureId = pic2.Id;

            await _pictureSliderRepository.InsertAsync(pictureSlider2);

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.DisplayOrder", "Display order");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.LimitedToGroups", "Limited to groups");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.LimitedToStores", "Limited to stores");


            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FriendlyName", "Widget Slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Added", "Slider added");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Addnew", "Add new slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.AvailableStores", "Available stores");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.AvailableStores.Hint", "Select stores for which the slider will be shown.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Backtolist", "Back to list");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category", "Category");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category.Hint", "Select the category where slider should appear.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Category.Required", "Category is required");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Description", "Description");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Description.Hint", "Enter the description of the slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder", "Display Order");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.DisplayOrder.Hint", "The slider display order. 1 represents the first item in the list.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edit", "Edit slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Edited", "Slider edited");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Displayorder", "Display Order");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Link", "Link");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.ObjectType", "Slider type");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Picture", "Picture");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Published", "Published");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Fields.Title", "Title");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FullWidth", "Full width");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.FullWidth.hint", "Full width");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Info", "Info");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores", "Limited to stores");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.LimitedToStores.Hint", "Determines whether the slider is available only at certain stores.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link", "URL");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Link.Hint", "Enter URL. Leave empty if you don't want this picture to be clickable.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Manage", "Manage Bootstrap Slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection", "Collection");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection.Hint", "Select the collection where slider should appear.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Collection.Required", "Collection is required");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand", "Brand");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand.Hint", "Select the brand where slider should appear.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Brand.Required", "Brand is required");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name", "Name");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name.Hint", "Enter the name of the slider");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Name.Required", "Name is required");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Picture", "Picture");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Picture.Required", "Picture is required");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Published", "Published");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Published.Hint", "Specify it should be visible or not");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.SliderType", "Slider type");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.SliderType.Hint", "Choose the slider type. Home page, category or collection page.");

            await this.AddOrUpdatePluginTranslateResource(_translationService, _languageService, "Widgets.Slider.Stores", "Stores");


            await base.Install();
        }
Esempio n. 14
0
        public static void Run(ILogger logger)
        {
            OnlineClient client = Bootstrap.Client(logger);

            List <IFilter> filterList = new List <IFilter>();

            filterList.Add((new Filter("CUSTOMERID")).SetLike("c%"));
            filterList.Add((new Filter("CUSTOMERID")).SetLike("1%"));
            OrOperator filter = new OrOperator(filterList);

            OrderBuilder orderBuilder = new OrderBuilder();

            IOrder[] orders = orderBuilder.Descending("CUSTOMERID").GetOrders();

            SelectBuilder selectBuilder = new SelectBuilder();

            ISelect[] fields = selectBuilder.
                               Fields(new[] { "CUSTOMERID", "CUSTOMERNAME" }).
                               Sum("TOTALDUE").
                               GetFields();

            QueryFunction query = new QueryFunction()
            {
                SelectFields    = fields,
                FromObject      = "ARINVOICE",
                Filter          = filter,
                CaseInsensitive = true,
                PageSize        = 100,
                OrderBy         = orders
            };

            logger.LogInformation("Executing query to Intacct API");

            Task <OnlineResponse> task = client.Execute(query);

            task.Wait();
            OnlineResponse response = task.Result;
            Result         result   = response.Results[0];

            dynamic json = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(result.Data));

            if (json != null && json.First != null)
            {
                Console.WriteLine("Success! Number of ARINVOICE objects found: " + result.TotalCount);
                Console.WriteLine("First ARINVOICE result found");
                Console.WriteLine("CUSTOMERID: " + json.First["ARINVOICE"]["CUSTOMERID"].Value);
                Console.WriteLine("CUSTOMERNAME: " + json.First["ARINVOICE"]["CUSTOMERNAME"].Value);
                Console.WriteLine("SUM.TOTALDUE: " + json.First["ARINVOICE"]["SUM.TOTALDUE"].Value);

                Console.WriteLine("See the log file (logs/intacct.log) for the complete list of results.");
            }
            else
            {
                Console.WriteLine("The query executed, but no ARINVOICE objects met the query criteria.");
                Console.WriteLine("Either modify the filter or comment it out from the query.");
                Console.WriteLine("See the log file (logs/intacct.log) for the XML request.");
            }

            try
            {
                string jsonString = json.ToString();

                logger.LogDebug(
                    "Query successful [ Company ID={0}, User ID={1}, Request control ID={2}, Function control ID={3}, Total count={4}, Data={5} ]",
                    response.Authentication.CompanyId,
                    response.Authentication.UserId,
                    response.Control.ControlId,
                    result.ControlId,
                    result.TotalCount,
                    jsonString
                    );
            }
            catch (NullReferenceException e)
            {
                logger.LogDebug("No response in Data. {0}", e);
            }
            finally
            {
                LogManager.Flush();
            }
        }
 public static Order ConvertToOrder(OrderBuilder <T> orderBuilder)
 {
     return(new Order(orderBuilder));
 }
Esempio n. 16
0
 public MinimumCollectibleConstraintTests()
 {
     _orderBuilder     = new OrderBuilder();
     _orderItemBuilder = new OrderItemBuilder();
 }
 public void ShouldOrderWithoutClient_ThrowException()
 {
     _orderBuilder = new OrderBuilder();
     _orderBuilder.SetSalad(_salad).Build();
 }
Esempio n. 18
0
        public void Should_Not_Add_A_New_OrderItem_When_It_Is_Null()
        {
            var order = OrderBuilder.New().WithOrderItems(listOfOrderItems).Build();

            Assert.Throws <DomainException>(() => order.AddOrderItem(null)).WithMessage("OrderItem cannot be null");
        }
 public void ShouldOrderWithoutFood_ThrowException()
 {
     _orderBuilder = new OrderBuilder();
     _orderBuilder.SetClient(_client).Build();
 }
Esempio n. 20
0
        void _bw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            while (_bwgo)
            {
                bool newsym = false;
                while (!_newsyms.isEmpty)
                {
                    _newsyms.Read();
                    newsym = true;
                }
                if (newsym)
                {
                    // get symbols
                    _numDisplayed = 0;
                    _numIgnored   = 0;
                    debug("Subscribe request: " + _newsymlist);
                    if (!isConnected)
                    {
                        debug("not connected.");
                        return;
                    }

                    Basket b = BasketImpl.FromString(_newsymlist);
                    foreach (Security s in b)
                    {
                        try
                        {
                            TBL.WantData(TBL.TqlForBidAskTrade(s.Symbol, null), true, true);
                            TBL.Start();
                            //TT.WantData(TBL.TqlForBidAskTrade(s.Symbol, null), true, true);
                            //TT.Start();
                            _done.WaitOne(30000);
                        }
                        catch (Exception ex)
                        {
                            debug(s.Symbol + " error subscribing: " + ex.Message + ex.StackTrace);
                        }
                    }
                    debug(string.Format("DISPLAYED {0} TRADES AND IGNORED {1} QUOTES", _numDisplayed, _numIgnored));
                    debug("DONE.");
                    debug("registered: " + _newsymlist);
                }
                while (!_neworders.isEmpty)
                {
                    Order o  = _neworders.Read();
                    var   ob = new OrderBuilder(_oc);
                    ob.SetAccount(null, o.Account, null, null);
                    ob.SetBuySell(o.side ? OrderBuilder.BuySell.BUY : OrderBuilder.BuySell.SELL);
                    ob.SetExpiration(OrderBuilder.Expiration.DAY);
                    ob.SetRoute("NYS");
                    ob.SetSymbol(o.symbol, o.Exchange, OrderBuilder.SecurityType.STOCK);
                    if (o.size != 0)
                    {
                        ob.SetVolume(Math.Abs(o.size));
                    }
                    if (o.isMarket)
                    {
                        ob.SetPriceMarket();
                    }
                    if (o.isLimit)
                    {
                        ob.SetPriceLimit(new Price(o.price.ToString()));
                    }
                    if (o.isStop)
                    {
                        ob.SetPriceLimit(new Price(o.price.ToString()));
                    }
                    // ob.SetGoodFrom(DateTime.Now.AddMinutes(60));
                    currentOrderId = o.id;
                    state          = OrderState.OrderPending;
                    _oc.SubmitOrder(ob);
                }
                while (!_newcancel.isEmpty)
                {
                    long id = _newcancel.Read();
                    if (_orSet.ContainsKey(id))
                    {
                        var cxl = new CancelBuilder(_orSet[id]);
                        try
                        {
                            _oc.SubmitCancel(cxl);
                        }
                        catch (Exception ee)
                        {
                            debug("ORDER CANCEL FAILED:" + ee.Message);
                        }

                        state = OrderState.CancelPending;
                        debug("ORDER CANCEL FINISHED");
                    }
                    else
                    {
                        debug("ORDER CANCEL FAILED, NOT EXIST THE Order.Id:" + id);
                    }
                }
                if (_newcancel.isEmpty && _neworders.isEmpty && _newsyms.isEmpty)
                {
                    Thread.Sleep(_SLEEP);
                }
            }
        }
Esempio n. 21
0
 public Order(OrderBuilder orderBuilder)
     : base(orderBuilder.Id)
 {
     OrderItems = orderBuilder.OrderItems;
     CustomerId = orderBuilder.CustomerId;
 }
Esempio n. 22
0
 public void TestInitialize()
 {
     _service             = new Service();
     _service.ServiceType = new ServiceType();
     _service.Order       = OrderBuilder.New(1).FirstOrDefault();
 }
Esempio n. 23
0
 /// <summary>
 /// 清理排序及查询条件
 /// </summary>
 public void Clear()
 {
     Criteria     = null;
     OrderBuilder = new OrderBuilder();
 }
Esempio n. 24
0
 public WebServiceRowFormatter(OrderBuilder <T> order)
 {
     _order = order;
 }
 /// <summary>
 /// Dodawanie własnych zależności do komendy.
 /// </summary>
 /// <param name="container">Kontener IoC</param>
 public override void SetupDependencies(IWindsorContainer container)
 {
     orderBuilder = container.Resolve <OrderBuilder>();
 }
 protected override void Establish_context()
 {
     _order = OrderBuilder.CreateOrderWithProductsForState("MI");
 }
Esempio n. 27
0
        public void placeOrder(OrderDirections directions)
        {
            cancelOrder();
            cache           = new OrderCache(app);
            this.directions = directions;
            OrderBuilder bld = new OrderBuilder(cache);

            state = State.ConnectionPending;
            using (OrderWatcher watch = new OrderWatcher(cache, bld.OrderTag)) {
                cache.Start();
                while (state != State.ConnectionDead && state != State.OrderFinished)
                {
                    if (!WaitAny(10000, watch.WaitHandles))
                    {
                        WriteLine("TIMED OUT WaitAny(10000) WAITING FOR RESPONSE");
                        break;
                    }
                    OrderWatcher.Action action;
                    while (watch.GetNext(out action, out ord))
                    {
                        switch (action)
                        {
                        case OrderWatcher.Action.Live:
                            if (state == State.ConnectionPending)
                            {
                                WriteLine("SUBMITTING ORDER");
                                state = State.OrderPending;
                                bld.SetAccount(Configuration.getValue("Configuration/Account/Bank"),
                                               Configuration.getValue("Configuration/Account/Branch"),
                                               Configuration.getValue("Configuration/Account/Customer"),
                                               Configuration.getValue("Configuration/Account/Deposit"));
                                bld.SetBuySell(OrderBuilder.BuySell.BUY);
                                bld.SetExpiration(OrderBuilder.Expiration.DAY);
                                bld.SetRoute(directions.Route);
                                bld.SetSymbol(directions.Symbol, getExchange(directions), OrderBuilder.SecurityType.STOCKOPT);
                                bld.SetVolume(directions.Size);
                                bld.SetPriceLimit(directions.LimitPrice);
                                if (directions.Simulated)
                                {
                                    WriteLine("Am sending simulated order");
                                }
                                else
                                {
                                    WriteLine("Am sending real order");
                                    cache.SubmitOrder(bld);
                                }
                            }
                            break;

                        case OrderWatcher.Action.Dead:
                            WriteLine("CONNECTION FAILED");
                            state = State.ConnectionDead;
                            break;

                        case OrderWatcher.Action.Order:
                            DisplayOrder(ord);
                            if (state == State.OrderPending && ord.Type == "UserSubmitOrder")
                            {
                                if (ord.CurrentStatus == "COMPLETED")
                                {
                                    WriteLine("Order Completed");
                                    state = State.OrderFinished;
                                }
                                else
                                {
                                    WriteLine("Order UNEXPECTEDLY FINISHED");
                                    state = State.OrderFinished;
                                }
                            }
                            else if (state == State.CancelPending)
                            {
                                if (ord.CurrentStatus == "COMPLETED" || ord.CurrentStatus == "DELETED")
                                {
                                    state = State.OrderFinished;
                                }
                            }

                            if (ord.Type == "ExchangeTradeOrder")
                            {
                                WriteLine("GOT FILL FOR {0} {1} AT {2}", ord.Buyorsell, ord.Volume, ord.Price);
                            }
                            if (ord.Type == "ExchangeKillOrder")
                            {
                                WriteLine("GOT KILL");
                            }

                            break;
                        } // end switch
                    }     // end while getNext
                }         // end while state
            }             // end using watch
            WriteLine("DONE PLACING ORDER");
        }
Esempio n. 28
0
 public void order_customer_id_should_not_be_zero_or_null_or_less_than_zero(int customerId)
 {
     Assert.Throws <ArgumentException>(() => OrderBuilder.New().WithCustomerId(customerId).Build()).WithMessage(ExceptionMessage.DOMAIN_ORDER_CUSTOMER_ID_INVALID);
 }
        public static void AddOrUpdateOrderItem_NullOrderItem_ThrowsArgumentNullException()
        {
            var order = OrderBuilder.Create().Build();

            Assert.Throws <ArgumentNullException>(() => order.AddOrUpdateOrderItem(null));
        }
 public MinimumPayableConstraintTests()
 {
     _orderBuilder     = new OrderBuilder();
     _orderItemBuilder = new OrderItemBuilder();
 }
Esempio n. 31
0
        void _bw_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            while (_bwgo)
            {
                bool newsym = false;
                while (!_newsyms.isEmpty)
                {
                    _newsyms.Read();
                    newsym = true;
                }
                if (newsym)
                {
                    // get symbols
                    _numDisplayed = 0;
                    _numIgnored = 0;
                    debug("Subscribe request: " + _newsymlist);
                    if (!isConnected)
                    {
                        debug("not connected.");
                        return;
                    }

                    Basket b = BasketImpl.FromString(_newsymlist);
                    foreach (Security s in b)
                    {
                        try
                        {
                            TBL.WantData(TBL.TqlForBidAskTrade(s.Symbol, null), true, true);
                            TBL.Start();
                            //TT.WantData(TBL.TqlForBidAskTrade(s.Symbol, null), true, true);
                            //TT.Start();
                            _done.WaitOne(30000);
                        }
                        catch (Exception ex)
                        {
                            debug(s.Symbol + " error subscribing: " + ex.Message + ex.StackTrace);
                        }
                    }
                    debug(string.Format("DISPLAYED {0} TRADES AND IGNORED {1} QUOTES", _numDisplayed, _numIgnored));
                    debug("DONE.");
                    debug("registered: " + _newsymlist);
                }
                while (!_neworders.isEmpty)
                {
                    Order o = _neworders.Read();
                    var ob = new OrderBuilder(_oc);
                    ob.SetAccount(null, o.Account, null, null);
                    ob.SetBuySell(o.side ? OrderBuilder.BuySell.BUY : OrderBuilder.BuySell.SELL);
                    ob.SetExpiration(OrderBuilder.Expiration.DAY);
                    ob.SetRoute("NYS");
                    ob.SetSymbol(o.symbol, o.Exchange, OrderBuilder.SecurityType.STOCK);
                    if (o.size != 0)
                        ob.SetVolume(Math.Abs(o.size));
                    if (o.isMarket)
                    {
                        ob.SetPriceMarket();
                    }
                    if (o.isLimit)
                    {
                        ob.SetPriceLimit(new Price(o.price.ToString()));
                    }
                    if (o.isStop)
                    {
                        ob.SetPriceLimit(new Price(o.price.ToString()));
                    }
                    // ob.SetGoodFrom(DateTime.Now.AddMinutes(60));
                    currentOrderId = o.id;
                    state = OrderState.OrderPending;
                    _oc.SubmitOrder(ob);
                }
                while (!_newcancel.isEmpty)
                {
                    long id = _newcancel.Read();
                    if (_orSet.ContainsKey(id))
                    {
                        var cxl = new CancelBuilder(_orSet[id]);
                        try
                        {
                            _oc.SubmitCancel(cxl);
                        }
                        catch (Exception ee)
                        {
                            debug("ORDER CANCEL FAILED:" + ee.Message);
                        }

                        state = OrderState.CancelPending;
                        debug("ORDER CANCEL FINISHED");

                    }
                    else
                    {
                        debug("ORDER CANCEL FAILED, NOT EXIST THE Order.Id:" + id);
                    }

                }
                if (_newcancel.isEmpty && _neworders.isEmpty && _newsyms.isEmpty)
                    Thread.Sleep(_SLEEP);
            }
        }
 public WebServiceRowFormatter(OrderBuilder <T> order) : this(order, true)
 {
 }
Esempio n. 33
0
 public void Should_Not_Create_An_Order_Without_CustomerId()
 {
     Assert.Throws <DomainException>(() => OrderBuilder.New().WithCustomerId(0).Build()).WithMessage("Customer is required");
 }