|
You can store this data in a database and use an automated process, perhaps a SQL Job, to format and email it. There is nothing built-in that will do this if that's what you are asking.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Assumption: ASP.NET
You can get the first three from Request.Headers, but not the last.
The last is probably not possible, since everything is stateless and you can't tell when they leave unless there is a "log out" of some kind. If there is, then that's just a matter of doing a time difference between login and logout.
Emailing can be done with System.Net.Mail as long as you have an available SMTP server out there you can use.
|
|
|
|
|
E-mail seems like a terribly inefficient way to record that kind of data.
Try adding google analytics[^] to your site. It will give you way more than what you are looking for and probably take less time to add than some custom code for the short list you gave.
|
|
|
|
|
Hi,
I am using the open source provided at code project for SFTP. However it gives following error :
'Tamir.SharpSsh.jsch.Util' is inaccessible due to its protection level
Is Anyone aware of this error? How to resolve. Please help
|
|
|
|
|
If you got the code from an article, then there is a "new message" button at the bottom of that article, which causes an email to be sent to the author. They are then alerted that you wish to speak to them.
Posting this here relies on them "dropping by" and realising it is for them.
Otherwise, we would need to see relevant code fragments to be specific. However, the error "inaccessible due to its protection level" normally means you are trying to access a private, protected or internal class, field, property or method from outside. Either change the protection level (carefully, restrictions are generally put there for a purpose), or reconsider what you are doing.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Typically the projects have some kind of "main class" which is meant for general use, and some "code behind classes" which are required by the main class, but the author did not think that they are used without the "main class". Depending on your specific needs, it can be quite appropriate to directly access such a "code behind class" or derive one of your classes from there. Simply change the "private"/"internal" label to "public" and recompile, but more important: do a lot of testing, because some further changes to that class may be required.
|
|
|
|
|
I want to change the font size of the Console but that is not easy. After googling, the WinAPI SetCurrentConsoleFontEx() located in the kernel32.dll should do the trix. This is my code:
using System;
using System.Runtime.InteropServices;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
[StructLayout(LayoutKind.Sequential)]
public struct COORD
{
public short X;
public short Y;
}
[StructLayout(LayoutKind.Sequential)]
public struct CONSOLE_FONT_INFO_EX
{
public uint cbSize;
public uint nFont;
public COORD dwFontSize;
public ushort FontFamily;
public ushort FontWeight;
string FaceName;
}
[DllImport("kernel32.dll", SetLastError = true)]
static extern bool SetCurrentConsoleFontEx(IntPtr ConsoleOutput, bool MaximumWindow, CONSOLE_FONT_INFO_EX ConsoleCurrentFontEx);
static void Main(string[] args)
{
CONSOLE_FONT_INFO_EX font = new CONSOLE_FONT_INFO_EX();
}
}
}
My code is is in the Main() method, all other code I have googled and pasted in.
The only thing I miss is how I shall instantiate the CONSOLE_FONT_INFO_EX struct?
I want the font to be 16 x 12. Some suggestions?
Some sites I used:
http://msdn.microsoft.com/en-us/library/ms686200%28VS.85%29.aspx[^]
http://msdn.microsoft.com/en-us/library/ms682069%28v=VS.85%29.aspx[^]
|
|
|
|
|
You shouldn't change it. Let the user use what he likes. I prefer 7x12 and I wouldn't want someone to change it on me.
|
|
|
|
|
Never tried it, but from the code you've posted...
COORD coord = new COORD();
coord.X = 12;
coord.Y = 16;
font.cbSize = coord;
|
|
|
|
|
Thanks! It actually worked.
|
|
|
|
|
I've been working with C# for about 6 months. This is the first time that a little searching has not resolved a problem for me. I'm trying to change the text of a label and update a progress bar in a loop that does some graphic calculations. The progress bar is working fine but the label text does not change until the loop has completed.
int nImgCnt = m_Parent.m_ImageList.Count - 1;
int nStatBarAdd = 1000 / nImgCnt;
for (int nIdx = 0; nIdx <= nImgCnt; nIdx++)
{
lblProg.Text = "Calculating minimum image size. Image " + (nIdx+1).ToString() + " of " + (nImgCnt + 1).ToString();
lblProg.Focus();
lblProg.Invalidate();
CurRC = getImageMinSize(m_Parent.m_ImageList[nIdx]);
if (CurRC.Width > MinRC.Width)
{
MinRC.Width = CurRC.Width;
MinRC.X = CurRC.X;
}
if (CurRC.Height > MinRC.Height)
{
MinRC.Height = CurRC.Height;
MinRC.Y = CurRC.Y;
}
prgBr.Value += nStatBarAdd;
}
If anyone can help me out with this I will really appreciate it!
|
|
|
|
|
it all depends where your code is sitting.
if it is in a GUI event handler (say a button click handler) then the main thread would be busy with your code, and hence the GUI would not respond to the things the user does, and a lot of things your code does. The right approach would be to use a separate thread, maybe a BackgroundWorker would be fine.
if it is not in a GUI event handler, hence already being executed by some other thread, then you are performing illegal cross-thread operations to GUI components. You might want to read this article[^].
All the above applies to all kinds of Controls; from what I've seen, I can't tell why the progress bar works better for you, I don't think it should the way things are.
|
|
|
|
|
Thanks for the quick response Luc!
Sorry, I should have pointed out this is in a button click event handler. I will trying doing the calculations in a BackgroundWorker, thanks again!
Edit:
I added a BackgroundWorker and life is good again. Thanks again Luc! I should have worked this one out for myself. I must be having a bad code day.
modified on Sunday, January 2, 2011 1:47 PM
|
|
|
|
|
You're welcome.
|
|
|
|
|
Luc Pattyn wrote: if it is not in a GUI event handler, hence already being executed by some other thread, then you are performing illegal cross-thread operations to GUI components. You might want to read this article[^].
But since he's not getting an exception, that can't be it. Unless there's more to it than I've experienced.
|
|
|
|
|
He didn't mention exceptions, so it was unclear whether any occurred or not. And a ThreadPool thread would happily swallow any exception he didn't handle explicitly: ThreadPool threads are built to survive no matter what.
|
|
|
|
|
I don't think their is a way of making this syntax work, but I think it would be quite nice to see this in C# .Net:
Instead of something on the lines of :
for(int i = 0; i <= 10; i++)myArray[i]...
We could just:
myArray[0 to 10]....
Even:
myArray[(n) 0 to length-1]n++;//which could increment each item in the array.
Just an idea although Linq may have some way already
|
|
|
|
|
Something wrong with foreach ?
foreach (MyElement me in myArray)
{
...
}
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Dunno why that got you a visit from the univoter - the for loop is a bit old and clunky.
Compensated.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thanks
I just find that sometimes using the for-loop for a trivial idea in an array is too much.
|
|
|
|
|
|
OriginalGriff wrote: the for loop is a bit old and clunky.
That is like saying the while loop is old and clunky.
foreach is appropriate for certain situations and for is appropriate for others. Attempting to use foreach in all situations would lead to some code that would be attempting to replicate what for already does.
|
|
|
|
|
Using a for loop for a simple iteration though all the elements of any list is old and clunky - foreach is much more appropriate. Since that is what the OP was trying to do, that is how I responded.
I agree that foreach is not appropriate in all cases - in some you cannot use it at all - but I was indicating that a language element already existed that did what the OP was trying to achieve.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OriginalGriff wrote: Using a for loop for a simple iteration though all the elements of any list is old and clunky - foreach is much more appropriate. Since that is what the OP was trying to do, that is how I responded.
I didn't see a qualification limiting your comment to only what the OP was doing. Rereading your post several times I still don't see any way to read it that provides a qualification.
With the qualification I have no problem with that comment.
|
|
|
|
|
Write a macro.
|
|
|
|