|
FinkieMcGee posted:Basically we store each table as a datatable in a big Dictionary. Is this reasonable at all? I'm noticing a huge performance difference between going to our cached table, and going to the database for the same information. Going to the cache takes TWICE as long as going to the database! Moral of the Post: I'd use the ASP.NET caching instead of your all-in-one Dictionary and I'd use the cache where necessary.
|
# ? Mar 18, 2008 16:17 |
|
|
# ? Jun 10, 2024 09:19 |
|
mintskoal posted:There's really no good reason to be storing the tables in the cache. Use straight LINQ or SQL calls. I'm positive you're not under enough load to warrant using caching. I agree, for the time being the application isn't being used enough to justify caching, but we're trying to get it to a point where there are several thousand users hitting it, and it is a pretty database heavy cache. Some of the tables are small, but some of the tables (and the views especially) are really big. The app is database heavy. And don't hit me, I didn't write this crap! It's persisted as a static dictionary across the application, I may just switch it over to the ASP caching (no one here really has a lot of experience with caching, I maybe have the most and I'm a rookie) so I need to put together a case to modify it before I start touching that stuff.
|
# ? Mar 18, 2008 19:37 |
|
FinkieMcGee posted:C#/ASP.NET Caching question, as I'm a rookie and I'm trying to understand what the hell is going on. The way I used caching in this app I made is the following: everything (*) I read from the database is put in custom objects and generic lists of those objects. They got bound to dropdownlists and what have you with objectdatasources. Now for some dropdownlists that I needed a lot, I created a cache object that had functions to retrieve the lists from the cache (or retrieved them from the database and put them in the cache first if it didn't exist yet or was expired.) So where normally it would ask some class to retrieve a list from the database, for those lists it would ask my cache class to retrieve the list from the cache. I don't really know if that improved performance really, but it was a neat thing to do Now I'm not really clear on how you're doing it. You're storing each table as a table in a Dictionary, but then what do you do with that Dictionary ? Are you putting that in the cache and retrieving it all the time ? (*: There were, naturally, exceptions on this.) Edit: ^^ Wait. That Dictionary is just in some static class ? I'm not 100% sure, but I think it's possible that the Dictionary is being recreated for every single call to the webserver. I doubt that it's persisted through postbacks, let alone sessions. uXs fucked around with this message at 00:19 on Mar 19, 2008 |
# ? Mar 18, 2008 23:46 |
|
Just so you guys know, I'm noticing a big speed difference between doing Datatable selects (like we were doing) and using FindAll/Find in a generic list. My old company did the objects stored in a cache, but no one here is familiar with caching, so it's a work in progress. Thanks for the advice.
|
# ? Mar 19, 2008 20:43 |
|
More questions. I wish I wasn't the only C# guy here at work. Sorry dudes. If you don't know off the top of your head don't go out of your way, I've been Googlin' for a while.code:
Is this a server config issue, or am I doing it wrong?
|
# ? Mar 19, 2008 23:00 |
|
Looking at the MSDN page for IfModifiedSince, this comment was at the bottom, maybe this is ties into your problem?quote:These samples are fundamentally wrong. They're been written with the premise that IfModifiedSince on a web request is somehow the modification date of the file on the server. It isn't -- the request hasn't even been sent to the server yet.
|
# ? Mar 20, 2008 00:35 |
|
I have a dropdown list and a listbox in an ASP app. At runtime, I want the user to be able select several names from the dropdown list and move them into the listbox. When the user has finished filling out the form, I want their selections to be submitted back to the DB and be recorded. Here is my problem - the names are stored in the DB via their "NameID", which is the same as the value attribute in the dropdownlist (<option value=1... <option value=2... etc). When the user dumps the names into the listbox, these ID values are lost - there are ways I can get them back but not without a wimpy hack. What's the best/most correct/righteous/efficient way to preserve this value between controls in ASP.NET?
|
# ? Mar 20, 2008 01:28 |
|
These days, you should probably be handling that fully client-side with ajax. But, from a .NET perspective, both DropDownLists and ListBoxes implement IListControl, so you could actually pass the list items between the two pretty easily. What you need to do is: 1) Grab the selected value from the DDL. 2) Find the appropriate list item that matches said selected value. 3) Remove it from DDL's Items collection 4) Add it to LB's Items collection 5) gently caress a duck 6) Profit.
|
# ? Mar 20, 2008 01:44 |
|
Is there a way to get the names of the files contained in an IIS-hosted web site's browseable directory? I would create a web service to do it if I had access, but I don't. Edit: Figured it out. Now to re-learn regular expressions. No Pants fucked around with this message at 16:49 on Mar 20, 2008 |
# ? Mar 20, 2008 02:16 |
|
Does anyone know of a way to populate a DataGridView with data from an excel file using C#. I can do it in VB but I am just learning C# and seem to be hung up somewhere on syntax.
|
# ? Mar 20, 2008 04:05 |
|
Lone_Strider posted:Looking at the MSDN page for IfModifiedSince, this comment was at the bottom, maybe this is ties into your problem? Unfortunately not. I noticed the example was wrong, they were using compare on a datetime and ifmodifiedsince, which is really weird, because obviously how would the class know what the mod date is before it makes a request. Is-Modified-Since is an HTTP header that makes a server respond with a specific code if the file has not been changed since the If-Modified-Since date. It's so you don't have to download the whole file just to check for an updated version. For some reason, the header is being ignored in my case. The webserver is just a default Apache install and I'm pretty sure it supports the header, it's in HTTP/1.1 specs.
|
# ? Mar 20, 2008 04:55 |
|
Pivo posted:Unfortunately not. I noticed the example was wrong, they were using compare on a datetime and ifmodifiedsince, which is really weird, because obviously how would the class know what the mod date is before it makes a request. I'm pretty sure it's the server. When I run your code against an image on my IIS site, GetResponse() throws a WebException -- "The remote server returned an error: (304) Not Modified." But if I run it against my apache2 server at home, it does not. Dromio fucked around with this message at 14:41 on Mar 20, 2008 |
# ? Mar 20, 2008 14:29 |
|
Dromio posted:I'm pretty sure it's the server. When I run your code against an image on my IIS site, GetResponse() throws a WebException -- "The remote server returned an error: (304) Not Modified." But if I run it against my apache2 server at home, it does not. Bizzzzzzaaare. Thank you!
|
# ? Mar 20, 2008 15:18 |
|
wwb posted:These days, you should probably be handling that fully client-side with ajax. But, from a .NET perspective, both DropDownLists and ListBoxes implement IListControl, so you could actually pass the list items between the two pretty easily. What you need to do is: Thank you, I was trying to do this with ListItem and thought that I had done so - it turns out I was doing .add(blahitem.toString()) and that of course will not achieve what I want.
|
# ? Mar 20, 2008 18:45 |
|
C# + .NET 3.5 I'm having some conundrums with regular expressions in my app. I have a string containing essentially the following: "lots of text and newline characters 2008-03-20 849.63 MB 7.71 GB 8.54 GB 2008-03-19 896.02 MB 4.44 GB 5.31 GB 2008-03-18 668.67 MB 1.28 GB 1.93 GB 2008-03-17 212.83 MB 16.35 MB 229.18 MB 2008-03-16 5.66 GB 8.49 GB 14.15 GB 2008-03-15 361.12 MB 2.39 GB 2.75 GB 2008-03-14 936.02 MB 2.38 GB 3.30 GB some more text and newline characters" (The above are internet transfer stats from my ISP, date + in + out + total) By using: @"(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])" and @"([0-9]{1,3}\.[0-9]{2}\s(MB|GB))" ...I can match for example "2008-03-19" and "896.02 MB" respectively, but for the life of me I can't match "2008-03-19 896.02 MB". Ultimately I would like to match each date together with the corresponding 3 transfer amounts, resulting in strings "2008-03-19 896.02 MB 4.44 GB 5.31 GB", "2008-03-18 668.67 MB 1.28 GB 1.93 GB" etc. Any help on how I can combine the two working expressions? I've readin every regex resource I can find but I just can't work it notflipmo fucked around with this message at 01:53 on Mar 21, 2008 |
# ? Mar 21, 2008 01:49 |
|
code:
|
# ? Mar 21, 2008 02:12 |
|
FrantzX posted:
|
# ? Mar 21, 2008 02:13 |
|
notflipmo posted:Ultimately I would like to match each date together with the corresponding 3 transfer amounts, resulting in strings "2008-03-19 896.02 MB 4.44 GB 5.31 GB", "2008-03-18 668.67 MB 1.28 GB 1.93 GB" etc. when ran against your sample above, it returned code:
Potassium Problems fucked around with this message at 02:56 on Mar 21, 2008 |
# ? Mar 21, 2008 02:53 |
|
Oh wow, thanks guys. Figured out my problem, original string has two whitespace characters between each date and transfer amount. Your suggestions and the way HTML ignores multiple whitespaces when I posted it to the forums provided me with an early morning epiphany. Final regex is as follows: (19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])(\s\s[0-9]{1,3}\.[0-9]{2}\s(MB|GB)){3} ..which matches everything like a champ. notflipmo fucked around with this message at 12:07 on Mar 21, 2008 |
# ? Mar 21, 2008 12:04 |
|
I feel retarded asking this, but I can't find a way to google it to get a good answer. In visual studio 2005, how do you get the property description in the properties box to show up when it is gone? I have tried dragging up from the bottom of the properties box, but I can't get the descriptions to show up. It's a very simple problem, but it's kinda bothering me. Edit: Looks like it was just one of those dumb things visual studio does. Restarting the program got it back. I guess I should shut up and reboot before asking stupid questiongs. DemiShadow fucked around with this message at 12:26 on Mar 21, 2008 |
# ? Mar 21, 2008 12:21 |
|
DemiShadow posted:I feel retarded asking this, but I can't find a way to google it to get a good answer.
|
# ? Mar 21, 2008 12:39 |
|
Anyone see what I'm doing wrong with log4net in my ASP.NET project? I've got three loggers defined in the web.config:code:
code:
Edit: Doh, I'm using dbgview from sysinternals and it was set to filter everything but the Service and Code loggers. That's a stupid mistake, right there. Dromio fucked around with this message at 16:21 on Mar 21, 2008 |
# ? Mar 21, 2008 15:56 |
|
Anyone know any open source game libraries? I need something like a checkers/chess/othello grid to prototype something for a friend and want to avoid the trouble of writing one from scratch if possible. Was just going to do a C# form app since I can probably whip that together most quickly.
|
# ? Mar 21, 2008 21:17 |
|
Hey, another newbie C# question here I made a method called CardGen() CardGen() basically just generates a random number (with some limitations, shouldn't be necessary to state) then, in my Main() I do something like: Program p = new Program() if (x=6) { p.CardGen() p.CardGen() } I'm trying to generate a different random number twice, but the problem is it seems to generate the same number both times. I can't really find a solution online since I don't know what to ask, any help would be appreciated, thanks.
|
# ? Mar 22, 2008 01:00 |
|
LetoAtreides posted:Hey, another newbie C# question here Also, when you do, use the [ code ] [ /code ] tags so that things like spacing and indentation work right.
|
# ? Mar 22, 2008 01:13 |
|
alright, here it is. Thing is, if I put cardgen() once outside the main method and then once inside the main method, it'll output two different cardscode:
|
# ? Mar 22, 2008 02:42 |
|
A simple/quick/easy/dirty solution to your issue is putting a call to System.Threading.Thread.Sleep between your calls to the CardGen() method. I'm not 100% positive how the Random class generates its numbers, but like most random number generators it's based in part of the current system time. You can also pass an integer to the constructor for the Random class that will act as a seed for the random number generator. Passing random values to the constructor on each call will give you different output. Using the code you posted (with some additions to make it run)... code:
code:
Horse Cock Johnson fucked around with this message at 03:11 on Mar 22, 2008 |
# ? Mar 22, 2008 03:07 |
|
nice, I just tried it and it works great Good to know that its not some weird flaw in my code. Guess their random number generator is system timed based. Thanks for the help
|
# ? Mar 22, 2008 05:37 |
|
You could also use a static Random object, so you don't have to needlessly burden yourself with adding Sleeps between every call to your card generator.
|
# ? Mar 22, 2008 07:06 |
|
Oh Christ, please don't use a Thread.Sleep to seed your random numbers.
|
# ? Mar 22, 2008 09:24 |
|
LetoAtreides posted:alright, here it is. Thing is, if I put cardgen() once outside the main method and then once inside the main method, it'll output two different cards I think the problem is that you're making a new Random object each time you call your method. If you make 2 of them at practically the same instant, you can get the same "random" value. The following would probably work better: code:
code:
Code not tested in any way. Also I don't know how thread-safe this is, but I don't think you care.
|
# ? Mar 22, 2008 12:55 |
|
I like to use System.Security.Cryptography for my random numbers.code:
tk fucked around with this message at 15:05 on Mar 22, 2008 |
# ? Mar 22, 2008 14:00 |
|
Mr. Herlihy posted:A simple/quick/easy/dirty solution to your issue is putting a call to System.Threading.Thread.Sleep between your calls to the CardGen() method. Really? Leto, to learn more about this, look up the concept of "seeding" a random number generator. Basically, RNGs are actually random sequence generator, and that sequence is dependent on the "seed" that you create the Random object with. The same seed causes the same sequence. If you use the Random(int) constructor, you can use your own seed value, but Random() with no parameters uses the system time, and you were creating two new Random objects fast enough that they generated the same sequence. The correct solution in this situation is to use one Random() object for each "shuffle" of the deck. Also, get those Deck and Card array creations the hell out of the method. They will never ever change from call to call, and should be in a higher scope so you don't have to keep creating them over and over.
|
# ? Mar 22, 2008 15:03 |
|
I've never really understood databinding. Maybe someone can help. Right now I'm trying to whip up a quick one-page webapp that displays log lists. I've got a class for the log messages like this: code:
code:
code:
Any idea what I'm doing wrong?
|
# ? Mar 23, 2008 03:02 |
|
Dromio posted:But when I DataBind() I get an exception-- "A field or property with the name 'Message' was not found on the selected data source." I don't know about ASP, but at least in WPF only properties can be databound, not class members. code:
|
# ? Mar 23, 2008 06:16 |
|
thanks for the replies above, I'm reading more and trying out your suggestions now.
|
# ? Mar 23, 2008 06:34 |
|
csammis posted:I don't know about ASP, but at least in WPF only properties can be databound, not class members. That's the critical fact I've been missing. Thank you very much!
|
# ? Mar 23, 2008 14:54 |
|
I'm trying to synchronise 250+ grid's columns, using the SharedSizeGroup property of the columns and I'm running into performance and layout problems. Each grid is only 1 row with 2 columns and lives inside a ListBox. As you've probably guessed by now I'm doing this simply so I can have columns inside a ListBox. I imagine the code that gets generated (from DataTemplates and bindings and all sorts of things) looks something like this: code:
1) Is there a better way to do this? 2) Is it possible to calculate the maximum width needed by the left column, set it for the all of the grids, then lock this value in?
|
# ? Mar 24, 2008 14:13 |
|
C# + .NET 3.5 Learn me some XML please config.xml: code:
and saves the limit and interval values to ints, and the process values to any suitable storeage class, most likely a string array since I don't expect more than a few process entries. I figured it would be fun to use an XML configuration file in this project just to have used .NETs mechanisms for XML. But amongst XmlDocuments, XmlReaders, XmlElements, XmlNodes, my brain seems to have melted and I can't seem to grasp it. I now feel exceedingly dense, after googling all day long and understanding very little code:
Beyond this, I haven't been able to make any sense of it all...
|
# ? Mar 24, 2008 20:14 |
|
|
# ? Jun 10, 2024 09:19 |
|
code:
Basically, the SelectSingleNode method will be your friend. Read up on XPath to learn how to select nodes from the document.
|
# ? Mar 24, 2008 20:25 |