aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs171
1 files changed, 88 insertions, 83 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs
index d429c8935..db0936e56 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Publisher/MainWindowVM.cs
@@ -29,12 +29,6 @@ namespace Tango.PPC.Publisher
{
private IPPCUpdateService _client;
-#if DEBUG
- private String _appPath = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Debug\\PPC";
-#else
- private String _appPath = AppDomain.CurrentDomain.BaseDirectory + "..\\..\\Release\\PPC";
-#endif
-
private BasicHashGenerator _hashGenerator;
private List<MachineVersion> _machineVersions;
@@ -51,6 +45,13 @@ namespace Tango.PPC.Publisher
set { _selectedMachineVersion = value; RaisePropertyChangedAuto(); OnSelectedMachineVersionChanged(); }
}
+ private String _selectedBuildConfiguration;
+ public String SelectedBuildConfiguration
+ {
+ get { return _selectedBuildConfiguration; }
+ set { _selectedBuildConfiguration = value; RaisePropertyChangedAuto(); }
+ }
+
private String _localVersion;
public String LocalVersion
{
@@ -132,6 +133,8 @@ namespace Tango.PPC.Publisher
public MainWindowVM()
{
+ SelectedBuildConfiguration = "Release";
+
_hashGenerator = new BasicHashGenerator();
SequenceItems = new ObservableCollection<SequenceItem>();
@@ -171,106 +174,108 @@ namespace Tango.PPC.Publisher
private void Publish()
{
- Task.Factory.StartNew(() =>
- {
- IsUpdating = true;
- String tempFile = String.Empty;
+ String _appPath = String.Format(AppDomain.CurrentDomain.BaseDirectory + "..\\..\\{0}\\PPC", SelectedBuildConfiguration);
- try
+ Task.Factory.StartNew(() =>
{
- var response = _client.UploadVersion(new UploadVersionRequest()
+ IsUpdating = true;
+ String tempFile = String.Empty;
+
+ try
{
- Comments = Comments,
- Email = Email,
- Password = _hashGenerator.Encrypt(Password),
- Version = LocalVersion,
- MachineVersionGuid = SelectedMachineVersion.Guid
- });
+ var response = _client.UploadVersion(new UploadVersionRequest()
+ {
+ Comments = Comments,
+ Email = Email,
+ Password = _hashGenerator.Encrypt(Password),
+ Version = LocalVersion,
+ MachineVersionGuid = SelectedMachineVersion.Guid
+ });
- tempFile = Path.Combine(Path.GetTempPath(), response.FileName);
+ tempFile = Path.Combine(Path.GetTempPath(), response.FileName);
- using (ZipFile zip = new ZipFile())
- {
- String sync_dir = "Synchronization Scripts";
+ using (ZipFile zip = new ZipFile())
+ {
+ String sync_dir = "Synchronization Scripts";
- zip.AddDirectoryByName(sync_dir);
+ zip.AddDirectoryByName(sync_dir);
- ExaminerSequenceConfiguration config = new ExaminerSequenceConfiguration();
+ ExaminerSequenceConfiguration config = new ExaminerSequenceConfiguration();
- foreach (var item in SequenceItems)
- {
- config.Items.Add(new ExaminerSequenceItem()
+ foreach (var item in SequenceItems)
{
- Direction = item.Direction,
- FileName = item.FileName,
- Index = item.Index,
- Name = item.Name,
- Type = item.Type,
- RequiresSerialNumber = item.RequiresSerialNumber
- });
+ config.Items.Add(new ExaminerSequenceItem()
+ {
+ Direction = item.Direction,
+ FileName = item.FileName,
+ Index = item.Index,
+ Name = item.Name,
+ Type = item.Type,
+ RequiresSerialNumber = item.RequiresSerialNumber
+ });
- zip.AddFile(item.FilePath, sync_dir);
- }
+ zip.AddFile(item.FilePath, sync_dir);
+ }
- String config_file = TemporaryManager.Default.CreateFile(".zip");
- config.ToFile(config_file);
+ String config_file = TemporaryManager.Default.CreateFile(".zip");
+ config.ToFile(config_file);
- var cf = zip.AddFile(config_file, sync_dir);
- cf.FileName = sync_dir + "\\config.xml";
+ var cf = zip.AddFile(config_file, sync_dir);
+ cf.FileName = sync_dir + "\\config.xml";
- foreach (var file in Directory.GetFiles(_appPath, "*.*", SearchOption.TopDirectoryOnly))
- {
- zip.AddFile(file, "/");
- }
+ foreach (var file in Directory.GetFiles(_appPath, "*.*", SearchOption.TopDirectoryOnly))
+ {
+ zip.AddFile(file, "/");
+ }
- zip.SaveProgress += (x, e) =>
- {
- MaxProgress = e.EntriesTotal;
- Progress = e.EntriesSaved;
- };
+ zip.SaveProgress += (x, e) =>
+ {
+ MaxProgress = e.EntriesTotal;
+ Progress = e.EntriesSaved;
+ };
- zip.Save(tempFile);
- }
+ zip.Save(tempFile);
+ }
- Progress = 0;
- MaxProgress = 100;
+ Progress = 0;
+ MaxProgress = 100;
- FileStreamWrapper fs = null;
+ FileStreamWrapper fs = null;
- using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) =>
- {
- InvokeUINow(() =>
+ using (fs = new FileStreamWrapper(tempFile, FileMode.Open, (current) =>
{
- Thread.Sleep(10);
- Progress = ((double)current / (double)fs.Length) * 100d;
- });
- }))
- {
- using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password))
+ InvokeUINow(() =>
+ {
+ Thread.Sleep(10);
+ Progress = ((double)current / (double)fs.Length) * 100d;
+ });
+ }))
{
- ftp.ConnectAsync().Wait();
- ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait();
+ using (FtpClient ftp = new FtpClient(response.FtpHost, response.UserName, response.Password))
+ {
+ ftp.ConnectAsync().Wait();
+ ftp.UploadAsync(fs, response.FilePath, FtpExists.Overwrite, true).Wait();
+ }
}
- }
- _client.NotifyUploadCompleted(new UploadCompletedRequest()
- {
- Token = response.Token,
- });
+ _client.NotifyUploadCompleted(new UploadCompletedRequest()
+ {
+ Token = response.Token,
+ });
- Progress = 0;
- OnSelectedMachineVersionChanged();
- ShowInfo("Version published successfully!");
- }
- catch (Exception ex)
- {
- ShowError(ex.Message);
- }
- finally
- {
- IsUpdating = false;
- }
- });
+ Progress = 0;
+ OnSelectedMachineVersionChanged();
+ ShowInfo("Version published successfully!");
+ }
+ catch (Exception ex)
+ {
+ ShowError(ex.Message);
+ }
+ finally
+ {
+ IsUpdating = false;
+ }
+ });
}
private void ShowError(String error)