How to upload applications written in C# onto a website using Drupal? - c#

Please answer for Dummies ;) ... Absolute newbie to web programming, especially new to Drupal. We have some modules written in C#, that access a database in MySQL and works on it (it's a student information system actually. We have some forms created in C#, through which interface student's can enter their details onto the database and we have desktop applications which work on those data). Now we need to create a website so that student's can enter information through the internet. We can not re-write the whole modules in PHP, and we want to use Drupal to create the website. So how to do that?

Not really a direct answer, but some points that you need to consider. How complicated this will be depends on how much interoperability you need between the C# code and Drupal.
Does Drupal need to use the forms written in C# in order to enter the data in the DB, or could data entry be done directly from PHP (As in, is there any validation or processing of data in the C# forms that needs to be done?) If not, it seems like the easiest way would be to build a page in Drupal that can enter the data directly into the MySQL database.
Otherwise, the easiest way to get the programmes to talk to each other might be outputting the data to another format — e.g. XML or JSON. (Here's a similar question with someone using JSON as the intermediary data type) You could have your PHP form create an XML document in a temp folder, with the C# programme polling this folder for new files every X minutes and use them as an input into its application.
It will really depend on your workflow — how immediate does the processing of data need to be? Is the flow of data in/out, or in only — i.e does there need to be a set of results returned to the user?

Related

C# Web Application Form using Stored Procedure

As a DBA/SQL Server Developer, I'm often asked to produce web pages where users can view the data in the database and edit them, and see the edits they've made straight away (without refreshing the page). I know nothing about ADO.NET or C#, but I would like to be able to give users this very simple functionality. Essentially I'm looking for three things:
to display a table of data in a webpage retrieved from a SQL Server stored procedure
to display a text box in the same webpage where users can input data
to display a button in the webpage that takes the inputted data from the text box, runs it through the stored procedure as a parameter, and refreshes the table.
Ideally I'd like this all to happen without the user having to refresh the webpage.
My questions are: is this kind of thing possible? How difficult is it to achieve? And how do I do it? I don't have the time to learn web development in full. I wouldn't need the vast majority of skills I'd learn even if I did learn it in full. I just really need this basic functionality, to produce ultra simple pages when user requests come in.
If anyone knows of any examples of just this kind of thing, that I can copy, they would be greatly appreciated!
You don't really need to use MVC, WebForms or even C# for that matter. Using one of those would be killing a ant with a rocket launcher.
Look into node.js and pug, using a RESTFUL API to deliver the information you need. I don't believe you will need more than two hours to provide your users with the interface you told us.
Node has a awesome package called express, it sets up everything for you and uses Pug on the starter template.
You can check out a tutorial right here.
Actually it will also take 2 hours doing with Webforms or MVC . I recommend using Entity Framework to make it super simple.
Webforms may be a bit older technology but will be faster to develop this specific page (assuming you only targeting Desktop users). Otherwise MVC is the way to go.
You can Check the tutorial.
https://learn.microsoft.com/en-us/aspnet/mvc/overview/getting-started/introduction/getting-started

Using C# can I communicate with webpages and local desktop programs?

I am very new to C# and Microsoft Visual Studio, so, with that in mind, I am teaching myself and have started a project (excuse my lack of vocabulary). What I have so far is a WPF project that looks good but offers zero functionality. The general functionality I envision is this:
The Main Window has multiple buttons which navigate to multiple pages. (Achieved this already)
On each page navigated to, I want to display information from a website. (?)
Using the web information, I want control another program on the desktop. (?)
Are points (2) and (3) possible using C#?
Let me illustrate the scenario. A person submits information (username) into a website. That website contacts a server and sends back data about that person/username. The website then stores this data and usernames on a list visible to the users. There are five different lists and five navigable xaml pages via the main window on the program. I want to display each list on each page. Using the data found on the website and now my program, I want to send a command to a program/script running on the desktop and have it perform an action (type the usernames somewhere using AutoHotKey and AutoScriptWriter, which is essentially updating a special notepad file).
The answers I am looking for are not "this is how you do specifically what you're asking" but rather "Use these tools/features in C# and start there". If what I want from this program is possible, I have these follow up questions:
The information submitted to that website would be constant, so would the web information viewed through the program be updated/refreshed in real-time?
Would creating an entirely new website to work with the program be more beneficial than using an existing website and scraping information from it?
Can a program communicate with another program on a local virtual desktop via Oracle VirtualBox?
If someone used this program on their computer, could they command the program/script on my computer via the internet?
Quick answers to your various questions:
Is not a question...
Websites are just user interfaces sitting on top of logic defined on a webserver - if you can interact with the logic (i.e. a webservice) instead of with the raw UI layer (which is HTML) you should rather do that. You can find a control which will render HTML information but this is unlikely to be the best approach for what you want to do.
Yes, through COMInterop with the Windows Shell - quite an advanced topic and I hope you understand Windows SDK, memory management and unmanaged, unsafe pointer-based code quite well.
Follow-up questions:
I don't understand the question - you're submitting information constantly or the information you're submitting is always the same? You would need to trigger the refresh of the web information (i.e. request the particular page) when you want a refreshed rendering of the webpage.
Most beneficial would not be using the user interface at all (webpage) and establishing a link to the logic layer instead and requesting the data directly via a web service - it gives you the most control in your WPF application.
Yes, but again, very advanced stuff - it's not simple or easy and comes with a host of challenges such as local security and automation APIs for VirtualBox.
Doubtful unless you wrote the code to be internet-enabled which again, is an advanced topic.
If I understood your situation correctly, you can use the WebClient class to communicate with your web server and use the returned string by it to generate the content.
WebClient web = new WebClient();
web.Headers.Add("HTTP Header", "Header Value");
web.Headers.Add("POST Data Header", "POST Data Value");
string response = web.DownloadString(new Uri("https://www.myserver.net/mypage"));
// Implement your processing on response variable here to generate and present data to the user.
And you can use the StandardOutput of the Process class to get the output of any programs on the local machine.
Process proc = new Process();
proc.StartInfo.FileName = #"C:\Path\to\my\executable.exe";
proc.Start();
proc.StartInfo.RedirectStandardOutput = true;
// Start the process...
proc.Start();
// Retrieve the output...
string output = proc.StandardOutput.ReadToEnd();

C#: Drupal database access

I am making a C# program that recreates websites in offline mode for use at computers within the company, that are not connected to the internet. These offline websites are identical to their online versions, with all content displayed.
I already have a solution for websites with simple MySQL access, but I need to rewrite the program, so that it can handle Drupal based websites aswell. However, I couldn't figure out how to access Drupal's SQL database, or even what to look for.
The original program uses the website's templates (that are already rewritten in HTML), and places the data mined out of it's database in the templates. Problem is, I don't know where to look for Drupal's templates, or if there aren't any, what data should I gather from it's database.
I use MySQL Connector to reach the database with C#. Should I look for the nodes? If yes, where?
If you want to go down that path you will have to sort of act like Drupal, in order to know which things to read from where. Each module installed has their own tables and functions in a particular way, so not always all the data are nodes with fields.
I you need to work with websites in offline mode, I would suggest using a portable webserver, that way you just copy the website to the root folder and run a script to copy the MySQL database as well, the point being that it's portable, you can carry it around in a flash drive and to run it, you don't need to install anything.
Again, what you want to do is possible, but it will require a tremendous amount of work and you cannot guarantee that things will behave well when you install new modules.
Another approach would be to look into the Boost module, which creates offline, static files based on the request you make to the site, and stores them in a configurable folder.
Another way: build a screenscrapper which reads the HTML from the homepage, and recursively follows the links and modify them before saving the HTML yo your local copy.
Summing it up.. avoid accessing the database yourself and try to read the HTML already rendered.

prevent users from showing XML file on server .NET

I'm building a trivia game that retrieve questions from XML file using javascript.
But the XML file is available to those who got the full path to the XML file.
How can i prevent users from showing the XML file ?
Thank you.
If it's going to be available to the client via Javascript, it's got to be available to the client in general. Now you could encrypt it, then decrypt it in the Javascript - but that's more of an obfuscation technique than anything else... basically if you need the browser to have the plaintext version of the file at some point, you can't prevent it from being available to users in general.
If the problem is that the file contains both questions and answers - i.e. data that you're happy for users to see and also data that you don't want them to see - you should split the file in two.
If you only want users to be able to see the data at the right time (i.e. when the question is asked) then you can introduce a server-side aspect which will serve one question at a time, when requested, and log that the user has just seen the question. That won't stop users from fetching questions, but it will stop them from doing so in advance without you being aware of it. (Unless, of course, they can log in as a different user, fetch the questions, work out the answers, then log in as their real account and give all the right answers. At that point it's more a matter of authentication and user control than anything else - after all, they could take the test twice, too...)
I don't know your game software flow, but I think you have to write a web service which enforces validation rules over the XML files (stored in non publish web server are).

A lot of data in WP 7 App, how?

I would like to have a lot of data (quotes of famous people, arround 100 k quotes). And I want that users are able to search, sort on category and sort on authors.
Got a big big xml file at the moment, but what is smart to do? How can i get all the quotes in the app? maybe a sql lite database? or just loop the xml when app starts?
Any tips are most welcome!
Kevin
UPDATE: Thanks for all the replies and tips, I really appreciate it and I am looking forward to program my App, did make a runkeeper-like app yesterday, now starting the quotes app.
I would recommend storing this data on a webserver somewhere and using some SOAP interface of something like this, to access it. I wouldn't be positively surprised when a downloaded application all of a sudden decides to download a big file of quotes.
I would recommend a SQL CE database (.sdf file)
Great overview here: http://windowsphonegeek.com/tips/Windows-Phone-Mango-Local-Database%28SQL-CE%29-Introduction
And here: http://msdn.microsoft.com/en-us/library/hh202860%28v=VS.92%29.aspx
There's no SQLite on WP7. There's SQL Server Compact though. Read up on the latter, and also on LINQ. WP7.5 only.
Alternatively, store data on the Web server, and use a service to pull it on demand. In that case, read up on services and SOAP.
With the fact that you are looking at a 500mb file I think you have a couple of options.
1) Put all of this data in a database on a webserver, then have your phone application use whatever method you like to contact the database to get specific data that is needed. Obviously your UI would have to be optimised to allow a user to sort by the type of quote and / or the person to whom the quote is attributed.
2) If you want this to be done without the use of the webserver you could have a stripped down basic database of quotes in the application itself, to extend this connect to the database and download more data.
This method may be best as it lets you use the database data to say populate a website if you wanted to (make a bit of money from ad revenue / promote your app) and also it means if your users dont have an internet connection they can still get some use from your app.
Without more knowledge of the platform I couldnt say what would happen if you try load a 500mb application but I doubt it would be good, though having such a large file locally is a bad idea for a mobile device. I can see this going two ways.
1) Im out and see your application, I set it downloading, pay it no attention and then later check to find it has downloaded 500mb over my mobile phone data package. This could mean a big bill.
2) I start to download your application, it hasnt finished downloading after 10mins, I delete it and dont bother trying again.
You can do something like let the user to enter three character minimum before search from webservice ans user the service result to bind the data.
Check the following links
How to connect to a Webservice from a Windows Mobile Device 6.0
http://msdn.microsoft.com/en-us/library/aa446547.aspx
Let me know if this helps.

Categories