public void SyncDate(DateTime from, DateTime to)
        {
            var fieldControlConfiguration = new FieldControlApi.Configuration.AppSettingsConfiguration();
            var client = new Client(fieldControlConfiguration);

            var authenticationCache = new SimpleFileCache("authentication");
            var accessToken         = authenticationCache.GetOrPut(() => {
                client.Authenticate();
                return(client.AuthenticationToken);
            });

            client.AuthenticationToken = accessToken;

            FileLog.WriteJson(fieldControlConfiguration);
            FileLog.WriteJson(client);

            var cPlusConfiguration = new CPlus.Configurations.AppSettingsConfiguration();
            var cPlusOrdersQuery   = new OrdersQuery(cPlusConfiguration);
            var orderDao           = new OrderDao(cPlusConfiguration);

            FileLog.WriteJson(cPlusConfiguration);

            var orders     = cPlusOrdersQuery.Execute(from, to);
            var activities = client.Execute(new GetActivitiesRequest(from, to));

            FileLog.WriteJson(orders);
            FileLog.WriteJson(activities);

            var       geoCoderConfiguration = new AppSettingsGeoCoderConfiguration();
            IGeocoder geocoder = new GoogleGeocoder()
            {
                ApiKey = geoCoderConfiguration.GoogleKey
            };

            var services  = client.Execute(new GetServicesRequest());
            var employees = client.Execute(new GetActiveEmployeesRequest(from));

            var activityConveter = new ActivityConverter(
                services: services,
                employees: employees,
                customerFieldControlService: new CustomerFieldControlService(client, geocoder)
                );

            FileLog.WriteJson(services);
            FileLog.WriteJson(employees);

            var commands = new List <ICommand>()
            {
                new CreateFieldControlActivityCommand(orders, activities, activityConveter, client),
                new UpdateCPlusOrderStatusCommand(orders, activities, orderDao)
            };

            commands.ForEach(command => {
                command.Run();
            });
        }
Пример #2
0
        public void FileCacheTest()
        {
            var fileCache = new SimpleFileCache("Test");
            fileCache.Add("Test", 1, DateTime.Now + new TimeSpan(1, 0, 0));

            var objActual = fileCache.Get("Test");
            Assert.AreEqual(1, objActual);

            fileCache.Remove("Test");
            objActual = fileCache.Get("Test");
            Assert.AreEqual(null, objActual);
        }
Пример #3
0
        public void ByteTest()
        {
            var fileCache = new SimpleFileCache("Test");

            var expected = new byte[]
            {
                1, 2, 3, 4
            };
            fileCache.Add("Test byte", expected, DateTime.Now + new TimeSpan(1, 0, 0));
            var objActual = fileCache.Get<byte[]>("Test byte");
            Assert.AreEqual(expected, objActual);
        }
Пример #4
0
        public void ByteTest()
        {
            var fileCache = new SimpleFileCache("Test");

            var expected = new byte[]
            {
                1, 2, 3, 4
            };

            fileCache.Add("Test byte", expected, DateTime.Now + new TimeSpan(1, 0, 0));
            var objActual = fileCache.Get <byte[]>("Test byte");

            Assert.AreEqual(expected, objActual);
        }
Пример #5
0
        public void FileCacheTest()
        {
            var fileCache = new SimpleFileCache("Test");

            fileCache.Add("Test", 1, DateTime.Now + new TimeSpan(1, 0, 0));

            var objActual = fileCache.Get("Test");

            Assert.AreEqual(1, objActual);

            fileCache.Remove("Test");
            objActual = fileCache.Get("Test");
            Assert.AreEqual(null, objActual);
        }