public TransferCommand(int userID1, ushort objID1, UserStyle userStyle1, string userName1) { userID = userID1; objID = objID1; userStyle = userStyle1; userName = userName1; }
public async Task <IActionResult> PutStyle(UserStyle userStyle) { UserStyle oldUS = _context.UserStyles.Single(d => d.Id == userStyle.Id); _context.UserStyles.Remove(oldUS); await _context.SaveChangesAsync(); _context.UserStyles.Add(userStyle); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserStyleExists(userStyle.Id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
// Sébastien Berger : Styles // Met à jour le style de l'utilisateur // GET: Account/EditStyle/5 public async Task <IActionResult> EditStyle(string id) { if (id == null) { return(NotFound()); } // Préparation de l'appel à l'API string accessToken = await HttpContext.GetTokenAsync("access_token"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); // Récurération des données et convertion des données dans le bon type string content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Account/getUserInfo"); AspNetUser aspNetUser = JsonConvert.DeserializeObject <AspNetUser>(content); if (aspNetUser == null) { return(NotFound()); } // Récurération des données et convertion des données dans le bon type, idem que précédemment content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/styles"); List <Style> styles = JsonConvert.DeserializeObject <List <Style> >(content); UserStyle userStyle = aspNetUser.UserStyles.Single(); ViewData["StyleId"] = new SelectList(styles, "StyleId", "StyleName", userStyle.Style.StyleId); return(View(userStyle)); }
public void RenderViewContextTest() { StringDictionary parameters = new StringDictionary(); parameters.Add("styles", "default"); parameters.Add("width", "512"); parameters.Add("height", "512"); parameters.Add("crs", "EPSG:4326"); parameters.Add("layers", "world_admin"); parameters.Add("bgcolor", "0x0000FF"); parameters.Add("version", "1.3.0"); parameters.Add("format", "image/png"); parameters.Add("request", "GetMap"); parameters.Add("bbox", "-180,-85,180,85"); ViewContext context = new ViewContext(); // add context details inline for test, this is normally done by ViewContext(parameters) // which applies details from configuration files etc. context.General.Window.Width = 512; context.General.Window.Height = 512; Layer layer = new Layer(); layer.Title = "World Administration Boundaries"; layer.Table = "world_admin"; layer.Name = "world_admin"; layer.GeometryColumn = "shape"; layer.FeatureIdColumn = "fid"; layer.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Projects\\GeospatialServices\\TestGeospatialServices\\Input\\Runtime\\TestGeospatialServicesDatabase.mdf;Integrated Security=True;User Instance=True"; Style style = new Style(); UserLayer userLayer = new UserLayer(); userLayer.UserStyles = new List <UserStyle>(); UserStyle userStyle = new UserStyle(); FeatureTypeStyle featureTypeStyle = new FeatureTypeStyle(); Rule rule = new Rule(); PolygonSymbolizer polygon = new PolygonSymbolizer(); style.Name = "default"; userLayer.Name = "World in green"; polygon.Fill.SvgParameters.Add(new SvgParameter("fill", "#2E8C7C")); BaseSymbolizer[] symbolizers = new BaseSymbolizer[] { polygon }; rule.Symbolizers = symbolizers; featureTypeStyle.Rules.Add(rule); userStyle.FeatureTypeStyles.Add(featureTypeStyle); userLayer.UserStyles.Add(userStyle); style.SLD.StyledLayerDescriptor.UserLayers.Add(userLayer); layer.StyleList.Add(style); context.Layers.Add(layer); System.Drawing.Image mapImage = context.Render(parameters); }
public void ResetLogin() { currUserFullname = String.Empty; currStyle = UserStyle.Диспетчер; currWorked = false; foreach (Form pan in panels) { IUpdateStatusPanel pm = (IUpdateStatusPanel)pan; pm.UpdateUserLogged("Нет регистрации"); pm.UpdateTuningMenu(false); } }
public void LoginUser(string fullname, string shortname, UserStyle style) { currUserFullname = fullname; currStyle = style; currWorked = true; foreach (Form pan in panels) { IUpdateStatusPanel pm = (IUpdateStatusPanel)pan; pm.UpdateUserLogged(shortname); pm.UpdateTuningMenu(true); } }
public List <Пользователь> GetUserList(UserStyle style) { List <Пользователь> list = new List <Пользователь>(); var QueryResults = from n in userList where n.Категория == style orderby n select n; foreach (var item in QueryResults) { list.Add(item); } return(list); }
//根据配置文件加载窗体风格 private void loadUserStyleProfile() { try { userStyle = ConfigurationManager.GetConfiguration(USERSTYLEPROFILE_CONFIG_NAME) as UserStyle; string windowsStyle = userStyle.StyleName; string windowsSkin = userStyle.SkinName; if (windowsStyle.Equals("Default")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetDefaultStyle(); } else if (windowsStyle.Equals("WindowsXP")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetWindowsXPStyle(); } else if (windowsStyle.Equals("OfficeXP")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style(); } else if (windowsStyle.Equals("Office2000")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetDefaultStyle(); } else if (windowsStyle.Equals("Office2003")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetOffice2003Style(); } else if (windowsStyle.Equals("Skin")) { DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(windowsSkin); } } catch (Exception ex) { MessageBox.Show(ex.Message, "系统信息", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void AddUserStyle(Stream stream, UserStyle userStyle) { stream.WriteByte((byte)userStyle.UserStyleId); stream.WriteWord(userStyle.RegionHorizontalPositionDelta, userStyle.RegionHorizontalPositionDirection); stream.WriteWord(userStyle.RegionVerticalPositionDelta, userStyle.RegionVerticalPositionDirection); stream.WriteByte(userStyle.FontSizeDelta, userStyle.FontSizeIncDec); stream.WriteWord(userStyle.TextBoxHorizontalPositionDelta, userStyle.TextBoxHorizontalPositionDirection); stream.WriteWord(userStyle.TextBoxVerticalPositionDelta, userStyle.TextBoxVerticalPositionDirection); stream.WriteWord(userStyle.TextBoxWidthDelta, userStyle.TextBoxWidthIncDec); stream.WriteWord(userStyle.TextBoxHeightDelta, userStyle.TextBoxHeightIncDec); stream.WriteByte(userStyle.LineSpaceDelta, userStyle.LineSpaceIncDec); }
public DialogStyleSegment(byte[] buffer) { PlayerStyleFlag = (buffer[9] & Helper.B10000000) > 0; NumberOfRegionStyles = buffer[11]; NumberOfUserStyles = buffer[12]; int idx = 13; RegionStyles = new List<RegionStyle>(NumberOfRegionStyles); for (int i = 0; i < NumberOfRegionStyles; i++) { var rs = new RegionStyle { RegionStyleId = buffer[idx], RegionHorizontalPosition = (buffer[idx + 1] << 8) + buffer[idx + 2], RegionVerticalPosition = (buffer[idx + 3] << 8) + buffer[idx + 4], RegionWidth = (buffer[idx + 5] << 8) + buffer[idx + 6], RegionHeight = (buffer[idx + 7] << 8) + buffer[idx + 8], RegionBgPaletteEntryIdRef = buffer[idx + 9], TextBoxHorizontalPosition = (buffer[idx + 11] << 8) + buffer[idx + 12], TextBoxVerticalPosition = (buffer[idx + 13] << 8) + buffer[idx + 14], TextBoxWidth = (buffer[idx + 15] << 8) + buffer[idx + 16], TextBoxHeight = (buffer[idx + 17] << 8) + buffer[idx + 18], TextFlow = buffer[idx + 19], TextHorizontalAlignment = buffer[idx + 20], TextVerticalAlignment = buffer[idx + 21], LineSpace = buffer[idx + 22], FontIdRef = buffer[idx + 23], FontStyle = buffer[idx + 24], FontSize = buffer[idx + 25], FontPaletteEntryIdRef = buffer[idx + 26], FontOutlinePaletteEntryIdRef = buffer[idx + 27], FontOutlineThickness = buffer[idx + 28] }; RegionStyles.Add(rs); idx += 29; } UserStyles = new List<UserStyle>(); for (int j = 0; j < NumberOfUserStyles; j++) { var us = new UserStyle { UserStyleId = buffer[idx], RegionHorizontalPositionDirection = buffer[idx + 1] >> 7, RegionHorizontalPositionDelta = ((buffer[idx + 1] & Helper.B01111111) << 8) + buffer[idx + 2], RegionVerticalPositionDirection = buffer[idx + 3] >> 7, RegionVerticalPositionDelta = ((buffer[idx + 3] & Helper.B01111111) << 8) + buffer[idx + 4], FontSizeIncDec = buffer[idx + 5] >> 7, FontSizeDelta = (buffer[idx + 5] & Helper.B01111111), TextBoxHorizontalPositionDirection = buffer[idx + 6] >> 7, TextBoxHorizontalPositionDelta = ((buffer[idx + 6] & Helper.B01111111) << 8) + buffer[idx + 7], TextBoxVerticalPositionDirection = buffer[idx + 8] >> 7, TextBoxVerticalPositionDelta = ((buffer[idx + 8] & Helper.B01111111) << 8) + buffer[idx + 9], TextBoxWidthIncDec = buffer[idx + 10] >> 7, TextBoxWidthDelta = ((buffer[idx + 10] & Helper.B01111111) << 8) + buffer[idx + 11], TextBoxHeightIncDec = buffer[idx + 12] >> 7, TextBoxHeightDelta = ((buffer[idx + 12] & Helper.B01111111) << 8) + buffer[idx + 13], LineSpaceIncDec = buffer[idx + 14] >> 7, LineSpaceDelta = (buffer[idx + 14] & Helper.B01111111) }; UserStyles.Add(us); idx += 15; } int numberOfPalettees = ((buffer[idx] << 8) + buffer[idx + 1]) / 5; Palettes = new List<Palette>(numberOfPalettees); idx += 2; for (int i = 0; i < numberOfPalettees; i++) { var palette = new Palette { PaletteEntryId = buffer[idx], Y = buffer[idx + 1], Cr = buffer[idx + 2], Cb = buffer[idx + 3], T = buffer[idx + 4] }; Palettes.Add(palette); idx += 5; } NumberOfDialogPresentationSegments = (buffer[idx] << 8) + buffer[idx + 1]; }
public async Task <IActionResult> SignUpSend(RegisterInput input) { ApplicationUser user = new ApplicationUser(); try { string connectionString = Startup.Configuration.GetConnectionString("DefaultConnection"); var services = new ServiceCollection(); services.AddLogging(); services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(connectionString)); services.AddIdentity <ApplicationUser, IdentityRole>() .AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); using (var serviceProvider = services.BuildServiceProvider()) { using (var scope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { var context = scope.ServiceProvider.GetService <ApplicationDbContext>(); var userMgr = scope.ServiceProvider.GetRequiredService <UserManager <ApplicationUser> >(); var checkUser = _userManager.FindByNameAsync(input.UserName).Result; if (checkUser == null) { if (input.ConfirmPassword != input.PasswordHash) { throw new Exception("Votre formulaire comporte des erreurs"); } else { user = input; } var checkEmail = _userManager.FindByEmailAsync(input.Email).Result; if (checkEmail != null) { throw new Exception("Email déjà utilisé"); } int now = int.Parse(DateTime.Now.ToString("yyyyMMdd")); int dob = int.Parse(input.Birthday.ToString("yyyyMMdd")); int age = (now - dob) / 10000; if (age < 18) { throw new Exception("Vous devez avoir 18 ans pour vous inscrire"); } // Vérification du numéro de téléphone - Sébastien Berger PhoneNumber phoneNumber = _phoneUtil.Parse(input.PhoneNumber, input.countryCode); if (!_phoneUtil.IsValidNumberForRegion(phoneNumber, input.countryCode) && !phoneNumber.HasExtension) { throw new Exception("Numéro invalide"); } else { input.PhoneNumber = "+" + phoneNumber.CountryCode.ToString() + phoneNumber.NationalNumber.ToString(); } user.CorpulenceId = input.CorpulenceId; user.SexualityId = input.SexualityId; user.Sexeid = input.Sexeid; user.HairColorId = input.HairColorId; user.HairSizeId = input.HairSizeId; user.QuizCompleted = false; user.ReligionId = input.ReligionId; user.AccountCompleted = true; checkUser = user; var result = userMgr.CreateAsync(checkUser, user.PasswordHash).Result; if (!result.Succeeded) { throw new Exception(result.Errors.First().Description); } else { AspNetUserRole userRole = new AspNetUserRole(); userRole.UserId = checkUser.Id; userRole.RoleId = "Utilisateur"; _context.AspNetUserRoles.Add(userRole); string ip = _accessor.ActionContext.HttpContext.Connection.RemoteIpAddress.ToString(); _logger.LogInformation("User created a new account with password with ip: " + ip); string userId = _context.AspNetUsers.Where(u => u.UserName == input.UserName).Select(u => u.Id).SingleOrDefault(); UserTrace trace = new UserTrace { Logdate = DateTime.Now, Ipadress = ip, Pagevisited = "SignUp : User created a new account", Id = userId }; UserStyle us = new UserStyle(); us.Id = user.Id; us.StyleId = input.StyleId; _context.UserStyles.Add(us); _context.UserTraces.Add(trace); _context.SaveChanges(); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, Request.Scheme); string message = "Salut mon pote comment ca va ? si tu veux confirmer ton inscription c'est par <a href='" + callbackUrl + "'>ici</a>"; await _emailSender.SendEmailAsync(user.Email, "Confirmer votre Email", message); } Log.Debug($"{checkUser.UserName} created"); } else { throw new Exception("Votre nom d'utilisateur est déjà pris"); } } } return(View("SignUpSuccess", user)); } catch (Exception e) { Log.Debug($"{e.Message} error"); ViewData["error"] = e.Message; await SignUp(); return(View("SignUp")); } }
public void ExerciseWmcFromCodeTest() { ViewContext context = new ViewContext(); // Context -> General context.General.Window.Width = 500; context.General.Window.Height = 300; context.General.BoundingBox.SRS = "EPSG:4326"; context.General.BoundingBox.MinX = -180; context.General.BoundingBox.MinY = -90; context.General.BoundingBox.MaxX = 180; context.General.BoundingBox.MaxY = 90; context.General.Title = "EOS Data Gateways"; context.General.KeywordList.Add("EOS"); context.General.KeywordList.Add("EOSDIS"); context.General.KeywordList.Add("NASA"); context.General.KeywordList.Add("CCRS"); context.General.KeywordList.Add("CEOS"); context.General.KeywordList.Add("OGC"); context.General.Abstract = "Map View of EOSDIS partners locations"; context.General.LogoURL.Width = 130; context.General.LogoURL.Height = 74; context.General.LogoURL.Format = "image/gif"; context.General.LogoURL.OnlineResource.Type = "simple"; context.General.LogoURL.OnlineResource.Href = "http://redhook.gsfc.nasa.gov/~imswww/pub/icons/logo.gif"; context.General.DescriptionURL.Format = "text/html"; context.General.DescriptionURL.OnlineResource.Type = "simple"; context.General.DescriptionURL.OnlineResource.Href = "http://eos.nasa.gov/imswelcome"; context.General.ContactInformation.ContactPersonPrimary.ContactPerson = "Tom Kralidis"; context.General.ContactInformation.ContactPersonPrimary.ContactOrganisation = "Canada Centre for Remote Sensing"; context.General.ContactInformation.ContactPosition = "Systems Scientist"; context.General.ContactInformation.ContactAddress.AddressType = "postal"; context.General.ContactInformation.ContactAddress.Address = "615 Booth Street, room 650"; context.General.ContactInformation.ContactAddress.City = "Ottawa"; context.General.ContactInformation.ContactAddress.StateOrProvince = "Ontario"; context.General.ContactInformation.ContactAddress.Country = "Canada"; context.General.ContactInformation.ContactVoiceTelephone = "+01 613 947 1828"; context.General.ContactInformation.ContactFacsimileTelephone = "+01 613 947 2410"; context.General.ContactInformation.ContactElectronicMailAddress = "*****@*****.**"; context.Version = "1.0"; context.Id = "TEST"; // Context -> Layer Layer layer = new Layer(); layer.Queryable = 1; layer.Hidden = 0; layer.Server.Service = GeospatialServices.Ogc.Common.ServiceNames.WMS; layer.Server.Version = "1.0.7"; layer.Title = "The GLOBE Program Visualization Server"; layer.Server.OnlineResource.Type = "simple"; layer.Server.OnlineResource.Href = "http://globe.digitalearth.gov/viz-bin/wmt.cgi"; layer.Name = "NATIONAL"; layer.Title = "National Boundaries"; layer.Abstract = "Context layer: National Boundaries"; layer.SRS = "EPSG:4326"; // Context -> Layer -> Format layer.FormatList.Add(new Format("GIF", 1)); // Context -> Layer -> Style Style style1 = new Style(); style1.Current = 1; style1.Name = "default"; style1.LegendURL.Width = 16; style1.LegendURL.Height = 16; style1.LegendURL.Format = "image/gif"; style1.LegendURL.OnlineResource.Type = "simple"; style1.LegendURL.OnlineResource.Href = "http://mapserv2.esrin.esa.it/cubestor/cubeserv.cgi?VERSION=1.1.0&REQUEST=GetLegendIcon&LAYER=WORLD_MODIS_1KM:MapAdmin&SPATIAL_TYPE=RASTER&STYLE=default&FORMAT=image//gif"; // Context -> Layer -> Style -> Named Layer NamedLayer namedLayer = new NamedLayer(); namedLayer.Name = "Roads"; // Context -> Layer -> Style -> Named Layer -> Named Styles namedLayer.NamedStyles.Add(new NamedStyle("Casing")); namedLayer.NamedStyles.Add(new NamedStyle("Centerline")); // Context -> Layer -> Style -> Named Layer -> User Style UserStyle userStyle1 = new UserStyle(); // Context -> Layer -> Style -> Named Layer -> User Style -> FeatureTypeStyle FeatureTypeStyle featureTypeStyle1 = new FeatureTypeStyle(); Rule rule1 = new Rule(); // Context -> Layer -> Style -> Named Layer -> User Style -> FeatureTypeStyle -> Rule -> Symbolizers BaseSymbolizer[] symbolizers = new BaseSymbolizer[6]; SymbolizerTypes[] symbolizerSelections = new SymbolizerTypes[6]; // Line Symbolizer LineSymbolizer lineSymbolizer = new LineSymbolizer(); lineSymbolizer.Geometry.PropertyName = "center-line"; lineSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke", "#0000ff")); lineSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke-width", "2")); symbolizers[0] = lineSymbolizer; symbolizerSelections[0] = SymbolizerTypes.LineSymbolizer; // Polygon Symbolizer PolygonSymbolizer polygonSymbolizer = new PolygonSymbolizer(); polygonSymbolizer.Geometry.PropertyName = "the_area"; polygonSymbolizer.Fill.SvgParameters.Add(new SvgParameter("fill", "#aaaaff")); polygonSymbolizer.Stroke.SvgParameters.Add(new SvgParameter("stroke", "#0000aa")); symbolizers[1] = polygonSymbolizer; symbolizerSelections[1] = SymbolizerTypes.PolygonSymbolizer; // Point Symbolizer PointSymbolizer pointSymbolizer = new PointSymbolizer(); // Point Symbolizer - > External Graphic 1 ExternalGraphic externalGraphic1 = new ExternalGraphic(); externalGraphic1.OnlineResource.Type = "simple"; externalGraphic1.OnlineResource.Href = "http://www.vendor.com/geosym/2267.svg"; externalGraphic1.Format = "image/svg+xml"; pointSymbolizer.Graphic.ExternalGraphics.Add(externalGraphic1); // Point Symbolizer - > External Graphic 2 ExternalGraphic externalGraphic2 = new ExternalGraphic(); externalGraphic2.OnlineResource.Type = "simple"; externalGraphic2.OnlineResource.Href = "http://www.vendor.com/geosym/2267.png"; externalGraphic2.Format = "image/png"; pointSymbolizer.Graphic.ExternalGraphics.Add(externalGraphic2); pointSymbolizer.Graphic.Size = 15.0; symbolizers[2] = pointSymbolizer; symbolizerSelections[2] = SymbolizerTypes.PointSymbolizer; // Text Symbolizer TextSymbolizer textSymbolizer = new TextSymbolizer(); textSymbolizer.Geometry.PropertyName = "locatedAt"; textSymbolizer.Label = @"ogc:PropertyName[hospitalName]"; textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-family", "Arial")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-family", "Sans-Serif")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-style", "italic")); textSymbolizer.Font.SvgParameters.Add(new SvgParameter("font-size", "10")); textSymbolizer.Fill.SvgParameters.Add(new SvgParameter("fill", "#000000")); textSymbolizer.LabelPlacement.PointPlacement = new PointPlacement(); textSymbolizer.LabelPlacement.PointPlacement.AnchorPoint.AnchorPointX = 456; textSymbolizer.LabelPlacement.PointPlacement.AnchorPoint.AnchorPointY = 123; textSymbolizer.LabelPlacement.PointPlacement.Rotation = 180; textSymbolizer.LabelPlacement.PointPlacement.Displacement.DisplacementX = 111; textSymbolizer.LabelPlacement.PointPlacement.Displacement.DisplacementY = 222; textSymbolizer.LabelPlacement.LinePlacement = new LinePlacement(); textSymbolizer.LabelPlacement.LinePlacement.Gap = 12; textSymbolizer.LabelPlacement.LinePlacement.GeneraliseLine = 3; textSymbolizer.LabelPlacement.LinePlacement.InitialGap = 3; textSymbolizer.LabelPlacement.LinePlacement.IsAligned = 0; textSymbolizer.LabelPlacement.LinePlacement.IsRepeated = 1; textSymbolizer.LabelPlacement.LinePlacement.PerpendicularOffset = 5; textSymbolizer.Halo.Fill = new Fill(); textSymbolizer.Halo.Fill.SvgParameters.Add(new SvgParameter("fill", "#000000")); textSymbolizer.Halo.Radius = 3; symbolizers[3] = textSymbolizer; symbolizerSelections[3] = SymbolizerTypes.TextSymbolizer; // Raster Symbolizer 1 RasterSymbolizer rasterSymbolizer1 = new RasterSymbolizer(); rasterSymbolizer1.Opacity = 1.0; rasterSymbolizer1.OverlapBehaviour = OverlapBehaviourTypes.Average; rasterSymbolizer1.ColourMap.Categorize.LookupValue = "Rasterdata"; rasterSymbolizer1.ColourMap.Categorize.Values.Add("#00ff00"); rasterSymbolizer1.ColourMap.Categorize.Thresholds.Add(-417); rasterSymbolizer1.ColourMap.Categorize.Values.Add("#00fa00"); rasterSymbolizer1.ColourMap.Categorize.Thresholds.Add(-333); symbolizers[4] = rasterSymbolizer1; symbolizerSelections[4] = SymbolizerTypes.RasterSymbolizer; // Raster Symbolizer 2 RasterSymbolizer rasterSymbolizer2 = new RasterSymbolizer(); rasterSymbolizer2.Opacity = 1.0; rasterSymbolizer2.OverlapBehaviour = OverlapBehaviourTypes.LatestOnTop; rasterSymbolizer2.ChannelSelection.RedChannel.SourceChannelName = "1"; rasterSymbolizer2.ChannelSelection.GreenChannel.SourceChannelName = "2"; rasterSymbolizer2.ChannelSelection.GreenChannel.ContrastEnhancement.GammaValue = 2.5; rasterSymbolizer2.ChannelSelection.BlueChannel.SourceChannelName = "3"; rasterSymbolizer2.ColourMap.Interpolate.FallBackValue = "#dddddd"; rasterSymbolizer2.ColourMap.Interpolate.LookupValue = "Rasterdata"; rasterSymbolizer2.ColourMap.Interpolate.InterpolationPoints.Add(new InterpolationPoint(0, "#000000")); rasterSymbolizer2.ColourMap.Interpolate.InterpolationPoints.Add(new InterpolationPoint(255, "#ffffff")); rasterSymbolizer2.ContrastEnhancement.GammaValue = 1; rasterSymbolizer2.Geometry.PropertyName = "Coastlines"; symbolizers[5] = rasterSymbolizer2; symbolizerSelections[5] = SymbolizerTypes.RasterSymbolizer; rule1.SymbolizerSelections = symbolizerSelections; rule1.Symbolizers = symbolizers; featureTypeStyle1.Rules.Add(rule1); Rule rule2 = new Rule(); rule2.ElseFilter = new ElseFilter(); featureTypeStyle1.Rules.Add(rule2); Rule rule3 = new Rule(); GeospatialServices.Ogc.Wmc.PropertyIsEqualTo propEqualTo = new PropertyIsEqualTo(); propEqualTo.Literal.Value = "NEW YORK"; propEqualTo.PropertyName = "SALES_AREA"; //BaseComparisonOps ComparisonOps[] = new BaseComparisonOps[2]; rule3.Filter.FilterExpression = propEqualTo; featureTypeStyle1.Rules.Add(rule3); userStyle1.FeatureTypeStyles.Add(featureTypeStyle1); namedLayer.UserStyles.Add(userStyle1); // Context - > Layer -> Style -> User Layer UserLayer userLayer = new UserLayer(); userLayer.Name = "Lakes and Rivers"; UserStyle userStyle = new UserStyle("Default"); userStyle.FeatureTypeStyles.Add(featureTypeStyle1); userLayer.UserStyles = new List <UserStyle>(); userLayer.UserStyles.Add(userStyle); style1.SLD.StyledLayerDescriptor.NamedLayers.Add(namedLayer); style1.SLD.StyledLayerDescriptor.UserLayers.Add(userLayer); layer.StyleList.Add(style1); context.Layers.Add(layer); }
public void RenderSLDInParametersTest() { StringBuilder sld = new StringBuilder(); sld.Append("<SLD>"); sld.Append("<sld:StyledLayerDescriptor>"); sld.Append("<sld:UserLayer>"); sld.Append("<sld:Name>World</sld:Name>"); sld.Append("<sld:UserStyles>"); sld.Append("<sld:UserStyle>"); sld.Append("<se:FeatureTypeStyle>"); sld.Append("<se:Rule>"); sld.Append("<se:PointSymbolizer>"); sld.Append("<se:Graphic>"); sld.Append("<se:Opacity>255</se:Opacity>"); sld.Append("<se:Mark>"); sld.Append("<se:WellKnownName>font://Webdings?CharIndex=114</se:WellKnownName>"); sld.Append("<se:Fill>"); sld.Append("<se:SvgParameter name=\"fill\">#000000</se:SvgParameter>"); sld.Append("</se:Fill>"); sld.Append("</se:Mark>"); sld.Append("<se:Size>12</se:Size>"); sld.Append("</se:Graphic>"); sld.Append("</se:PointSymbolizer>"); sld.Append("<se:PolygonSymbolizer>"); sld.Append("<se:Fill>"); sld.Append("<se:SvgParameter name=\"fill\">#2E8C7C</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"fill-opacity\">255</se:SvgParameter>"); sld.Append("</se:Fill>"); sld.Append("<se:Stroke>"); sld.Append("<se:SvgParameter name=\"stroke\">#206055</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-opacity\">255</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-width\">1</se:SvgParameter>"); sld.Append("</se:Stroke>"); sld.Append("</se:PolygonSymbolizer>"); sld.Append("<se:LineSymbolizer>"); sld.Append("<se:Stroke>"); sld.Append("<se:SvgParameter name=\"stroke\">#000000</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-width\">1</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-opacity\">255</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-dasharray\">Solid</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-linecap\">Flat</se:SvgParameter>"); sld.Append("<se:SvgParameter name=\"stroke-linejoin\">Miter</se:SvgParameter>"); sld.Append("</se:Stroke>"); sld.Append("</se:LineSymbolizer>"); sld.Append("</se:Rule>"); sld.Append("</se:FeatureTypeStyle>"); sld.Append("</sld:UserStyle>"); sld.Append("</sld:UserStyles>"); sld.Append("</sld:UserLayer>"); sld.Append("</sld:StyledLayerDescriptor>"); sld.Append("</SLD>"); StringDictionary parameters = new StringDictionary(); parameters.Add(WmsParameters.Styles, "default"); parameters.Add(WmsParameters.Width, "512"); parameters.Add(WmsParameters.Height, "512"); parameters.Add(WmsParameters.Crs, "EPSG:4326"); parameters.Add(WmsParameters.Layers, "world_admin"); parameters.Add(WmsParameters.BgColor, "0x0000FF"); parameters.Add("version", "1.3.0"); parameters.Add(WmsParameters.Format, "image/png"); parameters.Add("request", "GetMap"); parameters.Add(WmsParameters.Bbox, "-180,-85,180,85"); parameters.Add(WmsParameters.SldBody, sld.ToString()); ViewContext context = new ViewContext(); // add context details inline for test, this is normally done by ViewContext(parameters) // which applies details from configuration files etc. context.General.Window.Width = 512; context.General.Window.Height = 512; Layer layer = new Layer(); layer.Title = "World Administration Boundaries"; layer.Table = "world_admin"; layer.Name = "world_admin"; layer.GeometryColumn = "shape"; layer.FeatureIdColumn = "fid"; layer.ConnectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\Projects\\GeospatialServices\\TestGeospatialServices\\Input\\Runtime\\TestGeospatialServicesDatabase.mdf;Integrated Security=True;User Instance=True"; Style style = new Style(); UserLayer userLayer = new UserLayer(); userLayer.UserStyles = new List <UserStyle>(); UserStyle userStyle = new UserStyle(); FeatureTypeStyle featureTypeStyle = new FeatureTypeStyle(); Rule rule = new Rule(); PolygonSymbolizer polygon = new PolygonSymbolizer(); style.Name = "default"; userLayer.Name = "World in green"; polygon.Fill.SvgParameters.Add(new SvgParameter("fill", "#2E8C7C")); BaseSymbolizer[] symbolizers = new BaseSymbolizer[] { polygon }; rule.Symbolizers = symbolizers; featureTypeStyle.Rules.Add(rule); userStyle.FeatureTypeStyles.Add(featureTypeStyle); userLayer.UserStyles.Add(userStyle); style.SLD.StyledLayerDescriptor.UserLayers.Add(userLayer); layer.StyleList.Add(style); context.Layers.Add(layer); System.Drawing.Image mapImage = context.Render(parameters); }
private static MvcHtmlString GetSelectUserHtml(HtmlHelper html, string name, List <ITreeData> data, string GetLeafURL, string CallBackMethod, UserStyle userStyle, OpenNoteEnum openNote, ValidateOptions validateOptions, string value) { BizDataContext context; List <string> keyList = new List <string>(); JavaScriptSerializer serializer = new JavaScriptSerializer(); StringBuilder builder = new StringBuilder(); TagBuilder builder2 = new TagBuilder("div"); builder2.GenerateId(name); builder2.AddCssClass("treeDiv"); TagBuilder builder3 = GetTagBuilder("ul", name, "ztree"); builder3.MergeAttribute("style", "display : none;"); builder2.InnerHtml = builder2.InnerHtml + builder3; TagBuilder builder4 = GetTagBuilder("div", name, "dataHF"); builder4.MergeAttribute("style", "display:none;"); if ((data != null) && (data.Count > 0)) { data = DealWithNoteOpenState(data, openNote); builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(data); } else { using (context = new BizDataContext(true)) { ParameterExpression expression; // List<ITreeData> list2 = DealWithNoteOpenState(context.Set<T_Department>(). // Select<T_Department, TreeData>(Expression.Lambda<Func<T_Department, TreeData>>(Expression.MemberInit(Expression.New((ConstructorInfo) methodof(TreeData..ctor), new Expression[0]), new MemberBinding[] { Expression.Bind((MethodInfo) methodof(TreeData.set_id), Expression.Property(expression = Expression.Parameter(typeof(T_Department), "u"), (MethodInfo) methodof(T_Department.get_Department_ID))), Expression.Bind((MethodInfo) methodof(TreeData.set_name), Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Department_Name))), Expression.Bind((MethodInfo) methodof(TreeData.set_open), Expression.Constant(false, typeof(bool))), Expression.Bind((MethodInfo) methodof(TreeData.set_pId), Expression.Coalesce(Expression.Property(expression, (MethodInfo) methodof(T_Department.get_Parent_ID)), Expression.Constant(-1, typeof(int)))) }), new ParameterExpression[] { expression })).ToList<ITreeData>(), openNote); //builder4.InnerHtml = builder4.InnerHtml + serializer.Serialize(list2); } } builder2.InnerHtml = builder2.InnerHtml + builder4; TagBuilder builder5 = GetTagBuilder("input", name, "resultInput"); if (userStyle == UserStyle.Normal) { builder5.MergeAttribute("style", "float: left;"); } else { builder5.MergeAttribute("style", "float: left;display:none"); } builder5.MergeAttribute("type", "text"); if (validateOptions != null) { builder5.MergeAttribute("data-bvalidator", ValidateCommon.GetValidateAttr(validateOptions)); if (!string.IsNullOrEmpty(validateOptions.ErrorMsg)) { builder5.MergeAttribute("data-bvalidator-msg", validateOptions.ErrorMsg); } } builder5.MergeAttribute("readonly", "true"); TagBuilder builder6 = GetTagBuilder("input", name, "resultHf"); builder6.MergeAttribute("type", "hidden"); builder2.InnerHtml = builder2.InnerHtml + builder5; builder2.InnerHtml = builder2.InnerHtml + builder6; TagBuilder builder7 = GetTagBuilder("input", name, "treeButton"); builder7.MergeAttribute("type", "button"); builder7.MergeAttribute("value", "选择"); builder7.MergeAttribute("treeName", name); builder2.InnerHtml = builder2.InnerHtml + builder7; TagBuilder builder8 = GetTagBuilder("input", name, "selectedIDHf"); builder8.MergeAttribute("type", "hidden"); string str = string.Empty; if (!string.IsNullOrEmpty(value)) { string[] strArray = value.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries); using (context = new BizDataContext(true)) { IEnumerable <string> values = from u in context.FetchAll <T_User>() join suid in strArray on u.User_ID.ToString() equals suid select u.User_Name; str = string.Join(",", values); } builder8.MergeAttribute("value", value); } builder2.InnerHtml = builder2.InnerHtml + builder8; TagBuilder builder9 = GetTagBuilder("input", name, "selectedNameHF"); builder9.MergeAttribute("type", "hidden"); builder9.MergeAttribute("value", str); builder2.InnerHtml = builder2.InnerHtml + builder9; TagBuilder builder10 = GetTagBuilder("input", name, "configDataHF"); builder10.MergeAttribute("type", "hidden"); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("GetLeafURL", GetLeafURL); dictionary.Add("CallBackMethod", CallBackMethod); builder10.MergeAttribute("value", serializer.Serialize(dictionary)); builder2.InnerHtml = builder2.InnerHtml + builder10; builder.AppendLine(builder2.ToString()); builder.AppendLine(CtrlScripts.RenderScript(html, keyList)); return(MvcHtmlString.Create(builder.ToString())); }
private async Task <ApplicationUser> AutoProvisionUserAsync(string provider, string providerUserId, IEnumerable <Claim> claims) { // create a list of claims that we want to transfer into our store var filtered = new List <Claim>(); // user's display name var name = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Name)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Name)?.Value; if (name != null) { filtered.Add(new Claim(JwtClaimTypes.Name, name)); } else { var first = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.GivenName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.GivenName)?.Value; var last = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.FamilyName)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Surname)?.Value; if (first != null && last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first + " " + last)); } else if (first != null) { filtered.Add(new Claim(JwtClaimTypes.Name, first)); } else if (last != null) { filtered.Add(new Claim(JwtClaimTypes.Name, last)); } } HttpClient client = new HttpClient(); // email var email = claims.FirstOrDefault(x => x.Type == JwtClaimTypes.Email)?.Value ?? claims.FirstOrDefault(x => x.Type == ClaimTypes.Email)?.Value; if (email != null) { filtered.Add(new Claim(JwtClaimTypes.Email, email)); } short sexeId = 0; if (claims.FirstOrDefault(x => x.Type.Contains("gender")).Value.Contains("male")) { sexeId = 1; } else { sexeId = 2; } var user = new ApplicationUser { UserName = ("fb" + claims.FirstOrDefault(x => x.Type.Contains("givenname")).Value + claims.FirstOrDefault(x => x.Type.Contains("surname")).Value).ToLower(), Sexeid = sexeId, Birthday = DateTime.ParseExact(claims.FirstOrDefault(x => x.Type.Contains("dateofbirth")).Value, "MM/dd/yyyy", null), Email = claims.FirstOrDefault(x => x.Type.Contains("email")).Value, HairColorId = 1, CorpulenceId = 1, HairSizeId = 1, SexualityId = 1, ReligionId = 1, EmailConfirmed = true, LastName = claims.FirstOrDefault(x => x.Type.Contains("surname")).Value, Firstname = claims.FirstOrDefault(x => x.Type.Contains("givenname")).Value, AccountCompleted = false, IsFacebookAccount = true }; int cptUser = _context.AspNetUsers.Where(x => x.UserName.Contains(user.UserName)).Count(); if (cptUser != 0) { user.UserName += (cptUser + 1).ToString(); } user.UserName = RemoveSpecialCharacters(user.UserName); var identityResult = await _userManager.CreateAsync(user); if (!identityResult.Succeeded) { throw new Exception(identityResult.Errors.First().Description); } UserStyle userStyle = new UserStyle(); userStyle.Id = user.Id; userStyle.StyleId = 1; AspNetUserRole aspNetUserRole = new AspNetUserRole(); aspNetUserRole.UserId = user.Id; aspNetUserRole.RoleId = "Utilisateur"; _context.AspNetUserRoles.Add(aspNetUserRole); _context.UserStyles.Add(userStyle); _context.SaveChanges(); if (filtered.Any()) { identityResult = await _userManager.AddClaimsAsync(user, filtered); if (!identityResult.Succeeded) { throw new Exception(identityResult.Errors.First().Description); } } identityResult = await _userManager.AddLoginAsync(user, new UserLoginInfo(provider, providerUserId, provider)); if (!identityResult.Succeeded) { throw new Exception(identityResult.Errors.First().Description); } return(user); }
public async Task <IActionResult> EditStyle(string id, [Bind("Id, StyleId")] UserStyle userStyle) { // Préparation de l'appel à l'API string accessToken = await HttpContext.GetTokenAsync("access_token"); HttpClient client = new HttpClient(); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken); // Récurération des données et convertion des données dans le bon type string content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Account/getUserInfo"); AspNetUser aspNetUserFromClaim = JsonConvert.DeserializeObject <AspNetUser>(content); AspNetUser aspNetUser = aspNetUserFromClaim; UserStyle us = aspNetUserFromClaim.UserStyles.Single(d => d.Id == aspNetUserFromClaim.Id); if (id != userStyle.Id || id != aspNetUserFromClaim.Id) { return(NotFound()); } if (ModelState.IsValid) { // Préparation de la requête update à l'API StringContent httpContent = new StringContent(userStyle.ToJson(), Encoding.UTF8, "application/json"); HttpResponseMessage response = await client.PutAsync(_configuration["URLAPI"] + "api/Account/PutStyle", httpContent); if (response.StatusCode != HttpStatusCode.NoContent) { return(BadRequest()); } return(RedirectToAction(nameof(Details))); } // En cas d'erreur de modèle, il faut refournir à la vue les données... content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/corpulences"); List <Corpulence> corpulences = JsonConvert.DeserializeObject <List <Corpulence> >(content); ViewData["CorpulenceId"] = new SelectList(corpulences, "CorpulenceId", "CorpulenceName", aspNetUser.CorpulenceId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/hairColor"); List <HairColor> hairColors = JsonConvert.DeserializeObject <List <HairColor> >(content); ViewData["HairColorId"] = new SelectList(hairColors, "HairColorId", "HairColorName", aspNetUser.HairColorId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/hairSize"); List <HairSize> hairSizes = JsonConvert.DeserializeObject <List <HairSize> >(content); ViewData["HairSizeId"] = new SelectList(hairSizes, "HairSizeId", "HairSizeName", aspNetUser.HairSizeId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/sex"); List <Sex> sexs = JsonConvert.DeserializeObject <List <Sex> >(content); ViewData["SexeId"] = new SelectList(sexs, "SexeId", "SexeName", aspNetUser.SexeId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/sexuality"); List <Sexuality> sexualitiess = JsonConvert.DeserializeObject <List <Sexuality> >(content); ViewData["SexualityId"] = new SelectList(sexualitiess, "SexualityId", "SexualityName", aspNetUser.SexualityId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/subscription"); List <Subscription> subscriptions = JsonConvert.DeserializeObject <List <Subscription> >(content); ViewData["SubscriptionId"] = new SelectList(subscriptions, "SubscriptionId", "SubscriptionName", aspNetUser.SubscriptionId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/religions"); List <Religion> religions = JsonConvert.DeserializeObject <List <Religion> >(content); ViewData["ReligionId"] = new SelectList(religions, "ReligionId", "ReligionName", aspNetUser.ReligionId); content = await client.GetStringAsync(_configuration["URLAPI"] + "api/Data/styles"); List <Style> styles = JsonConvert.DeserializeObject <List <Style> >(content); ViewData["StyleId"] = new SelectList(styles, "StyleId", "StyleName", aspNetUser.UserStyles.Single().Style.StyleId); return(View(aspNetUser)); }