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/Update | |
| 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/Update')
8 files changed, 236 insertions, 0 deletions
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; } + } +} |
