|
The item is being removed from the Cache after the default 20 minutes? Are you removing it somewhere prior to this? If you are attempting to login during this time period then it is correct.
Just personal preference I guess but I would rather use String.IsNullOrEmpty or String.IsNullOrWhiteSpace rather than this
if (sUser == null || sUser==" ")
Less typing and more clear as to what condition you are testing.
No comment
|
|
|
|
|
Hello,
Yup I set it to default, few question why does if I tried other account it still says that the accout is already login.
|
|
|
|
|
akosidandan wrote: if I tried other account it still says that the accout is already login
That part wasn't clear in your question. Have you debugged it? What is in your Cache? Code is stupid, it only does what it is told, unless you tell it to insert the user it won't be there, ergo, you must be adding it to the cache at some point.
No comment
|
|
|
|
|
Hello,
My apology about that, the code was orginally in vb.net in the link of my main post. I just managed and tried converting it myself thats why I dont have 100% idea about to code logic.
"After the code every time I login it always says that the user is already login now" <- it was a follow up question for this.
|
|
|
|
|
The main question here is: why would you want to do that? In 99% of cases it is a pure annoyance with no functional benefit (as well as being rather difficult to do well because of the nature of HTTP and session management).
|
|
|
|
|
Hello,
I know its hard and really annoying but still what if the my boss want it that way then I have no choice but to do it or else I will be kicked out.
Seems I have no choice but no to add it if I can't managed to do it, I guess
|
|
|
|
|
akosidandan wrote: what if the my boss want it that way
So this functionality isn't part of the specifications? Then why do it? Many man-years have been wasted on projects providing functionality that was never requested. If you think it has added benefit to the application then present your idea to your boss.
You are worried about being "kicked out" for not doing something that was not requested. I'd be more concerned about being "kicked out" for spending time on functionality not requested.
No comment
|
|
|
|
|
Hello,
I apologize if I may not understand you but I'm just a newbie asking for some experts advice,recommendation about stuff I'm not able to do. It's a part of my project specification that's why why if possible I want to add that functionality.Since I'm stuck in this part I came to ask in this forum was hoping to get some advice how to it or if lucky an answer.
|
|
|
|
|
Well, your first approach should be to make sure your boss realises it's a dumb requirement (though I wouldn't necessarily put it in those words), and if it comes from a client, get your boss to have the same discussion with the person who put it in the specification. By far the best solution here is if you can persuade the customer that they don't actually want this 'feature' at all. Even if you're a newbie or new to the company, don't be intimidated out of at least raising the point.
If you try that and you really can't get it removed, the logic goes something like this (in the login attempt script, once authorisation has been checked and you are about to log in) – pseudocode only, if that wasn't obvious:
string sid = DBQuery("select lastsessionid from user where userid=(ID)", userid);
Session session = GetSession(sid);
if(IsValidSession(session)){
session.Logout();
}
thisSession["user"] = userData;
DBQuery("update user set lastsessionid=(sessID) where userid=(ID)", thisSession.ID, userid);
I think it's better to kill any previous sessions rather than reject the login, otherwise it's way too easy to lock yourself out for the session expiry timeout (turn off machine at work without pressing 'Logout' link and go home/to lunch/etc) or, if there is some AJAX that keeps the session alive indefinitely, permanently.
I haven't tried to do this with ASP.net so I'm not sure how easy it is to get hold of session objects for sessions other than the one you're currently in. You need to be able to do that because otherwise you won't be able to tell when a previous session has expired.
session.Logout is a placeholder for clearing whatever you put into the session on login (so the next page load in that session is as a guest). Again, with ASP.net's role management that might be more tricky than it should be.
|
|
|
|
|
I don't do Web stuff, so I don't know the intricacies of it, but for the few WinForms apps I've written that require login, if the user logs in a second time, I invalidate the earlier login. I expect that's how the user would want it to work.
|
|
|
|
|
Hello,
Good idea , but still it would be hard for me to Invalidate the earlier login because I need to force logout the earlier log in.
Thanks for the idea I will still try it.
|
|
|
|
|
I am working with an existing C#.net 2008 desktop application that I would like to add security to the application by using windows authenication to connect to the active directory. i would like the error message to show up when a user clicks on a desktop link they have no access to.
Can you point me to some links that I can use as a reference to accomplish this task?
|
|
|
|
|
Try the link Simon supplied to can your request for code in the previous question.
I would also pick out the key word in you question and type them into Bing/Google and peruse the results.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
|
Look at the System.DirectoryServices namespace. There you'll find classes for connecting to the server and the DirectoryEntry.NativeObject which will allow for checking access rights.
|
|
|
|
|
I have a new C#.net 2008 console/windows form application that I need to add security for. I would like to tie all logins together at one time using the active directory. I would like to have windows authenicatiuon setup to use to connect to the sql server 2008 r2 database, I would like to know what role each person has, I also would like to setup a methods to determine what application a user has access to and what their roles are in each application. (For example; a person can have access to app1 and be a manager in the next applicationn the person would only have a 'general' user role.) Thus i am wondering if you can tell me the following;
1. I would like to know how each person can connect to the database,
2. I would like to see C#.net 2008 code that would accomplish the tasks i listed above or at least accomplish part of the tasks listed above.
|
|
|
|
|
|
Are you going to forward your paycheck to responders too? This sounds an awful lot like a "do my work for me" post.
|
|
|
|
|
hey i have a table under the repeater like shown below in the code. Now my problem is there showing the empty rows too along with the data from that table value "TotalAmount". So i am wondering if I could be able to put the condition under that table. some thing like if value equals null, delete the table cell or else show the table cell kind of thing. Is there any way I can do this?
<asp:Repeater ID="rptTotAmount" runat="server">
<ItemTemplate>
<div style="page-break-after:always;">
<asp:Table ID="tblItemListt" runat="server" Font-Size="8%">
<asp:TableRow>
<asp:TableCell HorizontalAlign="Right"><%# DataBinder.Eval(Container.DataItem, "TotalAmount", "Total: {0:c}")%></asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</ItemTemplate>
</asp:Repeater>
suchita
|
|
|
|
|
You should ask this in the ASP.NET forum
|
|
|
|
|
|
Good Afternoon,
So, I am using this very nice code to generate Excel spreadsheets from my Datagridview, and I could not be more pleased:
private void CreateExcelReport()
{
Microsoft.Office.Interop.Excel.Workbook wBook;
Microsoft.Office.Interop.Excel.Worksheet wSheet;
Microsoft.Office.Interop.Excel.Application wApp = new Microsoft.Office.Interop.Excel.Application();
wApp.Visible = false;
wBook = wApp.Workbooks.Add(true);
wSheet = wApp.ActiveSheet;
try
{
for (int i = 0; i < dataGridViewReport.Columns.Count; i++)
{
wSheet.Cells[1, i + 1] = dataGridViewReport.Columns[i].HeaderText;
}
for (int i = 0; i < dataGridViewReport.Rows.Count; i++)
{
DataGridViewRow row = dataGridViewReport.Rows[i];
for (int j = 0; j < row.Cells.Count; j++)
{
DataGridViewCell cell = row.Cells[j];
try
{
wSheet.Cells[i + 2, j + 1] = (cell.Value == null) ? "" : cell.Value.ToString();
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
}
}
wApp.Visible = true;
}
catch (Exception ex)
{
MessageBox.Show("Error : " + ex.Message);
}
wApp.UserControl = true;
}
Now I would like to have the application run in the background and generate these reports automatically and put them in a folder (anyplace) perhaps by using the timer. I have created the timer part and can call a named file from a database and launch it, however, I do not know where to begin adding onto the Excel code to do it automatically. I need to be able name the file in the spreadsheet, point this script at a location where it can be saved and found later and and have it run automatically as long as the app is running. A piece of code here (perhaps a sample) would be much appreciated. Thank You....Pat
|
|
|
|
|
You could autoname the file using the date/time function.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Thank you, Dave....yes, I have used that to actually create the name by creating an addendum with the date/time, but what I am really looking for is some code that, after the timer calls the method and the Excel sheet is generated by the Excel application, saves the file in a specific location as you would manually from the SaveDialog box, but instead it would do it automatically. The purpose of this method is to run predetermined (by time) SQL Select statements that are retrieved from a database and then store the results in a file so they can be examined at a later time. I am having a problem explaining it here..I am sorry... . Thank you again for your response.
BTW...I see you are British...my new neighbors are from England. He is here (U.S., California) as an Engineer to work with the Air Force on the Harrier Jet at Edwards AFB. They are a real "kick"...way too funny .
Thanks Again, Pat
|
|
|
|
|
Having read your reply to DD I wonder why you are using a DGV at all. I would do the following
Go into Excel and record a macro that saves your workbook to a folder. Take the macro and rewrite it into c# code. This will be the save method, consider that you will pass in a workbook and a filename to the method.
Use a timer with a tick method set to the interval you need
Your form starts the timer and has a listbox of the selected queries and the pass/fail of each process and a textbox with the destination folder.
In the tick event you:
Stop the timer
Get the datatable from SQL
instead of looping the columns/rows in the DGV loop the Rows/Columns of the datatable
for (int i = 0; i < dataGridViewReport.Columns.Count; i++)
use
for (int i = 0; i < Datatable.Columns.Count; i++)
Call your save method you have reconstructed from the excel macro
start the timer.
Your exception handling needs to deal with failed methods and write to the listbox data store and restart the timer.
In various places you need to log results to the listbox data store
Never underestimate the power of human stupidity
RAH
|
|
|
|