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
Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm just learning .net and have run into something I can't figure out. Using asp.net to connect to an access database. The access database has a few tables, and I have some drop down forms that allow you to filter the data on the main table.

When you click on an item once filtered, it selects the data from the corresponding table using as an example "select * from other table where code = ?", the code is supplied via the browser string, etc.

It's all done except for the last page, which is slightly different than the others. Two variables are sent in the address bar, and depending on which data is supplied a different select statement is used.

This is an on load event:
code:
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Request.QueryString("prot") = "JD" Then
            FormViewDataSource.SelectCommand = "SELECT PackageName, Channel, PackageCode FROM DACPkgs WHERE Pkgcode = ?"
        ElseIf Request.QueryString("prot") = "SD" Then
            FormViewDataSource.SelectCommand = "SELECT PackageName, Channel, PackageCode FROM DNCSPkgs WHERE Pkgcode = ?"
        ElseIf Request.QueryString("prot") = "TD" Then
            FormViewDataSource.SelectCommand = "SELECT PackageName, Channel, PackageCode FROM HITSPkgs WHERE Pkgcode = ?"
        Else
            Response.Write("See Code details for more information")
        End If
        FormViewDataSource.SelectParameters.Clear()
        FormViewDataSource.SelectParameters.Add(New QueryStringParameter("?", "pkgcode"))
        FormView1.DataBind()
I ran it through debug and everything seems to work under the SelectParameters.

This is the error I get:
code:
Exception Details: System.Data.OleDb.OleDbException: No value given for one or more required parameters.

Source Error: 


Line 16:         FormViewDataSource.SelectParameters.Clear()
Line 17:         FormViewDataSource.SelectParameters.Add(New QueryStringParameter("?", "pkgcode"))
Line 18:         FormView1.DataBind()
Line 19: 
Line 20: 
 
Any ideas?

Adbot
ADBOT LOVES YOU

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm trying to add some code to a VB project I didn't create and am running out of ideas. I'd not really a developer, this is one of those things that were thrown at me, as I'm still on Chapter 1 of my C# book.

I have a panel with ID panServiceDetailID, a form with ID fvServiceSummaryID and a Datasource named ODS_ServiceSummary.

It pulls from a table showing basic information about a township. I want to use some of that information in another datasource/gridview, but I keep getting "Could not find control 'Sys' in ControlParameter 'sys'". Searching for this error says that I'm improperly referencing the control and suggests using the controlpath followed by a dollar sign, then the control.

Here is some sample code:
code:
<asp:Label ID="lblSys" runat="server" Text='<%# Bind("Sys") %>' />
                    <asp:Label ID="lblPrin" runat="server" Text='<%# Bind("Prin") %>' />&nbsp;
                    <asp:Label ID="lblAgent" runat="server" Text='<%# Bind("Agent") %>' />
                    <asp:HiddenField ID="HDNSys" runat="server" Value='<%# Bind("Sys") %>' />
                    <asp:HiddenField ID="HDNPrin" runat="server" Value='<%# Bind("Prin") %>' />
                    <asp:HiddenField ID="HDNAgent" runat="server" Value='<%# Bind("Agent") %>' />
That's the section where that information is displayed is the aforementioned form/grid view. I added the hidden fields because someone recommend that was the best way to reference their data.

So I have another gridview below with the following code:
code:
<asp:SqlDataSource ID="PDFLink" runat="server" 
        ConnectionString="Data Source yep edited out" 
        ProviderName="System.Data.SqlClient" 
                        
                        SelectCommand="SELECT [file_link] FROM [SPA_PDF] WHERE ([corp] = @corp) or ([corp] = @sys+@prin+@agent)">
                        <SelectParameters>
                            <asp:QueryStringParameter DefaultValue="?" Name="corp" QueryStringField="corp" 
                                Type="String" />
                           
                            <asp:ControlParameter ControlID="Sys" Name="sys" 
                                PropertyName="Value" />
                            <asp:ControlParameter ControlID="Prin" Name="prin" 
                                PropertyName="Value" />
                            <asp:ControlParameter ControlID="Agent" Name="agent" 
                                PropertyName="Value" />
                           
                        </SelectParameters>
    </asp:SqlDataSource>
Any ideas?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Thanks, that worked. I removed the hidden variables, made the three identifiers (sys, prin, agent) datakeynames for the gridview gvServiceSummary and then changed the control parameters to:
code:
<asp:ControlParameter ControlID="gvServiceSummary" Name="sys" 
                                PropertyName="SelectedDataKey('Sys')" />
                            <asp:ControlParameter ControlID="gvServiceSummary" Name="prin" 
                                PropertyName="SelectedDataKey('Prin')" />
                            <asp:ControlParameter ControlID="gvServiceSummary" Name="agent" 
                                PropertyName="SelectedDataKey('Agent')" />
Works great!

I'm running into one more issues though. There are two ways to run the query, you can manually enter the zipcode into a search box, or you can reach the detailed page via another website or application. The sys prin agent information is a string in the URL, example being default.aspx?corp=999999999999

My select statement for this is currently:
code:
SelectCommand="SELECT [file_link] FROM [SPA_PDF] WHERE ([corp] = @corp  or [corp] = @sys+@prin+@agent)">
Now, the search portion works with that code as is. The query doesn't work when the corp is grabbed from the URL, however if I remove the search portion of the query, and change it to
code:
SelectCommand="SELECT [file_link] FROM [SPA_PDF] WHERE ([corp] = @corp)">
Then, getting the corp from the URL works just fine.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Nurbs posted:

Everything after the ? in your url is part of the querystring. So what you need to do is add a querystring parameter in the select command instead of using the control parameter (I assume each method is on a different page), or just create another datasource and change the grid's datasourceID to the id of that datasource when you're going to use that search method. Don't forget to rebind if you go that route.
I did have a select parameter for the query string, but per your advice I just made a duplicate datasource with a distinct select statement per gridview and it works great. Thanks for all of your help!

Uziel fucked around with this message at 18:43 on Oct 13, 2008

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I am having an issue with Crystal Reports in Visual Studio. Everything with the report itself is actually working fine, but when I finished styling the MasterPage, the report format gets misaligned.

I have a report with an embedded subreport, and when using the MasterPage, the any subreports move out of alignment to the far right of the page. This is only IE, as it renders fine in Firefox and Safari. Unfortunately, I only have to develop for IE in this case.

This is what it looks like in IE:
http://i39.tinypic.com/akwtit.jpg

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm creating a custom web user control in c#. It is intended to interact with a permission hierarchy. We have different "sites" and each site has many "apps" and each app has many "permissions"

So, We have a TabPanel that loads a tab for each site. Then in each tab we have a TreeView where the parent nodes are the apps and the inner nodes are the permissions.

The Permissions show check boxes based on some criteria and are checked based on whether or not the HasPermission function returns true.

All of this code works...but only for the first user selected. For any subsequent user chosen, a step through the debugger shows all the correct logic being executed, but the page displays the same information as that of the first user selected.

So basically, it's saving the display somewhere...and I'm at a loss to find out where.

code:
public partial class Permissions : System.Web.UI.UserControl
{
    string _NTLogin;
    CoreUser _User;
    bool _IsAdmin;
    public string NTLogin
    {
        get
        {
            return _NTLogin;
        }
        set
        {
            ViewState["NTLogin"] = value;
            _NTLogin = value;
        }
    }
    public bool IsAdmin
    {
        get
        {
            return _IsAdmin;
        }
        set
        {
            ViewState["IsAdmin"] = value;
            _IsAdmin = value;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void LoadTabs()
    {
        string [] sites = MISCore.BusinessLayer.CorePermission.GetSites();
        foreach (string site in sites)
        {
            TabPanel tp = new TabPanel();
            tp.HeaderText = site;
            TabContainer1.Tabs.Add(tp);
        }
    }
    public void LoadTrees()
    {
        if(_User == null)
            return;
        TabPanelCollection tabs = TabContainer1.Tabs;
        foreach (TabPanel tab in tabs)
        {
            string site = tab.HeaderText;
            string[] apps = MISCore.BusinessLayer.CorePermission.GetApplications(site);
            TreeView tv1 = new TreeView();
            tv1.EnableViewState = false;
            foreach (string app in apps)
            {
                TreeNode tn1 = new TreeNode(app);
                tn1.SelectAction = TreeNodeSelectAction.None;
                string[] perms = MISCore.BusinessLayer.CorePermission.GetPermissions(site, app);
                foreach (string perm in perms)
                {
                    TreeNode tcn1 = new TreeNode(perm);
                    tcn1.SelectAction = TreeNodeSelectAction.None;
                    if (IsAdmin || _User.Manager.HasPermission(site, app, perm))
                    {
                        tcn1.ShowCheckBox = true;
                        if (_User.HasPermission(site, app, perm))
                        {
                            tcn1.Checked = true;
                        }
                        else
                        {
                            tcn1.Checked = false;
                        }
                    }
                    else
                    {
                        tcn1.ShowCheckBox = false;
                    }
                    tn1.ChildNodes.Add(tcn1);
                }
                tv1.Nodes.Add(tn1);
            }
            tab.Controls.Add(tv1);
        }

    }
    protected override void LoadViewState(object savedState)
    {
        base.LoadViewState(savedState);
        _NTLogin = (string)ViewState["NTLogin"];
        _IsAdmin = (bool)ViewState["IsAdmin"];
        if(_NTLogin != null)
            _User = new CoreUser(_NTLogin);
        TabContainer1.Tabs.Clear();
        LoadTabs();
        LoadTrees();
    }
}

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm having an issue going between content pages and a master page. In the master page, my navigation is based on a list.

I need to change the ID of a specific list item based on which directly the content file is in.

Here is what the master page looks like:
code:
<ul>
				<li><a href="index.html"><span>Home</span></a></li>
				<li><a href="index.html"><span>Addressability</span></a></li>
				<li><a href="index.html"><span>Addressing</span></a></li>
				<li id="current"><a href="index.html"><span>App Dev</span></a></li>
				<li><a href="index.html"><span>Desktop</span></a></li>
				<li><a href="index.html"><span>IT Only</span></a></li>
				<li><a href="index.html"><span>Macro</span></a></li>
				<li><a href="index.html"><span>MIS</span></a></li>
				<li><a href="index.html"><span>Server</span></a></li>
				<li><a href="index.html"><span>Telecom</span></a></li>
			</ul>
In my code behind, I have:
code:
  string path = (string)Page.AppRelativeTemplateSourceDirectory;
            if (path == "~/")
            {
                //Change the ID of the list item for the home link
            }
So I'm not entirely sure how to change the ID of the list item for which page I'm on. All it needs to do is set that ID so that on the master page, the menu indicates which link you are currently on. So if I'm in the root directly, I need the link for home to look like:
code:
<li id="current"><a href="index.html"><span>Home</span></a></li>

Uziel fucked around with this message at 21:14 on Mar 25, 2009

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Mick posted:

What you've pasted here: is this output from a server control or just straight html that you put into the Master page?
Straight HTML in the master page.

The design is pretty specific and I don't think there is a control for an unordered list with list items?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Uziel posted:

Straight HTML in the master page.

The design is pretty specific and I don't think there is a control for an unordered list with list items?


I figured it out!
I added an ID and run at server attribute to the li markup:
code:
<li id="liHome" runat="server"><a href="index.html"><span>Home</span></a></li>
In the codebehind, I have:
code:
 string path = (string)Page.AppRelativeTemplateSourceDirectory;
            if (path == "~/")
            {
                liHome.Attributes.Add("class", "current");
            }

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Is there an easy way to start/stop/restart services on a different server? I was looking at this (http://www.csharp-examples.net/restart-windows-service/) but this would indicate same server services.

Situation:
We have a service that sometimes needs to be rebooted and instead of us answering off hours support calls to just restart a simple service and would like to integrate the restart ability into the web app itself.

Also, is there a way to check for orphaned processes on a remote machine? The above service has another 3rd party exe that it opens and the service cannot be correctly restarted unless any orphan exes of that specific type are closed first.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Code Jockey posted:

^^^^ Ohhh man I want to know this too, I've got a few services that I'd kill to be able to control / monitor status of via web app!
I should learn to just search MSDN instead of trying to phrase what I want into a google search. I am trying this via System.ServiceProcess right now. When you create a new instance of ServiceController, you specific the service name and the machine name. I'll let you know if it works. It might not work for me considering the orphaned exe issue but I'll still update you.

Edit: It works for monitoring status, stopping and starting the service.

Really simple:

code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ServiceProcess;

namespace Addressability
{
    public partial class ModemRestTest : System.Web.UI.Page
    {
        ServiceController sc;
        protected void Page_Load(object sender, EventArgs e)
        {
            sc = new ServiceController("Service name", "machine name");
            lblServiceStatus.Text = sc.Status.ToString();
            

        }

        protected void STOP_Click(object sender, EventArgs e)
        {
            sc.Stop();
        }

        protected void START_Click(object sender, EventArgs e)
        {
            string[] arghs = { "-d" };
            sc.Start(arghs);
        }

        
    }

}

Uziel fucked around with this message at 21:05 on Jun 16, 2009

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm working on some error reporting for our site, and some XML is stored as varchar in our error reporting table.

I am able to generate the XML correctly, but I also want to prompt to save the XML file. Response.TransmitFile wants a physical path, but the file doesn't exist. I want to create it on the fly and prompt for download.

Here is what I have thus far:

code:
protected void Page_Load(object sender, EventArgs e)
        {
            string ThisID = Request.QueryString["id"];
            ErrorTracking.Error ThisError = new ErrorTracking.Error(ThisID);

            System.Text.Encoding enc = System.Text.Encoding.ASCII;

            byte[] DebugInfo = enc.GetBytes(ThisError.DebugInfo.XML);
            
            Response.ContentType = "text/xml";
            Response.OutputStream.Write(DebugInfo, 0, DebugInfo.Length);
            Response.AddHeader("Content-Disposition", "inline;filename=" + ThisID + ".xml");
            Response.End();
           
        }
This writes out the XML to the HTML page. Any ideas how to prompt to download and create the xml file on the fly?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Fiend posted:

If you change the content type to something the browser doesn't recognize, like "text/NotAXml" it'll prompt you to download.

Anyone know of a way that doesn't involve lying to the browser?
I set the content type to "what" and it still correctly output the XML tree structure without prompting for a download.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
A coworker helped me figure it out. So damned simple =(

code:
Response.AddHeader("Content-Disposition", "inline;filename=" + ThisID + ".xml");
to

code:
Response.AddHeader("Content-Disposition", "attachment;filename=" + ThisID + ".xml");

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm having issues disabling a button control and still having it process that button's click procedure.

Basically, our users love to hit the submit button multiple times. I'd love to disable to the submit button and change it's text to Processing. I'm able to change the text and disable the button via javascript (the on click click event), but then it doesn't process the procedure for btnSubmit_Click.

Any ideas?

Uziel fucked around with this message at 17:40 on Feb 24, 2010

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Sprawl posted:

You should be able to ".Disabled = true" in javascript iirc.
Right, but what happens is that the disabled property is set to true in javascript before the page posts, thus the submit button is not send via post and it's procedure never executes.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Sprawl posted:

Or are trying to make it so hambeasts can't mash submit a bunch of times and have to start multiple processing's?

you would want to do something like this


Button.Attributes.Add("onclick", GetPostBackEventReference(Button) & ";this.value='Please wait...';this.disabled = true;")
I wanted to stop hambeasts from mashing the submit button many times. The GetPostBackEventRereference worked. Thanks so much. Now its time to add this to every single submit button across a few hundred pages!

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
This is the most mundane thing, but I'm pulling my hair out over it as I can't seem to phrase it correctly for a search engine.

I simply just want to move the Select button on my gridview to the right side instead of being on the left. The gridview itself is populated by linq in the code behind.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Sprawl posted:

If i'm thinking right that's the command column that's part of the gridview so you should just change that.
Where specifically? I thought I'd done this before, but searching for moving the command column comes up with a ton of code to accomplish something that I'd hope would be very simple.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Sprawl posted:

Ah that would be done in the display time part.

inside your
<asp:GridView>


<Columns>

There would be something like

<asp:EditCommandColumn>

And you just move it around to where you want.
I gave up on gridviews for this purpose and am just going with a repeater.
The only thing I had in columns was the command column, the datafields were being generated by linq, so their code looked like:
code:
gvComments.DataSource = from c in ThisTicket.Comments 
                        orderby c.TimeStamp descending 
                        select new { TimeStamp = c.TimeStamp, 
                         PostedBy = new MISUser(c.NTLogin).FullName,
                         Entry = c.Comment, };

gvComments.DataBind();
I tried to programatically add the command field, but it is still limited by the properties of the design view created command fields. I was simply adding the instance of a command field to the gridview before the databind, and it was appearing to the left.

Anyways, yeah. Repeater should be a bit easier.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Crepthal posted:

Sorry if this is a stupid question. I'm pretty new to working with AD in .Net.
I'm having problems just getting user info from AD into vb.
I'm currently trying to build an LDAP query string that just pulls in a specific user and it isn't working.

Here is the code I'm having trouble with:
code:
   Dim conn As Connection
   Dim rs As Recordset

   conn = New Connection
   conn.Provider = "ADSDSOObject"
   conn.Open("ADs Provider")
   rs = conn.Execute("<LDAP://(ip address here)/cn=" & uname & ">")
Not sure if this helps, but this is our LDAP class in C#:
code:
using System.DirectoryServices;

 public LDAP(string iNTLogin)
        {
            _Loaded = false;
            //Connects to the specified ldap server in app config
            DirectoryEntry enTry = new DirectoryEntry(MISCore.Properties.Settings.Default.LDAPServer);

            DirectorySearcher mySearcher = new DirectorySearcher(enTry);

            //prepares a search on the ldap server for the user with the specified ntlogin
            mySearcher.Filter = "(&(objectClass=user) (sAMAccountName=" + iNTLogin + "))";

            try
            {
                SearchResult resEnt = mySearcher.FindOne();
                //pull the properties from ldap and store them in this instance
                if (resEnt.GetDirectoryEntry().Properties["givenName"].Value == null)
                {
                    _FirstName = " ";
                }
                else
                {
                    _FirstName = resEnt.GetDirectoryEntry().Properties["givenName"].Value.ToString();
                }
                _Loaded = true;

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
This is a rather general question that applies to multiple separate instances:
When using validators, they sometimes don't fire if there is a server timeout and incorrect data goes through into the database.

Is there any over reaching fix or work around, or does this need to be tackled on a case by case basis? If so, where do I start?

In the current example, in debug on localhost, a time out error is thrown and the data goes through. On the web server/live, the user doesn't seen an error and the data gets inserted.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm working with a Business Layer Object in C# that I'm serializing to XML, storing that XML in a table as text, then retrieving the XML and deserializing that XML back into a Business Layer Object. Having never done this before, I'm rather lost. I am able to store that Business Layer in the ViewState and retrieve it with deserializing/serializing with no problems. The Business Layer Object is called Builder.

View state example of loading the business layer object:
code:
_Builder = (Builder)ViewState["Builder"];
                    _Builder.Deserialized();
This is my code to commit the business layer object to the database as XML:
code:
 public void Commit()
        {
          XmlSerializer xmls = new XmlSerializer(this.GetType());
            System.Text.StringBuilder sb = new StringBuilder(null);

            System.IO.StringWriter sw = new System.IO.StringWriter(sb);

            xmls.Serialize(sw, this);
}
This also seems to work fine.

However, I cannot seem to figure out the loading from the database:
code:
 public static Builder Load(short iArea, QDay iDate)
        {
            QuotaDBDataContext db = new QuotaDBDataContext();
            DataLayer.Builder ThisDLBuilder = (from fb in db.Builders
                                               where fb.Area == iArea
                                              && fb.BuildDate == iDate
                                               orderby fb.RevisionDate descending
                                               select fb).FirstOrDefault();


            Builder ThisBLBuilder = new Builder();

             XmlSerializer xmls = new XmlSerializer(ThisBLBuilder.GetType());

            System.IO.StringReader sr = new      System.IO.StringReader(ThisDLBuilder.Build);
            ThisBLBuilder = (Builder)xmls.Deserialize(sr);
            ThisBLBuilder.Deserialized();

            return ThisBLBuilder;
        }
I get the errors:
There is an error in XML document (2,2)
InnerException: Use the "new" keyword to create an object instance
InnerException: Check to determine if the object is null before calling the method

Any ideas or advice?

Uziel fucked around with this message at 15:12 on Dec 16, 2010

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

epswing posted:

Do the contents of Builder not fit well with a relational database? I have to ask myself "is there a good reason to store xml as text in a column of an rdbms?" because it doesn't make too much sense.
Pretty much the only solution we were able to come up with in regard to storing "snapshots" of the builder object at various points in time, as they will need to be compared later, etc.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I figured it out, it was an issue with my classes and the serialization, not the retrieving of the XML. I had to make a blank public constructor in the classes when serializing and neglected to have some of the necessary properties have both get and set. :|

Uziel fucked around with this message at 18:47 on Dec 16, 2010

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm running into a weird error regarding rebinding a gridview after editing the data source that it pulls from. After editing the gridview in another panel and hitting the save button, the gridview's data is repulled from the database, but in Chrome and IE8 on the server (but NOT on localhost) the gridview defaults to edit mode with the changed data item as the selected row for editing.

Edit: Figured it out, had to set EditIndex = -1;

Uziel fucked around with this message at 20:15 on Oct 18, 2011

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Are there any recommended resources for getting started with WPF in .net4.0? I mostly work on web stuff but have a project that needs to be a desktop app.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Ithaqua posted:

No idea. Dump LINQ to SQL as soon as you can, it's a technological dead end. It's a decent proof of concept, but pretty much every other ORM is better.
Is Entity Framework still recomended? I'm considering migrating all of my Linq to SQL stuff but wasn't sure where to start. Any specific resources that would be a good start? I have access to Plural Sight for another two months but the entity stuff there seemed to focus on code first and not database first.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Dromio posted:

A year or so ago, we needed to start to introduce nightly maintenance processes to our system. W
This has gotten very unwieldy as we now have around 20 processes. If we want to put a new process in somewhere BEFORE an existing one, we end up having to find each process and adjust the RunOrder. Nasty.

But what's the best way to design this now? Should I get rid of the loop entirely and go back to having each process explicitly written in the NightlyRun (and end up with a constructor with 20 parameters)? Or go through some tricky Topological sorting where we list "Process1 depends on Process4"? Are there any other, better options?
I do something similar but using SSIS packages on a SQL Server, and have a single console app that has the necessary code and call it from the SSIS package with command line arguments depending on which process needs to run. Adjusting the order is as simple as reordering the jobs via SQL Management Studio, plus you easily get success/failure emails.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Are there any similar resources to Microsoft's "Improving .NET Application Performance and Scalability" (http://msdn.microsoft.com/en-us/library/ff649152.aspx)?

I'm sure some of it still applies, but its based around SQL Server 2000 and .NET Framework 1.1.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
This will probably lead into a bigger question, but I'm working on improving single user performance for an intranet application that has become business critical.

We are unfortunately storing large custom objects in session state (using session state server) and are paying a performance price due to the serialization/deserialization. I bought our team Ultra-Fast ASP.NET (http://www.amazon.com/Ultra-Fast-ASP-NET-Build-Ultra-Scalable-Server/dp/1430223839) and we are going through it, but given that we are using a single web server web garden, using cache for everything isn't ideal either (distributed cache also serializes/deserializes from what I understand).

I was starting to look into MVC, as its moving toward a stateless nature, but from what I've read there are still usages for session as our application is closer to "shopping cart" than basic "use a form to edit something in a database".

Any thoughts or opinions as to what direction we should be going? If more information would help, I can elaborate.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I have two ext js async tree panels and I'm loading their respective data via generics handlers (ashx). Is it best to just have a handler for each tree or have one handler that returns both types of data? What happens if both tree panels request to load at the same time? Is the handler that each points to run as a separate instance?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Xae posted:

Awesome, exactly what I was looking for to multithread.

code:
Parallel.ForEach<string>(fileNames, (filename) => { ProcessFile("parallel.foreach", filename); });
This bit confuses me though. Specifically what does the => do? I understand what it is doing, but I don't understand the syntax.
It's part of a lambda expression:

quote:

The => token is a direct substitute for the delegate clause. When the compiler sees the =>, it says that the preceeding part of the statement is the parameter list of a delegate, and what follows the => is the statement to execute.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I am trying to fix a news feature of our primary site. I am currently using TinyEditor to submit/edit news, and it works fine. My issue is displaying that HTML.

I have a control to display the news that contains a repeater, with a template that has a label for the title and a literal for the article itself. On ItemDataBound, I set the literal's text equal to the decoded html, and it looks just fine in the mark up but on display none of the markup works correctly (ie, an unordered list with list items does not become a list, just a giant block of text).

I feel like I'm just trying to hammer fist a solution, and since displaying decoded HTML can't be a unique problem, I wondering which direction I should be looking at.

My current "fix" is using Ext.NET's HTML editor in read only mode, and setting its value equal to the decoded HTML. This works but I cannot seem to get rid of the control's border or toolbar.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm starting a personal project in order to have something to put on my Github and for my resume as I don't have ANY personal projects/code examples because I "grew" into my current job as a developer and the last thing I've been wanting to do is program in my off time, plus I couldn't ever think of any passion projects.

However, I finally have an idea, and I'd like to take this opportunity to try out some technologies that I haven't been able to fully utilize at work.

Its essentially just a network equipment inventory tracker (these are the pieces of network equipment we have, these are our office locations, this office location has these instances of the equipment with these serial numbers, here are their IP addresses, etc).

My thoughts are MVC4 Web API and WPF MVVM accessing same database, and I'd like to use unit tests as well (which we don't do at work).

Any thoughts on things I should do to make sure I don't duplicate code between the web and windows application sides? I've done this before using ASP.NET forms and classic Windows forms, but I wasn't sure how this translated to MVC and MVVM as far as not duplicating code (since both are similar from my understanding).

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Ithaqua posted:

If you want to share the exact same UI between web and client, you might as well just do it in Silverlight. Then you don't have to worry about platform differences between web and client, you just do the whole thing with XAML and MVVM.

Otherwise, you'll want to have the model in its own assembly that's shared between the two. Your controller (MVC) and viewmodel (MVVM) will be sharing a lot of the same logic, so that's another thing worth abstracting as much as possible and putting into a shared assembly.

You'll still probably want to unit test both your controllers and viewmodels, just because they sometimes accomplish the same things in different ways (like validation).

If you're not familiar with unit testing, become familiar with best practices for doing so before starting. You have to architect your code properly in order to make unit testing painless, and refactoring something that's untestable in order to write unit tests can be a pain in the rear end.
I actually don't care about having the same/similar UI between them, just that they would be able to perform the exact same actions.

So I'd have the same data layer and then a single model for both, but then a separated out project for the site and desktop app respectively.

Any particular examples you'd recommend in regard to best practices for unit testing, designing for it, etc?

(unrelated but a new OP with links to the most update to date best practices, etc would be mega helpful)

Uziel fucked around with this message at 18:04 on Sep 2, 2012

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
Thanks.
So I'd have 5 projects (Web, Client, Model, Data, Tests) and things like View and Controllers would just be folders within? Or separate projects for say Web.View and Web.Controllers?

I will check out that book and setting up a build/revision server. I have a WHS server on my home network I will look into using for that purpose.

Ithaqua posted:

I'd probably break the project structure up like this, assuming it's sufficiently complex:

  • Project.Web.View
  • Project.Web.Controllers
  • Project.Client.View
  • Project.Client.ViewModels
  • Project.Model
  • Project.Data
  • Project.Tests.Unit
  • Project.Tests.Integration
  • Project.Tests.Presentation

The basic goal is to keep your projects logically separated. Think of each piece as "something you might want to potentially reuse".

That's why you have Web.View and Client.View projects -- those contain just visual aspects of your project. You probably would never reuse them, they depend entirely on having something to inform them of what to do. You might, however, reuse your controllers or your viewmodels. Let's say you made a mobile version of your site, or a windows 8 app. The presentation would be totally different, but everything else would probably be pretty much the same.

Past that, you have your model and a generic "data" project. You'll probaly end up splitting up "Data" a lot more, that's just my version of a placeholder where the guts of the application happen.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

Ithaqua posted:

Nope, each of those things I mentioned was a separate project. The reason you split up your test projects is so you can set up your builds to only run the tests in a specific project. For example, your CI build might only run unit tests, but your nightly build would run all of the tests.
Thank you, that makes perfect sense. I ordered that book, and in the meantime I'm going to get a working but simplified setup of just being able to add/edit/delete/view of device types from both UIs, and then see how to start creating unit tests for those methods/classes.

If I am posting my code is there a preferred way if I'm asking for pointers? Or is a github link enough?

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I'm finally getting to a project that's a perfect place to utilize MVC (Microsoft's implementation). Is it possible to mix MVC and regular ASP.NET webforms in a single project? I'm asking as I'm not sure some aspects of the project would either work or have the development time to learn how to do the more complicated aspects while other facets of the project as a simple as get a collection of data from a database, or add data.

Edit: I'm reading this post by Hanselman (http://www.hanselman.com/blog/PlugInHybridsASPNETWebFormsAndASPMVCAndASPNETDynamicDataSideBySide.aspx) but was curious if there are any more up to date resources for MVC4, etc.

Uziel fucked around with this message at 17:03 on Oct 29, 2012

Adbot
ADBOT LOVES YOU

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.
I hope there is something simple I'm missing, but I asked in this thread a few days earlier about combining MVC with asp.net web forms and was given the advice of just try to do everything in MVC.

I went through the MVC4 Movie site tutorial, and everything makes sense as far as how simple that application is. I'm now trying to convert the simpliest of our applications to MVC and running into something that seems trivial in webforms but I just don't get in MVC.

I have two drop downs. Selecting a value in the first clears the 2nd drop down and repopulates with data revelant to the selection of the data in the first. In this context, you have various manufacturers. You select one and the valid models for that manufacture are now in the second dropdown. This would take like 30 seconds to write in webforms.


Any ideas? I found this on Stack Overflow (http://stackoverflow.com/questions/11260086/cascading-dropdown-list-in-mvc-4) but this uses a button post back to populate the second drop down which I'm not able to do.

Part of the problem is that I want to work in MVC4 but don't know if solutions I find (if any) for the problem in older versions are the best practice way to do them in MVC4.

  • Locked thread