public Contracts.Types.Supplier GetSupplierInfo()
        {
            List<Product> products = new List<Product>();
            ProductFamily hardware = new ProductFamily { Name = "Hardware" };
            ProductFamily software = new ProductFamily { Name = "Software" };

            Product primavera = new Product { Family = software, Name = "Primavera" };
            Product artsoft = new Product { Family = software, Name = "Artsoft" };

            Product radeon = new Product { Family = hardware, Name = "ATI Radeon HD" };
            Product nvidia = new Product { Family = hardware, Name = "nVidia GeForce" };

            Product raspberryPi = new Product { Family = hardware, Name = "Raspberry Pi" };

            products.Add(primavera);
            products.Add(artsoft);
            products.Add(radeon);
            products.Add(nvidia);
            products.Add(raspberryPi);

            return new Supplier
            {
                EndPoint = "http://localhost:25262/ProductosService.svc/Central",
                Name = "Supplier 1",
                Products = products
            };
        }
        public Supplier GetSupplierInfo()
        {
            List<Product> products = new List<Product>();
            ProductFamily hardware = new ProductFamily { Name = "Hardware" };
            ProductFamily software = new ProductFamily { Name = "Software" };

            Product primavera = new Product { Family = software, Name = "Primavera" };
            Product artsoft = new Product { Family = software, Name = "Artsoft" };

            Product radeon = new Product { Family = hardware, Name = "ATI Radeon HD" };
            Product nvidia = new Product { Family = hardware, Name = "nVidia GeForce" };

            Product raspberryPi = new Product { Family = hardware, Name = "Raspberry Pi" };

            products.Add(primavera);
            products.Add(artsoft);
            products.Add(radeon);
            products.Add(nvidia);
            products.Add(raspberryPi);

            return new Supplier
                       {
                           EndPoint = OperationContext.Current.Channel.LocalAddress.ToString(),
                           Name = "Supplier 1",
                           Products = products
                       };
        }
示例#3
0
        public ContestInfoWithSuppliers CreateContest(string endPoint, Product product)
        {
            IComprasServiceCentral service = OperationContext.Current.GetCallbackChannel<IComprasServiceCentral>();
            Organization organization = service.GetOrganizationInfo();
            ContestInfo contest = new ContestInfo { Organization = organization, Product = product };
            int nextId = 0;
            List<Supplier> suppliersToNotify = null;
            lock (this._monitor)
            {
                suppliersToNotify =
                _suppliers.Values.Where(
                    supplier => supplier.Products.SingleOrDefault(prod => prod.Name.Equals(product.Name)) != null).ToList();

                if (suppliersToNotify.Count == 0)
                {
                    throw new FaultException<CentralServiceFault>(
                        new CentralServiceFault("No suppliers available for that product"));
                }

                var organizationInfo = OperationContext.Current.GetCallbackChannel<IComprasServiceCentral>().GetOrganizationInfo();
                contest.Organization = organizationInfo;
                if ( _contestInfos.Keys.Count != 0)
                {
                    nextId = _contestInfos.Keys.Max();
                }
                ++nextId;
                contest.Id = nextId;
                _contestInfos.Add(nextId, contest);
            }
            foreach (var supplier in suppliersToNotify)
            {
                var client = new ProductosServiceCentralClient(
                    new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(supplier.EndPoint));
                client.NewContest(contest);
            }
            //Parallel.ForEach(suppliersToNotify, supplier =>
            //{
            //    var client = new ProductosServiceCentralClient(
            //        new BasicHttpBinding(BasicHttpSecurityMode.None), new EndpointAddress(supplier.EndPoint));
            //    client.NewContest(contest);
            //});

            ContestInfoWithSuppliers contestResult = new ContestInfoWithSuppliers
            {
                Id = nextId,
                Product = product,
                Suppliers = suppliersToNotify
            };

            return contestResult;
        }
 public void PostProposal(int contestId, Product product, Supplier supplier)
 {
     List<Proposal> prop;
     if (!Proposals.ContainsKey(contestId))
     {
         prop = new List<Proposal>();
         Proposals.Add(contestId, prop);
     }
     else
     {
         prop = Proposals[contestId];
     }
     Proposal proposal = new Proposal { Product = product, Supplier = supplier };
     prop.Add(proposal);
 }