|
Khoramdin wrote: what are the steps that I need to take in order to convert my existing code into a browser base application?
Well, if your application is written in layers (presentation, business, data) then it should be fairly easy to swap out the presentation layer and create a new one based on a web application. If it isn't written properly then you'll have a fair bit of redesign to go to get it to work in a browser.
|
|
|
|
|
Hi there.
I've developed a media player like application.
This uses Windows forms and runs stand-alone locally.
Now, i want to embed that player application into a website.
[ Just like those flash players around ... ]
But how to achieve this ?
Especially, how to achieve this for either IE AND FF ?
Can I 'easily' use <object> and <embed /> tags to run the application IN
a website from the WWW, or has there some more 'magic' to be done ?
I want to run the application / player just like the flash player.
|
|
|
|
|
There is some magic to be done: first, your program must be compiled to a library, and the bits you want to show up on the web page must be a UserControl, not a form.
From there, you'll want to expose your control as an ActiveX control. A quick Google Search[^] reveals a good deal of articles on this.
|
|
|
|
|
|
Hello All,
Just a question I was hoping to get answered. I completed an application about a month ago which implemented a FileSystemWatcher object and most of of the time is works great; but, sometimes for some reason, it will miss some files, which I will have to manually cut and paste the files to get the file watcher to process. I have increased the InternalBufferSize but it still happens.
I was thinking of another approach which may be foolproof (in my little mind anyway.) I was thinking a employing a timer and when the elapsed time is met, I could check the directory and see if there are any files available. If so, I want to grab the name of just one of the files and then do the processing. Yeah I know, sounds an awful lot like the watcher but I think I would have more control by just processing one at a time and no matter how many files pile in there at once, I will systematically process them all.
My only problem is trying to figure out how to get just 1 of the names of the files at the timeElasped point. Say there are files named like A.txt all the way to Z.txt. I want to check the directory and just return A.txt. I don't want to put all 26 into an array.
Any thoughts would be appreciated and thanks in advance.
F
|
|
|
|
|
Have you looked at this article that goes into detail about the FileSystemWatcher[^]? From the article,
The sample application simply logs messages to the UI. In general however you will be doing far more work. Work that will take a reasonable amount of time (such as retry counting). The FSW communicates to the underlying file system through a shared buffer. This buffer is limited in size. If more events come from the file system than the FSW can handle the buffer will overflow. In this case two things will happen: you will miss events and the Error event will be raised.
|
|
|
|
|
I don't think there's a method that just returns 1 file. As far as I know your options are the static Directory Class and it's GetFiles() method and the same method with the DirectoryInfo Class. But you could just use the first file in the array and toss the rest if you only care about 1 file.
If you're not going to use the FSW and want to just run this app on a scheduled basis, then make it a generic console application and use the Windows scheduled tasks to run it once an hour or whatever time increment you think works best.
Your applciation could always store the last runtime in a config file so you know not to process files with a date before that last runtime.
|
|
|
|
|
Hi Chris,
Good old kernel32.dll offers the Win32 function "FindFirstFile" which returns a single file.
From that, one could find the next file using "FindNextFile", or somehow eliminate the
file found, and repeat "FindFirstFile". So a little P/Invoke might help here, although I am
not convinced it would offer a better solution that what you suggested with GetFiles()
assuming the number of files is reasonable.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I've read the article about FSW a couple of times and I still think there is that margin of error that I don't want to deal with, seeing how I am experiencing it now. I am going to try the array route and let you guys know how things turned out.
As always, thanks for taking the time to respond to my simple questions.
F
|
|
|
|
|
Dear programmers,
I want to create a large/complicated application which has a user-interface that start a lot of operations in background via threading.
If these threads are running, then the user-interface has to be partially disabled (depending on the type of operation).
This can be complicated because of a lot of dependencies.
My question now is:
Is there any "kind of design-pattern" by which this problem can be solved?
Thanks for your support ! ! !
|
|
|
|
|
Have you looked into the BackgroundWorker[^] component? It's designed especially for this. *edit link fixed
|
|
|
|
|
Thanks !
Unfortunately your link does not work
|
|
|
|
|
Maybe it works in the background?
Try this one[^].
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Tomerland wrote: Is there any "kind of design-pattern" by which this problem can be solved?
No single design pattern will provide solutions for the various problems that situation entails. You will need to implement several patterns. As always start with MVC. For User Interface components that need to enable/disable based on application state and multiplicity in relationships ("This can be complicated because of a lot of dependencies.") you might look into extending the Command Pattern to include UI control state mechanisms ( enabled, visible, checked, etc.)
|
|
|
|
|
HI,
I am trying to display the contends in a .cs folder inside a listbox .
i wrote the code where in i can open the file but after that how to show the contents inside the list box i am stuck.i want tehe list box to show all the codes inside the file.
do i need to use StreamReader?
otherwise how can i do it?
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog objDialog = new OpenFileDialog();
objDialog.Title = "Open .cs File";
objDialog.Filter = "C Sharp Files (*.cs)|*.cs|Text Files (*.txt)|*.txt";
objDialog.InitialDirectory = @"D:\back up d \users\k\ConsoleApplication1";
if (objDialog.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(objDialog.FileName.ToString());
}
listBox1.Items.Add(@"D:\back up d \users\k\ConsoleApplication1");
Any help is welcome.
Thanking You
p
|
|
|
|
|
You could use a filestream and a streamreader
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
File.ReadAllLines() may help you.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
(?mx-s:\#region\b
(?<name>.*)
(?<content>
(?>
\#region\b.* (?<djup>) |
\#endregion\b (?<-djup>) |
[^\#]+
)+
(?(djup)(?!))
)
\#endregion\b.*
)
This is my pattern, it gets the content of #region sections. It works perfectly in Expresso,
but when i run it on the same code in C# it does not!
const string GET_REGIONS = @"(?mx-s:\#region\b
(?<name>.*)
(?<content>
(?>
\#region\b.* (?<djup>) |
\#endregion\b (?<-djup>) |
[^\#]+
)+
(?(djup)(?!))
)
\#endregion\b.*
)
";
MatchCollection regions = Regex.Matches(classContent, GET_REGIONS);
Any ideas about what im doing wrong?
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
It worked when i used Expressos generate C# code ^__^
fafafa, ringakta icke sådant som bringa ack så naggande högönsklig välmåga å baronens ära.
|
|
|
|
|
I'm struggling to get this to work..
Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?
Any help would be appreciated
|
|
|
|
|
hakonvik wrote: I'm struggling to get this to work..
Is it possible to set the checked state on all the selected rows in an datagridview at the same time (e.g. when the user selects multiple rows using ctrl+mouseclick)?
From reading the manual, I've come up with a minimal idea. To set checked on all rows selected, you would iterate over all the rows of your data source, and for each row check IsSelected, and if it is, set the appropriate checked value in the data source. Then you'd have to get the data grid to update its display for the new values.
Nathan
|
|
|
|
|
Well, yes that is right but not quite my problem.
My datagrid has an checkbox on each row in the first cell (built in code). The problem occurs when I have selected multiple rows and click one of the checkbox cells (in which case I want all the selected to get checked )
I can check selected rows by putting a button or link outside the grid, but that is not "normal" windows behaviour..
Any ideas
|
|
|
|
|
hi
i create a queue and service in my sql server 2005 by this code :
create queue myNotificationQueue
create service myService on queue myNotificationQueue
in my csharp code i wrote this code : (i copy this instance from msdn website)
class Program
{
string connstring = null;
SqlConnection conn = null;
SqlDataReader rdr = null;
static void Main(string[] args)
{
Program c = new Program();
c.connstring = @"Data Source=MYLAPTOP\SQLLAPTOP;Initial Catalog=pubs;Persist Security Info=True;User ID=sa;Password=1";
c.conn = new SqlConnection(c.connstring);
c.DoWork();
Console.ReadLine();
}
private void DoWork()
{
conn.Open();
rdr = GetJobs(2);
if (rdr != null)
{
rdr.Close();
WaitForChanges();
}
conn.Dispose();
}
public SqlDataReader GetJobs(int JobId)
{
using (SqlCommand cmd = new SqlCommand("Select job_id, job_desc from dbo. jobs where job_id = @id", conn))
{
try
{
cmd.Parameters.AddWithValue("@id", JobId);
SqlNotificationRequest not = new SqlNotificationRequest();
not.ID = new Guid(); // error occured
// this must be a service named MyService in the pubs database
// associated with a queue called notificationqueue (see below)
// service must go by QueryNotifications contract
not.Service = "myService"; // error occured
not.Timeout = 0;
// hook up the notification request
cmd.Notification = not;
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return rdr;
}
}
public void WaitForChanges()
{
// wait for notification to appear on the queue
// then read it yourself
using (SqlCommand cmd = new SqlCommand("WAITFOR (Receive convert(xml,message_body) from notificationqueue)", conn))
{
object o = cmd.ExecuteScalar();
// process the notification message however you like
Console.WriteLine(o);
}
}
}
but when i compile it, two following errors shown me :
System.Data.Sql.SqlNotificationRequest' does not contain a definition for 'ID'
System.Data.Sql.SqlNotificationRequest' does not contain a definition for 'Service'
How to solve my problem ?
thanks
|
|
|
|
|
Check this[^] out.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
thanks for reply
i corrected my code as following :
class Program
{
string connstring = null;
SqlConnection conn = null;
SqlDataReader rdr = null;
static void Main(string[] args)
{
Program c = new Program();
c.connstring = @"Data Source=MYLAPTOP\SQLLAPTOP;Initial Catalog=pubs;Persist Security Info=True;User ID=sa;Password=1";
c.conn = new SqlConnection(c.connstring);
c.DoWork();
Console.ReadLine();
}
private void DoWork()
{
conn.Open();
rdr = GetJobs();
if (rdr != null)
{
rdr.Close();
WaitForChanges();
}
conn.Dispose();
}
public SqlDataReader GetJobs()
{
using (SqlCommand cmd = new SqlCommand("Select job_id, job_desc from dbo.jobs", conn))
{
try
{
//cmd.Parameters.AddWithValue("@id", JobId);
SqlNotificationRequest not = new SqlNotificationRequest();
not.UserData = Guid.NewGuid().ToString();
// this must be a service named MyService in the pubs database
// associated with a queue called notificationqueue (see below)
// service must go by QueryNotifications contract
not.Options = "service=myService;local database=pubs";
not.Timeout = 0;
// hook up the notification request
cmd.Notification = not;
rdr = cmd.ExecuteReader();
while (rdr.Read())
Console.WriteLine(rdr[0]);
rdr.Close();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return rdr;
}
}
public void WaitForChanges()
{
// wait for notification to appear on the queue
// then read it yourself
using (SqlCommand cmd = new SqlCommand("WAITFOR (Receive convert(xml,message_body) from myNotificationQueue)", conn))
{
cmd.CommandTimeout = 0;
object o = cmd.ExecuteScalar();
// process the notification message however you like
Console.WriteLine(o);
}
}
}
but in runtime, when i update any record in jobs table, my app was not reponse to that change (nothing occured),
where does my problem ?
|
|
|
|