public ContestInfoWithBool(ContestInfo contestInfo) { Id = contestInfo.Id; Organization = contestInfo.Organization; Product = contestInfo.Product; IsAccepted = false; IsFinished = false; }
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 NewContest(ContestInfo contest) { throw new NotImplementedException(); }
public void NewContest(ContestInfo info) { System.Diagnostics.Debug.WriteLine("New Contest Arrived"); System.Diagnostics.Debug.WriteLine("ID: {0}, Organization: {1}, Product: {2}", info.Id, info.Organization.Name, info.Product.Name); ContestInfoWithBool moreComplexInfo = new ContestInfoWithBool(info); Contests.Add(info.Id, moreComplexInfo); }