Exemple #1
0
        /// <summary>
        /// Set the style.
        /// </summary>
        /// <param name="styleBackground">Style for the background.</param>
        /// <param name="styleText">Style for the text.</param>
        /// <param name="style">Full style data.</param>
        public virtual void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
        {
            styleBackground.ApplyTo(Background);

            if ((Owner != null) && (Owner.IsTable))
            {
                Background.sprite = null;

                if (GraphicsBackground != null)
                {
                    GraphicsBackground.ForEach(style.Table.Background.ApplyTo);
                }
            }

            if (GraphicsForeground != null)
            {
                foreach (var gf in GraphicsForeground)
                {
                    if (gf != null)
                    {
                        styleText.ApplyTo(gf.gameObject);
                    }
                }
            }

            ResetGraphics();
        }
Exemple #2
0
        /// <summary>
        /// Set the style.
        /// </summary>
        /// <param name="styleBackground">Style for the background.</param>
        /// <param name="styleText">Style for the text.</param>
        /// <param name="style">Full style data.</param>
        public override void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
        {
            base.SetStyle(styleBackground, styleText, style);

            if (Name != null)
            {
                styleText.ApplyTo(Name.gameObject);
            }
        }
        /// <summary>
        /// Set the style.
        /// </summary>
        /// <param name="styleBackground">Style for the background.</param>
        /// <param name="styleText">Style for the text.</param>
        /// <param name="style">Full style data.</param>
        public virtual void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
        {
            styleBackground.ApplyTo(Background);

            foreach (var gf in GraphicsForeground)
            {
                if (gf != null)
                {
                    styleText.ApplyTo(gf.gameObject);
                }
            }

            var connector = GetComponent <MultipleConnector>();

            connector.color = style.Collections.DefaultColor;
        }
		/// <summary>
		/// Set the style.
		/// </summary>
		/// <param name="styleBackground">Style for the background.</param>
		/// <param name="styleText">Style for the text.</param>
		/// <param name="style">Full style data.</param>
		public override void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
		{
			base.SetStyle(styleBackground, styleText, style);

			PaddingPerLevel = style.TreeView.PaddingPerLevel;

			style.TreeView.Toggle.ApplyTo(ToggleImage);

			OnNodeExpand = style.TreeView.OnNodeExpand;

			AnimateArrow = style.TreeView.AnimateArrow;

			NodeOpened = style.TreeView.NodeOpened;

			NodeClosed = style.TreeView.NodeClosed;

			styleText.ApplyTo(Text);
		}
Exemple #5
0
        public MessageStyle(byte[] romData, int offset)
        {
            TileDataOffset    = (uint)(offset + BitConverter.ToUInt32(romData, offset));
            TileDataSize      = BitConverter.ToUInt32(romData, offset + 0x04);
            Unknown0x08       = BitConverter.ToUInt16(romData, offset + 0x08);
            Unknown0x0A       = BitConverter.ToUInt16(romData, offset + 0x0A);
            PaletteDataOffset = (uint)(offset + 0x0C + BitConverter.ToUInt32(romData, offset + 0x0C));
            PaletteDataSize   = BitConverter.ToUInt32(romData, offset + 0x10);

            TileData = new byte[TileDataSize];
            Buffer.BlockCopy(romData, (int)TileDataOffset, TileData, 0, TileData.Length);

            PaletteData = new byte[PaletteDataSize];
            Buffer.BlockCopy(romData, (int)PaletteDataOffset, PaletteData, 0, PaletteData.Length);

            if (Unknown0x08 == 0x0040 && Unknown0x0A == 0x0020)
            {
                StyleImage        = GBAGraphics.GetBitmap(TileData, 0, PaletteData, 0, 8, 8);
                StyleImageFlipped = (StyleImage.Clone() as Bitmap);
                StyleImageFlipped.RotateFlip(RotateFlipType.RotateNoneFlipX);
            }
        }
        public Style Store(string styleId,
                           int itemTypeId,
                           string name,
                           string imageSource,
                           DateTime when)
        {
            var dbStyle = new Style
            {
                StyleID       = styleId,
                Name          = name,
                Image         = imageSource,
                ItemTypeId    = itemTypeId,
                DropShipperId = DSHelper.DefaultPAId,

                UpdateDate = when,
                CreateDate = when
            };

            Add(dbStyle);
            unitOfWork.Commit();

            if (!String.IsNullOrEmpty(imageSource))
            {
                var dbStyleImage = new StyleImage()
                {
                    StyleId    = dbStyle.Id,
                    Image      = imageSource,
                    Type       = (int)StyleImageType.None,
                    CreateDate = when,
                };
                unitOfWork.StyleImages.Add(dbStyleImage);
                unitOfWork.Commit();
            }

            return(dbStyle);
        }
Exemple #7
0
        /// <summary>
        /// Set the style.
        /// </summary>
        /// <param name="styleBackground">Style for the background.</param>
        /// <param name="styleText">Style for the text.</param>
        /// <param name="style">Full style data.</param>
        public override void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
        {
            base.SetStyle(styleBackground, styleText, style);

            styleText.ApplyTo(Name);
        }
Exemple #8
0
 /// <summary>
 /// Set the style.
 /// </summary>
 /// <param name="styleBackground">Style for the background.</param>
 /// <param name="styleText">Style for the text.</param>
 /// <param name="style">Full style data.</param>
 public virtual void SetStyle(StyleImage styleBackground, StyleText styleText, Style style)
 {
     styleBackground.ApplyTo(GetComponent <Image>());
 }
        private void CreateOrUpdateListing(IDbFactory dbFactory,
                                           ITime time,
                                           ILogService log,
                                           MarketType market,
                                           string marketplaceId,
                                           ParentItemDTO product,
                                           bool canCreate,
                                           bool updateQty,
                                           bool updateStyleInfo,
                                           bool mapByBarcode,
                                           bool processOnlyStyle)
        {
            using (var db = dbFactory.GetRWDb())
            {
                //var productImageUrl = product.ImageSource;

                if (!product.Variations.Any())
                {
                    log.Debug("No variations, productId=" + product.SourceMarketId + ", handle=" + product.SourceMarketUrl);
                }

                var skuList  = product.Variations.Select(v => v.SKU).ToList();
                var baseSKU  = product.Variations.FirstOrDefault()?.SKU ?? "";
                var skuParts = baseSKU.Split("-".ToCharArray());

                var mainSKU = (skuList.Distinct().Count() > 1 && skuParts.Count() > 1) ? String.Join("-", skuParts.Take(skuParts.Count() - 1)) : baseSKU;
                _log.Info("Main SKU: " + mainSKU + ", variations: " + String.Join(", ", skuList));
                //var firstMRSP = product.Variations.FirstOrDefault()?.ListPrice;
                //var firstBarcode = product.Variations.FirstOrDefault()?.Barcode;

                //Style

                Style existStyle = null;

                //Get by SKU/Name
                if (existStyle == null)
                {
                    existStyle = db.Styles.GetAll().FirstOrDefault(s => s.StyleID == mainSKU);
                    if (existStyle != null)
                    {
                        _log.Info("Style found by StyleID");
                    }
                }

                var isNewStyle = false;
                //Create new
                if (existStyle == null)
                {
                    if (!canCreate)
                    {
                        _log.Info("Unable to find style for, SKU: " + mainSKU);
                        return;
                    }

                    existStyle = new Style()
                    {
                        StyleID    = mainSKU,
                        CreateDate = time.GetAppNowTime(),
                    };
                    db.Styles.Add(existStyle);

                    isNewStyle = true;
                }
                else
                {
                }

                existStyle.DropShipperId = DSHelper.DefaultDSId;

                if (updateStyleInfo || isNewStyle)
                {
                    existStyle.StyleID     = mainSKU;
                    existStyle.Description = product.Description;
                    existStyle.Name        = product.AmazonName;

                    existStyle.Image        = product.ImageSource;
                    existStyle.Manufacturer = product.Department;
                    existStyle.BulletPoint1 = product.SearchKeywords;
                    existStyle.BulletPoint2 = product.Type;
                    //existStyle.MSRP = firstMRSP;
                    //existStyle.Price = product.Variations.Select(v => v.AmazonCurrentPrice).FirstOrDefault();

                    existStyle.UpdateDate = time.GetAppNowTime();
                }

                db.Commit();

                //if (!processOnlyStyle)
                {
                    //Style Image
                    var existStyleImages = db.StyleImages.GetAll().Where(si => si.StyleId == existStyle.Id).ToList();
                    if (!existStyleImages.Any() && !String.IsNullOrEmpty(product.ImageSource))
                    {
                        var newImage = new StyleImage()
                        {
                            Image      = product.ImageSource,
                            IsDefault  = true,
                            Type       = (int)StyleImageType.HiRes,
                            StyleId    = existStyle.Id,
                            CreateDate = _time.GetAppNowTime()
                        };
                        db.StyleImages.Add(newImage);
                        db.Commit();
                    }
                }

                //StyleFeatures
                if (isNewStyle && !processOnlyStyle)
                {
                    var existFeatures =
                        db.StyleFeatureTextValues.GetAll().Where(tv => tv.StyleId == existStyle.Id).ToList();
                    var existDdlFeatures =
                        db.StyleFeatureValues.GetAll().Where(tv => tv.StyleId == existStyle.Id).ToList();
                    var allFeatureValues = db.FeatureValues.GetAllAsDto().ToList();
                    var newFeatures      = ComposeFeatureList(db,
                                                              allFeatureValues,
                                                              product.Type,
                                                              product.SearchKeywords);
                    newFeatures.Add(ComposeFeatureValue(db, "Product Type", product.Type));
                    //newFeatures.Add(ComposeFeatureValue(db, "Brand Name", product.Department));
                    foreach (var feature in newFeatures)
                    {
                        if (feature == null)
                        {
                            continue;
                        }

                        var existFeature    = existFeatures.FirstOrDefault(f => f.FeatureId == feature.Id);
                        var existDdlFeature = existDdlFeatures.FirstOrDefault(f => f.FeatureId == feature.Id);
                        if (existFeature == null && existDdlFeature == null)
                        {
                            if (feature.Type == (int)FeatureValuesType.TextBox)
                            {
                                db.StyleFeatureTextValues.Add(new StyleFeatureTextValue()
                                {
                                    FeatureId = feature.FeatureId,
                                    Value     = StringHelper.Substring(feature.Value, 512),
                                    StyleId   = existStyle.Id,

                                    CreateDate = _time.GetAppNowTime()
                                });
                            }
                            if (feature.Type == (int)FeatureValuesType.DropDown)
                            {
                                db.StyleFeatureValues.Add(new StyleFeatureValue()
                                {
                                    FeatureId      = feature.FeatureId,
                                    FeatureValueId = feature.FeatureValueId.Value,
                                    StyleId        = existStyle.Id,

                                    CreateDate = _time.GetAppNowTime()
                                });
                            }
                        }
                    }
                    db.Commit();
                }

                ParentItem existParentItem = null;
                //if (!processOnlyStyle)
                {
                    //ParentItem
                    existParentItem = db.ParentItems.GetAll().FirstOrDefault(pi => pi.Market == (int)market
                                                                             &&
                                                                             (pi.MarketplaceId ==
                                                                              marketplaceId ||
                                                                              String.IsNullOrEmpty(
                                                                                  marketplaceId))
                                                                             &&
                                                                             pi.SourceMarketId ==
                                                                             product.SourceMarketId);
                    if (existParentItem == null)
                    {
                        existParentItem = new ParentItem()
                        {
                            Market         = (int)market,
                            MarketplaceId  = marketplaceId,
                            ASIN           = product.ASIN,
                            SourceMarketId = product.SourceMarketId,
                            CreateDate     = time.GetAppNowTime(),
                        };
                        db.ParentItems.Add(existParentItem);
                    }
                    existParentItem.AmazonName           = product.AmazonName;
                    existParentItem.Type                 = product.Type;
                    existParentItem.Description          = product.Description;
                    existParentItem.ImageSource          = product.ImageSource;
                    existParentItem.SourceMarketUrl      = product.SourceMarketUrl;
                    existParentItem.SearchKeywords       = product.SearchKeywords;
                    existParentItem.UpdateDate           = time.GetAppNowTime();
                    existParentItem.IsAmazonUpdated      = true;
                    existParentItem.LastUpdateFromAmazon = time.GetAppNowTime();

                    db.Commit();

                    product.Id = existParentItem.Id;
                }

                //if (!processOnlyStyle)
                {
                    foreach (var variation in product.Variations)
                    {
                        //StyleItem
                        var existStyleItem = db.StyleItems.GetAll()
                                             .FirstOrDefault(si => si.StyleId == existStyle.Id);
                        // && (si.Color == variation.Color || String.IsNullOrEmpty(variation.Color)));

                        var isNewStyleItem = false;
                        if (existStyleItem == null)
                        {
                            if (!canCreate && !isNewStyle)
                            {
                                _log.Info("Unable to find StyleItem for styleId: " + existStyle.StyleID);
                                return;
                            }

                            existStyleItem = new StyleItem()
                            {
                                StyleId = existStyle.Id,
                                Size    = variation.Size,
                                Color   = variation.Color,
                            };
                            db.StyleItems.Add(existStyleItem);

                            isNewStyleItem = true;
                        }

                        //TEMP:
                        //if (updateQty || isNewStyle)
                        //{
                        //    existStyleItem.Quantity = variation.AmazonRealQuantity;
                        //    existStyleItem.QuantitySetDate = time.GetAppNowTime();
                        //}
                        db.Commit();

                        variation.StyleItemId = existStyleItem.Id;

                        //StyleItem Barcode
                        if (!String.IsNullOrEmpty(variation.Barcode))
                        {
                            var existBarcode =
                                db.StyleItemBarcodes.GetAll().FirstOrDefault(b => b.Barcode == variation.Barcode);
                            if (existBarcode == null)
                            {
                                _log.Info("Added new barcode: " + variation.Barcode);
                                existBarcode = new StyleItemBarcode()
                                {
                                    Barcode    = variation.Barcode,
                                    CreateDate = time.GetAppNowTime(),
                                };
                                db.StyleItemBarcodes.Add(existBarcode);
                            }
                            existBarcode.StyleItemId = existStyleItem.Id;
                            existBarcode.UpdateDate  = time.GetAppNowTime();
                            db.Commit();
                        }

                        //if (!processOnlyStyle)
                        {
                            //Item
                            var existItem =
                                db.Items.GetAll().FirstOrDefault(v => v.SourceMarketId == variation.SourceMarketId &&
                                                                 v.Market == (int)market
                                                                 &&
                                                                 (v.MarketplaceId == marketplaceId ||
                                                                  String.IsNullOrEmpty(marketplaceId)));
                            if (existItem == null)
                            {
                                existItem = new Item()
                                {
                                    ParentASIN     = existParentItem.ASIN,
                                    ASIN           = variation.ASIN,
                                    SourceMarketId = variation.SourceMarketId,
                                    Market         = (int)market,
                                    MarketplaceId  = marketplaceId,
                                    CreateDate     = time.GetAppNowTime(),
                                };
                                db.Items.Add(existItem);
                            }

                            existItem.StyleId     = existStyle.Id;
                            existItem.StyleItemId = existStyleItem.Id;

                            existItem.Title   = product.AmazonName;
                            existItem.Barcode = variation.Barcode;
                            existItem.Color   = variation.Color;
                            existItem.Size    = variation.Size;

                            existItem.SourceMarketUrl = variation.SourceMarketUrl;

                            existItem.PrimaryImage = variation.ImageUrl;
                            existItem.ListPrice    = (decimal?)variation.ListPrice;

                            existItem.UpdateDate              = time.GetAppNowTime();
                            existItem.IsExistOnAmazon         = true;
                            existItem.LastUpdateFromAmazon    = time.GetAppNowTime();
                            existItem.ItemPublishedStatus     = variation.PublishedStatus;
                            existItem.ItemPublishedStatusDate = variation.PuclishedStatusDate ?? time.GetAppNowTime();

                            db.Commit();

                            variation.Id = existItem.Id;

                            //Listing
                            var existListing =
                                db.Listings.GetAll().FirstOrDefault(v => v.ListingId == variation.ListingId.ToString() &&
                                                                    v.Market == (int)market
                                                                    &&
                                                                    (v.MarketplaceId == marketplaceId ||
                                                                     String.IsNullOrEmpty(marketplaceId)));
                            if (existListing == null)
                            {
                                existListing = new Listing()
                                {
                                    ItemId = existItem.Id,

                                    ASIN      = variation.ASIN,
                                    ListingId = StringHelper.GetFirstNotEmpty(variation.ASIN, variation.ListingId),

                                    Market        = (int)market,
                                    MarketplaceId = marketplaceId,

                                    CreateDate = time.GetAppNowTime(),
                                };
                                db.Listings.Add(existListing);
                            }

                            existListing.SKU = variation.SKU;

                            existListing.CurrentPrice                 = (decimal)(variation.AmazonCurrentPrice ?? 0);
                            existListing.AmazonCurrentPrice           = (decimal?)variation.AmazonCurrentPrice;
                            existListing.AmazonCurrentPriceUpdateDate = time.GetAmazonNowTime();
                            existListing.PriceFromMarketUpdatedDate   = time.GetAppNowTime();

                            existListing.RealQuantity                 = variation.AmazonRealQuantity ?? 0;
                            existListing.AmazonRealQuantity           = variation.AmazonRealQuantity ?? 0;
                            existListing.AmazonRealQuantityUpdateDate = time.GetAppNowTime();

                            existListing.UpdateDate = time.GetAppNowTime();
                            existListing.IsRemoved  = false;

                            db.Commit();

                            variation.ListingEntityId = existListing.Id;
                        }
                    }
                }
            }
        }
Exemple #10
0
        public void SyncStyles(DropShipperApi api)
        {
            var styles = api.GetStyles(_log, _sourceMarket, _sourceMarketplaceId);

            using (var db = _dbFactory.GetRWDb())
            {
                foreach (var incomeStyle in styles)
                {
                    var existStyle = db.Styles.GetAll().FirstOrDefault(st => (st.StyleID == incomeStyle.StyleID ||
                                                                              st.OriginalStyleID.Contains(incomeStyle.StyleID + ";")) &&
                                                                       !st.Deleted);
                    if (existStyle == null)
                    {
                        _log.Info("Creating style, StyleId=" + incomeStyle.StyleID);

                        var newStyle = new Style()
                        {
                            StyleID         = incomeStyle.StyleID,
                            OriginalStyleID = incomeStyle.OriginalStyleID,
                            Name            = incomeStyle.Name,
                            Description     = incomeStyle.Description,
                            BulletPoint1    = incomeStyle.BulletPoint1,
                            BulletPoint2    = incomeStyle.BulletPoint2,
                            BulletPoint3    = incomeStyle.BulletPoint3,
                            BulletPoint4    = incomeStyle.BulletPoint4,
                            BulletPoint5    = incomeStyle.BulletPoint5,
                            MSRP            = incomeStyle.MSRP,
                            Manufacturer    = PrepareManufacture(incomeStyle.Manufacturer),
                            DropShipperId   = _dropShipperId,// DSHelper.MBGPAId,

                            Image = incomeStyle.Image,

                            CreateDate = _time.GetAppNowTime(),
                        };
                        db.Styles.Add(newStyle);
                        db.Commit();

                        foreach (var featureValue in incomeStyle.StyleFeatures)
                        {
                            var findFeature = db.Features.GetAll().FirstOrDefault(f => f.Name == featureValue.FeatureName);
                            if (findFeature == null)
                            {
                                continue;
                            }

                            if (featureValue.Type == (int)FeatureValuesType.TextBox ||
                                featureValue.Type == (int)FeatureValuesType.CheckBox)
                            {
                                db.StyleFeatureTextValues.Add(new StyleFeatureTextValue()
                                {
                                    StyleId    = newStyle.Id,
                                    FeatureId  = findFeature.Id,
                                    Value      = featureValue.Value,
                                    CreateDate = _time.GetAppNowTime(),
                                });
                            }
                            else
                            {
                                var findFeatureValue = db.FeatureValues.GetAll().FirstOrDefault(fv => fv.FeatureId == findFeature.Id &&
                                                                                                fv.Value == featureValue.Value);
                                if (findFeatureValue != null)
                                {
                                    db.StyleFeatureValues.Add(new StyleFeatureValue()
                                    {
                                        StyleId        = newStyle.Id,
                                        FeatureId      = findFeatureValue.FeatureId,
                                        FeatureValueId = findFeatureValue.Id,
                                        CreateDate     = _time.GetAppNowTime(),
                                    });
                                }
                            }
                        }
                        db.Commit();


                        foreach (var si in incomeStyle.StyleItems)
                        {
                            var newStyleItem = new StyleItem()
                            {
                                StyleId         = newStyle.Id,
                                Size            = si.Size,
                                Color           = si.Color,
                                Quantity        = si.Quantity,
                                QuantitySetDate = si.QuantitySetDate,
                                Weight          = si.Weight,

                                CreateDate = _time.GetAppNowTime()
                            };
                            db.StyleItems.Add(newStyleItem);
                            db.Commit();
                            if (si.Barcodes != null && si.Barcodes.Any())
                            {
                                foreach (var bi in si.Barcodes)
                                {
                                    db.StyleItemBarcodes.Add(new StyleItemBarcode()
                                    {
                                        StyleItemId = newStyleItem.Id,
                                        Barcode     = bi.Barcode,

                                        CreateDate = _time.GetAppNowTime(),
                                    });
                                }
                            }
                            db.Commit();
                        }

                        foreach (var image in incomeStyle.Images)
                        {
                            var newStyleImage = new StyleImage()
                            {
                                StyleId        = newStyle.Id,
                                Image          = image.Image,
                                SourceImage    = image.SourceImage,
                                SourceMarketId = image.SourceMarketId,
                                Type           = image.Type,
                                Category       = image.Category,
                                IsDefault      = image.IsDefault,
                                IsSystem       = image.IsSystem,
                                CreateDate     = _time.GetAppNowTime()
                            };
                            db.StyleImages.Add(newStyleImage);
                        }
                        db.Commit();
                    }
                    else
                    {
                        _log.Info("Already exists: " + incomeStyle.StyleID);

                        _log.Info("Style Name changed: " + existStyle.Name + " => " + incomeStyle.Name);
                        existStyle.Name = incomeStyle.Name;
                        db.Commit();
                    }
                }
            }
        }