Skip to content

Commit

Permalink
Adding custom ddr prop support (#20)
Browse files Browse the repository at this point in the history
* Needed to expose custom DDR support, and set default property for MSFT telemetry

* fixed item wont collapse bug

* updating file ver
  • Loading branch information
1RedOne authored May 23, 2019
1 parent 5cf7b74 commit ddabb40
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 22 deletions.
6 changes: 3 additions & 3 deletions ClientFaux/ClientFaux.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>4</ApplicationRevision>
<ApplicationRevision>5</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand All @@ -39,6 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -178,7 +179,6 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
<PostBuildEvent>rem robocopy C:\git\ClientFaux\ClientFaux\bin\Debug \\DC2016\Debug &amp; exit 0</PostBuildEvent>
</PropertyGroup>
</Project>
5 changes: 3 additions & 2 deletions ClientFaux/FauxDeployCMAgent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Microsoft.ConfigurationManagement.Messaging.Messages.Server;
using System.IO;
using CERTENROLLLib;
using System.Collections.ObjectModel;

namespace CMFaux
{
Expand Down Expand Up @@ -181,14 +182,14 @@ public static void SendDiscovery(string CMServerName, string ClientName, string
hinvMessage.SendMessage(Sender);
};
}
public static void SendCustomDiscovery(string CMServerName, string ClientName, string SiteCode, string FilePath, List<CustomClientRecord> customClientRecords)
public static void SendCustomDiscovery(string CMServerName, string ClientName, string SiteCode, string FilePath, ObservableCollection<CustomClientRecord> customClientRecords)
{
string ddmLocal = FilePath + "\\DDRS\\" + ClientName;
string CMddmInbox = "\\\\" + CMServerName + "\\SMS_" + SiteCode + "\\inboxes\\ddm.box\\" + ClientName + ".DDR";

DiscoveryDataRecordFile ddrF = new DiscoveryDataRecordFile("ClientFaux");
ddrF.SiteCode = SiteCode;
ddrF.Architecture = "System";
ddrF.Architecture = "System";
ddrF.AddStringProperty("Name", DdmDiscoveryFlags.Key, 32, ClientName);
ddrF.AddStringProperty("Netbios Name", DdmDiscoveryFlags.Name, 16, ClientName);

Expand Down
57 changes: 55 additions & 2 deletions ClientFaux/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
<Button MinHeight="40" Background="#FF001741" Foreground="#FFF2EAEA" Content="✈ Ready..." Name="ReadyButton" BorderBrush="#FF001741" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Click="ReadyButton_Click" Width="119" />
<Button MinHeight="40" Background="#FF001741" Foreground="#FFF2EAEA" Content="📜 Certificates" Name="Certificates" BorderBrush="#FF001741" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Click="Certificates_Click" Width="119"/>
<Button MinHeight="40" Background="#FF001741" Foreground="#FFF2EAEA" Content="📝 Device Naming" Name="DeviceNaming" BorderBrush="#FF001741" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Click="DeviceNaming_Click"/>
<Button MinHeight="40" Background="#FF001741" Foreground="#FFF2EAEA" Content="📄 Inventory" Name="Inventory" BorderBrush="#FF001741" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Click="Inventory_Click" Width="119"/>
<Button MinHeight="40" Background="#FF001741" Foreground="#FFF2EAEA" Content="🌐 Configure CM" Name="SCCMSettings" BorderBrush="#FF001741" HorizontalAlignment="Left" HorizontalContentAlignment="Left" Click="SCCMSettings_Click" />
</StackPanel>
</Expander>
<TabControl Name="TabControl" BorderBrush="White" >
<TabControl Name="TabControl" BorderBrush="White">
<TabControl.ItemContainerStyle>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Visibility" Value="Collapsed"/>
Expand All @@ -41,7 +42,7 @@
<Label Name="ClientCount" FontSize="24">Device Count</Label>
<Label Name="Counter" FontSize="24" Content="{Binding IdCounter}"/>
<Expander Name="DeviceExpander" >
<ContentControl HorizontalAlignment="Left" Margin="10,0,0,0" MaxWidth="700">
<ContentControl HorizontalAlignment="Left" Margin="10,0,0,0" MaxWidth="700">
<DataGrid Name="dgDevices" AutoGenerateColumns="False" MaxHeight="500">
<DataGrid.Columns>
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"/>
Expand All @@ -54,6 +55,11 @@
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.ItemContainerStyle>
<Style TargetType="DataGridRow">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="OnMouseDown"/>
</Style>
</DataGrid.ItemContainerStyle>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DockPanel Background="GhostWhite">
Expand Down Expand Up @@ -117,6 +123,53 @@
</StackPanel>
</Grid>
</TabItem>
<TabItem Name="InventoryPanel">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="400*" />
<ColumnDefinition Width="400*" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0" Margin="10" HorizontalAlignment="Left">
<Label FontFamily="Calibri" FontSize="22px">Custom Inventory Settings</Label>
<TextBlock TextWrapping="WrapWithOverflow">ClientFaux can report many types of custom inventory.</TextBlock>
<Label FontSize="20">Discovery Custom Properties</Label>
<Label>PropertyName</Label>
<TextBox ToolTip="The three letter acronym of your CM Primary Site, something like [F0X]." Name="NewDDRProp" HorizontalAlignment="Left" MaxWidth="180px" Margin="0,0,20,0" MinWidth="120px">MyCustomProp</TextBox>
<Label>PropertyValue</Label>
<TextBox ToolTip="The starting digit when making multiple clients, something like [10]." Name="NewDDRValue" HorizontalAlignment="Left" Margin="0,0,10,0" MinWidth="120px">MyCustomValue</TextBox>
<Button Content="Save" Margin="0,10,10,10" Width="80px" HorizontalAlignment="Left" Click="SaveButton_Click"></Button>
<DataGrid Name="dgInventory" AutoGenerateColumns="False" MaxHeight="500" MaxWidth="400" HorizontalAlignment="Left">
<DataGrid.Columns>
<DataGridTextColumn Header="Property" Binding="{Binding RecordName}" IsReadOnly="True"/>
<DataGridTextColumn Header="Value" Binding="{Binding RecordValue}" IsReadOnly="True" />
</DataGrid.Columns>
<!--<DataGrid.RowDetailsTemplate>
<DataTemplate>
<DockPanel Background="GhostWhite">
<Image DockPanel.Dock="Left" Source="{Binding ImageSource}" Height="64" Margin="10" />
<Grid Margin="0,10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock Text="Name: " FontWeight="Bold" Grid.Row="1" />
<TextBlock Text="{Binding Name}" Grid.Column="1" Grid.Row="1" />
<TextBlock Text="Client Status: " FontWeight="Bold" Grid.Row="2" />
<TextBlock Text="{Binding Status}" Grid.Column="1" Grid.Row="2" />
<ProgressBar Grid.Column="1" Minimum="0" Maximum="100" Value="{Binding ProcessProgress}" MaxWidth="150px" Height="18" FlowDirection="LeftToRight"/>
</Grid>
</DockPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>-->
</DataGrid>
</StackPanel>
</Grid>
</TabItem>
<TabItem Name="SettingsConfigMgr">
<Grid>
<Grid.ColumnDefinitions>
Expand Down
50 changes: 37 additions & 13 deletions ClientFaux/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ namespace CMFaux

// to do : fix discovery
public partial class MainWindow : Window, INotifyPropertyChanged
{
private readonly BackgroundWorker worker = new BackgroundWorker();
{
public string Password { get; private set; }
public string BaseName { get; private set; }
public string CMServer { get; private set; }
Expand Down Expand Up @@ -54,6 +53,16 @@ public int DeviceCounter
}
}
}

internal ObservableCollection<Device> Devices { get => devices; set => devices = value; }
private ObservableCollection<Device> devices = new ObservableCollection<Device>();

internal ObservableCollection<CustomClientRecord> CustomClientRecords { get => customClientRecords; set => customClientRecords = value; }
private ObservableCollection<CustomClientRecord> customClientRecords = new ObservableCollection<CustomClientRecord> {
new CustomClientRecord(){ RecordName="ClientKind", RecordValue="FakeClient" }
};

private static object _syncLock = new object();

public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string name)
Expand All @@ -64,15 +73,6 @@ protected virtual void OnPropertyChanged(string name)
handler(this, new PropertyChangedEventArgs(name));
}
}
internal ObservableCollection<Device> Devices { get => devices; set => devices = value; }

private ObservableCollection<Device> devices = new ObservableCollection<Device>();
private static object _syncLock = new object();

public List<CustomClientRecord> CustomClientRecords = new List<CustomClientRecord> {
new CustomClientRecord(){ RecordName="Property1", RecordValue="Value1" },
new CustomClientRecord(){ RecordName="Property2", RecordValue="Value2" }
};

public MainWindow()
{
Expand All @@ -88,7 +88,9 @@ public MainWindow()
ExportPath = FilePath.Text;
maxThreads = int.Parse(MaximumThreads.Text);
dgDevices.ItemsSource = Devices;
dgInventory.ItemsSource = customClientRecords;
BindingOperations.EnableCollectionSynchronization(Devices, _syncLock);
BindingOperations.EnableCollectionSynchronization(CustomClientRecords, _syncLock);
Counter.SetBinding(ContentProperty, new Binding("IdCounter"));
DataContext = this;
DeviceCounter = 0;
Expand Down Expand Up @@ -191,7 +193,7 @@ private async void CreateClientsButton_Click(object sender, RoutedEventArgs e)
{
Parallel.ForEach(DeviceList, new ParallelOptions { MaxDegreeOfParallelism = maxThreads}, device =>
{
Device ThisDevice = new Device() { Name = device, Status = "CertCreated", ImageSource = "Images\\step01.png", ProcessProgress = 10 };
Device ThisDevice = new Device() { Name = device, Status = "Starting...", ImageSource = "Images\\step01.png", ProcessProgress = 10 };
Devices.Add(ThisDevice);
int thisIndex = devices.IndexOf(ThisDevice);
RegisterClient(thisIndex);
Expand Down Expand Up @@ -253,11 +255,16 @@ private void DeviceNaming_Click(object sender, RoutedEventArgs e)
TabControl.SelectedIndex = 2;
}

private void SCCMSettings_Click(object sender, RoutedEventArgs e)
private void Inventory_Click (object sender, RoutedEventArgs e)
{
TabControl.SelectedIndex = 3;
}

private void SCCMSettings_Click(object sender, RoutedEventArgs e)
{
TabControl.SelectedIndex = 4;
}

private void ReadyButton_Click(object sender, RoutedEventArgs e)
{
TabControl.SelectedIndex = 0;
Expand Down Expand Up @@ -315,5 +322,22 @@ private void MaximumThreads_TextChanged(object sender, TextChangedEventArgs e)
{
maxThreads = int.Parse(MaximumThreads.Text);
}

private void SaveButton_Click(object sender, RoutedEventArgs e)
{
CustomClientRecord newRecord = new CustomClientRecord() { RecordName = NewDDRProp.Text, RecordValue = NewDDRValue.Text };
CustomClientRecords.Add(newRecord);
NewDDRValue.Text = null;
NewDDRProp.Text = null;
}

private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
DataGridRow row = sender as DataGridRow;
if (row != null)
{
row.DetailsVisibility = row.IsSelected ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible;
}
}
}
}
4 changes: 2 additions & 2 deletions ClientFaux/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]

0 comments on commit ddabb40

Please sign in to comment.