|
I am faced with a problem and dont know where to begin. I am required to write a bot (automated program) in C# (preferably). Right now we have a website where a user has to enter some information and depending upon the options selected, a number representing that particular client with the options selected is generated and given back.
This website is working perfectly fine. But now what we want to do is instead of entering all the inforamtion again and again everytime we want to generate that number, we want to automate it. That is, write a class which will get the inforamtion from the database and accesses the already existing website, provide it with all the information and get the number generated.
The details of the existing website are as follows:
1. It is a form based website.
2. It has two web pages. i.e., on the fist page after entering the information and submitting it, the next page comes up and after entering the information on this one and submitting it will generate the required number.
3. Both these pages are passwrord protected. i.e., have to provide a user name and password before accessing them.
I am really confused how to begin and where to begin. I am not even sure if something like this can be done? Any help would be greatly appreciated.
Thanks in advance
Kashif
|
|
|
|
|
Filling the web page with information is pointless - just post the data yourself using a HttpWebRequest and using the GetRequestStream method, which - if you look at the documentation for that method in the .NET Framework SDK - includes an example. You can also use the WebClient.UploadData for this, but you don't have quit as much control over the HTTP headers that are sent.
As far as pulling information from a database, that's easy. Use ADO.NET. See the System.Data namespace in the .NET Framework SDK, and use whichever child namespaces (like System.Data.SqlClient for SQL Server or System.Data.OleDb for any data source with an OLE DB provider). There is plenty of examples in the class library documentation for members of those namespaces and you can always ask this forum if you have specific questions.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi Mr.Heath Stewart
I use the way that you describe for me .
this way only safe for graphic based on Win App.
but when i use from that file generated in web, black color appear in background.
i will make transparent background area (alpha channel)
if you know how i can resolve this problem , please describe for me .
thank's
---------------
Bitmap b = new Bitmap(100,20);<br />
Graphics g = Graphics.FromImage(b);<br />
g.Clear(Color.Orange);<br />
g.DrawString("Test",new Font("Tahoma",8),new SolidBrush(Color.Green),0,0);<br />
b.MakeTransparent(Color.Orange);<br />
b.Save("test.gif",System.Drawing.Imaging.ImageFormat.Gif);<br />
|
|
|
|
|
There is a bug in the .NET Framework when it comes to transparency. Head over to dotnet247 for lots of info on this plus some complicated workarounds.
regards,
Paul Watson
Bluegrass
South Africa
Chris Maunder wrote:
"I'd rather cover myself in honey and lie on an ant's nest than commit myself to it publicly."
Jon Sagara replied:
"I think we've all been in that situation before."
Crikey! ain't life grand?
|
|
|
|
|
ON top of that, .GIF files don't support an alpha channel. Just a transparency key...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Nome
|
|
|
|
|
...which is what I told him.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I know! Sometime you just need a bigger hammer to drive the point home! Like making TABs in VS.NET...
RageInTheMachine9532
"...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
Hi! anybody can assist me in developing a simple blob analysis program via C# -GDI+. The idea is I would want to do some image processing on a captured images (in this example, it'll be few coins). The picture of these coins are taken via digital camera. I would really much appreciate it somebody can help me in the blob analysis program.
M
|
|
|
|
|
I have a class that I access from my main form to get all my class data. I created a thread to do a particular task (first time using threads), only it seems to have a new instantiation of my class, and all the class data is off. How can I get these two synchronized so that my thread can access the same data my form gets?
|
|
|
|
|
Post the code that spawns the work thread, assuming that this work thread is used to read in data or whatever and set a form's data member in the main thread.
In general, read in the data in the work thread. Invocate an event to update the main thread.
Kuphryn
|
|
|
|
|
Heres what the code looks like:
static void Main()
{
//making a new instance of this class to run outside of main
Form1 f = new Form1();
f.startScheduler();
Application.Run(new Form1());
}
public void startScheduler()
{
//get this thread goin
Thread t1 = new Thread(new ThreadStart(ripper));
t1.Start();
}
public void ripper()
{
//infinite loop
for ( ;;)
{
if (hc.getNumThemes() >= 1)
{
MessageBox.Show("calling riptheme");
hc.rip_Theme();
}
Thread.Sleep(4000);
}
}
during the application, hc.getNumThemes gets bumped from 0 to 1,2,3. But the thread always remains at 0.
|
|
|
|
|
Dear CPians,
I am in need of customized PropertyGrid component(.NET Compatable) with look and feel like the link below
http://www.visualhint.com/propertygrid.php
If you know any of such controls, Please let me know.
I would appreciate your help in this regard.
Thanks in advance.
Regards,
Jay.
|
|
|
|
|
As I mentioned to you before[^], you can use either the IL Disassembler (ildasm.exe that comes with the .NET Framework SDK) or a decompiler to find out how the PropertyGrid works. I also told you how it uses the System.ComponentModel namespace members to provide it with functionality (which leppie also mentioned), which is what that namespace (and a few related namespaces) are for. The .NET FCL provides a designer with almost everything it needs to design components.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
Actually, I was referring to how you let the UITypeEditor s and what-not "do their job". That was the point I was trying to make.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
here is a C++ function:
LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// Do we have to handle this message?
if (nCode == HC_ACTION)
{
// Process the hook only if the WinVNC thread id is valid
if (vnc_thread_id)
{
MSG *msg = (MSG *) lParam;
// Only handle application messages if they're being removed:
if (wParam & PM_REMOVE)
{
// Handle the message
if (m_ddihook)
HookHandleddi(msg->message, msg->hwnd, msg->wParam, msg->lParam);
else HookHandle(msg->message, msg->hwnd, msg->wParam, msg->lParam);
}
}
}
// Call the next handler in the chain
return CallNextHookEx (hGetMsgHook, nCode, wParam, lParam);
}
////////////////////////////////////////////////
according to an article on MSDN, i write a Hook code in C#.
how to convert this code to C# counterpart:
MSG *msg = (MSG *) lParam;
i declare lParam as IntPtr type. How about *msg ?
should i write it as this :
System.Messaging.Message msg = (System.Messaging.Message)lParam
???
|
|
|
|
|
MSG is a simple struct:
[StructLayout(LayoutLind.Sequential)]
public struct MSG
{
public IntPtr hwnd;
[MarshalAs(UnmanagedType.SysUInt)] public IntPtr message;
public IntPtr wParam;
public IntPtr lParam;
[MarshalAs(UnmanagedType.U4)] public int time;
public System.Drawing.Point pt;
} The second field is an IntPtr because the unmanaged type UINT is a processor-dependent bit width: 32 bits on a 32-bit CPU and 64 bits on a 64-bit CPU. To pass a value, just use new IntPtr(someNum);
If you need a pointer to this struct (MSG* ), you can either use the Marshal.StructureToPtr to marshal it to an IntPtr or - even easier - declare the method that accepts the MSG* as ref MSG msg . Here's an example:
[DllImport("user32.dll")]
private static extern bool SomeExampleFunc(ref MSG msg); This automatically marshals the MSG struct (that you simply instantiate and fill the fields) as a MSG* .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Ok, i have a DataTable with some columns, and i have a DataGrid.
The DataGrid DataSource is my DataTable.
So, how i color some elements?
I want to color all elements in the Table = "F" and "I"
Thanks.
|
|
|
|
|
|
I dont know, im not using Colum or table styles, just DataSource.
I Want color a element on a cell.
I have a DataTable with some columns, and call this table in DataSource.
|
|
|
|
|
1.To do this you first have to create class derived from DataGridTextBoxColumn or DataGridColumnStyle . You then have to override the Paint() method of these classes.
Implement the Paint Method as below
protected override void Paint(Graphics g, Rectangle bounds, CurrencyManager source, int rowNum, Brush backBrush, Brush foreBrush, bool alignToRight)
{
string val = (string) GetColumnValueAtRow(source, rowNum);
if(val == "T")
foreBrush = Brushes.Green;
else if (val == "F")
foreBrush = Brushes.Red;
base.Paint (g, bounds, source, rowNum, backBrush, foreBrush, alignToRight);
}
2. You will have to use DataGridColumnStyle to achieve the functionality.
3. Read the article, I had given you in my previuos reply. also download and run the sample project of the article. This will help you a lot.
Regards,
Jay.
|
|
|
|
|
You're need to. It's not hard - just see the DataGrid.TableStyles property in the .NET Framework SDK documentation. If you don't, you can't. The other reply is correct in what you must do.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I have this project in school, doing a project and while the code is the small part(main thing is learning use RUP and so on) it is still kinda tricky. Not codewise but design wise.
Right now we have one Project class, one Resource class, one Employee class, one "main" class and a "storage manager".(The program will be quite bigger eventually but this is the gist of it).
The program can handle several projects and several employees. And we added a resource class "between" employee and project, ie a resource can only have one project and one employee and it keeps the information needed. Like how many hours the employee should work on the project and so on.
At first we had no relation between these three classes, instead we had a database way of thinking and used a "foreign key" a employee id and project id in resource. But instead it was recommended to us that a good object oriented design should have associations instead.
So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered".
Another problem we faced was that if that many objects are bound to each other we will have trouble sending them back and forth to our server.(Or will we?)
Any tips of design patterns or just general tips about how we can do?
(Not asking you too do school work for me here , we are actually recommended seeking information on the Internet)
|
|
|
|
|
Cenatar wrote:
So I've have been thinking of adding knowledge of project and employee to the resource class and both the employee and project should know about the resource. Will this be good or just too "cluttered".
It depends on which way you need to travel through the objects. I would imaging your suggestion above is correct. Asking yourself some questions like: Does an employee object need to know about the projects it is connected with? Does a project object need to know about the employees working on it? If it is "yes" in both cases then:
Project keeps a collection of references to its resources
Resource keeps a reference to its project and the employee
Employee keeps a collection of references to its resources
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|