Robert Harvey

1

votes
0

answer
228

views

Proper Care and Feeding of a Dapper IDBConnection

What's the best way to manage a database connection in Dapper, the way that takes the best advantage of its feature set? I know, for example, that Dapper has a static query cache, so that identical queries presented to it in the future will execute faster. I also know that this cache can get too la...
Robert Harvey
1

votes
0

answer
20

views

Convert row or column in MS Word stored table into searchable array of text in MS Word document

SUMMARY: I would like to extract strings of text from a row or a column of cells in an MS Word table, and then use each item in the array of text strings as a search term in an MS Word VBA macro. DETAILS: I have been given the task of creating a macro that will search and highlight certain forbidd...
Robert Harvey
1

votes
2

answer
158

views

Automation of Downloads in Web Browsers

What is the reason for automating download links in websites? It could have the benefit of sparing the user a click, except that the browser always blocks it (you have to click on the yellow bar that appears at the top of the browser). That's harder than just clicking on the link that says, 'If y...
Robert Harvey
1

votes
1

answer
545

views

New Error in Strongly-Typed View - Cannot Enumerate Model? [closed]

I am currently using ASP.NET MVC 2.0 RC2, having recently moved from version 1.0. I have noticed that some of my views no longer work. I have views that inherit from a strongly-typed IEnumerable, like this: Inherits='System.Web.Mvc.ViewPage' In the past, I have enumerated the model in my view like...
Robert Harvey
1

votes
2

answer
134

views

How can I generalize the use of these different data structures?

I have an application that reads times from a file. These times can be in three different formats, based on flag bits elsewhere in the file, as shown below: [StructLayout(LayoutKind.Sequential, Pack = 1] public struct IntraPacketTime_RTC { public UInt64 RTC; } [StructLayout(LayoutKind.Sequential, P...
Robert Harvey
1

votes
1

answer
1.4k

views

Binding a Winform to a Dictionary or Key/Value List

I have a Winforms application that dynamically instantiates external form objects for use in a configuration UI. Each dynamically-instantiated form is placed in a TabPage. I would like to create a property that will accept a Dictionary or Key/Value list, and populate the form with those values, mat...
Robert Harvey
1

votes
3

answer
283

views

Concatenating inner text in an XPath array

I have some XML that looks like this: Cannot do business directly with consumers Cannot marry a martian and an instructions variable that looks like this: var instructions = myXDocument.XPathSelectElements('/root/instructions').Nodes(); I am attempting to concatenate all of the item strings, thusly:...
Robert Harvey
1

votes
1

answer
807

views

Asynchronous console program hangs on completion of task using CefSharp

In my quest to create the perfect string result = browser.Browse(url) method, I have created a simple class library to demonstrate CefSharp. The code for that is: public class CefSharpHeadlessBrowser { public CefSharpHeadlessBrowser() { Cef.Initialize(new CefSettings { CachePath = 'cache' }, false,...
Robert Harvey
1

votes
2

answer
72

views

How do I distinguish the new rows in a datagrid from the existing ones?

I have an ordinary DataGrid in a WPF application that is backed by an ObservableCollection. I am updating a SQL Server database using Dapper. Dapper can update existing records without problems, but to get new records into the database I have to insert them. So I have to make two Dapper calls; one...
Robert Harvey
1

votes
1

answer
0

views

“A binding can only be set on a DependencyProperty of a DependencyObject” error when attempting to bind this ValueConverter

I have this class: public class AssetDescriptionLookupConverter : FrameworkElement, IValueConverter { public IEnumerable LookupList { get { return (IEnumerable)GetValue(LookupListProperty); } set { SetValue(LookupListProperty, value); } } public static readonly DependencyProperty LookupListProperty...
Robert Harvey
1

votes
2

answer
0

views

How do I get Prism to report the exceptions it traps?

I have a Prism WPF application which failed to load one of its modules when I deployed it (due to a database problem). On my development machine, I can see the relevant exceptions being thrown (and apparently caught and handled by Prism) in the Output window of Visual Studio. I was able to solve...
Robert Harvey
1

votes
2

answer
0

views

How to organize libraries and links of programming information

I have an email account whose sole purpose it is to store interesting and useful links to programming articles, code, and blog posts. It has become a little knowledgebase of sorts. I can even do a search on it, which is pretty cool. However, after using this account for a couple of years, I now ha...
Robert Harvey
1

votes
1

answer
280

views

Crystal Reports Viewer always uses WaitCursor

I have a Crystal Reports control that is embedded in a Winform. When the application is run, the WaitCursor (hourglass) is always shown over the Crystal Reports. Attempting to change the Cursor property for the Crystal Reports Viewer Control in the Property Pane of Visual Studio has no effect (the...
Robert Harvey
1

votes
1

answer
127

views

How do you capture the result of a POST in the WebBrowser control?

I have a Winforms form with a WebBrowser control on it. I've already figured out how to connect the C# code to the Javascript in the Web Browser control by attaching an instance of a C# class to the ObjectForScripting property, like this: public partial class Browser : Form { private void webBrowser...
Robert Harvey
1

votes
2

answer
46

views

Creating and using a temporary table to return a specific row, instead of running the query repeatedly

I have a program where a query is being run repeatedly to get a single row number (here called a 'partition'). declare @partition int = {0} ;with candidates as ( select column1, column2, ROW_NUMBER() over (order by table1.column1) as RowNumber, ... ) select c.column1, c.column2, from candidates c w...
Robert Harvey
1

votes
1

answer
70

views

Wrapping an Expression Tree with a Logger

I'm doing some work in Expression Trees. When you call ToString() on an Expression Tree, you get a lovely bit of diagnostic text (here is a sampling): ((Param_0.Customer.LastName == 'Doe') AndAlso ((Param_0.Customer.FirstName == 'John') Or (Param_0.Customer.FirstName == 'Jane'))) So I wrote this...
Robert Harvey
1

votes
1

answer
57

views

How do I get my XPath to search only within each table?

I have a bit of HTML that looks like this: Name ACME ANVILS, INC and some C# code that looks like this: var name = document.DocumentNode .SelectSingleNode('//*[text()='Name']/following::td').InnerText which happily returns ACME ANVILS, INC. However, there's a new wrinkle. The page in question now...
Robert Harvey
1

votes
1

answer
135

views

Bit-level querying in Hadoop and Hive

We have a use case for bit-level querying in Hadoop. It goes something like this: Given a set of variable-length records containing a date/time stamp and one or more sixteen bit data words, return a list of date/time stamps where some combination of arbitrary bits from one or more arbitrary data wo...
Robert Harvey
1

votes
1

answer
109

views

How to make a field required, based on the value of another field

I have a ViewModel with some public properties that have data annotations, like this: [Required] public string PointOfContact { get; set; } Which works just fine. I've got all of the necessary plumbing in place to display the proper control formatting and error messages when validation fails. Howe...
Robert Harvey
1

votes
2

answer
382

views

Handling null values in asp.net MVC dropdowns

How do I create a dropdown in ASP.NET MVC that can handle a null value? The application is a lookup field in a database, where the primary key is in a lookup table, i.e. Categories, and the foreign key is in another table, i.e. CategoryID, but CategoryID is OPTIONAL (i.e. it can contain a null). I w...
Robert Harvey
1

votes
3

answer
219

views

Routing Rule for ASP.NET Products Website

I am building a product catalog for a customer website under ASP.NET using .NET Framework 3.5 SP1. Each product has a part number and an OEM part number (all globally unique). For SEO purposes I would like the OEM part number to be as close as possible to the actual domain name. How do I build a ro...
Robert Harvey
1

votes
3

answer
164

views

How to represent a hierarchically-organized URL in ASP.NET MVC

Let's say I have an URL that looks like this: http://www.mysite.com/area/topic/subtopic/subsubtopic where the number of topics and subtopics is arbitrary. Is there a way to process this kind of URL in ASP.NET MVC?
Robert Harvey
1

votes
3

answer
322

views

Modifying text files and executing programs with command line parameters in c# or c++ on Linux

I have a need to create a utility in Suze Linux. The utility will make modifications to some text files, and then use the information in those text files to program a device in the computer using a different executable which accepts command line parameters. I am fluent in c#, but have never worked...
Robert Harvey
1

votes
2

answer
1k

views

How to marshal a struct into a UInt16 Array

I know that you can use code like this to marshal a structure into a byte array: public static byte[] StructureToByteArray(object obj) { int len = Marshal.SizeOf(obj); byte[] arr = new byte[len]; IntPtr ptr = Marshal.AllocHGlobal(len); Marshal.StructureToPtr(obj, ptr, true); Marshal.Copy(ptr, arr, 0...
Robert Harvey
1

votes
4

answer
701

views

How do I write a Lambda statement for this Linq to XML function?

I am working with this XSD file. The portion of the XML that is relevant to this question is here: TMATS G Group PN To get the documentation value for a given xs:element, I have this small function, which recursively walks the descendant nodes until it finds the documentation element: public string...
Robert Harvey
1

votes
1

answer
694

views

Making a Controls.Add method call thread-safe

Let's say I have the following code: public void Inject(Form subform) { this.tabControl1.TabPages[1].Controls.Add(subform); this.Refresh(); } How can I convert the Controls.Add() call to a thread-safe call, using Control.Invoke?
Robert Harvey
1

votes
2

answer
42

views

How do you retrieve one of the pallet brushes from the Material Design in XAML toolkit using C# Code Behind?

My pathetic attempt to retrieve one: MaterialDesign.Themes.Wpf.Current.Brushes.MaterialDesignBody (which doesn't work, of course.) The documentation for the brushes is here. The brushes themselves appear to be located here; I can get to them in xaml, but don't know how to get to them in C#. If anyo...
Robert Harvey
1

votes
1

answer
0

views

How do I use a Pack Icon as a mouse cursor?

I have the following code which I'm using to provide mouse cursor feedback on a drag and drop operation. It uses a local cursor file. private void UserControl_GiveFeedback(object sender, GiveFeedbackEventArgs e) { if (e.Effects == DragDropEffects.None) { e.UseDefaultCursors = true; e.Handled = true...
Robert Harvey
2

votes
1

answer
390

views

What are the use cases for jQuery Templates in ASP.NET MVC?

For awhile now I have been looking for an overall data/markup strategy to settle into ASP.NET MVC, and am now currently looking at jQuery Templates. jQuery templates appear to me to be a new binding system, similar to the MVC view engine or its various flavors, except that it does the data binding i...
Robert Harvey
3

votes
2

answer
606

views

Instrumenting an expression tree — How to get the computed result of each subtree?

I'm doing some work in Expression Trees, a rules engine of sorts. When you call ToString() on an Expression Tree, you get a lovely bit of diagnostic text: ((Param_0.Customer.LastName == 'Doe') AndAlso ((Param_0.Customer.FirstName == 'John') Or (Param_0.Customer.FirstName == 'Jane'))) I wrote thi...
Robert Harvey
17

votes
8

answer
29.1k

views

Regular expression to split string and number

I have a string of the form: codename123 Is there a regular expression that can be used with Regex.Split() to split the alphabetic part and the numeric part into a two-element string array?
Robert Harvey
18

votes
4

answer
13.5k

views

How do you get the duplicate key that ToDictionary() has failed on?

I'm creating a Dictionary object, using IEnumerable's ToDictionary() extension method: var dictionary = new Dictionary (myCollection.ToDictionary(k => k.Key)); When it executes, it throws the following ArgumentException: An item with the same key has already been added. How do I get it to tell me wh...
Robert Harvey
18

votes
1

answer
26.6k

views

How do I group data in an ASP.NET MVC View?

In reporting tools like Crystal Reports, there are ways to take denormalized data and group it by a particular column in the data, creating row headings for each unique item in the specified column. If I have this: Category1 Data1 Category1 Data2 Category1 Data3 Category2 Data4 Category2...
Robert Harvey
5

votes
4

answer
16.5k

views

Bit manipulation in C# using a mask

I need a little help with bitmap operations in C# I want to take a UInt16, isolate an arbitrary number of bits, and set them using another UInt16 value. Example: 10101010 -- Original Value 00001100 -- Mask - Isolates bits 2 and 3 Input Output 00000000 -- 10100010 00000100 -- 10100110 0000...
Robert Harvey
2

votes
4

answer
859

views

Performance Testing a Greenfield Database

Assuming that best practices have been followed when designing a new database, how does one go about testing the database in a way that can improve confidence in the database's ability to meet adequate performance standards, and that will suggest performance-enhancing tweaks to the database structur...
Robert Harvey
6

votes
5

answer
1.3k

views

How to create a menu in WPF that has Microsoft Web Application styling

We have been tasked with designing an enterprise application in WPF that will replace a battleship grey Winforms application with a modern look and feel. We like the look and feel that Microsoft web applications currently possess: We could create these menus in WPF in the usual way: But we'd get som...
Robert Harvey
5

votes
3

answer
2.7k

views

Creating Database Mocks in ASP.NET MVC using Data from Existing Database

I have an existing ASP.NET MVC application with some sample data in the SQL Server database, which is working fine.. Assuming I have all of the necessary repositories and IOC in place, is there a tool that will extract the data from a group of tables, and 'freeze-dry' it into a mock object (perhap...
Robert Harvey
5

votes
3

answer
9.5k

views

Why is my Extension Method not showing up in my test class?

I created an extension method called HasContentPermission on the System.Security.Principal.IIdentity: namespace System.Security.Principal { public static class IdentityExtensions { public static bool HasContentPermission (this IIdentity identity, int contentID) { // I do stuff here return result; }...
Robert Harvey
3

votes
2

answer
616

views

How can I identify the color of the letters in these images?

I am using this article to solve captchas. It works by removing the background from the image using AForge, and then applying Tesseract OCR to the resulting cleaned image. The problem is, it currently relies on the letters being black, and since each captcha has a different text color, I need to ei...
Robert Harvey
11

votes
2

answer
1k

views

Is there a relatively straightforward way to finalize a CD or DVD in C# or PowerShell?

First, some clarification of terms. By finalize, I don't mean closing a session; I mean writing a lead-out to a CD or DVD in such a way that information can no longer be added to it via the usual means (Roxio, Nero, Windows Explorer, etc.) I've done a fair amount of research on this. There are som...
Robert Harvey

View additional