Exemplo n.º 1
0
        public listsettingsimportconfigurations GetConfigurationVersion()
        {
            listsettingsimportconfigurations validationsetting = new listsettingsimportconfigurations();

            validationsetting.updateavailable = false;


            TableQuery <listsettingsimportconfigurations> query;

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


            var queryresult = tableconfiguration.ExecuteQuery(query);

            string availableversion = "";
            string currentversion   = "";

            foreach (var item in queryresult)
            {
                currentversion            = item.version;
                validationsetting.version = item.version;
            }

            WebClient client = new WebClient();
            Stream    stream = client.OpenRead("https://raw.githubusercontent.com/Lagler-Gruener/Sol-CABackupDeploy/main/StorageAccount/configuration/version");

            using (var reader = new StreamReader(stream))
            {
                while (!reader.EndOfStream)
                {
                    availableversion             = reader.ReadLine();
                    validationsetting.newversion = reader.ReadLine();
                }
            }

            if (availableversion != currentversion)
            {
                validationsetting.updateavailable = true;
            }

            return(validationsetting);
        }
Exemplo n.º 2
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
        }