コード例 #1
0
        private static async Task Inner_RegisterToMenuService(SampleAppSettings appSettings, MenuRegistrationRequest newRequest)
        {
            var apiPath = MENUSERVICE_BASE_API_PATH + "/api/Menus/PostApplicationMenus?appId={0}";

            apiPath = string.Format(apiPath, NAFInitializationInfo.Current.AppSecurityID.ToString());
            //
            var client = GetMenuClient(appSettings);

            var content = new StringContent(NSerializer.JSONSimple.Serialize(new MenuRegistrationRequest[] { newRequest }), Encoding.UTF8, "application/json");

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var result = await client.PostAsync(apiPath, content).ConfigureAwait(false);

            if (!result.IsSuccessStatusCode)
            {
                var responseContent = await result.Content.ReadAsStringAsync().ConfigureAwait(false);

                NLogger.Instance().Error($"Menu registration error: {responseContent}");
            }
            else
            {
                NLogger.Instance().Info($"Menu registration completed");
            }
        }
コード例 #2
0
 public static void RegisterToMenuService(SampleAppSettings appSettings, MenuRegistrationRequest newRequest)
 {
     Inner_RegisterToMenuService(appSettings, newRequest).GetAwaiter().GetResult();
 }