Exemplo n.º 1
0
        private async void buttonBackupDownload_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonBackupDownload Clicked");
            ConfigSaveAllItem();
            string json = string.Empty;

            foreach (DataGridViewRow item in dgvInternalStorage.Rows)
            {
                if (bool.Parse(item.Cells[0].Value.ToString()))
                {
                    var       postParams = new List <KeyValuePair <string, string> >();
                    AsyncCall asyncCall  = new AsyncCall();
                    postParams.Add(new KeyValuePair <string, string>("cloudDBInstanceNo", config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo)));
                    postParams.Add(new KeyValuePair <string, string>("fileName", item.Cells[1].EditedFormattedValue.ToString()));
                    postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                    string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                    endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                    Task <string> result = asyncCall.WebApiCall(
                        endpointUrl, GetPostType.POST, @"/clouddb/v2/uploadDmsFile", postParams);
                    json = await result;
                    nlog.Warn(json);
                }
            }
            ;

            ObjectStorageFileList();
            InternalStorageFileList();
            nlog.Warn("buttonBackupDownload Completed");
        }
Exemplo n.º 2
0
        private async Task <string> getBackupListAsync()
        {
            nlog.Warn("getBackupListAsync Started");

            ConfigSaveAllItem();
            string json = string.Empty;

            try
            {
                var       postParams = new List <KeyValuePair <string, string> >();
                AsyncCall asyncCall  = new AsyncCall();
                postParams.Add(new KeyValuePair <string, string>("cloudDBInstanceNo", config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo)));
                postParams.Add(new KeyValuePair <string, string>("databaseName", ""));
                postParams.Add(new KeyValuePair <string, string>("type", ""));
                postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                Task <string> result = asyncCall.WebApiCall(
                    endpointUrl
                    , GetPostType.POST
                    , @"/clouddb/v2/getBackupList"
                    , postParams);

                json = await result;
                nlog.Warn(json);
            }
            catch (Exception e)
            {
                nlog.Error(string.Format("{0}, {1}", e.Message, e.StackTrace));
            }
            StatusUpdate(Status.Completed);
            nlog.Warn("getBackupListAsync Completed");
            return(json);
        }
        private async Task <string> GetZoneListAsync()
        {
            nlog.Warn("GetZoneListAsync Started");

            string json = string.Empty;

            try
            {
                var       postParams = new List <KeyValuePair <string, string> >();
                AsyncCall asyncCall  = new AsyncCall();

                postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                postParams.Add(new KeyValuePair <string, string>("regionNo", "1"));
                string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                Task <string> result = asyncCall.WebApiCall(
                    endpointUrl
                    , GetPostType.POST
                    , "/server/v2/getZoneList"
                    , postParams);

                json = await result;
                nlog.Warn(json);
            }
            catch (Exception e)
            {
                nlog.Error(string.Format("{0}, {1}", e.Message, e.StackTrace));
            }
            return(json);
        }
Exemplo n.º 4
0
        private async void buttonSaveDmsInfo_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonSaveDmsInfo_Click Started");
            StatusUpdate(Status.Working);
            ConfigSaveAllItem();
            var       postParams     = new List <KeyValuePair <string, string> >();
            AsyncCall asyncCall      = new AsyncCall();
            string    objectEndpoint = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";

            objectEndpoint = objectEndpoint + config.GetEnumValue(Category.Config, Key.ObjectEndPoint);

            postParams.Add(new KeyValuePair <string, string>("objectStorageAccessKey", config.GetEnumValue(Category.Config, Key.ObjectAccessKey)));
            postParams.Add(new KeyValuePair <string, string>("objectStorageSecretKey", config.GetEnumValue(Category.Config, Key.ObjectSecretKey)));
            postParams.Add(new KeyValuePair <string, string>("endpoint", objectEndpoint));
            postParams.Add(new KeyValuePair <string, string>("bucketName", config.GetEnumValue(Category.Config, Key.ObjectBucket)));
            postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));

            string apiEndpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";

            apiEndpointUrl = apiEndpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

            Task <string> result = asyncCall.WebApiCall(
                apiEndpointUrl
                , GetPostType.POST
                , @"/clouddb/v2/setObjectStorageInfo"
                , postParams);

            string json = await result;

            nlog.Warn(json);
            MessageBox.Show(json);
            StatusUpdate(Status.Completed);
            nlog.Warn("buttonSaveDmsInfo_Click Completed");
        }
        private async Task <string> getObjectStorageBackupListAync(string objectFolder)
        {
            nlog.Warn("BackupStorageFileListAync Started");
            workBackupStorage = true;
            ConfigSaveAllItem();
            string json = string.Empty;

            try
            {
                var       postParams = new List <KeyValuePair <string, string> >();
                AsyncCall asyncCall  = new AsyncCall();
                postParams.Add(new KeyValuePair <string, string>("cloudDBInstanceNo", config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo)));
                postParams.Add(new KeyValuePair <string, string>("folderName", objectFolder));
                postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                Task <string> result = asyncCall.WebApiCall(
                    endpointUrl
                    , GetPostType.POST
                    , @"/clouddb/v2/getObjectStorageBackupList"
                    , postParams);

                json = await result;
                nlog.Warn(json);
            }
            catch (Exception ex)
            {
                nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
            }
            finally
            {
                workBackupStorage = false;
            }

            nlog.Warn("BackupStorageFileListAync Completed");
            return(json);
        }
Exemplo n.º 6
0
        private async void buttonApiGatewayTest_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonApiGatewayTest_Click Started");
            StatusUpdate(Status.Working);
            try
            {
                if (textApiUrl.Text.ToUpper().StartsWith(@"HTTP://"))
                {
                    textApiUrl.Text = textApiUrl.Text.Substring(7, textApiUrl.Text.Length - 7);
                }

                if (textApiUrl.Text.ToUpper().StartsWith(@"HTTPS://"))
                {
                    textApiUrl.Text = textApiUrl.Text.Substring(8, textApiUrl.Text.Length - 8);
                }
            }
            catch (Exception) { }

            ConfigSaveAllItem();
            var       postParams  = new List <KeyValuePair <string, string> >();
            AsyncCall asyncCall   = new AsyncCall();
            string    endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";

            endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

            Task <string> result = asyncCall.WebApiCall(
                endpointUrl
                , GetPostType.GET
                , @"/clouddb/v2/" + config.GetEnumValue(Category.Config, Key.DefaultTestApi) + "?dbKindCode=MSSQL&responseFormatType=json"
                , postParams);

            string json = await result;

            nlog.Warn(json);
            MessageBox.Show(json);
            StatusUpdate(Status.Completed);
            nlog.Warn("buttonApiGatewayTest_Click Completed");
        }
        private async void buttonRestoreLog_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonLogRecovery Started");
            StatusUpdate(Status.Working);
            try
            {
                if (!CheckBoxCountCheck(1))
                {
                    MessageBox.Show("please selecet one file");
                    return;
                }
                ConfigSaveAllItem();
                string json        = string.Empty;
                string checkStatus = string.Empty;
                checkStatus = checkRecovery.CheckState == CheckState.Checked ? "true" : "false";
                foreach (DataGridViewRow item in dgvBackupStorage.Rows)
                {
                    if (bool.Parse(item.Cells[0].Value.ToString()))
                    {
                        var       postParams = new List <KeyValuePair <string, string> >();
                        AsyncCall asyncCall  = new AsyncCall();

                        string recoveryFilename = string.Empty;
                        if (config.GetEnumValue(Category.Upload, Key.InternalFolder).Trim().Length > 0)
                        {
                            recoveryFilename = config.GetEnumValue(Category.Upload, Key.InternalFolder).Trim() + @"/" + item.Cells[1].EditedFormattedValue.ToString();
                        }
                        else
                        {
                            recoveryFilename = item.Cells[1].EditedFormattedValue.ToString();
                        }

                        long recoveryFileSize = Convert.ToInt64(item.Cells[2].EditedFormattedValue.ToString());
                        if (await IsMatchFileSizeInObjectStorage(recoveryFilename, recoveryFileSize))
                        {
                            postParams.Add(new KeyValuePair <string, string>("cloudDBInstanceNo", config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo)));
                            postParams.Add(new KeyValuePair <string, string>("fileName", recoveryFilename));
                            postParams.Add(new KeyValuePair <string, string>("isRecovery", checkStatus));
                            postParams.Add(new KeyValuePair <string, string>("newDatabaseName", config.GetEnumValue(Category.Upload, Key.NewDatabaseName)));
                            postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                            if (textStopAtTime.Text != "0000-00-00T00:00:00+0900")
                            {
                                postParams.Add(new KeyValuePair <string, string>("stopTime", textStopAtTime.Text));
                            }
                            string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                            endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                            Task <string> result = asyncCall.WebApiCall(
                                endpointUrl
                                , GetPostType.POST
                                , @"/clouddb/v2/restoreDmsTransactionLog"
                                , postParams);

                            json = await result;
                            nlog.Warn(json);
                            restoreDmsTransactionLog restoreDmsTransactionLog = JsonConvert.DeserializeObject <restoreDmsTransactionLog>(json);
                            ApiResponseRecord(
                                config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo),
                                config.GetEnumValue(Category.Upload, Key.NewDatabaseName),
                                item.Cells[1].EditedFormattedValue.ToString()
                                , new Response
                            {
                                requestNo         = restoreDmsTransactionLog.restoreDmsTransactionLogResponse.requestNo,
                                requestReturnCode = restoreDmsTransactionLog.restoreDmsTransactionLogResponse.returnCode,
                                returnCode        = "",
                                returnCodeName    = ""
                            });
                        }
                    }
                }
                BackupStorageFileList();
            }
            catch (Exception ex)
            {
                nlog.Error(string.Format("{0},{1}", ex.Message, ex.StackTrace));
            }
            nlog.Warn("buttonLogRecovery Completed");
        }
        private async void updateRestoreStatus()
        {
            ConfigSaveAllItem();
            apiResponseTemp.Clear();
            string json = string.Empty;

            foreach (var a in apiResponses)
            {
                try
                {
                    var       postParams = new List <KeyValuePair <string, string> >();
                    AsyncCall asyncCall  = new AsyncCall();
                    postParams.Add(new KeyValuePair <string, string>("requestNo", a.Value.requestNo));
                    postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                    string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                    endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                    Task <string> result = asyncCall.WebApiCall(
                        endpointUrl
                        , GetPostType.POST
                        , @"/clouddb/v2/getDmsOperation"
                        , postParams);

                    json = await result;
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Ignore,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };
                    getDmsOperation getDmsOperation = JsonConvert.DeserializeObject <getDmsOperation>(json, settings);

                    string codeName = string.Empty;
                    try
                    {
                        codeName = getDmsOperation.getDmsOperationResponse.status.codeName;
                    }
                    catch { }
                    if (codeName == string.Empty)
                    {
                        codeName = "UNKNOWN ERROR!";
                    }

                    apiResponseTemp.Add(a.Key, new Response
                    {
                        requestNo         = a.Value.requestNo,
                        requestReturnCode = a.Value.requestReturnCode,
                        returnCode        = getDmsOperation.getDmsOperationResponse.returnCode,
                        returnCodeName    = codeName
                    });
                    nlog.Warn(json);
                }
                catch (Exception ex)
                {
                    nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
                }
            }

            try
            {
                foreach (var temp in apiResponseTemp)
                {
                    apiResponses[temp.Key] = temp.Value;
                }
                apiResponseTemp.Clear();
            }
            catch (Exception ex)
            {
                nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
            }
        }
        private async void buttonRestoreDatabase_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonDatabaseRecovery Started");
            StatusUpdate(Status.Working);
            if (!CheckBoxCountCheck(1))
            {
                MessageBox.Show("please selecet one file");
                return;
            }

            ConfigSaveAllItem();
            string json        = string.Empty;
            string checkStatus = string.Empty;

            checkStatus = checkRecovery.CheckState == CheckState.Checked ? "true" : "false";

            try

            {
                foreach (DataGridViewRow item in dgvBackupStorage.Rows)
                {
                    if (bool.Parse(item.Cells[0].Value.ToString()))
                    {
                        var       postParams       = new List <KeyValuePair <string, string> >();
                        AsyncCall asyncCall        = new AsyncCall();
                        string    recoveryFilename = string.Empty;

                        if (textInternalFolder.Text.Trim().Length > 0)
                        {
                            recoveryFilename = textInternalFolder.Text.Trim() + @"/" + item.Cells[1].EditedFormattedValue.ToString();
                        }
                        else
                        {
                            recoveryFilename = item.Cells[1].EditedFormattedValue.ToString();
                        }

                        long recoveryFileSize = Convert.ToInt64(item.Cells[2].EditedFormattedValue.ToString());
                        if (await IsMatchFileSizeInObjectStorage(recoveryFilename, recoveryFileSize))
                        {
                            postParams.Add(new KeyValuePair <string, string>("cloudDBInstanceNo", config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo)));
                            postParams.Add(new KeyValuePair <string, string>("fileName", recoveryFilename));
                            postParams.Add(new KeyValuePair <string, string>("isRecovery", checkStatus));
                            postParams.Add(new KeyValuePair <string, string>("newDatabaseName", config.GetEnumValue(Category.Upload, Key.NewDatabaseName)));
                            postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));
                            string endpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";
                            endpointUrl = endpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

                            Task <string> result = asyncCall.WebApiCall(
                                endpointUrl
                                , GetPostType.POST
                                , @"/clouddb/v2/restoreDmsDatabase"
                                , postParams);

                            json = await result;
                            nlog.Warn(json);

                            var settings = new JsonSerializerSettings
                            {
                                NullValueHandling     = NullValueHandling.Ignore,
                                MissingMemberHandling = MissingMemberHandling.Ignore
                            };

                            if (json.Contains("responseError"))
                            {
                                var    responseError = JsonConvert.DeserializeObject <ResponseError>(json, settings);
                                string errorMessage  = $@"returnMessage : {responseError.responseError.returnMessage}, returnCode : {responseError.responseError.returnCode} {Environment.NewLine}Check the internal storage folder name.";
                                throw new Exception(errorMessage);
                            }
                            else
                            {
                                restoreDmsDatabase restoreDmsDatabase = JsonConvert.DeserializeObject <restoreDmsDatabase>(json);
                                ApiResponseRecord(
                                    config.GetEnumValue(Category.Config, Key.CloudDbInstanceNo),
                                    config.GetEnumValue(Category.Upload, Key.NewDatabaseName),
                                    item.Cells[1].EditedFormattedValue.ToString()
                                    , new Response
                                {
                                    requestNo         = restoreDmsDatabase.restoreDmsDatabaseResponse.requestNo,
                                    requestReturnCode = restoreDmsDatabase.restoreDmsDatabaseResponse.returnCode,
                                    returnCode        = "",
                                    returnCodeName    = ""
                                });
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                nlog.Error(string.Format("{0}, {1}", ex.Message, ex.StackTrace));
                MessageBox.Show(ex.Message);
            }

            BackupStorageFileList();
            nlog.Warn("buttonDatabaseRecovery Completed");
        }
        private async void buttonSaveDmsInfo_Click(object sender, EventArgs e)
        {
            nlog.Warn("buttonSaveDmsInfo_Click Started");

            if (!TargetObjectStorageInfoTested)
            {
                MessageBox.Show("Save after performing the Target Object Storage Info Connection test.");
                return;
            }
            if (!ApigatewayInfoTested)
            {
                MessageBox.Show("Save after performing the ApiGateway Info Connection test.");
                return;
            }
            if (!DatabaseInfoTested)
            {
                MessageBox.Show("Save after performing the Database Info Connection test.");
                return;
            }


            StatusUpdate(Status.Working);
            ConfigSaveAllItem();
            var       postParams     = new List <KeyValuePair <string, string> >();
            AsyncCall asyncCall      = new AsyncCall();
            string    objectEndpoint = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";

            objectEndpoint = objectEndpoint + config.GetEnumValue(Category.Config, Key.ObjectEndPoint);

            postParams.Add(new KeyValuePair <string, string>("objectStorageAccessKey", config.GetEnumValue(Category.Config, Key.ObjectAccessKey)));
            postParams.Add(new KeyValuePair <string, string>("objectStorageSecretKey", config.GetEnumValue(Category.Config, Key.ObjectSecretKey)));
            postParams.Add(new KeyValuePair <string, string>("endpoint", objectEndpoint));
            postParams.Add(new KeyValuePair <string, string>("bucketName", config.GetEnumValue(Category.Config, Key.ObjectBucket)));
            postParams.Add(new KeyValuePair <string, string>("responseFormatType", "json"));

            string apiEndpointUrl = config.GetEnumValue(Category.Config, Key.UseSSLApiGateway) == "1" ? @"https://" : @"http://";

            apiEndpointUrl = apiEndpointUrl + config.GetEnumValue(Category.Config, Key.ApiUrl);

            Task <string> result;



            if (Platform.Equals("CP"))
            {
                result = asyncCall.WebApiCall(
                    apiEndpointUrl
                    , GetPostType.POST
                    , @"/clouddb/v2/setObjectStorageInfo"
                    , postParams);
            }
            else
            {
                result = asyncCall.WebApiCall(
                    apiEndpointUrl
                    , GetPostType.POST
                    , @"/vmssql/v2/setDmsObjectStorageInfo"
                    , postParams);
            }

            string json = await result;

            nlog.Warn(json);

            if (json.Contains("success"))
            {
                MessageBox.Show("DMT setting information was saved on the server.");
            }

            StatusUpdate(Status.Completed);
            nlog.Warn("buttonSaveDmsInfo_Click Completed");
        }