|
Yup. We have had a few intranet apps here that used windows integrated auth. When alternate browsers and macs started hitting people had caniptions as the login was so silently effective that no one realized they were logging in (or that I was logging their every move).
|
# ? Feb 1, 2013 22:18 |
|
|
# ? May 13, 2024 21:51 |
|
I have a feeling this is "a bad idea", but I'm curious enough to risk asking anyway. We are using EF Code-first. We have a "Pay" entity in the database that contains an amount and an "EarnedDate". However, they are not allowed to be withdrawn until two weeks later. The logic is simple enough, but there are a lot of reports and other things which rely on this basic rule. I could create some sort of withdrawal manager class that makes sure that all functions dealing with withdrawals only include Pays that are two+ weeks old, but I know some developer will forget at some point and include extra pays in a report. I'm wondering if I could create a Second mapping entity and have it only map to db rows where the EarnedDate is over two weeks old. So if I accessed Context.Pays it would include all, but Context.Earnings it would only include ones over two weeks old. Is it possible? If it's the bad idea my gut tells me it is, does anyone have a suggestion (other than rewriting the db schema) that would keep us from forgetting this in a report somewhere?
|
# ? Feb 3, 2013 23:52 |
|
You can create a view on the database, and map your class to that like it was a table. We typically solved that problem with a service-orientated architecture, so your business layer would only get access to the data store through methods provided by the service layer, so we could control exactly what that layer would return.
|
# ? Feb 4, 2013 13:51 |
|
Hey WPF people, I'm loading a 75x120 pixel PNG from the web, stuffing it into a BitmapImage like soC# code:
XML code:
The left is the WPF app, the right is Chrome. I have Stretch set to None, why does the image in WPF look so crappy?
|
# ? Feb 4, 2013 15:22 |
|
Have you set SnapsToDevicePixels?
|
# ? Feb 4, 2013 17:10 |
|
You need to set RenderOptions.BitmapScalingMode on the Image control (WPF 4+ only).
|
# ? Feb 4, 2013 17:26 |
|
Thanks for the suggestions. I've set SnapsToDevicePixels and BitmapScalingMode, to no effect.XML code:
|
# ? Feb 4, 2013 17:38 |
|
Try NearestNeighbor instead of HighQuality. Make sure the image is pixel aligned, ie. no 0.5 px margins. You can force pixel alignment by applying UseLayoutRounding to the root element.
|
# ? Feb 4, 2013 18:12 |
|
Maybe the image isn't really 75x120, somehow, I don't know? Does it look any better if you take out the size specifications?
|
# ? Feb 4, 2013 18:20 |
|
Sedro posted:Try NearestNeighbor instead of HighQuality. Ding ding, this was it. Thanks guys.
|
# ? Feb 4, 2013 18:37 |
|
Okay, who wants to play Tell Me What Blindingly Obvious Thing I'm Missing? I've got an MVC website that I'm putting up on an IIS 7 server. Unfortunately, when I put it up, I get a directory view instead of, y'know, a website. We've got another MVC site that works fine. I tried moving the new site to the old one's AppPool (it was on its own AppPool for some reason, even though all the settings look the same as Default to me). Didn't work, so it's not AppPool settings. I deleted the site's code and put a copy of the working MVC site in the folder instead. Didn't work, so it's nothing local like web.config. That just leaves some specific application setting that I'm just... not... seeing. Microsoft's documentation claims that as long as I'm using a working AppPool I don't need to do anything else, which is unhelpful. MVC isn't my strong suit (not by a mile, I'm still learning it) and I didn't set up the working one, my boss did, and he's since forgotten what he did to make it work. I'm stumped. edit: I got it! Mostly! I had to change PageHandlerFactory-ISAPI-2.0's extension to "*" from "*.aspx". Now everything works but the .css. CapnAndy fucked around with this message at 20:01 on Feb 4, 2013 |
# ? Feb 4, 2013 19:55 |
|
I'm building an ASP.Net MVC4 data entry page for invoices, and I'm not sure how to handle the detail part of the master/detail view. My invoices have a customer and some notes, which is just like any other MVC create/edit page, and then I need to add/remove line items - these have some behaviour dictated by a couple of drop downs that cause other fields to show or hide, plus calculate line item price, and then the total price needs to be calculated too. I'm struggling to find the "standard" way of doing this in MVC - I started out hand-rolling DOM manipulation javascript using D3.js (because I'd used it in a previous project), but then I came across knockout.js as a way to template the line items DOM stuff and behaviour (which seemed a bit easier than hand-rolling)... I'm getting the feeling that I'm missing something fundamental in MVC, but google isn't being very helpful at the moment, does anyone have any pointers or examples? mortarr fucked around with this message at 21:43 on Feb 6, 2013 |
# ? Feb 6, 2013 21:00 |
|
mortarr posted:I'm building an ASP.Net MVC4 data entry page for invoices, and I'm not sure how to handle the detail part of the master/detail view. Partial views?
|
# ? Feb 6, 2013 23:49 |
|
How would you guys handle this: Say you want to copy an object. When you first write the method/whatever to make the copy, you decide for each property/field/whatever if you want to either copy the property/... or ignore it. So hooray. Then later you add another property to the class, and you forget to handle the extra property in the copy method. This is bad because you may want it copied and then your users will panic and hell will open and swallow you whole. So, any fool-proof and simple way to ensure that you never forget to either copy new fields, or explicitly not copy them? Preferably with some kind of unit test failing. I just can't think of a reasonable method to handle this.
|
# ? Feb 7, 2013 00:08 |
|
uXs posted:How would you guys handle this: I'd probably go with attributes. You can still forget to decorate the property with the attribute, but at least you're doing it right at the property level, not buried somewhere else in the code.
|
# ? Feb 7, 2013 00:16 |
|
You could use a DoNotCopy attribute and reflection to iterate over the properties and fields of the object and copy any that don't have the attribute. Then you get the opt-out behavior you're asking for.
|
# ? Feb 7, 2013 00:29 |
|
Ithaqua posted:Partial views? I can get editable partial views going with just text boxes, but how would you deal with anything more complex, like parent-child drop downs, calculated fields etc?
|
# ? Feb 7, 2013 01:33 |
|
mortarr posted:I can get editable partial views going with just text boxes, but how would you deal with anything more complex, like parent-child drop downs, calculated fields etc? jQuery and Ajax. At least that's how I do it
|
# ? Feb 7, 2013 02:07 |
|
uXs posted:How would you guys handle this: It will try to map every matching field, can warn you on missing/mismatched fields (in a unit test AssertConfigurationIsValid), can either ignore fields by attribute or fluently when configuring.
|
# ? Feb 7, 2013 04:59 |
|
aBagorn posted:jQuery and Ajax. Yes this. Create a new Action you call through the Ajax, so you can still handle all the logic server side in your Controller. Your new Action can return the data you need in whatever format you want it (full HTML, Json, etc.).
|
# ? Feb 7, 2013 08:22 |
|
I'm struggling a bit with modularity and reusable code using Entity Framework. I have some slightly complex logic to determine sales for a user, something like this (simplified, but enough to go on):code:
code:
Is there something I can do to my original query to make it reusable within other queries like this? Of course I could just call one query to get the user by region, then another to get the volume, but I want to avoid some situations where I'd end up with a ton of calls to the db if I need to get the volume for a lot of users.
|
# ? Feb 8, 2013 16:04 |
|
Dromio posted:I'm struggling a bit with modularity and reusable code using Entity Framework. I have some slightly complex logic to determine sales for a user, something like this (simplified, but enough to go on): Look in to deferred execution, C# actually only executes your queries when you enumerate them etc. So keeping stuff as an IQueryable as long as possible means that it will reflect changes deeper down. This is what makes EF angry at you "this method cannot be translated into a store expression".
|
# ? Feb 8, 2013 16:32 |
|
zokie posted:Look in to deferred execution, C# actually only executes your queries when you enumerate them etc. So keeping stuff as an IQueryable as long as possible means that it will reflect changes deeper down. This is what makes EF angry at you "this method cannot be translated into a store expression". I changed the GetSalesVolume so it returns IQueryable<int> and have the callers use GetSalesVolume(ID).FirstOrDefault(). But I still end up with the same error, LINQ to Entities does not recognize the method ...
|
# ? Feb 8, 2013 16:45 |
|
Linq does a great job of hiding it, but at the end of the day anything in that linq statement needs to be translatable to SQL and the EF query generator isn't smart enough to use your functions unfortunately -- it has no idea how to translate GetSalesVolume() to sql. So structurally re-use is hard. As for getting past it, IIRC you can register custom methods with your EF ObjectContext. Or you could just inline that and call it a day.
|
# ? Feb 8, 2013 16:57 |
|
wwb posted:As for getting past it, IIRC you can register custom methods with your EF ObjectContext. Or you could just inline that and call it a day. The calculation for volume is more complex than my example and will be used extensively. It'll be a real pain for maintenance if I duplicate it all over the place. I'll look at registering custom methods with the Context. Or I guess I could just move the logic into the DB as a stored proc or func or something that I could join against
|
# ? Feb 8, 2013 17:10 |
|
That isn't a horrible idea honestly, especially if you've got enough abstraction built in that you can work with it in a code / testing level.
|
# ? Feb 8, 2013 18:48 |
|
One solution and one question....... In a vb.net program I'm writing that draws a bunch of charts on bitmaps and displays them in pictureboxes/forms, for some reason one of the fonts I declared (as a regular fontstyle),,,, suddenly goes to bold fontstyle in the middle of the program. ??? What I found messing with it was that if I painted a white fillRectangle over the text area first, then the drawstring command goes back to printing text in regular style....... from them on. I dunno? The font is declared once (as a global) and it works 100% correct in every other instance it is used. I have seen this problem mentioned a few times elsewhere, but the circumstances are different. Some people do not paint the bitmap a base color before applying the text, and I knew about that already. Some people get font weirdness when writing a program on one OS and then running on a different OS, but I am writing & running on the same Win7 PC. ------- The question is about using the vb.net string.split() method. At one point I got the bright idea of using non-key characters (characters that non-techie people would never normally type) and so I randomly chose alt-20 {§} and alt-21 {¶} (some pages refer to these as the 'section' symbol and 'paragraph' symbol). And I found out that split() doesn't work {at all} with alt-21. Or does it? I just assumed that maybe split() won't work with non-printing characters, but there are other reports that it does. Here is someone's account of using the section symbol- http://stackoverflow.com/questions/1879860/most-reliable-split-character When I switched the program to use the ` and ^ symbols instead, it worked perfectly. I was trying to split a file that was written & read in text mode. Is there any restrictions about using non-printing characters in such a file? I casually looked around on the msdn site and could not find any.....
|
# ? Feb 9, 2013 20:53 |
|
edmund745 posted:In a vb.net program I'm writing that draws a bunch of charts on bitmaps and displays them in pictureboxes/forms, for some reason one of the fonts I declared (as a regular fontstyle),,,, suddenly goes to bold fontstyle in the middle of the program. I believe this is almost always due to running out of win32 GDI resources (brushes, pens, fonts, ...) And the solution is to be absolutely iron-clad sure that you're disposing each one as soon as you're done with it. quote:The question is about using the vb.net string.split() method. At one point I got the bright idea of using non-key characters (characters that non-techie people would never normally type) and so I randomly chose alt-20 {§} and alt-21 {¶} (some pages refer to these as the 'section' symbol and 'paragraph' symbol). And I found out that split() doesn't work {at all} with alt-21. Or does it? Sure it does! Works fine. Here's an example: code:
|
# ? Feb 10, 2013 01:45 |
|
ljw1004 posted:I believe this is almost always due to running out of win32 GDI resources (brushes, pens, fonts, ...) And the solution is to be absolutely iron-clad sure that you're disposing each one as soon as you're done with it. (The bitmaps are sometimes used in multiple displays so they are left persistent intentionally--but there is only a few in use, referred to by specific names) quote:...I think you're more likely having a trouble with text-encoding. The paragraph marker isn't in the "!@#$%^1*()*+,-./0...9...A...a...z{|}~" range of standardised ascii. So if you have a non-unicode text document and load it in, it's hard to predict what the paragraph-mark will come back as.
|
# ? Feb 10, 2013 04:49 |
|
edmund745 posted:I do all the graphics stuff in using,,, end using statements. Do the pens and brushes still need to be disposed? I had read that they didn't. Where did you read that? Pens and brushes are still GDI objects, so if you're creating new ones all the time and not cleaning them up then that will cause you to hit the handle limit.
|
# ? Feb 10, 2013 15:19 |
|
edmund745 posted:I dunno. The file in question is one used by the program, and it is written and read in text-mode. :| Written and read in text-UTF8? text-UTF16? Some text-ASCII encoding? If so which codepage? Just saying "text mode" isn't enough! I reckon if you change every single file-open and file-close to explicitly say UTF8, it could work. Also be sure that the way you express ¶ is the same in all cases. You can either write the symbol straight into your code (VS has a unicode text-editor), or you can call it Chr(182).
|
# ? Feb 10, 2013 19:22 |
|
Jabor posted:Where did you read that? Pens and brushes are still GDI objects, so if you're creating new ones all the time and not cleaning them up then that will cause you to hit the handle limit. http://www.dreamincode.net/forums/topic/265854-dispose-method-in-using-statement/ Does msdn say either way? I could not find where either topic mentions the other. ljw1004 posted:Written and read in text-UTF8? text-UTF16? Some text-ASCII encoding? If so which codepage? Just saying "text mode" isn't enough! Now I am looking and can't find what encoding it uses by default.... ?
|
# ? Feb 11, 2013 17:57 |
|
edmund745 posted:It is my understanding that normally graphics objects are persistent and need to be disposed--(that is the reason for the dispose method being there)--but the using/end using statement also automatically disposes of anything declared inside it. It will try to detect the encoding of the file based on the presence of a BOM (byte order mark), which usually won't work. If it can't find a BOM it will fall back to UTF8. Here's the actual code (abridged): C# code:
|
# ? Feb 11, 2013 18:23 |
|
edmund745 posted:It is my understanding that normally graphics objects are persistent and need to be disposed--(that is the reason for the dispose method being there)--but the using/end using statement also automatically disposes of anything declared inside it. Not quite. The using block is equivalent to a try/finally block. So, doing this: code:
code:
code:
Fixed my try/finally New Yorp New Yorp fucked around with this message at 18:31 on Feb 11, 2013 |
# ? Feb 11, 2013 18:27 |
|
So I'm making an MVC website (still), and part of that was changing the Handler Mappings so the path for PageHandlerFactory was "*". That's fine, it worked. I just noticed today though that all my CSS was blowing up, and after initially blaming the pathing I finally went to view one of the images directly and got a Failed to Execute URL error. I figured out that the "*" pathing for PageHandlerFactory has basically told the server to treat anything I haven't given it specific pathing rules for as a webpage. If I change the StaticFile path to "*" my images start working again; unfortunately this blows up the website, because now it's treating website/FolderName as a static file instead of trying to get the view that belongs to FolderName. Do I seriously have to make a new handler for every single extension of every type of static file I want to use? This problem is nowhere on Google and I am not exactly the first person to use MVC, which leaves me with the sneaking suspicion I've screwed up somewhere.
|
# ? Feb 11, 2013 21:35 |
|
CapnAndy posted:Do I seriously have to make a new handler for every single extension of every type of static file I want to use? This problem is nowhere on Google and I am not exactly the first person to use MVC, which leaves me with the sneaking suspicion I've screwed up somewhere. Check out this MSDN article. Try setting your runallmodulesblahblah true (read up on why this is not a great idea though and see if it applies to your circumstances).
|
# ? Feb 11, 2013 21:55 |
|
^^^ that is a good start. It really sounds like something got buggered, I've never had to futz with the handler mappings from the default templates except when I was doing upgrades from MVC versions to different versions or I mucked something up. If your app / site isn't too complex, I'd consider doing new project and then carefully re-adding your code, avoiding paving over the config files while you are at it.
|
# ? Feb 11, 2013 22:08 |
|
wwb posted:^^^ that is a good start. I'd also add that if you're doing MVC4, look into using bundles for your CSS/JS. It makes life a lot easier and handles minification for you.
|
# ? Feb 11, 2013 22:31 |
|
wwb posted:It really sounds like something got buggered, I've never had to futz with the handler mappings from the default templates except when I was doing upgrades from MVC versions to different versions or I mucked something up.
|
# ? Feb 11, 2013 22:55 |
|
|
# ? May 13, 2024 21:51 |
|
CapnAndy posted:Really? So, like, servername.com/ControlName works for you without changing any mappings, or do you go to ControlName/Index.aspx? Because I've never made the former work without changing handler mappings. The former is how it's always worked out of the box for me.
|
# ? Feb 11, 2013 23:04 |