|
I'm afraid you have a race condition in your code. Suppose two files with the same name are being uploaded at the same time. Both could hit the version retrieval code at the same time, which will result in them both getting the same version number. The reason is because there is a delay between the get version and the update part of the code.
|
|
|
|
|
i did write it a long time ago...
Oops! In the field where it is being used it is very unlikely to happen (because the file names are specific to the customer site), but you are absolutely right - I'll fix it in the code next time I release an update - a quick stored proc will fix that!
Thanks for the head up...
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|
|
No problem. I'm glad I can help.
|
|
|
|
|
When I do this, to avoid clashes of file and, I just use a guid as the file name on the disk. Simply store the original file name in your database along with the new name.
|
|
|
|
|
Pete O'Hanlon wrote: I just use a guid as the file name on the disk I read that as quid and thought .
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
That's because you're obsessed with money.
|
|
|
|
|
No, it's because both my eyes and brain are getting more feeble.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Richard MacCutchan wrote: No, it's because both my eyes and brain are getting more feeble
The brain part isn't an issue for me - mine was always feeble. The eyes are rapidly catching up.
|
|
|
|
|
I am using this code to set watermark for textbox but watermark now showing with no error.
here is the code:
private const uint ECM_FIRST = 0x1500;
private const uint EM_SETCUEBANNER = ECM_FIRST + 1;
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, uint wParam, [MarshalAs(UnmanagedType.LPWStr)] string lParam);
and in Form_Load:
SendMessage(txtLoginID.Handle, EM_SETCUEBANNER, 0, "login");
SendMessage(txtPassword.Handle, EM_SETCUEBANNER, 0, "login now");
SendMessage(txtPIN.Handle, EM_SETCUEBANNER, 0, "wow");
SendMessage(txtLoginID.Handle, EM_SETCUEBANNER, 0, "login");
SendMessage(txtPassword.Handle, EM_SETCUEBANNER, 0, "login now");
SendMessage(txtPIN.Handle, EM_SETCUEBANNER, 0, "wow");
|
|
|
|
|
|
jrahma wrote: but watermark now showing with no error
If the watermark is showing without error then what is the problem?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
he probably meant "not showing"
|
|
|
|
|
My watermark is not showing error AND not showing the watermark either!
|
|
|
|
|
jrahma wrote:
My watermark is not showing error AND not showing
the watermark either!
You question does not say that now does it?
The code that you have posted works perfectly fine on my system.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
Wes Aday wrote: The code that you have posted works perfectly fine on my system.
So you have earned the coveted "Works on My Machine" designation!
Works on My Machine![^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard Andrew x64 wrote: Works on My Machine
Yeah! Thank you so much! I feel so honored!
I would like to thank the Academy, the directors and producers....
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Please stand in front of my pistol, smile and wait for the flash - JSOP 2012
|
|
|
|
|
The docs for the EM_SETCUEBANNER message say this:
Quote: To use this API, you must provide a manifest specifying Comclt32.dll version 6.0. For more information on manifests, see Enabling Visual Styles.
Enabling Visual Styles[^]
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Basically I am experimenting with Tuple for the first time and I am completely out of my element. I have no idea of how to correct the errors I am getting. Can someone please help.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Testing_Functions
{
class Program
{
public static Tuple<double, double> Test(Double Val1, Double Val2, Double Val3)
{
Double Test_Val = Val1 + Val2 + Val3;
Double Test_2 = 7;
return Tuple(Test_Val, Test_2);
}
static void Main(string[] args)
{
Double A = 1, B = 2, C = 3;
Tuple Result = Test(A,B,C);
Console.WriteLine("{0}", Result);
}
}
}
|
|
|
|
|
A tuple is a reference object, so you need to create one using the new keyword. Try this :-
public static Tuple<double, double> Test(Double Val1, Double Val2, Double Val3)
{
Double Test_Val = Val1 + Val2 + Val3;
Double Test_2 = 7;
return new Tuple<double, double>(Test_Val, Test_2);
}
static void Main(string[] args)
{
Double A = 1, B = 2, C = 3;
Tuple<double,double> Result = Test(A, B, C);
Console.WriteLine("{0} {1}", Result.Item1 , Result.Item2 );
Console.ReadLine();
}
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
Wayne Gaylard wrote: A tuple is a reference object, so you need to create one using the new keyword. I suppose that's true. IMO that looks a lot like it wouldn't have been necessary if Tuple had been a value type though, but it would have been.
|
|
|
|
|
To create a Tuple , use one of the generic constructors (or the static Tuple.Create() methods). I believe this is what you want to do:
var result = new Tuple<Double, Double, Double>(a, b, c);
return new Tuple<Double, Double>(test_val, test_2);
[edit]
To the univoter:
Thank you for downvoting me because I was writing my reply at the same time as the first reponse (Wes) but didn't click the "Post Message" button in time.
[/edit]
/ravi
modified 17-Aug-12 14:00pm.
|
|
|
|
|
You have the answer to your question, this is just a comment regarding the casing of your parameters, variables etc.
There are some generally accepted rules for casing which makes code at a glance easier to read and understand. See here[^]. It is not normally recommended to use underscores, they don't add any clarity, and abbreviations are discouraged.
Taking the above into consideration your code would look like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TestingFunctions
{
class Program
{
public static Tuple<double, double> Test(double value1, double value2, double value3)
{
double result1 = value1 + value2 + value3;
double result2 = 7;
return new Tuple(result1, result2);
}
static void Main(string[] args)
{
double a = 1, b = 2, c = 3;
Tuple result = Test(a, b, c);
Console.WriteLine("{0}", result);
}
}
}
This makes no difference to the execution of the code, it is just a personal (or company if you code professionaly) matter of style. There are also many differing opinions on some finer points!
|
|
|
|
|
DaveyM69, no personal attack intended, but I think it is generally unhelpful, and off-topic, to respond to a poster, struggling to get his, or her, head around a "best practice" technical strategy, with a "sermon" on variable-naming, and code-style: a topic on which there are many (widely debated) points of view.
Consider the "religious wars" over just use of indentation, and/or, the virtues of the location of a block-open curly brace, and block-close curly brace: K&R, where the block-start curly brace follows the final close-parens of the argument list (usually preceded by a space) vs. the practice of adding a line break after the end of the argument list, then the open-curly-brace, followed by another line-break, and then use of indentation.
Perhaps long ago, the very limited memory available in developer's machines made minimizing white-space desirable: but that is no longer the case.
The fact is that if you get employed in a working team with a substantial code-base, you will have to adopt to their notation and casing conventions.
And, some code transformations, such as KR style brace use <==> line-break-indent style, are easily done with very simple Regex expressions.
And, conventions, like use of braces, may have very different behaviors from language to language: example: JavaScript: variables declared inside {} are not locally-scoped and disposed; they are global.
For this reason, I voted your response a #1.
best, Bill
"One of the few good things about modern times: If you die horribly on television, you will not have died in vain. You will have entertained us." Kurt Vonnegut
|
|
|
|
|
I believe some 'generally accepted' conventions should be followed as early as possible as code legibility and comprehension can be greatly increased for both the individual and anyone reviewing the code.
I did point out there were differing opinions too and also mentioned that companies have their own styles.
In my opinion it was far from a sermon; One sentence followed by a code example does not a sermon make.
BillWoodruff wrote: For this reason, I voted your response a #1
That is your prerogative, but perhaps somewhat extreme? No matter, CP reputation points are the least of my concerns in life!
|
|
|
|
|
You can return more than 2 value from function.
There are 2 way but I suggest you second one.
1. You can change your Method type to object[].
2. Create a class and its member can be what you need to return.
for example if you want to return 3 Double type value use these:
public class Result
{
public double FirstNumber { get; set; }
public double SecondNumber { get; set; }
public double ThirdNumber { get; set; }
}
Then in your function:
public static Result Do(params double[] numbers)
{
Result result = new Result();
result.FirstNumber = numbers[0] - numbers[1];
foreach (double number in numbers)
result.SecondNumber += number;
return result;
}
Meysam
|
|
|
|
|