Routed Direction using GooglemapforAsp.net control - asp.net

I'm trying to research the routed direction using google maps for asp.net control. Here is my Code.
GoogleMapForASPNet1.GoogleMapObject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
GoogleMapForASPNet1.GoogleMapObject.Width = "1100px";
GoogleMapForASPNet1.GoogleMapObject.Height = "600px";
GoogleMapForASPNet1.GoogleMapObject.ZoomLevel = 10;
GoogleMapForASPNet1.GoogleMapObject.CenterPoint = new GooglePoint("1", 1.352083, 103.819836);
GoogleMapForASPNet1.GoogleMapObject.ShowTraffic = true;
int count=0;
bool flag = false;
GoogleMapForASPNet1.GoogleMapObject.Points.Clear();
foreach (var gitem in tblG)
{
foreach (var item in tblDT)
{
if (item.Latitude==gitem.Latitude && item.Longitude==gitem.Longitude && flag!=true)
{
count += 1;
GooglePoint GP1 = new GooglePoint();
GP1.ID = "GP" + count.ToString();
GP1.Latitude = Convert.ToDouble(gitem.Latitude);//latitude;
GP1.Longitude = Convert.ToDouble(gitem.Longitude);
GP1.InfoHTML = " Name:<b>" + Name + "</b></br>Point:<b>" + "GP" + count.ToString() + "</b></br>Time:<b>" + gitem.CDate.ToString() + "</b></br>";//stime;
GoogleMapForASPNet1.GoogleMapObject.Points.Add(GP1);
string address = gitem.Latitude + "," + gitem.Longitude;
GoogleMapForASPNet1.GoogleMapObject.Directions.Addresses.Add(address);
flag = true;
}
}
flag = false;
}
I want it as Routed Direction is only between start and End point.
But I got result look like driving Direction. I don't want to get that result. How to fix that problem?

Related

Trouble integrating Woocommerce order details into Google Sheet with Google App Script API

I have an API that automatically pulls new order details from my Woocommerce store into a Google Sheet. It seems to be working however, it has failed to pull the first 7 orders into my google sheet. It has all of the orders after the first 7. How do I get it to pull the first 7 orders into the sheet?
Here is my Google App Script:
function start_sync() {
// Followed instructions at https://github.com/mithunmanohar/woocommerce-orders-google-sheets-integration
var sheet_name = "OrderDetails"
update_order_5_min(sheet_name)
}
function update_order_5_min(sheet_name) {
var ck = "ck_ed82fae51e5bafce28dde95224db9c9c4bd36dba";
var cs = "cs_9a16fd7b641769a65412f336de3e7a928f7e153c";
var website = "https://www.funtrackdayz.com";
var now = new Date();
var website_t ="240";
var min = website_t * 60
now.setMinutes(now.getMinutes() - min);
var n = now.toISOString();
var surl = website + "/wc-api/v3/orders?consumer_key=" + ck + "&consumer_secret=" + cs + "&status=processing&filter[created_at_min]=" + n //"&after=2016-10-27T10:10:10Z"
// var surl = website + "/wc-api/v3/orders?consumer_key=" + ck + "&consumer_secret=" + cs + "&status=processing"
// &filter[created_at_min]=" + n //"&after=2016-10-27T10:10:10Z"
var url = surl
var options = {
"method": "GET",
"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
"muteHttpExceptions": true,
};
var result = UrlFetchApp.fetch(url, options);
if (result.getResponseCode() == 200) {
var params = JSON.parse(result.getContentText());
}
var doc = SpreadsheetApp.getActiveSpreadsheet();
var temp = doc.getSheetByName(sheet_name);
var consumption = {}
//"orders"
arrayLength = params["orders"].length
for (var i = 0; i < arrayLength; i++) {
var container = [];
a = container.push(params["orders"][i]["billing_address"]["first_name"]);
a = container.push(params["orders"][i]["billing_address"]["last_name"]);
a = container.push(params["orders"][i]["billing_address"]["address_1"] + ", " + params["orders"][i]["billing_address"]["address_2"]);
a = container.push("");
a = container.push(params["orders"][i]["billing_address"]["city"]);
a = container.push(params["orders"][i]["billing_address"]["state"]);
a = container.push(params["orders"][i]["billing_address"]["postcode"]);
a = container.push(params["orders"][i]["billing_address"]["phone"]);
a = container.push(params["orders"][i]["billing_address"]["email"]);
a = container.push(params["orders"][i]["total"]); //price
a = container.push(params["orders"][i]["payment_details"]["method_id"]);
c = params["orders"][i]["line_items"].length;
items = "";
skus="";
for (var k = 0; k < c; k++) {
item = params["orders"][i]["line_items"][k]["name"];
qty = params["orders"][i]["line_items"][k]["quantity"];
sku = params["orders"][i]["line_items"][k]["sku"];
meta = ""
try {
meta = params["orders"][i]["line_items"][k]["meta"][0]["value"];
meta = " - " + meta
} catch (err) {
meta = ""
}
item_f = qty + " x " + item + meta
items = items + item_f + ",\n"
skus = skus + ",\n"
}
a = container.push(items)
a = container.push(sku)
// a = container.push(params["orders"][i]["total_line_items_quantity"]); // Quantity
a = container.push(params["orders"][i]["order_number"]); //
a = container.push(params["orders"][i]["note"])
a = container.push(params["orders"][i]["created_at"]);
var doc = SpreadsheetApp.getActiveSpreadsheet();
var temp = doc.getSheetByName(sheet_name);
temp.appendRow(container);
removeDuplicates(sheet_name)
}
}
function removeDuplicates(sheet_name) {
var doc = SpreadsheetApp.getActiveSpreadsheet();
var sheet = doc.getSheetByName(sheet_name);
var data = sheet.getDataRange().getValues();
var newData = new Array();
for (i in data) {
var row = data[i];
var duplicate = false;
for (j in newData) {
if (row.join() == newData[j].join()) {
duplicate = true;
}
}
if (!duplicate) {
newData.push(row);
}
}
sheet.clearContents();
sheet.getRange(1, 1, newData.length, newData[0].length).setValues(newData);
}

Want to get data from other website in asp.net

I am trying to get data from other website using NuGet but its not get anything.
var aTags showing null value.
var getHtmlWeb = new HtmlWeb();
var document = getHtmlWeb.Load("https://www.google.com");
var aTags = document.DocumentNode.SelectNodes("//a");
int counter = 1;
if (aTags != null)
{
foreach (var aTag in aTags)
{
Label1.Text += counter + ". " + aTag.InnerHtml + " - " + aTag.Attributes["href"].Value + "\t" + "<br />";
counter++;
}
}

Creating a Dynamic Menu

I want to created a vertical dynamic menu with menu items that pop when needed. For example, menu has all country names and when you roll over a country, sub menu city names becomes visible. I chose the UL method to do this. So far I can make the menu list etc, but I have no idea how to make the sub menus visible and hide on roll over of country. Here is the code I got.
qString = "SELECT t.cID, t.cCountry, t.cPlace, t.cRating FROM tplaces AS t ORDER BY t.cCountry ASC, t.cPlace";
dtMenuPlaces = GetTable(qString);
int placeMenuWidth = 130;
int placeMenuHeight = 40;
if (dtMenuPlaces != null)
{
int menuY = 0;
string previousCountry = "";
int previousBGColor = 0;
Random rand = new Random();
string fnMenuBG = "blankblockBlue";
HtmlGenericControl mainLI = new HtmlGenericControl("li");
HtmlGenericControl subUL = new HtmlGenericControl("ul");
for (int x = 0; x < dtMenuPlaces.Rows.Count; x++)
{
int rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
int cPlaceID = Convert.ToInt32(dtMenuPlaces.Rows[x][0]);
string cCountry = dtMenuPlaces.Rows[x][1].ToString();
string cPlace = dtMenuPlaces.Rows[x][2].ToString();
int cRating = Convert.ToInt32(dtMenuPlaces.Rows[x][3]);
string tempUrl = cCountry + cPlace + ".aspx";
tempUrl = tempUrl.Replace(" ", "");
tempUrl += "?fVar1=place&" + "fVar2=" + cPlace + "&fVar3=" + cCountry;
System.Text.StringBuilder tString = new System.Text.StringBuilder();
// used to make multiline buttons.
if (cPlace != "")
{
// tString.Append(Environment.NewLine);
tString.AppendLine(cPlace);
}
else
{
tString.AppendLine(cCountry);
}
if (previousCountry != cCountry)
{
rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
while (rnMenuBG == previousBGColor)
{
System.Diagnostics.Debug.WriteLine("Random - #" + rnMenuBG + " P " + previousBGColor);
rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
}
fnMenuBG = "blankblock" + arrayMenuButtonNames[rnMenuBG];
mainLI = new HtmlGenericControl("li");
menuPlaces.Controls.Add(mainLI);
HtmlGenericControl mainA = new HtmlGenericControl("a");
mainA.Attributes.Add("href", tempUrl);
mainA.InnerText = tString.ToString();
// mainA.Attributes.Add("onmouseover", "mainLI.style.display='none'");
// mainA.Attributes.Add("onmouseout", "mainLI.style.display='block'");
mainA.Attributes.Add("style", "text-decoration: none;width:" + placeMenuWidth + "px;height:" + placeMenuHeight + "px;line-height:" + placeMenuHeight + "px;");
mainLI.Controls.Add(mainA);
subUL = new HtmlGenericControl("ul");
mainLI.Controls.Add(subUL);
mainLI.ID = "mainList";
previousCountry = cCountry;
previousBGColor = rnMenuBG;
// mainLI.Style["Background-image"] = "url:('images/gfx/" + fnMenuBG + ".gif'); no-repeat;";
mainLI.Attributes.Add("style", "display:block;position:absolute;top:" + menuY + "px;font-size:14px;font-family:century gothic;text-align: center;font-weight:bold;background:url('images/gfx/" + fnMenuBG + ".gif'); background-repeat:no-repeat;");
// mainLI.Attributes.Add("style", "background:url('images/gfx/" + fnMenuBG + ".gif'); background-repeat:no-repeat;");
menuY += placeMenuHeight + 5;
}
else
{
rnMenuBG = previousBGColor;
fnMenuBG = "blankblock" + arrayMenuButtonNames[rnMenuBG];
/// add SUB place if not main country.
HtmlGenericControl subLI = new HtmlGenericControl("li");
subUL.Controls.Add(subLI);
subUL.Attributes.Add("style", "display:block;position:relative;top:-" + placeMenuHeight + "px;left:" + placeMenuWidth + "px;margin: 0px; padding:0px;width:" + placeMenuWidth + "px;list-style-type:none;");
HtmlGenericControl subA = new HtmlGenericControl("a");
subA.Attributes.Add("href", tempUrl);
// subA.Attributes.Add("onmouseover", "this.style.color=\"red\"");
// subA.Attributes.Add("onmouseout", "this.style.color=\"black\"");
// subA.Attributes.Add("onclick", "this.style.color=\"yellow\"");
subA.Attributes.Add("style", "text-decoration: none;display:block;width:" + placeMenuWidth + "px;height:" + placeMenuHeight + "px;line-height:" + placeMenuHeight + "px;");
subA.InnerText = tString.ToString();
subLI.Controls.Add(subA);
// subLI.Style["Background-image"] = "url:('images/gfx/" + fnMenuBG + ".gif'); no-repeat;";
subLI.Attributes.Add("style", "width:" + placeMenuWidth + "px;height:" + placeMenuHeight + "px;margin:0px;margin-bottom:5px;;padding:0px;font-size:14px;font-family:century gothic;text-align: center;font-weight:bold;background:url('images/gfx/" + fnMenuBG + ".gif'); background-repeat:no-repeat;");
// subLI.Attributes.Add("style", "font-size:14px;font-family:century gothic;text-align: center;font-weight:bold");
// subLI.Attributes.Add("style", "background:url('images/gfx/" + fnMenuBG + ".gif'); background-repeat:no-repeat;");
}
}
}
Also is it better to create HTMLGENERICCONTROLS or adding literal controls to a string builder?
heres a snippet of Jquery that might help you for the mouseover and mouseout, i picked it from a Jquery plugin :
$(document).ready(function(){
var el = $('li');
var hidden_ul = $('.hidden')
el.on('mouseover mouseout', function(e) {
$(this).find('.hidden').css({'display' : 'block'});
e.type == 'mouseout' && $(this).find('.hidden').css({'display' : 'none'});
}); //---------------------------- End on function.
});
I have constructed a simple responsive menu , which might help you understand , what i mean as a whole check out the fiddle below :
fiddle
incase you are not comfortable with Jquery , just remove the Jquery code and add the following peice of CSS in the stylesheet :
ul li a:hover + ul ,.hidden:hover{
display: block;
}
The original menu i build was intended to be CSS only , but i am giving you both a CSS as well as a Jquery solution , you can pick whichever one is more suited to you. :)
Cheers.
I was close to getting to work with HTMLGENERIC method, but I decided to rewrite the whole thing using stringbuilder and it worked. adding like u said to main.css plus in C#.
System.Text.StringBuilder sbMenu = new System.Text.StringBuilder();
qString = "SELECT t.cID, t.cCountry, t.cPlace, t.cRating FROM tplaces AS t ORDER BY t.cCountry ASC, t.cPlace";
dtMenuPlaces = GetTable(qString);
if (dtMenuPlaces != null)
{
string previousCountry = "";
int previousBGColor = 0;
Random rand = new Random();
string fnMenuBG = "blankblockBlue";
// HtmlGenericControl mainLI = new HtmlGenericControl("li");
// HtmlGenericControl subUL = new HtmlGenericControl("ul");
for (int x = 0; x < dtMenuPlaces.Rows.Count; x++)
{
int rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
int cPlaceID = Convert.ToInt32(dtMenuPlaces.Rows[x][0]);
string cCountry = dtMenuPlaces.Rows[x][1].ToString();
string cPlace = dtMenuPlaces.Rows[x][2].ToString();
int cRating = Convert.ToInt32(dtMenuPlaces.Rows[x][3]);
string tempUrl = cCountry + cPlace + ".aspx";
tempUrl = tempUrl.Replace(" ", "");
tempUrl += "?fVar1=place&" + "fVar2=" + cPlace + "&fVar3=" + cCountry;
System.Text.StringBuilder tString = new System.Text.StringBuilder();
// used to make multiline buttons.
if (cPlace != "")
{
// tString.Append(Environment.NewLine);
tString.AppendLine(cPlace);
}
else
{
tString.AppendLine(cCountry);
if (x != 0)
{
sbMenu.Append("</ul>");
}
}
if (previousCountry != cCountry)
{
rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
while (rnMenuBG == previousBGColor)
{
System.Diagnostics.Debug.WriteLine("Random - #" + rnMenuBG + " P " + previousBGColor);
rnMenuBG = rand.Next(1, arrayMenuButtonNames.Length) - 1;
}
fnMenuBG = "blankblock" + arrayMenuButtonNames[rnMenuBG];
sbMenu.Append("<li class='subMenuPlaces' style = background:url('images/gfx/" + fnMenuBG + ".gif');background-repeat:no-repeat;><a href='" + tempUrl + "'>" + tString.ToString() + "</a><ul class='subList'>");
previousCountry = cCountry;
previousBGColor = rnMenuBG;
}
else
{
rnMenuBG = previousBGColor;
fnMenuBG = "blankblock" + arrayMenuButtonNames[rnMenuBG];
sbMenu.Append("<li class='subMenuPlaces' style = background:url('images/gfx/" + fnMenuBG + ".gif');background-repeat:no-repeat;><a href='" + tempUrl + "'>" + tString.ToString() + "</a></li>");
}
}
menuPlaces.InnerHtml = sbMenu.ToString();
}

Updating existing fields in MS Access database through classic ASP

I've been given working ASP code which I have to change in order to update existing data in database insted of creating new entries. I think I should swap INSERT INTO statment with UPDATE but the code is a bit too coplicated for me to figure out where and what to change.
Here it comes:
// *** Edit Operations: declare variables
// set the form action variable
var MM_editAction = Request.ServerVariables("SCRIPT_NAME");
if (Request.QueryString) {
MM_editAction += "?" + Server.HTMLEncode(Request.QueryString);
}
// boolean to abort record edit
var MM_abortEdit = false;
// query string to execute
var MM_editQuery = "";
// *** Insert Record: set variables
if (String(Request("MM_insert")) == "AddRecord") {
var MM_editConnection = MM_PhoneWeb_conn_STRING;
var MM_editTable = "Employees";
var MM_editRedirectUrl = "userRegister.asp";
var MM_fieldsStr = "textSurname|value|textFirstname|value|textUsername|value|textPass|value";
var MM_columnsStr = "Surname|',none,''|FirstName|',none,''|Username|',none,''|Password|',none,''";
// create the MM_fields and MM_columns arrays
var MM_fields = MM_fieldsStr.split("|");
var MM_columns = MM_columnsStr.split("|");
// set the form values
for (var i=0; i+1 < MM_fields.length; i+=2) {
MM_fields[i+1] = String(Request.Form(MM_fields[i]));
}
// append the query string to the redirect URL
if (MM_editRedirectUrl && Request.QueryString && Request.QueryString.Count > 0) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + Request.QueryString;
}
}
// *** Insert Record: construct a sql insert statement and execute it
if (String(Request("MM_insert")) != "undefined") {
// create the sql insert statement
var MM_tableValues = "", MM_dbValues = "";
for (var i=0; i+1 < MM_fields.length; i+=2) {
var formVal = MM_fields[i+1];
var MM_typesArray = MM_columns[i+1].split(",");
var delim = (MM_typesArray[0] != "none") ? MM_typesArray[0] : "";
var altVal = (MM_typesArray[1] != "none") ? MM_typesArray[1] : "";
var emptyVal = (MM_typesArray[2] != "none") ? MM_typesArray[2] : "";
if (formVal == "" || formVal == "undefined") {
formVal = emptyVal;
} else {
if (altVal != "") {
formVal = altVal;
} else if (delim == "'") { // escape quotes
formVal = "'" + formVal.replace(/'/g,"''") + "'";
} else {
formVal = delim + formVal + delim;
}
}
MM_tableValues += ((i != 0) ? "," : "") + MM_columns[i];
MM_dbValues += ((i != 0) ? "," : "") + formVal;
}
MM_editQuery = "insert into " + MM_editTable + " (" + MM_tableValues + ") values (" + MM_dbValues + ")";
if (!MM_abortEdit) {
// execute the insert
var MM_editCmd = Server.CreateObject('ADODB.Command');
MM_editCmd.ActiveConnection = MM_editConnection;
MM_editCmd.CommandText = MM_editQuery;
MM_editCmd.Execute();
MM_editCmd.ActiveConnection.Close();
if (MM_editRedirectUrl) {
Response.Redirect(MM_editRedirectUrl);

Read cookie in javascript

This is my asp code, can be the same done in Javascript?
HttpCookie cookie = this.Request.Cookies["Votes"];
if (cookie != null)
if (cookie.Values.Get(id.ToString()) == "true") return true;
return false;
function readTheCookie(the_info)
{
// load the cookie into a variable and unescape it
var the_cookie = document.cookie;
var the_cookie = unescape(the_cookie);
// separate the values from the cookie name
var broken_cookie = the_cookie.split("some parameter"); // parameter depends on how the cookie is stored
var the_values = broken_cookie["some index"]; // index of the value that you want
}
These are all the parts of reading a cookie, you can use this snippet to achieve what you want.
document.cookie gives you access to the cookies in JavaScript. You will need to do some parsing to do what you want to do.
using this code
function setCookie(c_name, value, exdays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + exdays);
var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
document.cookie = c_name + "=" + c_value;
}
function getCookie(c_name) {
var i, x, y, ARRcookies = document.cookie.split(";");
for (i = 0; i < ARRcookies.length; i++) {
x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
x = x.replace(/^\s+|\s+$/g, "");
if (x == c_name) {
return unescape(y);
}
}
}
function GetSetCookie() {
var version = getCookie("version");
if (version != null && version != "") {
if (version == 'full') {
version = 'text';
}
else {
version = 'full';
}
}
else {
version = 'full';
}
setCookie("version", version, 365);
window.top.location.reload();
}
I have found this code in W3schools which works for me
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1);
if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
}
return "";
}
function checkCookie() {
var user = getCookie("username");
if (user != "") {
alert("Welcome again " + user);
} else {
user = prompt("Please enter your name:", "");
if (user != "" && user != null) {
setCookie("username", user, 365);
}
}
}

Resources