Wednesday, April 23, 2014

VS2013 - Visual Studio 2013 References, WTF why can't I add references. (solved)



So I'm switching to Vs2013...


and I keep adding references to the project, but they don't' show up in the references list under the project.


all I can say is WTF... but I finally figured it out..


You dont' add references like you did in say... every other visual studio ever...




If you highlight the reference and hit OK... it doesn't add it.


You MUST check the checkboxes for one or more reference to get it to add (see image below)





You have to get the check box next the reference name to appear and get it checked...


the easiest way is to just double click the reference and it'll show up checked... then and only then can you add the reference..




It makes sense, now you can add multiple references in one go, unlike before.. but DAMN was it confusing to a brain that already "knew" how to do it....




Proving once again the Maxim,


It's not what you dont' know that will kill you, it's what you do know, that's not what you think it is.



Wednesday, April 16, 2014

Rotativa corrupting or "ghosting" images when converting a JPEG in HTML to aPDF document

I'm using Rotativa to generate PDFs from Html Razor views.


v1.5.0 display images correctly, but doesn't paginate correctly
v1.6.1 correctly paginates from the html, but "ghosts" the images  Per this bug:


this is because of wkhtmltopdf which has a bug... it's supposed to be fixed in the trunk, but it's not in the versions I downloaded from their page.




The workaround is to convert the JPEG to one of the other "not jacked up" image formats..


In our case we converted to PNG. There is some loss of clarity, but we can live with that.






try

{
  byte [] byteArrayIn = ( byte[] )@Model.ETA640StudentProfileVM[ currentRecord ].ImageObj;

  byte[] byteArrayOut = null;




 MemoryStream ms = new MemoryStream( byteArrayIn, 0, byteArrayIn.Length );

  ms.Write( byteArrayIn, 0, byteArrayIn.Length );

  Image returnImage = Image.FromStream( ms, true );

  using (var output = new MemoryStream())


  {
    returnImage.Save( output, System.Drawing.Imaging.ImageFormat.Png );

    byteArrayOut = output.ToArray();


  };

  @:<img src="data:image/png;base64,@(Html.Raw( Convert.ToBase64String( byteArrayOut )))" alt="Image Not Available" height="155" />

}
catch

{
  @:<img src="" alt="Error Generating Image" height="155" />


}

Thursday, March 27, 2014

Memory Leak doing alot of NHibernate processing in a loop?

Do you have a memory leak using NHibernate?


Are you doing a lot of processing in a loop, get, process, save, repeat,?


Well, firstly it's not really a leak... it's how Nhibernate works, and seeing as a leak
indicates you're probably not using NHibernate remotely how it's supposed to be used...


But then again , so are we... I have a winforms application generating reports for lots of students in a row... Once processed I'm completely done with the student and not  going back...


So I needed to flush everything out of the Nhibernate cache, both layer 1 and 2.


Now If you're going to use this realize it almost certainly means you're using Nhibernate incorrectly...
and you'd probably be better off just going back to Ado... more speed, less memory used...


But that said, here's how to flush it all


SuperFlushJcdcSessionFirstAndSecondCaches();




Ha Hah just kidding, here's the part you really want...




public void SuperFlushJcdcSessionFirstAndSecondCaches(
{

   INHFactory eFolderDocFactory = ObjectFactory.GetNamedInstance<INHFactory>( "JCDC" );
   ISessionFactory sessionFactory = eFolderDocFactory.GetFactory();

   // FROM http://stackoverflow.com/questions/2660714/how-to-clear-the-entire-second-level-cache-in-nhibernate - EWB


   sessionFactory.EvictQueries();

   foreach ( var collectionMetadata in sessionFactory.GetAllCollectionMetadata() )
   {     sessionFactory.EvictCollection( collectionMetadata.Key );
   }

  foreach ( var classMetadata in sessionFactory.GetAllClassMetadata() )
  {    sessionFactory.EvictEntity( classMetadata.Key )
  }


}



Friday, March 7, 2014

Brace Matching Hotkeys in Visual Studio...





I'm sure most of you are know about the matching brace highlighting feature in Visual Studio...


If you double click to select a brace, it's matching brace is highlighted in the same color...


Great, awesome for the file types where it works.. but what about the file types where it DOESN'T work?


Here where my tip of the <however often I decide to add tips> comes in...


In any file, say a razor view, click next to a brace, hit <ctrl>, ]... It jumps to the matching brace...


Bam,


Darn handy.


(I use resharper and the resharper keyboard settings , so YMMV, etc)

Sunday, February 23, 2014

In flow path , to add tabs you need to be sure you have set a snap to
or it will not add tabs

snap to nearest is easiest.

the tab button is the bottom on the left side closest to the draw panel, it looks like two Ls one up one down

Saturday, February 15, 2014

Flow jet cutting from an illustrator file.

There is a special export trick for exporting AI files to work in flow.

It's on page 8 of the flowjet SBU document

here it is in summary

edit_>preferences->units make sure it's inches
File-> save as-> save as .ai file
when you click save, in teh top field select "illustrator 3" as your version #
openthe file in corel draw
gott file-> export, delct DXF - AutoCad
when you select export in the top field select "autocad r10"

the segments will be disconnected bu flowpath can autopath it.