Ejemplo n.º 1
0
        private ApiContext()
        {
            appConfig   = onedrive.ReadConfig <AqaraConfiguration>("aqaraCloud");
            tokenConfig = onedrive.ReadConfig <Token>("aqaraCloud.token");

            api = new AqaraClient(appConfig);
            api.SetCredentials(tokenConfig.AccessToken);
        }
Ejemplo n.º 2
0
        public MainForm()
        {
            InitializeComponent();

            var basepath = APPFOLDER;

            if (Directory.Exists(APPFOLDER))
            {
                basepath = APPFOLDER;
            }
            else if (Directory.Exists(SKYFOLDER))
            {
                basepath = SKYFOLDER;
            }
            else if (Directory.Exists(DOCFOLDER))
            {
                basepath = DOCFOLDER;
            }

            var         configFile = Path.Combine(basepath, "config", "aqara.json");
            AqaraConfig config     = null;

            if (File.Exists(configFile))
            {
                config = AqaraConfig.Parse(File.ReadAllText(configFile));
            }
            client = new AqaraClient(config);

            timerRefresh          = new Timer();
            timerRefresh.Interval = 1000;
            timerRefresh.Tick    += TimerRefresh_Tick;

            var column = new DataColumn()
            {
                Unique = true
            };

            table.Columns.Add("sid", typeof(string));
            table.Columns.Add("short_id", typeof(string));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("model", typeof(string));
            table.Columns.Add("data", typeof(string));
            table.Columns.Add("timestamp", typeof(string));
            table.Columns.Add("DateUpdated", typeof(DateTime));
            table.PrimaryKey = new DataColumn[] { table.Columns["sid"] };

            dataGridView1.DataSource = table;
        }
Ejemplo n.º 3
0
        public MainForm()
        {
            InitializeComponent();

            string basePath = Path.Combine(
                KnownFolderPaths.KnownFolders.GetPath(KnownFolderPaths.KnownFolder.SkyDrive),
                @"ApplicationData\ConnectedHome\");

            if (!Directory.Exists(basePath))
            {
                Path.Combine(
                    Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments),
                    @"Elton\ConnectedHome\");
            }
            var         configFile = Path.Combine(basePath, "config", "aqara.json");
            AqaraConfig config     = null;

            if (File.Exists(configFile))
            {
                config = AqaraConfig.Parse(File.ReadAllText(configFile));
            }
            client = new AqaraClient(config);

            timerRefresh          = new Timer();
            timerRefresh.Interval = 1000;
            timerRefresh.Tick    += TimerRefresh_Tick;

            var column = new DataColumn()
            {
                Unique = true
            };

            table.Columns.Add("sid", typeof(string));
            table.Columns.Add("short_id", typeof(string));
            table.Columns.Add("name", typeof(string));
            table.Columns.Add("model", typeof(string));
            table.Columns.Add("data", typeof(string));
            table.Columns.Add("timestamp", typeof(string));
            table.Columns.Add("DateUpdated", typeof(DateTime));
            table.PrimaryKey = new DataColumn[] { table.Columns["sid"] };

            dataGridView1.DataSource = table;
        }
Ejemplo n.º 4
0
 public void Initialize()
 {
     instance = ApiContext.Api;
     config   = ApiContext.Config;
 }