protected override void ExecuteVendorTask() { _monitoring = new FeeblMonitoring(); _monitoring.Notify(Name, 0); if (Location.IsNullOrWhiteSpace()) { TraceError("The connector setting '{0}' does not exists or is empty!", Constants.Vendor.Setting.Location); } else { var locationInfo = new DirectoryInfo(Location); if (!locationInfo.FullName.EndsWith("$") && !locationInfo.Exists) { TraceError("The directory '{0}' does not exists!", locationInfo.FullName); } else if (!locationInfo.FullName.EndsWith("$") && !locationInfo.HasAccess(FileSystemRights.FullControl)) { TraceError("The user '{0}' has insufficient access over the directory '{1}'!", WindowsIdentity.GetCurrent().Name, locationInfo.FullName); } else if (ProductAttributeHelper.Bind(PropertyStore, Context, TraceSource)) { Languages = Unit.Scope .Repository <Language>() .GetAll(language => language.Name == Constants.Language.English) .ToArray(); TariffVendors = Unit.Scope .Repository <Vendor>() .Include(vendor => vendor.VendorSettings) .GetAll(vendor => vendor.ParentVendorID == VendorID) .AsEnumerable() .Where(vendor => vendor.GetVendorSetting(Constants.Vendor.Setting.IsTariff, false) && !vendor.GetVendorSetting(Constants.Vendor.Setting.CountryCode).IsNullOrWhiteSpace() && !vendor.GetVendorSetting(Constants.Vendor.Setting.CurrencyCode).IsNullOrWhiteSpace()) .ToDictionary(GetTariffCode); var files = locationInfo.GetFiles("*.csv", SearchOption.TopDirectoryOnly); TraceInformation("Found {0} CSV-files for import!", files.Length); foreach (var fileInfo in files) { TraceInformation("Importing the file '{0}'...", fileInfo); var articles = GetArticles(fileInfo.FullName); if (articles != null) { var enumerableArticles = articles as Article[] ?? articles.ToArray(); ImportTariffVendors(enumerableArticles); var vendorAssortmentItems = GetVendorAssortments(enumerableArticles).ToArray(); var success = true; foreach (var vendorAssortmentGrouping in vendorAssortmentItems.GroupBy(vendorAssortmentItem => vendorAssortmentItem.VendorProduct.VendorID)) { TraceInformation("Importing assortment for vendor '{0}'...", vendorAssortmentGrouping.Key != VendorID ? Unit.Scope.Repository <Vendor>().GetSingle(vendor => vendor.VendorID == vendorAssortmentGrouping.Key).Name : VendorName); var bulkConfig = new VendorAssortmentBulkConfiguration { IsPartialAssortment = true }; using (var bulk = new VendorAssortmentBulk(vendorAssortmentGrouping, vendorAssortmentGrouping.Key, VendorID, bulkConfig)) { try { bulk.Init(Unit.Context); bulk.Sync(Unit.Context); } catch (Exception exception) { success = false; TraceCritical(exception); } } } fileInfo.CopyTo(fileInfo.FullName + (success ? ".processed" : ".failed"), true); fileInfo.Delete(); } } ImportProductConfiguration(PropertyStore.ColorCode, PropertyStore.SizeCode); ImportProductGroups(); } } _monitoring.Notify(Name, 1); }