예제 #1
0
        private void SyncProductMediaData(ProductMediaDifferential productToSync, Database db)
        {
            var productMedia = ProductMediaRepository.GetMediaForProduct(productToSync.ProductID);

            foreach (var productMediaItem in productMedia)
            {
                var newProductMedia = productMediaItem;
                newProductMedia.ProductID = productToSync.RsoProductID;
                newProductMedia.TypeID    = ProductMediaTypeIDLookup[productMediaItem.TypeID];
                newProductMedia.VendorID  = IntersportContentVendorID;
                newProductMedia.MediaPath = GetNewMediaPath(productMediaItem.MediaPath);

                ProductMediaRepository.AddNewProductMedia(newProductMedia, db);
            }
        }
예제 #2
0
        private void SyncProductMediaFiles(ProductMediaDifferential productToSync, Database db)
        {
            var productMedias = ProductMediaRepository.GetMediaForProduct(productToSync.ProductID);

            foreach (var productMedia in productMedias)
            {
                var newFileLocation = Path.Combine(MediaLocationBasePath, GetNewMediaPath(productMedia.MediaPath));

                var directoryName = Path.GetDirectoryName(newFileLocation);
                if (!Directory.Exists(directoryName))
                {
                    Directory.CreateDirectory(directoryName);
                }

                if (!File.Exists(newFileLocation))
                {
                    File.Copy(Path.Combine(MediaSourceLocation, productMedia.MediaPath), newFileLocation);
                }
            }
        }
예제 #3
0
        private void SyncMedia(ProductMediaDifferential productToSync)
        {
            TraceInformation("Synchronizing product: {0}", productToSync.VendorItemNumber);

            using (var db = new Database(Environments.Current.Connection, "System.Data.SqlClient"))
            {
                db.BeginTransaction();

                try
                {
                    SyncProductMediaData(productToSync, db);
                    SyncProductMediaFiles(productToSync, db);

                    db.CompleteTransaction();
                }
                catch (Exception e)
                {
                    db.AbortTransaction();
                    TraceError("Failed to synchronize media for product: {0}", productToSync.VendorItemNumber);
                    TraceCritical(e);
                }
            }
        }