public RedirectResult LoadMySettings(string returnUrl) { try { if (MySettingsManager.DoesNameExistOnDisk(SettingsName)) { MySettings mySettings = MySettingsManager.LoadFromDisk(SettingsName); SessionHandler.MySettings = mySettings; } } catch (Exception) { } return(Redirect(returnUrl)); }
private void LoadMySettings(IUserContext userContext) { try { if (MySettingsManager.DoesNameExistOnDisk(userContext, MySettingsManager.SettingsName)) { var mySettings = MySettingsManager.LoadFromDisk(userContext, MySettingsManager.SettingsName); mySettings.EnsureDataProviders(userContext); SessionHandler.MySettings = mySettings; RemoveCookie("MapState"); } } catch (Exception) { } }
/// <summary> /// Loads a MySettings object from disk and uses this /// as the current settings. /// </summary> /// <returns></returns> public RedirectToRouteResult LoadMySettings() { try { IUserContext userContext = GetCurrentUser(); if (MySettingsManager.DoesNameExistOnDisk(userContext, MySettingsManager.SettingsName)) { MySettings mySettings = MySettingsManager.LoadFromDisk(userContext, MySettingsManager.SettingsName); SessionHandler.MySettings = mySettings; RemoveCookie("MapState"); } } catch (Exception) { } SessionHandler.UserMessages.Add(new UserMessage(Resources.Resource.MySettingsLoaded)); return(RedirectToAction("Index", "Home")); }
public void SerializeAndDeserializeMySettings() { using (ShimsContext.Create()) { ShimFilePath(); AnalysisPortal.MySettings.MySettings mySettings; AnalysisPortal.MySettings.MySettings loadedSettings; const string settingsName = "test"; // Arrange mySettings = CreateMySettingsObjectWithTaxonFilter(1, 2, 5); // Act MySettingsManager.SaveToDisk(settingsName, mySettings); loadedSettings = MySettingsManager.LoadFromDisk(settingsName); // Assert CollectionAssert.AreEqual(new[] { 1, 2, 5 }, loadedSettings.Filter.Taxa.TaxonIds); } }
public void SerializeAndDeserializeProtectedSettings() { // When this test is run a file called test.dat will be saved to // c:\InetPub\wwwRoot\AnalysisPortalTestRun\temp\settings using (ShimsContext.Create()) { string fullPath = @"C:\InetPub\wwwRoot\AnalysisPortalTestRun\temp\settings\myTempFile.txt"; ShimHostingEnvironment.MapPathString = (path) => { return(fullPath); }; var mySettings = new ArtDatabanken.WebApplication.AnalysisPortal.MySettings.MySettings(); mySettings.Filter.Taxa.TaxonIds.Add(1); mySettings.Filter.Taxa.TaxonIds.Add(2); mySettings.Filter.Taxa.TaxonIds.Add(5); int wfsLayersCount = mySettings.DataProvider.MapLayers.WfsLayers.Count; var layer = mySettings.DataProvider.MapLayers.AddWfsLayer(new WfsLayerSetting() { Name = "Test", GeometryType = GeometryType.Polygon, Color = "#336699", Filter = "", ServerUrl = "http://slwgeo.artdata.slu.se:8080/geoserver/SLW/wfs", TypeName = "SLW:MapOfSwedishCounties" }); MySettingsManager.SaveToDisk("test", mySettings); var mySettings2 = MySettingsManager.LoadFromDisk("test"); Assert.IsNotNull(mySettings2); Assert.IsTrue(mySettings2.Filter.Taxa.TaxonIds.Contains(1)); Assert.IsTrue(mySettings2.Filter.Taxa.TaxonIds.Contains(2)); Assert.IsTrue(mySettings2.Filter.Taxa.TaxonIds.Contains(5)); Assert.AreEqual(wfsLayersCount + 1, mySettings.DataProvider.MapLayers.WfsLayers.Count); } }