Friday, May 30, 2014

Objective-C has Arrays and NSMutable Arrays.

The former has a fixed size and the later may have new items added into it not unlike a List of T in C#.

Thursday, May 29, 2014

PCI history

It seems Payment Card Industry Data Security Standard approaches are not required by U.S. Law, but are instead just required in Minnesota and Nevada (while Washington State law gives heavy incentive for an embrace of PCI) and thus the Minnesota and Nevada requirements effectively drive a nationwide requirement as who would want to make a shopping cart which attempts to sidestep interfacing with with two of the fifty U.S. states? The oldest of the Minnesota/Nevada laws is the Minnesota law and it goes back to 2007. PCI as an idea goes back less than ten years to the tail end of 2004. Amongst the requirements for compliant web sites are things like:

  • session data may only be kept for X minutes
  • users must change their passwords every Y days
  • etc.

If you make a page in Sharepoint in a library and no one can see your page but you...

Maybe you need to "check in" or "publish a major version" and if you navigate up one level to the library itself and then click upon the name of your page within the library a menu should appear with options such as these.

Create SharePoint wiki pages from within Internet Explorer!

  • Open the F12 tools in IE 11 and set the Document Mode to "9" to emulate IE 9.
  • Edit a wiki page full of links to other wiki pages and add something like this:
    [[My Page]]
    ...which will make both a new page and a link to it which you may click to enter it.
  • Edit your new page!

RAD used to stand for Rapid Application Development...

...and it basically meant: Check in anything you want.

We are moving offices at work and as we go through our things we have uncovered an old book on HTML from 1996.

It is the second edition of the HTML Sourcebook by Ian S. Graham, and it went home with me as nobody wanted it for some reason. 1996 was the year I learned HTML and I suppose that version of HTML, the version with the blink tags that existed before Internet Explorer, was HTML 3.0 per the book's cover. I suppose the XHTML (HTML as XML) stuff was HTML version 4 and now we of course have HTML 5. Version 3 was out eighteen years ago, huh? What were the first two versions?

When a DevExpress ASPxGridView has a column of checkboxes for selecting its rows, you may uncheck all of the checkboxes via C# in this way.

MyGrid.Selection.UnselectAll();

Why you should care about a DevExpress ASPxCheckBox's enabled state.

Foo.Enabled = false;

...is not the same as...

Foo.ClientEnabled = false;

 
 

The former is going to hide the whole of the checkbox from the UI. There will be no way to call the checkbox by its id from JavaScript and such attempts will throw an error up to the console. Nonetheless the "disabled" checkbox will appear to be a checkbox which is disabled in the traditional sense. The later actually disables a checkbox in the traditional sense. The checkbox may be grabbed ahold of by JavaScript and even reenabled by JavaScript.

Wednesday, May 28, 2014

Argument is 'value' while parameter is declared as 'ref'

This means that instead of handing in a ref variable like so in C#...

DoSomething(Whatever);

 
 

That you need to do this:

DoSomething(ref Whatever);

if (!string.IsNullOrEmpty(whatever)) {

This sanity check for determining if a string is either null or not null while yet containing zero characters is now, finally, a part of the .NET Framework. Remember when you had to write an extension method for string to deal with this stuff?

The "Blame..." option in TortoiseSVN...

...shows you who last changed each line in a selected file.

Prepare pagination on the C# side for a DevExpress ASPxGridView.

whatever.SettingsPager.PageSize = 10;
whatever.SettingsPager.AlwaysShowPager = true;
whatever.SettingsPager.AllButton.Visible = true;

 
 

...is equal to the following:

<SettingsPager PageSize="10" AlwaysShowPager="True">
   <AllButton Visible="True"></AllButton>
</SettingsPager>

 
 

Don't try to be silly and have both.

The VisibleRowCount property of a DevExpress ASPxGridView will reveal how many total rows are in the control.

Following this, I finished a means for adjusting the height of a div holding yet another div which had absolute positioning holding an ASPxGridView named Foo when Foo's height changed due to pagination changing. My C# looks like this:

namespace MyProject.MyFolder
{
   public partial class MyWebFormCodeBehind
   {
      private int _rowHeight;
      private int _headerAndFooterHeight;
      private int _pageSize;
      
      public MyWebFormCodeBehind()
      {
         _rowHeight = 26;
         _headerAndFooterHeight = 70;
         _pageSize = 10;
      }
      
      private void Foo_PageIndexChanged(object sender, EventArgs e)
      {
         int pageIndex = (sender as ASPxGridView).PageIndex;
         int totalRows = (sender as ASPxGridView).VisibleRowCount;
         if (pageIndex > -1)
         {
            decimal division = totalRows /_pageSize;
            int remainder = totalRows % _pageSize;
            int lastPage = Convert.ToInt32(Math.Floor(division));
            if (pageIndex == lastPage && remainder != 0)
            {
               Foo.JSProperties["cp_ToAdjustHeightTo"] = (remainder * _rowHeight) +
                     _headerAndFooterHeight;
            } else {
               Foo.JSProperties["cp_ToAdjustHeightTo"] = (_pageSize * _rowHeight) +
                     _headerAndFooterHeight;
            }
         } else {
            Foo.JSProperties["cp_ToAdjustHeightTo"] = (totalRows * _rowHeight) +
                  _headerAndFooterHeight;
         }
      }

 
 

...and in JavaScript I have:

function AdjustHeightOfDivHoldingPaymentConfigurations(s, e) {
   var middlemanDiv = document.getElementById("MiddlemanDiv");
   middlemanDiv.style.height = s.cp_ToAdjustHeightTo + "px";
}

 
 

What are the three calculations in C#? From the bottom up there are...

  1. This circumstance is for pressing the "All" button and showing every record at once.
    Foo.JSProperties["cp_ToAdjustHeightTo"] = (totalRows * _rowHeight) +
          _headerAndFooterHeight;

     
  2. This is for showing almost any page in the pagination. There is one exception however.
    Foo.JSProperties["cp_ToAdjustHeightTo"] = (_pageSize * _rowHeight) +
          _headerAndFooterHeight;

     
  3. Here is the exception. If the last page in the pagination is not a complete page (with ten line items) then we use this.
    Foo.JSProperties["cp_ToAdjustHeightTo"] = (remainder * _rowHeight) +
          _headerAndFooterHeight;

If the number of records is equal to or less than the number of records in one page (ten) then the pagination controls will be disabled and all of this will be moot.

Catch JavaScript exceptions in Visual Studio!

At "Exceptions..." within the "DEBUG" menu in Visual Studio 2013, allow for errors which normally fail silently (JavaScript errors for example) to be thrown.

 
 

"Options and Settings..." within the "DEBUG" menu brings up a dialog wherein under "General" under "Debugging" one may check a checkbox for "Enable Just My Code" to make sure that DotNetNuke errors do not get caught in debugging in this manner.

dummy numbers which are legitimate for testing credit card processing

What follows is just copied and pasted shamelessly from this. Enjoy.

 American Express   378282246310005 
 American Express   371449635398431 
 American Express Corporate   378734493671000 
 Australian BankCard   5610591081018250 
 Diners Club   30569309025904 
 Diners Club   38520000023237 
 Discover   6011111111111117 
 Discover   6011000990139424 
 JCB   3530111333300000 
 JCB   3566002020360505 
 MasterCard   5555555555554444 
 MasterCard   5105105105105100 
 Visa   4111111111111111 
 Visa   4012888888881881 
 Visa   4222222222222 
 Dankort (PBS)   76009244561 
 Dankort (PBS)   5019717010103742 
 Switch/Solo (Paymentech)   6331101999990016 

Tuesday, May 27, 2014

When attempting to use an out parameter in a C# method which is a list of T...

...you may get this:

Out parameter 'yourNameHere' might not be initialized before accessing

 
 

...when you mouse over all references to the variable in Visual Studio which now have squiggly red lines under them. The way to beat this is to use ref in lieu of out.

manipulating HTML whenever pagination changes within a DevExpress ASPxGridView

Here is my challenge. I put an ASPxGridView inside an existing page. I wanted it to be wider than the div it would sit within would allow so I gave it absolute positioning and made it sit within the div it had to sit within within a middleman div which had a fixed height creating the illusion that the ASPxGridView was pushing the rest of the content below on the page downwards. This illusion was shattered when I pressed the "All" button or when the last page in the pagination (with fewer records than the other pages) was visited. I needed a way to alter the height of the middleman div when the pagination changed. This touches on how to do so a little bit. In my implementation I am adding this tag inside my ASPxGridView:

<ClientSideEvents EndCallback="AdjustHeightOfDivHoldingPaymentConfigurations" />

 
 

On the C# side I then have an event like so:

private void Foo_PageIndexChanged(object sender, EventArgs e)
{
   Foo.JSProperties["cp_PageChanged"] = "whatever";
}

 
 

And in JavaScript I'll do something like this:

function AdjustHeightOfDivHoldingPaymentConfigurations(s, e) {
   alert(s.cp_PageChanged);
}

 
 

The alert will surface the "whatever" and by this process with cp_ variables one may hand the number of records shown to JavaScript where the height of the middleman div may be restyled appropriately.

Just move the thing you are clicking upon in Adobe Photoshop CC in lieu of finding the appropriate layer first.

If you pick the move tool, one of the options should be a checkbox for "Auto-Select:" which will allow you to click on something visible and select the Group or Layer the artwork is in automatically before dragging it about the image's canvas.

When you use Resharper to make a method for a web forms event...

It, by default, will throw an exception...

private void Whatever_PageIndexChanged(object sender, EventArgs e)
{
   throw new NotImplementedException();
}

 
 

...that ends up coming up in a JavaScript alert box reading:

The method or operation is not implemented.

Saturday, May 24, 2014

Figure out if you are showing all records in a DevExpress ASPxGridView with the "All" button, breaking out of pagination.

Wire up an event like this:

Whatever.PageIndexChanged += Whatever_PageIndexChanged;

 
 

Catch a variable like so:

private void Whatever_PageIndexChanged(object sender, EventArgs e)
{
   int pageIndex = (sender as ASPxGridView).PageIndex;

 
 

The number will reveal which page you are viewing. A value of zero means page one, a value of one means page two, a value of two means page three, and so on. A negative one means you've broken out of the pagination.

Friday, May 23, 2014

Explicitly find a DevExpress control in web forms in the name of using it on the C# side!

It takes some getting used to to do this...

var noticeForNoRecords = group.FindControl("NoticeForNoRecords") as ASPxLabel;
noticeForNoRecords.Text = "Hello";

 
 

...instead of just this:

NoticeForNoRecords.Text = "Hello";

There are industry standards for scoring credit card transactions numerically for validity.

A value would denote how legit or shady a transaction might likely be based on other data points and metrics.

You may have an "All" button at a DevExpress ASPxGridView to allow a user to break out of the pagination and just show everything!

<SettingsPager PageSize="10" AlwaysShowPager="True">
   <AllButton Visible="True"></AllButton>
</SettingsPager>

Thursday, May 22, 2014

PAN stands for Primary Account Number

This says: "PAN (primary account number) truncation is a technology that prevents most of the digits in a credit card, debit card or bank account number from appearing on printed receipts issued to customers."

Visa, Mastercard, and Europay have a collective spec for the keeping of credit card records.

This speaks to EMVCo's EMV Payment Tokenisation Specification which is a suggested approach for the tokenisation of credit card data.

Get Update 2 for Visual Studio Professional 2013!

http://www.microsoft.com/en-us/download/confirmation.aspx?id=42664

Live Streaming Unlimited Productions

...or LSUP is a company I was introduced to yesterday which seems impressive. I know one of the founders and I'd like to support him so I thought I'd offer a shameless free plug. At 7PM Central Time here in Austin tonight on the 1370 AM radio station they will once again be broadcasting the "Danny Webber's Real Estate Investor Power Hour" which is a news show focused on Austin real estate. This time it's different as they will be taking your questions via chat at http://www.justin.tv/livestreamingunlimited. Why not check it out?

Wednesday, May 21, 2014

Quintessential Select Lambda!

In C#, pluck out all of the unique ids from a list of some type to another collection like so:

List<Foo> foos = Whatever();
int[] fooIds = foos.Select(x => x.FooId).ToArray();

Make a common separated string from the .ToString() values of a List of T in C#!

string foo = string.Join(",", GetMyListOfStuff());

Tuesday, May 20, 2014

make a remote desktop connection in Windows XP

open a command prompt and then type "mstsc"

enable a remote desktop connection in Windows

  1. in Windows Server 2008 R2 at: Start > Administrative Tools > Server Manager ...click on the "Configure Remote Desktop" link at the right nav which should make the "Remote" tab of a "System Properties" dialog box appear
    • If you can't see the "Configure Remote Desktop" link click on "Server Manager" at the upper left at the top of the tree of things within the Server Manager pane.
  2. in Windows 7: right-click on the "My Computer" icon and pick "Properties" from the menu that appears ...then click on "Remote Settings" at the upper left of the pane that appears to get to the same place suggested above

Just restart the desktop or laptop running the VMware VMs if you get this error. (Restarting always fixes everything, right?)

  • Failed to lock the file
  • Cannot open the disk 'C:\Users\tjaeschke\Documents\Virtual Machines\Windows Server 2008 R2 x64\Windows Server 2008 R2 x64.vmdk' or one of the snapshot disks it depends on.
  • Module DiskEarly power on failed.
  • Failed to start the virtual machine.

Monday, May 19, 2014

Synergy

My superior showed me Synergy this morning. It allows him to drag his mouse pointer seamlessly from the two monitors he has for his PC onto the screen of his Macintosh laptop and back without having to explicitly toggle between the two with a KVM (keyboard, video and mouse). He can also copy and paste text between the two realms. When at the Mac he uses Windows-C and Windows-V and when at his PC he uses Ctrl-C and Ctrl-V. I thought my head was going to explode.

mysteries of casting the CallbackEventArgsBase object in a DevExpress ASPxGridView's callback method signature to a more manageable type revealed!

The "json" variable in this example is a JavaScriptSerializer type. The e in the signature of myCallBackPanel_Callback will have some properties hanging off of it which may be automatically assigned to a type precrafted to expect certain values. This type is FooClientParams in my example. "Button" ends up in clientParams.ControlType and "MatchMeUpInCallBack" ends up in clientParams.ControlFunction in my example. In order for this to work, the FooClientParams type must hold string getsetters for ControlType and ControlFunction.

conditionally disabling checkboxes in a column full of checkboxes in a DevExpress ASPxGridView

This touches on "conditionally hiding checkboxes in a column full of checkboxes in a DevExpress ASPxGridView" and the disabling of checkboxes may be done in largely the same way. In the Foo_CommandButtonInitialize C# method one would disabled checkboxes with...

e.Enabled = false;

 
 

...instead of:

e.Visible = false;

 
 

And in the DoSomethingInJavaScript function this blob of code...

if (checkBoxSanityCheck != ' ')
   Foo.SelectRowOnPage(i);

 
 

...could be replaced with this blob of code so that both hidden and disabled checkboxes are not selected when one checks the special checkbox to check all checkboxes.

if (checkBoxSanityCheck != ' ') {
   if (checkBoxSanityCheck.indexOf('savedtabindex') == -1) {
      Foo.SelectRowOnPage(i);
   }
}

It's time for a new local IP address.

ipconfig /release
ipconfig /renew

Get back the whole collection databound to an ASPxGridView or fish out particular fields.

Assuming that a list of Foo has been databound to FooGrid and a Foo has Bar and Baz properties...

protected void FooGrid_CommandButtonInitialize(object sender,
      ASPxGridViewCommandButtonEventArgs e)
{
   var grid = sender as ASPxGridView;
   int barId = Convert.ToInt32(grid.GetRowValues(e.VisibleIndex, "Bar"));
   int bazId = Convert.ToInt32(grid.GetRowValues(e.VisibleIndex, "Baz"));

 
 

...then the above will pull out the Bar and Baz properties for the given row to variables while the following will get the whole of the object collection back from the ASPxGridView assuming that Bar is the unique id for Foo.

void FooGrid_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
   List<object> rawValues = FooGrid.GetSelectedFieldValues("Bar");
   List<int> values = rawValues.Cast<int>().ToList();
   var collection = values.Select(x => FooGrid.FindVisibleIndexByKeyValue(x))
         .Select(y => FooGrid.GetRow(y) as Foo).ToList();

Yay! TeamViewer uses port 80!

One of the more frustrating things about using the guest wireless at a Starbucks or whatever is that many ports are not exposed. Don't plan to use an FTP client at a Starbucks for example. I was able to help a friend over TeamViewer from a DoubleTree Inn yesterday. That was nice.

Saturday, May 17, 2014

Select the unique id of all selected rows in a DevExpress ASPxGridView and cast them to a List of int in C#.

I have an ASPxGridView with an opening tag like so wherein the KeyFieldName must match up to the name of a "unique id parameter" within the object of which the list of T that binds to the ASPxGridView is filled (databound) by.

<dx:ASPxGridView AutoGenerateColumns="False" ID="GridOfFoo"
      ClientIDMode="Static" runat="server" KeyFieldName="FooId">

 
 

In my ASPxGridView I have a GridViewCommandColumn full of checkboxes for selecting rows as detailed here and here. Far outside of the ASPxGridView I have a plain Jane button.

<dx:ASPxButton ID="Whatever" runat="server" AutoPostBack="false"
      EnableTheming="False" CssPostfix="none" CssClass="button" Text="Whatever">
      </dx:ASPxButton>

 
 

In the page loading stuff (web forms) I wire up this event for the button.

BetterButtonToBe.ClientSideEvents.Click =
      String.Format("function(s,e){{{0}.PerformCallback(JSON.stringify({1}));}}",
      myCallBackPanel.ClientInstanceName, json.Serialize(CertificationParams("Button",
      "MatchMeUpInCallBack")).Replace('\"', '\''));

 
 

I then get the "values" of the selected rows like this in the event for the callback panel:

void myCallBackPanel_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
{
   var clientParams = json.Deserialize<FooClientParams>(e.Parameter);
   List<object> rawValues = GridOfFoo.GetSelectedFieldValues("FooId");
   List<int> values = rawValues.Cast<int>().ToList();

 
 

I don't really understand the line of code with the object deserialization above yet, and I could have left it out as it really does nothing. Some of this comes from an example at work. In that example we would match "MatchMeUpInCallBack" conditionally on something hanging off of clientParams to determine the intent of this particular callback. Ugh, I should have thought this out more before I typed it up. I am trying to not have caffeine on the weekends and it does make me bouncy during the work week, but, well, you know...

Thursday, May 15, 2014

conditionally hiding checkboxes in a column full of checkboxes in a DevExpress ASPxGridView

Following up on this, I tried to hide checkboxes conditionally the wrong way today...

function hideCheckboxes() {
   var checkBoxesToHide = Array.parse($('#WhichCheckboxesToHide').val());
   var rows = $('#Foo').find('tbody:first').find('tr:first').find('td:first').find('table:first')
         .find('tbody:first').children().toArray();
   var isFirstRow = true;
   var counter = 0;
   rows.forEach(function (row) {
      if (!isFirstRow) {
         var id = row.cells[2].innerHTML;
         checkBoxesToHide.forEach(function(checkbox) {
            if (checkbox == id) {
               var whatnow = $('#Foo').find('tbody:first').find('tr:first').find('td:first').find('table:first')
                     .find('tbody:first').find('tr:eq('+counter+')').find('td:first');
            }
         });
      }
      counter++;
      isFirstRow = false;
   });
}

 
 

I didn't know what to do with the whatnow variable above. It turns out the checkboxes that DevExpress makes are not even checkboxes but are instead span tags which are dressed up to look like checkboxes. The better thing to do is this in C#:

Foo.CommandButtonInitialize += Foo_CommandButtonInitialize;

 
 

...followed by this:

protected void Foo_CommandButtonInitialize(object s,
      ASPxGridViewCommandButtonEventArgs e)
{
   var grid = s as ASPxGridView;
   if (grid.GetRowValues(e.VisibleIndex, "FlattenedErrorList").ToString().Length > 0)
         e.Visible = false;
}

 
 

Alright, now we are doing things the DevExpress way! Here is my redacted JavaScript. You'll notice that I was able to bring in elements of the first mess.

function DoSomethingInJavaScript(s, e) {
   if (Foo.GetVisibleRowsOnPage() == 0)
      return;
   if (!s.GetChecked())
      Foo.UnselectAllRowsOnPage();
   else {
      var topIndex = Foo.GetTopVisibleIndex();
      var bottomIndex = (topIndex + Foo.GetVisibleRowsOnPage());
      var rows = $('#Foo').find('tbody:first').find('tr:first').find('td:first').find('table:first')
            .find('tbody:first').children().toArray();
      for (var i = topIndex; i < bottomIndex ; i++) {
         var row = (i + 1) - topIndex;
         var checkBoxSanityCheck = rows[row].cells[0].innerHTML;
         if (checkBoxSanityCheck != ' ')
            Foo.SelectRowOnPage(i);
      }
   }
   MyCallBackPanel_BeginCallback(null, "refresh");
}

Parse stringified JSON to an array in JavaScript/jQuery.

var checkBoxesToHide = Array.parse($('#WhichCheckboxesToHide').val());

Wednesday, May 14, 2014

more SAP notes

  1. ABAP (Advanced Business Application Programming) is the language of SAP.
  2. SAP 4.6 is quarter century old (yes, the 80s) and is no longer supported by SAP AG itself. Yet, if you are an SAP developer you may have to deal with this stuff. As you modify an existing deployment it gets harder and harder to upgrade and some companies are still trapped in the 4.6 world.
  3. Oracle has only 200 to 300 corporate entities using its Oracle eBusiness Suite ERP, but SAPs numbers are in the thousands.

add a DevExpress ASPxHyperLink conditionally to some cells of a DevExpress ASPxGridView

private void Foo_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
   if (e.DataColumn.FieldName == "FlattenedErrorList")
   {
      var errors = (string)e.CellValue;
      if (errors.Length > 0)
      {
         ASPxHyperLink hyperLink = new ASPxHyperLink();
         hyperLink.Text = "Error";
         hyperLink.EnableClientSideAPI = true;
         hyperLink.CssClass = "Whatever";
         e.Cell.Text = "";
         e.Cell.Controls.Add(hyperLink);
         e.Cell.HorizontalAlign = HorizontalAlign.Left;
         hyperLink.Attributes.Add("onmouseover", "DoSomething()");
      }
   }
}

At the Cruise Control .NET Continuous Integration Server Dashboard click on any one project to get a "Project Report."

Click on a line item beneath "Recent Builds" at the left navigation at "Project Report" to see details for the build. Then click on "View Build Log" at the left navigation to see the details for that particular build. If that particular build is breaking, you may just scroll to the bottom of the details to see where the break happens in the log. (The dashboard itself where you see a list of projects is where you may force a build with the "Force" button at a given line item.)

Tuesday, May 13, 2014

In making a brand new Visual Studio web forms project DevExpress friendly...

  1. I brought in the .dlls for DevExpress as references.
     
  2. I added this to the system.web chunk of Web.config:
    <compilation debug="true" targetFramework="4.5">
       <assemblies>
          <add assembly="DevExpress.Web.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=B88D1754D700E49A" />
          <add assembly="DevExpress.Data.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=B88D1754D700E49A" />
          <add assembly="DevExpress.Printing.v13.1.Core, Version=13.1.9.0,
                Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
          <add assembly="System.Design, Version=4.0.0.0, Culture=neutral,
                PublicKeyToken=B03F5F7F11D50A3A" />
          <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral,
                PublicKeyToken=B77A5C561934E089" />
          <add assembly="DevExpress.RichEdit.v13.1.Core, Version=13.1.9.0,
                Culture=neutral, PublicKeyToken=B88D1754D700E49A" />
          <add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral,
                PublicKeyToken=B77A5C561934E089" />
          <add assembly="DevExpress.Web.ASPxThemes.v13.1, Version=13.1.9.0,
                Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
       </assemblies>
    </compilation>

     
  3. The end of the system.web hunk of Web.config and the whole of the system.webServer stuff ended up looking like this:
       <httpModules>
          <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule,
                DevExpress.Web.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=b88d1754d700e49a"
                name="ASPxHttpHandlerModule" />
       </httpModules>
       <httpHandlers>
          <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule,
                DevExpress.Web.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx"
                validate="false" />
       </httpHandlers>
    </system.web>
    <system.webServer>
       <modules>
          <remove name="FormsAuthenticationModule" />
          <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule,
                DevExpress.Web.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=b88d1754d700e49a"
                name="ASPxHttpHandlerModule" />
       </modules>
       <validation validateIntegratedModeConfiguration="false" />
       <handlers>
          <add type="DevExpress.Web.ASPxClasses.ASPxHttpHandlerModule,
                DevExpress.Web.v13.1, Version=13.1.9.0, Culture=neutral,
                PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx"
                name="ASPxHttpHandlerModule" preCondition="integratedMode" />
       </handlers>
    </system.webServer>

     
  4. configSections in Web.config was also doctored up in another project I used as a crutch/example, but so far I am doing just fine without that gunk.

I had trouble renaming some of the DevExpress controls in a web forms application.

I would change the ID property and the new word would just sit there with red, angry text. I don't know why. I hacked around the problem by pulling the thing I wanted to change out to a .txt file, removing it from the web form, removing the tags at the top of the form which start with...

Register TagPrefix="dx"

...and then copying content back into the page with a new name.

an interesting Cassini quirk in making a copy of a solution in Visual Studio 2013

I made a copy of a Visual Studio 2013 project. I just copied the folder holding everything elsewhere and gave it a new name. When I ran the app in the debugger in Cassini, Cassini seemed to show me the files from the first solution that I copied from. This is odd behavior and I do not yet know how I empowered it. Anyways, the strangeness continued until I right-clicked on the Solution, picked "Properties" and then changed the Assembly name and Default namespace. Nasty.

Foo.Settings.ShowFilterRow = false; ...is the way to hide that row of search controls at a DevExpress ASPxGridView control from the C# side.

Foo in this example corresponds to the ID tag of a would-be ASPxGridView.

This tag allows for even rows to be different colors from odd rows in a DevExpress ASPxGridView.

<SettingsBehavior AutoExpandAllGroups="True" />

Make a column of checkboxes for selecting the rows inside a DevExpress ASPxGridView control with a checkbox for selecting all items at the column's header!

<dx:GridViewCommandColumn ShowSelectCheckbox="true" Name="CheckAll"
      Width="5%" AllowDragDrop="False" VisibleIndex="0">
   <HeaderTemplate>
      <dx:ASPxCheckBox ID="CheckAllBox" type="checkbox" runat="server"
            ToolTip="Select/Unselect all" ClientInstanceName="CheckAllBox">
         <ClientSideEvents CheckedChanged="DoSomethingInJavaScript">
         </ClientSideEvents>
      </dx:ASPxCheckBox>
   </HeaderTemplate>
   <HeaderStyle HorizontalAlign="Center" />
   <CellStyle HorizontalAlign="Center" />
   <ClearFilterButton Visible="true" />
</dx:GridViewCommandColumn>

 
 

Adding the column above will have an effect like so:

 
 

The JavaScript side is seen here. Note that Foo is the name of our ASPxGridView and MyCallBackPanel_BeginCallback is the callback event for a ASPxCallbackPanel wrapping the ASPxGridView.

function DoSomethingInJavaScript(s, e) {
   if (Foo.GetVisibleRowsOnPage() == 0)
      return;
   if (!s.GetChecked())
      Foo.UnselectAllRowsOnPage();
   else {
      var topIndex = Foo.GetTopVisibleIndex();
      var bottomIndex = (topIndex + Foo.GetVisibleRowsOnPage());
      for (var i = topIndex; i < bottomIndex ; i++) {
         if (!Foo.IsCheckBoxDisabled(Foo.GetDataRowSelBtn(i)))
            Foo.SelectRowOnPage(i);
      }
   }
   MyCallBackPanel_BeginCallback(null, "refresh");
}

At a DevExpress ASPxGridView, left align copy in numeric column types and get rid of those goofy checkboxes in boolean column types.

Let's mess with a DateTime too while we are at this...

private void Foo_HtmlDataCellPrepared(object sender, ASPxGridViewTableDataCellEventArgs e)
{
   if (e.DataColumn.FieldName == "PaymentConfigurationId")
   {
      e.Cell.HorizontalAlign = HorizontalAlign.Left;
   }
   if (e.DataColumn.FieldName == "ModifiedDate")
   {
      DateTime dateTime = (DateTime) e.CellValue;
      e.Cell.Text = dateTime.Year.ToString();
   }
   if (e.DataColumn.FieldName == "HasError")
   {
      if ((bool) e.CellValue)
      {
         e.Cell.HorizontalAlign = HorizontalAlign.Left;
         e.Cell.Text = "Error";
      } else {
         e.Cell.Text = "";
      }
   }
}

 
 

Um, wait... the goofy checkboxes will only appear if you are using a dx:GridViewDataColumn instead of a dx:GridViewDataTextColumn in which case they are intentional and not "goofy."

It seems that there IS a way to do code first Entity Framework against an existing database.

Scott Guthrie has a blog posting on it.

Monday, May 12, 2014

old school C# getsetters before the 3.0 stuff

Today we write getsetters in C# like so:

public string PendingRequest { get; set; }

 
 

These are techinically called auto-properties. The 3.0 framework uses the same compiler as the 2.0 framework so anything "new" in the 3.0 framework is really doing what it does with compiler tricks. If you look at the CLR for an auto-property you will see something like so:

private string _pendingRequest;
public string PendingRequest
{
   get
   {
      return _pendingRequest;
   }
   set
   {
      _pendingRequest = value;
   }
}

 
 

The example above is actually a C# 2.0 style getsetter, but the CLR for both this example and the example at the very top with an auto-property should look about the same. Yawn? Is that your response? Well, you should care about the old way to do getsetters because you may hack them into doing interesting things like this:

public string PendingRequest
{
   get
   {
      TimeSpan timeSpan = DateTime.Now.Subtract(WhatTimeWasItEarlier());
      return timeSpan.Days + " Day(s) " + timeSpan.Hours + " Hour(s)";
   }
}

 
 

In an example of warping a getsetter, herein I've decided I do not care about setting, just getting, so I've thrown out the set and the private field that was a backing store. I've added logic to the get to calculate a TimeSpan by substracting one DateTime from another and then I've crafted a string using the TimeSpan. This isn't the best example. A better example might be an expanded setter that sets more than the backing store field. Perhaps whenever you update FirstName or LastName on a Person the act could update FullName, etc.

Math.Floor(whatever);

...rounds down ALWAYS in C#!

Days seems to be the largest time unit in a TimeSpan type in C#.

The number in Days may be over 30. It may be in the thousands. The number of days is not the number of days since the last complete month. The months just are not measured. The number of Days is the number of full days in the window of time while TotalDays will also have a decimal and some digits for the piece of the not full "last" day bolted on to the end of the number. Hours on the other hand is not a count of all of the hours in the TimeSpan. It represents the number of full hours left in the window of time after you take away all of the full days. Days are Hours and thus calculated very differently.

Friday, May 9, 2014

When testing static methods in a static class in C# via reflection, you may just hand in null for the first Invoke parameter.

The second parameter will still populate the parameters in the method signature with its array contents.

Type type = typeof(MyStaticType);
MethodInfo info = type.GetMethods(BindingFlags.NonPublic|BindingFlags.Static)[0];
Expectations[] expectations = (Expectations[])info.Invoke(null, new object[] { "x", "y" });
Assert.AreEqual(expectations.Length, 999);

Set a contract of sorts for how big an array will be in C#.

WeddingGift[] forSally = new WeddingGift[4];

 
 

If you make an array as seen above and then later on in code make an assignment to it, you will have to hand in specifically four items like so:

forSally = new WeddingGift[4]
{
   somethingOld,
   somethingNew,
   somethingBorrowed,
   somethingBlue
}

conditionally hiding the spinner at a DevExpress ASPxCallbackPanel in ASP.NET web forms

For all of the would-be other ways I saw in Googling against this problem, I recommend using some jQuery like this upon callback:

$(".dxcpLoadingPanelWithContent_PortalDefault").attr('style', "display: none;");

 
 

Turning things back on like so however...

$(".dxcpLoadingPanelWithContent_PortalDefault").attr('style', "display: block;");

 
 

...is not recommended. It will sabotage styles that the spinner should have. The spinner will get jacked. So, plan carefully.

using HttpContext context with StructureMap

This commentary by Josh Flanagan suggests that both .HybridHttpOrThreadLocalScoped() and .HttpContextScoped() as suggested here...

ObjectFactory.Initialize(x =>
{
   x.For<IWhatever>().HybridHttpOrThreadLocalScoped().Singleton().Use<Whatever>();
   x.For<ISomethingMore>().HttpContextScoped().Singleton().Use<SomethingMore>();

 
 

...are going to try to use the HttpContext within their doings. The later has to have it or it will break and blow up. In an app I am working on we have some of this stuff going on for an implementation that uses Session and thus has to have HttpContext. I did some hand-ringing over whether or not HttpContext would be recognized if I just grabbed ahold of the IWhatever implementation in core logic far away from a code behind or controller like so:

DataProvider dataProvider = ObjectFactory.GetInstance<DataProvider>();

 
 

...but then it was pointed out to me that .Singleton() would prevent duplicate and possibly retarded StructureMap implementations of IWhatever from being spun up provided IWhatever was created with HttpContext available to begin with! In our app all code behinds in a DotNetNuke application inheirt from a base case that does the StructureMap wireups first. Clearly, HttpContext is available in that scenario.

Thursday, May 8, 2014

this equals that equals whatever

...works just fine in C#. An example:

foo.Digit = bar.Digit = 13;

 
 

In this example both foo.Digit and bar.Digit are going to end up being set to 13.

Tuesday, May 6, 2014

IHydratable is baked into DotNetNuke and it provides a way to read data into an object collection in sort of an ORM way.

using System;
using DotNetNuke.Entities.Modules;
namespace Whatver
{
   public class Foo : IHydratable
   {
      public int FooId { get; set; }
      public string Bar { get; set; }
      public bool IsBaz { get; set; }
      public string Qux { get; set; }
      
      public void Fill(System.Data.IDataReader dr)
      {
         FooId = Convert.ToInt32(dr[DALColumnNames.Foo_Id]);
         Bar = dr[DALColumnNames.Bar].ToString();
         IsBaz = !(dr[DALColumnNames.Is_Baz] is DBNull) &&
               Convert.ToBoolean(dr[DALColumnNames.Is_Baz]);
         Qux = dr[DALColumnNames.Qux] is DBNull ?
               null : dr[DALColumnNames.Qux].ToString();
      }
      
      public int KeyID
      {
         get
         {
            return DataMapID;
         }
         set
         {
            DataMapID = value;
         }
      }
   }
}

 
 

You must implement a Fill and KeyID. We do nothing with the KeyID where I work, but the Fill denotes what columns coming back from a sproc should be mapped to what fields on an implementation. If you don't use the Fill, there is another way to map with Hydratable via reflection, but it...

  1. comes with the performance hit you'd expect from reflection
  2. requires that there be no discrepancies between column names and field names

break; ...will jump you to the end of a foreach loop in C#.

This explains: you can break out of the loop by using the break keyword

If a field (not a password) on an object is sometimes encrypted and sometimes not...

...it might be wise to carry the unencrypted value in another field on the object for ease of sanity checks in saving and displaying.

NetSuite

...is yet another ERP!

Monday, May 5, 2014

position:fixed;

Imagine that the first div below was full of thousands of words of copy. How might that affect the second div?

<!DOCTYPE html>
<html>
   <body>
      <div></div>
      <div style="position:fixed; right:0; top: 100px;">
         hello!
      </div>
   </body>
</html>

 
 

It wouldn't affect the second div at all. Even as one scrolled down with the scrollbar to see all of the copy, the word hello! would still hug the right side of the browser one hundred pixels from the top.

Use SQL Server 2012 like Agent Ransack to find strings in flat files (in this case your SQL files).

Click on the icon which looks like binoculars overlaying a folder at the top navigation. This is part of the "Standard" toolbar. If you don't see this toolbar, you may just open it up anew at: View > Toolbars ...binoculars-overlaying-a-folder icon will open a search box and from there it should be obvious as to what to do next. The "Look in:" field gets the path to the folder you wish to search, etc.

Addendum 5/7/2014: by "SQL Server 2012" I really mean SSMS

Heal the "Photos" live tile in Windows 8 when it gets sickly.

Well this worked for me:

  • Go to: Control Panel > All Control Panel Items > Personalization (or right-click in open space on the desktop and pick "Personalization")
  • At the dialog box which appears go to: View > Refresh

 
 

...by "sickly" I mean that it would not display my photos.

Addendum 5/7/2014: I think you may need to select the current theme and then pick the refresh option. I keep needing to do this. I think something in my startup makes the photo tile sick.

Sunday, May 4, 2014

Medical Recordkeeping

...is a very hot domain for my line of work (building line of business applications). I've never done any work myself in this space, but I've brushed into a few interesting things. At Veterans Affairs I had a coworker who was working on an application that would seize funds from tax returns to doctors who owed Veterans Affairs money! The way these situations would arise is that a patient would visit a doctor, a doctor would get Veterans Affairs to pay for the visit, Veterans Affairs would (after the fact) realize that the doctor should have gotten Medicare to pay for the costs, and would then ask to be reimbursed for the mix-up. If a doctor did not pay up, one recourse the U.S. government had was to seize funds in would-be tax returns! In 2012, I interviewed for a job I did not get at a company which audited the records of client hospitals to try to find individuals who welched on emergency room visits who were covered by Medicare and for whom Medicare could pay their bills. Individuals who get food stamps are in fact covered by Medicare in these scenarios (mostly). If a hospital knows who these parties are, it may recover lost revenue by asking the government to pay instead of the patient.

MultiDimensional eXpressions

Wikipedia says: "The MultiDimensional eXpressions (MDX) language provides a specialized syntax for querying and manipulating the multidimensional data stored in OLAP cubes."

Thursday, May 1, 2014

Distributed Transactions in C#

...is something I'd like to learn about!

Check to see if a record exists in SQL before making an insert so as not to make a duplicate!

IF NOT EXISTS(SELECT 1 FROM dbo.Foo WHERE Foo_ID=13)
BEGIN
   SET IDENTITY_INSERT dbo.Foo ON
   
   INSERT INTO dbo.Foo (Foo_ID, Name, Description)
   VALUES (13, 'Whatever', 'blah. blah. blah.')
   
   SET IDENTITY_INSERT dbo.Foo OFF
   PRINT('record thirteen was added')
END

openssl req -new -out Whatever.csr -keyout Whatever.privkey.pem

May be run as a command line against OpenSSL for Windows to make a Whatever.privkey.pem file. This assumes that you have navigated to C:/user/local/ssl/ and that openssl.exe and openssl.cnf are both in the directory.

WinRAR is a good tool to open tarballs and zip files.

Get it here or here and use it to open .rar, .tar.gz, and .zip files.

Who may verify and who may sign?

Following up on this and this...

  • Again, a CSR authorized by a CA is a PEM.
  • With a PEM alone you may verify a request.
  • With a PEM, a private key, and a password you may sign a request.
  • The PEM and the private key may be kept together for convenience, and their togetherness is called a PFX or P12. See: this
  • Under Certificates at "the console" there should be a folder for "Trusted Root Certification Authorities" which lists all of the CAs that the computer trusts. Unless you've doctored this list all of the CAs should largely be the same from computer to computer. Go Daddy is an example of a vendor which is a trusted CA (typically). If you interface with a web site that uses both an SSL (https://www.example.com) and a trusted CA, you will not be prompted with "are you sure?" alerts. You will get the alerts if the CA is not trusted but is instead just something random.