|
Thank you very much.That did it exactly.
|
|
|
|
|
You're welcome. There are one or two changes I'd make to that, and one would be to eliminate all numbers that are not factors to start with. If the array was large, it would be an extremely significant reduction in loops. (The first line in the function achieves that).
private static List<string> GetFactors(int number, int[] possValues)
{
int[] possValuesNew = possValues.Where(i => number % i == 0).ToArray();
List<string> nodes = new List<string>();
for (int j = 0; j < possValuesNew.Count(); j++)
{
GetFactorsInner(nodes, number, possValuesNew, j, possValuesNew[j], possValuesNew[j].ToString());
}
return nodes;
}
|
|
|
|
|
Dear All,
I have a Asp.net website, wich gives the users the possibility to pay via internet and add credits to there cards.
Ofter they are done with payment on the website of there bank, they return to my website and at that point im checking the status of the transaction from there bank to add(or not) the credit to there card.
Sometimes it happens that the status of a certain transaction is not 'Success'. So i have to check the status later.
For this i want to make a another process that runs on the background and looks in the transaction logs for not succeeded transactions to request there status at there bank.
My questions is what is best for this purpose a Win Service or a WWF app. and why?
Hope to get some good advice.
Thanks in advance.
|
|
|
|
|
Well WWF will give you a declarative view of doing just that. Most peolple that have implement WWF use it in a transactional base system and use persistant storage to store in your case would be a "status" and use the workflow instance to retrieve it. You can use a Flow Chart or Sequence activity and easily create Aync calls I would recommend using WWF 4.0. It will give you much more options than it's predecessors. Also, it will give you a few options in hosting WWF and take a look at the behaviors it offers. So at the end, WWF will give you some stuff out of the box that you will have to do manually if you were writing a Windows Service.
|
|
|
|
|
You will find more documentation and help online on Windows Service.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
How can we pick dynamic images and rotate them in J-Query in dot.net applications?
|
|
|
|
|
I think this question would be better posted in the JavaScript forum.
I must get a clever new signature for 2011.
|
|
|
|
|
I am writing Windows service with FileSystemWatcher.
Protected Overrides Sub OnStart(ByVal args() As String)
fw = New StreamWriter(LogPathFile)
fsw = New FileSystemWatcher
If args.Length > 0 Then
' the path to monitor has been specified in the argument passed in at Start
fsw.Path = args(0)
Else
fsw.Path = My.Settings.PathToWatch
End If
fsw.IncludeSubdirectories = False
fsw.Filter = "*.*"
AddHandler fsw.Created, New FileSystemEventHandler(AddressOf File_Created)...
Public Sub File_Created(ByVal obj As Object, ByVal e As FileSystemEventArgs)...
How can I check on start if My.Settings.PathToWatch had any files and then call for each file File_Created event?
|
|
|
|
|
byka wrote: How can I check on start if My.Settings.PathToWatch had any files and then call for each file File_Created event?
Could you explain clearly? Format code in code blocks too.
Best wishes,
Navaneeth
|
|
|
|
|
I have a service which is monitors path by using FileSystemWatcher .
When files beeing drop it will moved to a dirrenet location
AddHandler fsw.Created, New FileSystemEventHandler(AddressOf File_Created)
it's working fine until service stoped. Let's say service stop for 1 min during that time other process drop a file to my monitor path.When service is re-started it won't pick that file. How to I process those files ?
here is my code:
Protected Overrides Sub OnStart(ByVal args() As String)<br />
Try <br />
fw = New StreamWriter(LogPathFile)<br />
fsw = New FileSystemWatcher<br />
<br />
If args.Length > 0 Then<br />
' the path to monitor has been specified in the argument passed in at Start<br />
fsw.Path = args(0)<br />
Else<br />
fsw.Path = My.Settings.PathToWatch' My monitor path<br />
End If<br />
fsw.IncludeSubdirectories = False<br />
fsw.Filter = "*.*"<br />
fsw.NotifyFilter = NotifyFilters.LastWrite<br />
AddHandler fsw.Created, New FileSystemEventHandler(AddressOf File_Created) ' File created
... Public Sub File_Created(ByVal obj As Object, ByVal e As FileSystemEventArgs)... processing files
|
|
|
|
|
Naturally if the application isn't running (regardless of the type of application) it can't monitor file changes.
Excluding design problems which would stop this, the solution is that when the application starts up it looks for new files. That solution has nothing to do with FileSystemWatcher.
|
|
|
|
|
byka wrote: How to I process those files ?
How about making a list of files that are "there" in the directory that you're watching when the service is started, and process those?
I are Troll
|
|
|
|
|
Just enumerate the files in that folder, create the EventArgs, and call the handler, e.g. in C#:
foreach (string filename in Directory.GetFiles(fsw.Path))
{
FileSystemEventArgs e = new FileSystemEventArgs(WatcherChangeTypes.Created, fsw.Path, filename);
File_Created(this, e);
}
|
|
|
|
|
how can i connect visual studio 2008 application to sql server 2008 using ODBC?
|
|
|
|
|
Why would you want to? ODBC is the method of last resort, to be used when nothing else will work, and VS 2008 comes with classes optimized for connecting to SQL Server. The only excuse for using ODBC is if your application has to interface with other database products after you're done developing it, and you want to minimize the amount of customization required for installation. Use the classes in System.Data.Sql to access a SQL Server database. If you need to rehost the solution to another database, you might duplicate the functionality you build for SQL Server using the namespace, System.Data.Odbc and use the installer to select which method is implemented.
Will Rogers never met me.
|
|
|
|
|
Hey wow, you say that like you know what you're talking about.
Roger Wright wrote: Why would you want to?
Because it's there. I don't know about the OP, but I just like to try things out -- I'll try most anything once. And I like to test my database code in a number of configurations.
My first experience with Sql Server (v6 circa 1999) was with ODBC... brings back memories... ones better left forgotten.
|
|
|
|
|
I've learned a thing or two hanging around this unsavory lot.
As a result, I've given up driving square pegs in round holes, among other bad habits. Just because I can doesn't mean I should.
Will Rogers never met me.
|
|
|
|
|
|
Hi,
MahaKh wrote: how can i connect visual studio 2008 application to sql server 2008 using ODBC?
Here's an example that works for me (.NET 2.0, W7, SQL 2005)
using (OdbcConnection con = new OdbcConnection(
"DRIVER={SQL Server};SERVER=.;Trusted_connection=yes;DATABASE=AdventureWorks;"))
using (OdbcCommand cmd = con.CreateCommand())
{
con.Open();
cmd.CommandText = @"
SELECT FirstName
FROM Person.Contact
WHERE ContactID = 20";
string 结果 = (string)cmd.ExecuteScalar();
MessageBox.Show(String.Format(
"The FirstName of Person.Contact is '{0}'.", 结果));
}
..and this on top of that unit, between the other imports and the namespace-declaration;
using System.Data.Odbc;
And here's the manual[^]
I are Troll
|
|
|
|
|
thanks to all, but my requirement is to use OLEDB instead of ODBC....
|
|
|
|
|
MahaKh wrote: but my requirement is to use OLEDB instead of ODBC
The requirement should state that you should use a SqlConnection . Anyway, the difference between the code is relatively subtle;
using (OleDbConnection con = new OleDbConnection(
"Provider=SQLNCLI;Server=.;Database=AdventureWorks;Trusted_Connection=yes;"))
using (OleDbCommand cmd = con.CreateCommand())
{
con.Open();
cmd.CommandText = @"
SELECT FirstName
FROM Person.Contact
WHERE ContactID = 20";
string result = (string)cmd.ExecuteScalar();
MessageBox.Show(String.Format(
"The FirstName of Person.Contact is '{0}'.",
result
));
} Code tested and verified on W7, .NET 2.0, SQL2k5
I are Troll
|
|
|
|
|
I have noticed looking at MS source that they regularly do this for a class with only static methods instead of creating a static class:
public class ClassName
{
private ClassName()
{ }
public static void Method()
{
}
}
Is there any benifit to this that I'm missing over a static class?
|
|
|
|
|
Perhaps so the class can be inherited? just a guess
Don't vote my posts down just because you don't understand them - if you lack the superior intelligence that I possess then simply walk away
|
|
|
|
|
A class with a single private default constructor cannot be inherited. It will always need some way to instantiate the parent...
|
|
|
|
|
Yes well spotted. Thou I am not assuming the op sample code is 100% correct still
I may or may not be responsible for my own actions
|
|
|
|