diff options
| author | Shlomo Hecht <shlomo@twine-s.com> | 2018-06-24 19:13:33 +0300 |
|---|---|---|
| committer | Shlomo Hecht <shlomo@twine-s.com> | 2018-06-24 19:13:33 +0300 |
| commit | a27ef72084d844ef703aaa9b1c6f4ec032ca182e (patch) | |
| tree | 6899419d1dbce9e5509f7eec3c0415a3de232464 /Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs | |
| parent | 7e77e5877a6ab6a03c672199fd3edbe9395e4c45 (diff) | |
| parent | 545f603c873cd026faf5560dae83da947f0a02a6 (diff) | |
| download | Tango-a27ef72084d844ef703aaa9b1c6f4ec032ca182e.tar.gz Tango-a27ef72084d844ef703aaa9b1c6f4ec032ca182e.zip | |
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
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.cs | 22 |
1 files changed, 16 insertions, 6 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 index 9b03cda30..b90a03c1d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UpdateService/MachineStudioUpdateService.svc.cs @@ -30,6 +30,8 @@ namespace Tango.MachineStudio.UpdateService public String Comments { get; set; } + public bool ForcedUpdate { get; set; } + public String FilePath { get; set; } } @@ -48,7 +50,7 @@ namespace Tango.MachineStudio.UpdateService { CheckForUpdatesResponse response = new CheckForUpdatesResponse(); - using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) { db.Configuration.LazyLoadingEnabled = false; @@ -61,7 +63,7 @@ namespace Tango.MachineStudio.UpdateService String hash = User.GetPasswordHash(request.Password); var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == request.Email.ToLower() && x.Password == hash); - if (user != null && user.HasPermission(Permissions.RunMachineStudio)) + if (user != null && user.HasPermission(Permissions.RunMachineStudio) || (request.Email == "ForceUpdate")) { var latestVersion = db.MachineStudioVersions.FirstOrDefault(); Version currentVersion = Version.Parse(request.Version); @@ -75,6 +77,7 @@ namespace Tango.MachineStudio.UpdateService response.Password = ConfigurationManager.AppSettings["Password"].ToString(); response.FilePath = latestVersion.FtpFilePath; response.Version = latestVersion.Version; + response.ForcedUpdate = latestVersion.ForceUpdate; } } else @@ -98,7 +101,7 @@ namespace Tango.MachineStudio.UpdateService { UploadVersionResponse response = new UploadVersionResponse(); - using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) { db.Configuration.LazyLoadingEnabled = false; @@ -134,6 +137,7 @@ namespace Tango.MachineStudio.UpdateService { UserGuid = user.Guid, Comments = request.Comments, + ForcedUpdate = request.ForcedUpdate, Token = response.Token, Version = request.Version, FilePath = response.FilePath, @@ -169,7 +173,7 @@ namespace Tango.MachineStudio.UpdateService { _pendingUploads.RemoveAll(x => x.Token == upload.Token); - using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) { db.Configuration.LazyLoadingEnabled = false; @@ -178,7 +182,8 @@ namespace Tango.MachineStudio.UpdateService Comments = upload.Comments, FtpFilePath = upload.FilePath, UserGuid = upload.UserGuid, - Version = upload.Version + Version = upload.Version, + ForceUpdate = upload.ForcedUpdate, }); db.SaveChanges(); @@ -200,7 +205,7 @@ namespace Tango.MachineStudio.UpdateService { try { - using (ObservablesContext db = ObservablesContext.CreateDefaultForWeb()) + using (ObservablesContext db = ObservablesContext.CreateDefault(GetServerAddress())) { return db.MachineStudioVersions.FirstOrDefault().Version; } @@ -210,5 +215,10 @@ namespace Tango.MachineStudio.UpdateService throw new FaultException(ex.ToString()); } } + + private String GetServerAddress() + { + return ConfigurationManager.AppSettings["ServerAddress"].ToString(); + } } } |
