示例#1
0
        public BroadcastMainViewModel()
        {
            #region Initialising

            InitBroadcastCommands();
            ApplicationInformation = SimpleIoc.Default.GetInstance <ApplicationInformation>();
            Customers          = new ObservableCollectionEx <T>();
            clipboardHelper    = new ClipboardHelper <T>();
            dialogService      = SimpleIoc.Default.GetInstance <IDialogService>();
            csvImporter        = SimpleIoc.Default.GetInstance <ICsvImporter <T> >();
            csvExporter        = SimpleIoc.Default.GetInstance <ICsvExporter <T> >();
            scheduler          = SimpleIoc.Default.GetInstance <IScheduler <T> >();
            extensionContainer = SimpleIoc.Default.GetInstance <IExtensionContainer>();
            client             = SimpleIoc.Default.GetInstance <IClient>();
            sync = new object();

            #endregion

            #region Subscribes
            clipboardHelper.ItemLoaded  += ClipboardHelperOnItemLoaded;
            csvExporter.AllItemSaved    += csvExporter_AllItemSaved;
            csvImporter.ItemLoaded      += csvLoader_ItemLoaded;
            csvImporter.AllItemLoaded   += csvImporter_AllItemLoaded;
            Customers.CollectionChanged += Customers_CollectionChanged;
            client.ErrorOccurred        += ClientOnErrorOccurred;

            scheduler.WorksCompleted   += SchedulerOnWorksCompleted;
            scheduler.OneWorkCompleted += SchedulerOneWorkCompleted;
            #endregion
        }
示例#2
0
        /// Only handles email subscribers.
        public static async Task <int> ImportSubscribers(string filePath, ICsvImporter importer, GovDeliveryContextFactory factory)
        {
            var ctx = factory.CreateDbContext();

            if (string.IsNullOrWhiteSpace(filePath))
            {
                Console.WriteLine("Path to a .csv file must be provided.");
                return(1);
            }

            Console.WriteLine($"Attempting to import subscribers from {filePath}...");

            var subscribers = await importer.ImportSubscribersAsync(filePath);

            Console.WriteLine($"Found {subscribers.Count()} subscribers to import.");

            var importedSubscribers = subscribers
                                      .Where(s => s.Type == SubscriberType.Email)
                                      .Select(s => new Subscriber {
                Id = Guid.NewGuid(), Email = s.Contact
            });

            var localSubscribers = ctx.Subscribers.ToList();

            var newSubscribers = importedSubscribers
                                 .Where(s => !localSubscribers.Any(ls => ls.Email == s.Email));

            ctx.Subscribers.AddRange(newSubscribers);
            await ctx.SaveChangesAsync();

            Console.WriteLine("Successfully imported subscribers.");

            return(0);
        }
 private CommandExecuter CreateSut()
 {
     vehicleManager = new vehicleManagerMock();
     console        = new ConsoleMock();
     vehicleParser  = null;
     garageManager  = new GarageManagerMock();
     garageParser   = new GarageParserMock();
     csvImporter    = null;
     file           = null;
     return(new CommandExecuter(vehicleManager, console, vehicleParser, garageManager, garageParser, csvImporter, file));
 }
 public CommandExecuterFactory(
     IVehicleManager vehilceManager,
     IConsoleInputOutput console,
     IVehicleParser vehicleParser,
     IGarageManager garageManager,
     IGarageParser garageParser,
     ICsvImporter csvImporter,
     IFileInputOutput file)
 {
     this.vehicleParser  = vehicleParser;
     this.vehilceManager = vehilceManager;
     this.console        = console;
     this.garageManager  = garageManager;
     this.garageParser   = garageParser;
     this.csvImporter    = csvImporter;
     this.file           = file;
 }
示例#5
0
 public CommandExecuter(IVehicleManager vehicleManager,
                        IConsoleInputOutput consoleInputOutput,
                        IVehicleParser vehicleParser,
                        IGarageManager garageManager,
                        IGarageParser garageParser,
                        ICsvImporter csvImporter,
                        IFileInputOutput file
                        )
 {
     this.selectedVehicles = new Dictionary <Vehicle, ParkingPlaceOutput>();
     this.vehicleManager   = vehicleManager;
     this.console          = consoleInputOutput;
     this.vehicleParser    = vehicleParser;
     this.garageManager    = garageManager;
     this.garageParser     = garageParser;
     this.csvImporter      = csvImporter;
     this.file             = file;
 }
示例#6
0
        static void Main(string[] args)
        {
            using (var reader = File.OpenText($@"{AppContext.BaseDirectory}\appSettings.json"))
            {
                var appSettingsText = reader.ReadToEnd();
                AppSettings = JsonConvert.DeserializeObject <AppSettings>(appSettingsText);
            }

            Service = new GovDeliveryApiService(
                AppSettings.GovDelivery.Server,
                AppSettings.GovDelivery.AccountCode,
                AppSettings.GovDelivery.Username,
                AppSettings.GovDelivery.Password
                );

            var builderOptions = new DbContextOptionsBuilder()
                                 .UseSqlServer(AppSettings.ConnectionStrings.GovDelivery);

            ContextFactory = new GovDeliveryContextFactory(builderOptions);

            Importer = new CsvImporter();

            ConfigureCli(args);
        }
示例#7
0
 public IntegrationService(ICsvReader <CsvRow> reader, ICsvImporter csvImporter, ILogger <IntegrationService> logger)
 {
     this.reader      = reader;
     this.csvImporter = csvImporter;
     this.logger      = logger;
 }