// Group: Functions // __________________________________________________________________________ /* Constructor: TextFileLanguage */ public TextFileLanguage(string name, PropertyLocation propertyLocation, bool alterLanguage = false) { this.name = name; this.namePropertyLocation = propertyLocation; this.alterLanguage = alterLanguage; simpleIdentifier = null; simpleIdentifierPropertyLocation = default; aliases = null; aliasesPropertyChange = PropertyChange.None; aliasesPropertyLocation = default; fileExtensions = null; fileExtensionsPropertyChange = PropertyChange.None; fileExtensionsPropertyLocation = default; shebangStrings = null; shebangStringsPropertyChange = PropertyChange.None; shebangStringsPropertyLocation = default; lineCommentSymbols = null; lineCommentSymbolsPropertyLocation = default; blockCommentSymbols = null; blockCommentSymbolsPropertyLocation = default; memberOperator = null; memberOperatorPropertyLocation = default; prototypeEnders = null; lineExtender = null; lineExtenderPropertyLocation = default; enumValues = null; enumValuesPropertyLocation = default; caseSensitive = null; caseSensitivePropertyLocation = default; }
GeocoderLocation IGeoCoder.Geocode(PropertyLocation address) { string queryAddress = string.Format(((IGeoCoder)this).UrlPattern, HttpUtility.UrlEncode(address.ToString())); if (!string.IsNullOrWhiteSpace(address.ZipCode)) { queryAddress = string.Format("{0}&components=postal_code:{1}|country:DE", queryAddress, address.ZipCode); } WebRequest request = WebRequest.Create(queryAddress); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { XDocument document = XDocument.Load(stream); XElement longitudeElement = document.Descendants("lng").FirstOrDefault(); XElement latitudeElement = document.Descendants("lat").FirstOrDefault(); if (longitudeElement != null && latitudeElement != null) { return(new GeocoderLocation() { Longitude = double.Parse(longitudeElement.Value, CultureInfo.InvariantCulture), Latitude = double.Parse(latitudeElement.Value, CultureInfo.InvariantCulture) }); } } } return(null); }
/* Function: SetFileExtensions * Sets the list of the file extensions for this language. If <AlterLanguage> is true then you must set either <PropertyChange.Add> * or <PropertyChange.Replace>. */ public void SetFileExtensions(IList <string> fileExtensions, PropertyLocation propertyLocation, PropertyChange propertyChange = PropertyChange.None) { #if DEBUG if (alterLanguage == true && propertyChange == PropertyChange.None) { throw new Exception("You must set PropertyChange when setting extensions on an Alter Language entry."); } if (alterLanguage == false && propertyChange != PropertyChange.None) { throw new Exception("You can't set PropertyChange when setting extensions on a non-Alter Language entry."); } #endif if (fileExtensions == null) { this.fileExtensions = null; } else { this.fileExtensions = new List <string>(fileExtensions.Count); this.fileExtensions.AddRange(fileExtensions); } this.fileExtensionsPropertyChange = propertyChange; this.fileExtensionsPropertyLocation = propertyLocation; }
// Group: Functions // __________________________________________________________________________ public TextFilePrototypeEnders(string commentType, PropertyLocation propertyLocation) { this.propertyLocation = propertyLocation; this.commentType = commentType; this.enderStrings = new List <string>(); }
// Group: Functions // __________________________________________________________________________ public OutputBase(PropertyLocation propertyLocation) : base(propertyLocation) { projectInfo = new ProjectInfo(); number = 0; numberPropertyLocation = Source.NotDefined; }
internal static string GetRouteAsStoredFile(PropertyLocation source, PropertyLocation destination) { if (!source.IsMeaningful) { Logger.Instance.LogFormat(LogType.Warning, typeof(RoutePlanHelper), Properties.Resources.NoSourceLocationDefined); return(null); } if (!destination.IsMeaningful) { Logger.Instance.LogFormat(LogType.Warning, typeof(RoutePlanHelper), Properties.Resources.NoDestinationLocationAvailable); return(null); } try { return(GetRouteAsStoredFileCore(source, destination)); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, typeof(RoutePlanHelper), Properties.Resources.RoutePlanHelperError); Logger.Instance.LogException(typeof(RoutePlanHelper), ex); } return(null); }
/* Function: SetShebangStrings * Sets the list of the shebang strings for this language. If <AlterLanguage> is true then you must set either <PropertyChange.Add> * or <PropertyChange.Replace>. */ public void SetShebangStrings(IList <string> shebangStrings, PropertyLocation propertyLocation, PropertyChange propertyChange = PropertyChange.None) { #if DEBUG if (alterLanguage == true && propertyChange == PropertyChange.None) { throw new Exception("You must set PropertyChange when setting shebang strings on an Alter Language entry."); } if (alterLanguage == false && propertyChange != PropertyChange.None) { throw new Exception("You can't set PropertyChange when setting shebang strings on a non-Alter Language entry."); } #endif if (shebangStrings == null) { this.shebangStrings = null; } else { this.shebangStrings = new List <string>(shebangStrings.Count); this.shebangStrings.AddRange(shebangStrings); } this.shebangStringsPropertyChange = propertyChange; this.shebangStringsPropertyLocation = propertyLocation; }
GeocoderLocation IGeoCoder.Geocode(PropertyLocation address) { //This format is required by osm --> StreetNumber before Street is the advice from OSM. string queryAdress = string.Format(((IGeoCoder)this).UrlPattern, HttpUtility.UrlEncode(address.StreetNumber + " " + address.Street + " " + address.ZipCode + " " + address.City)); WebRequest request = WebRequest.Create(queryAdress); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { XDocument document = XDocument.Load(stream); XElement placeElement = document.Descendants("place").FirstOrDefault(); if (placeElement != null) { XAttribute longitudeElement = placeElement.Attribute("lon"); XAttribute latitudeElement = placeElement.Attribute("lat"); if (longitudeElement != null && latitudeElement != null) { return(new GeocoderLocation() { Longitude = double.Parse(longitudeElement.Value, CultureInfo.InvariantCulture), Latitude = double.Parse(latitudeElement.Value, CultureInfo.InvariantCulture) }); } } } } return(null); }
protected void Page_Load(object sender, EventArgs e) { entities = new PropertyDbEntities(); int ID = Convert.ToInt32(Request.QueryString["PropertyID"]); PropertyDetail obj = entities.PropertyDetails.Where(x => x.PropertyID == ID).FirstOrDefault(); //lblPrice.Text = obj.Price.ToString(); PropertyLocation propertyLoc = entities.PropertyLocations.Where(x => x.PropertyID == obj.PropertyID).FirstOrDefault(); lblAddress.Text = propertyLoc.Address + propertyLoc.City + propertyLoc.Region; lblType.Text = entities.PropertyTypes.Where(x => x.TypeID == obj.TypeID).Select(y => y.Type).FirstOrDefault().ToString(); lblSubType.Text = entities.PropertySubtypes.Where(x => x.TypeID == obj.TypeID).Select(y => y.Subtype).FirstOrDefault().ToString(); lblSize.Text = obj.Size.ToString(); lblFloorLvl.Text = obj.FloorLevel.ToString(); lblTenure.Text = entities.PropertyTenures.Where(x => x.TenureID == obj.TenureID).Select(y => y.TenureType).FirstOrDefault().ToString(); lblDev.Text = obj.Developer.ToString(); lblListDate.Text = obj.ListedDate.ToString(); lblMRT.Text = obj.MRT.ToString(); lblSchool.Text = obj.School.ToString(); lblChildcare.Text = obj.ChildCare.ToString(); lblDesc.Text = obj.Description.ToString(); }
/// <summary> /// Renders the given operation using the provided template file and restricts the output to the given size. /// </summary> /// <param name="source">The source location to start. This is usually the fire department site.</param> /// <param name="operation">The operation to render.</param> /// <param name="templateFile">The HTML template file to use for layouting.</param> /// <param name="size">The maximum size of the created image.</param> /// <param name="timeout">The timeout to use for executing the script. The script will be terminated if it exceeds the duration.</param> /// <returns></returns> internal static Image RenderOperation(PropertyLocation source, Operation operation, string templateFile, Size size, TimeSpan timeout) { Image image = null; string tempFilePath = GetTemporaryHtmlFilePath(operation, templateFile); FileInfo fi = new FileInfo(tempFilePath); try { string html = CreateHtml(templateFile, source, operation); using (FileStream stream = fi.Create()) { fi.Attributes = FileAttributes.Temporary; byte[] content = Encoding.Default.GetBytes(html); stream.Write(content, 0, content.Length); } image = RenderOperationWithBrowser(fi, size, timeout); } catch (Exception ex) { Logger.Instance.LogException(typeof(TemplateRenderer), ex); } finally { if (!KeepTempHtmlAfterFinish) { fi.Delete(); } } return(image); }
private static string CreateHtml(string templateFile, PropertyLocation source, Operation operation) { StringBuilder sb = new StringBuilder(); IEnumerable <string> lines = File.ReadAllLines(templateFile).Where(_ => !string.IsNullOrWhiteSpace(_)); foreach (string item in lines) { string line = item; /* Replace some special lines we might expect... */ if (line.Contains("var var_awSource = null")) { line = string.Format("var var_awSource = {0};", Json.Serialize(source)); } else if (line.Contains("var var_awOperation = null")) { line = string.Format("var var_awOperation = {0};", Json.Serialize(operation)); } else { line = ObjectFormatter.ToString(operation, line); } sb.AppendLine(line); } return(sb.ToString()); }
/// <summary> /// Renders the given operation using the provided template file and restricts the output to the given size. /// </summary> /// <param name="source">The source location to start. This is usually the fire department site.</param> /// <param name="operation">The operation to render.</param> /// <param name="templateFile">The HTML template file to use for layouting.</param> /// <param name="size">The maximum size of the created image.</param> /// <returns></returns> internal static Image RenderOperation(PropertyLocation source, Operation operation, string templateFile, Size size) { TemplateObject to = new TemplateObject(); to.Operation = operation; to.RouteImageFilePath = RoutePlanHelper.GetRouteAsStoredFile(source, operation.Einsatzort); Image image = null; try { string html = CreateHtml(templateFile, to); image = RenderOperationWithBrowser(to, html, size); } catch (Exception ex) { Logger.Instance.LogException(typeof(TemplateRenderer), ex); } finally { TryDeleteRouteImageFile(to); } return(image); }
GeocoderLocation IGeoCoder.GeoCode(PropertyLocation address) { string queryAdress = string.Format(((IGeoCoder)this).UrlPattern, ((IGeoCoder)this).ApiKey, HttpUtility.UrlEncode(address.ToString())); WebRequest request = WebRequest.Create(queryAdress); using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { XDocument document = XDocument.Load(new StreamReader(stream)); XElement longitudeElement = document.Descendants("lng").FirstOrDefault(); XElement latitudeElement = document.Descendants("lat").FirstOrDefault(); if (longitudeElement != null && latitudeElement != null) { return(new GeocoderLocation { Longitude = Double.Parse(longitudeElement.Value, CultureInfo.InvariantCulture), Latitude = Double.Parse(latitudeElement.Value, CultureInfo.InvariantCulture) }); } } } return(null); }
/* Function: SetDisplayNameFromLocale * Sets the comment type's display name identifier to be retrieved from <Engine.Locale>. This will also set <DisplayName> * to null since the cannot both have values. */ public void SetDisplayNameFromLocale(string displayNameFromLocale, PropertyLocation propertyLocation) { this.displayNameFromLocale = displayNameFromLocale; this.displayNameFromLocalePropertyLocation = propertyLocation; this.displayName = null; this.displayNamePropertyLocation = default; }
// Group: Functions // __________________________________________________________________________ public SourceFolder(PropertyLocation propertyLocation) : base(propertyLocation) { folder = null; folderPropertyLocation = PropertySource.NotDefined; this.name = null; namePropertyLocation = PropertySource.NotDefined; }
/* Function: SetPluralDisplayName * Sets the comment type's plural display name. This will also set <PluralDisplayNameFromLocale> to null since they * cannot both have values. */ public void SetPluralDisplayName(string pluralDisplayName, PropertyLocation propertyLocation) { this.pluralDisplayName = pluralDisplayName; this.pluralDisplayNamePropertyLocation = propertyLocation; this.pluralDisplayNameFromLocale = null; this.pluralDisplayNameFromLocalePropertyLocation = default; }
private static string GetRouteAsStoredFileCore(PropertyLocation source, PropertyLocation destination) { int width = 800; int height = 800; // https://developers.google.com/maps/documentation/directions/?hl=de string originText = source.ToString(); string destinationText = destination.ToString(); StringBuilder sbInitialRequest = new StringBuilder(); sbInitialRequest.Append("http://maps.google.com/maps/api/directions/xml?"); sbInitialRequest.AppendFormat("origin={0}", HttpUtility.UrlEncode(originText)); sbInitialRequest.AppendFormat("&destination={0}", HttpUtility.UrlEncode(destinationText)); sbInitialRequest.Append("&sensor=false"); WebRequest wreqInitial = WebRequest.Create(sbInitialRequest.ToString()); XDocument docResponse = null; using (WebResponse wresInitial = wreqInitial.GetResponse()) { using (Stream stream = wresInitial.GetResponseStream()) { docResponse = XDocument.Load(stream); } string status = docResponse.Root.Element("status").Value; if (status != "OK") { Logger.Instance.LogFormat(LogType.Error, typeof(RoutePlanHelper), Properties.Resources.MapsRequestFailed, status); return(null); } } XElement overviewE = docResponse.Root.Element("route").Element("overview_polyline").Element("points"); StringBuilder sbContinuationRequest = new StringBuilder(); sbContinuationRequest.Append("http://maps.google.com/maps/api/staticmap?"); sbContinuationRequest.AppendFormat("size={0}x{1}", width, height); sbContinuationRequest.AppendFormat("&sensor=false&path=weight:3|color:red|enc:{0}", overviewE.Value); WebRequest wr1 = WebRequest.Create(sbContinuationRequest.ToString()); using (WebResponse res1 = wr1.GetResponse()) { using (Image image = Image.FromStream(res1.GetResponseStream())) { using (FileStream tempFile = File.OpenWrite(Path.GetTempFileName())) { image.Save(tempFile, ImageFormat.Png); return(tempFile.Name); } } } }
/// <summary> /// Initializes a new instance of the <see cref="OperationData"/> class. /// </summary> public OperationData() { Resources = new HashSet <OperationResourceData>(); DispositionedResources = new HashSet <DispositionedResourceData>(); Einsatzort = new PropertyLocation(); Zielort = new PropertyLocation(); Keywords = new OperationKeywords(); }
// Group: Functions // __________________________________________________________________________ public InputBase(PropertyLocation propertyLocation, Files.InputType type) : base(propertyLocation) { this.name = null; this.number = 0; this.type = type; namePropertyLocation = Source.NotDefined; numberPropertyLocation = Source.NotDefined; typePropertyLocation = propertyLocation; }
private PropertyLocation GetSourceLocation() { PropertyLocation loc = new PropertyLocation() { Street = _settings.GetSetting(SettingKeys.FDStreet).GetValue <string>(), StreetNumber = _settings.GetSetting(SettingKeys.FDStreetNumber).GetValue <string>(), City = _settings.GetSetting(SettingKeys.FDCity).GetValue <string>(), ZipCode = _settings.GetSetting(SettingKeys.FDZipCode).GetValue <string>(), }; return(loc); }
internal static string GetRouteAsStoredFile(PropertyLocation source, PropertyLocation destination) { try { return(GetRouteAsStoredFileCore(source, destination)); } catch (Exception ex) { Logger.Instance.LogFormat(LogType.Error, typeof(RoutePlanHelper), Resources.RoutePlanHelperError); Logger.Instance.LogException(typeof(RoutePlanHelper), ex); } return(null); }
/* Function: SetLineCommentSymbols * Sets the list of strings that start line comments. */ public void SetLineCommentSymbols(IList <string> lineCommentSymbols, PropertyLocation propertyLocation) { if (lineCommentSymbols == null || lineCommentSymbols.Count == 0) { this.lineCommentSymbols = null; } else { this.lineCommentSymbols = new List <string>(lineCommentSymbols.Count); this.lineCommentSymbols.AddRange(lineCommentSymbols); } this.lineCommentSymbolsPropertyLocation = propertyLocation; }
private static XElement WritePropertyLocation(string name, PropertyLocation propertyLocation) { XElement element = new XElement(name); element.Add(CreateXElement(() => propertyLocation.Street)); element.Add(CreateXElement(() => propertyLocation.StreetNumber)); element.Add(CreateXElement(() => propertyLocation.ZipCode)); element.Add(CreateXElement(() => propertyLocation.City)); element.Add(CreateXElement(() => propertyLocation.Intersection)); element.Add(CreateXElement(() => propertyLocation.Property)); element.Add(CreateXElement(() => propertyLocation.GeoLatitude)); element.Add(CreateXElement(() => propertyLocation.GeoLongitude)); return(element); }
/* Function: AddTag * Adds a tag to the file. */ public void AddTag(string tag, PropertyLocation propertyLocation) { if (tags == null) { tags = new List <string>(); } tags.Add(tag); // Only add the first one, ignore subsequent ones if (!tagsPropertyLocation.IsDefined) { tagsPropertyLocation = propertyLocation; } }
// Group: Functions // __________________________________________________________________________ /* Function: AddIgnoredFileExtensions * Adds a set of ignored file extensions to the file. There can be more than one. */ public void AddIgnoredFileExtensions(IList <string> fileExtensions, PropertyLocation propertyLocation) { if (ignoredFileExtensions == null) { ignoredFileExtensions = new List <string>(fileExtensions.Count); } ignoredFileExtensions.AddRange(fileExtensions); // Only use the first one if (!ignoredFileExtensionsPropertyLocation.IsDefined) { ignoredFileExtensionsPropertyLocation = propertyLocation; } }
private byte[] DownloadRoutePlan(Operation operation) { PropertyLocation source = GetFDLocation(); if (!source.IsMeaningful) { Logger.Instance.LogFormat(LogType.Warning, this, Resources.RoutePlanningSourceLocationNotMeaningful, source); return(null); } PropertyLocation destination = operation.GetDestinationLocation(); if (!operation.GetDestinationLocation().IsMeaningful) { Logger.Instance.LogFormat(LogType.Warning, this, Resources.DestinationLocationIsUnknown); return(null); } Logger.Instance.LogFormat(LogType.Trace, this, Resources.DownloadRoutePlanBegin, destination.ToString()); Stopwatch sw = Stopwatch.StartNew(); try { byte[] imageBuffer = GoogleMapsProvider.GetRouteImage(source, destination); sw.Stop(); if (imageBuffer == null) { Logger.Instance.LogFormat(LogType.Warning, this, Resources.DownloadRoutePlanFailed); } else { Logger.Instance.LogFormat(LogType.Trace, this, Resources.DownloadRoutePlanSuccess, sw.ElapsedMilliseconds); } return(imageBuffer); } catch (Exception ex) { sw.Stop(); Logger.Instance.LogFormat(LogType.Error, this, Resources.DownloadRoutePlanError); Logger.Instance.LogException(this, ex); } return(null); }
private PropertyLocation GetZielort(OperationData entity) { PropertyLocation pl = new PropertyLocation(); pl.Street = entity.ZielortStreet; pl.StreetNumber = entity.ZielortStreetNumber; pl.ZipCode = entity.ZielortZipCode; pl.City = entity.ZielortCity; pl.Intersection = entity.ZielortIntersection; pl.Location = entity.ZielortLocation; pl.Property = entity.ZielortProperty; string[] latlng = entity.ZielortLatLng.Split(';'); pl.GeoLatitude = latlng[0]; pl.GeoLongitude = latlng[1]; return(pl); }
/// <summary> /// Renders the given operation using the provided template file and restricts the output to the given size. /// </summary> /// <param name="source">The source location to start. This is usually the fire department site.</param> /// <param name="operation">The operation to render.</param> /// <param name="templateFile">The HTML template file to use for layouting.</param> /// <param name="size">The maximum size of the created image.</param> /// <returns></returns> internal static Image RenderOperation(PropertyLocation source, Operation operation, string templateFile, Size size) { TemplateObject to = new TemplateObject(); to.Operation = operation; to.RouteImageFilePath = RoutePlanHelper.GetRouteAsStoredFile(source, operation.Einsatzort); // Create HTML to render StringBuilder sb = new StringBuilder(); foreach (string line in File.ReadAllLines(templateFile)) { sb.AppendLine(ObjectFormatter.ToString(to, line)); } Image image = RenderOperationWithBrowser(to, sb.ToString(), size); TryDeleteRouteImageFile(to); return(image); }
// Group: Functions // __________________________________________________________________________ /* Constructor: TextFileCommentType */ public TextFileCommentType(string name, PropertyLocation propertyLocation, bool alterType = false) { this.name = name; this.namePropertyLocation = propertyLocation; this.alterType = alterType; displayName = null; displayNamePropertyLocation = default; displayNameFromLocale = null; displayNameFromLocalePropertyLocation = default; pluralDisplayName = null; pluralDisplayNamePropertyLocation = default; pluralDisplayNameFromLocale = null; pluralDisplayNameFromLocalePropertyLocation = default; simpleIdentifier = null; simpleIdentifierPropertyLocation = default; scope = null; scopePropertyLocation = default; keywordGroups = null; flags = null; flagsPropertyLocation = default; }
private static PropertyLocation GetFDLocation() { if (FDLocation == null) { FDLocation = new PropertyLocation(); try { using (var service = ServiceFactory.GetCallbackServiceWrapper <ISettingsService>(new SettingsServiceCallback())) { FDLocation.Street = service.Instance.GetSetting(SettingKeys.FDStreet).GetValue <string>(); FDLocation.StreetNumber = service.Instance.GetSetting(SettingKeys.FDStreetNumber).GetValue <string>(); FDLocation.ZipCode = service.Instance.GetSetting(SettingKeys.FDZipCode).GetValue <string>(); FDLocation.City = service.Instance.GetSetting(SettingKeys.FDCity).GetValue <string>(); } } catch (Exception ex) { Logger.Instance.LogException(typeof(OperationToRouteImageConverter), ex); } } return(FDLocation); }