コード例 #1
0
 public ProductCollection FetchAll()
 {
     ProductCollection coll = new ProductCollection();
     Query qry = new Query(Product.Schema);
     coll.LoadAndCloseReader(qry.ExecuteReader());
     return coll;
 }
コード例 #2
0
ファイル: ETL.cs プロジェクト: RyanDansie/SubSonic-2.0
 public void Acc_ETL_CollectionToTable()
 {
     ProductCollection coll = new ProductCollection().Where("CategoryID", 1);
     coll.Load();
     DataTable tbl = coll.ToDataTable();
     Assert.IsTrue(coll.Count == tbl.Rows.Count);
 }
コード例 #3
0
 /// <summary>
 /// Fetches all products by category id.
 /// </summary>
 /// <param name="categoryId">The category id.</param>
 /// <returns></returns>
 public ProductCollection FetchAllProductsByCategoryId(int categoryId)
 {
     IDataReader reader = SPs.FetchAllProductsByCategoryId(categoryId).GetReader();
       ProductCollection productCollection = new ProductCollection();
       productCollection.LoadAndCloseReader(reader);
       return productCollection;
 }
コード例 #4
0
        public static ProductCollection BestRating()
        {
            ProductCollection list = new ProductCollection();
            //list.ReadTop(4, true, Product.Columns.Total_Rate);

            return list;
        }
コード例 #5
0
ファイル: ETL.cs プロジェクト: RyanDansie/SubSonic-2.0
 public void Acc_ETL_CloneCollection()
 {
     ProductCollection coll = new ProductCollection().Where("CategoryID", 1);
     coll.Load();
     ProductCollection coll2 = new ProductCollection();
     coll2.AddRange(coll.Clone());
     Assert.IsTrue(coll.Count == coll2.Count);
 }
コード例 #6
0
        public virtual ProductCollection GetProducts()
        {
            var products = ProductHelper.GetProducts(2);
            var collection = new ProductCollection(products);
            collection.Links.Add(new Link("self", "/products"));
            collection.Links.Add(new Link("product", "/products/{productId}"));

            return collection;
        }
コード例 #7
0
        public void BatchSaveInsert()
        {
            ProductCollection c = CreateProductCollection();
            c.BatchSave();

            c = new ProductCollection();
            c.Load(ReadOnlyRecord<Product>.FetchByParameter(Product.Columns.ProductName, Comparison.Like, "Unit Test Product%"));
            Assert.AreEqual(1000, c.Count, "Expected 1000 - After Save: " + c.Count);
        }
コード例 #8
0
 public static Product callbackProductName(string ProductId)
 {
     ProductCollection lists = new ProductCollection();
     lists.ReadList(Criteria.NewCriteria(Product.Columns.ProductId,CriteriaOperators.Like,ProductId));
     if (lists.Count != 0)
     {
         return lists[0];
     }
     else return null;
 }
コード例 #9
0
 public static ProductCollection tablets()
 {
     ProductCollection lists = new ProductCollection();
     lists.ReadList(Criteria.NewCriteria(Product.Columns.Category, CriteriaOperators.Like, "tablet"));
     if (lists.Count != 0)
     {
         return lists;
     }
     else return null;
 }
コード例 #10
0
ファイル: Mapper.cs プロジェクト: dinkelburg/leet
 public static IEnumerable<ProductVM> MapToProductVMList(ProductCollection productCollection)
 {
     return productCollection.Select(product => new ProductVM
     {
         ID = product.Id,
         Naam = product.Naam,
         LeverancierNaam = product.LeverancierNaam,
         Prijs = product.Prijs,
         AfbeeldingPad = Util.AfbeeldingPrefix + product.AfbeeldingURL,
     });
 }
コード例 #11
0
 private static void AssertProductCollection(ProductCollection productCollection, ProductCollection expectedProductCollection)
 {
     for (int i = 0; i < productCollection.Count; i++)
     {
         Assert.AreEqual(expectedProductCollection[i].Id, productCollection[i].Id);
         Assert.AreEqual(expectedProductCollection[i].Naam, productCollection[i].Naam);
         Assert.AreEqual(expectedProductCollection[i].LeverancierNaam, productCollection[i].LeverancierNaam);
         Assert.AreEqual(expectedProductCollection[i].AfbeeldingURL, productCollection[i].AfbeeldingURL);
         Assert.AreEqual(expectedProductCollection[i].Prijs, productCollection[i].Prijs);
     }
 }
コード例 #12
0
ファイル: MapperTest.cs プロジェクト: dinkelburg/leet
 private static void AssertProductCollectionWithProductVMList(ProductCollection productCollection, IEnumerable<ProductVM> productVMList)
 {
     var productVMArray = productVMList.ToArray();
     for (int i = 0; i < productCollection.Count; i++)
     {
         Assert.AreEqual(productVMArray[i].ID, productCollection[i].Id);
         Assert.AreEqual(productVMArray[i].Naam, productCollection[i].Naam);
         Assert.AreEqual(productVMArray[i].LeverancierNaam, productCollection[i].LeverancierNaam);
         Assert.AreEqual(productVMArray[i].AfbeeldingPad, Util.AfbeeldingPrefix + productCollection[i].AfbeeldingURL);
         Assert.AreEqual(productVMArray[i].Prijs, productCollection[i].Prijs);
     }
 }
コード例 #13
0
        private static ProductCollection DBMapping(DBProductCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ProductCollection collection = new ProductCollection();
            foreach (DBProduct dbItem in dbCollection)
            {
                Product item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
コード例 #14
0
        public void GetCostOfAllItems_ShouldReturnTheCostOfAllItems()
        {
            var productCollection = new ProductCollection
                                        {
                                            Items = new List<Product>
                                                        {
                                                            new Product {Price = 10},
                                                            new Product {Price = 10},
                                                            new Product {Price = 10}
                                                        }
                                        };

            var result = productCollection.GetCostOfAllItems();

            Assert.That(result, Is.EqualTo(30));
        }
コード例 #15
0
 private ProductCollection GetProducts()
 {
     int totalItems = 0;
     ProductCollection productCollection = new ProductCollection();
     try
     {
         ViewedItemsCollection collection = ViewedItemManager.GetCurrentViewedItem(10, 0, out totalItems);
         List<int> productsIDs = collection.Select(x => x.ProductVariantID).ToList();
         foreach (var productID in productsIDs)
         {
             ProductVariant product = ProductManager.GetProductVariantByID(productID);
             productCollection.Add(product.Product);
         }
     }
     catch { }
     return productCollection;
 }
コード例 #16
0
        public void DeferredDelete()
        {
            ProductCollection c = CreateProductCollection();
            c.BatchSave();

            c = new ProductCollection();
            c.Load(ReadOnlyRecord<Product>.FetchByParameter(Product.Columns.ProductName, Comparison.Like, "Unit Test Product%"));
            Assert.AreEqual(1000, c.Count, "Expected 1000 - After Save: " + c.Count);

            while(c.Count > 0)
                c.RemoveAt(0); // RemoveItem() gets called
            c.SaveAll();

            c = new ProductCollection();
            c.Load(ReadOnlyRecord<Product>.FetchByParameter(Product.Columns.ProductName, Comparison.Like, "Unit Test Product%"));
            Assert.AreEqual(0, c.Count, "Expected 0 - After Save: " + c.Count);
        }
コード例 #17
0
 /// <summary>
 /// Will sort the product collection passed in depending on the sort by.
 /// </summary>
 /// <param name="products">The product collection to sort.</param>
 /// <param name="sortBy">The type of sorting.</param>
 public static void SortProducts(ProductCollection products, CatalogSortBy sortBy)
 {
     switch (sortBy) {
     case CatalogSortBy.PriceAscending:
       products.Sort(delegate(Product p1, Product p2) {
     return p1.OurPrice.CompareTo(p2.OurPrice);
       });
       break;
     case CatalogSortBy.PriceDescending:
       products.Sort(delegate(Product p1, Product p2) {
     return p2.OurPrice.CompareTo(p1.OurPrice);
       });
       break;
     case CatalogSortBy.TitleAscending:
       products.Sort(delegate(Product p1, Product p2) {
     return p1.Name.CompareTo(p2.Name);
       });
       break;
     case CatalogSortBy.TitleDescending:
       products.Sort(delegate(Product p1, Product p2) {
     return p2.Name.CompareTo(p1.Name);
       });
       break;
     case CatalogSortBy.DateUpdatedAscending:
       products.Sort(delegate(Product p1, Product p2) {
     return p2.CreatedOn.CompareTo(p1.CreatedOn);
       });
       break;
     case CatalogSortBy.DateCreatedAscending:
       products.Sort(delegate(Product p1, Product p2) {
     return p1.CreatedOn.CompareTo(p2.CreatedOn);
       });
       break;
     case CatalogSortBy.DateCreatedDescending:
       products.Sort(delegate(Product p1, Product p2) {
     return p2.ModifiedOn.CompareTo(p1.ModifiedOn);
       });
       break;
     case CatalogSortBy.DateUpdatedDescending:
       products.Sort(delegate(Product p1, Product p2) {
     return p1.ModifiedOn.CompareTo(p2.ModifiedOn);
       });
       break;
       }
 }
コード例 #18
0
ファイル: ProductService.cs プロジェクト: ibollen/website
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public static ProductCollection GetCommend()
        {
            ProductCollection list = new ProductCollection();

            string sql = "select * from t_product where iscommend = 1 order by prod_id desc limit 18";

            MySqlDataReader reader = DbHelper.ExecuteDataReader(sql);

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    list.Add(FillDataRecord(reader));
                }

            }
            reader.Close();

            return list;
        }
コード例 #19
0
ファイル: QueryTest.cs プロジェクト: BlackMael/SubSonic-2.0
        public void Query_Updates()
        {
            Query qry = new Query(Product.Schema);
            qry.AddUpdateSetting("Discontinued", true);
            qry.AddWhere(Product.Columns.ProductName, "Unit Test Product 3");
            qry.Execute();

            //verify
            qry = new Query(Product.Schema);
            qry.AddWhere(Product.Columns.ProductName, "Unit Test Product 3");

            ProductCollection coll = new ProductCollection();

            using(IDataReader rdr = qry.ExecuteReader())
            {
                coll.Load(rdr);
                rdr.Close();
            }
            foreach(Product prod in coll)
                Assert.IsTrue(prod.Discontinued);
        }
コード例 #20
0
 /// <summary>
 /// Handles the Click event of the lbDelete control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.Web.UI.WebControls.CommandEventArgs"/> instance containing the event data.</param>
 protected void lbDelete_Click(object sender, CommandEventArgs e)
 {
     try {
     Manufacturer manufacturer;
     int manufacturerId = 0;
     int.TryParse(e.CommandArgument.ToString(), out manufacturerId);
     if (manufacturerId > 0) {
       manufacturer = new Manufacturer(manufacturerId);
       ProductCollection productCollection = new ProductCollection().Where(Product.Columns.ManufacturerId, Comparison.Equals, manufacturerId).Load();
       if (productCollection.Count > 0) {
     Master.MessageCenter.DisplayFailureMessage(string.Format(LocalizationUtility.GetText("lblUnableToDeleteManufacturers"), manufacturer.Name));
       }
       else {
     Manufacturer.Delete(manufacturerId);
     LoadManufacturers();
     Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblManufacturerDeleted"));
       }
     }
       }
       catch (HttpException) {
     try {
       if(dgManufacturers.PageCount > 1) {
     dgManufacturers.CurrentPageIndex = dgManufacturers.CurrentPageIndex - 1;
       }
       else {
     dgManufacturers.CurrentPageIndex = 0;
       }
       dgManufacturers.DataBind();
       Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblManufacturerDeleted"));
     }
     catch (Exception exe) {
       Logger.Error(typeof(manufacturers).Name + ".lbDelete_Click", exe);
       Master.MessageCenter.DisplayCriticalMessage(LocalizationUtility.GetCriticalMessageText(exe.Message));
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(manufacturers).Name + ".lbDelete_Click", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
コード例 #21
0
        public static void CheckAreValidProducts(
            Microsoft.UpdateServices.Administration.IUpdateServer server,
            ProductCollection products,
            System.String runSetName,
            System.String groupId,
            System.String classificationId
            )
        {
            //make sure we have at least one product
            if (products.Count < 1)
            {
                System.String groupPath = (groupId != null)
                    ? "\\TargetGroups\\" + groupId :
                    "\\AllTargetGroups";

                throw new System.Configuration.ConfigurationErrorsException(
                    "The products section in \"" + runSetName + groupPath + "\\Classifications\\" + classificationId + "\\\" must have at least 1 item."
                );
            }

            foreach (Product product in products)
            {
                //make sure the product exists on wsus
                try
                {
                    server.GetUpdateCategory(product.Guid);
                }
                catch (System.Exception)
                {
                    throw new System.ArgumentException(
                            "The Product Guid \"" + product.Guid + "\" could not be found on the WSUS server. Run Set: " + runSetName
                            );
                }

                //todo: make sure the product doesn't appear in the list twice
                //todo: make sure the product parent hasn't already been added to the list
            }
        }
コード例 #22
0
    /// <summary>Register the price and currency that a user is using to make iOS in-app purchases.</summary>
    /// <remarks>
    /// After receiving the list of in-app purchases from Apple, this method can be called to record the localized item information.
    /// This overload is meant to be called from Unity's IStoreListener.OnInitialized callback passing in the
    /// ProductCollection which you can get from the IStoreListener using the products property.
    /// </remarks>
    /// <param name="unityProducts">A collection containing all the products registered with Unity.</param>
    public static void RegisterIOSInAppPurchaseList(ProductCollection unityProducts)
    {
        if(unityProducts == null || unityProducts.all == null || unityProducts.all.Length == 0)
            return;

        Product[] products = unityProducts.all;

        var fuseProducts = new List<FuseMisc.Product>();
        foreach(var p in products)
        {
            if(p.availableToPurchase)
            {
                fuseProducts.Add(new FuseMisc.Product()
                {
                    ProductId = p.definition.storeSpecificId,
                    Price = (float)p.metadata.localizedPrice,
                    PriceLocale = p.metadata.isoCurrencyCode
                });
            }
        }

        RegisterIOSInAppPurchaseList(fuseProducts.ToArray());
    }
コード例 #23
0
ファイル: Program.cs プロジェクト: claq2/Spurious
        private static void AddUpdateDeleteProducts(ZipArchiveEntry entry)
        {
            IEnumerable<Product> products = null;
            using (var entryStream = entry.Open())
            {
                Console.WriteLine("products.csv is {0} bytes", entry.Length);
                Console.WriteLine("Starting products at {0:hh:mm:ss.fff}", DateTime.Now);
                var stopwatch = new Stopwatch();
                stopwatch.Start();

                var reader = new StreamReader(entryStream);
                var csv = new CsvReader(reader);
                csv.Configuration.RegisterClassMap(new ProductMap());
                products = csv.GetRecords<Product>().Where(p => !p.IsDead);
                var productCollection = new ProductCollection();
                productCollection.SetItems(products);
                var importer = new NpgsqlBulkImporter(ConfigurationManager.ConnectionStrings["spurious"].ConnectionString, stopwatch);
                importer.BulkImport("products", productCollection);

                stopwatch.Stop();
                Console.WriteLine("Finished products at {0:hh:mm:ss.fff}, taking {1}", DateTime.Now, stopwatch.Elapsed);
            }
        }
コード例 #24
0
        public void Acc_Products_CollectionSample()
        {
            // sample snippet #1
            ProductCollection products = new ProductCollection().Where("categoryID", 1).Load();
            Assert.AreEqual(12, products.Count);

            // sample snippet #2
            products = new ProductCollection().Where("categoryID", 1).OrderByAsc("ProductName").Load();
            Assert.AreEqual(12, products.Count);
            Assert.AreEqual("Chai", products[0].ProductName);
            Assert.AreEqual("Steeleye Stout", products[11].ProductName);
        }
コード例 #25
0
 /// <summary>
 /// Gets a "recently viewed products" list
 /// </summary>
 /// <param name="Number">Number of products to load</param>
 /// <returns>"recently viewed products" list</returns>
 public static ProductCollection GetRecentlyViewedProducts(int Number)
 {
     ProductCollection products = new ProductCollection();
     List<int> productIDs = GetRecentlyViewedProductsIDs(Number);
     foreach (int productID in productIDs)
     {
         Product product = GetProductByID(productID);
         if (product != null && product.Published && !product.Deleted)
             products.Add(product);
     }
     return products;
 }
 public IActionResult Index(ProductCollection model)
 {
     return(View(model));
 }
コード例 #27
0
        protected void resultFilter(string SearchFor)
        {
            int CategoryFilterID      = CommonLogic.QueryStringUSInt("CategoryFilterID");
            int SectionFilterID       = CommonLogic.QueryStringUSInt("SectionFilterID");
            int ProductTypeFilterID   = CommonLogic.QueryStringUSInt("ProductTypeFilterID");
            int ManufacturerFilterID  = CommonLogic.QueryStringUSInt("ManufacturerFilterID");
            int DistributorFilterID   = CommonLogic.QueryStringUSInt("DistributorFilterID");
            int GenreFilterID         = CommonLogic.QueryStringUSInt("GenreFilterID");
            int VectorFilterID        = CommonLogic.QueryStringUSInt("VectorFilterID");
            int AffiliateFilterID     = CommonLogic.QueryStringUSInt("AffiliateFilterID");
            int CustomerLevelFilterID = CommonLogic.QueryStringUSInt("CustomerLevelFilterID");

            String ENCleaned = CommonLogic.QueryStringCanBeDangerousContent("EntityName").Trim().ToUpperInvariant();

            // kludge for now, during conversion to properly entity/object setup:
            if (ENCleaned == "CATEGORY")
            {
                CategoryFilterID      = CommonLogic.QueryStringUSInt("EntityFilterID");
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = CategoryFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "SECTION")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = CommonLogic.QueryStringUSInt("EntityFilterID");
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = SectionFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "MANUFACTURER")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = CommonLogic.QueryStringUSInt("EntityFilterID");
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = ManufacturerFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "DISTRIBUTOR")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = CommonLogic.QueryStringUSInt("EntityFilterID");
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = DistributorFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "GENRE")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = CommonLogic.QueryStringUSInt("EntityFilterID");
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = GenreFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "VECTOR")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = CommonLogic.QueryStringUSInt("EntityFilterID");
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = 0;

                _entityId   = VectorFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "AFFILIATE")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = CommonLogic.QueryStringUSInt("EntityFilterID");
                CustomerLevelFilterID = 0;

                _entityId   = AffiliateFilterID;
                _entityName = ENCleaned;
            }
            if (ENCleaned == "CUSTOMERLEVEL")
            {
                CategoryFilterID      = 0;
                SectionFilterID       = 0;
                ProductTypeFilterID   = Localization.ParseNativeInt(ddTypes.SelectedValue);
                ManufacturerFilterID  = 0;
                DistributorFilterID   = 0;
                GenreFilterID         = 0;
                VectorFilterID        = 0;
                AffiliateFilterID     = 0;
                CustomerLevelFilterID = CommonLogic.QueryStringUSInt("EntityFilterID");

                _entityId   = CustomerLevelFilterID;
                _entityName = ENCleaned;
            }
            // end kludge

            //search
            if (SearchFor.Length == 0)
            {
                SearchFor = txtSearch.Text;
                ThisCustomer.ThisCustomerSession.SetVal("ProductsSearch", txtSearch.Text);
            }

            //Node filter
            string Index = "";

            for (int i = 0; i < treeMain.Nodes.Count; i++)
            {
                if (treeMain.Nodes[i].Selected)
                {
                    Index = treeMain.Nodes[i].Value;

                    ThisCustomer.ThisCustomerSession.SetVal("ProductsTree", treeMain.Nodes[i].Value);

                    break;
                }
            }


            //Type filter
            string typepName = ddTypes.SelectedValue;

            ThisCustomer.ThisCustomerSession.SetVal("ProductsType", typepName);


            ThisCustomer.ThisCustomerSession.SetVal("ProductsSort", ViewState["Sort"].ToString());
            ThisCustomer.ThisCustomerSession.SetVal("ProductsOrder", ViewState["SortOrder"].ToString());

            //remember page
            if (ThisCustomer.ThisCustomerSession.SessionNativeInt("ProductsPage") > 0)
            {
                gMain.PageIndex = ThisCustomer.ThisCustomerSession.SessionNativeInt("ProductsPage");
            }

            ProductCollection products = new ProductCollection();

            products.CategoryID     = CategoryFilterID;
            products.SectionID      = SectionFilterID;
            products.ManufacturerID = ManufacturerFilterID;
            products.DistributorID  = DistributorFilterID;
            products.GenreID        = GenreFilterID;
            products.VectorID       = VectorFilterID;
            products.AffiliateID    = AffiliateFilterID;
            products.ProductTypeID  = ProductTypeFilterID;
            products.PublishedOnly  = false;
            products.SearchDescriptionAndSummaryFields = false;
            products.SearchMatch = SearchFor;

            if (!Index.Equals("All"))
            {
                products.SearchIndex = Index;
            }

            products.SortBy    = ViewState["Sort"].ToString();
            products.SortOrder = ViewState["SortOrder"].ToString();

            DataSet dsProducts = products.LoadFromDBEntity();

            //build grid
            buildGridData(dsProducts);

            ((TextBox)Form.FindControl("txtSearch")).Text = SearchFor;
        }
コード例 #28
0
        //public static void FedExShowShipmentRateDetails(RatedShipmentDetail shipmentDetail, Person shipto, ProductCollection cart)
        public static double FedExRate(RatedShipmentDetail shipmentDetail, Person shipto, ProductCollection cart)
        {
            double temp = 0;

            if (shipmentDetail == null)
            {
                return(-1);                       //***EAC something wrong?
            }
            if (shipmentDetail.ShipmentRateDetail == null)
            {
                return(-1);                                          //***EAC something wrong?
            }
            ShipmentRateDetail rateDetail = shipmentDetail.ShipmentRateDetail;

            FedExNoelWrite("--- Shipment Rate Detail ---");
            //
            FedExNoelWrite("RateType: " + rateDetail.RateType);
            if (rateDetail.TotalBillingWeight != null)
            {
                FedExNoelWrite("Total Billing Weight: " + rateDetail.TotalBillingWeight.Value + " " + shipmentDetail.ShipmentRateDetail.TotalBillingWeight.Units);
            }
            if (rateDetail.TotalBaseCharge != null)
            {
                FedExNoelWrite("Total Base Charge: " + rateDetail.TotalBaseCharge.Amount + " " + rateDetail.TotalBaseCharge.Currency);
            }
            if (rateDetail.TotalFreightDiscounts != null)
            {
                FedExNoelWrite("Total Freight Discounts: " + rateDetail.TotalFreightDiscounts.Amount + " " + rateDetail.TotalFreightDiscounts.Currency);
            }
            if (rateDetail.TotalSurcharges != null)
            {
                FedExNoelWrite("Total Surcharges: " + rateDetail.TotalSurcharges.Amount + " " + rateDetail.TotalSurcharges.Currency);
            }
            if (rateDetail.Surcharges != null)
            {
                // Individual surcharge for each package
                foreach (Surcharge surcharge in rateDetail.Surcharges)
                {
                    FedExNoelWrite(" surcharge " + surcharge.SurchargeType + " " + surcharge.Amount.Amount + " " + surcharge.Amount.Currency);
                }
            }
            if (rateDetail.TotalNetCharge != null)
            {
                FedExNoelWrite("Total Net Charge: " + rateDetail.TotalNetCharge.Amount + " " + rateDetail.TotalNetCharge.Currency);
                temp = (double)rateDetail.TotalNetCharge.Amount;
            }
            return(temp);
        }
コード例 #29
0
 public static void FedExSetShipmentDetails(RateRequest request, Person shipto, ProductCollection cart)
 {
     request.RequestedShipment = new RequestedShipment();
     request.RequestedShipment.ShipTimestamp          = DateTime.Now;                                                                                       // Shipping date and time
     request.RequestedShipment.ShipTimestampSpecified = true;
     request.RequestedShipment.DropoffType            = DropoffType.REGULAR_PICKUP;                                                                         //Drop off types are BUSINESS_SERVICE_CENTER, DROP_BOX, REGULAR_PICKUP, REQUEST_COURIER, STATION
     request.RequestedShipment.ServiceType            = (ServiceType)Enum.Parse(typeof(ServiceType), DAL2.DAL.GetShippingMethodValuebyID(cart.ShipMethod)); // Service types are STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND ...
     request.RequestedShipment.ServiceTypeSpecified   = true;
     request.RequestedShipment.PackagingType          = PackagingType.YOUR_PACKAGING;                                                                       // Packaging type FEDEX_BOK, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
     request.RequestedShipment.PackagingTypeSpecified = true;
     //
     FedExSetOrigin(request, shipto, cart);
     //
     FedExSetDestination(request, shipto, cart);
     //
     FedExSetPackageLineItems(request, shipto, cart);
     //
     //request.RequestedShipment.TotalInsuredValue = new Money();
     //request.RequestedShipment.TotalInsuredValue.Amount = 100;
     //request.RequestedShipment.TotalInsuredValue.Currency = "USD";
     //
     request.RequestedShipment.RateRequestTypes    = new RateRequestType[1];
     request.RequestedShipment.RateRequestTypes[0] = RateRequestType.LIST;
     //request.RequestedShipment.RateRequestTypes[1] = RateRequestType.LIST;
     request.RequestedShipment.PackageCount = boxcount.ToString();
 }
コード例 #30
0
ファイル: Job.cs プロジェクト: dpvreony/wsussmartapprove
        /// <summary>
        /// Gets a list of update categories by searching for the guids specified in the config
        /// </summary>
        /// <param name="server">
        /// wsus server connection
        /// </param>
        /// <param name="products">
        /// list of product guids from config
        /// </param>
        /// <returns>
        /// collection of update categories
        /// </returns>
        private static UpdateCategoryCollection GetUpdateCategoryCollection(
            IUpdateServer server,
            ProductCollection products)
        {
            if (products == null)
            {
                throw new ArgumentNullException("products");
            }

            if (products.Count < 1)
            {
                throw new ArgumentException("products has no product items.");
            }

            var result = new UpdateCategoryCollection();

            foreach (Product product in products)
            {
                IUpdateCategory category = server.GetUpdateCategory(product.Guid);

                result.Add(category);
            }

            return result;
        }
コード例 #31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //Some checks - We need a good confid
            if (Request.QueryString["confid"] == null)
            {
                Utils.ResetSessions();
                Response.Redirect("default.aspx?redirect=cart", true);
            }
            else
            {
                strConfId = Request.QueryString["confid"].ToString();
            }

            if (strConfId.Length > 4 || strConfId == "") //potentially an intrusion
            {
                Utils.ResetSessions();
                Response.Redirect("default.aspx?redirect=cart", true);
            }
            //End of checks


            ImgBtnContinueSearch.Attributes.Add("onmousedown", "this.src='images/continuered_on.jpg'");
            ImgBtnContinueSearch.Attributes.Add("onmouseup", "this.src='images/continuered_off.jpg'");
            ImgBtnCancelOrder.Attributes.Add("onmousedown", "this.src='images/cancel_on.jpg'");
            ImgBtnCancelOrder.Attributes.Add("onmouseup", "this.src='images/cancel_off.jpg'");
            ImgBtnCheckOut.Attributes.Add("onmousedown", "this.src='images/checkout_on.jpg'");
            ImgBtnCheckOut.Attributes.Add("onmouseup", "this.src='images/checkout_off.jpg'");

            //***EAC Hide buttons or not...Better to do on PageLoad for each page than in Master.cs!
            Master.FindControl("btnViewCart").Visible = false;
            //Master.FindControl("btnSearchOther").Visible = false;
            Master.FindControl("btnFinish").Visible       = false;
            Master.FindControl("lblFreePubsInfo").Visible = false;

            //Check whether the conference is domestic or international
            if (Session["KIOSK_ShipLocation"] != null)
            {
                if (Session["KIOSK_ShipLocation"].ToString().Length > 0)
                {
                    if (string.Compare(Session["KIOSK_ShipLocation"].ToString(), "Domestic", true) == 0)
                    {
                        hdnTotalLimit.Value = ConfigurationManager.AppSettings["DomesticOrderLimit"];
                    }
                    else if (string.Compare(Session["KIOSK_ShipLocation"].ToString(), "International", true) == 0)
                    {
                        //hdnTotalLimit.Value = ConfigurationManager.AppSettings["InternationalOrderLimit"];
                        hdnTotalLimit.Value = PubEnt.DAL.DAL.GetIntl_MaxOrder(int.Parse(strConfId)).ToString();
                    }
                }
            }

            if (!IsPostBack)
            {
                #region dummydata2--remove before going live
                if (Request.QueryString["debug"] == "yes")
                {
                    Session["KIOSK_Pubs"]         = "4236,1095,1169";
                    Session["KIOSK_Qtys"]         = "1,14,1";
                    Session["KIOSK_Urls"]         = "34,47,110,116,117,118,119,120,121,122,123,124,127,128,129,130,131";
                    Session["KIOSK_ShipLocation"] = "Domestic";
                }
                #endregion


                this.shoppingcart = null;     //destroy cart if it exists
                this.shoppingcart = new ProductCollection();

                //***EAC Parse the KIOSK_Pubs and KIOSK_qtys..assume they have same dimensions
                string[] pubs = Session["KIOSK_Pubs"].ToString().Split(new Char[] { ',' });
                string[] qtys = Session["KIOSK_Qtys"].ToString().Split(new Char[] { ',' });
                for (var i = 0; i < pubs.Length; i++)
                {
                    if (pubs[i].Trim() != "")
                    {
                        int     pubid = Int32.Parse(pubs[i]);
                        Product p     = Product.GetPubByPubID(pubid);
                        p.NumQtyOrdered  = Int32.Parse(qtys[i]);
                        p.IsPhysicalItem = true;
                        shoppingcart.Add(p);   //TODO: BLL Add should differentiate physical from virtual items while deduping
                    }
                }


                #region EAC Add ONLINE-only items to the shopping cart (20130226)
                //***EAC We are assuming Session_pubs and Session_Urls are mutually exclusive
                string[] urls = Session["KIOSK_Urls"].ToString().Split(new Char[] { ',' });
                for (var i = 0; i < urls.Length; i++)
                {
                    if (urls[i].Trim() != "")
                    {
                        int     pubid = Int32.Parse(urls[i]);
                        Product p     = Product.GetPubByPubID(pubid);
                        p.NumQtyOrdered  = 1;
                        p.IsPhysicalItem = false;
                        shoppingcart.Add(p);   //TODO: BLL Add should differentiate physical from virtual items while deduping
                    }
                }
                #endregion


                //--- Sorting the publication collection by long title
                this.shoppingcart.Sort(ProductCollection.ProductFields.LongTitle, true);

                grdViewItems.DataSource = this.shoppingcart;
                grdViewItems.DataBind();

                //Add client code
                //ImgBtnCancelOrder.Attributes.Add("onclick", "return fnAskBeforeCancelling(" + "'" + ImgBtnCancelOrder.ClientID + "')");
            }

            //Check for cart object here
            if (this.shoppingcart == null)
            {
                //Display empty shopping cart
                Panel1.Visible         = false;
                Panel2.Visible         = true;
                ImgBtnCheckOut.Visible = false;
            }
            else
            {
                if (this.shoppingcart.Count > 0 && hdnTotalLimit.Value.Length > 0)
                {
                    //***EAC at this point we have a usable cart
                    lblTot.Text           = this.shoppingcart.TotalQtyForShipping.ToString();
                    lblFreeRemaining.Text = (Int32.Parse(hdnTotalLimit.Value) - this.shoppingcart.TotalQtyForShipping).ToString();

                    Panel1.Visible = true;
                    Panel2.Visible = false;

                    if (Session["KIOSK_ShipLocation"].ToString() != "Domestic")
                    {
                        h3free.Visible       = false;
                        trFreeRemain.Visible = false;
                        spanQty.Visible      = false;
                        trTotalItems.Visible = false;
                    }
                }
                else//shopping cart is empty
                {
                    Panel1.Visible         = false;
                    Panel2.Visible         = true;
                    ImgBtnCheckOut.Visible = false;
                }
            }
        }
コード例 #32
0
 public void Update(ProductCollection pt)
 {
     pt.ObjectState = ObjectState.Modified;
     _unitOfWork.Repository <ProductCollection>().Update(pt);
 }
コード例 #33
0
        protected void GetOrderInfo()
        {
            string strOrderSource  = "";
            string strOrderCreator = "";

            Customer Cust = DAL.DAL.GetOrderCustInfobyOrderNum(OrderNum);

            lblInvoice.Text = OrderNum;
            if (Cust != null)
            {
                lblShipToName.Text  = Cust.ShipToName;
                lblShipToOrg.Text   = Cust.ShipToOrg;
                lblShipToAddr1.Text = Cust.ShipToAddr1;
                lblShipToAddr2.Text = Cust.ShipToAddr2;
                lblShipToZip5.Text  = Cust.ShipToZip5;
                lblShipToZip4.Text  = Cust.ShipToZip4;
                lblShipToCity.Text  = Cust.ShipToCity;
                lblShipToState.Text = Cust.ShipToState;
                lblShipToPhone.Text = Cust.ShipToPhone;
                lblShipToEmail.Text = Cust.ShipToEmail;

                if (Cust.BillToName != "")
                {
                    lblBillToName.Text = Cust.BillToName;
                }
                else
                {
                    lblBillToName.Text = "&nbsp;";
                }
                lblBillToOrg.Text   = Cust.BillToOrg;
                lblBillToAddr1.Text = Cust.BillToAddr1;
                lblBillToAddr2.Text = Cust.BillToAddr2;
                lblBillToZip5.Text  = Cust.BillToZip5;
                lblBillToZip4.Text  = Cust.BillToZip4;
                lblBillToCity.Text  = Cust.BillToCity;
                lblBillToState.Text = Cust.BillToState;
                lblBillToPhone.Text = Cust.BillToPhone;
                lblBillToEmail.Text = Cust.BillToEmail;
            }

            IDataReader dr = DAL.DAL.GetOrderStatus(OrderNum);

            try
            {
                using (dr)
                {
                    if (dr.Read())
                    {
                        if (dr["ORDERSOURCE"].ToString() == "IWEB")
                        {
                            strOrderSource  = "NCIPL";
                            strOrderCreator = "NCIPL user";
                        }
                        else if (dr["ORDERSOURCE"].ToString() == "IVPR")
                        {
                            strOrderSource  = "VPR";
                            strOrderCreator = "VPR user";
                        }
                        else if (dr["ORDERSOURCE"].ToString() == "IEOT")
                        {
                            strOrderSource  = "NCIPLex";
                            strOrderCreator = "Exhibit Team";
                        }
                        else if (dr["ORDERSOURCE"].ToString() == "ICIS")
                        {
                            strOrderSource  = dr["ORDERMEDIA"].ToString();
                            strOrderCreator = dr["ORDERCREATOR"].ToString();
                        }

                        lblOrderSource.Text    = strOrderSource;
                        lblOrderCreator.Text   = strOrderCreator;
                        lblTypeofCustomer.Text = dr["CUSTOMERTYPE"].ToString();

                        lblCreated.Text = dr["CREATEDATE"].ToString();

                        if (dr["MethodDisplay"].ToString() == "")
                        {
                            lblShipMethod.Text = "USPS";
                        }
                        else
                        {
                            lblShipMethod.Text = dr["MethodDisplay"].ToString();
                        }

                        //---- Current Logic

                        /*
                         * if (dr["DOWNLOAD"].ToString() == "Y")
                         * {
                         *  lblDownload.Text = "Yes";
                         *
                         * if (dr["TERMCODE"].ToString() != "B")
                         *  {
                         *      if (dr["PACKSLIP"].ToString() != "")
                         *      {
                         *          lblShipped.Text = "Shipped - " + dr["DATE_SHIP"].ToString();
                         *
                         *          if (dr["TRACKTRACE"].ToString() != "")
                         *          {
                         *              lblTracking.Text = dr["TRACKTRACE"].ToString();
                         *          }
                         *          else
                         *          {
                         *              lblTracking.Text = "";
                         *          }
                         *      }
                         *      else
                         *      {
                         *          lblShipped.Text = "Pending";
                         *      }
                         *  }
                         *  else
                         *  {
                         *      lblShipped.Text = "Backorder";
                         *  }
                         * }
                         * else
                         * {
                         *  lblDownload.Text = "No";
                         * }*/


                        //--- New Logic 11/05/2012
                        if (dr["TERMCODE"].ToString() == "B")
                        {
                            lblShipped.Text  = "Not Processed";
                            lblDownload.Text = "No";
                        }
                        else if (dr["TERMCODE"].ToString() == "R" || dr["TERMCODE"].ToString() == "P")
                        {
                            lblShipped.Text  = "Held – Under Review";
                            lblDownload.Text = "No";
                        }
                        else if (dr["TERMCODE"].ToString() == "G")
                        {
                            lblShipped.Text = "Pending";

                            if (dr["DOWNLOAD"].ToString() == "Y")
                            {
                                lblDownload.Text = "Yes";
                            }
                            else
                            {
                                lblDownload.Text = "No";
                            }
                        }
                        else
                        {
                            if (dr["TERMCODE"].ToString() == "" && dr["PACKSLIP"].ToString() == "")
                            {
                                lblShipped.Text = "Pending";

                                if (dr["DOWNLOAD"].ToString() == "Y")
                                {
                                    lblDownload.Text = "Yes";
                                }
                                else
                                {
                                    lblDownload.Text = "No";
                                }
                            }
                            else
                            {
                                if (dr["DOWNLOAD"].ToString() == "Y")
                                {
                                    lblDownload.Text = "Yes";
                                }
                                else
                                {
                                    lblDownload.Text = "No";
                                }

                                if (dr["PACKSLIP"].ToString() != "")
                                {
                                    lblShipped.Text = "Shipped - " + dr["DATE_SHIP"].ToString();

                                    if (dr["TRACKTRACE"].ToString() != "")
                                    {
                                        lblTracking.Text = dr["TRACKTRACE"].ToString();
                                    }
                                    else
                                    {
                                        lblTracking.Text = "";
                                    }
                                }
                            }
                        }
                        //---------------------------------------------------------------------------------
                    }
                }
            }
            catch (Exception ECREAx)
            {
                //TO DO: log any error
                if (!dr.IsClosed)
                {
                    dr.Close();
                }
            }

            ProductCollection col = DAL.DAL.GetHistOrderDetail(OrderNum);

            grdViewItems.DataSource = col;
            grdViewItems.DataBind();
        }
コード例 #34
0
 public void Delete(ProductCollection pt)
 {
     _unitOfWork.Repository <ProductCollection>().Delete(pt);
 }
コード例 #35
0
 public ProductCollection Create(ProductCollection pt)
 {
     pt.ObjectState = ObjectState.Added;
     _unitOfWork.Repository <ProductCollection>().Insert(pt);
     return(pt);
 }
コード例 #36
0
 public ProductCollection Add(ProductCollection pt)
 {
     _unitOfWork.Repository <ProductCollection>().Insert(pt);
     return(pt);
 }
コード例 #37
0
 public ProductPage(ProductCollection collection)
 {
     InitializeComponent();
     this.BindingContext = new ProductsViewModel(collection);
 }
コード例 #38
0
        protected void BindData()
        {
            StringBuilder allowedTokensString = new StringBuilder();

            string[] allowedTokens = Pricelist.GetListOfAllowedTokens();
            for (int i = 0; i < allowedTokens.Length; i++)
            {
                string token = allowedTokens[i];
                allowedTokensString.Append(token);
                if (i != allowedTokens.Length - 1)
                {
                    allowedTokensString.Append(", ");
                }
            }
            this.lblAllowedTokens.Text = allowedTokensString.ToString();

            Pricelist pricelist = ProductManager.GetPricelistByID(this.PricelistID);

            if (pricelist != null)
            {
                this.txtAdminNotes.Text    = pricelist.AdminNotes;
                this.txtBody.Text          = pricelist.Body;
                this.txtCacheTime.Value    = pricelist.CacheTime;
                this.txtDescription.Text   = pricelist.Description;
                this.txtDisplayName.Text   = pricelist.DisplayName;
                this.txtFooter.Text        = pricelist.Footer;
                this.txtHeader.Text        = pricelist.Header;
                this.txtPricelistGuid.Text = pricelist.PricelistGuid;
                this.txtShortName.Text     = pricelist.ShortName;
                CommonHelper.SelectListItem(this.ddlExportMode, pricelist.ExportModeID);
                CommonHelper.SelectListItem(this.ddlExportType, pricelist.ExportTypeID);
                CommonHelper.SelectListItem(this.ddlPriceAdjustmentType, pricelist.PriceAdjustmentTypeID);
                CommonHelper.SelectListItem(this.ddlAffiliate, pricelist.AffiliateID);
                this.chkOverrideIndivAdjustment.Checked  = pricelist.OverrideIndivAdjustment;
                this.txtPriceAdjustment.Value            = pricelist.PriceAdjustment;
                this.ddlFormatLocalization.SelectedValue = pricelist.FormatLocalization;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
            else
            {
                ddlFormatLocalization.SelectedValue = System.Globalization.CultureInfo.CurrentCulture.IetfLanguageTag;

                ProductVariantCollection productVariants = new ProductVariantCollection();
                ProductCollection        products        = ProductManager.GetAllProducts();
                foreach (Product product in products)
                {
                    productVariants.AddRange(product.ProductVariants);
                }
                if (productVariants.Count > 0)
                {
                    gvProductVariants.DataSource = productVariants;
                    gvProductVariants.DataBind();
                }
            }
        }
コード例 #39
0
 public ProductCollection GetProductCollection()
 {
     return(ProductCollection.GetFromFileAsync(Path.Combine(_path, "releases-index.json"), false).Result);
 }
コード例 #40
0
        public void GetEventsStartDate()
        {
            DateTime startTime = DateTime.Now.AddMonths(-1);

            AtomFeed atomFeed = new AtomFeed(null, 1, 100000, false, false, null, 11);

            // ATOM LOGIN.
            Assert.AreEqual(true, atomFeed.Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword));

            // ATOM GetProducts.
            AtomProductCollection atomProducts = atomFeed.GetProducts();


            // WERAPI Login.
            Login login = new Login(TestSettings.WinQualUserName, TestSettings.WinQualPassword);

            login.Validate();

            // WERAPI GetProducts.
            ProductCollection apiProducts = Product.GetProducts(ref login);

            Assert.AreEqual(atomProducts.Count, apiProducts.Count);

            bool eventListsDifferent = false;

            foreach (AtomProduct atomProduct in atomProducts)
            {
                // ATOM GetFiles.
                AtomFileCollection atomFiles = atomFeed.GetFiles(atomProduct);

                // API GetFiles
                Product apiProduct = Utils.FindProduct(apiProducts, atomProduct.Product.Id);
                ApplicationFileCollection apiFiles = apiProduct.GetApplicationFiles(ref login);

                Assert.AreEqual(atomFiles.Count, apiFiles.Count);

                foreach (AtomFile atomFile in atomFiles)
                {
                    ApplicationFile apiFile = Utils.FindFile(apiFiles, atomFile.File.Id);

                    // ATOM GetEvents.
                    StackHashEventCollection atomStackHashEvents       = Utils.GetEventsAtom(atomFeed, atomFile, startTime);
                    StackHashEventCollection atomStackHashEventsNoTime = Utils.GetEventsAtom(atomFeed, atomFile);

                    if (atomStackHashEvents.Count != atomStackHashEventsNoTime.Count)
                    {
                        eventListsDifferent = true;
                    }

                    // WERAPI GetEvents.
                    List <Event>             rawApiEvents;
                    StackHashEventCollection apiStackHashEvents = Utils.GetEventsApi(ref login, apiFile, out rawApiEvents, startTime);

                    Assert.AreEqual(apiStackHashEvents.Count, atomStackHashEvents.Count);

                    foreach (StackHashEvent stackHashEvent in atomStackHashEvents)
                    {
                        // Find the equivalent event in the api file list.
                        StackHashEvent apiEvent = apiStackHashEvents.FindEvent(stackHashEvent.Id, stackHashEvent.EventTypeName);

                        Assert.AreNotEqual(null, apiEvent);

                        Assert.AreEqual(true, stackHashEvent.CompareTo(apiEvent) == 0);
                    }
                }
            }

            Assert.AreEqual(true, eventListsDifferent);
        }
コード例 #41
0
        public static void FedExSetPackageLineItems(RateRequest request, Person shipto, ProductCollection cart)
        {
            double MaxWeightPerBox = Double.Parse(ConfigurationManager.AppSettings["MaxWeightPerBox"]);

            boxcount = (int)(cart.TotalWeight / MaxWeightPerBox) + 1;
            request.RequestedShipment.RequestedPackageLineItems = new RequestedPackageLineItem[boxcount];

            for (int i = 0; i < boxcount; i++)
            {
                request.RequestedShipment.RequestedPackageLineItems[i] = new RequestedPackageLineItem();
                request.RequestedShipment.RequestedPackageLineItems[i].SequenceNumber    = (i + 1).ToString(); // package sequence number
                request.RequestedShipment.RequestedPackageLineItems[i].GroupPackageCount = "1";
                // package weight
                request.RequestedShipment.RequestedPackageLineItems[i].Weight       = new Weight();
                request.RequestedShipment.RequestedPackageLineItems[i].Weight.Units = WeightUnits.LB;
                if (i == (boxcount - 1))                                                                                                               //last box
                {
                    request.RequestedShipment.RequestedPackageLineItems[i].Weight.Value = (decimal)((cart.TotalWeight - (i * MaxWeightPerBox)) * 1.1); //plus 10%
                }
                else
                {
                    request.RequestedShipment.RequestedPackageLineItems[i].Weight.Value = (decimal)(MaxWeightPerBox * 1.1);   //plus 10%
                }
                // package dimensions
                //***EAC per Andy's instructions
                request.RequestedShipment.RequestedPackageLineItems[i].Dimensions        = new Dimensions();
                request.RequestedShipment.RequestedPackageLineItems[i].Dimensions.Length = "18";    //per Andy
                request.RequestedShipment.RequestedPackageLineItems[i].Dimensions.Width  = "12";    //per Andy
                request.RequestedShipment.RequestedPackageLineItems[i].Dimensions.Height = "10";    //per Andy
                request.RequestedShipment.RequestedPackageLineItems[i].Dimensions.Units  = LinearUnits.IN;
            }
        }
コード例 #42
0
        public ActionResult Post(ProductCollection vm)
        {
            ProductCollection pt = vm;

            if (ModelState.IsValid)
            {
                if (vm.ProductCollectionId <= 0)
                {
                    pt.CreatedDate  = DateTime.Now;
                    pt.ModifiedDate = DateTime.Now;
                    pt.CreatedBy    = User.Identity.Name;
                    pt.ModifiedBy   = User.Identity.Name;
                    pt.ObjectState  = Model.ObjectState.Added;
                    _ProductCollectionService.Create(pt);

                    int RefDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.ProductCollection).DocumentTypeId;

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = vm.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
                        return(View("Create", vm));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId    = RefDocTypeId,
                        DocId        = pt.ProductCollectionId,
                        ActivityType = (int)ActivityTypeContants.Added,
                    }));

                    ViewBag.id   = vm.ProductTypeId;
                    ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
                    return(RedirectToAction("Edit", new { id = pt.ProductCollectionId }).Success("Data saved successfully"));
                }

                else
                {
                    List <LogTypeViewModel> LogList = new List <LogTypeViewModel>();
                    ProductCollection       temp    = _ProductCollectionService.Find(pt.ProductCollectionId);
                    int RefDocTypeId = new DocumentTypeService(_unitOfWork).Find(MasterDocTypeConstants.ProductCollection).DocumentTypeId;

                    ProductCollection ExRec = Mapper.Map <ProductCollection>(temp);

                    temp.ProductCollectionName = pt.ProductCollectionName;
                    temp.IsActive     = pt.IsActive;
                    temp.ModifiedDate = DateTime.Now;
                    temp.ModifiedBy   = User.Identity.Name;
                    temp.ObjectState  = Model.ObjectState.Modified;
                    _ProductCollectionService.Update(temp);

                    var ProcSeqHeader = (from p in db.ProcessSequenceHeader
                                         where p.ReferenceDocId == temp.ProductCollectionId && p.ReferenceDocTypeId == RefDocTypeId
                                         select p).FirstOrDefault();

                    if (ProcSeqHeader != null)
                    {
                        ProcSeqHeader.ProcessSequenceHeaderName = temp.ProductCollectionName + "-" + new DivisionService(_unitOfWork).Find((int)HttpContext.Session["DivisionId"]).DivisionName;
                    }


                    LogList.Add(new LogTypeViewModel
                    {
                        ExObj = ExRec,
                        Obj   = temp,
                    });
                    XElement Modifications = new ModificationsCheckService().CheckChanges(LogList);

                    try
                    {
                        _unitOfWork.Save();
                    }

                    catch (Exception ex)
                    {
                        string message = _exception.HandleException(ex);
                        ModelState.AddModelError("", message);
                        ViewBag.id   = pt.ProductTypeId;
                        ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName;
                        return(View("Create", pt));
                    }

                    LogActivity.LogActivityDetail(LogVm.Map(new ActiivtyLogViewModel
                    {
                        DocTypeId       = RefDocTypeId,
                        DocId           = temp.ProductCollectionId,
                        ActivityType    = (int)ActivityTypeContants.Modified,
                        xEModifications = Modifications,
                    }));

                    ViewBag.id   = pt.ProductTypeId;
                    ViewBag.Name = new ProductTypeService(_unitOfWork).Find(pt.ProductTypeId).ProductTypeName;
                    return(RedirectToAction("Index", new { id = vm.ProductTypeId }).Success("Data saved successfully"));
                }
            }
            ViewBag.id   = vm.ProductTypeId;
            ViewBag.Name = new ProductTypeService(_unitOfWork).Find(vm.ProductTypeId).ProductTypeName;
            return(View("Create", vm));
        }
コード例 #43
0
 public ProductCollectionTest()
 {
     _sut = new ProductCollection(_productRepoMock.Object);
 }
コード例 #44
0
        private void UpdateProducts(bool forceResynchronize, IErrorIndex errorIndex, ProductCollection products, bool getEvents, bool getCabs)
        {
            // Product -1 is the special product ID that indicates when the last sync of products
            // was complete.
            DateTime lastProductPullDate = errorIndex.GetLastSyncTimeLocal(-1);

            if (forceResynchronize)
            {
                lastProductPullDate = new DateTime(0, DateTimeKind.Local);
            }

            // Add the products first.
            foreach (Product product in products)
            {
                if (m_AbortRequested)
                {
                    throw new OperationCanceledException("Abort requested during Win Qual synchronize");
                }

                m_SyncProgress.ProductId = product.ID;

                StackHashProduct stackHashProduct = ObjectConversion.ConvertProduct(product);

                // Check the date created. If it is greater than the last pull date then
                // this is a new product so add a product record.
                if (product.DateCreatedLocal > lastProductPullDate)
                {
                    errorIndex.AddProduct(stackHashProduct);
                }
                else if (product.DateModifiedLocal > lastProductPullDate)
                {
                    // Update the product information if product last modified date is greater than
                    // the last pull date.
                    errorIndex.AddProduct(stackHashProduct);
                }
                else
                {
                    // Check if the file exists. If not then add it.
                    if (!errorIndex.ProductExists(stackHashProduct))
                    {
                        errorIndex.AddProduct(stackHashProduct);
                    }
                }

                if (getEvents && !isExcludedProduct(stackHashProduct.Id))
                {
                    // Get the last date that this product was synchronized on WinQual.
                    DateTime lastPullDate = errorIndex.GetLastSyncTimeLocal(stackHashProduct.Id);

                    if (forceResynchronize)
                    {
                        lastPullDate = new DateTime(0, DateTimeKind.Local);
                    }

                    UpdateFiles(lastPullDate, errorIndex, product, stackHashProduct, getCabs);

                    if (getCabs)
                    {
                        onProgress(WinQualProgressType.ProductCabsUpdated, stackHashProduct);
                    }
                    else
                    {
                        onProgress(WinQualProgressType.ProductEventsUpdated, stackHashProduct);
                    }

                    if (getCabs)
                    {
                        // Completed getting all events and cabs for this product.
                        errorIndex.SetLastSyncTimeLocal(stackHashProduct.Id, DateTime.Now);
                    }
                }
            }

            errorIndex.SetLastSyncTimeLocal(-1, DateTime.Now);
        }
コード例 #45
0
        /// <summary>
        /// Generates the feed data for given products
        /// </summary>
        /// <param name="products">The products to generate feed for</param>
        /// <returns>Feed data generated</returns>
        protected override string GetFeedData(ProductCollection products)
        {
            //write header row
            StringWriter  feedWriter = new StringWriter();
            StringBuilder feedLine;

            string storeUrl = Token.Instance.Store.StoreUrl;

            storeUrl = storeUrl + (storeUrl.EndsWith("/") ? "" : "/");

            string url, name, desc, price, imgurl, category, mpn, upc, manufacturer, stock, stockdesc, shiprate;

            foreach (Product product in products)
            {
                url = product.NavigateUrl;
                if (url.StartsWith("~/"))
                {
                    url = url.Substring(2);
                }
                url = storeUrl + url;

                name = CleanupText(product.Name);
                desc = CleanupText(product.Summary);
                if (desc.Length > 1024)
                {
                    desc = desc.Substring(0, 1024);
                }

                price = string.Format("{0:F2}", product.Price);

                imgurl = product.ImageUrl;
                if (!string.IsNullOrEmpty(imgurl) && !IsAbsoluteURL(imgurl))
                {
                    if (imgurl.StartsWith("~/"))
                    {
                        imgurl = imgurl.Substring(2);
                    }
                    imgurl = storeUrl + imgurl;
                }

                if (product.Categories.Count > 0)
                {
                    List <CatalogPathNode> path = CatalogDataSource.GetPath(product.Categories[0], false);
                    category = "";
                    foreach (CatalogPathNode item in path)
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        if (category.Length > 0)
                        {
                            category = category + "->" + CleanupText(item.Name);
                        }
                        else
                        {
                            category = CleanupText(item.Name);
                        }
                    }
                }
                else
                {
                    category = "None";
                }

                manufacturer = "";
                if (product.Manufacturer != null)
                {
                    manufacturer = CleanupText(product.Manufacturer.Name);
                }

                mpn = product.ModelNumber;

                if (product.InventoryMode == InventoryMode.Product)
                {
                    stock = product.InStock > 0 ? "Y" : "N";
                }

                // IF INVENTORY IS DISABLED OR INVENTORY MODE IS TRACK VARIANTS, ASSUME INVENTORY IS AVAILABLE
                else
                {
                    stock = "Y";
                }

                //TODO
                stockdesc = "New";

                upc      = this.IsUpcCode(product.Sku) ? product.Sku : string.Empty;
                shiprate = "";

                feedLine = new StringBuilder();
                feedLine.Append(mpn + "," + upc + ",\"" + manufacturer
                                + "\",\"" + name + "\",\"" + desc + "\"," + price
                                + "," + stock + "," + stockdesc + "," + url
                                + "," + imgurl + ",\"" + category + "\"," + shiprate);
                feedWriter.WriteLine(feedLine.ToString());
            }

            string returnData = feedWriter.ToString();

            feedWriter.Close();

            return(returnData);
        }
コード例 #46
0
        protected void chkReOrder_CheckedChanged(object sender, EventArgs e)
        {
            if (chkReOrder.Checked)
            {
                this.shoppingcart = null;     //destroy cart if it exists
                this.shoppingcart = new ProductCollection();

                ProductCollection colOrigOrder = DAL.DAL.GetOrigOrderDetail(OrderNum);

                /*foreach (GridViewRow item in grdViewItems.Rows)
                 * {
                 *  TextBox txtQty = (TextBox)item.FindControl("txtQty");
                 *  HiddenField hdnPubID = (HiddenField)item.FindControl("hdnPubID");
                 *
                 *  int pubid = Int32.Parse(hdnPubID.Value);
                 *  Product p = Product.GetCartPubByPubID(pubid);
                 *  p.NumQtyOrdered = Int32.Parse(txtQty.Text);
                 *  this.shoppingcart.Add(p);
                 *
                 *  Session["NCIPL_Pubs"] = this.shoppingcart.Pubs;
                 *  Session["NCIPL_Qtys"] = this.shoppingcart.Qtys;
                 * }*/


                foreach (Product item in colOrigOrder)
                {
                    //TextBox txtQty = (TextBox)item.FindControl("txtQty");
                    //HiddenField hdnPubID = (HiddenField)item.FindControl("hdnPubID");

                    int pubid = item.PubId;
                    //Do not add to the cart if Pub is a Promotion Pub
                    if (DAL.DAL.IsPromotionPub(pubid) == 0)
                    {
                        Product p = Product.GetCartPubByPubID(pubid);
                        p.NumQtyOrdered = item.NumQtyOrdered;
                        this.shoppingcart.Add(p);

                        Session["NCIPL_Pubs"] = this.shoppingcart.Pubs;
                        Session["NCIPL_Qtys"] = this.shoppingcart.Qtys;
                    }
                }

                if (chkUseAddress4NewOrder.Checked)
                {
                }
                else
                {
                    Session["SEARCHORDER_CUSTID"] = CustID;

                    Customer Cust = DAL.DAL.GetOrderCustInfobyCustID(CustID);
                    this.shipto = new Person(1, Cust.ShipToName, Cust.ShipToOrg, Cust.ShipToEmail, Cust.ShipToAddr1, Cust.ShipToAddr2, Cust.ShipToCity, Cust.ShipToState, Cust.ShipToZip5, Cust.ShipToZip4, Cust.ShipToPhone);
                    this.billto = new Person(1, Cust.BillToName, Cust.BillToOrg, Cust.BillToEmail, Cust.BillToAddr1, Cust.BillToAddr2, Cust.BillToCity, Cust.BillToState, Cust.BillToZip5, Cust.BillToZip4, Cust.BillToPhone);
                }
            }
            else
            {
                Session["NCIPL_cart"] = null;           //destroy
                Session["NCIPL_Pubs"] = null;           //destroy
                Session["NCIPL_Qtys"] = null;           //destroy

                if (chkUseAddress4NewOrder.Checked)
                {
                }
                else
                {
                    Session["SEARCHORDER_CUSTID"] = null;   //destroy

                    Session["NCIPL_shipto"] = null;         //destroy
                    Session["NCIPL_billto"] = null;         //destroy
                }
            }

            //Display the master page tabs
            GlobalUtils.Utils UtilMethod = new GlobalUtils.Utils();
            if (Session["NCIPL_Pubs"] != null)
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp(Session["NCIPL_Qtys"].ToString(), "cart");
            }
            else
            {
                Master.LiteralText = UtilMethod.GetTabHtmlMarkUp("", "cart");
            }
            UtilMethod = null;
        }
コード例 #47
0
        /// <summary>
        /// Generate froogle feed
        /// </summary>
        /// <param name="stream">Stream</param>
        public static void GenerateFeed(Stream stream)
        {
            const string googleBaseNamespace = "http://base.google.com/ns/1.0";

            XmlWriterSettings settings = new XmlWriterSettings
            {
                Encoding = Encoding.UTF8
            };

            using (XmlWriter writer = XmlWriter.Create(stream, settings))
            {
                writer.WriteStartDocument();
                writer.WriteStartElement("rss");
                writer.WriteAttributeString("version", "2.0");
                writer.WriteAttributeString("xmlns", "g", null, googleBaseNamespace);
                writer.WriteStartElement("channel");
                writer.WriteElementString("title", string.Format("{0} Google Base", SettingManager.StoreName));
                writer.WriteElementString("link", "http://base.google.com/base/");
                writer.WriteElementString("description", "Information about products");


                ProductCollection products = ProductManager.GetAllProducts(false);
                foreach (Product product in products)
                {
                    ProductVariantCollection productVariants = ProductManager.GetProductVariantsByProductID(product.ProductID, false);

                    foreach (ProductVariant productVariant in productVariants)
                    {
                        writer.WriteStartElement("item");
                        writer.WriteElementString("link", SEOHelper.GetProductURL(product));
                        writer.WriteElementString("title", productVariant.FullProductName);
                        writer.WriteStartElement("description");
                        string description = productVariant.Description;
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.FullDescription;
                        }
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.ShortDescription;
                        }
                        if (String.IsNullOrEmpty(description))
                        {
                            description = product.Name;
                        }
                        writer.WriteCData(description);
                        writer.WriteEndElement();     // description
                        writer.WriteStartElement("g", "brand", googleBaseNamespace);
                        writer.WriteFullEndElement(); // g:brand
                        writer.WriteElementString("g", "condition", googleBaseNamespace, "new");
                        writer.WriteElementString("g", "expiration_date", googleBaseNamespace, DateTime.Now.AddDays(30).ToString("yyyy-MM-dd"));
                        writer.WriteElementString("g", "id", googleBaseNamespace, productVariant.ProductVariantID.ToString());
                        string imageUrl = string.Empty;
                        ProductPictureCollection productPictures = product.ProductPictures;
                        if (productPictures.Count > 0)
                        {
                            imageUrl = PictureManager.GetPictureUrl(productPictures[0].Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize"), true);
                        }
                        writer.WriteElementString("g", "image_link", googleBaseNamespace, imageUrl);
                        decimal price = productVariant.Price;
                        writer.WriteElementString("g", "price", googleBaseNamespace, price.ToString(new CultureInfo("en-US", false).NumberFormat));
                        writer.WriteStartElement("g", "product_type", googleBaseNamespace);
                        writer.WriteFullEndElement(); // g:brand
                        //if (productVariant.Weight != decimal.Zero)
                        //{
                        //    writer.WriteElementString("g", "weight", googleBaseNamespace, string.Format(CultureInfo.InvariantCulture, "{0} {1}", productVariant.Weight.ToString(new CultureInfo("en-US", false).NumberFormat), MeasureManager.BaseWeightIn.SystemKeyword));
                        //}
                        writer.WriteEndElement(); // item
                    }
                }

                writer.WriteEndElement(); // channel
                writer.WriteEndElement(); // rss
                writer.WriteEndDocument();
            }
        }
コード例 #48
0
        public void _0001_Test()
        {
            SupplierCollection suppliers = new SupplierCollection();

            suppliers.Add(new SuplierItem(1, "Lomex"));
            suppliers.Add(new SuplierItem(2, "TME"));
            suppliers.Add(new SuplierItem(3, "Farnell"));
            suppliers.Add(new SuplierItem(4, "CBA"));

            ProductCollection products = new ProductCollection();

            products.Add(new ProductItem(1, "1N4148", "Dióda", 1));
            products.Add(new ProductItem(2, "BC128", "Tranzisztor", 1));
            products.Add(new ProductItem(3, "AT90CAN128", "Processzor", 2));
            products.Add(new ProductItem(4, "ESD szönyeg", "ESD Védelem", 2));
            //products.Add(new ProductItem(5, "Henkel On", "Forrasztás", 3));
            //products.Add(new ProductItem(6, "Weller WP szürő", "Egészség", 3));
            //products.Add(new ProductItem(7, "Banán", "Gyümölcs", 2));


            /*Data SET*/
            DataSet dataSet = new DataSet("DemoDataSet");

            /*Suppliers*/
            /*SupplierId-PK,SupplierName*/
            DataTable suppliersDt = ToDataTable(suppliers, "Suppliers");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["SupplierId"] };
            dataSet.Tables.Add(suppliersDt);

            /*Products*/
            /*ProductId-PK, ProductName, Description, SupplierId*/
            DataTable productsDt = ToDataTable(products, "Products");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["ProductId"] };
            DataColumn supplierNameColumn = new DataColumn("SupplierName", typeof(string));

            productsDt.Columns.Add(supplierNameColumn);

            dataSet.Tables.Add(productsDt);

            /* */

            DataRelation productsSuppliersRelation = dataSet.Relations.Add("ProductSuppliers",
                                                                           dataSet.Tables["Suppliers"].Columns["SupplierId"],
                                                                           dataSet.Tables["Products"].Columns["SupplierId"], true);



            dataSet.AcceptChanges();

            DataGrid dg = new DataGrid();

            dg.SetDataBinding(dataSet, "Products");

            var form = new Form2();


            form.dataGridView1.DataSource = dataSet;
            form.dataGridView1.DataMember = "Products";

            form.dataGridView2.DataSource = dataSet;
            form.dataGridView2.DataMember = "Suppliers";


            Application.Run(form);
        }
コード例 #49
0
ファイル: ProductService.cs プロジェクト: ibollen/website
        /// <summary>
        /// 条件查询产品
        /// </summary>
        /// <param name="istop">置顶</param>
        /// <param name="iscommend">推荐</param>
        /// <returns>ProductCollection 包含条件查询的记录</returns>
        public static ProductCollection GetList(bool istop, bool iscommend)
        {
            bool bIsTop = false;
            bool bIsCommend = false;

            if (istop)
            {
                bIsTop = istop;
            }
            if (iscommend)
            {
                bIsCommend = iscommend;
            }

            ProductCollection list = null;

            string sql = "select * from t_product where IsTop=?IsTop and IsCommend=?IsCommend";
            MySqlParameter[] parms = {
                                        new MySqlParameter("?IsTop",MySqlDbType.Bit),
                                        new MySqlParameter("?IsCommend",MySqlDbType.Bit)
                                     };
            parms[0].Value = bIsTop;
            parms[1].Value = bIsCommend;

            MySqlDataReader reader = DbHelper.ExecuteDataReader(sql, parms);
            if (reader.HasRows)
            {
                list = new ProductCollection();
                while (reader.Read())
                {
                    list.Add(FillDataRecord(reader));
                }
            }
            reader.Close();

            return list;
        }
コード例 #50
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         /////////////////////////////fill the product boxes///////////////////////////////////
         ProductCollection products = new ProductCollection();
         products.ReadList();
         //////BOX1/////
         lbl_title1.Text       = products[0].Brand + "-" + products[0].ProductName;
         lbl_id1.Text          = products[0].ProductId;
         img_product1.ImageUrl = "./Images/Products/" + products[0].Discount;
         lbl_price1.Text       = "قیمت: " + products[0].Price + " تومان";
         ////////
         //////BOX2/////
         lbl_title2.Text       = products[1].Brand + "-" + products[1].ProductName;
         lbl_id2.Text          = products[1].ProductId;
         img_product2.ImageUrl = "./Images/Products/" + products[1].Discount;
         lbl_price2.Text       = "قیمت: " + products[1].Price + " تومان";
         ////////
         //////BOX3/////
         lbl_title3.Text       = products[2].Brand + "-" + products[2].ProductName;
         lbl_id3.Text          = products[2].ProductId;
         img_product3.ImageUrl = "./Images/Products/" + products[2].Discount;
         lbl_price3.Text       = "قیمت: " + products[2].Price + " تومان";
         ////////
         //////BOX4/////
         lbl_title4.Text       = products[3].Brand + "-" + products[3].ProductName;
         lbl_id4.Text          = products[3].ProductId;
         img_product4.ImageUrl = "./Images/Products/" + products[3].Discount;
         lbl_price4.Text       = "قیمت: " + products[3].Price + " تومان";
         ////////
         //////BOX5/////
         lbl_title5.Text       = products[4].Brand + "-" + products[4].ProductName;
         lbl_id5.Text          = products[4].ProductId;
         img_product5.ImageUrl = "./Images/Products/" + products[4].Discount;
         lbl_price5.Text       = "قیمت: " + products[4].Price + " تومان";
         ////////
         //////BOX6/////
         lbl_title6.Text       = products[5].Brand + "-" + products[5].ProductName;
         lbl_id6.Text          = products[5].ProductId;
         img_product6.ImageUrl = "./Images/Products/" + products[5].Discount;
         lbl_price6.Text       = "قیمت: " + products[5].Price + " تومان";
         ////////
         //////BOX7/////
         lbl_title7.Text       = products[6].Brand + "-" + products[6].ProductName;
         lbl_id7.Text          = products[6].ProductId;
         img_product7.ImageUrl = "./Images/Products/" + products[6].Discount;
         lbl_price7.Text       = "قیمت: " + products[6].Price + " تومان";
         ////////
         //////BOX8/////
         lbl_title8.Text       = products[7].Brand + "-" + products[7].ProductName;
         lbl_id8.Text          = products[7].ProductId;
         img_product8.ImageUrl = "./Images/Products/" + products[7].Discount;
         lbl_price8.Text       = "قیمت: " + products[7].Price + " تومان";
         ////////
         //////BOX9/////
         lbl_title9.Text       = products[8].Brand + "-" + products[8].ProductName;
         lbl_id9.Text          = products[8].ProductId;
         img_product9.ImageUrl = "./Images/Products/" + products[8].Discount;
         lbl_price9.Text       = "قیمت: " + products[8].Price + " تومان";
         ////////
         //////BOX10/////
         lbl_title10.Text       = products[9].Brand + "-" + products[9].ProductName;
         lbl_id10.Text          = products[9].ProductId;
         img_product10.ImageUrl = "./Images/Products/" + products[9].Discount;
         lbl_price10.Text       = "قیمت: " + products[9].Price + " تومان";
         ////////
     }
 }
コード例 #51
0
ファイル: ProductService.cs プロジェクト: ibollen/website
        /// <summary>
        /// 查询产品 所有数据
        /// </summary>
        /// <param name="pc_id"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="maximumRows"></param>
        /// <returns>ProductCollection 包含所有记录</returns>
        public static ProductCollection GetList(int pc_id, int startRowIndex, int maximumRows)
        {
            int iStartRowIndex = -1;
            int iMaximumRows = -1;

            if (startRowIndex > 0 && maximumRows > 0)
            {
                iStartRowIndex = startRowIndex;
                iMaximumRows = maximumRows;
            }

            ProductCollection list = new ProductCollection();

            string sql = @"SELECT
                                prod_id,
                                prod_name,
                                prod_number,
                                prod_price,
                                prod_image,
                                prod_content,
                                prod_date,
                                prod_click,
                                istop,
                                iscommend,
                                pc_id
                            FROM
                            (
                                select
                                   *, (select ifnull(sum(1) + 1, 1)
                                        from t_product
                                        where (?pc_id=0 or pc_id=?pc_id) and prod_id > a.prod_id) as row_rank
                                from t_product a
                                where
                                ?pc_id=0
                                or
                                pc_id in (select pc_id from (select pc_id from t_productclass where pc_id=?pc_id
                                                         union all
                                                         select p.pc_id
                                                         from t_productclass p
                                                         inner join
                                                         (select pc_id
                                                         from t_productclass
                                                         where pc_id=?pc_id) t on p.parent_id = t.pc_id) as temp)
                                order by prod_id desc
                            )
                            as ProductWithRowNumbers
                            where
                            ((row_rank between ?start_row_index AND ?start_row_index + ?maximum_rows - 1)
                                        OR ?start_row_index = -1 OR ?maximum_rows = -1);";

             MySqlParameter[] parms = {
                                         new MySqlParameter("?pc_id",MySqlDbType.Int32),
                                         new MySqlParameter("?start_row_index",MySqlDbType.Int32),
                                         new MySqlParameter("?maximum_rows",MySqlDbType.Int32)
                                     };
            parms[0].Value = pc_id;
            parms[1].Value = iStartRowIndex;
            parms[2].Value = iMaximumRows;

            MySqlDataReader reader = DbHelper.ExecuteDataReader(sql, parms);
            if (reader.HasRows)
            {
                list = new ProductCollection();
                while (reader.Read())
                {
                    list.Add(FillDataRecord(reader));
                }
            }
            reader.Close();

            return list;
        }
コード例 #52
0
        /// <summary>
        /// Generate the bootstrapper.
        /// </summary>
        /// <returns> Return true on success, false on failure.</returns>
        public override bool Execute()
        {
            if (Path == null)
            {
                Path = Util.GetDefaultPath(VisualStudioVersion);
            }

            var bootstrapperBuilder = new BootstrapperBuilder
            {
                Validate = Validate,
                Path     = Path
            };

            ProductCollection products = bootstrapperBuilder.Products;

            var settings = new BuildSettings
            {
                ApplicationFile = ApplicationFile,
                ApplicationName = ApplicationName,
                ApplicationRequiresElevation = ApplicationRequiresElevation,
                ApplicationUrl     = ApplicationUrl,
                ComponentsLocation = ConvertStringToComponentsLocation(ComponentsLocation),
                ComponentsUrl      = ComponentsUrl,
                CopyComponents     = CopyComponents,
                Culture            = Culture,
                FallbackCulture    = FallbackCulture,
                OutputPath         = OutputPath,
                SupportUrl         = SupportUrl
            };

            if (String.IsNullOrEmpty(settings.Culture) || settings.Culture == "*")
            {
                settings.Culture = settings.FallbackCulture;
            }

            if (BootstrapperItems != null)
            {
                // The bootstrapper items may not be in the correct order, because XMake saves
                // items in alphabetical order.  So we will attempt to put items into the correct
                // order, according to the Products order in the search.  To do this, we add all
                // the items we are told to build into a hashtable, then go through our products
                // in order, looking to see if the item is built.  If it is, remove the item from
                // the hashtable.  All remaining items in the table can not be built, so errors
                // will be issued.
                var items = new Dictionary <string, ITaskItem>(StringComparer.OrdinalIgnoreCase);

                foreach (ITaskItem bootstrapperItem in BootstrapperItems)
                {
                    string installAttribute = bootstrapperItem.GetMetadata("Install");
                    if (String.IsNullOrEmpty(installAttribute) || Shared.ConversionUtilities.ConvertStringToBool(installAttribute))
                    {
                        if (!items.ContainsKey(bootstrapperItem.ItemSpec))
                        {
                            items.Add(bootstrapperItem.ItemSpec, bootstrapperItem);
                        }
                        else
                        {
                            Log.LogWarningWithCodeFromResources("GenerateBootstrapper.DuplicateItems", bootstrapperItem.ItemSpec);
                        }
                    }
                }

                foreach (Product product in products)
                {
                    if (items.ContainsKey(product.ProductCode))
                    {
                        settings.ProductBuilders.Add(product.ProductBuilder);
                        items.Remove(product.ProductCode);
                    }
                }

                foreach (ITaskItem bootstrapperItem in items.Values)
                {
                    Log.LogWarningWithCodeFromResources("GenerateBootstrapper.ProductNotFound", bootstrapperItem.ItemSpec, bootstrapperBuilder.Path);
                }
            }

            BuildResults results = bootstrapperBuilder.Build(settings);

            BuildMessage[] messages = results.Messages;

            if (messages != null)
            {
                foreach (BuildMessage message in messages)
                {
                    if (message.Severity == BuildMessageSeverity.Error)
                    {
                        Log.LogError(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                    else if (message.Severity == BuildMessageSeverity.Warning)
                    {
                        Log.LogWarning(null, message.HelpCode, message.HelpKeyword, null, 0, 0, 0, 0, message.Message);
                    }
                }
            }

            BootstrapperKeyFile        = results.KeyFile;
            BootstrapperComponentFiles = results.ComponentFiles;

            return(results.Succeeded);
        }
コード例 #53
0
 public void Acc_Products_CollectionLoad2()
 {
     ProductCollection products = new ProductCollection().Load();
     Assert.AreEqual(77, products.Count);
 }
コード例 #54
0
        protected void LoadBody()
        {
            ltBody.Text  = "<form method=\"post\" action=\"entityBulkDownloadFiles.aspx?entityname=" + EntityName + "&EntityID=" + EntityID + "\">";
            ltBody.Text += "<div style=\"width: 100%; border-top: solid 1px #d2d2d2; padding-top: 3px; margin-top: 5px;\">";
            ltBody.Text += ("<input type=\"hidden\" name=\"EntityName\" value=\"" + EntityName + "\">\n");
            ltBody.Text += ("<input type=\"hidden\" name=\"EntityID\" value=\"" + EntityID + "\">\n");

            ProductCollection products = new ProductCollection(m_EntitySpecs.m_EntityName, EntityID);

            products.PageSize          = 0;
            products.PageNum           = 1;
            products.PublishedOnly     = false;
            products.ReturnAllVariants = true;

            Int32 mappingCount = DB.GetSqlN("select count(*) as N from Product" + this.m_EntitySpecs.m_EntityName + " where " + m_EntitySpecs.m_EntityName + "Id = " + this.EntityID.ToString());

            DataSet dsProducts = new DataSet();

            if (mappingCount > 0)
            {
                dsProducts = products.LoadFromDB();
            }

            int NumProducts = products.NumProducts;

            if (NumProducts > 1000)
            {
                ltBody.Text += ("<p><b>" + AppLogic.GetString("admin.common.ImportExcession", SkinID, LocaleSetting) + "</b></p>");
            }
            else if (NumProducts > 0)
            {
                ltBody.Text += ("<script type=\"text/javascript\">\n");
                ltBody.Text += ("function Form_Validator(theForm)\n");
                ltBody.Text += ("{\n");
                ltBody.Text += ("submitonce(theForm);\n");
                ltBody.Text += ("return (true);\n");
                ltBody.Text += ("}\n");
                ltBody.Text += ("</script>\n");

                ltBody.Text += ("<input type=\"hidden\" name=\"IsSubmit\" value=\"true\">\n");
                ltBody.Text += ("<table border=\"0\" cellpadding=\"0\" border=\"0\" cellspacing=\"0\" width=\"100%\">\n");
                ltBody.Text += ("<tr class=\"table-header\">\n");
                ltBody.Text += ("<td><b>" + AppLogic.GetString("admin.common.ProductID", SkinID, LocaleSetting) + "</b></td>\n");
                ltBody.Text += ("<td><b>" + AppLogic.GetString("admin.common.VariantID", SkinID, LocaleSetting) + "</b></td>\n");
                ltBody.Text += ("<td><b>" + AppLogic.GetString("admin.common.ProductName", SkinID, LocaleSetting) + "</b></td>\n");
                ltBody.Text += ("<td><b>" + AppLogic.GetString("admin.common.VariantName", SkinID, LocaleSetting) + "</b></td>\n");
                ltBody.Text += ("<td align=\"left\"><b>" + AppLogic.GetString("admin.common.DownloadFile", SkinID, LocaleSetting) + "</b></td>\n");
                ltBody.Text += ("</tr>\n");
                int LastProductID = 0;


                int rowcount = dsProducts.Tables[0].Rows.Count;

                for (int i = 0; i < rowcount; i++)
                {
                    DataRow row = dsProducts.Tables[0].Rows[i];

                    if (DB.RowFieldBool(row, "IsDownload"))
                    {
                        int ThisProductID = DB.RowFieldInt(row, "ProductID");
                        int ThisVariantID = DB.RowFieldInt(row, "VariantID");

                        if (i % 2 == 0)
                        {
                            ltBody.Text += ("<tr class=\"table-row2\">\n");
                        }
                        else
                        {
                            ltBody.Text += ("<tr class=\"table-alternatingrow2\">\n");
                        }
                        ltBody.Text += ("<td align=\"left\" valign=\"middle\">");
                        ltBody.Text += (ThisProductID.ToString());
                        ltBody.Text += ("</td>");
                        ltBody.Text += ("<td align=\"left\" valign=\"middle\">");
                        ltBody.Text += (ThisVariantID.ToString());
                        ltBody.Text += ("</td>");
                        ltBody.Text += ("<td align=\"left\" valign=\"middle\">");
                        bool showlinks = false;
                        if (showlinks)
                        {
                            ltBody.Text += ("<a target=\"entityBody\" href=\"" + AppLogic.AdminLinkUrl("entityeditproducts.aspx") + "?iden=" + ThisProductID.ToString() + "&entityname=" + EntityName + "&entityid=" + EntityID.ToString() + "\">");
                        }
                        ltBody.Text += (DB.RowFieldByLocale(row, "Name", cust.LocaleSetting));
                        if (showlinks)
                        {
                            ltBody.Text += ("</a>");
                        }
                        ltBody.Text += ("</td>\n");
                        ltBody.Text += ("<td align=\"left\" valign=\"middle\">");
                        if (showlinks)
                        {
                            ltBody.Text += ("<a target=\"entityBody\" href=\"" + AppLogic.AdminLinkUrl("entityeditproductvariant.aspx") + "?iden=" + ThisProductID.ToString() + "&variantid=" + ThisVariantID.ToString() + "&entityname=" + EntityName + "&entityid=" + EntityID.ToString() + "\">");
                        }
                        ltBody.Text += (DB.RowFieldByLocale(row, "VariantName", cust.LocaleSetting));
                        if (showlinks)
                        {
                            ltBody.Text += ("</a>");
                        }
                        ltBody.Text  += ("</td>\n");
                        ltBody.Text  += ("<td align=\"left\" valign=\"middle\">");
                        ltBody.Text  += ("<input maxLength=\"1000\" class=\"singleNormal\" onkeypress=\"javascript:return WebForm_FireDefaultButton(event, 'btnsubmit')\" name=\"DownloadLocation_" + ThisProductID.ToString() + "_" + ThisVariantID.ToString() + "\" value=\"" + DB.RowField(row, "DownloadLocation") + "\">\n");
                        ltBody.Text  += ("</td>\n");
                        ltBody.Text  += ("</tr>\n");
                        LastProductID = ThisProductID;
                    }
                }
                if (LastProductID == 0)
                {
                    ltBody.Text += ("</table>\n");
                    ltBody.Text += ("<p align=\"left\"><b>" + AppLogic.GetString("admin.common.NoDownloadProductsFound", SkinID, LocaleSetting) + "</b></p>");
                }
                else
                {
                    ltBody.Text += ("<tr><td colspan=\"5\" align=\"right\"><input type=\"submit\" id=\"btnsubmit\" value=\"" + AppLogic.GetString("admin.entityBulkDownloadFiles.DownloadUpdate", SkinID, LocaleSetting) + "\" name=\"Submit\" class=\"normalButtons\"></td></tr>\n");
                    ltBody.Text += ("</table>\n");
                }
            }
            else
            {
                ltBody.Text += ("<p><b>" + AppLogic.GetString("admin.common.NoProductsFound", SkinID, LocaleSetting) + "</b></p>");
            }
            dsProducts.Dispose();
            products.Dispose();

            ltBody.Text += ("</div>");
            ltBody.Text += ("</form>");
        }
コード例 #55
0
        public void _0001_Test()
        {
            SupplierCollection suppliers = new SupplierCollection();

            suppliers.Add(new SuplierItem(1, "Lomex"));
            suppliers.Add(new SuplierItem(2, "TME"));
            suppliers.Add(new SuplierItem(3, "Farnell"));
            suppliers.Add(new SuplierItem(4, "CBA"));

            ProductCollection products = new ProductCollection();

            products.Add(new ProductItem(1, "1N4148", "Dióda", 1));
            products.Add(new ProductItem(2, "BC128", "Tranzisztor", 1));
            products.Add(new ProductItem(3, "AT90CAN128", "Processzor", 2));
            products.Add(new ProductItem(4, "ESD szönyeg", "ESD Védelem", 2));
            //products.Add(new ProductItem(5, "Henkel On", "Forrasztás", 3));
            //products.Add(new ProductItem(6, "Weller WP szürő", "Egészség", 3));
            //products.Add(new ProductItem(7, "Banán", "Gyümölcs", 2));


            /*Data SET*/
            DataSet dataSet = new DataSet("DemoDataSet");

            /*Suppliers*/
            /*SupplierId-PK,SupplierName*/
            DataTable suppliersDt = ToDataTable(suppliers, "Suppliers");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["SupplierId"] };
            dataSet.Tables.Add(suppliersDt);

            /*Products*/
            /*ProductId-PK, ProductName, Description, SupplierId*/
            DataTable productsDt = ToDataTable(products, "Products");

            suppliersDt.PrimaryKey = new DataColumn[] { suppliersDt.Columns["ProductId"] };
            DataColumn supplierNameColumn = new DataColumn("SupplierName", typeof(string));

            productsDt.Columns.Add(supplierNameColumn);

            dataSet.Tables.Add(productsDt);

            /* */

            DataColumn parentColumn = dataSet.Tables["Suppliers"].Columns["SupplierId"];
            DataColumn childColumn  = dataSet.Tables["Products"].Columns["ProductId"];

            ForeignKeyConstraint fKConstraint;

            fKConstraint                  = new ForeignKeyConstraint("SupplierFKConstraint", parentColumn, childColumn);
            fKConstraint.DeleteRule       = Rule.SetNull;
            fKConstraint.UpdateRule       = Rule.Cascade;
            fKConstraint.AcceptRejectRule = AcceptRejectRule.Cascade;

            dataSet.Tables["Products"].Constraints.Add(fKConstraint);
            dataSet.EnforceConstraints = true;

            dataSet.AcceptChanges();

            var form = new Form2();


            form.dataGridView1.DataSource = dataSet;
            form.dataGridView1.DataMember = "Products";

            form.dataGridView2.DataSource = dataSet;
            form.dataGridView2.DataMember = "Suppliers";

            Application.Run(form);
        }
コード例 #56
0
        public static double UPSEstimatedRate(Person shipto, ProductCollection cart)
        {
            double temp = 0.0;  //return 0.0 if something is wrong

            try
            {
                RateService rate        = new RateService();
                RateRequest rateRequest = new RateRequest();
                UPSSecurity upss        = new UPSSecurity();
                UPSSecurityServiceAccessToken upssSvcAccessToken = new UPSSecurityServiceAccessToken();
                upssSvcAccessToken.AccessLicenseNumber = ConfigurationManager.AppSettings["UPSAccessLicenseNumber"];
                upss.ServiceAccessToken = upssSvcAccessToken;
                UPSSecurityUsernameToken upssUsrNameToken = new UPSSecurityUsernameToken();
                upssUsrNameToken.Username = ConfigurationManager.AppSettings["UPSUserName"];
                upssUsrNameToken.Password = ConfigurationManager.AppSettings["UPSPassword"];
                upss.UsernameToken        = upssUsrNameToken;
                rate.UPSSecurityValue     = upss;
                RequestType request       = new RequestType();
                String[]    requestOption = { "Rate" };
                request.RequestOption = requestOption;
                rateRequest.Request   = request;
                ShipmentType shipment = new ShipmentType();
                ShipperType  shipper  = new ShipperType();
                shipper.ShipperNumber = ConfigurationManager.AppSettings["UPSShipperNumber"];

                UPSRateService.AddressType shipperAddress = new UPSRateService.AddressType();
                String[] addressLine = { ConfigurationManager.AppSettings["LMStreet"] };
                shipperAddress.AddressLine       = addressLine;
                shipperAddress.City              = ConfigurationManager.AppSettings["LMCity"];
                shipperAddress.StateProvinceCode = ConfigurationManager.AppSettings["LMState"];
                shipperAddress.PostalCode        = ConfigurationManager.AppSettings["LMZip"];
                shipperAddress.CountryCode       = ConfigurationManager.AppSettings["LMCountry"];
                shipperAddress.AddressLine       = addressLine;
                shipper.Address  = shipperAddress;
                shipment.Shipper = shipper;

                ShipFromType shipFrom = new ShipFromType();
                //UPSRateService.AddressType shipFromAddress = new UPSRateService.AddressType();
                //shipFromAddress.AddressLine = shipperAddress.AddressLine;
                //shipFromAddress.City = shipperAddress.City;
                //shipFromAddress.StateProvinceCode = shipperAddress.StateProvinceCode;
                //shipFromAddress.PostalCode = shipperAddress.PostalCode;
                //shipFromAddress.CountryCode = shipperAddress.CountryCode;
                shipFrom.Address  = shipperAddress;
                shipment.ShipFrom = shipFrom;


                ShipToType        shipTo        = new ShipToType();
                ShipToAddressType shipToAddress = new ShipToAddressType();
                String[]          addressLine1  = { shipto.Addr1 };
                shipToAddress.AddressLine       = addressLine1;
                shipToAddress.City              = shipto.City;
                shipToAddress.StateProvinceCode = shipto.State;
                shipToAddress.PostalCode        = shipto.Zip5;
                shipToAddress.CountryCode       = shipto.Country;
                shipTo.Address  = shipToAddress;
                shipment.ShipTo = shipTo;


                CodeDescriptionType service = new CodeDescriptionType();
                //Below code uses dummy date for reference. Please udpate as required.
                //service.Code = "03"; //01:nextdayair 02;2ndday 03:ground 12:3dayselect
                service.Code     = DAL2.DAL.GetShippingMethodValuebyID(cart.ShipMethod);
                shipment.Service = service;
                PackageType       package       = new PackageType();
                PackageWeightType packageWeight = new PackageWeightType();
                packageWeight.Weight = cart.TotalWeight.ToString();
                CodeDescriptionType uom = new CodeDescriptionType();
                uom.Code        = "LBS";
                uom.Description = "pounds";
                packageWeight.UnitOfMeasurement = uom;
                package.PackageWeight           = packageWeight;
                CodeDescriptionType packType = new CodeDescriptionType();
                packType.Code         = "02"; //02:pkgcustomer
                package.PackagingType = packType;
                PackageType[] pkgArray = { package };
                shipment.Package     = pkgArray;
                rateRequest.Shipment = shipment;
                System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();

                RateResponse rateResponse = rate.ProcessRate(rateRequest);
                UPSNoelWrite("The transaction was a " + rateResponse.Response.ResponseStatus.Description);
                UPSNoelWrite("Total Shipment Charges " + rateResponse.RatedShipment[0].TotalCharges.MonetaryValue + rateResponse.RatedShipment[0].TotalCharges.CurrencyCode);
                temp = Double.Parse(rateResponse.RatedShipment[0].TotalCharges.MonetaryValue);
            }
            catch (Exception ex)
            {
                temp = 0.0;
            }
            return(temp);
            //catch (System.Web.Services.Protocols.SoapException ex)
            //{
            //    UPSNoelWrite("");
            //    UPSNoelWrite("---------Rate Web Service returns error----------------");
            //    UPSNoelWrite("---------\"Hard\" is user error \"Transient\" is system error----------------");
            //    UPSNoelWrite("SoapException Message= " + ex.Message);
            //    UPSNoelWrite("");
            //    UPSNoelWrite("SoapException Category:Code:Message= " + ex.Detail.LastChild.InnerText);
            //    UPSNoelWrite("");
            //    UPSNoelWrite("SoapException XML String for all= " + ex.Detail.LastChild.OuterXml);
            //    UPSNoelWrite("");
            //    UPSNoelWrite("SoapException StackTrace= " + ex.StackTrace);
            //    UPSNoelWrite("-------------------------");
            //    UPSNoelWrite("");
            //}
            //catch (System.ServiceModel.CommunicationException ex)
            //{
            //    UPSNoelWrite("");
            //    UPSNoelWrite("--------------------");
            //    UPSNoelWrite("CommunicationException= " + ex.Message);
            //    UPSNoelWrite("CommunicationException-StackTrace= " + ex.StackTrace);
            //    UPSNoelWrite("-------------------------");
            //    UPSNoelWrite("");

            //}
            //catch (Exception ex)
            //{
            //    UPSNoelWrite("");
            //    UPSNoelWrite("-------------------------");
            //    UPSNoelWrite(" Generaal Exception= " + ex.Message);
            //    UPSNoelWrite(" Generaal Exception-StackTrace= " + ex.StackTrace);
            //    UPSNoelWrite("-------------------------");

            //}
            //finally
            //{
            //    //Console.ReadKey();
            //}
        }
コード例 #57
0
        /// <param name='cancellationToken'>
        /// Cancellation token.
        /// </param>
        public async Task <HttpOperationResponse <IList <Product> > > GetWithOperationResponseAsync(CancellationToken cancellationToken = default(System.Threading.CancellationToken))
        {
            // Tracing
            bool   shouldTrace  = ServiceClientTracing.IsEnabled;
            string invocationId = null;

            if (shouldTrace)
            {
                invocationId = ServiceClientTracing.NextInvocationId.ToString();
                Dictionary <string, object> tracingParameters = new Dictionary <string, object>();
                ServiceClientTracing.Enter(invocationId, this, "GetAsync", tracingParameters);
            }

            // Construct URL
            string url = "";

            url = url + "/api/Product";
            string baseUrl = this.Client.BaseUri.AbsoluteUri;

            // Trim '/' character from the end of baseUrl and beginning of url.
            if (baseUrl[baseUrl.Length - 1] == '/')
            {
                baseUrl = baseUrl.Substring(0, baseUrl.Length - 1);
            }
            if (url[0] == '/')
            {
                url = url.Substring(1);
            }
            url = baseUrl + "/" + url;
            url = url.Replace(" ", "%20");

            // Create HTTP transport objects
            HttpRequestMessage httpRequest = new HttpRequestMessage();

            httpRequest.Method     = HttpMethod.Get;
            httpRequest.RequestUri = new Uri(url);

            // Set Credentials
            if (this.Client.Credentials != null)
            {
                cancellationToken.ThrowIfCancellationRequested();
                await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false);
            }

            // Send Request
            if (shouldTrace)
            {
                ServiceClientTracing.SendRequest(invocationId, httpRequest);
            }
            cancellationToken.ThrowIfCancellationRequested();
            HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false);

            if (shouldTrace)
            {
                ServiceClientTracing.ReceiveResponse(invocationId, httpResponse);
            }
            HttpStatusCode statusCode = httpResponse.StatusCode;

            cancellationToken.ThrowIfCancellationRequested();
            string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false);

            if (statusCode != HttpStatusCode.OK)
            {
                HttpOperationException <object> ex = new HttpOperationException <object>();
                ex.Request  = httpRequest;
                ex.Response = httpResponse;
                ex.Body     = null;
                if (shouldTrace)
                {
                    ServiceClientTracing.Error(invocationId, ex);
                }
                throw ex;
            }

            // Create Result
            HttpOperationResponse <IList <Product> > result = new HttpOperationResponse <IList <Product> >();

            result.Request  = httpRequest;
            result.Response = httpResponse;

            // Deserialize Response
            if (statusCode == HttpStatusCode.OK)
            {
                IList <Product> resultModel = new List <Product>();
                JToken          responseDoc = null;
                if (string.IsNullOrEmpty(responseContent) == false)
                {
                    responseDoc = JToken.Parse(responseContent);
                }
                if (responseDoc != null)
                {
                    resultModel = ProductCollection.DeserializeJson(responseDoc);
                }
                result.Body = resultModel;
            }

            if (shouldTrace)
            {
                ServiceClientTracing.Exit(invocationId, result);
            }
            return(result);
        }
 static partial void OnAfterEntityCollectionToDtoCollection(EntityCollection <ProductEntity> entities, ProductCollection dtos);
コード例 #59
0
        /// <summary>
        /// Loads the products.
        /// </summary>
        private void LoadProducts()
        {
            SetButtonState(ddlDisplayTypes.Items.Count > 0);
              if (ddlDisplayTypes.Items.Count <= 0)
            return;

              lbAllItems.DataSource = new Store.ProductCollection()
            .Where(Product.Columns.IsEnabled, true)
            .Load();
              lbAllItems.DataBind();

              _products = CustomizedProductDisplayType.GetProductCollection(int.Parse(ddlDisplayTypes.SelectedValue));
              foreach (Product item in _products) {
            lbAddedItems.Items.Add(new ListItem(item.Name, item.ProductId.ToString()));
            ListItem itemToRemove = null;
            foreach (ListItem litem in lbAllItems.Items) {
              if (litem.Value == item.ProductId.ToString()) {
            itemToRemove = litem;
            break;
              }
            }
            if (itemToRemove != null)
              lbAllItems.Items.Remove(itemToRemove);
              }
        }
コード例 #60
0
 public async Task AddProductCollectionAsync(ProductCollection collection)
 {
     throw new NotImplementedException();
 }