Exemplo n.º 1
0
        public void AddNewTranslationSetting(listcabackuptranslation settings)
        {
            TableOperation insertOperation = TableOperation.Insert(settings);

            tabletranslation.Execute(insertOperation);
        }
Exemplo n.º 2
0
        public void RemoveTranslationSetting(listcabackuptranslation settings)
        {
            TableOperation deleteOperation = TableOperation.Delete(settings);

            tabletranslation.Execute(deleteOperation);
        }
Exemplo n.º 3
0
        public void UpdateConfigSettings()
        {
            WebClient client = new WebClient();

            #region Update translation settings
            Stream streamsettings = client.OpenRead("https://raw.githubusercontent.com/Lagler-Gruener/Sol-CABackupDeploy/main/StorageAccount/configuration/catranslation.csv");
            int    i = 0;
            using (var reader = new StreamReader(streamsettings))
            {
                try
                {
                    while (!reader.EndOfStream)
                    {
                        var line = reader.ReadLine();
                        if (i > 0)
                        {
                            var values = line.Split(',');

                            listcabackuptranslation translation = new listcabackuptranslation();
                            translation.PartitionKey = values[3] + ":" + values[7];
                            translation.RowKey       = values[1];
                            translation.Function     = values[3];
                            translation.Section      = values[5];
                            translation.Setting      = values[7];
                            translation.Translation  = values[9];

                            TableOperation querytranslation = TableOperation.InsertOrReplace(translation);
                            tabletranslation.Execute(querytranslation);
                        }
                        i++;
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception(ex.Message);
                }
            }

            #endregion

            #region Update validation settingsto default if not set
            TableQuery <listsettingsrestorevalidation> query;

            query = new TableQuery <listsettingsrestorevalidation>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "config"),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, "overridepolicyvalidate")));


            var queryresult = tableconfiguration.ExecuteQuery(query);

            if (queryresult.Count <listsettingsrestorevalidation>() == 0)
            {
                listsettingsrestorevalidation validationsetting = new listsettingsrestorevalidation();
                validationsetting.PartitionKey = "config";
                validationsetting.RowKey       = "overridepolicyvalidate";
                validationsetting.email        = "";
                validationsetting.state        = false;

                TableOperation insertvalidationsetting = TableOperation.InsertOrReplace(validationsetting);
                tableconfiguration.Execute(insertvalidationsetting);
            }

            #endregion

            #region Update version number
            string newversion    = "0.0";
            Stream streamversion = client.OpenRead("https://raw.githubusercontent.com/Lagler-Gruener/Sol-CABackupDeploy/main/StorageAccount/configuration/version");
            using (var reader = new StreamReader(streamversion))
            {
                while (!reader.EndOfStream)
                {
                    newversion = reader.ReadLine();
                }
            }

            listsettingsimportconfigurations entity = new listsettingsimportconfigurations();
            entity.PartitionKey = "config";
            entity.RowKey       = "configversion";
            entity.version      = newversion;

            TableOperation update = TableOperation.InsertOrReplace(entity);
            tableconfiguration.Execute(update);
            #endregion
        }