Example #1
0
 public CommandSideInitializer(
     IEventStore eventStore,
     IRemoteRepository remoteRepository)
 {
     _eventStore       = eventStore;
     _remoteRepository = remoteRepository;
 }
 /// <summary>
 /// Creates a new installation manager.
 /// </summary>
 /// <param name="remoteRepository">The remote respository to download versions from.</param>
 /// <param name="fileUtility">The file utility to use.</param>
 /// <param name="installationDirectory">The directory to place DR installations in.</param>
 /// <param name="context">The application's context.</param>
 public InstallationManager(IRemoteRepository remoteRepository, IFileUtility fileUtility, string installationDirectory, IContext context)
 {
     this.installationDirectory = installationDirectory;
     this.fileUtility           = fileUtility;
     this.remoteRepository      = remoteRepository;
     this.context = context;
 }
Example #3
0
 public ProductPicSynchronizer(IRemoteRepository remoteRepository, IProductPicProcessor productPicProcessor)
 {
     _remoteRepository = remoteRepository;
     //_updateDateStore = updateDateStore;
     _productPicProcessor = productPicProcessor;
     //_lastUpdateDateTimeKey = GetType().FullName;
 }
 public ProductStockSyncJob()
 {
     _remoteRepository             = new RemoteRepository();
     _channelMapper                = new ChannelMapper();
     _productPropertySyncProcessor = new ProductPropertySyncHandler(_channelMapper);
     _inventorySyncProcessor       = new InventorySyncProcessor();
 }
Example #5
0
        public ProductSyncProcessor(IRemoteRepository remoteRepository, IChannelMapper channelMapper)
        {
            _channelMapper         = channelMapper;
            _categorySyncProcessor = new CategorySyncProcessor(channelMapper);
            _brandSyncProcessor    = new BrandSyncProcessor(remoteRepository, channelMapper);
            var storeSyncProcessor = new StoreSyncProcessor(remoteRepository, channelMapper);

            _sectionSyncProcessor = new SectionSyncProcessor(remoteRepository, storeSyncProcessor, channelMapper);
        }
        public AllSynchronizer(IRemoteRepository remoteRepository)
        {
            _remoteRepository = remoteRepository;
            _skuSyncProcessor = new SkuSyncProcessor();
            var storeSyncProcessor   = new StoreSyncProcessor(_remoteRepository, _channelMapper);
            var sectionSyncProcessor = new SectionSyncProcessor(_remoteRepository, storeSyncProcessor, _channelMapper);

            _stockSyncProcessor           = new StockSyncProcessor(sectionSyncProcessor);
            _productSyncProcessor         = new ProductSyncProcessor(_remoteRepository, _channelMapper);
            _productPropertySyncProcessor = new ProductPropertySyncProcessor(_channelMapper);
            _productPropertySyncHandler   = new ProductPropertySyncHandler(_channelMapper);
            _inventorySyncProcessor       = new InventorySyncProcessor();
            _brandSizeProcessor           = new BrandSizeProcessor();
        }
        } // end of function - AuthenticateAsync

        /*----------------------- CheckAuthorizationAsync -----------------------*/
        /// <summary>
        ///
        /// </summary>
        /// <param name="repo"></param>
        private async Task <ActionResult> CheckAuthorizationAsync(IRemoteRepository repo)
        {
            ActionResult retval = null;
            // Authenticate the repository
            var resp = await AuthenticateAsync(repo);

            // If we were not successful, then we will forward the result back to the
            // user
            if (System.Net.HttpStatusCode.OK != resp.StatusCode)
            {
                retval = new ForwardedResult(resp);
            }
            return(retval);
        } // end of function - CheckAuthorizationAsync
Example #8
0
 /************************ Construction ***********************************/
 /*----------------------- LocalRepo -------------------------------------*/
 /// <summary>
 /// Constructor, taking a remote repository and local configuration object
 /// </summary>
 /// <param name="remoteRepo">
 /// A remote repository to setup a local one for
 /// </param>
 /// <param name="config">
 /// A configuration object to use for the local repository
 /// </param>
 public LocalRepository(IRemoteRepository remoteRepo, IGitCacheConfiguration config)
 {
     if (null == (Remote = remoteRepo))
     {
         throw new ArgumentNullException(
                   nameof(remoteRepo),
                   "Must provide a remote repository object");
     }
     if (null == config)
     {
         throw new ArgumentNullException(
                   nameof(config),
                   "Must provide a valid configuration item");
     }
     Path = System.IO.Path.Combine(config.LocalStoragePath,
                                   Remote.Server,
                                   Remote.Owner,
                                   Remote.Name);
 } /* End of Function - LocalRepo */
        } /* End of Function - OnResourceExecutionAsync */

        /************************ Fields *****************************************/
        /************************ Static *****************************************/

        /*======================= PROTECTED =====================================*/
        /************************ Events *****************************************/
        /************************ Properties *************************************/
        /************************ Construction ***********************************/
        /************************ Methods ****************************************/
        /************************ Fields *****************************************/
        /************************ Static *****************************************/

        /*======================= PRIVATE =======================================*/
        /************************ Events *****************************************/
        /************************ Properties *************************************/
        /************************ Construction ***********************************/
        /************************ Methods ****************************************/
        /*----------------------- AuthenticateAsync -----------------------------*/
        /// <summary>
        ///
        /// </summary>
        /// <param name="repo"></param>
        private async Task <HttpResponseMessage> AuthenticateAsync(IRemoteRepository repo)
        {
            // Create a HTTP client to work with
            HttpClient client = new HttpClient();

            // Clear out the headers and setup our own
            client.DefaultRequestHeaders.Accept.Clear();
            // Attach the authentication if we have it
            if (null != repo.Auth)
            {
                client.DefaultRequestHeaders.Authorization
                    = new AuthenticationHeaderValue(repo.Auth.Scheme,
                                                    repo.Auth.Encoded);
            }
            // Pretend we are a git client
            client.DefaultRequestHeaders.UserAgent.Add(
                new ProductInfoHeaderValue("git", "1.0"));
            // Finally go ahead and authenticate against the info/refs url
            string url = $"{repo.Url}/info/refs?service=git-upload-pack";

            return(await client.GetAsync(url));
        } // end of function - AuthenticateAsync
Example #10
0
 /// <summary>
 /// Creates a new documentation manager.
 /// </summary>
 /// <param name="remoteRepository">The remote respository to download versions from.</param>
 /// <param name="fileUtility">The file utility to use.</param>
 /// <param name="installationDirectory">The directory to place DR documentation in.</param>
 public DocumentationManager(IRemoteRepository remoteRepository, IFileUtility fileUtility, string installationDirectory)
 {
     this.installationDirectory = installationDirectory;
     this.remoteRepository      = remoteRepository;
     this.fileUtility           = fileUtility;
 }
 public AddRemoteHandler(IRemoteRepository remoteRepository)
 {
     _remoteRepository = remoteRepository;
 }
Example #12
0
 public UpdateAnalogCoordinateHandler(IRemoteRepository remoteRepository)
 {
     _remoteRepository = remoteRepository;
 }
Example #13
0
 public MainPageViewModel(INavigationService navigationService, IRemoteRepository remoteRepository, IBrowser browser)
     : base(navigationService)
 {
     _remoteRepository = remoteRepository;
     _browser          = browser;
 }
Example #14
0
        public async Task RunAsync()
        {
            using IRemoteRepository repo = _repoProvider();

            PrintHeader("GET ALL PRODUCTS:");
            foreach (var item in await repo.Products.ToArrayAsync().ConfigureAwait(false))
            {
                PrintLine($"  {item.Id} | {item.Name} | {item.Price:C}");
            }

            PrintHeader("CROSS JOIN:");
            Func <object, string> sufix = (x) => x + "ending";
            var crossJoinQuery          =
                from c in repo.ProductCategories
                from p in repo.Products
                select new { Category = "#" + c.Name + sufix("-"), p.Name };
            var crossJoinResult = await crossJoinQuery.ToListAsync().ConfigureAwait(false);

            foreach (var item in crossJoinResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("INNER JOIN:");
            var innerJoinQuery =
                from c in repo.ProductCategories
                join p in repo.Products on c.Id equals p.ProductCategoryId
                select new { c.Name, P = new { p.Price }, X = new { Y = string.Concat(c.Name, "-", p.Name) } };
            var innerJoinResult = await innerJoinQuery.ToListAsync().ConfigureAwait(false);

            foreach (var item in innerJoinResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("SELECT IDs:");
            var productIdsQuery =
                from p in repo.Products
                orderby p.Price descending
                select p.Id;
            var productIds = await productIdsQuery
                             .ToListAsync()
                             .ConfigureAwait(false);

            foreach (int id in productIdsQuery)
            {
                PrintLine($"  {id}");
            }

            PrintHeader("COUNT:");
            var productsQuery =
                from p in repo.Products
                select p;

            PrintLine($"  Count = {await productsQuery.CountAsync().ConfigureAwait(false)}");

            PrintHeader("TOTAL AMOUNT BY CATEGORY:");
            var totalAmountByCategoryQuery =
                from c in repo.ProductCategories
                join p in repo.Products
                on c.Id equals p.ProductCategoryId
                join i in repo.OrderItems
                on p.Id equals i.ProductId
                group new { c, p, i } by c.Name into g
                select new
            {
                Category = g.Key,
                Amount   = g.Sum(x => x.i.Quantity * x.p.Price),
                Amount2  = new { Amount = g.Sum(x => x.i.Quantity * x.p.Price) },
            };

            var totalAmountByCategroyResult = await totalAmountByCategoryQuery
                                              .ToDictionaryAsync(x => x.Category)
                                              .ConfigureAwait(false);

            foreach (var item in totalAmountByCategroyResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("EXPECTED INVALID OPERATION:");
            try
            {
                _ = await totalAmountByCategoryQuery
                    .Select(x => x.Category)
                    .FirstAsync(x => false)
                    .ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                PrintLine($"  {ex.GetType().Name}: {ex.Message}");
            }
        }
Example #15
0
 public StoreSyncProcessor(IRemoteRepository remoteRepository, IChannelMapper channelMapper)
 {
     _remoteRepository = remoteRepository;
     _channelMapper    = channelMapper;
 }
 public SectionSyncProcessor(IRemoteRepository remoteRepository, IStoreSyncProcessor storeSyncProcessor, IChannelMapper channelMapper)
 {
     _remoteRepository   = remoteRepository;
     _storeSyncProcessor = storeSyncProcessor;
 }
Example #17
0
 /*======================= PUBLIC ========================================*/
 /************************ Events *****************************************/
 /************************ Properties *************************************/
 /************************ Construction ***********************************/
 /************************ Methods ****************************************/
 /*----------------------- Build -----------------------------------------*/
 /// <summary>
 ///
 /// </summary>
 /// <param name="repo"></param>
 /// <param name="config"></param>
 public ILocalRepository Build(
     IRemoteRepository repo,
     IGitCacheConfiguration config)
 {
     return(new LocalRepository(repo, config));
 } /* End of Function - Build */
Example #18
0
        public async Task RunAsync()
        {
            using IRemoteRepository repo = _repoProvider();

            PrintHeader("GET ALL PRODUCTS:");
            var allProducts = repo.Products
                              .AsAsyncEnumerable()
                              .ConfigureAwait(false);

            await foreach (var item in allProducts)
            {
                PrintLine($"  {item.Id} | {item.Name} | {item.Price:C}");
            }

            PrintHeader("CROSS JOIN:");
            Func <object, string> sufix = (x) => x + "ending";
            var crossJoinQuery          =
                from c in repo.ProductCategories
                from p in repo.Products
                select new { Category = "#" + c.Name + sufix("-"), p.Name };
            var crossJoinResult = crossJoinQuery
                                  .AsAsyncEnumerable()
                                  .ConfigureAwait(false);

            await foreach (var item in crossJoinResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("INNER JOIN:");
            var innerJoinQuery =
                from c in repo.ProductCategories
                join p in repo.Products on c.Id equals p.ProductCategoryId
                select new { c.Name, P = new { p.Price }, X = new { Y = string.Concat(c.Name, "-", p.Name) } };
            var innerJoinResult = innerJoinQuery
                                  .AsAsyncEnumerable()
                                  .ConfigureAwait(false);

            await foreach (var item in innerJoinResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("SELECT IDs:");
            var productIdsQuery =
                from p in repo.Products
                orderby p.Price descending
                select p.Id;
            var productIds = productIdsQuery
                             .AsAsyncEnumerable()
                             .ConfigureAwait(false);

            await foreach (int id in productIds)
            {
                PrintLine($"  {id}");
            }

            PrintHeader("TOTAL AMOUNT BY CATEGORY:");
            var totalAmountByCategoryQuery =
                from c in repo.ProductCategories
                join p in repo.Products
                on c.Id equals p.ProductCategoryId
                join i in repo.OrderItems
                on p.Id equals i.ProductId
                group new { c, p, i } by c.Name into g
                select new
            {
                Category = g.Key,
                Amount   = g.Sum(x => x.i.Quantity * x.p.Price),
                Amount2  = new { Amount = g.Sum(x => x.i.Quantity * x.p.Price) },
            };

            var totalAmountByCategroyResult = totalAmountByCategoryQuery
                                              .AsAsyncEnumerable()
                                              .ConfigureAwait(false);

            await foreach (var item in totalAmountByCategroyResult)
            {
                PrintLine($"  {item}");
            }
        }
 public AddAnalogHandler(IRemoteRepository remoteRepository)
 {
     _remoteRepository = remoteRepository;
 }
Example #20
0
        public void Run()
        {
            using IRemoteRepository repo = _repoProvider();

            PrintHeader("GET ALL PRODUCTS:");
            foreach (var item in repo.Products)
            {
                PrintLine($"  {item.Id} | {item.Name} | {item.Price:C}");
            }

            PrintHeader("GET PRODUCTS FILTERED BY ID:");
            var idSelection = new List <int> {
                1, 11, 111
            };

            foreach (var item in repo.Products.Where(p => idSelection.Contains(p.Id) || p.Id % 3 == 0))
            {
                PrintLine($"  {item.Id} | {item.Name} | {item.Price:C}");
            }

            PrintHeader("CROSS JOIN:");
            Func <object, string> sufix = (x) => x + "ending";
            var crossJoinQuery          =
                from c in repo.ProductCategories
                from p in repo.Products
                select new { Category = "#" + c.Name + sufix("-"), p.Name };

            var crossJoinResult = crossJoinQuery
#if KNOWN_TYPES_ONLY
                                  .Select(x => new Common.Model.CrossJoinResultDto {
                Category = x.Category, Name = x.Name
            })
#endif
                                  .ToList();

            foreach (var i in crossJoinResult)
            {
                PrintLine($"  {i}");
            }

            PrintHeader("INNER JOIN:");
            var innerJoinQuery =
                from c in repo.ProductCategories
                join p in repo.Products on c.Id equals p.ProductCategoryId
                select new { c.Name, P = new { p.Price }, X = new { Y = string.Concat(c.Name, "-", p.Name) } };
            var innerJoinResult = innerJoinQuery
#if KNOWN_TYPES_ONLY
                                  .Select(x => new Common.Model.InnerJoinResultDto {
                Name = x.Name, Price = x.P.Price, XY = x.X.Y
            })
#endif
                                  .ToList();

            foreach (var item in innerJoinResult)
            {
                PrintLine($"  {item}");
            }

            PrintHeader("SELECT IDs:");
            var productIdsQuery =
                from p in repo.Products
                orderby p.Price descending
                select p.Id;
            var productIds = productIdsQuery.ToList();

            foreach (int id in productIdsQuery)
            {
                PrintLine($"  {id}");
            }

            PrintHeader("COUNT:");
            var productsQuery =
                from p in repo.Products
                select p;

            PrintLine($"  Count = {productsQuery.Count()}");

            PrintHeader("TOTAL AMOUNT BY CATEGORY:");
            var totalAmountByCategoryQuery =
                from c in repo.ProductCategories
                join p in repo.Products
                on c.Id equals p.ProductCategoryId
                join i in repo.OrderItems
                on p.Id equals i.ProductId
                group new { c, p, i } by c.Name into g
                select new
            {
                Category = g.Key,
                Amount   = g.Sum(x => x.i.Quantity * x.p.Price),
            };

            var totalAmountByCategroyResult = totalAmountByCategoryQuery
#if KNOWN_TYPES_ONLY
                                              .Select(x => new Common.Model.TotalAmountByCategoryDto {
                Category = x.Category, Amount = x.Amount
            })
#endif
                                              .ToDictionary(x => x.Category, x => x.Amount);

            foreach (var i in totalAmountByCategroyResult)
            {
                PrintLine($"  {i.Key}: {i.Value:C}");
            }

            PrintHeader("GET PRODUCT GROUPS:");
            foreach (var group in repo.ProductGroups)
            {
                PrintLine($"  {group.Id} | {group.GroupName}");

                foreach (var p in group.Products)
                {
                    PrintLine($"    | * {p.Name}");
                }
            }

            PrintHeader("EXPECTED INVALID OPERATION:");
            try
            {
                _ = totalAmountByCategoryQuery
                    .Select(x => x.Category)
                    .First(x => false);
            }
            catch (Exception ex)
            {
                PrintLine($"  {ex.GetType().Name}: {ex.Message}");
            }
        }
Example #21
0
 public RemoteCollectionView2(IRemoteRepository repository)
 {
     _repository = repository;
 }