|
bool IsCardValid(string CCNumber)
{
return (CustomerResponse("Is this your card?") == "Yes")
&& (ExpirationDate > DateTime.Now());
}
CQ de W5ALT
Walt Fair, Jr., P. E.
Comport Computing
Specializing in Technical Engineering Software
|
|
|
|
|
Thanks for Ur reply..
But i need to validate CCNumber is it possible?
|
|
|
|
|
WTF is a "Skilties"?
See if you can crack this: fb29a481781fe9b3fb8de57cda45fbef
The unofficial awesome history of Code Project's Bob!
"People demand freedom of speech to make up for the freedom of thought which they avoid."
|
|
|
|
|
Dear friends on CodeProject,
do not discourage the OP!
Have you ever been to India?
I just spent 4 weeks of holidays there, and I can tell you from my experience: credit/debit card validation is a real issue!
In 1 hotel only were my credit cards accepted, all other hotels failed - and of course none had the old type of machines doing a simple paper offprint as a fall-back solution...
I had to get cash from (Indian) ATMs... At the first machine, I failed using it, on the first screen I saw the logo of the bank and its name on top, a "WELCOME:" in bold black letters on the middle left, and a "CONTINUE" on the middle right, I selected "CONTINUE" and was back to this page. A security man could tell me that I was expected to enter my PIN here (and in fact, in small dark gray characters on a light gray background it read "Please enter your PIN", where I previously thought was part of the logo). But in the end, the transaction failed for unknown reasons.
After many more failures at different ATMs, I tried to change cash at a Western Union office, which they were not licensed to do, but they told me that only a few banks can handle non-Indian MasterCards, and could give me two suggestions to try. At ICICI bank, the transaction failed, but their staff told me that they can do, I should try later again, and it failed again... Only from the ATM of HDFC bank I could get cash (and that ATM looked like Western make, quite different from the other ones).
Some time ago, some (Indian?) guy asked here on CodeProject how to program a cash machine. We should have provided him with much more guidance!
In the end, we could become victims of our failure to guide such newbies.
|
|
|
|
|
Ok, I think I know the answer to this but I am looking for some validation/verification here…
I am TRYING to use the latest Enterprise Library build, specifically the Logging functionality, to write out debug logs… I am running into cases where I am ending up with log files being written that have a GUID prepended onto the filename:
trace.log
0ce735a7-8bb1-465c-8340-cee60f6cc0d2trace.log
89e76526-07ea-4154-bc1c-c4caba63de48trace.log
From what I can tell this seems to be because the logging subsystem opens the log file and keeps it open. This means that any other logging statements that try to use that same file get a new file built with this goofy name, and their debug goes there. This seams really odd, but it seems to be what’s happening. In fact if you watch the debug output when you run in the IDE you actually see two exception being thrown as the initial write happens because apparently (I have not yet 100% validated this by reviewing the code myself) they logging writer system tries to grab a handle to a log stream and does not know that it needs to open the file until it catches that exception. Then, once it is open it hangs on to it and does not allow any other source use THAT stream, it opens new ones and logs to there.
What I am trying to achieve seems simple… I want to use different message formats for different areas of the code, but write all the entries to the same file. It seems that unless I use the same formatter layout for all calls to the file, I end up creating a new file handle and writing my entries to a new file instead of writing all to the one I have specified.
Anyone else seen this? Know a way around it?
Yeah, I have heard it recommended that I just write out using MSMQ and then have one single reader grab that data and log it to a file, but that seems really overkill for what SHOULD be a simple multiple-writer, single-reader, type of process here. I can’t believe that the entire logging library is actually suffering from this junk code. It just seems dumb that they can’t internally just handle this multiple writer issue by implementing their own darn queue of messages between the input text stream readers and the output file writer.
|
|
|
|
|
Alhtough I have never seen this in EntLib 4.1, how about disposing the Logger after call to Write method?
|
|
|
|
|
I am actually disposing of the writer and it is still happening. I am not making any direct calls tothe Logger in this case.
I create an instance of the writer:
LogWriter writer;
writer = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();
...and then I just make a call to the writer using one of the overloads...
writer.Write(message);
writer.Dispose();
. . .
writer.Write(message, categories);
writer.Dispose();
The thing I want to do is use different formatted writers bassed upon the type of message I am writing, but have them all go to the same file.
|
|
|
|
|
In that case, you might have missed something in configuration. Can you check if all listeners have a file name associated with them. I haven't seen this happenning so just guessing around what might have happenned.
|
|
|
|
|
Yeah, they do... They are all writing to 'trace.log' and each one is connected to a formatter that knows how to write out the fields that get passed in. I even have them all connected to one inbound entry point, the 'All Events' category...
I have a feeling that this is what is causing the multiple files to be opened up... If I just connect on Listener to the category and send in events formatted in that way so it sees the right format, it works fine, but I want to have different formats for my messages so I am trying to define different listeners and formatters. There does not seem to be a way to tie multiple formatters to a single Log without defining multiple Listeners. I had figured that I would just define different formatters and they would be used based upon what methods I called and what signatures that provided (made sense to me and would be how I would build it) but that doe snot seem to be the case.
|
|
|
|
|
What is the trick to sending an enter key when a legal banner appears with this project?
The legal banner displays before the login password screen and requires an enter key to acknowledge it.
Thanks!
Palantir - Remote Desktop Manager[^]
modified on Wednesday, December 22, 2010 2:42 PM
|
|
|
|
|
Try posting your question in the forum at the end of the article, so the author can see and respond to it.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
you should Move there[^] to ask question.
modified on Wednesday, December 22, 2010 11:51 PM
|
|
|
|
|
I've emailed her and sent her a link, hopefully she'll reply ... but I was also hoping someone else had encountered this and had some input.
|
|
|
|
|
I've tried a ton of tutorials but none work. Or rather, sooner or later ALL digress and leave the crucial part of transfering a file that isn't pure text.
I'm remodeling an app I've previously used to transfer text and project specific objects over a LAN. I'm just having trouble to receive the file and save it again after the transfer (I assume the sending of the file is successful, but of course have no way to actually verify this).
Here is the code for my client (sending) app:
private void Send(string arg)
{
TcpClient client = new TcpClient(TB_Host.Text, (int)UD_Port.Value);
FileStream fstream = File.Open(OFD_File.FileName, FileMode.Open);
NetworkStream nstream = client.GetStream();
int data = 0;
while (data > 0)
{
data = fstream.ReadByte();
nstream.WriteByte((byte)data);
}
fstream.Close();
nstream.Close();
client.Close();
}
And this is the code for the server (receiving) app:
public void Listen()
{
int port = 21112;
byte[] result = new byte[1024];
IPAddress address = IPAddress.Parse("127.0.0.1");
TcpListener listener = new TcpListener(address, port);
ipEnd = new IPEndPoint(address, port);
listener.Start();
socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
int f = 0;
object state = new object();
socket.Connect(ipEnd);
while (true)
{
TcpClient client = listener.AcceptTcpClient();
NetworkStream ns = client.GetStream();
f = socket.Receive(result);
Invoke(new UpdateDisplayDelegate(UpdateDisplay), result);
}
} The current problem is that the code never reaches the invoke call (the Listen method is on a 2nd thread), which confuses me as there never had been any problem when I transferred text or objects.
I tried a SoapFormatter , but while it works great for text and objects, I can't get it to work for files.
I also tried using no sockets but a NetworkStream to write into the buffer:
result = ns.Write(result, 0, int.MaxValue); but I always get an ArgumentOutOfRange exception for the size (I used int.MaxValue) parameter.
Can you tell me how to get it to work? Or is this approach wrong in the first place?
Thanks!
|
|
|
|
|
Hi,
that does not look good.
1.
Megidolaon wrote: while (data > 0)
the test fails right away, so nothing gets sent.
2.
Megidolaon wrote: data = fstream.ReadByte();
Now why would you handle one byte at a time? it will take forever on medium-sized files, and even longer on large ones.
You are trying to receive 1024 bytes, why not do something similar on the sender side?
Use a byte array, Stream.Read(), and make sure to watch the actual number of bytes transferred.
3.
Megidolaon wrote: the code never reaches the invoke call
see (1)
4.
Megidolaon wrote: I tried a SoapFormatter
I have no idea why you would use a formatter. Sockets don't care about the data they carry.
5.
Megidolaon wrote: I used int.MaxValue
If the method needs to allocate a buffer, it will fail to get int.MaxValue bytes of memory, no matter how much RAM your system has.
I suggest you try something like this as a sender (not tested!):
int DIM=1024;
byte[] bytes=new byte[DIM];
for(;;) {
int count=fstream.Read(bytes, 0, DIM);
if (count==0) break;
nstream.Write(bytes, 0, count);
}
|
|
|
|
|
...what?
All you did is provide some vague comments that are unusable and post code that does exactly the same thing as mine.
|
|
|
|
|
... What?
All he did was provide a good critique that you should learn from and some code that has more than a snowball's chance of working.
|
|
|
|
|
Critique? I did not ask for critique, I asked for help. Which he pretended he gave, but actually did not give at all.
|
|
|
|
|
Look, if you aren't up to working out what he said, that's your problem. The answer he have was helpful:
Your code couldn't possibly run, was inefficient and poorly designed. He covered each of those points. He even gave you a sample of code that fixes those problems.
I suggest you read the other comments and figure out why you are wrong, rather than attempting flip answers.
|
|
|
|
|
Megidolaon wrote: All you did is provide some vague comments that are unusable and post code that does exactly the same thing as mine.
Except that yours does nothing, that you can verify anyway. You were given a reason for this, have you investigated it?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Megidolaon wrote: int data = 0;
while (data > 0) ...
and how many iterations will this loop execute in your opinion?
|
|
|
|
|
I'll give him a clue: it's the same value as data . Lets see if he cracks the code
|
|
|
|
|
My vote of 1... Try doing a bit of the thinking yourself. He provided you exactly what you need to get it going. All you have to do is follow instructions.
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
All you did was provide code that couldn't possibly work. Luc provided reasons why, and a practical suggestion on how to take your code forwards. Luc's comments were valid, pertinent and usable - if you think his code does the same as yours, I suggest that you need to step through the code line by line. BTW - had you actually bothered to debug your application, you'd have spotted that you could never step into the loop.
|
|
|
|
|
Megidolaon wrote: and post code that does exactly the same thing as mine.
With one major difference, your code will never work, Luc's always will.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|