protected override void OnViewLoaded()
        {
            _Cars = new ObservableCollection <Car>();

            try
            {
                WithClient <IInventoryService>(_ServiceFactory.CreateClient <IInventoryService>(), inventoryClient =>
                {
                    Car[] cars = inventoryClient.GetAllCars();

                    if (cars != null)
                    {
                        foreach (Car car in cars)
                        {
                            _Cars.Add(car);
                        }
                    }
                });
            }
            catch (FaultException ex)
            {
                if (ErrorOccured != null)
                {
                    ErrorOccured(this, new ErrorMessageEventArgs(ex.Message));
                }
            }
            catch (Exception ex)
            {
                if (ErrorOccured != null)
                {
                    ErrorOccured(this, new ErrorMessageEventArgs(ex.Message));
                }
            }
        }
Exemple #2
0
        private void GetOrders()
        {
            //if (!string.IsNullOrWhiteSpace(SearchTerm))
            //{
            IsBusy = true;
            IOrderService order_service = service_factory.CreateClient <IOrderService>();

            using (order_service)
            {
                try
                {
                    //Orders = new ObservableCollection<Order>(order_service.FindOrdersByCompany((Company)CurrentCompany, SearchTerm));
                    var account = SelectedAccount as Account;
                    if (account != null)
                    {
                        Orders = new ObservableCollection <Order>(order_service.GetInvoicableOrdersByAccount(CurrentCompanyKey, account.AccountKey));

                        MessageToDisplay = Orders.Count.ToString() + " order(s) found";
                    }
                }
                catch (Exception ex)
                {
                    MessageToDisplay = ex.Message;
                    IsBusy           = false;
                    return;
                }
            }
            //}
            //else
            //{
            //    MessageToDisplay = "You must enter a search term in order to find an... order?";
            //}
            IsBusy = false;
        }
        public async void ValidateAddress(AddressWrapper which_address)
        {
            IAddressService addr_service = service_factory.CreateClient <IAddressService>();

            using (addr_service)
            {
                try
                {
                    Task <AddressPostal> task = addr_service.GetAddressInfoByPostalAsync(which_address.AddressPostalCode);
                    await         task;
                    AddressPostal postal_info = task.Result;

                    if (postal_info != null)
                    {
                        which_address.AddressCity    = postal_info.CityName;
                        which_address.AddressState   = postal_info.StateCode;
                        which_address.AddressCounty  = postal_info.CountyName;
                        which_address.AddressCountry = postal_info.CountryName;
                    }
                    else
                    {
                        event_aggregator.GetEvent <AccountUpdatedEvent>().Publish("Postal code not found");
                    }
                }
                catch (Exception ex)
                {
                    event_aggregator.GetEvent <AccountUpdatedEvent>().Publish(ex.Message);
                    return;
                }
            }
        }
        private void GetCompanyOpenOrders()
        {
            var proxy   = service_factory.CreateClient <IOrderService>();
            var company = new Company()
            {
                CompanyKey = CurrentCompanyKey
            };
            var open_order_col = new ObservableCollection <OrderWrapper>();

            using (proxy)
            {
                //Task<List<Order>> orders = proxy.GetOrdersByCompanyAsync(company);
                var orders = proxy.GetOrdersByCompany(company);
                //await orders;

                foreach (var order in orders)
                {
                    var id = new QIQODate()
                    {
                        Date            = (DateTime)order.DeliverByDate,
                        EntityType      = "Account",
                        EntityName      = order.Account.AccountName,
                        BackgroundBrush = Brushes.LightGreen,
                        DateDescription = $"Due Date\nOrder: {order.OrderNumber}",
                        DateType        = QIQODateType.OrderDeliverByDate,
                        FontWeight      = FontWeights.Bold
                    };

                    _working_days.Add(id);
                }
            }
        }
Exemple #5
0
        private void GenEmployeeCode()
        {
            // TODO: add code to go get an employee code that doesn't already exist!
            var account_service = service_factory.CreateClient <ICompanyService>();

            CurrentEmployee.PersonCode = account_service.GetCompanyNextNumber((Company)CurrentCompany, QIQOEntityNumberType.EmployeeNumber);
            account_service.Dispose();
        }
        private void RemoveAccount(Guid accountid)
        {
            var accountSvc = _serviceFactory.CreateClient <IAccountService>();

            accountSvc.DeleteAccount(accountid);
            RefreshViewModelAccounts();
            _view.BindForm();
        }
Exemple #7
0
        public IEnumerable <LookupItem> GetProjectLookupAsync()
        {
            WithClient <IProjectService>(_serviceFactory.CreateClient <IProjectService>(), projectClient =>
            {
                _projects = projectClient.GetProjectLookup();
            });

            return(_projects);
        }
Exemple #8
0
        private void OnRecalculateCostsForAssemblyCommand(string partId)
        {
            //ToDo refactor this to accept parameter as int
            int intPartId = Int32.Parse(partId);

            WithClient(_serviceFactory.CreateClient <IPartService>(), partClient =>
            {
                partClient.RecalculateCostsForAssembly(intPartId);
            });
        }
        protected override void OnViewLoaded()
        {
            _Rentals = new ObservableCollection <CustomerRentalData>();

            WithClient <IRentalService>(_ServiceFactory.CreateClient <IRentalService>(), rentalClient =>
            {
                CustomerRentalData[] rentals = rentalClient.GetCurrentRentals();
                if (rentals != null)
                {
                    // convert returned data into observable collection so binding can refresh automatically
                    Rentals.Merge(rentals);
                }
            });
        }
Exemple #10
0
        private void OnDeleteCarCommand(Car obj)
        {
            bool carIsRented = false;

            WithClient <IRentalService>(_ServiceFactory.CreateClient <IRentalService>(), rentalClient => {
                carIsRented = rentalClient.IsCarCurrentlyRented(obj.CarId);
            });
            if (!carIsRented)
            {
                CancelEventArgs args = new CancelEventArgs();
                if (ConfirmDelete != null)
                {
                    ConfirmDelete(this, args);
                }
                if (!args.Cancel)
                {
                    try
                    {
                        WithClient <IInventoryService>(_ServiceFactory.CreateClient <IInventoryService>(), inventoryClient =>
                        {
                            inventoryClient.DeleteCar(obj.CarId);
                            _Cars.Remove(obj);
                        });
                    }
                    catch (FaultException e)
                    {
                        if (ErrorOccured != null)
                        {
                            ErrorOccured(this, new ErrorMessageEventArgs(e.Message));
                        }
                    }
                    catch (Exception e)
                    {
                        if (ErrorOccured != null)
                        {
                            ErrorOccured(this, new ErrorMessageEventArgs(e.Message));
                        }
                    }
                }
                else
                {
                    if (ErrorOccured != null)
                    {
                        ErrorOccured(this, new ErrorMessageEventArgs("Cannot delete this car. It is currently rented."));
                    }
                }
            }
        }
        protected override void OnViewLoaded()
        {
            _parts = new ObservableCollection <Part>();

            WithClient(_serviceFactory.CreateClient <IPartService>(), partClient =>
            {
                Part[] parts = partClient.GetAllParts();
                if (parts != null)
                {
                    foreach (Part part in parts)
                    {
                        _parts.Add(part);
                    }
                }
            });
        }
Exemple #12
0
        public void obtain_service_factory_and_proxy_from_container()
        {
            IServiceFactory   factory = ObjectBase.Container.GetExportedValue <IServiceFactory>();
            IInventoryService proxy   = factory.CreateClient <IInventoryService>();

            Assert.IsTrue(proxy is InventoryClient);
        }
        protected override void OnViewLoaded()
        {
            _Cars = new ObservableCollection <Car>();

            WithClient <IInventoryService>(_ServiceFactory.CreateClient <IInventoryService>(), inventoryClient =>
            {
                Car[] cars = inventoryClient.GetAllCars();
                if (cars != null)
                {
                    foreach (Car car in cars)
                    {
                        _Cars.Add(car);
                    }
                }
            });
        }
Exemple #14
0
        private void GetAccounts()
        {
            if (!string.IsNullOrWhiteSpace(SearchTerm))
            {
                IsBusy    = true;
                IsLoading = true;
                var account_service = _serviceFactory.CreateClient <IAccountService>();

                using (account_service)
                {
                    try
                    {
                        Accounts = new ObservableCollection <Client.Entities.Account>(account_service.FindAccountByCompany((Company)CurrentCompany, SearchTerm));

                        MessageToDisplay = Accounts.Count.ToString() + " account(s) found";
                    }
                    catch (Exception ex)
                    {
                        MessageToDisplay = ex.Message;
                        return;
                    }
                }
            }
            else
            {
                MessageToDisplay = "You must enter a search term in order to find an account";
            }
            IsLoading = false;
            IsBusy    = false;
        }
Exemple #15
0
        private async void GetCompanyOpenOrders()
        {
            HeaderMessage = "Open Orders (Loading...)";
            IsLoading     = true;

            var proxy   = _serviceFactory.CreateClient <IOrderService>();
            var company = new Company()
            {
                CompanyKey = CurrentCompanyKey
            };

            using (proxy)
            {
                var   orders = proxy.GetOrdersByCompanyAsync(company);
                await orders;

                if (orders.Result.Count > 0)
                {
                    foreach (var order in orders.Result)
                    {
                        OpenOrders.Add(Map(order));
                    }

                    SelectedItem      = OpenOrders[0];
                    SelectedItemIndex = 0;
                    HeaderMessage     = "Open Orders (" + OpenOrders.Count.ToString() + ") X";
                }
                else
                {
                    HeaderMessage = "Open Orders (0)";
                }
            }
            IsLoading = false;
        }
Exemple #16
0
        protected override void OnViewLoaded()
        {
            _orders = new ObservableCollection <Order>();

            WithClient(_serviceFactory.CreateClient <IOrderService>(), orderClient =>
            {
                Order[] orders = orderClient.GetAllOrders();
                if (orders != null)
                {
                    foreach (Order order in orders)
                    {
                        _orders.Add(order);
                    }
                }
            });
        }
Exemple #17
0
        protected override void OnViewLoaded()
        {
            _stocks = new ObservableCollection <Part>();

            WithClient(_serviceFactory.CreateClient <IPartService>(), stockClient =>
            {
                Part[] stocks = stockClient.GetAllParts();
                if (stocks != null)
                {
                    foreach (Part stock in stocks)
                    {
                        _stocks.Add(stock);
                    }
                }
            });
        }
Exemple #18
0
        protected override void OnViewLoaded()
        {
            _Suppliers = new ObservableCollection <Supplier>();

            WithClient(_serviceFactory.CreateClient <ISupplierService>(), supplierClient =>
            {
                Supplier[] suppliers = supplierClient.GetAllSuppliers();
                if (suppliers != null)
                {
                    foreach (Supplier supplier in suppliers)
                    {
                        _Suppliers.Add(supplier);
                    }
                }
            });
        }
Exemple #19
0
        public void obtain_service_factory_and_procy_from_container()
        {
            IServiceFactory        factory = ObjectBase.Container.GetExportedValue <IServiceFactory>();
            IAuthenticationService proxy   = factory.CreateClient <IAuthenticationService>();

            Assert.IsTrue(proxy is AuthenticationClient);
        }
        public void GivenAContainter_WhenITryToGetAFileServiceFactory_IGetTheFileServiceFactory()
        {
            IServiceFactory factory = this.Resolve <IServiceFactory>();

            IFileService proxy = factory.CreateClient <IFileService>();

            proxy.Should().BeOfType <FileServiceClient>();
        }
Exemple #21
0
 /// <summary>
 /// Create a new object which will handle all communication to/from a specific client.
 /// </summary>
 /// <param name="remoteEndPoint">Remote end point</param>
 /// <returns>Created client</returns>
 protected override INetworkService CreateClient(EndPoint remoteEndPoint)
 {
     if (remoteEndPoint == null)
     {
         throw new ArgumentNullException("remoteEndPoint");
     }
     return(_clientFactory.CreateClient(remoteEndPoint));
 }
        public void GivenAContainter_WhenITryToGetADocumentProxyFactory_IGetTheDocumentFactory()
        {
            IServiceFactory factory = this.Resolve <IServiceFactory>();

            IDocument proxy = factory.CreateClient <IDocument>();

            proxy.Should().BeOfType <DocumentClient>();
        }
Exemple #23
0
        public List <FeeSchedule> GetFeeSchedules(Product product)
        {
            var fs_service = _service_factor.CreateClient <IFeeScheduleService>();

            using (fs_service)
            {
                try
                {
                    var fs_list = fs_service.GetFeeSchedulesByProductAsync(product);
                    return(new List <FeeSchedule>(fs_list.Result));
                }
                catch
                {
                    return(new List <FeeSchedule>());
                }
            }
        }
        public async Task <IActionResult> Get(int order_key)
        {
            Order ord;

            try
            {
                using (var proxy = _serviceFactory.CreateClient <IOrderService>())
                {
                    ord = await proxy.GetOrderAsync(order_key);
                }

                var order_vm = _entityService.Map(ord);

                foreach (var item in ord.OrderItems)
                {
                    order_vm.OrderItems.Add(_entityService.Map(item));
                }

                return(Json(order_vm));
            }
            catch (Exception ex)
            {
                return(Json(ex));
            }
        }
Exemple #25
0
        protected override void OnViewLoaded()
        {
            _productTree = new ObservableCollection <HierarchyNode <ProductTree> >();

            WithClient(_serviceFactory.CreateClient <IPartService>(), partClient =>
            {
                _productTree.Add(partClient.GetProductTree());
            });
        }
Exemple #26
0
        protected override void OnViewLoaded()
        {
            // can check properties for null here if not want to re-get every time view shows

            WithClient <IInventoryService>(_ServiceFactory.CreateClient <IInventoryService>(), inventoryClient =>
            {
                Cars = inventoryClient.GetAllCars();
            });
        }
Exemple #27
0
        public void obtain_service_factory_and_proxy_from_container()
        {
            using (var container = ObjectBase.Container) {
                IServiceFactory   factory = container.Resolve <IServiceFactory>();
                IInventoryService proxy   = factory.CreateClient <IInventoryService>();

                Assert.True(proxy is InventoryClient);
            }
        }
Exemple #28
0
        private void DoSave()
        {
            ExecuteFaultHandledOperation(() =>
            {
                var product = SelectedProduct as ProductWrapper;
                IProductService product_service = service_factory.CreateClient <IProductService>();
                IEntityProductService entity_product_service = service_factory.CreateClient <IEntityProductService>();
                using (TransactionScope scope = new TransactionScope()) // TransactionScopeAsyncFlowOption.Enabled
                {
                    using (product_service)
                    {
                        //*** Make sure the attributes are set before the save happens!!
                        int ret_val = product_service.CreateProduct(product.Model);
                        // We need to create a relationship in the entity product table too, or adding new products is a waste of time.
                        if (product.ProductKey == 0)
                        {
                            EntityProduct ent_prod = new EntityProduct()
                            {
                                EntityProductEntityKey     = CurrentCompanyKey,
                                EntityProductEntityTypeKey = QIQOEntityType.Company,
                                ProductKey       = ret_val,
                                EntityProductSeq = 1,
                                ProductType      = product.ProductType,
                                Comment          = string.Format($"New product {product.ProductName} (Key: {ret_val.ToString()}) entry for company {CurrentCompanyName}")
                            };

                            using (entity_product_service)
                            {
                                int ep_ret = entity_product_service.CreateEntityProduct(ent_prod);
                            }
                            product.ProductKey = ret_val;
                        }

                        product.AcceptChanges();
                        //Products.Add(product);
                        AddNewProductToCache(product);
                        SelectedProduct = null;
                        RaisePropertyChanged("Products");
                    }
                    scope.Complete();
                }
                event_aggregator.GetEvent <ProductNewProductCompleteEvent>().Publish(ViewNames.ProductHomeView);
            });
        }
        private void GetCompanyRepLists()
        {
            var employee_service = service_factory.CreateClient <IEmployeeService>();

            using (employee_service)
            {
                AccountRepList = new ObservableCollection <Representative>(employee_service.GetAccountRepsByCompany(CurrentCompanyKey));
                SalesRepList   = new ObservableCollection <Representative>(employee_service.GetSalesRepsByCompany(CurrentCompanyKey));
            }
        }
Exemple #30
0
 private void LoadSuppliers()
 {
     WithClient(_serviceFactory.CreateClient <ISupplierService>(), suppliersClient =>
     {
         if (suppliersClient == null)
         {
             return;
         }
         Supplier[] suppliers = suppliersClient.GetAllSuppliers();
         if (suppliers == null)
         {
             return;
         }
         _suppliers = new List <Supplier>();
         foreach (Supplier supplier in suppliers.OrderBy(p => p.Name))
         {
             _suppliers.Add(supplier);
         }
     });
 }