Beispiel #1
0
 /// <remarks/>
 public void FindAddressAsync(FindAddressSpecification specification, object userState) {
     if ((this.FindAddressOperationCompleted == null)) {
         this.FindAddressOperationCompleted = new System.Threading.SendOrPostCallback(this.OnFindAddressOperationCompleted);
     }
     this.InvokeAsync("FindAddress", new object[] {
                 specification}, this.FindAddressOperationCompleted, userState);
 }
Beispiel #2
0
 public FindResults FindAddress(FindAddressSpecification specification) {
     object[] results = this.Invoke("FindAddress", new object[] {
                 specification});
     return ((FindResults)(results[0]));
 }
Beispiel #3
0
 /// <remarks/>
 public void FindAddressAsync(FindAddressSpecification specification) {
     this.FindAddressAsync(specification, null);
 }
Beispiel #4
0
    /*
    *********************************************************************************************************
    *                                              GetDirectionsFromAdress()
    *
    * Description : Cette fonction effectue un appel au service web MapPoint afin de rechercher deux 
    *               adresses dans le but d'éventuellement tracer un trajet dans une image
    *
    * Argument(s) : strOrigAddress  L'adresse de départ
    *               strDestAddress  L'adresse de la destination 
    * 
    * Note        : Le format du string à passer en argument à la fonction est celui-ci:
    *               "ADRESSE;VILLE;PROVINCE;CODE POSTAL;PAYS"  
    *               ex: strOrigAddress = "1408 RUE DE L'EGLISE;SAINT-LAURENT;QC;H4L2H3;CA";
    *********************************************************************************************************
    */
    public static void GetDirectionsFromAdress(string strOrigAddress, string strDestAddress)
    {
        FindServiceSoap findService = new FindServiceSoap();
        findService.Credentials = new System.Net.NetworkCredential("124624", "PDALE_projets5");
        FindSpecification findSpec = new FindSpecification();
        FindResults startResults = null;
        FindResults endResults = null;


        //Output the formatted address
        string [] strTemp = new String[5];
        strTemp = strOrigAddress.Split(';');

        Address myOrigAddress = new Address();
        myOrigAddress.AddressLine = strTemp[0];
        myOrigAddress.PrimaryCity = strTemp[1];
        myOrigAddress.Subdivision = strTemp[2];
        myOrigAddress.PostalCode = strTemp[3];
        myOrigAddress.CountryRegion = "CA";

        FindAddressSpecification findOrigAddressSpec = new FindAddressSpecification();
        findOrigAddressSpec.InputAddress = myOrigAddress;
        findOrigAddressSpec.DataSourceName = "MapPoint.NA";

        //Retrieve the values of startResults
        try
        {
            startResults = findService.FindAddress(findOrigAddressSpec);
        }
        catch (Exception e2)  //The request failed with HTTP status 401: Unauthorized.
        {
            Console.WriteLine("Problem connecting with service");
        }

        //Output the formatted address
        strTemp = strDestAddress.Split(';');

        Address myDestAddress = new Address();
        myDestAddress.AddressLine = strTemp[0];
        myDestAddress.PrimaryCity = strTemp[1];
        myDestAddress.Subdivision = strTemp[2];
        myDestAddress.PostalCode = strTemp[3];
        myDestAddress.CountryRegion = "CA";

        FindAddressSpecification findDestAddressSpec = new FindAddressSpecification();
        findDestAddressSpec.InputAddress = myDestAddress;
        findDestAddressSpec.DataSourceName = "MapPoint.NA";

        //Retrieve the values of endResults
        try
        {
            endResults = findService.FindAddress(findDestAddressSpec);
        }
        catch
        {
            Console.WriteLine("Problem connecting with service");
        }

        // Make sure findResults isn't null
        if (startResults == null)
        {
            Console.WriteLine("Originating Address not found.");
        }
        else
        {
            // If no results were found, display error and return
            if (startResults.NumberFound == 0)
            {
                Console.WriteLine("Originating Address not found.");
                return;
            }
        }
        if (endResults == null)
        {
            Console.WriteLine("Destination Address not found.");
        }
        else
        {
            // If no results were found, display error and return
            if (endResults.NumberFound == 0)
            {
                Console.WriteLine("Destination Address not found.");
                return;
            }
        }

        //Call GetRoute:Calculates the Route and also generates the Map
        GetRoute(startResults, endResults);
    }