Esempio n. 1
0
        // Returns null if no record corresponds to itemID;
        public static EbayActiveListingType GetOneActiveListing(String itemID)
        {
            if (itemID == null || itemID.Trim().Length == 0)
            {
                return(null);
            }

            String sql_getOneActiveListing = String.Format("select * from [ActiveListing] where ItemID='{0}'", itemID);

            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getOneActiveListing);

            if (dt.Rows.Count == 0)
            {
                return(null);
            }

            DataRow dr = dt.Rows[0];
            EbayActiveListingType activeListing = new EbayActiveListingType();

            activeListing.ListId            = StringUtil.GetSafeInt(dr["ListId"]);
            activeListing.SellerName        = StringUtil.GetSafeString(dr["SellerName"]);
            activeListing.ItemID            = itemID;
            activeListing.Title             = StringUtil.GetSafeString(dr["Title"]);
            activeListing.ListingType       = StringUtil.GetSafeString(dr["ListingType"]);
            activeListing.GalleryURL        = StringUtil.GetSafeString(dr["GalleryURL"]);
            activeListing.QuantityBid       = StringUtil.GetSafeInt(dr["QuantityBid"]);
            activeListing.MaxBid            = StringUtil.GetSafeDouble(dr["MaxBid"]);
            activeListing.StartPrice        = StringUtil.GetSafeDouble(dr["StartPrice"]);
            activeListing.BuyItNowPrice     = StringUtil.GetSafeDouble(dr["BuyItNowPrice"]);
            activeListing.CurrencyID        = StringUtil.GetSafeString(dr["CurrencyID"]);
            activeListing.StartTime         = StringUtil.GetSafeDateTime(dr["StartTime"]);
            activeListing.EndTime           = StringUtil.GetSafeDateTime(dr["EndTime"]);
            activeListing.ViewItemURL       = StringUtil.GetSafeString(dr["ViewItemURL"]);
            activeListing.ListDuration      = StringUtil.GetSafeInt(dr["ListDuration"]);
            activeListing.PrivateListing    = StringUtil.GetSafeBool(dr["PrivateListing"]);
            activeListing.Quantity          = StringUtil.GetSafeInt(dr["Quantity"]);
            activeListing.QuantityAvailable = StringUtil.GetSafeInt(dr["QuantityAvailable"]);
            activeListing.SellingStatus     = StringUtil.GetSafeString(dr["SellingStatus"]);
            activeListing.SKU          = StringUtil.GetSafeString(dr["SKU"]);
            activeListing.TimeLeft     = StringUtil.GetSafeString(dr["TimeLeft"]);
            activeListing.WatchCount   = StringUtil.GetSafeInt(dr["WatchCount"]);
            activeListing.BidCount     = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.BidderCount  = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.CurrentPrice = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.FVF          = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.ImagePath    = StringUtil.GetSafeString(dr["ImagePath"]);

            return(activeListing);
        }
Esempio n. 2
0
        public static bool InsertOrUpdateOneActiveListing(EbayActiveListingType activeListing)
        {
            EbayActiveListingType existedListing = GetOneActiveListing(activeListing.ItemID);

            if (existedListing != null)
            {
                UpdateOneActiveListing(existedListing.ListId, activeListing);
            }
            else
            {
                InsertOneActiveListing(activeListing);
            }

            return(true);
        }
Esempio n. 3
0
        // Returns null if no record corresponds to itemID;
        public static EbayActiveListingType GetOneActiveListing(String itemID)
        {
            if (itemID == null || itemID.Trim().Length == 0)
                return null;

            String sql_getOneActiveListing = String.Format("select * from [ActiveListing] where ItemID='{0}'", itemID);

            DataTable dt = DataFactory.ExecuteSqlReturnTable(sql_getOneActiveListing);
            if (dt.Rows.Count == 0)
                return null;

            DataRow dr = dt.Rows[0];
            EbayActiveListingType activeListing = new EbayActiveListingType();
            activeListing.ListId = StringUtil.GetSafeInt(dr["ListId"]);
            activeListing.SellerName = StringUtil.GetSafeString(dr["SellerName"]);
            activeListing.ItemID = itemID;
            activeListing.Title = StringUtil.GetSafeString(dr["Title"]);
            activeListing.ListingType = StringUtil.GetSafeString(dr["ListingType"]);
            activeListing.GalleryURL = StringUtil.GetSafeString(dr["GalleryURL"]);
            activeListing.QuantityBid = StringUtil.GetSafeInt(dr["QuantityBid"]);
            activeListing.MaxBid = StringUtil.GetSafeDouble(dr["MaxBid"]);
            activeListing.StartPrice = StringUtil.GetSafeDouble(dr["StartPrice"]);
            activeListing.BuyItNowPrice = StringUtil.GetSafeDouble(dr["BuyItNowPrice"]);
            activeListing.CurrencyID = StringUtil.GetSafeString(dr["CurrencyID"]);
            activeListing.StartTime = StringUtil.GetSafeDateTime(dr["StartTime"]);
            activeListing.EndTime = StringUtil.GetSafeDateTime(dr["EndTime"]);
            activeListing.ViewItemURL = StringUtil.GetSafeString(dr["ViewItemURL"]);
            activeListing.ListDuration = StringUtil.GetSafeInt(dr["ListDuration"]);
            activeListing.PrivateListing = StringUtil.GetSafeBool(dr["PrivateListing"]);
            activeListing.Quantity = StringUtil.GetSafeInt(dr["Quantity"]);
            activeListing.QuantityAvailable = StringUtil.GetSafeInt(dr["QuantityAvailable"]);
            activeListing.SellingStatus = StringUtil.GetSafeString(dr["SellingStatus"]);
            activeListing.SKU = StringUtil.GetSafeString(dr["SKU"]);
            activeListing.TimeLeft = StringUtil.GetSafeString(dr["TimeLeft"]);
            activeListing.WatchCount = StringUtil.GetSafeInt(dr["WatchCount"]);
            activeListing.BidCount = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.BidderCount = StringUtil.GetSafeInt(dr["BidCount"]);
            activeListing.CurrentPrice = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.FVF = StringUtil.GetSafeDouble(dr["BidCount"]);
            activeListing.ImagePath = StringUtil.GetSafeString(dr["ImagePath"]);

            return activeListing;
        }
Esempio n. 4
0
        //
        // GetMyeBaySelling
        //  Use this call to return information from the All Selling section of the authenticated user's My eBay account.
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyeBaySelling.html
        //
        public static List<EbayActiveListingType> GetMyActiveListing(AccountType account)
        {
            if (account.SellerApiContext == null)
            {
                Logger.WriteSystemLog("Invalid API context in GetMyActiveListing.");
                return null;
            }

            GetMyeBaySellingCall getMyeBaySellingApiCall = new GetMyeBaySellingCall(account.SellerApiContext);
            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getMyeBaySellingApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getMyeBaySellingApiCall.SellingSummary = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.SellingSummary.Include = true;

            getMyeBaySellingApiCall.ActiveList = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.ActiveList.Include = true;
            getMyeBaySellingApiCall.ActiveList.IncludeNotes = true;
            //getMyeBaySellingApiCall.ActiveList.ListingType = ListingTypeCodeType.FixedPriceItem;
            getMyeBaySellingApiCall.ActiveList.Pagination = new PaginationType();
            getMyeBaySellingApiCall.ActiveList.Pagination.EntriesPerPage = 25; // max 200 default 25
            getMyeBaySellingApiCall.ActiveList.Pagination.PageNumber = 1;

            //getMyeBaySellingApiCall.BidList = new ItemListCustomizationType();
            //getMyeBaySellingApiCall.BidList.Include = true;
            //getMyeBaySellingApiCall.BidList.Pagination = new PaginationType();
            //getMyeBaySellingApiCall.BidList.Pagination.EntriesPerPage = 25;
            //getMyeBaySellingApiCall.BidList.Pagination.PageNumber = 1;

            getMyeBaySellingApiCall.GetMyeBaySelling();

            AmountType amountLimitRemaining = getMyeBaySellingApiCall.Summary.AmountLimitRemaining;
            long quantityLimitRemaining = getMyeBaySellingApiCall.Summary.QuantityLimitRemaining;

            PaginatedItemArrayType paginatedItemArray = getMyeBaySellingApiCall.ActiveListReturn;

            if (paginatedItemArray == null || paginatedItemArray.ItemArray == null)
                return null;

            List<EbayActiveListingType> activeListings = new List<EbayActiveListingType>();
            foreach (ItemType item in paginatedItemArray.ItemArray)
            {
                EbayActiveListingType activeListing = new EbayActiveListingType();
                activeListing.ListId = 0;   // to be set
                activeListing.SellerName = account.ebayAccount;
                activeListing.ItemID = StringUtil.GetSafeString(item.ItemID);
                activeListing.Title = StringUtil.GetSafeString(item.Title);
                if (item.ListingTypeSpecified)
                {
                    if (ListingTypeCodeType.FixedPriceItem == item.ListingType)
                        activeListing.ListingType = "FixedPriceItem";
                    else if (ListingTypeCodeType.Auction == item.ListingType ||
                            ListingTypeCodeType.Chinese == item.ListingType)
                        activeListing.ListingType = "Auction";
                    else
                        activeListing.ListingType = "Unknown";
                }
                else
                {
                    activeListing.ListingType = "Unknown";
                }
                if (item.PictureDetails != null)
                    activeListing.GalleryURL = StringUtil.GetSafeString(item.PictureDetails.GalleryURL);
                else
                    activeListing.GalleryURL = "";

                if (item.BiddingDetails != null)
                {
                    activeListing.QuantityBid = StringUtil.GetSafeInt(item.BiddingDetails.QuantityBid);
                    if (item.BiddingDetails.MaxBid != null)
                        activeListing.MaxBid = StringUtil.GetSafeDouble(item.BiddingDetails.MaxBid.Value);
                    else
                        activeListing.MaxBid = 0.0;
                }
                else
                {
                    activeListing.QuantityBid = 0;
                    activeListing.MaxBid = 0.0;
                }

                if (item.StartPrice!=null)
                {
                    activeListing.StartPrice = StringUtil.GetSafeDouble(item.StartPrice.Value);
                }
                else
                {
                    activeListing.StartPrice = 0.0;
                }

                if (item.BuyItNowPrice != null)
                {
                    activeListing.BuyItNowPrice = StringUtil.GetSafeDouble(item.BuyItNowPrice.Value);
                    activeListing.CurrencyID = StringUtil.GetSafeString(item.BuyItNowPrice.currencyID);
                }
                else
                {
                    activeListing.BuyItNowPrice = 0.0;
                    activeListing.CurrencyID = "";
                }

                if (item.ListingDetails != null)
                {
                    activeListing.StartTime = StringUtil.GetSafeDateTime(item.ListingDetails.StartTime);
                    activeListing.EndTime = StringUtil.GetSafeDateTime(item.ListingDetails.EndTime);
                    activeListing.ViewItemURL = StringUtil.GetSafeString(item.ListingDetails.ViewItemURL);

                }

                activeListing.ListDuration = StringUtil.GetSafeInt(StringUtil.GetSafeListDurationDays(item.ListingDuration));
                activeListing.PrivateListing = StringUtil.GetSafeBool(item.PrivateListing);
                activeListing.Quantity = StringUtil.GetSafeInt(item.Quantity);
                activeListing.QuantityAvailable = StringUtil.GetSafeInt(item.QuantityAvailable);
                if (item.SellingStatus != null)
                {
                    if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Active)
                        activeListing.SellingStatus = "Active";
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Completed)
                        activeListing.SellingStatus = "Completed";
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Ended)
                        activeListing.SellingStatus = "Ended";
                    else
                        activeListing.SellingStatus = "Unknown";

                    if (item.SellingStatus.BidCountSpecified)
                        activeListing.BidCount = item.SellingStatus.BidCount;
                    else
                        activeListing.BidCount = 0;

                    if (item.SellingStatus.BidderCountSpecified)
                        activeListing.BidderCount = (int)item.SellingStatus.BidderCount;
                    else
                        activeListing.BidderCount = 0;

                    if (item.SellingStatus.CurrentPrice != null)
                        activeListing.CurrentPrice = item.SellingStatus.CurrentPrice.Value;
                    else
                        activeListing.CurrentPrice = 0.0;
                }
                else
                {
                    activeListing.SellingStatus = "Unknown";
                }
                activeListing.SKU = StringUtil.GetSafeString(item.SKU);
                activeListing.TimeLeft = StringUtil.GetSafeString(item.TimeLeft);
                activeListing.WatchCount = StringUtil.GetSafeInt(item.WatchCount);

                activeListings.Add(activeListing);

            }

            Logger.WriteSystemLog(string.Format("Successfully called GetMyActiveListing, returns {0} entries", activeListings.Count));
            return activeListings;
        }
Esempio n. 5
0
        //
        // GetMyeBaySelling
        //  Use this call to return information from the All Selling section of the authenticated user's My eBay account.
        //      http://developer.ebay.com/DevZone/XML/docs/Reference/eBay/GetMyeBaySelling.html
        //

        public static List <EbayActiveListingType> GetMyActiveListing(AccountType account)
        {
            if (account.SellerApiContext == null)
            {
                Logger.WriteSystemLog("Invalid API context in GetMyActiveListing.");
                return(null);
            }

            GetMyeBaySellingCall getMyeBaySellingApiCall = new GetMyeBaySellingCall(account.SellerApiContext);

            DetailLevelCodeType[] detailLevels = new DetailLevelCodeType[] { DetailLevelCodeType.ReturnAll };
            getMyeBaySellingApiCall.DetailLevelList = new DetailLevelCodeTypeCollection(detailLevels);

            getMyeBaySellingApiCall.SellingSummary         = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.SellingSummary.Include = true;

            getMyeBaySellingApiCall.ActiveList              = new eBay.Service.Core.Soap.ItemListCustomizationType();
            getMyeBaySellingApiCall.ActiveList.Include      = true;
            getMyeBaySellingApiCall.ActiveList.IncludeNotes = true;
            //getMyeBaySellingApiCall.ActiveList.ListingType = ListingTypeCodeType.FixedPriceItem;
            getMyeBaySellingApiCall.ActiveList.Pagination = new PaginationType();
            getMyeBaySellingApiCall.ActiveList.Pagination.EntriesPerPage = 25; // max 200 default 25
            getMyeBaySellingApiCall.ActiveList.Pagination.PageNumber     = 1;



            //getMyeBaySellingApiCall.BidList = new ItemListCustomizationType();
            //getMyeBaySellingApiCall.BidList.Include = true;
            //getMyeBaySellingApiCall.BidList.Pagination = new PaginationType();
            //getMyeBaySellingApiCall.BidList.Pagination.EntriesPerPage = 25;
            //getMyeBaySellingApiCall.BidList.Pagination.PageNumber = 1;

            getMyeBaySellingApiCall.GetMyeBaySelling();

            AmountType amountLimitRemaining   = getMyeBaySellingApiCall.Summary.AmountLimitRemaining;
            long       quantityLimitRemaining = getMyeBaySellingApiCall.Summary.QuantityLimitRemaining;

            PaginatedItemArrayType paginatedItemArray = getMyeBaySellingApiCall.ActiveListReturn;

            if (paginatedItemArray == null || paginatedItemArray.ItemArray == null)
            {
                return(null);
            }

            List <EbayActiveListingType> activeListings = new List <EbayActiveListingType>();

            foreach (ItemType item in paginatedItemArray.ItemArray)
            {
                EbayActiveListingType activeListing = new EbayActiveListingType();
                activeListing.ListId     = 0; // to be set
                activeListing.SellerName = account.ebayAccount;
                activeListing.ItemID     = StringUtil.GetSafeString(item.ItemID);
                activeListing.Title      = StringUtil.GetSafeString(item.Title);
                if (item.ListingTypeSpecified)
                {
                    if (ListingTypeCodeType.FixedPriceItem == item.ListingType)
                    {
                        activeListing.ListingType = "FixedPriceItem";
                    }
                    else if (ListingTypeCodeType.Auction == item.ListingType ||
                             ListingTypeCodeType.Chinese == item.ListingType)
                    {
                        activeListing.ListingType = "Auction";
                    }
                    else
                    {
                        activeListing.ListingType = "Unknown";
                    }
                }
                else
                {
                    activeListing.ListingType = "Unknown";
                }
                if (item.PictureDetails != null)
                {
                    activeListing.GalleryURL = StringUtil.GetSafeString(item.PictureDetails.GalleryURL);
                }
                else
                {
                    activeListing.GalleryURL = "";
                }

                if (item.BiddingDetails != null)
                {
                    activeListing.QuantityBid = StringUtil.GetSafeInt(item.BiddingDetails.QuantityBid);
                    if (item.BiddingDetails.MaxBid != null)
                    {
                        activeListing.MaxBid = StringUtil.GetSafeDouble(item.BiddingDetails.MaxBid.Value);
                    }
                    else
                    {
                        activeListing.MaxBid = 0.0;
                    }
                }
                else
                {
                    activeListing.QuantityBid = 0;
                    activeListing.MaxBid      = 0.0;
                }

                if (item.StartPrice != null)
                {
                    activeListing.StartPrice = StringUtil.GetSafeDouble(item.StartPrice.Value);
                }
                else
                {
                    activeListing.StartPrice = 0.0;
                }


                if (item.BuyItNowPrice != null)
                {
                    activeListing.BuyItNowPrice = StringUtil.GetSafeDouble(item.BuyItNowPrice.Value);
                    activeListing.CurrencyID    = StringUtil.GetSafeString(item.BuyItNowPrice.currencyID);
                }
                else
                {
                    activeListing.BuyItNowPrice = 0.0;
                    activeListing.CurrencyID    = "";
                }

                if (item.ListingDetails != null)
                {
                    activeListing.StartTime   = StringUtil.GetSafeDateTime(item.ListingDetails.StartTime);
                    activeListing.EndTime     = StringUtil.GetSafeDateTime(item.ListingDetails.EndTime);
                    activeListing.ViewItemURL = StringUtil.GetSafeString(item.ListingDetails.ViewItemURL);
                }

                activeListing.ListDuration      = StringUtil.GetSafeInt(StringUtil.GetSafeListDurationDays(item.ListingDuration));
                activeListing.PrivateListing    = StringUtil.GetSafeBool(item.PrivateListing);
                activeListing.Quantity          = StringUtil.GetSafeInt(item.Quantity);
                activeListing.QuantityAvailable = StringUtil.GetSafeInt(item.QuantityAvailable);
                if (item.SellingStatus != null)
                {
                    if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Active)
                    {
                        activeListing.SellingStatus = "Active";
                    }
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Completed)
                    {
                        activeListing.SellingStatus = "Completed";
                    }
                    else if (item.SellingStatus.ListingStatus == ListingStatusCodeType.Ended)
                    {
                        activeListing.SellingStatus = "Ended";
                    }
                    else
                    {
                        activeListing.SellingStatus = "Unknown";
                    }

                    if (item.SellingStatus.BidCountSpecified)
                    {
                        activeListing.BidCount = item.SellingStatus.BidCount;
                    }
                    else
                    {
                        activeListing.BidCount = 0;
                    }

                    if (item.SellingStatus.BidderCountSpecified)
                    {
                        activeListing.BidderCount = (int)item.SellingStatus.BidderCount;
                    }
                    else
                    {
                        activeListing.BidderCount = 0;
                    }

                    if (item.SellingStatus.CurrentPrice != null)
                    {
                        activeListing.CurrentPrice = item.SellingStatus.CurrentPrice.Value;
                    }
                    else
                    {
                        activeListing.CurrentPrice = 0.0;
                    }
                }
                else
                {
                    activeListing.SellingStatus = "Unknown";
                }
                activeListing.SKU        = StringUtil.GetSafeString(item.SKU);
                activeListing.TimeLeft   = StringUtil.GetSafeString(item.TimeLeft);
                activeListing.WatchCount = StringUtil.GetSafeInt(item.WatchCount);

                activeListings.Add(activeListing);
            }

            Logger.WriteSystemLog(string.Format("Successfully called GetMyActiveListing, returns {0} entries", activeListings.Count));
            return(activeListings);
        } // GetMyActiveListing
Esempio n. 6
0
        public static bool InsertOneActiveListing(EbayActiveListingType activeListing)
        {
            EbayActiveListingType existedActiveListing = GetOneActiveListing(activeListing.ItemID);

            if (existedActiveListing != null)
            {
                Logger.WriteSystemLog(string.Format("Active listing with itemId={0} alreay exists.", activeListing.ItemID));
                return(false);
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"insert into [ActiveListing] (ItemID, SellerName, Title, ListingType, GalleryURL, QuantityBid,MaxBid,"
                              + "StartPrice, BuyItNowPrice, CurrencyID, StartTime, EndTime, ViewItemURL, ListDuration, PrivateListing,"
                              + "Quantity, QuantityAvailable, SellingStatus, SKU, TimeLeft, WatchCount, BidCount, BidderCount, CurrentPrice, FVF, ImagePath) values ("
                              + "@ItemID, @SellerName, @Title, @ListingType, @GalleryURL, @QuantityBid, @MaxBid, @StartPrice, @BuyItNowPrice,"
                              + "@CurrencyID, @StartTime, @EndTime, @ViewItemURL, @ListDuration, @PrivateListing,"
                              + "@Quantity, @QuantityAvailable, @SellingStatus, @SKU, @TimeLeft, @WatchCount, @BidCount, @BidderCount, @CurrentPrice, @FVF, @ImagePath)";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@SellerName", DbType.String, StringUtil.GetSafeString(activeListing.SellerName));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            bool result    = false;
            int  newItemId = 0;

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                {
                    DataFactory.DbConnection.Open();
                }
                cmd.ExecuteNonQuery();

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");

                // Retrieve the Auto number and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newItemId);
                result = newItemId > 0;
            }
            catch (DataException ex)
            {
                // Write to log here.
                Logger.WriteSystemLog(string.Format("Error inserting new active listing, itemID={0}, errorMsg={1}",
                                                    activeListing.ItemID, ex.Message));
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }   // InsertOneActiveListing
Esempio n. 7
0
        public static bool UpdateOneActiveListing(int listId, EbayActiveListingType activeListing)
        {
            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);

            cmd.CommandText = @"Update [ActiveListing] set ItemID=@ItemID, Title=@Title, ListingType=@ListingType,"
                              + "GalleryURL=@GalleryURL, QuantityBid=@QuantityBid, MaxBid=@MaxBid, StartPrice=@StartPrice,"
                              + "BuyItNowPrice=@BuyItNowPrice, CurrencyID=@CurrencyID, StartTime=@StartTime, EndTime=@EndTime,"
                              + "ViewItemURL=@ViewItemURL, ListDuration=@ListDuration, PrivateListing=@PrivateListing,"
                              + "Quantity=@Quantity, QuantityAvailable=@QuantityAvailable, SellingStatus=@SellingStatus,"
                              + "SKU=@SKU, TimeLeft=@TimeLeft, WatchCount=@WatchCount, BidCount=@BidCount, BidderCount=@BidderCount,"
                              + "CurrentPrice=@CurrentPrice, FVF=@FVF, ImagePath=@ImagePath where ListId=@ListId";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            DataFactory.AddCommandParam(cmd, "@ListId", DbType.Int32, listId);

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                {
                    DataFactory.DbConnection.Open();
                }
                cmd.ExecuteNonQuery();
                result = true;
            }
            catch (DataException)
            {
                // Write to log here.
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                {
                    DataFactory.DbConnection.Close();
                }
            }

            return(result);
        }
Esempio n. 8
0
        public static bool UpdateOneActiveListing(int listId, EbayActiveListingType activeListing)
        {
            bool result = false;

            IDbCommand cmd = DataFactory.CreateCommand(null);
            cmd.CommandText = @"Update [ActiveListing] set ItemID=@ItemID, Title=@Title, ListingType=@ListingType,"
                + "GalleryURL=@GalleryURL, QuantityBid=@QuantityBid, MaxBid=@MaxBid, StartPrice=@StartPrice,"
                + "BuyItNowPrice=@BuyItNowPrice, CurrencyID=@CurrencyID, StartTime=@StartTime, EndTime=@EndTime,"
                + "ViewItemURL=@ViewItemURL, ListDuration=@ListDuration, PrivateListing=@PrivateListing,"
                + "Quantity=@Quantity, QuantityAvailable=@QuantityAvailable, SellingStatus=@SellingStatus,"
                + "SKU=@SKU, TimeLeft=@TimeLeft, WatchCount=@WatchCount, BidCount=@BidCount, BidderCount=@BidderCount,"
                + "CurrentPrice=@CurrentPrice, FVF=@FVF, ImagePath=@ImagePath where ListId=@ListId";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            DataFactory.AddCommandParam(cmd, "@ListId", DbType.Int32, listId);

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                    DataFactory.DbConnection.Open();
                cmd.ExecuteNonQuery();
                result = true;

            }
            catch (DataException)
            {
                // Write to log here.
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                    DataFactory.DbConnection.Close();
            }

            return result;
        }
Esempio n. 9
0
        public static bool InsertOrUpdateOneActiveListing(EbayActiveListingType activeListing)
        {
            EbayActiveListingType existedListing = GetOneActiveListing(activeListing.ItemID);
            if (existedListing != null)
            {
                UpdateOneActiveListing(existedListing.ListId, activeListing);
            }
            else
            {
                InsertOneActiveListing(activeListing);
            }

            return true;
        }
Esempio n. 10
0
        public static bool InsertOneActiveListing(EbayActiveListingType activeListing)
        {
            EbayActiveListingType existedActiveListing = GetOneActiveListing(activeListing.ItemID);
            if (existedActiveListing != null)
            {
                Logger.WriteSystemLog(string.Format("Active listing with itemId={0} alreay exists.", activeListing.ItemID));
                return false;
            }

            IDbCommand cmd = DataFactory.CreateCommand(null);
            cmd.CommandText = @"insert into [ActiveListing] (ItemID, SellerName, Title, ListingType, GalleryURL, QuantityBid,MaxBid,"
                + "StartPrice, BuyItNowPrice, CurrencyID, StartTime, EndTime, ViewItemURL, ListDuration, PrivateListing,"
                + "Quantity, QuantityAvailable, SellingStatus, SKU, TimeLeft, WatchCount, BidCount, BidderCount, CurrentPrice, FVF, ImagePath) values ("
                + "@ItemID, @SellerName, @Title, @ListingType, @GalleryURL, @QuantityBid, @MaxBid, @StartPrice, @BuyItNowPrice,"
                + "@CurrencyID, @StartTime, @EndTime, @ViewItemURL, @ListDuration, @PrivateListing,"
                + "@Quantity, @QuantityAvailable, @SellingStatus, @SKU, @TimeLeft, @WatchCount, @BidCount, @BidderCount, @CurrentPrice, @FVF, @ImagePath)";

            DataFactory.AddCommandParam(cmd, "@ItemID", DbType.String, StringUtil.GetSafeString(activeListing.ItemID));
            DataFactory.AddCommandParam(cmd, "@SellerName", DbType.String, StringUtil.GetSafeString(activeListing.SellerName));
            DataFactory.AddCommandParam(cmd, "@Title", DbType.String, StringUtil.GetSafeString(activeListing.Title));
            DataFactory.AddCommandParam(cmd, "@ListingType", DbType.String, StringUtil.GetSafeString(activeListing.ListingType));
            DataFactory.AddCommandParam(cmd, "@GalleryURL", DbType.String, StringUtil.GetSafeString(activeListing.GalleryURL));
            DataFactory.AddCommandParam(cmd, "@QuantityBid", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityBid));

            DataFactory.AddCommandParam(cmd, "@MaxBid", DbType.Double, StringUtil.GetSafeDouble(activeListing.MaxBid));
            DataFactory.AddCommandParam(cmd, "@StartPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.StartPrice));
            DataFactory.AddCommandParam(cmd, "@BuyItNowPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.BuyItNowPrice));
            DataFactory.AddCommandParam(cmd, "@CurrencyID", DbType.String, StringUtil.GetSafeString(activeListing.CurrencyID));
            DataFactory.AddCommandParam(cmd, "@StartTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.StartTime));

            DataFactory.AddCommandParam(cmd, "@EndTime", DbType.DateTime, StringUtil.GetSafeDateTime(activeListing.EndTime));
            DataFactory.AddCommandParam(cmd, "@ViewItemURL", DbType.String, StringUtil.GetSafeString(activeListing.ViewItemURL));
            DataFactory.AddCommandParam(cmd, "@ListDuration", DbType.Int32, StringUtil.GetSafeInt(activeListing.ListDuration));
            DataFactory.AddCommandParam(cmd, "@PrivateListing", DbType.Boolean, StringUtil.GetSafeBool(activeListing.PrivateListing));
            DataFactory.AddCommandParam(cmd, "@Quantity", DbType.Int32, StringUtil.GetSafeInt(activeListing.Quantity));

            DataFactory.AddCommandParam(cmd, "@QuantityAvailable", DbType.Int32, StringUtil.GetSafeInt(activeListing.QuantityAvailable));
            DataFactory.AddCommandParam(cmd, "@SellingStatus", DbType.String, StringUtil.GetSafeString(activeListing.SellingStatus));
            DataFactory.AddCommandParam(cmd, "@SKU", DbType.String, StringUtil.GetSafeString(activeListing.SKU));
            DataFactory.AddCommandParam(cmd, "@TimeLeft", DbType.String, StringUtil.GetSafeString(activeListing.TimeLeft));
            DataFactory.AddCommandParam(cmd, "@WatchCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.WatchCount));

            DataFactory.AddCommandParam(cmd, "@BidCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidCount));
            DataFactory.AddCommandParam(cmd, "@BidderCount", DbType.Int32, StringUtil.GetSafeInt(activeListing.BidderCount));
            DataFactory.AddCommandParam(cmd, "@CurrentPrice", DbType.Double, StringUtil.GetSafeDouble(activeListing.CurrentPrice));
            DataFactory.AddCommandParam(cmd, "@FVF", DbType.Double, StringUtil.GetSafeDouble(activeListing.FVF));
            DataFactory.AddCommandParam(cmd, "@ImagePath", DbType.String, StringUtil.GetSafeString(activeListing.ImagePath));

            bool result = false;
            int newItemId = 0;

            try
            {
                if (DataFactory.DbConnection.State == ConnectionState.Closed)
                    DataFactory.DbConnection.Open();
                cmd.ExecuteNonQuery();

                IDbCommand cmdNewID = DataFactory.CreateCommand("SELECT @@IDENTITY");

                // Retrieve the Auto number and store it in the CategoryID column.
                object obj = cmdNewID.ExecuteScalar();
                Int32.TryParse(obj.ToString(), out newItemId);
                result = newItemId > 0;
            }
            catch (DataException ex)
            {
                // Write to log here.
                Logger.WriteSystemLog(string.Format("Error inserting new active listing, itemID={0}, errorMsg={1}",
                    activeListing.ItemID, ex.Message));
                result = false;
            }
            finally
            {
                if (DataFactory.DbConnection.State == ConnectionState.Open)
                    DataFactory.DbConnection.Close();
            }

            return result;
        }