MAP+PLUS
Version 2.2
Version 2.2
  • Einleitung
  • Allgemeines
    • Routenoptimierung
    • Digitale Stecknadelkarte
    • Adress Score
  • Einrichtung
    • Installation
    • Lizenz aktivieren
    • Einstellungen
      • Feldzuordnungen
      • Landkarte
      • Gruppen
    • Geokoordinaten aktualisieren
    • Fehlerhafte Adressen recherchieren
    • Virtuelle Felder
  • Aktualisierung
    • Aktualisierung von MAP+PLUS
    • Aktualisierung von cobra
  • Funktionen
    • Kartendarstellung
      • Karte öffnen
      • Adresse auf Karte anzeigen
      • Einzelnen Layer anzeigen
      • Gruppierte Layer anzeigen
    • Umkreisfunktionen
      • Karte mit Radius öffnen
      • Umkreisrecherche
    • Routen
      • Routenplanung / -optimierung
        • Routenplanung
        • Reihenfolge optimieren
        • Routenoptimierung
        • Routenprofile
        • Darstellung der Wegepunkte bearbeiten
        • Ausgabe der Route
    • Messen von Entfernungen
  • Map-Layer konfigurieren
    • Map-Layer konfigurieren
    • Datengrundlage
      • Aktuelle Recherche
      • Alle Adressen
      • Filter
      • Geparkte Recherche
    • Feld-Typ
      • Text
      • Bool
      • Zahl
      • Kein
    • Symbole
      • Symbol Übersicht
      • Bilder als Symbol
  • Digitale Landkarte
    • Digitale Landkarte
    • Navigation
    • Schaltkreuz
    • Skalieren
    • Layer
  • Experteneinstellungen
    • MapPlusSettings.json
      • AllowedCountries
      • ClusterItems
      • MapCacheSettings
      • RecommendedLocationDisplayCount
      • StrokeColor und StrokeWidth
      • UseDirectX
  • PRINT+PLUS
    • Standorte
  • Versionen
    • Neue Funktionen in Version 2.2.0
    • Version 2.2.x
  • Hilfe
    • Hilfe
    • Videos
  • FAQs
    • Fehlermeldungen
    • Terminalserver Lizenz
Powered by GitBook

p17 GmbH

  • Impressum

p17 GmbH | Mühlenmathe 50 | 48599 Gronau

On this page
  1. PRINT+PLUS

Standorte

Kombinieren Sie MAP+PLUS mit PRINT+PLUS und geben Sie Standortinformationen auf Ihren Dokumenten aus.

Das nachfolgende Skript ermittelt umliegende Standorte für die Ausgabe in PRINT+PLUS.

namespace Ruthardt.PrintPlus.Skripting
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Data.SqlClient;
    using System.IO;
    using System.Linq;
    using System.Windows.Forms;
    using Ruthardt.CobraBase.Functions.Access.Ado;
    using Ruthardt.CobraFramework.Ado;
    using Ruthardt.PrintPlus.Export.Context;
    using Ruthardt.PrintPlus.Model.Interfaces;
    using Ruthardt.PrintPlus.Model.Configuration;

    public class ExampleScript : IScriptAction
    {
        public void Execute(IPrintContext printContext, ICurrentContext currentContext, IChildContext childContext)
        {
            var currentAdoView = currentContext.AdoView;

            var addressAdoView = currentContext.ParentAdoViewByPrefix["Adresse"];
            string sql = 
                "DECLARE @origin geography " + 
                "SELECT @origin = (SELECT Location FROM Ruthardt_Locations WHERE SUPERID = @AdressId) " + 
                "SELECT TOP(3) Ruthardt_Locations.SuperId, Location.STDistance(@origin) as DISTANCE "+
                "FROM Ruthardt_Locations " +
                "JOIN [#Adressen#] ON Ruthardt_Locations.SuperId = [#Adressen.ID#] "+
                "WHERE Ruthardt_Locations.Location IS NOT NULL " +
                "AND Ruthardt_Locations.TotalScore > 70 " +
                "AND [#Adressen.Kundenart#] = 'Intern' " +
                "AND [#Adressen.Haupt#] = 'H' " +
                "ORDER BY Ruthardt_Locations.Location.STDistance(@origin) ASC";

            var table = printContext.AdoAccess.GetTable(sql, new SqlParameter("@AdressId", addressAdoView.CurrentKey));
            var addressIdsWithDistance = table.Rows.Cast<DataRow>().ToDictionary(row => (int)row["SuperId"], row => (double)row["DISTANCE"]);

            var standortTable = printContext.AdoAccess.GetTable("SELECT * FROM [#Adressen#] WHERE ID IN (" + string.Join(",", addressIdsWithDistance.Keys) + ")");

            var configNode = printContext.Config.Current.Children.First(node => node.Prefix == "Standorte");
            var standorte = new List<IChildContext>();
            foreach(DataRow row in standortTable.Rows)
            {
                var adoView = new AdoView(row, "Adressen", printContext.AdoAccess);

                var distance = addressIdsWithDistance[(int)row["ID"]];
                string stringDistance;
                if (distance == 0)
                {
                    stringDistance = string.Empty;
                }
                else if (distance < 1000)
                {
                    stringDistance = Math.Round(distance / 1000, 1).ToString("n1") + " km";
                }
                else
                {
                    stringDistance = Math.Round(distance / 1000, 0).ToString("n0") + " km";
                }

                adoView.SetValue("Distanz_Standort", stringDistance);
                adoView.SetValue("Distanz_Standort_Zahl", distance);

                standorte.Add(new ChildContext(adoView, currentContext, configNode));
            }

            currentContext.ChildContextByPrefix["Standorte"] = standorte.OrderBy(standort => standort.AdoView.GetDecimalValue("Distanz_Standort_Zahl")).ToList();
        }
    }
}

PreviousUseDirectXNextNeue Funktionen in Version 2.2.0

Last updated 3 years ago