Forums: [SOLVED] how to call external website/function/api - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

[SOLVED] how to call external website/function/api Rate Topic: -----

#1 User is offline   Michael Fiil 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 06-December 17

Posted 02 February 2018 - 04:20 PM

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
0

#2 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 16110
  • Joined: 03-February 03
  • Gender:Male

Posted 02 February 2018 - 06:00 PM

The same code will work:
https://stackoverflo...load-a-web-page
Best regards,
Sergey Kornilov
0

#3 User is offline   Michael Fiil 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 06-December 17

Posted 02 February 2018 - 07:16 PM

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: <br>");
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 ® Build Engine, version 4.7.2053.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright © 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,
0

#4 User is offline   Michael Fiil 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 06-December 17

Posted 18 February 2018 - 07:05 PM

Thanks Sergey,

Solved by rasing My link

Thank yiu

Michael
0

#5 User is offline   Eric_ 

  • Member
  • PipPip
  • Group: Members
  • Posts: 16
  • Joined: 20-April 17

Posted 05 April 2018 - 03:46 PM

View PostMichael Fiil, on 18 February 2018 - 02:05 PM, said:

Thanks Sergey,

Solved by rasing My link

Thank yiu

Michael


Hey what was the solution? the link is broken.
0

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users