Exemple #1
0
        private async Task LoginKeyReloadAsync()
        {
            try
            {
                LoginKeyItems = new ObservableCollection <loginKey>();
                string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string action   = @"/server/v2/getLoginKeyList";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                SoaCall soaCall  = new SoaCall();
                var     task     = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
                string  response = await task;

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                getLoginKeyList getLoginKeyList = JsonConvert.DeserializeObject <getLoginKeyList>(response, options);
                if (getLoginKeyList.getLoginKeyListResponse.returnCode.Equals("0"))
                {
                    LoginKeyItems.Clear();
                    foreach (var a in getLoginKeyList.getLoginKeyListResponse.loginKeyList)
                    {
                        LoginKeyItems.Add(new loginKey
                        {
                            fingerprint = a.fingerprint,
                            keyName     = a.keyName,
                            createDate  = a.createDate,
                        });
                    }
                }

                string loginKeyName = dataManager.GetValue(DataManager.Category.LoginKey, DataManager.Key.Name);

                foreach (var key in LoginKeyItems)
                {
                    if (key.keyName.Equals(loginKeyName))
                    {
                        SelectedLoginKey = key;
                    }
                }
            }
            catch (Exception ex)
            {
                var menuItem = mConfigListDesignModel.Items.Single(x => x.Number == "C2");
                menuItem.ProfilePictureRGB = "5c5c5c";
                await IoC.UI.ShowMessage(new MessageBoxDialogViewModel
                {
                    Title   = "ERROR",
                    Message = ex.Message,
                    OkText  = "OK"
                });
            }
        }
Exemple #2
0
        private void CheckLoginKey()
        {
            AppendVerifyLog("*. LoginKey");
            try
            {
                string endPoint         = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
                string accessKey        = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.AccessKey);
                string secretKey        = logClientConfig.GetValue(LogClient.Category.Api, LogClient.Key.SecretKey);
                string loginKey         = dataManager.GetValue(DataManager.Category.LoginKey, DataManager.Key.Name);
                bool   isExistsLoginKey = false;

                string action = @"/server/v2/getLoginKeyList";
                List <KeyValuePair <string, string> > parameters = new List <KeyValuePair <string, string> >();
                parameters.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                SoaCall soaCall  = new SoaCall();
                var     response = AsyncHelpers.RunSync <string>(() => soaCall.WebApiCall(endPoint, RequestType.POST, action, parameters, accessKey, secretKey));

                JsonSerializerSettings options = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                getLoginKeyList getLoginKeyList = JsonConvert.DeserializeObject <getLoginKeyList>(response, options);

                if (getLoginKeyList.getLoginKeyListResponse.returnCode.Equals("0"))
                {
                    foreach (var a in getLoginKeyList.getLoginKeyListResponse.loginKeyList)
                    {
                        if (loginKey.Equals(a.keyName, StringComparison.OrdinalIgnoreCase))
                        {
                            isExistsLoginKey = true;
                            break;
                        }
                    }
                    AppendVerifyLog($"   LoginKey : {loginKey}");

                    if (!isExistsLoginKey)
                    {
                        throw new Exception("   LoginKey does not exists in Managemnet Console!");
                    }
                }

                AppendVerifyLog($"   LoginKey Check Result : Success");
                {
                    var menuItem = mConfigListDesignModel.Items.Single(x => x.Number == "C2");
                    menuItem.ProfilePictureRGB = "3483eb";
                }
            }
            catch (Exception ex)
            {
                var menuItem = mConfigListDesignModel.Items.Single(x => x.Number == "C2");
                menuItem.ProfilePictureRGB = "5c5c5c";
                AppendVerifyLog(ex.Message);
                AppendVerifyLog("   LoginKey Help Message...");
                AppendVerifyLog("   -----------------------------------------------");
                AppendVerifyLog("   1. Select and save the login key saved in AD Tool > Config > C2 or create a new login key.");
                AppendVerifyLog("   -----------------------------------------------");
                throw new Exception($"C2 Error : {ex.Message}");
            }
        }