|
hi all
i am currently using vs2005 c# window app , i am trying to make a crystal report base on the data i have in my ms sql database which i have binded programmically by using SqlConnection
thus i would like to know if i could use the same method to bind my database to the crystal report
so far i only done crystal report via data from a ms access database
is it possible? and any good keyword or hint for reference would be nice too
thanks
|
|
|
|
|
|
Can somebody please give me an example of a windows service that uses threading to look at a folder for files and if it finds a file then does some processing. Upon completion of processing looks again and continues... I don't know if it is wise to keep looking at a folder every second for files, please advice on that. If it is not then maybe put a wait and look every 20 minutes or so. Please help!!
I don't need code to look for files, etc. I just need some guidance on how to build the service with a thread.
Thank you in advance
Sameer
|
|
|
|
|
|
Hi again,
there is a FileSystemWatcher class that monitors changes to a folder or file; the problem with it (and with any other method of observation you could possibly come up with) is that it recognizes changes, rather than states, i.e. it will tell you a file got created, got written to, etc, but it is unable to signal a file has reached a new and consistent state (there is no FileClosed event or something similar).
The only really good way is for the file creator to signal you when a file create or update has been executed to completion.
I see no need to use threading, unless maybe if you want to watch several folders. You might want to tell us more about what the files are about, and what you intend to do to them.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
As always thank you for your response. My windows service in short looks at 3 folders for .csv files, parses them and does some database updating. From time to time there are files added to these folders so I have to keep looking at a certain interval in these folders (currently configured every 20 minutes)
I decided to implement the following method:
http://en.csharp-online.net/Creating_a_.NET_Windows_Service%E2%80%94Alternative_1:_Use_a_Separate_Thread[^]
Please let me know if this is not a good method, I would hate to crash the server because that is where this service will be loaded
Thanks
Sameer
|
|
|
|
|
We do exactly the same thing except we use a winforms app to give feedback to the user, it chacks every 2 minutes and disables the timer while checking (otherwise eyou get multiple threads)
We have implemented a delay in the reading of the file to avoid touching files still being written by setting a flag with the time of first seeing the file, if more than # period has elapsed since seeing the file we can then process it.
This has been working perfectly for the past 4 years, at 2am it processes up to 1200 files an hour.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
one way to overcome the problem you don't get events when a file creation/update is completed is this, assuming you're in charge of the producer's code:
- look for "event files", recognized by a specific characteristic, maybe a new file extension .EVE
- create/update your data files in any way you see fit; when done, create a short .EVE file containing the full path of the data file. Such file will be written atomically since it fits in a single sector.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Ok, there are multiple way to do that. As Luc suggested you can use FileSystemWatcher Class to check a folder. If any new files created it will fire an event and based on that you can do the required operation.
you can use TimerDelegate with windows service to monitor on a specific duration.
Recentenly I have completed a similar application. Please let me know if you have more doubts. Hope I can help you in this.
Thank you.
|
|
|
|
|
|
Samir,
That is fine. I have one question regarding your application. How file are submitting into the Folder? Is it submitted by any client? Is there any possibilites the more than thousand files created on that folder?
|
|
|
|
|
Happy to hear that it is a good method. A different client creates and dumps these files. Usually, there is a single file at one point and what my application is doing is processing these files and dumping it to an Archive folder.
Sameer
|
|
|
|
|
I was asking because in my case there can be possiblity of many file submitted at the same time, because files are submitted via Web services. So I was wondaring with behaviour of FileSystemWatcher that it can manage that hughe change list or not. So what I did, I have stored the file name in DB while client storing the file into the folder, means my Web service save the posted file and store the Filename in DB . Now what I did, Windows Service read the DB load 100 Files name in DataSet, Process them one by one and update the dataset, After complete the all processing I have update DB with the updated dataset and Load the next 100 Records. Now If there is no records, I have used a DelegateTimer which will monitor the database with 15 min interval to file come. If file is there, I stopped the current timer and process those data.
|
|
|
|
|
what I am doing is reading the file names into a string array and then using foreach loop to process each file. This is incase there are multiple files. It seems to be doing a good job with the threading and the thread.sleep. I wonder if there are more system resources being used with my approach, I will monitor the error log and hopefully there won't be any issues
Sameer
|
|
|
|
|
|
I need to get the amount of computer physical memory.
Now, I can get the amount Windows uses by a GlobalMemoryStatus kernel32 API call.
However, this returns me the same number I see in the My Computer properties dialog box. And if I set MAXMEM paramter in the boot.ini file to 500M, this is what I'll get from this function.
Does there exist a way to find out how much memory's really plugged into my motherboard?
|
|
|
|
|
The WMI class, Win32_PhysicalMemory , will tell you how much memory is installed in each slot on the motherboard. Total it all up and you've got your total physical memory installed.
Google for "C# WMI System.Management" and you'll find examples on how to use WMI in your code.
Google for "Win32_PhysicalMemory" and you'll get the documentation on the class, including the properties to use to get your numbers.
|
|
|
|
|
That's great. Works fine for me. Thanks.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
thank you very much! works perfectly for me!
Just in case someone needs it, here's code:
using System;
using System.Management;
using System.Management.Instrumentation;
using System.Windows.Forms;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
ManagementObjectSearcher searcher =
new ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMemory");
int banknumber = 1;
foreach (ManagementObject bank in searcher.Get())
{
MessageBox.Show("Bank " + banknumber.ToString() + " size = " + bank["Capacity"].ToString());
banknumber++;
}
}
}
}
modified on Tuesday, June 9, 2009 2:07 PM
|
|
|
|
|
Hi
I am using this method to take screenshots from games in my application:
int screenWidth = Screen.GetBounds(new Point(0, 0)).Width;
int screenHeight = Screen.GetBounds(new Point(0, 0)).Height;
Bitmap bmpScreenShot = new Bitmap(screenWidth, screenHeight);
Graphics gfx = Graphics.FromImage((Image)bmpScreenShot);
gfx.CopyFromScreen(0, 0, 0, 0, new Size(screenWidth, screenHeight));
bmpScreenShot.Save("test.jpg", ImageFormat.Jpeg);
but in some games I can't get a proper screenshot. Sometimes some models are missing or only a black screen is captured.
Is there another method to capture screenshots from games? (Yes, they use DirectX)
Thanks.
|
|
|
|
|
Yes, you can ask DirectX for a copy of the backbuffer. I forgot how though but that would give you something to google for..
|
|
|
|
|
I wonder if there's a way to 'simulate' ALT+PrintScreen and then programatically get data from the clipboard and save it to a file? If there is... That oughta do it... I think
|
|
|
|
|
There is, there are functions like SendKeys . But there must be nicer ways.
My current favourite word is: Delicious!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Dear Sir/madom
I have three tables
1. Categorys (ID, Name)
2. Definitions (ID, Name, CategoryID)
3. Versions( ID, Name, DefinitionID)
I have generated three objects using EDM
1 Cagegorys
Navigation (Definition)
2. Definitions
Navigation (Category, Version)
3. Versions
Navigation (Definition)
I want to get latest versions against each category
My Code is as follow It return all version against the categoryId but I want to get only latest version of each definition against a category.
DataEntities data = new DataEntities();
Category cat = (from c in data.Categorys where c.ID == CategoryID select c).First();
IList<definition> defintions = (from d in data.Definitions.Include("Versions") where d.Category.ID == cat.ID select d).ToList();
IList<dynamicforms.data.version> versions;
if (defintions.Count>0)
{
versions = defintions.SelectMany(d=>d.Versions).ToList();
Grid.DataSource = versions;
Grid.DataBind();
}
If I need sub query How I have construct and use subquery in this code
Your early reply will be highly appriciated please.
|
|
|
|
|
I have been searching the net for 2 months now looking for info on how to do this. Can anyone point me in the right direction?
I have a vb.net program that used SendKeys to send ctrl+C and CTRL+V that was able to do this but I can't get that to go in VS2008 C#.
tia
rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|