diff options
| author | Avi Levkovich <avi@twine-s.com> | 2018-02-26 16:30:42 +0200 |
|---|---|---|
| committer | Avi Levkovich <avi@twine-s.com> | 2018-02-26 16:30:42 +0200 |
| commit | 5942bb7a13e5ad26c720a1b95ae4ea766eeeda25 (patch) | |
| tree | 2a855ce1065c875e615f5b040f984cb3fb84e518 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common | |
| parent | 4c052df707280abd208b03aa88cf904e0eb6b9bf (diff) | |
| parent | 6549d8672a93893599e921d9f1938af7dcabb8bf (diff) | |
| download | Tango-5942bb7a13e5ad26c720a1b95ae4ea766eeeda25.tar.gz Tango-5942bb7a13e5ad26c720a1b95ae4ea766eeeda25.zip | |
MERGE!
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common')
13 files changed, 270 insertions, 1 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs index 7718c0a7a..ad454556e 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/IStudioModule.cs @@ -36,6 +36,11 @@ namespace Tango.MachineStudio.Common FrameworkElement MainView { get; } /// <summary> + /// Gets or sets a value indicating whether this module is shown under a new window. + /// </summary> + bool InNewWindow { get; set; } + + /// <summary> /// Gets the permission required to see and load this module. /// </summary> Permissions Permission { get; } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs index db0f0471f..7e324c996 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Navigation/NavigationView.cs @@ -15,5 +15,6 @@ namespace Tango.MachineStudio.Common.Navigation MainView, LoginView, ShutdownView, + UpdateView, } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs index c67c34044..9a5f39a96 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioApplication/IStudioApplicationManager.cs @@ -48,5 +48,10 @@ namespace Tango.MachineStudio.Common.StudioApplication /// <param name="moduleName">Name of the module.</param> /// <param name="args">The arguments.</param> void RequestModule(String moduleName, Object args); + + /// <summary> + /// Gets the machine studio application version. + /// </summary> + String Version { get; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs index 5c594ab70..158661309 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/StudioModuleBase.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Media.Imaging; +using Tango.Core; using Tango.Integration.Observables; namespace Tango.MachineStudio.Common @@ -13,7 +14,7 @@ namespace Tango.MachineStudio.Common /// Represents a base class for studio modules. /// </summary> /// <seealso cref="Tango.MachineStudio.Common.IStudioModule" /> - public abstract class StudioModuleBase : IStudioModule + public abstract class StudioModuleBase : ExtendedObject, IStudioModule { private bool _isInitialized; private bool _isLoaded; @@ -79,6 +80,16 @@ namespace Tango.MachineStudio.Common } } + private bool _inNewWindow; + /// <summary> + /// Gets or sets a value indicating whether this module is shown under a new window. + /// </summary> + public bool InNewWindow + { + get { return _inNewWindow; } + set { _inNewWindow = value; RaisePropertyChangedAuto(); } + } + /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj index cd4fc1aeb..abe888d73 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Tango.MachineStudio.Common.csproj @@ -54,6 +54,8 @@ </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> + <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.ServiceModel" /> <Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <HintPath>..\..\packages\MahApps.Metro.1.5.0\lib\net45\System.Windows.Interactivity.dll</HintPath> </Reference> @@ -96,6 +98,14 @@ <Compile Include="Messages\IStudioMessage.cs" /> <Compile Include="Notifications\TaskItem.cs" /> <Compile Include="StudioModuleBase.cs" /> + <Compile Include="Update\CheckForUpdatesResponse.cs" /> + <Compile Include="Update\CheckForUpdatesRequest.cs" /> + <Compile Include="Update\FileStreamWrapper.cs" /> + <Compile Include="Update\IMachineStudioUpdateService.cs" /> + <Compile Include="Update\UpdateServiceHelper.cs" /> + <Compile Include="Update\UploadCompletedRequest.cs" /> + <Compile Include="Update\UploadVersionRequest.cs" /> + <Compile Include="Update\UploadVersionResponse.cs" /> <Compile Include="ValidationRules\Required.cs" /> <Compile Include="Video\DefaultVideoCaptureProvider.cs" /> <Compile Include="Video\IVideoCaptureProvider.cs" /> @@ -218,5 +228,6 @@ <Name>Tango.Video</Name> </ProjectReference> </ItemGroup> + <ItemGroup /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs new file mode 100644 index 000000000..f76e714a2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesRequest.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class CheckForUpdatesRequest + { + [DataMember] + public String Email { get; set; } + + [DataMember] + public String Password { get; set; } + + [DataMember] + public String Version { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs new file mode 100644 index 000000000..440e162a3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/CheckForUpdatesResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class CheckForUpdatesResponse + { + [DataMember] + public bool IsUpdateAvailable { get; set; } + + [DataMember] + public String Version { get; set; } + + [DataMember] + public String FtpHost { get; set; } + + [DataMember] + public String FilePath { get; set; } + + [DataMember] + public String UserName { get; set; } + + [DataMember] + public String Password { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs new file mode 100644 index 000000000..83fbdf7ea --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/FileStreamWrapper.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + /// <summary> + /// Represents a FileStream Wrapper dedicated for delivering Read/Write progress callbacks. + /// </summary> + /// <seealso cref="System.IO.FileStream" /> + public class FileStreamWrapper : FileStream + { + private Action<long> _callback; + + /// <summary> + /// Initializes a new instance of the <see cref="FileStreamWrapper"/> class. + /// </summary> + /// <param name="fileName">Name of the file.</param> + /// <param name="mode">The mode.</param> + /// <param name="callback">The callback.</param> + public FileStreamWrapper(String fileName, FileMode mode, Action<long> callback) : base(fileName, mode) + { + _callback = callback; + } + + /// <summary> + /// Writes a block of bytes to the file stream. + /// </summary> + /// <param name="array">The buffer containing data to write to the stream.</param> + /// <param name="offset">The zero-based byte offset in <paramref name="array" /> from which to begin copying bytes to the stream.</param> + /// <param name="count">The maximum number of bytes to write.</param> + public override void Write(byte[] array, int offset, int count) + { + _callback?.Invoke(Length); + base.Write(array, offset, count); + } + + /// <summary> + /// Reads a block of bytes from the stream and writes the data in a given buffer. + /// </summary> + /// <param name="array">When this method returns, contains the specified byte array with the values between <paramref name="offset" /> and (<paramref name="offset" /> + <paramref name="count" /> - 1<paramref name=")" /> replaced by the bytes read from the current source.</param> + /// <param name="offset">The byte offset in <paramref name="array" /> at which the read bytes will be placed.</param> + /// <param name="count">The maximum number of bytes to read.</param> + /// <returns> + /// The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached. + /// </returns> + public override int Read(byte[] array, int offset, int count) + { + _callback?.Invoke(Position); + return base.Read(array, offset, count); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs new file mode 100644 index 000000000..53e49e52c --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/IMachineStudioUpdateService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.ServiceModel; +using System.Text; +using Tango.MachineStudio.Common.Update; + +namespace Tango.MachineStudio.Common.Update +{ + [ServiceContract] + public interface IMachineStudioUpdateService + { + [OperationContract] + CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request); + + [OperationContract] + UploadVersionResponse UploadVersion(UploadVersionRequest request); + + [OperationContract] + void NotifyUploadCompleted(UploadCompletedRequest request); + + [OperationContract] + String GetLatestVersion(); + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs new file mode 100644 index 000000000..87b974b99 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UpdateServiceHelper.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.ServiceModel; +using System.Text; +using System.Threading.Tasks; +using Tango.Settings; + +namespace Tango.MachineStudio.Common.Update +{ + public static class UpdateServiceHelper + { + public static ChannelFactory<IMachineStudioUpdateService> GetUpdateServiceChannel() + { + BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None); + binding.ReceiveTimeout = TimeSpan.FromSeconds(20); + binding.SendTimeout = TimeSpan.FromSeconds(20); + binding.MaxBufferPoolSize = 6553600; + binding.MaxBufferSize = 6553600; + binding.MaxReceivedMessageSize = 6553600; + binding.ReaderQuotas.MaxDepth = 6553600; + binding.ReaderQuotas.MaxStringContentLength = 6553600; + binding.ReaderQuotas.MaxArrayLength = 6553600; + binding.ReaderQuotas.MaxBytesPerRead = 6553600; + + return new ChannelFactory<IMachineStudioUpdateService>(binding, SettingsManager.Default.MachineStudio.UpdateServiceAddress); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs new file mode 100644 index 000000000..ce6096792 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadCompletedRequest.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadCompletedRequest + { + [DataMember] + public String Token { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs new file mode 100644 index 000000000..71ce04f1f --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionRequest.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadVersionRequest + { + [DataMember] + public String Email { get; set; } + + [DataMember] + public String Password { get; set; } + + [DataMember] + public String Version { get; set; } + + [DataMember] + public String Comments { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs new file mode 100644 index 000000000..36dc3df30 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.Common/Update/UploadVersionResponse.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.MachineStudio.Common.Update +{ + [DataContract] + public class UploadVersionResponse + { + [DataMember] + public String FtpHost { get; set; } + + [DataMember] + public String FilePath { get; set; } + + [DataMember] + public String FileName { get; set; } + + [DataMember] + public String UserName { get; set; } + + [DataMember] + public String Password { get; set; } + + [DataMember] + public String Token { get; set; } + } +} |
