vendredi 14 juillet 2017

ASP.NET If statement based on Power Shell result

I have a simple Google Maps page that functions with a generic If statement. Right now it just changes the image for a marker based on what time it is. But, I really need it to change based on the result of a Power Shell script.

Here's the current code for my map:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Map.aspx.cs" Inherits="Maps.Map" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Store Locations</title>
</head>
<body>

    <div id="map" style="width:1600px;height:800px"></div>
    <script>
    function myMap() {
    var mapOptions = {
        center: new google.maps.LatLng(29.7604, -95.3698),
    zoom: 8,
    mapTypeId: google.maps.MapTypeId.HYBRID
        }
        var time = new Date().getHours();
        var url;
        var scaledSize = new google.maps.Size(64, 64);
        if (time > 3) {
            url = "Images/greenmarker.png";
        }
        else {
            url = "Images/marker.png";
        }
        var map = new google.maps.Map(document.getElementById("map"), mapOptions);
        var marker = new google.maps.Marker({
            position: { lat: 29.7604, lng: -95.3698 },
            map: map,
            title: 'Houston,TX',
            icon: {
                url: url,
            scaledSize: scaledSize}
            }
        );
        google.maps.event.addListener(marker, 'click', function () {
            window.location.href = 'http://contoso.com';
        });
        }
    </script>
    <script src="http://ift.tt/2tStW7f"></script>
</body>
</html>

And my CS file is pretty much blank. This is where I really have problems. I need to be able to just run a Power Shell script as soon as the page loads and the results be usable in my if statement above.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

namespace Maps
{
    public partial class Map : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}

Any help would be greatly appreciated.

Thank you,

Gary Winhoven

Aucun commentaire:

Enregistrer un commentaire