does this code do what i need it to do - c#

Hi I am trying to create a store locator and I am trying to get the user to input their location manually and then convert that into latitude and longitude without use of googles API due to the restrictions of it T&C and I have come across this piece of code will this do what I need it to do and if it doesn't is there a way I can use this to get what I want.
This code is c# and and i got it from this link http://code.google.com/p/geocoding-net/
IGeoCoder geoCoder = new GoogleGeoCoder("my-api-key");
Address[] addresses = geoCoder.GeoCode("123 Main St");
The reasons why I ask is because I don't have much experience within C# I just need someone to maybe point me in the right direction I just a little help from someone to you need to look into this or an example to work off I don't mind learning new code I'm just not sure what I'm looking for to get this to work.

Looking at your 2 previous questions1and 2 you have PHP available. This means you will probably have MySQL available as well.
You can use the zipcode/postcode of the user along with a database of these codes. These databases are available for most contries either free or for a fee.

This code doesn't do what I needed it to do because you still need to use someones API which is not what I wanted but it does work if you use googles API or someone elses API. im just wondering if anybody knows how to do this manually using javascript or c# or ajax without having to use an api to get it to work

Related

Accessing Acumatica through VB.Net ... getting started

Is anyone using VB.Net to access the Acumatica contract based REST API? I really need some help getting started. I am experienced in VB.Net, but new to Acumatica and I am a little overwhelmed by all of the documentation. I just want to start with something simple ... for example, log into Acumatica, get a list of stock parts & log out. Does anyone have any VB.Net code they would be willing to share? Or maybe a tutorial you could point me to? I spent a few hours looking through a lot of documentation but could not seem to find what I was looking for to get me started. I would appreciate any help you can provide. Thanks in advance...
I wrote a PHP binding for the Acumatica REST APIs. Some of the criticisms above are somewhat valid...it's a little unique as APIs go, and not very well documented. That's why to get started... you will want to get Postman: https://www.postman.com/
In Postman, setup a POST request to http://youracumsticaurl/entity/auth/login
Use JSON body with your user/pass/company details:
{
"name" : "admin",
"password" : "yourpass",
"company" : "Company name full text",
"locale" : "en-US"
}
for company....use the full text of the company in the tenant...not the id.
Next with Postman do a simple get request for an item:
http://localhost/Acumatica2021R2/entity/Default/20.200.001/StockItem/someitemid
...where "someitemid" is a valid stock item id
Once you get that far, you can start using Postman to write your VB.NET API calls. Here is some info on calling a REST web service with VB.NET: https://dotnetco.de/setup-post-rest-webservice-asp-net-vb-net/
It takes some messing around but the REST API works pretty well once you get your calls setup correctly. I login and logout on every call, which is probably not best practice but avoids some of the session management headaches with cookies and Acumatica. YMMV with that depending on use case and call volume.
I use the rest api client available on the Acumatica github site. (link below)
I'm using C# in my project, but there's no reason you couldn't use this library with vb.net.
I had to update the library to add custom fields and custom endpoints which would require you update the code in C#, but if you just want the base endpoints it should work fine.
https://github.com/Acumatica/AcumaticaRESTAPIClientForCSharp

Concerning Paypal and classic API

I have few questions concerning PayPal and Classic API. I have spent the last few days reading and experimenting with 1. Single PayPal Payment using variables and HTML post form. 2. Idem but for recurring/subscription payments. Even though I almost succeed to do most of what I want to accomplish, I still have few questions and grey zone I'd like to debunk.
Here it is:
Is it possible to use classic API, HTML form, PayPal variables and post a request to PayPal/Sandbox AND ONLY use credit card information, without having to log in PayPal or have a PayPal account? I never succeed and PayPal always block after you hit the PAY button, returning security codes error message or wrong card/account number etc.
If yes, how and where can I find a real code sample or demo for HTML/MVC-C#?
After a make a payment, I receive an invalid response which nothing happens, then, I receive a second IPN response and this one is verified etc. DO I really need to reply to PayPal/Sandbox to tell them everything is OK? If yes, is there info somewhere or code sample/demo I can see? MY point here is because i receive MANY hits on my IPN and I want to make sure I get the right response, make sure i don't DOUBLE subscribe etc..
Is there A GOOD MVC or C# IPN code sample somewhere? One I could read and analyse/take to handle most possible scenarios/errors/response code and what to do with them? not to copy and paste but something reliable I could adapt to my code.
I have succeeded to get a response to my IPN with a PayPal account only and I had to somehow hack security protocol using this instruction --> ServicePointManager.SecurityProtocol = (SecurityProtocolType)3072;//SecurityProtocolType.Tls1.2; and I also had to use ngrok to provide a 'valid' return URL. My question here is, Do I Need to remove that instruction when I go PROD?
Thank you so much in advance,
Mart.
Yes, but this is one of the reasons the question got voted down. You need to sign up for Payments Pro to do credit cards (or you could also use the REST API) and then you would use those specific APIs to process credit cards. The thing is, depending on what version of Pro you end up with or if you decide to go with REST, the APIs are different, so it's hard for anybody to tell you what to use at this point.
Yes, you need to POST back to PayPal to verify that the data actually came from them. This way you can trash any data where wannabe hackers are posting garbage to your IPN listener or anything else like that going on.
As long as your IPN script completes with a successful 200 response back from your server then PayPal will only send a single IPN. If you're getting multiples you must have a failure going on, in which case you'll need to troubleshoot that accordingly.
Yes, PayPal provides lots of sample code. This is another reason your question may have been voted down. It seems you have not taken the time to look into this stuff yourself. Go to http://developer.paypal.com and upon reviewing the APIs you'll find they provide SDKs for different languages. Each of those comes with samples, and their GitHub repos also include samples.
With a quick Google search you'll find loads of tutorials and samples as well, of course.
Within the developer site you'll also find the Integration Wizard, which will let you choose C#, choose the payment integration you want, and it will build it all for you so you can see how it works.
Then, when working on those samples or trying actual code, if you have specific problems / questions, you'd come here and post that specific issue with a code sample that you've tried. Then people here will be happy to help.
TLS 1.2 is a standard requirement for pretty much all web services now because of security vulnerabilities in SSLv3. If you have "hack" anything (outside of configuration files, maybe) then you're probably doing something unnecessary. All it would require is to ensure the software stack on your server not only supports TLS 1.2 HTTP requests, but also uses it by default.

Any tips on how i would go about extract Pandora likes and putting them on a spreadsheet? (C++/C#)

Fairly new to coding and i want a project to work on that could help me advance my skills. I'm not sure what language would be best for this sort of undertaking but i would definitely prefer to use C++ or C#.
For the first part of the program i basically would like to try and take all my pandora likes and put them on a spreadsheet with song name is one column and artist in the other. I don't see the formatting being too hard once i actually get the data i need, but i'm not really sure how to communicate with a server at all in this point in time. I'm guessing i probably won't be able to grab a raw list of likes so the i'm thinking my best course of action will be to first expand the likes list all the way, and then i need to read the text on the screen ro in the source code.
For the first step, expanding my like i found the HTML source code that actually does this:
<div class="show_more tracklike" data-nextLikeStartIndex="0" data-nextThumbStartIndex="5">Show more</div>"
Not sure if this is something i can work with but i was thinking if i could set data-nextThumbStartIndex="5" to be equal to the # of likes - 5 (the amount it shows by default) it would be fairly easy to expand the list. If not i would probably have to click the "show more" link repeatedly until i have all the likes on the page.
For the next step, getting the data i want, i think my best option would be to basically just grab the text that i physically see on the screen and worry about filtering and manipulating the data afterwards. The other option is looking at the source code, which i actually found the pieces of code where the info i want is stored. If i could retrieve the page's source code i think it would be relatively easy to pick out the data i actually want from that.
So yea that's about it, i know i'm pretty noob atm and what i'm saying is probably wrong and/or much more complicated than i think but i'm a pretty quick learner and at the very least if someone could point me in the right direction to communicate with a server that would be much appreciated.
This question is quite "wide" (and I have absolutely no knowledge of Pandora itself - can't access it from where I live).
In general, there are several different ways to solve this type of problem:
Screen Scraping - basically access the website as if you were a web-server, and from the HTML string that comes back, dig out the information you need. The problem here is that the data is not very suitable for "machine reading", as it often has no distinct points for the "reader" to find the relevant information, and it's difficult to sort the data from the "chaff".
AJAX api - "Asynchronous Java Script and XML" where the provider of the website has an interface to fetch certain data within to the web-browser - of course, if you "pretend" to be the web-browser, requesting the same type of information. You are relying on the website to have such an interface, but if it exists, the data is generally in a "more suitable form to be machine read" (typically XML, but not always).
JSON api - "Java Script Object Notation" is a similar solution to AJAX - like XML, JSON is a "human and machine readable format".
The latter two are definitely preferable, as the data coming back is meant for machine reading. The drawback is that you need to have "server side cooperation". The good thing here is that Pandora does have a JSON API. The bad thing is that it seems to be hard to use... Here's one discussion on the subject:
Making JSON calls to Unoffical Pandora API
The main principle here is that you send some stuff to the webserver, and receive a reply with the requested information. Exactly how this is done depends on the language/programming environment. A popular C++ solution is libcurl.
There is a Ruby Client here, using the JSON interface
https://github.com/nixme/pandora_client
A C# implementation to interface with Pandora is here:
http://pandoraunleashed.googlecode.com/svn/trunk/PandoraUnleashed/Pandora.cs
Unfortunately, I can't find any direct reference to "listing likes".

Working with monster.co.uk WSDL

I am a learner developer working on a project where I am required to post vacancies from our .Net based website to monster.co.uk but I have no idea as how to achieve this. This is my virtually my first project of XML (WSDL) integration. Here is what I have tried so far:
Create a reference to the desired WSDL file from monster.co.uk which is exposed at http://schemas.monster.com/current/WSDL/. But once the the objects are created in my Visual Studio project, I get stuck and don't know how to proceed from there. I consulted a couple of folks I thought may be able to help but in-vain. The documentation from monster is available from here http://doc.monster.com/real-time-posting.
I know I am asking for really basic stuff and should have been able to sort it out myself but have wasted 3 weeks and am no where. Please help!
I haven't read it in detail but from the second link with the documention my approach would be:
-Decide which Real Time Posting features to implement by reviewing the "Development Considerations" section of this guide.
Read the section and decide what are you going to use
Create the XML job posting by using the instructions in this guide and samples located in Monster's webservices toolkit
It seems you'll have to create a xml. First thing comes to mind is using a XmlDocument object and adding Nodes to it. But you may want to check other answers as there's different ways to do this. Create the xml in the format specified by Monster, you can check the samples they give to know how to do it
Validate XML using the toolkit.
(http://integrations.monster.com/Toolkit)
Go to the toolkit ulr and input the xml you are generating to check is correct
Test posting a job from your application (Applicant Tracking System, etc).
You do this calling methods from the Web service(e.g.: UpdateJobs) with your generated xml
Review the job posting response, make the necessary changes and
retest.
Check the testing section at the end. It says you can post into the demo board for you test.
Once the test cycle is complete, transition to production using the steps outlined in the "Deployment" section of this guide.
Once you are happy with the testing in UAT read this to know how to release to production.
--
EDIT to add more info after question was clarified
I understand the problem now. I added a Web service reference to https://gateway.monster.com:8443/bgwBroker and in the object that returns I can see a lot of data structures. However I was able to find a BusinessGatewayInterface that has the needed operations. Check the code below. I am sure it is not what you need but it may give you an idea of what to do. Then it will be an issue of exploring the Web service reference until you find what you need.
Also it seems it won't be needed to parse the xml directly but instead there are typed data structures that can be populated. Sorry I didn't realized that the first I looked into it
Job job = new Job();
UpdateJobRequest updateJobRequest = new UpdateJobRequest();
//populate job info here
updateJobRequest.Job = job;
ServiceReference1.BusinessGatewayInterface gateway = new BusinessGatewayInterfaceClient();
gateway.UpdateJob(updateJobRequest);
MonsterBusinessGatewayService gateway = new MonsterBusinessGatewayService();
gateway.Url = "https://208.71.198.74:8443/bgwBroker";
gateway.Proxy = proxy;
proxy.Credentials = cre;
gateway.UseDefaultCredentials = true;
gateway.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
gateway.Security = security;
security.UsernameToken = user;
user.Password = pass;
gateway.Security.UsernameToken.Username = "xtestxftp";
gateway.Security.UsernameToken.Password.Value = "ftp12345";
Job job = new Job();
JobsResponse jobresp = gateway.UpdateJob(job);
I'm working with Monster real time and I implemented this code to send request to Monster Business Gateway. May this can help also

SQL 2008: returning data rows as JSON?

I think this question is like clay pidgeon shooting.. "pull... bang!" .. shot down.. but nevertheless, it's worth asking I believe.
Lots of JS frameworks etc use JSON these days, and for good reason I know. The classic question is "where to transform the data to JSON".
I understand that at some point in the pipeline, you have to convert the data to JSON, be it in the data access layer (I am looking at JSON.NET) or I believe in .NET 4.x there are methods to output/serialize as JSON.
So the question is:
Is it really a bad idea to contemplate a SQL function to output as JSON?
Qualifier:
I understand trying to output 1000's of rows like that isn't a good idea - in fact not really a good idea for web apps either way unless you really have to.
For my requirement, I need possibly 100 rows at a time...
The answer really is: it depends.
If your application is a small one that doesn't receive much use, then by all means do it in the database. The thing to bear in mind though is, what happens when your application is being used by 10x as many users in 12 months time?
If it makes it quick, simple and easy to implement JSON encoding in your stored procedures, rather than in your web code and allows you to get your app out and in use, then that's clearly the way to go. That said, it really doesn't take that much work to do it "properly" with solutions that have been suggested in other answers.
The long and short of it is, take the solution that best fits your current needs, whilst thinking about the impact it'll have if you need to change it in the future.
This is why [WebMethod] (WebMethodAttribute) exists.
Best to load the data to to the piece of program and then return it as JSON.
.NET 4 has a support for returning json, and i did it as a part of one ASP.NET MVC site and it was fairly simple and straightforward.
I recommend to move the transformation out of the sql server
I agree with the other respondents that this is better done in your application code. However... this is theoretically possible using SQL Server's ability to include CLR assemblies in the database using create assembly syntax. The choice is really yours. You could create an assembly to do the translation in .net, define that assembly to SQL Server and then use contained method(s) to serialize to JSON as return values from your stored procedures...
Better to load it using your standard data access technique and then convert to JSON. You can then use it in standard objects in .NET as well as your client side javascript.
If using .net mvc you serialize your results in your controllers and output a JsonResult, there's a method Controller.Json() that does this for you. If using webforms an http handler and the JavascriptSerializer class would be the way to go.
Hey thanks for all the responses.. it still amazes me how many people out there have the time to help.
All very good points, and certainly confirmed my feeling of letting the app/layer do the conversion work - as the glue between the actual data and frontend. I guess I haven't kept up too much with MVC or SQL-2008, and so was unsure if there were some nuggets worth tracking down.
As it worked out (following some links posted here, and further fishing) I have opted to do the following for the time being (stuck back using .NET 3.5 and no MVC right now..):
Getting the SQL data as a datatable/datareader
Using a simple datatable > collection (dictionary) conversion for a serializable list
Because right now I am using an ASHX page to act as the broker to the javascript (i.e.
via a JQuery AJAX call), within my ASHX page I have:
context.Response.ContentType = "application/json";
System.Web.Script.Serialization.JavaScriptSerializer json = new System.Web.Script.Serialization.JavaScriptSerializer();
I can then issue: json.serialize(<>)
Might seem a bit backward, but it works fine.. and the main caveat is that it is not ever returning huge amounts of data at a time.
Once again, thanks for all the repsonses!

Categories