Skip to content

Commit 5ac98a1

Browse files
committed
Add project files.
1 parent 7f933b1 commit 5ac98a1

File tree

5 files changed

+194
-0
lines changed

5 files changed

+194
-0
lines changed

unlockdb.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.2.32505.173
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "unlockdb", "unlockdb\unlockdb.csproj", "{30DA4AC3-374A-4197-AFF0-214493A90729}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{30DA4AC3-374A-4197-AFF0-214493A90729}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{30DA4AC3-374A-4197-AFF0-214493A90729}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{30DA4AC3-374A-4197-AFF0-214493A90729}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{30DA4AC3-374A-4197-AFF0-214493A90729}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {766DAA71-6812-47C4-84A4-0EFA72E4415F}
24+
EndGlobalSection
25+
EndGlobal

unlockdb/App.config

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
5+
</startup>
6+
</configuration>

unlockdb/Program.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Xml;
4+
5+
class Program
6+
{
7+
static void Main(string[] args)
8+
{
9+
if (args.Length == 0)
10+
{
11+
Console.WriteLine("Please provide the XML file location as a command line argument.");
12+
return;
13+
}
14+
15+
string xmlFilePath = args[0];
16+
string attributeName = "state";
17+
string attributeValue = "eUnlockState_Unlocked";
18+
19+
try
20+
{
21+
// Load the XML file
22+
XmlDocument xmlDoc = new XmlDocument();
23+
xmlDoc.Load(xmlFilePath);
24+
25+
// Get all elements with the specified attribute
26+
XmlNodeList nodes = xmlDoc.DocumentElement.SelectNodes($"//*[@{attributeName}]");
27+
28+
// Track the IDs that have been processed
29+
HashSet<string> processedIds = new HashSet<string>();
30+
31+
// Update the attribute value for each matching element and list the associated id
32+
bool changesMade = false;
33+
34+
foreach (XmlNode node in nodes)
35+
{
36+
if (node.Attributes != null && node.Attributes[attributeName] != null)
37+
{
38+
string currentStateValue = node.Attributes[attributeName].Value;
39+
40+
if (currentStateValue != attributeValue)
41+
{
42+
string idValue = node.Attributes["id"]?.Value;
43+
if (!string.IsNullOrEmpty(idValue))
44+
{
45+
if (!processedIds.Contains(idValue))
46+
{
47+
processedIds.Add(idValue);
48+
49+
Console.WriteLine($"Changing state to '{attributeValue}' for id: {idValue}");
50+
node.Attributes[attributeName].Value = attributeValue;
51+
changesMade = true;
52+
}
53+
}
54+
}
55+
}
56+
}
57+
58+
if (changesMade)
59+
{
60+
// Save the modified XML document
61+
xmlDoc.Save(xmlFilePath);
62+
Console.WriteLine("XML file updated successfully.");
63+
}
64+
else
65+
{
66+
Console.WriteLine("No changes were made to the XML file as there was nothing to change.");
67+
}
68+
}
69+
catch (Exception ex)
70+
{
71+
Console.WriteLine($"An error occurred: {ex.Message}");
72+
}
73+
}
74+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("unlockdb")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("unlockdb")]
13+
[assembly: AssemblyCopyright("Copyright © 2023")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("30da4ac3-374a-4197-aff0-214493a90729")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

unlockdb/unlockdb.csproj

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{30DA4AC3-374A-4197-AFF0-214493A90729}</ProjectGuid>
8+
<OutputType>Exe</OutputType>
9+
<RootNamespace>unlockdb</RootNamespace>
10+
<AssemblyName>unlockdb</AssemblyName>
11+
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Net.Http" />
43+
<Reference Include="System.Xml" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<Compile Include="Program.cs" />
47+
<Compile Include="Properties\AssemblyInfo.cs" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<None Include="App.config" />
51+
</ItemGroup>
52+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
53+
</Project>

0 commit comments

Comments
 (0)