コード例 #1
0
ファイル: UiCatalog.xaml.cs プロジェクト: enviriot/EnviriotSW
        private async void LoadChildren()
        {
            try {
                _loaded = true;
                var json = await UiCatalog.GetHttpString(_url + "index.json");

                var arr = JSL.JSON.parse(json);
                _items = new List <CatalogItem>();
                foreach (var kv in arr)
                {
                    _items.Add(new CatalogItem(this, kv.Value));
                }
            }
            catch (Exception ex) {
                Log.Warning("{0}.Load - {1}", _path, ex.Message);
            }
        }
コード例 #2
0
ファイル: UiCatalog.xaml.cs プロジェクト: enviriot/EnviriotSW
        public async void Download()
        {
            string srcUrl;

            if (string.IsNullOrEmpty(_src))
            {
                srcUrl = null;
            }
            else if (_src.StartsWith("http"))
            {
                srcUrl = _src;
            }
            else if (_src.StartsWith("/"))
            {
                srcUrl = (new Uri(_parent._url)).GetLeftPart(UriPartial.Authority) + _src;
            }
            else
            {
                srcUrl = _parent._url + _src;
            }
            if (srcUrl == null)
            {
                return;
            }
            try {
                var txt = await UiCatalog.GetHttpString(srcUrl);

                var body    = Encoding.UTF8.GetBytes(txt);
                var payload = Convert.ToBase64String(body);

                _rootT.Connection.SendCmd(16, srcUrl, payload);
                if (_checkTopic == null)
                {
                    await Task.Delay(300);

                    var tt = _rootT.GetAsync(_checkPath).ContinueWith(CheckTopicLoaded);
                }
                Log.Info("Import({0})", srcUrl);
            }
            catch (Exception ex) {
                Log.Warning("Import({0}) - {1}", srcUrl, ex.Message);
            }
        }