Skip to content

Commit

Permalink
0.10.0.0 - Ready For Use #3
Browse files Browse the repository at this point in the history
Process config part is added
  • Loading branch information
mahdiehsanifar committed Oct 18, 2015
1 parent 804215b commit 09572f7
Show file tree
Hide file tree
Showing 17 changed files with 746 additions and 231 deletions.
9 changes: 6 additions & 3 deletions TfsWitAdminTools/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ private void Application_Startup(object sender, StartupEventArgs e)
DiManager.Current.Register<WIDImportVM, WIDImportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<WIDRenameVM, WIDRenameVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<WIDDestroyVM, WIDDestroyVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoryViewerVM, CategoryViewerVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoryExportVM, CategoryExportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoryImportVM, CategoryImportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoriesViewerVM, CategoriesViewerVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoriesExportVM, CategoriesExportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<CategoriesImportVM, CategoriesImportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<ProcessConfigViewerVM, ProcessConfigViewerVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<ProcessConfigExportVM, ProcessConfigExportVM>(lifeCycle: LifeCycle.Transient);
DiManager.Current.Register<ProcessConfigImportVM, ProcessConfigImportVM>(lifeCycle: LifeCycle.Transient);
}
}
}
8 changes: 8 additions & 0 deletions TfsWitAdminTools/Core/IWitAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ void ExportWorkItemDefenition(ITFManager tfManager, string projectCollectionName

void ImportCategories(ITFManager tfManager, string projectCollectionName, string teamProjectName, string fileName);

string ExportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName);


void ExportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName, string fileName);


void ImportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName, string fileName);

string InvokeCommand(string argument, bool isConfirmRequired = false);

Task<string[]> InvokeCommandWithSplitedResult(string argument, bool isConfirmRequired = false);
Expand Down
10 changes: 10 additions & 0 deletions TfsWitAdminTools/Model/TeamProjectInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,15 @@ public string Categories
SetValue(ref _categories, value);
}
}

private string _processConfig;
public string ProcessConfig
{
get { return _processConfig; }
set
{
SetValue(ref _processConfig, value);
}
}
}
}
20 changes: 20 additions & 0 deletions TfsWitAdminTools/Service/WitAdminService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ public void ImportCategories(ITFManager tfManager, string projectCollectionName,
string argument = string.Format("importcategories /collection:{0}/{1} /p:{2} /f:\"{3}\"", tfManager.TfsAddress, projectCollectionName, teamProjectName, fileName);
InvokeCommand(argument);
}

public string ExportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName)
{
string argument = string.Format("exportprocessconfig /collection:{0}/{1} /p:{2}", tfManager.TfsAddress, projectCollectionName, teamProjectName);
string result = InvokeCommand(argument);

return result;
}

public void ExportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName, string fileName)
{
string argument = string.Format("exportprocessconfig /collection:{0}/{1} /p:{2} /f:\"{3}\"", tfManager.TfsAddress, projectCollectionName, teamProjectName, fileName);
InvokeCommand(argument);
}

public void ImportProcessConfig(ITFManager tfManager, string projectCollectionName, string teamProjectName, string fileName)
{
string argument = string.Format("importprocessconfig /collection:{0}/{1} /p:{2} /f:\"{3}\"", tfManager.TfsAddress, projectCollectionName, teamProjectName, fileName);
InvokeCommand(argument);
}

#endregion

Expand Down
9 changes: 6 additions & 3 deletions TfsWitAdminTools/TfsWitAdminTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@
<DependentUpon>ToolsForm.xaml</DependentUpon>
</Compile>
<Compile Include="UserControls\TextEditorEx.cs" />
<Compile Include="ViewModel\CategoryExportVM.cs" />
<Compile Include="ViewModel\CategoryImportVM.cs" />
<Compile Include="ViewModel\CategoryViewerVM.cs" />
<Compile Include="ViewModel\CategoriesExportVM.cs" />
<Compile Include="ViewModel\CategoriesImportVM.cs" />
<Compile Include="ViewModel\CategoriesViewerVM.cs" />
<Compile Include="ViewModel\DelegateCommand.cs" />
<Compile Include="ViewModel\MainVM.cs" />
<Compile Include="ViewModel\ProcessConfigExportVM.cs" />
<Compile Include="ViewModel\ProcessConfigImportVM.cs" />
<Compile Include="ViewModel\ProcessConfigViewerVM.cs" />
<Compile Include="ViewModel\ToolsChildVM.cs" />
<Compile Include="ViewModel\ToolsVM.cs" />
<Compile Include="ViewModel\ViewModelBase.cs" />
Expand Down
63 changes: 50 additions & 13 deletions TfsWitAdminTools/UserControls/ToolsForm.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*" Name="grwWITypes"/>
<RowDefinition Height="*" MinHeight="230" Name="grwWIDef"/>
<RowDefinition Height="*" MinHeight="250" Name="grwWIDef"/>
</Grid.RowDefinitions>
<Expander Name="expWITypes" Grid.Row="0" IsExpanded="True" Expanded="expWITypes_Expanded" Collapsed="expWITypes_Collapsed">
<TabControl>
Expand All @@ -54,7 +54,7 @@
</TabControl>
</Expander>
<TabControl Grid.Row="1">
<TabItem Header="Work Item XML Defenition">
<TabItem Header="Work Item Defenition">
<TabControl>
<TabItem Header="View" DataContext="{Binding Path=WIDViewer}">
<Grid>
Expand Down Expand Up @@ -102,34 +102,71 @@
</TabControl>
</TabItem>
<TabItem Header="Categories">
<TabControl >
<TabItem Header="View" DataContext="{Binding CategoryViewer}">
<TabControl>
<TabItem Header="View" DataContext="{Binding Path=CategoriesViewer}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Command="{Binding Path=ShowCommand}">Show</Button>
<Button Grid.Row="0" Command="{Binding Path=ShowCommand}" Content="Show"/>
<localUserControl:TextEditorEx x:Name="txtCategories" Grid.Row="1"
DocumentText="{Binding Path=Tools.CurrentTeamProject.Categories}"/>
</Grid>
</TabItem>
<TabItem Header="Export">
<TabItem Header="Export" DataContext="{Binding Path=CategoriesExport}">
<StackPanel>
<Label Content="Path"/>
<TextBox Text="{Binding Path=CategoryExport.Path}"/>
<TextBox Text="{Binding Path=Path}"/>
<Label Content="FileName"/>
<TextBox Text="{Binding Path=CategoryExport.FileName}"/>
<Button Command="{Binding Path=CategoryExport.BrowseCommand}" Content="Browse"/>
<Button Command="{Binding Path=CategoryExport.ExportCommand}" Content="Export"/>
<TextBox Text="{Binding Path=FileName}"/>
<Button Command="{Binding Path=BrowseCommand}" Content="Browse"/>
<CheckBox IsChecked="{Binding IsAllTeamProjects, Mode=TwoWay}" Content="All Team Projects"/>
<Button Command="{Binding Path=ExportCommand}" Content="Export"/>
</StackPanel>
</TabItem>
<TabItem Header="Import">
<TabItem Header="Import" DataContext="{Binding Path=CategoriesImport}">
<StackPanel>
<Label Content="File Name"/>
<TextBox Text="{Binding Path=FileName, UpdateSourceTrigger=PropertyChanged}"/>
<Button Command="{Binding Path=CategoryImport.BrowseCommand}" Content="Browse"/>
<Button Command="{Binding Path=CategoryImport.ImportCommand}" Content="Import"/>
<Button Command="{Binding Path=BrowseCommand}" Content="Browse"/>
<CheckBox IsChecked="{Binding IsAllTeamProjects, Mode=TwoWay}" Content="All Team Projects"/>
<Button Command="{Binding Path=ImportCommand}" Content="Import"/>
</StackPanel>
</TabItem>
</TabControl>
</TabItem>
<TabItem Header="Process Config">
<TabControl>
<TabItem Header="View" DataContext="{Binding Path=ProcessConfigViewer}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Button Grid.Row="0" Command="{Binding Path=ShowCommand}" Content="Show"/>
<localUserControl:TextEditorEx x:Name="txtProcessConfig" Grid.Row="1"
DocumentText="{Binding Path=Tools.CurrentTeamProject.ProcessConfig}"/>
</Grid>
</TabItem>
<TabItem Header="Export" DataContext="{Binding Path=ProcessConfigExport}">
<StackPanel>
<Label Content="Path"/>
<TextBox Text="{Binding Path=Path}"/>
<Label Content="FileName"/>
<TextBox Text="{Binding Path=FileName}"/>
<Button Command="{Binding Path=BrowseCommand}" Content="Browse"/>
<CheckBox IsChecked="{Binding IsAllTeamProjects, Mode=TwoWay}" Content="All Team Projects"/>
<Button Command="{Binding Path=ExportCommand}" Content="Export"/>
</StackPanel>
</TabItem>
<TabItem Header="Import" DataContext="{Binding Path=ProcessConfigImport}">
<StackPanel>
<Label Content="File Name"/>
<TextBox Text="{Binding Path=FileName, UpdateSourceTrigger=PropertyChanged}"/>
<Button Command="{Binding Path=BrowseCommand}" Content="Browse"/>
<CheckBox IsChecked="{Binding IsAllTeamProjects, Mode=TwoWay}" Content="All Team Projects"/>
<Button Command="{Binding Path=ImportCommand}" Content="Import"/>
</StackPanel>
</TabItem>
</TabControl>
Expand Down
3 changes: 2 additions & 1 deletion TfsWitAdminTools/UserControls/ToolsForm.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ public ToolsForm()
InitializeComponent();

txtWIDefenition.Syntax =
txtCategories.Syntax = TextEditorEx.SyntaxNames.XML;
txtCategories.Syntax =
txtProcessConfig.Syntax = TextEditorEx.SyntaxNames.XML;

lsbWITypes.Items.SortDescriptions.Add(new System.ComponentModel.SortDescription("Name", System.ComponentModel.ListSortDirection.Ascending));
}
Expand Down
126 changes: 126 additions & 0 deletions TfsWitAdminTools/ViewModel/CategoriesExportVM.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System.Threading.Tasks;
using TfsWitAdminTools.Cmn;
using TfsWitAdminTools.Core;
using TfsWitAdminTools.Model;

namespace TfsWitAdminTools.ViewModel
{
public class CategoriesExportVM : ToolsChildVM
{
#region Ctor

public CategoriesExportVM(ToolsVM tools, IDialogProvider dialogProvider)
: base(tools)
{
this._dialogProvider = dialogProvider;

#region Commands

BrowseCommand = new DelegateCommand(() =>
{
string path = dialogProvider.OpenBrowseDialog();
Path = path;
});

ExportCommand = new DelegateCommand(async () =>
{
try
{
Tools.IsWorrking = true;
await Export();
}
finally
{
if (Tools.IsWorrking)
Tools.IsWorrking = false;
}
},
() => (
Tools.CurrentProjectCollection != null &&
(IsAllTeamProjects || Tools.CurrentTeamProject != null) &&
!string.IsNullOrEmpty(Path)
)
);

#endregion
}

#endregion

#region Props

private string _path;
public string Path
{
get { return _path; }
set
{
if (Set(ref _path, value))
ExportCommand.RaiseCanExecuteChanged();
}
}

private string _fileName;
public string FileName
{
get { return _fileName; }
set { Set(ref _fileName, value); }
}

private bool _isAllTeamProjects;

public bool IsAllTeamProjects
{
get { return _isAllTeamProjects; }
set
{
if (Set(ref _isAllTeamProjects, value))
ExportCommand.RaiseCanExecuteChanged();
}
}

#endregion

#region Fields

private IDialogProvider _dialogProvider;

#endregion

#region Methods

private async Task Export()
{
ProjectCollectionInfo projectCollection = Tools.CurrentProjectCollection;
TeamProjectInfo[] teamProjects;

teamProjects = (IsAllTeamProjects)
? projectCollection.TeamProjectInfos
: new TeamProjectInfo[] { Tools.CurrentTeamProject };

foreach (TeamProjectInfo teamProject in teamProjects)
Export(projectCollection, teamProject, Path);
}

private void Export(ProjectCollectionInfo projectCollection, TeamProjectInfo teamProject, string path)
{
string projectCollectionName = projectCollection.Name;
string teamProjectName = teamProject.Name;

string fileName = string.Format("{0}.xml", teamProjectName);
string fullPath = System.IO.Path.Combine(path, fileName);

Tools.WIAdminService.ExportCategories(TFManager, projectCollectionName, teamProjectName, fullPath);
}

#endregion

#region Commands

public DelegateCommand BrowseCommand { get; set; }

public DelegateCommand ExportCommand { get; set; }

#endregion
}
}
Loading

0 comments on commit 09572f7

Please sign in to comment.