示例#1
0
        private async Task <string> GetServerWebID()
        {
            string webId = AppSettingsManager.Instance.LocalSettings.Containers["ServerSettings"].GetValueOrDefault("WebId", "");

            if (!string.IsNullOrEmpty(webId))
            {
                return(webId);
            }

            HttpResponseMessage responseGetServer = await _piWebClient.GetServerByPath(@"\\jupiter001");

            dynamic valueResult;

            using (StreamReader sr = new StreamReader((await responseGetServer.Content.ReadAsInputStreamAsync()).AsStreamForRead()))
            {
                using (JsonTextReader jReader = new JsonTextReader(sr))
                {
                    valueResult = JObject.ReadFrom(jReader);
                }
            }

            string newWebId = valueResult["WebId"];

            if (!string.IsNullOrEmpty(newWebId))
            {
                AppSettingsManager.Instance.LocalSettings.Containers["ServerSettings"].AddOrUpdateValue("WebId", newWebId);
            }

            return(newWebId);
        }