|
asp.net MVC related latest news ?
modified 13-May-14 5:56am.
|
|
|
|
|
You already have this posted in Quick Answers - don't duplicate posts, it duplicates work and annoys people.
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
As Original Griff said, don't cross post.
Even if this weren't a cross post with Q&A, it would have been much better posted in the ASP.Net forum, and you should also format your post so it can be read.
|
|
|
|
|
This is now a nonsense question, even if it did make sense it would be in the wrong forum.
Please read the site guidance about how to ask a question - practically everyone here is an unpaid volunteer.
|
|
|
|
|
The OP changed the question because they'd crossposted it.
|
|
|
|
|
I notice you didn't use the word "improved"...
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
Hello,
for my app that is designed to run under WinPE 5.0 (both 32/64-bit) I need to implement OpenFileDialog in my Form. But OpenFileDialog can't be used under WinPE, so I decided to use OpenFileName instead. It works well, except file extension filter, because it shows all files. My code is as below
OpenFileName ofn = new OpenFileName();
ofn.structSize = System.Runtime.InteropServices.Marshal.SizeOf(ofn);
ofn.filter = "PDF files\0*.pdf\0";
ofn.file = new String(new char[256]);
ofn.maxFile = ofn.file.Length;
ofn.fileTitle = new String(new char[64]);
ofn.maxFileTitle = ofn.fileTitle.Length;
ofn.initialDir = openPath;
ofn.title = "Open PDF file...";
ofn.defExt = "pdf";
if (LibWrap.GetOpenFileName(ofn))
{
selectedFile = ofn.file;
}
File extension filter works normally under full OS / Win7 64-bit, so there is some problem with WinPE only. Any idea how to solve it ?
|
|
|
|
|
I am trying to make a game in c# for kinect, it runs without any error but it is not working as expected, can anyone with a Kinect test it?
|
|
|
|
|
Member 10807796 wrote: it is not working as expected
Now, I want you to sit back, and think about what you said: how useful a comment is that?
The answer is simple: none whatsoever.
It's like you going for a drive and breaking down in the middle of no-where. Quickly, you grab your phone and call the garage! "Hello? My car broke!" you say, before ending the call.
How long do you think it is going to be before the garage arrives where you are with the right bits to fix your car?
We are in the same position as the garage: all we know is that someone (who? No idea) has a problem (what? No idea) (where? No idea) and wants us to do something (how? No idea).
We only get to see what you tell us: we can't see your screen, access your HDD, or read your mind. So tell us things we can use!
Onward: testing your application. Unlikely. Would you download an executable from someone who don't know, that does something but you have no idea what, and has known problems but you don't know what? Because I wouldn't. And if you would, can I have your name and address, because I have a bridge that I'd like to sell you...
So, think again, and explain your problem. Tell us what you are trying to do, and tell us what is happening that you don't expect, or not happening that you do. Show us the relevant code fragments - not the whole code, just the minimum relevant lines.
Help us to help you!
Those who fail to learn history are doomed to repeat it. --- George Santayana (December 16, 1863 – September 26, 1952)
Those who fail to clear history are doomed to explain it. --- OriginalGriff (February 24, 1959 – ∞)
|
|
|
|
|
I have a requirement to generate an Outlook email that is downloaded after a new user is created through the UI. The client wants to review the email prior to it being sent to the user, this is why it needs to be downloaded. I cannot use Microsoft.Interop because this is a web application and Office is not installed on our servers.
I have created a html template for the email body and I am using MailMessage to generate the email. My current code sends the file to a pickup directory and then I try to download the file as an eml file. This works, except the body of the email is missing from the download. If I go to the server and view the file it does have the body. What am I missing from the download piece of code? Thank you for any thoughts and suggestions.
public static void sendNewUserEmail(string username, string password, string url, List<string> projects, string client)
{
try
{
var response = System.Web.HttpContext.Current.Response;
var emailfilepath = @"C:\LogFiles\FE\Emails\NewUser\";
DateTime now = DateTime.Now;
now.ToString("yyyy-mm-dd");
var projectlist = String.Join(", ", projects.ToArray());
string fromemail = "support@noreply.com";
string subject = "New Account Created - " + client + ": " + projectlist;
MailMessage message = new MailMessage();
using (StreamReader reader = File.OpenText(@"C:\inetpub\fe\Interior\UserAdmin\NewUserEmail.html"))
{
message.From = new MailAddress(fromemail);
message.To.Add(username);
message.Subject = subject;
message.Priority = MailPriority.High;
message.IsBodyHtml = true;
message.Body = reader.ReadToEnd();
message.Body = message.Body.Replace("{Password}", password);
message.Body = message.Body.Replace("{Project}", projectlist);
message.Body = message.Body.Replace("{URL}", url);
}
SmtpClient smtp = new SmtpClient("mysmtphost");
smtp.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
smtp.PickupDirectoryLocation = emailfilepath;
smtp.Send(message);
var file = new System.IO.FileInfo(emailfilepath);
string filename = file.Name.ToString();
response.BufferOutput = true;
response.Clear();
response.ClearHeaders();
response.ContentEncoding = Encoding.Unicode;
response.AddHeader("content-disposition", "attachment; filename=NewUserEmail_" + client + "_.eml");
response.AddHeader("Content-Length", file.Length.ToString(CultureInfo.InvariantCulture));
response.ContentType = "application/octet-stream";
response.WriteFile(emailfilepath + file.FullName);
response.End();
DeleteFile(filename);
}
catch (Exception ex)
{
string message = ex.Message;
string stacktrace = ex.StackTrace;
string source = ex.Source;
string method = "sendNewUserEmail";
Logger.LogFile(source, message, stacktrace, method);
}
}
modified 12-May-14 15:46pm.
|
|
|
|
|
Try to re-phrase your requirement. What do you want to do:
- Send an email to a freshly created user / someone else
- Use a template for the email
- Have the user edit the email before sending it
- Send it without Microsoft Outlook (SMTP)
- Download a file (why?)
- ...?
|
|
|
|
|
They just want to be able to track the sent emails through the shared email that they are using for support here. That is why I need to be able to download the email and have it open in Outlook. All of this code is handled in the Admin section of the website. The admin users are the ones who would download and send the new user emails out.
Bernhard Hiller wrote: Try to re-phrase your requirement. What do you want to do:
- Send an email to a freshly created user / someone else
- Use a template for the email
- Have the user edit the email before sending it
- Send it without Microsoft Outlook (SMTP)
- Download a file (why?)
- ...?
|
|
|
|
|
Hello there. Does there exist a way to execute my C# code (either graphic or non-graphic) on GPU (I have nvidia's gpu)?
1 - There exists this CUDAfy.Net from codeplex but I think I would like to do something that is directly done through visual studio. What could I do for this?
2 - What would be the best possible approach if I want to use Direct3D API from C# and get that code executed on GPU ?
Thanks for any input or pointer?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
|
First one can definitely be executed on GPU. Can the second one be run on it as well?
What can you say bout SharpDX and SlimDX?
This world is going to explode due to international politics, SOON.
|
|
|
|
|
AmbiguousName wrote: What can you say bout SharpDX and SlimDX? They're wrappers around DirectX. I don't have a 3D-card, but Warcraft is happy with DirectX.
What do you plan to (ab)use the GPU for?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Eddy Vluggen wrote: What do you plan to use ( ) the GPU for? Still learning graphics programming (you might have noticed). Just want to know that GPU can be used for general purpose processing. You did't answer the question. Can I make my GPU run the:
- Direct3D code using C#
- SharpDX code
- SlimDX code
This world is going to explode due to international politics, SOON.
|
|
|
|
|
AmbiguousName wrote: Just want to know that GPU can be used for general purpose processing. You can't use it as a second CPU, can't simlpy tell a new thread to run on the GPU; it doesn't do general processing, but works magic with large numeric datasets.
AmbiguousName wrote: You did't answer the question Kind of did
You're not going to program directly against the driver of the graphics-card, but against the next-best abstraction layer. That's DirectX.
SharpDx and SlimDx are wrappers around DirectX - they'll make it easier to have the GPU do something from C#, but will (probably) not offer everything that DirectX itself offers.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
foreach (var fname in fnames)
{
string[] lines = File.ReadAllLines(fname);
for (int i = 0; i < lines.Length; i++)
{
string[] wordsInLineRaw = Regex.Split(lines[i], @"\W+");
string[] wordsInLine = new string[wordsInLineRaw.Length];
for (int p = 0; p < wordsInLineRaw.Length; p++)
{
wordsInLine[p] = wordsInLineRaw[p].ToLower();
}
for (int j = 0; j < wordsInLine.Length; j++)
{
string w = wordsInLine[j];
if (stopWords.Contains(w)) continue;
if (!index.ContainsKey(w))
{
if (worker.CancellationPending)
{
}
index.Add(w, new IndexEntry());
}
index[w].UpdateInfo(fname, i);
}
}
|
|
|
|
|
There are a number of ways you can approach this.
The simplest is to execute the body of your outer loop for multiple files at the same time. You can use the Task Parallel Library that is part of .Net for this. The 'Task' classes let you run code in parallel and wait for results at the end.
If you choose to do that, the problem is now "How do I merge results of concurrent indexes into one big index"
Some possible solutions are:
- Use a lock to protect access to the index
- Create separate indexes and merge them at the end.
I would go with the second because it uses less shared state, and has less chance of me introducing a difficult to find bug
var indexFilesTasks = (from fname in fnames
select Task.Run(() => IndexSingleFile(fname, stopWords, () => worker.CancellationPending))).ToArray();
Task.WaitAll(indexFilesTasks);
index = MergeIndexes(from t in indexFilesTasks
select t.Result);
The IndexSingleFile() method contains all your code in your foreach (var fname in fnames) loop.
The MergeIndexes() method takes multiple Dictionary<string,indexentry>() structures, and merges them together. Below is the code I used for these.
Note this isn't the "best" way, but just one way of approaching the problem.
Dictionary<string,IndexEntry> IndexSingleFile(string filename, HashSet<string> stopWords, Func<bool> isCancelling) {
var index = new Dictionary<string,IndexEntry>();
string[] lines = File.ReadAllLines(filename);
for (int i = 0; i < lines.Length; i++)
{
string[] wordsInLineRaw = Regex.Split(lines[i], @"\W+");
string[] wordsInLine = new string[wordsInLineRaw.Length];
for (int p = 0; p < wordsInLineRaw.Length; p++)
{
wordsInLine[p] = wordsInLineRaw[p].ToLower();
}
for (int j = 0; j < wordsInLine.Length; j++)
{
string w = wordsInLine[j];
if (stopWords.Contains(w)) continue;
if (!index.ContainsKey(w))
{
if (isCancelling())
{
}
index.Add(w, new IndexEntry());
}
index[w].UpdateInfo(filename, i);
}
}
return index;
}
Dictionary<string,IndexEntry> MergeIndexes(IEnumerable<Dictionary<string,IndexEntry>> indexes) {
var result = new Dictionary<string,IndexEntry>();
foreach (var index in indexes) {
foreach (var srcPair in index) {
if (!result.ContainsKey(srcPair.Key)) {
result[srcPair.Key] = new IndexEntry();
}
result[srcPair.Key].MergeFrom(srcPair.Value);
}
}
return result;
}
modified 12-May-14 4:49am.
|
|
|
|
|
Phil Martin wrote: The simplest is to read in multiple files at the same time Wow, where do you get such multi-tasking harddisks from?
No, seriously: that step is likely to be the slowest of all, hence hardly anything can be gained from parallelizing. Only when processing the file contents takes a relatively high timespan, parallelizing might help, but then I'd uncouple reading and processing (i.e. read the file into memory and then send it to the processing function, with the next file read being started at that moment - note: may require large memory). The locks on the index may cause some extra overhead, i.e. slow down again.
|
|
|
|
|
I'm not sure Phil meant to read the files in parallel then continue processing them on a single thread. By parallelizing at the top level, the thread reading the file goes on to processing it so I'd say his assertion was correct but probably better stated as 'read in and process multiple files at the same time'.
It's an odd thing to do anyway. If I were to try and improve the performance of this code the first thing I'd do is get rid of the ReadAllLines and switch to streams before even thinking of going parallel.
Regards,
Rob Philpott.
|
|
|
|
|
Thanks for clarifying that for me Rob. And I agree with you, there are many other things I'd do first and differently. I was aiming for minimum effort on the developer's part with minimum side effects.
I'll edit the post and try to be a little less ambiguous about my intent.
|
|
|
|
|
Ha! I wish I had multitasking hard disks!
My choice of wording was poor, and I hope the code clarified the intent, i.e. choosing the simplest point in the original code to parallelize. Will the changes be optimal? No. Will they be parallel with significant and measurable difference? Yes.
And yes, there are many other options, but I think this was one of the simpler approaches to understand. If they already understood ways to set up a dataflow to achieve the task, I'm pretty sure they would have already done it that way.
|
|
|
|
|
Minimum changes would have been to just use Parallel.For on the outer loop and switch to a ConcurrentDictionary or use locks around the regular Dictionary. Your overall solution is overly complicated (no offense). Any time you save by parallelizing the main loop will be destroyed (and then some) by the merging loop.
|
|
|
|