I need to process a complex calculation to generate a report and display as a webpage. It has to be run periodically to recalculate the formula based on new input.
I have a few ideas:
1. Create a web service to process and cache the content and then create a web application to request the content via HTTP periodically.
2. Create a service to output a file periodically and then create a web application to read the file.
3. Create a web application which has a task in there running periodically to generate the output and then create a webpage to display it.
I have read some of the old threads but I want to know which is the better approach, the pros and cons or if there are a newer way of implementing this?
JiTE!
I did a program that is similar to yours. The task is to generate a report when a user asks the application to do. Usually it is a daily report, but the calculation costs several minutes, for there are too many records, and the fomular is complex, too.
We created a periodly thread to check wether it is time to calucate.Thus the thread will calute and store the condition and result into SqlServer. When users click the button to view the daily report, yet the report is in DB and the application just needs to read it out from DB, and show it on the screen.
Let disscuss your solutions: solution 1 and 2 seems good, but sulution 3 does not match the DesignPatterns, because all tasks are put in a single application.
Hope everything goes well!
David Liu
Related
What is the best choice that I can make to show logs in real time from 4 different projects to a DashBoard? I have 4 projects and a Dashboard for Admin there is possible to view, manage every bug, event from projects. All projects communicate with Dashboard with rest API and I don't want to overload projects with simple rest api request to parse a string. I think that I can make a txt file there will be logs or I can save in memory and to parse the string, and after to send to Dashboard. I want to optimize the speed of working projects.
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();
I'm currently developing a web application (C#, ASP.NET MVC) which going to let users upload there own data by Excel files to the SQL Server database. In most of the cases the Excel files will have more than 2000 rows with 5 columns.
To archive this a was thinking about the following solution the main key is performance:
User uploads a excel file with 2000 rows.
The web application returns the rows from the excel file in json, jQuery will do a validation and some calculations on the values, if the values are invalid he will pop-up with some suggestions. At the end jQuery appends the data to a form (10000 textboxes)
User can make changes and needs to improve the invalid data, and does a submit
The web application uses SqlBulkCopy (with the posted data) to a merge table
Stored procedure will merge it to the final table
Is this a good solution, are there better approaches? Is it possible to post 10000 textboxes at one time?
Thanks!
The first part is fine, but the second step is what gets me. That seems not only like it could be a performance nightmare, but it would definitely be a UI nightmare. The solution I would suggest is let the user know which rows have issues and have them fix them in Excel. You then have the option of either adding the rows that were good, saving the file for later use or just discarding it all together. The other steps look good to me as well.
I'm not aware of a limit to how many textboxes can be added to a web page, but like I said, it will be a UI nightmare when there already exists a platform that can make this easy for the user (Excel).
What I'm trying to do is create an asp.net page that runs a random number generator, displays the random number, and writes it to a text file. That part is no worries, the issues is I want the number generation and file writing to continue while the page is live - ie if no one is actually viewing the page, it's just sitting on the server, the process should continue.
Is this possible?
EDIT: Foolishly overlooked using a webservice to generate the number - I've knocked up a basic service that generates a number and writes it to a text file. Can't work out how to schedule/automate it - could I set up a timer, with a given interval, then use timer_Tick?
Scheduling is new to me, any advice is appreciated.
You can use Window Service to work in backgroud, please see below link:
http://www.codeproject.com/KB/dotnet/simplewindowsservice.aspx
http://www.codeguru.com/columns/dotnet/article.php/c6919
Have you considered the use of scheduled tasks? So, rather than the page calling the updates, the scheduled task does that, and the page viewer is just seeing "latest results" at any specific point. Of course, that may not be feasible, but by the sounds of it, you're after a constantly working service/task with an ability to view the latest number, a little like an RSA token which shows new numebrs even if you dont need one.
Not sure if this is what you want. But if you are interested in using a scheduler for this task, you can try Quartz.Net. It is a very popular, full-featured and open source sheduling system.
Please describe what you are trying to achieve. There might be a better way than writing random numbers to a file.
I would not use a service (web or winservice) for this. There is no benefit to use a webservice since it will just do exactly the same as your web would do. A windows service will continue to run independent of your web, and you need to create some kind of IPC and to keep track of several timers/files.
The easiest way to do this is to use a System.Threading.Timer and keep it in a session variable. Also note that you need to kill it when the user session expires.
You should also be aware of that one timer will be created per user that uses the page.
Update
Create a Windows Service application and add a System.Threading.Timer to it. Write to the file in the timer callback.
Then open the textfile in your web app (using FileShare.ReadWrite + FileMode.Read)
I have a situation where I need to generate SSRS report for each account holder. The vague idea that I am having is to write a C# Code that should get the list of account numbers as input and run the report for each account number and then store the report as a pdf in a location, that can be mailed to the respective account holders. Now I have an SSRS report that can run by inputting one account number. But how can I run this report in a kind of a loop for list of account numbers. Do I need to write a c# program that should in someway call the reports for each account number( and obviously this program should run at a specific time say 8P.M every day for instance). Is this idea possible to implement? I am totally struck at this point. Any help would be really appreciated.
Well. I googled and figured out that what I might need is an SSRS data driven subscription. But when I created one and scheduled to run at say 8P.M, its not running. And its not showing any error message in the description.
Old post, but possibly still relevant.
Two possible workarounds:
Write a C# program to call the ReportExecutionService webservice in a loop. You can call SetExecutionParameters() each time with an array of report parameters.
Write a C# program to use WebClient.DownloadFile in a loop with the url of the report. Report parameters can be part of the url.