Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Destroyenator
Dec 27, 2004

Don't ask me lady, I live in beer

Milotic posted:

I dunno if this thread is for sharing as well as asking, but am I the only who tends to not bother using mock frameworks? In my unit test libraries for non-MVVM apps I just tend to just do the following:

C# code:

internal class MockFooProvider : IFooProvider {

public MockFooProvider(Func<List<IFoo>> simpleFunc) {
	SimpleFunc = simpleFunc;
}

public MockFooProvider(Func<T1,T2,..,TN,List<IFoo>> fooFunc) {
	FooFunc = fooFunc;
}

private readonly Func<List<IFoo>> SimpleFunc;

private readonly Func<T1,T2,...,TN,List<IFoo>> FooFun;

public void GetFoos(T1 a, ..., TN n) {
	if (FooFunc != null)
		return FooFunc(a,..,n);
	else
		return SimpleFunc();
}

}

I've only started this approach relatively recently, but I've found it works well when an interface only has one method. It means you can whack any old thing in there. The SimpleFunc constructor overload is just for convenience.

Do most of you guys just use Moq?
I usually use NSubstitute. There's not a huge difference but it's less code to maintain and one less things that turns up when you find all implementations with resharper or whatever.
C# code:
var provider = Substitute.For<IFooProvider>();
provider.GetFoos(1, 2, Arg.Any<string>()).Returns(new FooList());

var result = new ItemUnderTest(provider).Action();

provider.Received(1).MethodCallOnFooProvidier("print", 14);
// Asserts on result...

Adbot
ADBOT LOVES YOU

wwb
Aug 17, 2004

I typically use hand-built test doubles. If they become too painful you are probably making things too internally complex and/or have too many environmental dependencies.

I also find myself doing alot more VEST style testing than traditional unit testing. See http://codebetter.com/sebastienlambla/2013/07/11/unit-testing-is-out-vertical-slice-testing-is-in/ for a description of what VEST is.

RICHUNCLEPENNYBAGS
Dec 21, 2010
I asked this question in the Excel thread, but maybe it would be better here. Is there a book or resource you folks recommend for VSTO? I'm not starting from zero because I have spent a fair amount of time with VBA so I have some appreciation for the Word/Excel object models but I'd like to be able to make real add-ins.

thezoidburg
Dec 26, 2005

RICHUNCLEPENNYBAGS posted:

I asked this question in the Excel thread, but maybe it would be better here. Is there a book or resource you folks recommend for VSTO? I'm not starting from zero because I have spent a fair amount of time with VBA so I have some appreciation for the Word/Excel object models but I'd like to be able to make real add-ins.

You may know this already, but since its the .Net thread, don't forget you can write add-ins in JavaScript and HTML now so they can run on both local office and web versions. I don't know exactly what platforms these add-ins can target however (new ipad apps too?)

wwb
Aug 17, 2004

Probably not the iPad app -- apple bans internal scripting. You could use a UIWebView and run the app as a HTML5 thing but that is pretty intentionally hamstrung and probably not what MSFT is doing.

Sab669
Sep 24, 2009

Is there an easy way to change what type of control something is? Have a form with about 30 textboxes on it, need to change them to a different textbox subclass we have. I started to just go through the Designer and change the code there, but even that is time consuming :(

crashdome
Jun 28, 2011
Find/Replace the type if it has all the same properties.

Sab669
Sep 24, 2009

Yea I just went through and ctrl-F, type in part of the control name and changed what it was. I wasn't sure if there was a way to do it through the property grid on the form design view or something though :saddowns:

RICHUNCLEPENNYBAGS
Dec 21, 2010

thezoidburg posted:

You may know this already, but since its the .Net thread, don't forget you can write add-ins in JavaScript and HTML now so they can run on both local office and web versions. I don't know exactly what platforms these add-ins can target however (new ipad apps too?)

I'm aware of this, but from the sound of it it's way more limited than VBA (except that you can talk to Web services, which is cool I guess but I don't know what I'd do with that).

Stobbit
Mar 9, 2006
Does anyone know how I can get a WPF TextBox which shows an input mask for a Regular Expression mask?

I've found plenty of controls online, all of which only support a simpler form of masking - but I need to be able to use RegEx.

For example, if the mask is ">[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}" (an IP address with port), I want to be able to show the watermark "_._._._:_" in the textbox.

However, most masked textboxes will only allow a fixed number of characters, so for example, I would only be able to type "1.2.3.4:5" in the box, but not "127.0.0.1:88" (because the first octet and port both have more than 1 digit).

I need to be able to type the following (the insertion point is represented by "|"):
_._._._:_
1|_._._._:_ (pressed 1)
12|_._._._:_ (pressed 2)
12.|_._._:_ (pressed .)
12.3|_._._:_ (pressed 3)
12.34|_._._:_ (pressed 4)
12.345.|_._:_ (pressed 5)
... and so on.

Failing a full-blown control, is there any way that I can produce a hint string (e.g. "_._._._:_") from a RegEx pattern?

Gul Banana
Nov 28, 2003

sure: just use a regex on your regex.

ninjeff
Jan 19, 2004

Gul Banana posted:

sure: just use a regex on your regex.

now you have 24 problems

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Stobbit posted:

Does anyone know how I can get a WPF TextBox which shows an input mask for a Regular Expression mask?

I've found plenty of controls online, all of which only support a simpler form of masking - but I need to be able to use RegEx.

For example, if the mask is ">[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\:[0-9]{1,5}" (an IP address with port), I want to be able to show the watermark "_._._._:_" in the textbox.

However, most masked textboxes will only allow a fixed number of characters, so for example, I would only be able to type "1.2.3.4:5" in the box, but not "127.0.0.1:88" (because the first octet and port both have more than 1 digit).

I need to be able to type the following (the insertion point is represented by "|"):
_._._._:_
1|_._._._:_ (pressed 1)
12|_._._._:_ (pressed 2)
12.|_._._:_ (pressed .)
12.3|_._._:_ (pressed 3)
12.34|_._._:_ (pressed 4)
12.345.|_._:_ (pressed 5)
... and so on.

Failing a full-blown control, is there any way that I can produce a hint string (e.g. "_._._._:_") from a RegEx pattern?

Sounds like you want to set a validator for a given box and then have the "hint" be automatically generated based on that regex. That seems overcomplicated. Set a regex validator, set a "hint" manually, and get on with coding more important stuff. You probably could find a way to do what you want, but the time you'd spend setting "hints" manually is probably a tiny fraction of the time it would take you to find a solution, and I can't imagine it would degrade maintainability that much.

Essential
Aug 14, 2003
I'm getting ready to do my first asp.net MVC project (and switching from vb.net to c#) and I was wondering for those of you who use Entity Framework with MVC do you prefer the Database First or Code First approach? The database is already created.

I've used the Database First approach in Silverlight applications, but the tutorial I'm going through right now is using the Code First approach. I honestly don't know if one way is better or more preferrable to the other. The Database First approach has been a great experience for me so far, but if there is some advantage to Code First then I don't have a problem with that.

edit: After a digging a little deeper, the db first approach inherits EntityObject, so they are not persistence ignorant. True POCO objects are (Code First approach). I don't even know what that means though.

Essential fucked around with this message at 16:43 on Jul 25, 2013

wwb
Aug 17, 2004

Go code first. You will feel better about yourself in the morning.

Dromio
Oct 16, 2002
Sleeper
I'm still struggling with occasional hangs in our apppool. I've been examining debug dumps of the process regularly using windbg and sos, and noticed that the finalizerqueue has a VERY large number of com.SomeWebService.ww.MyAPI objects in it -- thousands.

We're using Castle Windsor as our IOC container. I'd extracted an interface from the API (stubMyAPI) and use a factory class to return the proper implementation and setup the endpoint URL so we can change what server it actually hits. Something like this:

code:
public class MyClientFactory
{
  private readonly IMyAPI _clientAPI;
  public MyClientFactory (IMyAPI clientAPI)
  {
    _clientAPI = clientAPI;
  }

  public IMyAPI GetClient()
  {
    _clientAPI.URL = ConfigurationManager.AppSettings["ClientURL"];
    return _clientAPI;
  }
}
Both the factory and the implementation are registered in the IOC container with the "PerWebRequest" lifecycle, meaning they should be automatically released at the end of handling each request.

I call it pretty basically --
code:
using(var client = clientFactory.GetClient())
{
  client.DoStuff();
}
Why am I ending up with thousands of these in the finalizer queue? It shouldn't even be loaded up a thousand times, it's in some code paths that should not be running that often on the site.

Essential
Aug 14, 2003

wwb posted:

Go code first. You will feel better about yourself in the morning.

Perfect, code first it is then. Thanks!

VVVV Good to know, thanks! VVVVV

Essential fucked around with this message at 21:15 on Jul 25, 2013

AWWNAW
Dec 30, 2008

You can do POCO entities with DbContext with an existing database schema. You just add a code generation thing to your EDMX model.

PhonyMcRingRing
Jun 6, 2002
Does anyone know of a way to unit test MVC4 bundles? I'd like to make a unit test to ensure that all the style bundles compile correctly as I'm using a dotLess transformer on all of them.

My main problem is getting the bundles to read in the files. The articles I've been reading keep mentioning to use BundleTable.MapPathMethod as a way of overriding the VirtualPathProvider functionality, but I'm not even seeing that method anywhere.

Edit: Nevermind, looks like they removed MapPathMethod entirely. Annoying, I really didn't wanna have to implement a VirtualPathProvider just for this.

PhonyMcRingRing fucked around with this message at 16:37 on Jul 26, 2013

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I have a working prototype of a personal project I was talking about earlier and I got it up on App Harbor!

I have a specific app harbor question:
If I go to the application hart.apphb.com, it tries to connect to localhost.
But if I append index.htm, it works:
http://hart.apphb.com/index.htm
Edit: I did add a default document to my webconfig but still have the same problem.

And a non specific question:
If I change the values and hit submit again, the service stack service returns the first result regardless of what I change the input values to. I have to refresh the page and start from scratch to get the proper results.

What am I doing wrong?

Uziel fucked around with this message at 19:28 on Jul 26, 2013

Sab669
Sep 24, 2009

So, some random component in a project no one has touched in months just randomly stopped working. Went into the code for the solution to look at the Test application to see what's up but for some reason this project won't work.

1 Solution, 2 projects-- 1 class library, 1 application. The application has a reference to the project, and has the proper using reference on the form that's trying to interact with it. But as soon as I build the application it suddenly says The type or namesspace could not be found. What the gently caress? I tried completely removing the test application, re-adding it, and remaking a new one entirely. Tried making a completely seperate solution, adding the DLL and trying it... same result.


Our actual software that uses this library just randomly started throwing a RasterException saying there's something wrong with how our license is set.... Is it possible the company changed something with their licensing activations? I can't imagine this requires some sort of online authentication that could've changed. And even if it did, what the gently caress is going out with our unbuildable test apps :psyduck:

e; I feel like I'm explaining it very poorly. Here's 2 screenshots of this new test application I built to see what's up.

Screenshot 1, I just added the reference to the DLL and it looks fine.
Screenshot 2, I tried to build the project and suddenly it goes "I dunno what the gently caress those files are, dude".

http://imgur.com/a/nChnS

Sab669 fucked around with this message at 21:40 on Jul 26, 2013

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug

Sab669 posted:

So, some random component in a project no one has touched in months just randomly stopped working. Went into the code for the solution to look at the Test application to see what's up but for some reason this project won't work.

1 Solution, 2 projects-- 1 class library, 1 application. The application has a reference to the project, and has the proper using reference on the form that's trying to interact with it. But as soon as I build the application it suddenly says The type or namesspace could not be found. What the gently caress? I tried completely removing the test application, re-adding it, and remaking a new one entirely. Tried making a completely seperate solution, adding the DLL and trying it... same result.


Our actual software that uses this library just randomly started throwing a RasterException saying there's something wrong with how our license is set.... Is it possible the company changed something with their licensing activations? I can't imagine this requires some sort of online authentication that could've changed. And even if it did, what the gently caress is going out with our unbuildable test apps :psyduck:

e; I feel like I'm explaining it very poorly. Here's 2 screenshots of this new test application I built to see what's up.

Screenshot 1, I just added the reference to the DLL and it looks fine.
Screenshot 2, I tried to build the project and suddenly it goes "I dunno what the gently caress those files are, dude".

http://imgur.com/a/nChnS

Ah yes, Leadtools. Leadtools is a real pain in the rear end to get working. You're probably missing a dependent assembly reference which is causing it to not build.

AWWNAW
Dec 30, 2008

Lead tools? Good luck! I'd highly recommend looking for another third party library that meets your needs.

I recently figured out a lot of their stream based PDF operations use temporary disk files under the covers. I was wondering why their performance sucked rear end so I decompiled their libraries and voilà. That's pretty intellectually dishonest to offer a stream API that just uses temporary files behind the scenes. Not to mention all the other insane problems I've had with their other libraries.

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Dromio posted:

I'm still struggling with occasional hangs in our apppool. I've been examining debug dumps of the process regularly using windbg and sos, and noticed that the finalizerqueue has a VERY large number of com.SomeWebService.ww.MyAPI objects in it -- thousands.

We're using Castle Windsor as our IOC container. I'd extracted an interface from the API (stubMyAPI) and use a factory class to return the proper implementation and setup the endpoint URL so we can change what server it actually hits. Something like this:

code:
public class MyClientFactory
{
  private readonly IMyAPI _clientAPI;
  public MyClientFactory (IMyAPI clientAPI)
  {
    _clientAPI = clientAPI;
  }

  public IMyAPI GetClient()
  {
    _clientAPI.URL = ConfigurationManager.AppSettings["ClientURL"];
    return _clientAPI;
  }
}
Both the factory and the implementation are registered in the IOC container with the "PerWebRequest" lifecycle, meaning they should be automatically released at the end of handling each request.

I call it pretty basically --
code:
using(var client = clientFactory.GetClient())
{
  client.DoStuff();
}
Why am I ending up with thousands of these in the finalizer queue? It shouldn't even be loaded up a thousand times, it's in some code paths that should not be running that often on the site.

Simple question: is your implementation calling suppress finalize when disposed? Not a lot of information to go on here.

Dromio
Oct 16, 2002
Sleeper

quote:

Simple question: is your implementation calling suppress finalize when disposed? Not a lot of information to go on here.

The implementation was pretty much straight from vs.net's add service reference wizard. I just put in the URL of the service and it generated the class. Then I extracted an interface from it and built the factory stuff. My factory isn't IDisposable and I don't think it needs to be.

Funking Giblet
Jun 28, 2004

Jiglightful!

Dromio posted:

I'm still struggling with occasional hangs in our apppool. I've been examining debug dumps of the process regularly using windbg and sos, and noticed that the finalizerqueue has a VERY large number of com.SomeWebService.ww.MyAPI objects in it -- thousands.

We're using Castle Windsor as our IOC container. I'd extracted an interface from the API (stubMyAPI) and use a factory class to return the proper implementation and setup the endpoint URL so we can change what server it actually hits. Something like this:

code:
public class MyClientFactory
{
  private readonly IMyAPI _clientAPI;
  public MyClientFactory (IMyAPI clientAPI)
  {
    _clientAPI = clientAPI;
  }

  public IMyAPI GetClient()
  {
    _clientAPI.URL = ConfigurationManager.AppSettings["ClientURL"];
    return _clientAPI;
  }
}
Both the factory and the implementation are registered in the IOC container with the "PerWebRequest" lifecycle, meaning they should be automatically released at the end of handling each request.

I call it pretty basically --
code:
using(var client = clientFactory.GetClient())
{
  client.DoStuff();
}
Why am I ending up with thousands of these in the finalizer queue? It shouldn't even be loaded up a thousand times, it's in some code paths that should not be running that often on the site.

Any reason why the factory is per request over singleton? Usually factories are expensive to build and shouldn't really have transitive dependencies.

Dietrich
Sep 11, 2001

Per web request means that when you request another one in the context of a web request that you will get the same one that was instantiated earlier, it doesn't always mean that the object will be released automatically when the request is finished... You should be releasing your objects manually.

Funking Giblet
Jun 28, 2004

Jiglightful!
You can latch onto the global asax Application_EndRequest or use a HttpModule to handle this, it really depends on what Dispose does though. NHibernates ISession really needs a handler for per session requests, as dispose needs to ensure flush and close are called, and I recall that it doesn't.

Dromio
Oct 16, 2002
Sleeper
It doesn't even implement it's own Dispose() method... It's inherited from SoapHttpClientProtocol, which inherits from HttpWebClientProtocol, which ineherits from WebClientProtocol, which inherits from System.ComponentModel.Component, which has a DIspose() method. Really, it's just boilerplate code built by vs.net when you right click References, and choose Add Service Reference. I'm not doing anything special with the API class itself other than extracting the interface from it.

quote:

Per web request means that when you request another one in the context of a web request that you will get the same one that was instantiated earlier, it doesn't always mean that the object will be released automatically when the request is finished... You should be releasing your objects manually.

I thought this at first too, but Krzysztof's blog seems to indicate this isn't the case. I think I need to re-read that post a few more times and try to digest all the implications. Maybe a simple factory method like he demonstrates would be a better way to go.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING
I'm fiddling around with c# trying to teach myself and I'm entering into the world of mysql server connections. Previously I'd only used php and mysql both on localhost.

I was a bit concerned about putting mysql connection data (user, password, etc) in the application code itself, and google suggested I try a service layer on my webserver to grab standard non-SQL commands, interpret them for the mysql DB, execute, and return results to the external c# client.

But I can't find any examples or tutorials of service layers doing similar things. I figured I'd do it in python as it seems easy enough to learn, has a good documentation + support system, and the webserver is running debian so I can't do the service layer in c#.

I'm asking in the .NET thread because I actually have no idea how to even get the c# application to communicate with a service running on an external machine. What do I need to google to learn how to establish a connection, transmit auth data (user/password), receive a confirmation, and then send/receive table data in a form that a python script can interpret, form into SQL, execute, and send back to the c# client?

For reference, I kind of imagine the process as similar to this:

1. User logs in through c# application.
2. Connects to service via a certain port on the debian server, which has a python program listening.
3. Sends an object with details like "Type: LoginAuth, User: blah, HashedPass: blah" (and presumably the IP of the client would be retained server-side).
4. Python converts that into a SQL query based on type, executes query on mysql db using a generic account, and returns results (i.e. 'success' and a session token) as another object.
5. c# client interprets results and acts accordingly.
6. User repeats same process but for different purposes, e.g. creating/updating/retrieving multiple rows, blah blah.

Sulla Faex fucked around with this message at 13:37 on Jul 29, 2013

Dietrich
Sep 11, 2001

Sulla-Marius 88 posted:

I'm fiddling around with c# trying to teach myself and I'm entering into the world of mysql server connections. Previously I'd only used php and mysql both on localhost.

I was a bit concerned about putting mysql connection data (user, password, etc) in the application code itself, and google suggested I try a service layer on my webserver to grab standard non-SQL commands, interpret them for the mysql DB, execute, and return results to the external c# client.

But I can't find any examples or tutorials of service layers doing similar things. I figured I'd do it in python as it seems easy enough to learn, has a good documentation + support system, and the webserver is running debian so I can't do the service layer in c#.

I'm asking in the .NET thread because I actually have no idea how to even get the c# application to communicate with a service running on an external machine. What do I need to google to learn how to establish a connection, transmit auth data (user/password), receive a confirmation, and then send/receive table data in a form that a python script can interpret, form into SQL, execute, and send back to the c# client?

Ok, back up a few.

You're writing a website, or a client application?

Which parts do you want to be in C# versus python?

wwb
Aug 17, 2004

What you probably want to look at in 2013 is the Web API. This will let you make a HTTP-friendly api which python can easily communicate with using requests or whatever other wrapper you wish to use from anything that speaks HTTP.

You probably want to start thinking of things in terms of commands and objects not SQL and tables if you are taking this route.

I'll note that you still have the same security concerns no matter how you are communicating with the database server though having a web service gives you a much better layer to deal with and will also make your app alot more robust as HTTP is far more durable than most database protocols.

EDIT: Ok, I read your question backwards. You'll want something running on python that spits out JSON and then you can use the WebClient to deal with that. Other points generally still stand.

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING


Sorry, I should have made it clearer.

I'm writing a desktop based c# application that will query a mysql database hosted on an external (debian) webserver.

On the C# client, it will have forms to create an account, login, create tables of info, display tables of info, and do stuff with that, but all the information for this is stored on an external webserver. The service layer is on the external server, which handles all interaction with the mysql database. Thus the user on the c# client is only responsible for sending his own hashed login details over the internet, and no SQL at all (the object/command gets turned into sql by the service layer on the webserver).

How are there the same security concerns? The client (in C#) will only have the server IP address and whatever information is required to communicate with the python service layer. The client only sends proprietary commands and objects, which the python service layer converts into sql, executes, and formats the results into a similar command/object to return to the client.

I will check out that Web API, I've timed this poorly as I just have to step out for a couple hours for work, but I realise I have a lot of reading ahead, so I'm more asking for a pointer in the right direction so I know exactly what terms and processes to google. I figured it'd be in JSON or something similar but I wasn't sure if c# used a different format or if there were a preferred system.

Sulla Faex fucked around with this message at 13:58 on Jul 29, 2013

wwb
Aug 17, 2004

Same security concerns meaning you are still dealing with marshalling authentication across the public internet somehow. Slightly better as you've got more options in the application layer than in the data layer but you are still dealing with the same fundamental issues. For example, sending the hashed login details isn't horribly better than in the clear when you start thinking about things like replay attacks.

PS: as for json, yes that is easily usable from C# client apps. The WebClient is the new microsoft-supported option, you might also want to look at a number of different wrapper libraries. Personally I'm partial to restsharp but that probably has to do with seat-time.

Crazy Mike
Sep 16, 2005

Now with 25% more kimchee.
Today's problem: I am trying to filter a DataGridView based on a column containing a TextBox value. The DataGridView's DataSource is set to a DataView so I can use its RowFilter() method. The TextBox Text changed event contains two methods. One that sets the filter, and another the reformats the DataGridView Columns since the filter resets the columns to defaults. If I type in the TextBox too fast, then the FormatColumns() method runs a for loop on a count of rows larger than it should, resulting in a Data Error and empty cells/rows in the DataGridView beyond what the filter returns. If I comment out the FormatColumns() method, there is no Data Error, but I lose my column formats. How do I ensure the FormatColumns() method has the right count of rows to operate on? The pertinent code is similar to the following:

code:
 private void TextBox_TextChanged(object sender, EventArgs e)
        {
            //Since the text changed, we need a new filter...
            SetFilter();
            // Since the filter resets the column widths, we need to reset them, This one is causing problems
            FormatColumns();        
        }
 private void SetFilter()
        {
            DataView.RowFilter = string.Format("title like '%{0}%'", TextBox.Text);
        }
 private void FormatColumns()
        {
            DataGridViewCellStyle columnHeaders = new DataGridViewCellStyle();
            columnHeaders.WrapMode = DataGridViewTriState.True;
            columnHeaders.BackColor = Color.LightGray;
            columnHeaders.Alignment = DataGridViewContentAlignment.MiddleCenter;

            // Need to center certain columns in the data grid
            for (int i = 0; i < DataGridView.RowCount; i++)
            {
                DataGridView.Rows[i].Cells[0].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DataGridView.Rows[i].Cells[1].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DataGridView.Rows[i].Cells[2].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
                DataGridView.Rows[i].Cells[12].Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
            }

            DataGridView.ColumnHeadersDefaultCellStyle = columnHeaders;
	}
edit: And it looks like I can use a cell template instead of a for loop to center those columns...
code:
 	 private void FormatColumns()
        {
            DataGridViewCellStyle columnHeaders = new DataGridViewCellStyle();
            columnHeaders.WrapMode = DataGridViewTriState.True;
            columnHeaders.BackColor = Color.LightGray;
            columnHeaders.Alignment = DataGridViewContentAlignment.MiddleCenter;
	    // Format column headers
	    DataGridView.ColumnHeadersDefaultCellStyle = columnHeaders;
            
	    // Certain columns need to be centered, therefore we need a cell template that corresponds
            DataGridViewCell cellTemplate = new DataGridViewTextBoxCell();
            cellTemplate.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;

            //Format Column widths, give columns 0, 1, 2, and 12 the centered template

            DataGridViewColumn column= DataGridView.Columns[0];
            column.Width = 50;
            column.CellTemplate = cellTemplate;
	    //snip..
	}
            
Since the defaults aren't affected by setting the filter, I only have to call this method once after the data grid is populated.

Crazy Mike fucked around with this message at 19:42 on Jul 30, 2013

Grogsy
Feb 8, 2013

Sulla-Marius 88 posted:

I figured it'd be in JSON or something similar but I wasn't sure if c# used a different format or if there were a preferred system.

Someone mentioned some libraries before, I would just like to add servicestack to that list. We use them on both sides but that is because they both run on c#.

Also what are peoples opinions on using a temporary token for the ongoing authentication? It is generated after the initial login and valid for a certain period of time.

Grogsy
Feb 8, 2013

wwb posted:

Go code first. You will feel better about yourself in the morning.

I always prefered database first. I don't like it when I don't know how exactly it will create link and index the tables.

How does code first even handle changes in the model?

Sulla Faex
May 14, 2010

No man ever did me so much good, or enemy so much harm, but I repaid him with ENDLESS SHITPOSTING

wwb posted:

Same security concerns meaning you are still dealing with marshalling authentication across the public internet somehow. Slightly better as you've got more options in the application layer than in the data layer but you are still dealing with the same fundamental issues. For example, sending the hashed login details isn't horribly better than in the clear when you start thinking about things like replay attacks.

What is the standard accepted solution to overcome this for when clients need to log on? At some point, some form of identifiable username and encrypted password needs to be sent over the internet. Or are you just saying that I shouldn't send the info in plaintext, even a hashed password, and it needs to be through TLS?

Milotic
Mar 4, 2009

9CL apologist
Slippery Tilde
Given the permanence of bloody databases, if you're not thinking about the schema yourself, you're setting yourself up for a world of pain down the line. I'm not a massive EF fan anyway. Makes people lazy with thinking about query performance (though that's true of any ORM) and the upgrade path from EF4 to 5 is fiddly if you've already been writing your own partial classes extending the entities (the upgrade path tends to result in them being overwritten by classes generated by the tt files). Also no async/await support in 5.

Adbot
ADBOT LOVES YOU

Munkeymon
Aug 14, 2003

Motherfucker's got an
armor-piercing crowbar! Rigoddamndicu𝜆ous.



Sulla-Marius 88 posted:

What is the standard accepted solution to overcome this for when clients need to log on? At some point, some form of identifiable username and encrypted password needs to be sent over the internet. Or are you just saying that I shouldn't send the info in plaintext, even a hashed password, and it needs to be through TLS?

SSL/TLS (so HTTPS if you're talking about a web server) for data in motion. E: So yes, but you don't need to bother with hashing it on top of that for transport.

Munkeymon fucked around with this message at 15:33 on Jul 30, 2013

  • Locked thread