aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-02-21 20:21:57 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-02-21 20:21:57 +0200
commit956f9ea033553136ebf199fff30f288dc26fbeb0 (patch)
tree3780e906d8d4f12c5be3836e1704d93d8d4966bd /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs
parent808ce20dbd74862a75499ee0d4e87247ee4479b4 (diff)
downloadTango-956f9ea033553136ebf199fff30f288dc26fbeb0.tar.gz
Tango-956f9ea033553136ebf199fff30f288dc26fbeb0.zip
Working on machine studio update center..
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs62
1 files changed, 62 insertions, 0 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs
new file mode 100644
index 000000000..4cfea1b8a
--- /dev/null
+++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs
@@ -0,0 +1,62 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Runtime.Serialization;
+using System.ServiceModel;
+using System.ServiceModel.Web;
+using System.Text;
+using Tango.Integration.Observables;
+using Tango.Logging;
+using Tango.MachineStudio.Common.Update;
+
+namespace Tango.MachineStudio.UpdateService
+{
+ public class MachineStudioUpdateService : IMachineStudioUpdateService
+ {
+ public CheckForUpdatesResponse CheckForUpdates(CheckForUpdatesRequest request)
+ {
+ LogManager.Log("Request received...");
+
+ try
+ {
+ CheckForUpdatesResponse response = new CheckForUpdatesResponse();
+
+ using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb())
+ {
+ db.Configuration.LazyLoadingEnabled = false;
+
+ var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == request.Password);
+
+ if (user != null)
+ {
+ var latestVersion = db.MachineStudioVersions.FirstOrDefault();
+ Version currentVersionNumber = Version.Parse(request.Version);
+
+ if (latestVersion != null && Version.Parse(latestVersion.Version) > currentVersionNumber)
+ {
+ response.IsUpdateAvailable = true;
+
+ response.FtpHost = ConfigurationManager.AppSettings["FtpHost"].ToString();
+ response.UserName = ConfigurationManager.AppSettings["UserName"].ToString();
+ response.Password = ConfigurationManager.AppSettings["Password"].ToString();
+ response.FilePath = latestVersion.FtpFilePath;
+ response.Version = latestVersion.Version;
+ }
+ }
+ else
+ {
+ throw new FaultException("Invalid user credentials.");
+ }
+ }
+
+ return response;
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex);
+ throw new FaultException(ex.ToString());
+ }
+ }
+ }
+}