Beispiel #1
0
 public SerialConnection(ILogger logger, string portName, MessageHandler messageHandler)
 {
     _serialPort = new SerialPort
     {
         PortName = portName,
         BaudRate = 9600,
         Parity   = Parity.None,
         DataBits = 8,
         StopBits = StopBits.One,
         Encoding = Encoding.ASCII
     };
     _logger         = CategoryLogger.Create(nameof(SerialConnection), logger);
     _messageHandler = messageHandler;
 }
Beispiel #2
0
 public ActionRouter(ILogger logger, ButtonDeckCommunication communication)
 {
     _logger       = CategoryLogger.Create(nameof(ActionRouter), logger);
     Communication = communication;
     Communication.ToggleStateChanged   += Communication_ToggleStateChanged;
     Communication.VersionResponse      += Communication_VersionResponse;
     Communication.HeartbeatResponse    += Communication_HeartbeatResponse;
     Communication.LEDBrightness        += Communication_LEDBrightness;
     Communication.ButtonUp             += Communication_ButtonUp;
     Communication.ButtonDown           += Communication_ButtonDown;
     Communication.InvalidResponse      += Communication_InvalidResponse;
     Communication.AcknowledgedResponse += Communication_AcknowledgedResponse;
     Deck = ButtonDeckInformation.Default;
     Initialise();
 }
Beispiel #3
0
		public TestRunner(DependencyResolver resolver)
		{
			m_resolver = resolver;
			m_logger = new CategoryLogger(this);
		}
Beispiel #4
0
        public static void Main(string[] args)
        {
            string filePath = null;
            if (args.Length == 0)
            {
                throw new ArgumentException("Should be called with a Json PlayDrone file to import.");
            }

            filePath = args[0];

            var log = new Logger();
            var appConverter = new FileReader(log);

            var apps = appConverter.FileToModel(filePath);
            var count = apps.Count();

            // Setup connection
            var connectionString = ConfigurationManager.ConnectionStrings["MarketDbConnectionString"];
            using (var connection = new SqlConnection(connectionString.ConnectionString))
            {
                // Initialise app store with logger and connection
                var appSqlStore = new AppStore(connection);
                var appStore = new AppLogger(appSqlStore, appSqlStore, log);
                var categorySqlStore = new CategoryStore();
                var categoryCacheStore = new CategoryCache(categorySqlStore, categorySqlStore);
                var categoryStore = new CategoryLogger(categoryCacheStore, categoryCacheStore, log);

                // Assuming apps are added in order to save multiple queries to the database.
                var existingAppCount = appStore.Count();

                // Loop through apps. App store will save every 100,000 apps
                var appsToSave = new List<Models.App>();
                var appCounter = 0;
                for (int i = existingAppCount; i < count; i++)
                {
                    // Get the app from the list.
                    var app = apps[i];

                    // Store the app category if it doesn't exist.
                    if (!categoryStore.Exists(app.category))
                    {
                        var category = new Models.Category { Id = Guid.NewGuid(), Name = app.category };
                        categoryStore.Save(category);
                    }

                    // Lookup app category id.
                    var categoryId = categoryStore.GetId(app.category);

                    app.id = Guid.NewGuid();
                    app.categoryId = categoryId;
                    appsToSave.Add(app);
                    log.LogOperation(string.Format("App {0}/{1} added: {2}", i + 1, count, app.app_id));
                    appCounter++;

                    // Save apps
                    if(appCounter >= 100000)
                    {
                        appStore.SaveMany(appsToSave);
                        appsToSave.Clear();
                        appCounter = 0;
                    }
                }

                // Save the remainder
                appStore.SaveMany(appsToSave);

                log.LogOperation("DONE!!!!");
            }
        }
Beispiel #5
0
 public MessageBuilder(ILogger logger)
 {
     _logger = CategoryLogger.Create(nameof(MessageBuilder), logger);
 }