|
|
This is difference between Finalize() VS Dispose():-
- Methods dispose() and finalize() are the methods of C# which are invoked to free the unmanaged
resources held by an object.
- The dispose() method is defined inside the interface IDisposable whereas,
- the method finalize() is defined inside the class object.
- The main difference between dispose() and finalize() is that the method dispose() has to be
explicitly invoked by the user whereas, the method finalize() is invoked by the garbage collector,
just before the object is destroyed
|
|
|
|
|
Hi ,
I can do listing users account ,just want to change their passwords,
So ,I want to update users table according to ıd value like below
<table id="myTable" class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th style="width: 2px">Id</th>
<th>Name And Surname</th>
<th>Passwords</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var veri in Model)
{
<tr>
<td>@veri.Id</td>
<td>@veri.UserName</td>
<td>@Html.TextBoxFor(t => new AccountInfo().Pwd, new { @Value = @veri.Pwd, @class = "form-control", style = "width:100px"})
<td>
@Html.ActionLink(linkText: "UPDATE", actionName: "UpdateManageUser", controllerName: "AdminPanel", routeValues: new {id = @veri.Id, NewPwd = @veri.NewPwd },
htmlAttributes: new {onclick= "userUpdateJson()", id = "btnUpdate",@class = "btn btn-primary pull-left"})
</td>
</tr>
}
</tbody>
</table>
public ActionResult UpdateManageUser(int id,string pwd)
{
var con = Core.GetLocalConnection();
con.Open();
var cmd = new SqlCommand("SELECT COUNT(*) FROM S_ACCOUNTINFO WHERE ID=@P1", con);
cmd.Parameters.AddWithValue("@P1", id);
var result= Convert.ToInt32(cmd.ExecuteScalar());
if result= == 1)
{
cmd = new SqlCommand("UPDATE S_ACCOUNTINFO SET PWD=@P2 WHERE ID=@P1", con);
cmd.Parameters.AddWithValue("@P1", id);
cmd.Parameters.AddWithValue("@P2", pwd);
cmd.ExecuteNonQuery();
}
con.Close();
return RedirectToAction("ManageUser");
}
|
|
|
|
|
|
I am making a small example of adding, editing, deleting and saving the treeView directory tree into the SQL Server database, what must I design to store in the database and write code ?
|
|
|
|
|
Apart from the obvious items for each record you need to add some links to the child and sibling nodes. Assuming each record will be given an id or key value, you can link them by that. So a record can have an item that has the key of its first child node, if it has one. And also the key of its first sibling node, if it has one. That way you should be able to start from the root record and traverse the entire tree in order. Much the same as you would in the TreeView itself.
|
|
|
|
|
First there is a bit of configuration which I am not sure where is is set.. But is basically as follow:
- We got an ADFS server (AD Federation Server)
- It forwards authentication to 2 ("slave") servers, the company AD / Auth server and a private AD server for extra custom user
When we start the web site and go on a page marked with the [Authorize] attribute, it props the ADFS login page, which ask us to chose the AD server, then enter credential, and I can successfully login with user of either AS server.
However, when I try to do the same thing to authorize web server to web api call using an hard coded API User (we are not using JwtToken for the current user due to some other issue), getting the token as follows:
var context = new AuthenticationContext(adfsInfo.Authority, false);
var credential = new UserPasswordCredential(adfsInfo.UserName, adfsInfo.Password);
var result = await context.AcquireTokenAsync(adfsInfo.ResourceId, adfsInfo.ClientId, credential);
This
- works for user in the company AD server
- doesn't work for user in our private additional AD server. I got "invalid user or password"
where Authority is the same AD Url that I use for ADFS Web login, i.e. something like:
<a href="https://auth.dev.mycompany.com/adfs">https://auth.dev.mycompany.com/adfs</a>
What could be wrong? How could I fix it?
|
|
|
|
|
In a web form application I support, I need to have the web pages display in the following new languages:
Karen, Burmese, Nepali, and Arabic. Right now the application is displayed in English and Spanish.
My question is how to have the pages display in the various languages and here is what I am thinking:
Have the html that is generated point to the various languages by using different fonts. For example:
For the Karen language, the font would be 'Karen Hiland',
For Arabic language the font would be 'Arabic (Iraq),
If the above would not work, what would the web form need to make the html display to show what language is currently being displayed?
if that does not work, what would you suggest I do to accomplish my goal?
|
|
|
|
|
It's usually done with resource files. If it is already multi-lingual then can't you simply extend the method you have now for other languages? Converting a site to use resource files if it doesn't currently use them is a substantial effort.
|
|
|
|
|
Greetings again expoerts.
The code below was generously provided by the great Richard Deeming.
sp:HyperLinkField
DataNavigateUrlFields="filename, servername"
DataNavigateUrlFormatString="http://Archive/{1}/play_recording_wav.aspx?filename=noop_{0}.wav"
It concatenates fieldnames with hardcoded values to allow audio files saved on the server to be played.
For instance, Archive is hardcoded. So is noop and .wav.
However, {1} and {0} are database fieldnames (filename, servername)
The issue we are currently having now is that values for filename exist for all records in the database.
However, some of the filenames on the server do not exist.
For instance, let's say we have V0000YT as value for filename on the database, that same V00YT which is an audio file, does not exist on the server.
As a result, when you load that record on the browser and click Listen, you get "page cannot be displayed" error.
If I designed the database, I would have added a flag with a value of Yes or No.
Yes, if filename on the database has an associated audio file on the server.
No, if there is no associated audio file on the server.
Management has asked to disable the Listen link if there is no audio file on the serer is associated with a filename on the database.
I told him this is not possible.
Am I right?
Thanks very much in advance
modified 31-May-19 10:33am.
|
|
|
|
|
You'll need to use a TemplateField[^] instead, along with a code-behind function to test whether the file exists.
<asp:TemplateField HeaderText="Recording">
<ItemTemplate>
<asp:HyperLink runat="server"
NavigateUrl='<%# string.Format("http://Archive/{1}/play_recording_wav.aspx?filename=noop_{0}.wav", Eval("filename"), Eval("servername")) %>'
Enabled='<%# RecordingExists(Eval("filename", "{0}"), Eval("servername", "{0}")) %>'
Text="Listen"
/>
</ItemTemplate>
</asp:TemplateField>
protected bool RecordingExists(string filename, string servername)
{
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Sorry for the silly question sir but what goes in here:
protected bool RecordingExists(string filename, string servername)
{
...
}
Many thanks for your help
modified 29-May-19 20:17pm.
|
|
|
|
|
Some code to test whether the specified file exists.
Assuming your files are stored somewhere that's accessible to the current site, the simplest solution would be to add a virtual directory under App_Data , and then use something like:
protected bool RecordingExists(string filename, string servername)
{
string virtualPath = string.Format("~/App_Data/YourVirtualDirectory/{1}/noop_{0}.wav", filename, servername);
string physicalPath = Server.MapPath(virtualPath);
return System.IO.File.Exists(physicalPath);
}
Adding the virtual directory under App_Data will ensure that users can't access the files directly by navigating to them; they will have to use the "play_recording" page.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you so much sir.
Sorry to bother you again but the disable is working except that every audio on the Listen link is getting disabled whether an audio exists or not.
|
|
|
|
|
That doesn't sound right. Are you sure you're checking the correct path, and that your application pool user has at least "read" access to the folder and the files?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
--Yes sir - to the application pool having the correct permission.
However, on the issue of path, can I please explain it a bit?
Let's say our server name is it-server1.
On this server, we have two drives, drive c which looks like this:
LOLCAL DISK(C) and drive e which is set up to look like:
Archive(E).
Inside this Archive (drive E), we have (so far) 4 folders but for some reason, they are called servernames, servername1, servername2, servername3 and servername4.
It appears that these folders are created dynamically. I don't know how because this was set up by vendor.
Then on our database, we have same number of servernames, servername1 through servername4.
I don't know why they are called servernames instead of folders.
The audio files reside on each of these folders.
So, when you click on the Listen link depending the data queried from the database, a servername(folder) is selected and a selected audio file, if exists is selected.
So, the link that plays an audio looks like this:
http//it-server1/archives/folder1(servername1)/filename(audio file).wav
http://it-server1/archives are hardcoded. So is .wav
That's how it looks like on the browser.
|
|
|
|
|
That doesn't seem to match the link from your original question:
http:
You now seem to be navigating directly to the audio file, using a web server on it-server1 . Is that the same server that your code is running on?
Assuming it is the same server, then you'd want something like this:
protected bool RecordingExists(string filename, string servername)
{
string virtualPath = string.Format("/archives/{1}/{0}.wav", filename, servername);
string physicalPath = Server.MapPath(virtualPath);
return System.IO.File.Exists(physicalPath);
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you very much sir.
You are so kind and so patient, I really appreciate it.
Yes, that is the server that my code is running on.
I tried exactly this yesterday and I just tried again now and I am still getting the link disabled even when I am 100% sure the link I am clicking on has an audio file on the server.
Does it matter that my app is on C drive (on wwwroot) and the audio files are on E drive?
I can move my app to same E drive if I have to.
|
|
|
|
|
Having the files on a different drive shouldn't make any difference.
Have you checked that the physicalPath variable contains the correct path?
If it still doesn't work, then it must be an NTFS permissions issue. Make sure that IIS_IUSRS has at least "read & execute" access to the folders on the E: drive, and reset the permissions on all child objects.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Ok, HUGE progress.
Two problems.
I forgot to include noop_
Sorry about that.
When I included that, the link is now enabled (YEA!!!)
But I am having problem with the second problem.
E drive has the name Archive.
If I use that name on the code, the link is disabled.
However, if I add s as in Archives, the link is enabled.
However, when I click on the link, it displays Archive, removing the s and it gives an error, "file or path cannot be found"
I have got to find a way to change the name Archive on E drive to Archives when the link is clicked so that even though the drive says Archive, it will render as Archives.
Any ideas?
I don't think creating virtual path on the app can solve problem, no?
UPDATE: IT IS WORKING, YEA!!!
I realized the markup has just Archive. I added the 's' and NOW it WORKS!
I can't thank you enough for the many, many times you have come to my rescue.
Thank you very much sir and God bless.
modified 31-May-19 10:32am.
|
|
|
|
|
It sounds like you already have a virtual path /archives/ mapped to E:\Archive\ .
In which case, your URL should look something like:
NavigateUrl='<%# string.Format("/archives/{1}/noop_{0}.wav", Eval("filename"), Eval("servername")) %>'
And the code-behind should look like:
string virtualPath = string.Format("/archives/{1}/noop_{0}.wav", filename, servername);
string physicalPath = Server.MapPath(virtualPath);
return System.IO.File.Exists(physicalPath);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
You are coding god!
Just one last question.
On a regular markup, I can add a message when the link is disabled that says something like:
title="No audio exists for this record"
Is there a way to squeeze that message in somewhere?
|
|
|
|
|
Something like this should work:
ToolTip='<%# RecordingExists(Eval("filename", "{0}"), Eval("servername", "{0}")) ? "Play recording" : "No audio exists for this record" %>'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am getting two errors.
One said The '?' character cannot be used here.
The other error says: syntax error on -> "No audio exists for this record"
|
|
|
|
|
Are you using VB.NET? If so, try:
ToolTip='<%# If(RecordingExists(Eval("filename", "{0}"), Eval("servername", "{0}")), "Play recording", "No audio exists for this record") %>'
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|