コード例 #1
0
        public void drawosmmap()
        {
            mapwithanimation = "";
            try
            {
                DataTable   dt     = new DataTable();
                ibuckethead bucket = new ibuckethead();

                SqlCommand cmd = new SqlCommand(@"SELECT STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT
						'ol.proj.transform(['  + l_long + ','+ l_lat+'], 'EPSG:4326','EPSG:3857'),' as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'						 
                            ) alldata order by CONVERT(time, replace(l_time,' ','')) asc
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
 STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						' User ID : ' +userid +'<br/>User Name : '+ username +'<br/> Mobile No : '+ mobile   as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'						 
                            ) alldata order by CONVERT(time, replace(l_time,' ','')) asc
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
 STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						'ol.proj.transform(['  + l_long + ','+ l_lat+'], &apos;EPSG:4326&apos;,&apos;EPSG:3857&apos;),' as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		order by CONVERT(time, replace(l_time,' ','')) asc	 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						'ol.proj.transform(['  + l_long + ','+ l_lat+'], &apos;EPSG:4326&apos;,&apos;EPSG:3857&apos;),' as[Data],l_time
						from [location30days]
						where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		order by CONVERT(time, replace(l_time,' ','')) desc				 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (										
						SELECT top 1000
                        '[' + lat + ','+ lon+ ', '+CHAR(39)+'PM Date Time : '+Convert(varchar(10),Convert(date,vdate),103)+' '+vtime+'<br/>ATMID : '+ATMID+ CHAR(39)+']|' as[Data],vtime,vdate,ATMID
						from DR_CTP
						where vdate ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						and CONVERT(time, replace(vtime,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		
						 order by CONVERT(time, replace(vtime,' ','')) asc				 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            )");
                //   Response.Write(cmd.CommandText);
                cmd.CommandTimeout = 999999;
                dt = bucket.GetData(cmd);

                string    dailyvisit = "";
                DataTable dtcheckin  = new DataTable();
                // dtcheckin = bucket.BindoboutGrid(dailyvisit, out rows);

                string path     = "";
                string uadd     = "";
                string uaddlast = "";

                string incoords = "";
                string outcoords = "";
                string daudits = ""; string auditcoords = "";
                if (dt.Rows.Count > 0)
                {
                    path += dt.Rows[0][0].ToString();

                    string[] inparts = dt.Rows[0][2].ToString().Split(',');
                    incoords  = inparts[0].Replace('[', ' ') + inparts[1].Replace(']', ' ');
                    incoords  = dt.Rows[0][2].ToString();
                    outcoords = dt.Rows[0][3].ToString();
                    uadd      = dt.Rows[0][1].ToString();
                    uaddlast  = dt.Rows[0][1].ToString();

                    // daudits = dt.Rows[0][4].ToString();
                    //auditcoords += "ol.proj.transform([" + dtcheckin.Rows[i][4].ToString() + ", " + dtcheckin.Rows[i][3].ToString() + "], 'EPSG:4326','EPSG:3857'),";//"[" + dt.Rows[i][3].ToString() + ", " + dt.Rows[i][4].ToString() + "],";

                    try
                    {
                        string[] inparts1 = new string[] { };
                        //string[] inparts1 = dt.Rows[0][4].ToString().Split(',');
                        string[] inparts2 = dt.Rows[0][4].ToString().Split('|');

                        for (int i = 0; i < inparts2.Length; i++)
                        {
                            inparts1 = inparts2[i].Split(',');

                            auditcoords += "ol.proj.transform([" + inparts1[1].Replace('[', ' ') + ", " + inparts1[0].Replace('[', ' ') + "], 'EPSG:4326','EPSG:3857'),";//"[" + dt.Rows[i][3].ToString() + ", " + dt.Rows[i][4].ToString() + "],";

                            //daudits += inparts1[2].Replace(']', ' ');

                            daudits += "[" + inparts1[2] + ",";
                        }
                    }
                    catch (Exception ex) { }
                }

                mapwithanimation = @"<script>
        try{ 
       setTimeout(function(){ 
        debugger;
            var
                sourceFeatures = new ol.source.Vector(),
                layerFeatures = new ol.layer.Vector({
                    source: sourceFeatures
                });

            var container = document.getElementById('popup');
            var content = document.getElementById('popup-content');
            var closer = document.getElementById('popup-closer');

            var overlay = new ol.Overlay(/** @type {olx.OverlayOptions} */({
                element: container,
                autoPan: true,
                autoPanAnimation: {
                    duration: 250
                }
            }));

            closer.onclick = function () {
                document.getElementById('popup-content').innerHTML = '';
                overlay.setPosition(undefined);
                closer.blur();
                return false;
            };

            var lineString = new ol.geom.LineString([]);

            var layerRoute = new ol.layer.Vector({
                source: new ol.source.Vector({
                    features: [
                        new ol.Feature({ geometry: lineString })
                    ]
                }),
                style: [
                    new ol.style.Style({
                        stroke: new ol.style.Stroke({
                            width: 3, color: 'rgba(255, 0, 0, 1)'
                            //lineDash: [.1, 5]
                        }),
                        zIndex: 2
                    })
                ],
                updateWhileAnimating: true
            });

            var loc = [" + incoords + @"]; 
            var map = new ol.Map({
                target: 'map',
                view: new ol.View({
                    center: loc[0],
                    zoom: 4,
                    minZoom: 2,
                    maxZoom: 20
                }),
                layers: [
                    new ol.layer.Tile({
                        source: new ol.source.OSM(),
                        opacity: 0.6
                    }),
                    layerRoute, layerFeatures
                ],
                overlays: [overlay]
            });
            
            var iconFeatures = [];
            
                var view = map.getView();
                var extent = ol.extent.boundingExtent([" + path.TrimEnd(',') + @"]);
                var size = map.getSize();
                view.fit(extent, size);
                if (view.getZoom() > 16) {
                    view.setZoom(9);
                }            

            var CheckInloc=[" + incoords.TrimEnd(',') + @"]; 
           
            var CheckIniconFeature = new ol.Feature({
                geometry: new ol.geom.Point(CheckInloc[0]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name:  '" + uadd + @"',
                type:'user',
                population: 4000,
                rainfall: 500
            });
            CheckIniconFeature.setStyle(new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    //color: '#8959A8',
                    //crossOrigin: 'anonymous',
                    anchor: [0.5, 30],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    src: 'http://maps.google.com/mapfiles/ms/icons/green-dot.png'
                }))
            }));
            iconFeatures.push(CheckIniconFeature);
            
            var CheckOutloc=[" + outcoords.TrimEnd(',') + @"]; 
            var CheckouticonFeature = new ol.Feature({
                geometry: new ol.geom.Point(CheckOutloc[0]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name: '" + uaddlast + @"',
                type:'user',
                population: 4000,
                rainfall: 500
            });
            CheckouticonFeature.setStyle(new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    //color: '#8959A8',
                    //crossOrigin: 'anonymous',
                    anchor: [0.5, 30],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    src: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
                }))
            }));
            iconFeatures.push(CheckouticonFeature);            
                     
            var auditCoor = [ " + daudits.TrimEnd(',') + @"];
           
            var j=1;
            var loc1 = [" + auditcoords.TrimEnd(',') + @"]; 

          for (i = 0; i < auditCoor.length; i++) {
            debugger;
            
            var iconFeature = new ol.Feature({
                geometry: new ol.geom.Point(loc1[i]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name: auditCoor[i],
                type:'audit',
                population: 4000,
                rainfall: 500
            });

            iconFeature.setStyle(new ol.style.Style({
                            image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                                //color: '#8959A8',
                                //crossOrigin: 'anonymous',
                                anchor: [0.5, 30],
                                anchorXUnits: 'fraction',
                                anchorYUnits: 'pixels',
                                src: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+(j)+'|8E67FD|FFFFFF'
                            }))
                        }));
            iconFeatures.push(iconFeature);
            j++;           
            }

            var vectorSource = new ol.source.Vector({
                features: iconFeatures //add an array of features
            });

            var iconStyle = new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    anchor: [0.5, 46],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    opacity: 0.75,
                    src: 'http://openlayers.org/en/v3.9.0/examples/data/icon.png',
                }))
            });

            var vectorLayer = new ol.layer.Vector({
                source: vectorSource,
                //style: iconStyle
            });

            map.addOverlay(vectorLayer);

            var markerEl = document.getElementById('geo-marker');
            var marker = new ol.Overlay({
                positioning: 'center-center',
                offset: [5, 0],
                element: markerEl,
                stopEvent: false
            });

            var element = document.getElementById('popupinfo');
            var popup = new ol.Overlay({
                element: element,
                positioning: 'bottom-center',
                stopEvent: false,
                offset: [9, -21]
            });
            map.addOverlay(popup);

            map.on('click', function (evt) {
            debugger;
                var feature = map.forEachFeatureAtPixel(evt.pixel,
                    function (feature) {
                        return feature;
                    });
                if (feature) {
                    var coordinates = feature.getGeometry().getCoordinates();
                    var longlat = ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
                    popup.setPosition(coordinates);
                    
                    var sid = GetResults(longlat[1], longlat[0]);
                    //var sid='brijesh';
                   // content.innerHTML = '<p>'+ feature.O.name+ '<br/>'+'Address : '+ sid.display_name+'</p>';
                    
content.innerHTML = '<p>'+ feature.get('name')+ '<br/>'+'Address : '+ sid.display_name+'</p>';
                    
                     overlay.setPosition(coordinates);
                } else { 
                     overlay.setPosition(undefined);
                     closer.blur();
                }

            });

            map.addOverlay(marker);

            var fill = new ol.style.Fill({ color: 'rgba(255,255,255,1)' }),
                stroke = new ol.style.Stroke({ color: 'rgba(0,0,0,1)' }),
                style1 = [
                    new ol.style.Style({
                        image: new ol.style.Circle({
                            radius: 6, fill: fill, stroke: stroke
                        }),
                        zIndex: 4
                    })
                ];

            //a simulated path
            var path = [
                 " + path.TrimEnd(',') + @"
            ];

            var feature_start = new ol.Feature({
                geometry: new ol.geom.Point(path[0])
            }),
                feature_end = new ol.Feature({
                    geometry: new ol.geom.Point(path[path.length - 1])
                });

            feature_start.setStyle(style1);
            feature_end.setStyle(style1);
            sourceFeatures.addFeatures([feature_start, feature_end]);

            lineString.setCoordinates(path);  

            //fire the animation
            map.once('postcompose', function (event) {
                interval = setInterval(animation, 100);
            });

            var i = 0, interval;
            var animation = function () {

                if (i == path.length) {
                    i = 0;
                }

                marker.setPosition(path[i]);
                i++;
            };
        }, 300);
}
catch(ee)
{
    alert(ee);
}
                    
function GetResults(lat, long) {
                var jsonObjectInstance = $.parseJSON($.ajax({
                    url: 'https://locationiq.org/v1/reverse.php?format=json&key=9c73f8c9ed5d47&lat=' + lat + '&lon=' + long,     
                    async: false,
                    dataType: 'json'
                }).responseText); return jsonObjectInstance
            } 

</script>";
            }
            catch (Exception)
            {
                mapwithanimation = "<div style='font-size:x-large;text-align:center;font-family:Cambria, Cochin, Georgia, Times;color:#696969;'>No details found..</div>" + @"<script> var container = document.getElementById('popup');
                var geo = document.getElementById('geo-marker');
                container.style.display = 'none';  geo.style.display = 'none';
                </script>";
            }
            //   map.InnerHtml = mapwithanimation;
            Session["sess_x"] = mapwithanimation;
        }
コード例 #2
0
        public void drawmap()
        {
            mapwithanimation = "";
            try
            {
                DataTable   dt     = new DataTable();
                ibuckethead bucket = new ibuckethead();
                SqlCommand  cmd    = new SqlCommand(@"SELECT STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT
						'{ lat: '  + l_lat + ', lng:'+ l_long+'},' as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'						 
                            ) alldata order by CONVERT(time, replace(l_time,' ','')) asc
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
 STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						' User ID : ' +userid +'<br/>Engineer Name : '+ username +'<br/> Mobile No : '+ contactno   as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'						 
                            ) alldata order by CONVERT(time, replace(l_time,' ','')) asc
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
 STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						'[' + l_lat + ','+ l_long+'],' as[Data],l_time
						from [location30days]
						 where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		order by CONVERT(time, replace(l_time,' ','')) asc	 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),
STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1
						'[' + l_lat + ','+ l_long+'],' as[Data],l_time
						from [location30days]
						where l_date ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						 and CONVERT(time, replace(l_time,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		order by CONVERT(time, replace(l_time,' ','')) desc				 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            ),

STUFF(
                 (
                      SELECT  CAST([Data] AS XML)
                      FROM
                      (						
						
						SELECT top 1000
                        '[' + lat + ','+ lon+ ', '+CHAR(39)+' PM Date Time : '+Convert(varchar(10),Convert(date,vdate),103)+' '+vtime+'<br/>ATMID : '+ATMID+ CHAR(39)+'],' as[Data],vtime,vdate,ATMID
						from DR_CTP
						where vdate ='"                         + txt_frmDate.Text + @"' and userid = '" + uid + @"'
						and CONVERT(time, replace(vtime,' ','')) between '"                         + ddFromTime.SelectedValue + "' and '" + ddToTime.SelectedValue + @"'		
						 order by CONVERT(time, replace(vtime,' ','')) asc				 
                            ) alldata 
                        FOR XML PATH('')
                    )
                ,   1
                ,   0
                ,   ''
            )");

                //    Response.Write(cmd.CommandText);
                cmd.CommandTimeout = 999999;
                dt = bucket.GetData(cmd);


                string usercoor = "";
                string lat      = "";
                string lng      = "";
                string path     = "";
                string uadd     = "";
                string audits   = "";
                if (dt.Rows.Count > 0)
                {
                    path += dt.Rows[0][0].ToString();

                    string[] parts = dt.Rows[0][2].ToString().Split(',');
                    lat       = parts[0].Replace('[', ' ');
                    lng       = parts[1].Replace(']', ' ');
                    usercoor += dt.Rows[0][2].ToString() + dt.Rows[0][3].ToString();
                    uadd      = dt.Rows[0][1].ToString();

                    try
                    {
                        audits += dt.Rows[0][4].ToString();
                    }
                    catch (Exception ex) { }
                }

                mapwithanimation = @"<script>
try{ 
function initMap() {          
            var userCoor = [ " + usercoor.TrimEnd(',') + @"];
            var auditCoor = [" + audits.TrimEnd(',') + @"]
            var uaddress = '" + uadd + @"';
            var map = new google.maps.Map(document.getElementById('map'), {

                 center: { lat: " + lat + @" ,lng: " + lng + @"},
                zoom: 10,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            });

            // Define the symbol, using one of the predefined paths ('CIRCLE')
            // supplied by the Google Maps JavaScript API.
            var a= 0;
           
           
            
                var lineSymbol = {
                path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
                scale: 2,
                strokeColor: '#0000FF'
                };
            
            // Create the polyline and add the symbol to it via the 'icons' property.
            var line = new google.maps.Polyline({
                path: [ " + path.TrimEnd(',') + @" ],
               // path: [ { lat: 18.45202353, lng: 73.81140579 }, { lat: 23.0921453, lng: 72.5901526 }],
                icons: [{
                    icon: lineSymbol,
                    offset: '100%'
                }],
                strokeColor: '#FF0000',
                map: map
            });

            
            
            var infowindow = new google.maps.InfoWindow({
                //content: contentString
            });

            for (i = 0; i < userCoor.length; i++) {
            if(i==0){
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(userCoor[i][0], userCoor[i][1]),
                map: map,
                
                title: '',
                icon: new google.maps.MarkerImage('http://maps.google.com/mapfiles/ms/icons/green-dot.png')
            });
            }
            else{
             var marker = new google.maps.Marker({
                position: new google.maps.LatLng(userCoor[i][0], userCoor[i][1]),
                map: map,
                title: '',
                icon: new google.maps.MarkerImage('http://maps.google.com/mapfiles/ms/icons/red-dot.png')
            });
           }           
            google.maps.event.addListener(marker, 'click', (function (marker, i) {
                return function () {
                                       
                    var latlng = new google.maps.LatLng(userCoor[i][0],userCoor[i][1]);
                    var geocoder = geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ 'latLng': latlng }, function (results, status) {
                     if (status == google.maps.GeocoderStatus.OK) {
                    if (results[1]) { 
                        var contentString = ' ';  
                        contentString = uaddress +'<p> Address : ' + results[1].formatted_address +'</p>';// results[1].formatted_address;
                        infowindow.setContent(contentString);//userCoor[i][3]
                        infowindow.open(map, marker);
                            }
                        }   
                     });                   
                }
            })(marker, i));

        }

        for (i = 0; i < auditCoor.length; i++) {
if(auditCoor.length != 0){
            
            var marker1 = new google.maps.Marker({
                position: new google.maps.LatLng(auditCoor[i][0], auditCoor[i][1]),
                map: map,
                title: '',
                icon: new google.maps.MarkerImage('http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+(i+1)+'|8E67FD|FFFFFF')
                });
            }
            google.maps.event.addListener(marker1, 'click', (function (marker, i) {
                return function () {
                                       
                    var latlng = new google.maps.LatLng(auditCoor[i][0],auditCoor[i][1]);
                    var geocoder = geocoder = new google.maps.Geocoder();
                    geocoder.geocode({ 'latLng': latlng }, function (results, status) {
                     if (status == google.maps.GeocoderStatus.OK) {
                    if (results[1]) { 
                        var contentString = ' ';  
                        contentString = uaddress + '<br/>' + auditCoor[i][2] + '<p> Address : ' + results[1].formatted_address +'</p>';// results[1].formatted_address;
                        infowindow.setContent(contentString);//userCoor[i][3]
                        infowindow.open(map, marker);
                            }
                        }   
                     });                   
                }
            })(marker1, i));
}

            animateCircle(line);
        }

        // Use the DOM setInterval() function to change the offset of the symbol
        // at fixed intervals.
        function animateCircle(line) {
            var count = 0;
            window.setInterval(function () {
                count = (count + 1) % 200;

                var icons = line.get('icons');
                icons[0].offset = (count / 2) + '%';
                line.set('icons', icons);
            }, 200);
        }
}

catch(ee)
{
    alert(ee);
}
</script>";
            }
            catch (Exception)
            {
                mapwithanimation = "No details found..";
            }

            Session["sess_x"] = mapwithanimation;
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Server.ScriptTimeout       = 50000;
            defaultCalendarExtender.EndDate = Convert.ToDateTime(DateTime.Now.Date.ToString("MM/dd/yyyy"));

            //defaultCalendarExtender.EndDate = Convert.ToDateTime(DateTime.Now.Date.ToString("MM/dd/yyyy"));

            //string update = "update location set L_date = Convert(varchar(15),Convert(date,getdate()),101) , l_time = Convert(char(8),Convert(time,getdate()),109) where isdate(l_date) <> 1 ;" +
            //                "delete from locationHist where isdate(l_date) <> 1";
            //bucket.ExecuteQuery(update);

            if (!Page.IsPostBack)
            {
                Session["sess_x"] = "";
                ddofficer.DataBind();
                uid = Request.QueryString["userid"].ToString();
                txt_frmDate.Text = DateTime.Now.Date.ToString("MM'/'dd'/'yyyy");
                ddofficer.Items.Add(new ListItem("ALL", "ALL"));
                ddofficer.SelectedValue = uid;
                lblusername.Text        = "Location of " + uid;

                if (ddofficer.SelectedValue == "ALL")
                {
                    sql = "select l.userid,l_long,l_lat, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                          ", case when rem_battery <=5 then 'Batterylow' else " +
                          "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                          ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') ,Convert(char(8),Convert(time,l_time,109)) " +
                          " from location l, users u WHERE l.userid=u.userid and CONVERT(date, l_date) = CONVERT(date, getdate(), 101) and l_lat <> '' and l_lat is not null and RcM='" + Session["sess_username"] + "'order by userid , L_time desc";
                    //sql = "SELECT * ,case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                    //    ",case when rem_battery <=5 then 'Batterylow' else "+
                    //    "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end "+
                    //    "FROM(SELECT   locationHist.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc) AS RN " +
                    //    "FROM locationHist WHERE CONVERT(date, l_date) = CONVERT(date, getdate(), 101)) AS t " +
                    //    "WHERE RN = 1";
                }
                else
                {
                    sql = "select Top 1 userid,l_long,l_lat, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                          " , case when rem_battery <=5 then 'Batterylow' else " +
                          "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                          ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') , Convert(char(8),Convert(time,l_time,109))" +
                          "from location where userid='" + uid + "' and CONVERT(date, l_date) = CONVERT(date, getdate(), 101) and l_lat <> '' and l_lat is not null order by userid , L_time desc";

                    //sql = "SELECT Top 1 * ,case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                    //    ",case when rem_battery <=5 then 'Batterylow' else " +
                    //    "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end " +
                    //    "FROM(SELECT   location.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc) AS RN " +
                    //    "FROM location where userid='" + uid + "' and l_date=(select MAX(L_date) from locationHist " +
                    //     "where userid='" + uid + "')) AS t " +
                    //    "WHERE RN = 1";
                }
            }
            else
            {
                uid = ddofficer.SelectedValue;
                lblusername.Text = "Location of " + uid;

                if (ddofficer.SelectedValue == "ALL")
                {
                    //sql = "select top 5 *, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                    //    ",case when rem_battery <=5 then 'Batterylow' else " +
                    //    "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end " +
                    //    "from locationHist where l_date='" + txt_frmDate.Text + "'";
                    //Response.Write(txt_frmDate.Text + System.DateTime.Today.ToString("MM'/'dd'/'yyyy"));
                    if (txt_frmDate.Text == System.DateTime.Today.ToString("MM'/'dd'/'yyyy"))
                    {
                        sql = "SELECT userid,l_long,l_lat,case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                              ", case when rem_battery <=5 then 'Batterylow' else " +
                              "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                              ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') , Convert(char(8),Convert(time,l_time,109))" +
                              "FROM(SELECT   location.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc, L_time desc) AS RN " +
                              "FROM location  WHERE  l_date = '" + txt_frmDate.Text + "' and l_lat <> '' and l_lat is not null) AS t " +
                              "WHERE RN = 1 and userid in (select userid from users where RCM = '" + Session["sess_username"] + "') order by userid ";
                    }
                    else
                    {
                        sql = "SELECT userid,l_long,l_lat,case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                              ", case when rem_battery <=5 then 'Batterylow' else " +
                              "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                              ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') , Convert(char(8),Convert(time,l_time,109))" +
                              "FROM(SELECT   locationHist.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc, L_time desc) AS RN " +
                              "FROM locationHist WHERE l_date = '" + txt_frmDate.Text + "' and l_lat <> '' and l_lat is not null) AS t " +
                              "WHERE RN = 1 and userid in (select userid from users where RCM = '" + Session["sess_username"] + "') order by userid";
                    }
                }
                else
                {
                    //sql = "select Top 1  *, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                    //",case when rem_battery <=5 then 'Batterylow' else " +
                    //" case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end "+
                    //"from locationHist where userid='" + uid + "' and (l_date='" + txt_frmDate.Text + "')";

                    if (txt_frmDate.Text == System.DateTime.Today.ToString("MM'/'dd'/'yyyy"))
                    {
                        sql = "SELECT Top 1 userid,l_long,l_lat, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                              ",case when rem_battery <=5 then 'Batterylow' else " +
                              "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                              ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') , Convert(char(8),Convert(time,l_time,109))" +
                              "FROM(SELECT   location.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc, L_time desc) AS RN " +
                              "FROM location where userid='" + uid + "' and (l_date='" + txt_frmDate.Text + "') and l_lat <> '' and l_lat is not null) AS t " +
                              "WHERE RN = 1";
                        //sql = "select Top 1  userid,l_long,l_lat, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                        //",case when rem_battery <=5 then 'Batterylow' else " +
                        //" case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end " +
                        //", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') " +
                        //"from location where userid='" + uid + "' and (l_date='" + txt_frmDate.Text + "')";
                    }
                    else
                    {
                        sql = "SELECT Top 1 userid,l_long,l_lat, case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1 " +
                              ",case when rem_battery <=5 then 'Batterylow' else " +
                              "case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l_date,'/','-') + ' ' + l_time) < -60 then 'Offline' else 'Online' end end as [status] " +
                              ", replace(Convert(varchar(15),Convert(date,l_date),106),' ','-') , Convert(char(8),Convert(time,l_time,109))" +
                              "FROM(SELECT   locationHist.*, ROW_NUMBER() OVER (PARTITION BY l_date, userid ORDER BY CONVERT(date, l_date) desc, L_time desc) AS RN " +
                              "FROM locationHist where userid='" + uid + "' and (l_date='" + txt_frmDate.Text + "') and l_lat <> '' and l_lat is not null) AS t " +
                              "WHERE RN = 1";
                    }
                }
            }
            //Response.Write(sql);
            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(sql);

            dt = bucket.GetData(cmd);

            string x       = "";
            string markers = "";
            string zoomstr = "";

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //if (dt.Rows[i][4].ToString() == "Offline")
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}
                    //else if (dt.Rows[i][4].ToString() == "Batterylow")
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}
                    //else
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}

                    if (dt.Rows[i][4].ToString() == "Offline")
                    {
                        markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    else if (dt.Rows[i][4].ToString() == "Batterylow")
                    {
                        markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    else
                    {
                        markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    if (ddofficer.SelectedValue == "ALL")
                    {
                        zoomstr = "var lonLat = new OpenLayers.LonLat(77.2658031,23.1996633).transform(epsg4326, projectTo);" + "\n" +
                                  "var zoom = 4;" + "\n";
                    }
                    else
                    {
                        zoomstr = "var lonLat = new OpenLayers.LonLat(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo);" + "\n" +
                                  "var zoom = 17;" + "\n";
                    }
                }
                Label1.Visible = false;
            }
            else
            {
                Label1.Visible = true;
            }
            x = @" <script src=" + Convert.ToChar(34) + "http://openlayers.org/api/OpenLayers.js" + Convert.ToChar(34) + "></script> <script src=" + Convert.ToChar(34) + "https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" + Convert.ToChar(34) + "></script>" +
                "<script>" + "\n" +
                "function GetResults(lat, long) {" + "\n" +
                "var jsonObjectInstance = $.parseJSON($.ajax({" + "\n" +//Transovative && Transo@123 mapzen // [email protected] && Trans123
                " url: 'https://search.mapzen.com/v1/reverse?api_key=search-BST68nm&point.lat='+lat+'&point.lon='+long+'&size=1'," + "\n" +
                " async: false," + "\n" +
                "dataType: 'json'" + "\n" +
                "}).responseText); return jsonObjectInstance" + "\n" +
                "}" + "\n" +

                "map = new OpenLayers.Map(" + Convert.ToChar(34) + "basicMap" + Convert.ToChar(34) + ");" + "\n" +
                "map.addLayer(new OpenLayers.Layer.OSM());" + "\n" +

                "epsg4326 = new OpenLayers.Projection(" + Convert.ToChar(34) + "EPSG:4326" + Convert.ToChar(34) + ");" + "\n" + //WGS 1984 projection
                "projectTo = map.getProjectionObject(); " + "\n" +                                                              //The map projection (Spherical Mercator)

                //"var lonLat = new OpenLayers.LonLat(77.2658031,23.1996633).transform(epsg4326, projectTo);" + "\n" +
                //"var zoom = 4;" + "\n" +
                zoomstr +
                "map.setCenter(lonLat, zoom);" + "\n" +

                "var vectorLayer = new OpenLayers.Layer.Vector(" + Convert.ToChar(34) + "Overlay" + Convert.ToChar(34) + ");" + "\n" +

                markers +

                "map.addLayer(vectorLayer);" + "\n" +
                //Add a selector control to the vectorLayer with popup functions
                "var controls = {" + "\n" +
                "selector: new OpenLayers.Control.SelectFeature(vectorLayer, { onSelect: createPopup, onUnselect: destroyPopup })" + "\n" +
                "};" + "\n" +

                "function createPopup(feature) {" + "\n" +
                "feature.popup = new OpenLayers.Popup.FramedCloud(" + Convert.ToChar(34) + "pop" + Convert.ToChar(34) + "," + "\n" +
                "feature.geometry.getBounds().getCenterLonLat()," + "\n" +
                "null," + "\n" +
                "'<div class=" + Convert.ToChar(34) + "markerContent" + Convert.ToChar(34) + ">' + feature.attributes.description + '</div>'," + "\n" +
                "null," + "\n" +
                "true," + "\n" +
                "function () { controls['selector'].unselectAll(); }" + "\n" +
                ");" + "\n" +
                //feature.popup.closeOnMove = true;
                "map.addPopup(feature.popup);" + "\n" +
                "}" + "\n" +

                "function destroyPopup(feature) {" + "\n" +
                "feature.popup.destroy();" + "\n" +
                "feature.popup = null;" + "\n" +
                "}" + "\n" +

                "map.addControl(controls['selector']);" + "\n" +
                "controls['selector'].activate();" + "\n" +

                "</script>";

            Session["sess_x"] = x;
        }
コード例 #4
0
        public void createOSMMap()
        {
            var officername = "";

            string strmap = "";

            try
            {
                hdnlocation.Value = Request.Form[ddofficer.UniqueID];
                if (hdnlocation.Value == null || hdnlocation.Value == "")
                {
                    officername = "%";
                }
                else
                {
                    officername = hdnlocation.Value;
                }

                string s1 = "", s2 = "";

                s1 = @"select   distinct l.userid,L_lat,L_Long,
                case when rem_battery>0 then rem_battery when rem_battery<0 then '0' end as rem_battery1,
                case when l.rem_battery <=5 then 'Batterylow' else
                case when DATEDIFF(MINUTE,replace(l.b_date,'/','-') + ' ' + l.l_time,CONVERT(VARCHAR(19), GETDATE(),120)) > 60 then
                'Offline' else 'Online' end end as [Status],
                l_Date,l_time,
                isnull(u.mobile,'NA'),username
                from location l 
                inner join users u 
                on l.userid = u.userid where    u.userid like '%" + officername + @"%' and (l_lat<>'0') and  l_date = '" + txt_frmDate.Text + "' and ( l_long<> '0')  and l_lat is not null and l_long is not null	and u.status <> 'DEL'";

                s2 = @"select distinct u.unitid,LTRIM(RTRIM(unitlat)),LTRIM(RTRIM(unitlong)),u.unitname,case when type='CMS' then 'CMS' else 'NONCMS' end as type, location,region,'','','','',''
                    from unit u 
				    where unitlat is not null and  unitlat not like '' and unitlat <> '0.0' and unitlat <> '0'  and unitlat<> '1..' and unitlat <> 'NULL' and u.status <> 'Inactive'"                ;

                string qry = @"";


                qry = s1;
                //Response.Write(qry);
                SqlCommand cmd = new SqlCommand(qry);
                DataTable  dt  = bucket.GetData(cmd);

                //string userpropic = "";
                string markers    = "";
                string usercoords = "";
                string usercoor   = "";
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //  markers += "{ " + "\"title\"" + ": '" + dt.Rows[i][0].ToString().Trim().Replace("'", "") + "' ," + "\"lat\"" + ": '" + dt.Rows[i][1].ToString().Trim() + "' ," + "\"lng\"" + ": '" + dt.Rows[i][2].ToString().Trim() + "' ," + "\"description\"" + ": 'Name : " + dt.Rows[i][8] + " <br/> Mobile No : " + dt.Rows[i][7] + " <br/> Date Time : " + dt.Rows[i][5].ToString().Trim().Replace("'", "") + " - " + dt.Rows[i][6].ToString().Trim().Replace("'", "") + " <br/> Status : " + dt.Rows[i][4] + " <br/> Battery Remaining : " + dt.Rows[i][3] + "'  ," + "\"type\"" + ": '" + dt.Rows[i][4] + "'," + "\"unitdescp\"" + ": 'Unit Name : " + dt.Rows[i][3].ToString().Trim().Replace("'", "") + " <br/> Location : " + dt.Rows[i][5].ToString().Trim().Replace("'", "") + " <br/> Region : " + dt.Rows[i][6] + " <br/> Site Type : " +dt.Rows[i][4].ToString().ToUpper().Replace("NONCMS","NON-CMS")+"'},";
                    markers += "{ " + "\"title\"" + ": '" + dt.Rows[i][0].ToString().Trim().Replace("'", "") + @"' ,
                           " + "\"lat\"" + ": '" + dt.Rows[i][1].ToString().Trim() + "' ," + "\"lng\"" + ": '" + dt.Rows[i][2].ToString().Trim() + @"' ,
                 'Name : " + dt.Rows[i][8] + " <br/> Mobile No : " + dt.Rows[i][7] + " <br/> Date Time : "
                               + dt.Rows[i][5].ToString().Trim().Replace("'", "") + " - " + dt.Rows[i][6].ToString().Trim().Replace("'", "") +
                               " <br/> Status : " + dt.Rows[i][4] + " <br/> Battery Remaining : " + dt.Rows[i][3] + "'  ," + "\"type\"" + ": '"
                               + dt.Rows[i][4] + @"' <br/>}";

                    usercoords += "ol.proj.transform([" + dt.Rows[i][2].ToString() + "," + dt.Rows[i][1].ToString() + "], 'EPSG:4326','EPSG:3857'),";
                    usercoor   += "['" + dt.Rows[i][0].ToString().Trim().Replace("'", "") + "'," + dt.Rows[i][1].ToString() + "," + dt.Rows[i][2].ToString() + ",'" +
                                  dt.Rows[i][3].ToString() + "','" + dt.Rows[i][4].ToString().ToUpper().Replace("NONCMS", "NON-CMS") + "','" +
                                  dt.Rows[i][5].ToString().Trim().Replace("'", "") + "','" +
                                  dt.Rows[i][6].ToString() + "','" + dt.Rows[i][7].ToString() + "','" + dt.Rows[i][8].ToString() + "'],";
                    //Response.Write(usercoor+"<br/>");
                }

                strmap = @"<script>
   // setTimeout(function(){ 
        debugger;
            var
                sourceFeatures = new ol.source.Vector(),
                layerFeatures = new ol.layer.Vector({
                    source: sourceFeatures
                });

            var container = document.getElementById('popup');
            var content = document.getElementById('popup-content');
            var closer = document.getElementById('popup-closer');

            var overlay = new ol.Overlay(/** @type {olx.OverlayOptions} */({
                element: container,
                autoPan: true,
                autoPanAnimation: {
                    duration: 250
                }
            }));

            closer.onclick = function () {
                document.getElementById('popup-content').innerHTML = '';
                overlay.setPosition(undefined);
                closer.blur();
                return false;
            };


            var lineString = new ol.geom.LineString([]);

            var layerRoute = new ol.layer.Vector({
                source: new ol.source.Vector({
                    features: [
                        new ol.Feature({ geometry: lineString })
                    ]
                }),
                style: [
                    new ol.style.Style({
                        stroke: new ol.style.Stroke({
                            width: 3, color: 'rgba(255, 0, 0, 1)'
                            //lineDash: [.1, 5]
                        }),
                        zIndex: 2
                    })
                ],
                updateWhileAnimating: true
            });

            var loc = [" + usercoords + @"]; 
            var map = new ol.Map({
                target: 'map',
                view: new ol.View({
                    center: loc[0],
                    zoom: 16,
                    minZoom: 2,
                    maxZoom: 20
                }),
                layers: [
                    new ol.layer.Tile({
                        source: new ol.source.OSM(),
                        opacity: 0.6
                    }),
                    layerRoute, layerFeatures
                ],
                overlays: [overlay]
            });
            
            
                var view = map.getView();
                var extent = ol.extent.boundingExtent([" + usercoords + @"]);
                var size = map.getSize();
                view.fit(extent, size);
                if (view.getZoom() > 16) {
                    view.setZoom(9);
                }            

            var userCoor = [ " + usercoor.TrimEnd(',') + @"];
            var iconFeatures = [];
            var j=0;
            var iconBase = 'http://maps.google.com/mapfiles/ms/icons/';
          for (i = 0; i < userCoor.length; i++) {
            //debugger;
     if(userCoor[i][4]== 'ONLINE')
            {
            var iconFeature = new ol.Feature({
                geometry: new ol.geom.Point(loc[i]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name: '<table><tr><td> User ID : '+userCoor[i][0]+'<br/>Name : '+userCoor[i][8]+'<br/>Mobile No : '+userCoor[i][7]+'<br/>Date Time : '+userCoor[i][5]+' - '+userCoor[i][6]+'<br/>Status : '+userCoor[i][4]+'<br/>Battery Remaining : '+userCoor[i][3]+'%</td></tr></table>',
                type:'user',                
                population: 4000,
                rainfall: 500
            });
            iconFeature.setStyle(new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    //color: '#8959A8',
                    //crossOrigin: 'anonymous',
                    anchor: [0.5, 30],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    src: './Image/man-green.png'
                }))
            }));
            iconFeatures.push(iconFeature);
            }
             else if(userCoor[i][4] == 'OFFLINE')
            {
            var iconFeature = new ol.Feature({
                geometry: new ol.geom.Point(loc[i]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name: '<table><tr><td> User ID : '+userCoor[i][0]+'<br/>Name : '+userCoor[i][8]+'<br/>Mobile No : '+userCoor[i][7]+'<br/>Date Time : '+userCoor[i][5]+' - '+userCoor[i][6]+'<br/>Status : '+userCoor[i][4]+'<br/>Battery Remaining : '+userCoor[i][3]+'%</td></tr></table>',
                type:'user',                
                population: 4000,
                rainfall: 500
            });
            iconFeature.setStyle(new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    //color: '#8959A8',
                    //crossOrigin: 'anonymous',
                    anchor: [0.5, 30],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    
                    src: './Image/man-red.png'
                }))
            }));
            iconFeatures.push(iconFeature);
            }
            else if(userCoor[i][4] == 'BATTERYLOW'){ 
            var iconFeature = new ol.Feature({
                geometry: new ol.geom.Point(loc[i]),//ol.proj.transform([-72.0704, 46.678], 'EPSG:4326','EPSG:3857')),
                name: '<table><tr><td> User ID : '+userCoor[i][0]+'<br/>Name : '+userCoor[i][8]+'<br/>Mobile No : '+userCoor[i][7]+'<br/>Date Time : '+userCoor[i][5]+' - '+userCoor[i][6]+'<br/>Status : '+userCoor[i][4]+'<br/>Battery Remaining : '+userCoor[i][3]+'%</td></tr></table>',
                type:'user',                            
                population: 4000,
                rainfall: 500
            });
            iconFeature.setStyle(new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    //color: '#8959A8',
                    //crossOrigin: 'anonymous',
                    anchor: [0.5, 30],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    src: './Image/man-orange.png'
                }))
            }));
            iconFeatures.push(iconFeature);
           }
             
           
            }
debugger;
//            var iconFeature1 = new ol.Feature({
//                geometry: new ol.geom.Point(loc[1]),
//                name: 'Null Island Two',
//                population: 4001,
//                rainfall: 501
//            });
//
//            iconFeature1.setStyle(new ol.style.Style({
//                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
//                    //  color: '#8959A8',
//                    //crossOrigin: 'anonymous',
//                    anchor: [0.5, 30],
//                    anchorXUnits: 'fraction',
//                    anchorYUnits: 'pixels',
//                    src: 'http://maps.google.com/mapfiles/ms/icons/red-dot.png'
//                }))
//            }));
//
//            iconFeatures.push(iconFeature1);


            var vectorSource = new ol.source.Vector({
                features: iconFeatures //add an array of features
            });

            var iconStyle = new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    anchor: [0.5, 46],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    opacity: 0.75,
                    src: 'http://openlayers.org/en/v3.9.0/examples/data/icon.png',
                }))
            });

            var vectorLayer = new ol.layer.Vector({
                source: vectorSource,
                //style: iconStyle
            });

            map.addOverlay(vectorLayer);

            var markerEl = document.getElementById('geo-marker');
            var marker = new ol.Overlay({
                positioning: 'center-center',
                offset: [5, 0],
                element: markerEl,
                stopEvent: false
            });

            var element = document.getElementById('popupinfo');
            var popup = new ol.Overlay({
                element: element,
                positioning: 'bottom-center',
                stopEvent: false,
                offset: [9, -21]
            });
            map.addOverlay(popup);

            map.on('click', function (evt) {
                var feature = map.forEachFeatureAtPixel(evt.pixel,
                    function (feature) {
                        return feature;
                    });
                if (feature) {
                    var coordinates = feature.getGeometry().getCoordinates();
                    var longlat = ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
                    popup.setPosition(coordinates);
                    if(feature.get('type')=='atm')
                    {
                    content.innerHTML = '<p>'+ feature.get('name')+ '</p>';
                    }
                    else if(feature.get('type')=='user')
                    {
                    var sid = GetResults(longlat[1], longlat[0]);
                    //var sid='brijesh';
                    content.innerHTML = '<p>'+ feature.get('name')+ '<br/>'+'Address : '+ sid.display_name+'</p>';
                    }
//                    var sid = GetResults(longlat[1], longlat[0]);
//                    content.innerHTML = feature.get('name')+ 'Address : '+ sid.display_name;
                     overlay.setPosition(coordinates);
                } else { 
                     overlay.setPosition(undefined);
                     closer.blur();
                }
//                    $(element).popover({
//                        'placement': 'top',
//                        'html': true,
//                        'content': 'Siteid : '+feature.get('name')+'<br/>Address : '+ sid.display_name //feature.get('name')
//                    });
//                    $(element).popover('show');
//                } else {
//                    $(element).popover('destroy');
//                }
            });

            map.addOverlay(marker);

            var fill = new ol.style.Fill({ color: 'rgba(255,255,255,1)' }),
                stroke = new ol.style.Stroke({ color: 'rgba(0,0,0,1)' }),
                style1 = [
                    new ol.style.Style({
                        image: new ol.style.Circle({
                            radius: 6, fill: fill, stroke: stroke
                        }),
                        zIndex: 4
                    })
                ];


                    //}, 300);

             function GetResults(lat, long) {
                var jsonObjectInstance = $.parseJSON($.ajax({
                    url: 'https://locationiq.org/v1/reverse.php?format=json&key=9c73f8c9ed5d47&lat=' + lat + '&lon=' + long,     
                    async: false,
                    dataType: 'json'
                }).responseText); return jsonObjectInstance
            } 
        </script>";

                if (dt.Rows.Count <= 0)
                {
                    strmap = @"No details found.." + @"<script> var container = document.getElementById('popup');
                var geo = document.getElementById('geo-marker');
                container.style.display = 'none';  geo.style.display = 'none';
                </script>";
                }
            }
            catch (Exception)
            {
                strmap = "No details found.." + @"<script> var container = document.getElementById('popup');
                var geo = document.getElementById('geo-marker');
                container.style.display = 'none';  geo.style.display = 'none';
                </script>";
            }
            map.InnerHtml = strmap;
        }
コード例 #5
0
        public string drawmap()
        {
            string mapstr = "";

            try
            {
                ibuckethead bucket = new ibuckethead();
                string      rows;
                string      qry = @"select u.username,l.l_lat,l.l_long,l.Rem_Battery, case when l.rem_battery <=5 then 'Batterylow' else 
                    case when DATEDIFF(MINUTE,CONVERT(VARCHAR(19), GETDATE(),120),replace(l.b_date,'/','-') + ' ' + l.l_time) < -60 then 'Offline' 
                    else 'Online' end end as[Status],substring(b_date,4,3) + substring(b_date,1,2)+ substring(b_date,6,5) + ' ' + b_time as [Last Updated On]
                    from location l inner join users u on l.userid = u.userid where l_lat <>'0' and l_long <>'0'";
                if (Session["sess_role"].ToString() == "AO")
                {
                    qry += " and u.userid in (select userid from  AreaUserMap where area in (select area from AreaUserMap where userid='" + Session["sess_userid"].ToString() + "'))";
                }
                else if (Session["sess_role"].ToString() == "BM")
                {
                    qry += " and u.Branch in (Select Branch from users where userid = '" + Session["sess_userid"].ToString() + "')";
                }
                else if (Session["sess_role"].ToString() == "REGION")
                {
                    qry += " and u.REGION in (Select REGION from users where userid = '" + Session["sess_userid"].ToString() + "')";
                }
                SqlCommand cmd = new SqlCommand(qry);
                DataTable  dt  = bucket.GetData(cmd);

                string usercoor = "";
                string marker   = "";
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        //usercoor += "ol.proj.transform([" + dt.Rows[i][4].ToString() + "," + dt.Rows[i][3].ToString() + "], 'EPSG:4326','EPSG:3857'),";
                        usercoor += "ol.proj.transform([" + dt.Rows[i][2].ToString() + "," + dt.Rows[i][1].ToString() + "], 'EPSG:4326','EPSG:3857'),";

                        marker += @"var iconFeature" + i + @" = new ol.Feature({
                        geometry: new ol.geom.Point(loc[" + i + @"]),
                        name: '" + dt.Rows[i][0].ToString() + @"',
                        LastUpdatedOn: '" + dt.Rows[i][5].ToString() + @"',
                        rainfall: 501
                    });

                    iconFeature" + i + @".setStyle(new ol.style.Style({
                        image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                            //  color: '#8959A8',
                            //crossOrigin: 'anonymous',
                            anchor: [0.5, 30],
                            anchorXUnits: 'fraction',
                            anchorYUnits: 'pixels',                    ";

                        if (dt.Rows[i][4].ToString() == "Batterylow")
                        {
                            marker += "src: '../Image/man-orange.png'";
                        }
                        else if (dt.Rows[i][4].ToString() == "Offline")
                        {
                            marker += "src: '../Image/man-red.png'";
                        }
                        else if (dt.Rows[i][4].ToString() == "Online")
                        {
                            marker += "src: '../Image/man-green.png'";
                        }
                        marker += @" }))
                    }));

                    iconFeatures.push(iconFeature" + i + @");";
                    }
                }

                mapstr = @"<script>
    setTimeout(function(){  
            var container = document.getElementById('popup');
            var content = document.getElementById('popup-content');
            var closer = document.getElementById('popup-closer');

            var overlay = new ol.Overlay(/** @type {olx.OverlayOptions} */({
                element: container,
                autoPan: true,
                autoPanAnimation: {
                    duration: 250
                }
            }));

            closer.onclick = function () {
                document.getElementById('popup-content').innerHTML = '';
                overlay.setPosition(undefined);
                closer.blur();
                return false;
            };


            var lineString = new ol.geom.LineString([]);

            var layerRoute = new ol.layer.Vector({
                source: new ol.source.Vector({
                    features: [
                        new ol.Feature({ geometry: lineString })
                    ]
                }),
                style: [
                    new ol.style.Style({
                        stroke: new ol.style.Stroke({
                            width: 3, color: 'rgba(255, 0, 0, 1)' 
                        }),
                        zIndex: 2
                    })
                ],
                updateWhileAnimating: true
            });

            var loc = [" + usercoor + @"]; 
            var map = new ol.Map({
                target: 'map',
                view: new ol.View({
                    center: loc[0],
                    zoom: 16,
                    minZoom: 2,
                    maxZoom: 20
                }),
                layers: [
                    new ol.layer.Tile({
                        source: new ol.source.OSM(),
                        opacity: 0.6
                    })
                ],
                overlays: [overlay]
            });
            
                var view = map.getView();
                var extent = ol.extent.boundingExtent([" + usercoor + @"]);
                var size = map.getSize();
                view.fit(extent, size);
                if (view.getZoom() > 16) {
                    view.setZoom(9);
                }              

            var iconFeatures = [];
            " + marker + @"

            var vectorSource = new ol.source.Vector({
                features: iconFeatures //add an array of features
            });

            var iconStyle = new ol.style.Style({
                image: new ol.style.Icon(/** @type {olx.style.IconOptions} */({
                    anchor: [0.5, 46],
                    anchorXUnits: 'fraction',
                    anchorYUnits: 'pixels',
                    opacity: 0.75,
                    src: 'http://openlayers.org/en/v3.9.0/examples/data/icon.png',
                }))
            });

            var vectorLayer = new ol.layer.Vector({
                source: vectorSource,
                //style: iconStyle
            });

            map.addOverlay(vectorLayer);

            var markerEl = document.getElementById('geo-marker');
            var marker = new ol.Overlay({
                positioning: 'center-center',
                offset: [5, 0],
                element: markerEl,
                stopEvent: false
            });

            var element = document.getElementById('popupinfo');
            var popup = new ol.Overlay({
                element: element,
                positioning: 'bottom-center',
                stopEvent: false,
                offset: [9, -21]
            });
            map.addOverlay(popup);
            map.on('click', function (evt) {
                var feature = map.forEachFeatureAtPixel(evt.pixel,
                    function (feature) {
                        return feature;
                    });
                if (feature) { 
                    var coordinates = feature.getGeometry().getCoordinates();
                    var longlat = ol.proj.transform(coordinates, 'EPSG:3857', 'EPSG:4326');
                    popup.setPosition(coordinates);
                    var sid = GetResults(longlat[1], longlat[0]);  
                      //var sid = '';
                     content.innerHTML = '<p>User Name : '+ feature.get('name')+ '<br/>Last Updated On : '+feature.get('LastUpdatedOn')+'<br/>'+'Address : '+ sid.display_name+'</p>';
                     overlay.setPosition(coordinates);
                } else { 
                     overlay.setPosition(undefined);
                     closer.blur();
                }
            });

            map.addOverlay(marker);

            var fill = new ol.style.Fill({ color: 'rgba(255,255,255,1)' }),
                stroke = new ol.style.Stroke({ color: 'rgba(0,0,0,1)' }),
                style1 = [
                    new ol.style.Style({
                        image: new ol.style.Circle({
                            radius: 6, fill: fill, stroke: stroke
                        }),
                        zIndex: 4
                    })
                ];

        }, 300);

             function GetResults(lat, long) {
                var jsonObjectInstance = $.parseJSON($.ajax({
                    url: 'https://locationiq.org/v1/reverse.php?format=json&key=9c73f8c9ed5d47&lat=' + lat + '&lon=' + long,     
                    async: false,
                    dataType: 'json'
                }).responseText); return jsonObjectInstance
            } 
        </script>";
            }
            catch (Exception)
            {
                mapstr = "No details found.." + @"<script> var container = document.getElementById('popup');
                var geo = document.getElementById('geo-marker');
                container.style.display = 'none';  geo.style.display = 'none';
                </script>";
            }
            return(mapstr);
            // map.InnerHtml = mapstr;
        }
コード例 #6
0
        //public void graph()
        //{
        //    if (Request.QueryString["request"] == "ctp")
        //    {
        //        piechartctp();
        //        barchatctp();
        //    }
        //    else
        //    {
        //        Response.Redirect("Default.aspx?request=ctp");
        //    }
        //    //timer.Enabled = false;
        //}

        public string piechart()
        {
            int    flag = 0;
            string sql  = "";

            if (Request.QueryString["request"] == "ctp")
            {
                Button4.ForeColor = System.Drawing.Color.Black;
                Button4.BackColor = System.Drawing.Color.White;
                string[] q = bucket.verifyReader("select distinct COUNT(atmid) as 'a' from ATMs where status <> 'inactive' and atmid not like '%*BR*%' and atmid not like '%HDFC%' and bankid like 'ICICI'", "a");
                lbl_siteassigned.Text = "5";// q[0];

                sql =
                    @"
            select count(atmid) as Audited from atms 
            where atmid in (select atmid from current_dr_ctp) and status<>'Inactive' and atmid not like '%*BR*%' and atmid not like '%HDFC%' and bankid like 'ICICI'
            union all
            select count(atmid) from atms 
            where atmid not in (select atmid from current_dr_ctp) and status<>'Inactive' and atmid not like '%*BR*%' and atmid not like '%HDFC%' and bankid like 'ICICI'
            ";
                flag = 1;
            }
            else
            if (Request.QueryString["request"] == "hdfc")
            {
                Button1.ForeColor = System.Drawing.Color.Black;
                Button1.BackColor = System.Drawing.Color.White;
                //Chart4.Visible = false; Label1.Visible = false;
                string[] q = bucket.verifyReader("select distinct COUNT(atmid) as 'a' from ATMs where status <> 'inactive'  and atmid like '%HDFC%'", "a");
                lbl_siteassigned.Text = q[0];
                sql =
                    @"
            select count(atmid) as Audited from atms 
            where atmid in (select distinct atmid from current_dr_ctp where atmid like '%HDFC%') and status<>'Inactive'
            and bankid='HDFC'
            union all
            select count(atmid) from atms 
            where atmid not in (select distinct atmid from current_dr_ctp  where atmid like '%HDFC%') and status<>'Inactive' and bankid='HDFC'
            ";
                flag = 1;
            }
            else if (Request.QueryString["request"] == "axis")
            {
                Button2.ForeColor = System.Drawing.Color.Black;
                Button2.BackColor = System.Drawing.Color.White;
                string[] q = bucket.verifyReader("select distinct COUNT(atmid) as 'a' from ATMs where bankid='BANK OF MAHARASHTRA' and status <> 'inactive' and atmid like '%*BR*%' and atmid not like '%HDFC%' and bankid='BANK OF MAHARASHTRA'", "a");
                lbl_siteassigned.Text = q[0];
                //  Chart4.Visible = false; Label1.Visible = false;

                sql =
                    @"
            select count(atmid) as Audited from atms 
            where atmid in (select atmid from DR_BRANCH) and status<>'Inactive' and atmid like '%*BR*%' and atmid not like '%HDFC%'
            and bankid='BANK OF MAHARASHTRA'
            union all
            select count(atmid) from atms 
            where atmid not in (select atmid from DR_BRANCH) and status<>'Inactive' and atmid like '%*BR*%' and atmid not like '%HDFC%'
            and bankid='BANK OF MAHARASHTRA'
            ";
                flag = 1;
            }
            else
            {
                Response.Redirect("Dashboard.aspx?request=ctp");
            }
            SqlCommand cmd1 = new SqlCommand(sql);
            DataTable  dt1  = bucket.GetData(cmd1);

            cmd1.CommandTimeout = 200;
            string pie = "";

            if (flag == 1 && dt1.Rows.Count > 0)
            {
                pie = @"<script src=""js/highcharts.js""></script>
   
        <script type=""text/javascript"">
		    $(function () {

		        $(document).ready(function () {

		            // Build the chart
		            $('#container').highcharts({
		                chart: {
		                    plotBackgroundColor: null,
		                    plotBorderWidth: null,
		                    plotShadow: false
		                },
		                title: {
		                    text: ''
		                },
		                tooltip: {
		                    pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
		                },
		                plotOptions: {
		                    pie: {
		                        allowPointSelect: true,
		                        cursor: 'pointer',
		                        dataLabels: {
		                            enabled: false
		                        },
		                        showInLegend: true
		                    }
		                },
		                series: [{
		                    type: 'pie',
		                    name: 'Audits',
		                    data: [                   
                   
                    ['Audited', " + Convert.ToInt32(dt1.Rows[0][0]) + @"],
                    ['Pending'," + Convert.ToInt32(dt1.Rows[1][0]) + @"]
                ]
		                }]
		            });
		        });

		    });
		</script>"        ;
            }
            return(pie);
        }
コード例 #7
0
        public void drawmap()
        {
            DataTable  dt  = new DataTable();
            SqlCommand cmd = new SqlCommand(sql);

            dt = bucket.GetData(cmd);

            string x       = "";
            string markers = "";
            string zoomstr = "";
            var    lonLat  = "";

            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //if (dt.Rows[i][4].ToString() == "Offline")
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}
                    //else if (dt.Rows[i][4].ToString() == "Batterylow")
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}
                    //else
                    //{
                    //    markers += "var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                    //    "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                    //    "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                    //    "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : '+ r.features[0].properties.label +'<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                    //        //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                    //    "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                    //    "vectorLayer.addFeatures(feature);" + "\n";
                    //}
                    if (dt.Rows[i][4].ToString() == "Offline")
                    {
                        markers += "var r = '';" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-red.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    else if (dt.Rows[i][4].ToString() == "Batterylow")
                    {
                        markers += "var r = '';" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-orange.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    else
                    {
                        //"var r = GetResults(" + dt.Rows[i][2].ToString() + ", " + dt.Rows[i][1].ToString() + ");" + "\n" +
                        markers += "var r = '';" + "\n" +
                                   "try {" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA<br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);" + "\n" +
                                   "} catch(ee){" +
                                   "var feature = new OpenLayers.Feature.Vector(" + "\n" +
                                   "new OpenLayers.Geometry.Point(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo)," +
                                   "{ description: 'UserID : " + dt.Rows[i][0].ToString() + " <br/> Location : NA <br/>Battery : " + dt.Rows[i][3].ToString() + "%<br/>Date : " + dt.Rows[i][5].ToString() + " " + dt.Rows[i][6].ToString() + "'}," +
                                   //"{ description: 'Location : ' + '" + bucket.filterText(dt.Rows[i][5].ToString().TrimStart(',')) + "' }," +
                                   "{ externalGraphic: 'Image/man-green.png', graphicHeight: 35, graphicWidth: 35, graphicXOffset: -12, graphicYOffset: -25 });" + "\n" +
                                   "vectorLayer.addFeatures(feature);}" + "\n";
                    }
                    if (ddofficer.SelectedValue == "ALL")
                    {
                        zoomstr = "var lonLat = new OpenLayers.LonLat(77.2658031,23.1996633).transform(epsg4326, projectTo);" + "\n" +
                                  "var zoom = 4;" + "\n";
                    }
                    else
                    {
                        zoomstr = "var lonLat = new OpenLayers.LonLat(" + dt.Rows[i][1].ToString() + ", " + dt.Rows[i][2].ToString() + ").transform(epsg4326, projectTo);" + "\n" +
                                  "var zoom = 17;" + "\n";
                    }
                }
                Label1.Visible = false;
            }
            else
            {
                Label1.Visible = true;
            }
            x = @" <script src=" + Convert.ToChar(34) + "https://openlayers.org/api/OpenLayers.js" + Convert.ToChar(34) + "></script> <script src=" + Convert.ToChar(34) + "https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" + Convert.ToChar(34) + "></script>" +
                "<script>" + "\n" +
                "function GetResults(lat, long) {" + "\n" +
                "var jsonObjectInstance = $.parseJSON($.ajax({" + "\n" +//Transovative && Transo@123 mapzen // [email protected] && Trans123
                " url: 'https://search.mapzen.com/v1/reverse?api_key=mapzen-p6NsJtH&point.lat='+lat+'&point.lon='+long+'&size=1'," + "\n" +
                " async: false," + "\n" +
                "dataType: 'json'" + "\n" +
                "}).responseText); return jsonObjectInstance" + "\n" +
                "}" + "\n" +

                "map = new OpenLayers.Map(" + Convert.ToChar(34) + "basicMap" + Convert.ToChar(34) + ");" + "\n" +
                "map.addLayer(new OpenLayers.Layer.OSM());" + "\n" +

                "epsg4326 = new OpenLayers.Projection(" + Convert.ToChar(34) + "EPSG:4326" + Convert.ToChar(34) + ");" + "\n" + //WGS 1984 projection
                "projectTo = map.getProjectionObject(); " + "\n" +                                                              //The map projection (Spherical Mercator)

                //"var lonLat = new OpenLayers.LonLat(77.2658031,23.1996633).transform(epsg4326, projectTo);" + "\n" +
                //"var zoom = 4;" + "\n" +
                zoomstr +
                "map.setCenter(lonLat, zoom);" + "\n" +

                "var vectorLayer = new OpenLayers.Layer.Vector(" + Convert.ToChar(34) + "Overlay" + Convert.ToChar(34) + ");" + "\n" +

                markers +

                "map.addLayer(vectorLayer);" + "\n" +
                //Add a selector control to the vectorLayer with popup functions
                "var controls = {" + "\n" +
                "selector: new OpenLayers.Control.SelectFeature(vectorLayer, { onSelect: createPopup, onUnselect: destroyPopup })" + "\n" +
                "};" + "\n" +

                "function createPopup(feature) {" + "\n" +
                "feature.popup = new OpenLayers.Popup.FramedCloud(" + Convert.ToChar(34) + "pop" + Convert.ToChar(34) + "," + "\n" +
                "feature.geometry.getBounds().getCenterLonLat()," + "\n" +
                "null," + "\n" +
                "'<div class=" + Convert.ToChar(34) + "markerContent" + Convert.ToChar(34) + ">' + feature.attributes.description + '</div>'," + "\n" +
                "null," + "\n" +
                "true," + "\n" +
                "function () { controls['selector'].unselectAll(); }" + "\n" +
                ");" + "\n" +
                //feature.popup.closeOnMove = true;
                "map.addPopup(feature.popup);" + "\n" +
                "}" + "\n" +

                "function destroyPopup(feature) {" + "\n" +
                "feature.popup.destroy();" + "\n" +
                "feature.popup = null;" + "\n" +
                "}" + "\n" +

                "map.addControl(controls['selector']);" + "\n" +
                "controls['selector'].activate();" + "\n" +

                "</script>";

            Session["sess_x"] = x;
        }