This topic is locked
[SOLVED]

 how to call external website/function/api

2/2/2018 11:20:57 AM
ASPRunner.NET General questions
A
admin author

Hi Experts,
Using another developing Tool i had this code:
var client = new WebClient();

var text = client.DownloadString("http://ojabiler.dk/sms/emailarbejdskort.asp?sagnr="; + rnoo);
How to code the same in asprunner.net
Best regards Newbie Michael

A
admin author 2/2/2018

Thanks Sergey,
I am really newbi in C# so i hope for more help!
On an add page i need to send a mail to managers if a new order are confirmed.
I have tryed this in asprunner.net addpage customadd event:
dynamic tblsales = GlobalVars.dal.Table("afdelingbilordrer");

dynamic tblCars = GlobalVars.dal.Table("bildata");

string sql = "SELECT MAX(ordrenr) as c FROM afdelingbilordrer";

XVar rs = tDAL.CustomQuery(sql);

XVar data = CommonFunctions.db_fetch_array(rs);

int rnoo = data["c"] + 1;

if (values["ostatus"] == '2')

{

tblCars.Param["bilid"] = values["bilnr"];

tblCars.Value["afdelingid"] = values["afdeling"];

tblCars.Value["kostprisdkk"] = values["prisexmoms"] + values["extrapris"];

tblCars.Value["engrosprisemo"] = 0;

tblCars.Value["indkoeber"] = values["bestiltaf"];

tblCars.Value["oprettet"] = values["kdato"];

tblCars.Value["klargoomk"] = 0;

tblCars.Value["egenwebside"] = "";

tblCars.Update();

string email = "michael@ojabiler.dk";

string from = "salg@leasebil.nu";

string msg = "Hello there\nBest regards";

string subject = "Sample subject";

XVar result;

result = MVCFunctions.runner_mail(new XVar("to", email, "cc", "michael@leasebil.nu", "subject", subject, "body", msg, "from", from));

if(!result["mailed"])

{

MVCFunctions.EchoToOutput("Error happened:
");

MVCFunctions.EchoToOutput(result["message"]);

}

}

tblSales.Value["afdeling"] = values["afdeling"];

tblSales.Value["bilnr"] = values["bilnr"];

tblSales.Value["kdato"] = values["kdato"];

tblSales.Value["bestiltaf"] = values["bestiltaf"];

tblSales.Value["prisexmoms"] = values["prisexmoms"];

tblSales.Value["extrapris"] = values["extrapris"];

tblSales.Value["skalklargoeres"] = values["skalklargoeres"];

tblSales.Value["skaltoldsynes"] = values["skaltoldsynes"];

tblSales.Value["skalmales"] = values["skalmales"];

tblSales.Value["skalleveres"] = values["skalleveres"];

tblSales.Value["ostatus"] = values["ostatus"];

tblSales.Add();

XSession.Session["bilid"] = null;

return false;
No error and no email!!
i have a Classic VB script called emailarbejdskort.asp on the same server, which do the Work sending an email,

but if i put this in the addpage customadd event:
dynamic tblUsers = GlobalVars.dal.Table("afdelingbilordrer");

dynamic tblCars = GlobalVars.dal.Table("bildata");

string sql = "SELECT MAX(ordrenr) as c FROM afdelingbilordrer";

XVar rs = tDAL.CustomQuery(sql);

XVar data = CommonFunctions.db_fetch_array(rs);

int rnoo = data["c"] + 1;

var client = new WebClient();

if (values["ostatus"] == '2')

{

tblCars.Param["bilid"] = values["bilnr"];

tblCars.Value["afdelingid"] = values["afdeling"];

tblCars.Value["kostprisdkk"] = values["prisexmoms"] + values["extrapris"];

tblCars.Value["engrosprisemo"] = 0;

tblCars.Value["indkoeber"] = values["bestiltaf"];

tblCars.Value["oprettet"] = values["kdato"];

tblCars.Value["klargoomk"] = 0;

tblCars.Value["egenwebside"] = "";

tblCars.Update();

var text = client.DownloadString("http://ojabiler.dk/sms/emailarbejdskort.asp?sagnr="; + rnoo);

}

tblUsers.Value["afdeling"] = values["afdeling"];

tblUsers.Value["bilnr"] = values["bilnr"];

tblUsers.Value["kdato"] = values["kdato"];

tblUsers.Value["bestiltaf"] = values["bestiltaf"];

tblUsers.Value["prisexmoms"] = values["prisexmoms"];

tblUsers.Value["extrapris"] = values["extrapris"];

tblUsers.Value["skalklargoeres"] = values["skalklargoeres"];

tblUsers.Value["skaltoldsynes"] = values["skaltoldsynes"];

tblUsers.Value["skalmales"] = values["skalmales"];

tblUsers.Value["skalleveres"] = values["skalleveres"];

tblUsers.Value["ostatus"] = values["ostatus"];

tblUsers.Add();

XSession.Session["bilid"] = null;

return false;
i get this compiling error error in asprunner.net:
\\ ERP_LeaseBil_nuEventsCS.csproj

Microsoft (R) Build Engine, version 4.7.2053.0

[Microsoft .NET Framework, version 4.0.30319.42000]

Copyright (C) Microsoft Corporation 2007. Alle rettigheder forbeholdes.
include\afdelingbilordrer_TableEvents.cs(62,18): error CS0246: Type or namespace 'WebClient' not found or 'using' directive missing?) [C:\Users\Auto\Documents\ASPRunnerNETProjects\ERP-LeaseBil.nu\output\ERP_LeaseBil_nuEventsCS.csproj]
Thanks in advance
Michael,

A
admin author 2/18/2018

Thanks Sergey,
Solved by rasing My link
Thank yiu
Michael

J
jetsguy 4/5/2018



Thanks Sergey,
Solved by rasing My link
Thank yiu
Michael


Hey what was the solution? the link is broken.