How can I learn Enterprise Library 4.0? - c#

I'm trying to learn the Enterprise Library. I found this useful code sample to get data from a SQL database. But I tried to send data via a parameter. I'm also using the UPDATE, DELETE, and SAVE methods. Can you give me a similar sample? I'm using Enterprise Library 4.0.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace WebApplicationForEnterpirires
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Database objdbase = DatabaseFactory.CreateDatabase("connectionString");
DataSet ds = objdbase.ExecuteDataSet(CommandType.StoredProcedure, "sp_GetProducts");
GridView1.DataSource = ds;
GridView1.DataBind();
}
}
}

You might find these handy
http://msdn.microsoft.com/en-us/magazine/cc188705.aspx
http://msdn.microsoft.com/en-us/magazine/cc188702.aspx
and this >>one<< which targets your situation directly (I think). Although I think what you want to do there, is pass the DbCommand object into your ExecuteDataSet method.

First of all. Go to Microsoft download center for downloading Hand-on Labs. The Hand-on Labs has all you need in side (tutorial doc, sample code, exercise...etc). Just follow each steps with tutorial of every block. Then you could totally understand how to use the Enterprise Library in just few days.

Also, check out the new Developer's Guide. It incldues code sampels in both C# and VB.
Happy learning!

Have you tried this. This gives an example on how you can use the enterprise lib. to get DataSet passing a parameter.

Related

HL7 - Parsing Specimen Source (OBR-15) using nHapi in c#

I was wondering if any wonderful person with experience of using nHAPI in C# would be able to help a newbie out with the OBR-15 field (Specimen Source) of an HL7 message? I've dug around and I can't find any documentation online to help me out, so I'd be grateful for any suggestions.
My problem is, I can't find the correct method for filling the OBR-15 field using nHAPI. I'm hoping to send an OBR segment that looks like this (I've removed data from all other fields except OBR15, so my actually message isn't as bare as this):
OBR|1||||||||||||||T034^Blood||||||||||||||||||||
I've tried every way possible to form this field with no success. I'm always getting an ampersand that appears in the front everything I'm sending, which means that the field is unreadable in downstream applications:
OBR|1||||||||||||||&T034^^^^^^&Blood||||||||||||||||||||
My OBR-15 code snippet (I've just kept the relevant stuff in here, as otherwise this section would be massive):
using System;
using System.Collections.Generic;
using System.Web.Services;
using NHapi.Model.V24.Message;
using NHapi.Model.V24.Segment;
using NHapi.Model.V24.Group;
using System.Data;
using System.Text;
using NHapi.Base.Parser;
using NHapi.Model.V24.Datatype;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Data.SqlClient;
namespace HL7WebService
{
public class HL7Reporting : System.Web.Services.WebService
{
private ORU_R01 Create_ORU_R01(Dictionary <string,string> reportData, int reportNumber)
{
ORU_R01 oruR01 = new ORU_R01();
// lots of stuff removed for clarity
ORU_R01_ORDER_OBSERVATION oruR01OrderObs = oruR01.GetPATIENT_RESULT().GetORDER_OBSERVATION(1);
OBR obr = oruR01OrderObs.OBR;
// OBR-15 Specimen Source
obr.SpecimenSource.SpecimenSourceNameOrCode.Text.Value = "T034";
obr.SpecimenSource.SpecimenRole.Text.Value = "Blood";
// lots of other stuff removed for clarity
return oruR01;
}
}
}
I'm using nHapi (v2.5.0.6) and visual studio 2015. If I've missed anything out or you require any further information, just let me know and I'll provide it. Thanks!
I solved it by declaring OBR-15 the following way:
obr.SpecimenSource.SpecimenSourceNameOrCode.Identifier.Value = "T034";
obr.SpecimenSource.Additives.Value = "Blood";

I cant get SevenZipLib library to work (p/invoke)

Very basic knowledge on c# and is the first i use anything p/invoke related.
Help me pls, i have made this code but it doesnt seem to work.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
[DllImport("C:\\Users\\lchris\\Desktop\\SevenZipLib_9.13.2\\SevenZipLib\\SevenZipLib\\7z86.dll")]
public static extern void SevenZipArchive(string c);
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
using (SevenZipArchive archive = new SevenZipArchive("file.rar"))
{
foreach (ArchiveEntry entry in archive)
{
Console.WriteLine(entry.FileName);
}
}
}
}
}
It tells me that SevenZipArchive is a 'Method' and is being used like a 'type'.
I have include the library to my project already, i just dont know how to use it.
Here is the library:
https://sevenziplib.codeplex.com/
You first need to remove this code:
[DllImport("...")]
public static extern void SevenZipArchive(string c);
You do not need to provide any p/invoke declarations. The library wraps that up for you.
This is a .net assembly. You use it just as you use any other. Take the following steps:
Download the project. You already did that I think.
Build the solution. Make sure that
In your project, add a reference to the assembly that you built in the previous stage. It's SevenZipLib\bin\Debug\SevenZipLib.dll or SevenZipLib\bin\Release\SevenZipLib.dll depending on the target you selected.
Add using SevenZipLib; to your project code to to gain access to the namespace.
Once you've done that your code will work. You can use the tests project that is supplied as part of the download as a rich source of example code.

Not able To find A Class in A namespace In c#

I am extracting images from pdf in c#.
Someone has suggested that use Aspose namespace which is a third party namespace.
I have downloaded the aspose and included in my project as a reference.But the problem is i am not able to find the class PdfExtractor which is used to extract images.
I am sharing the link in which some one has suggested to use aspose and also sharing my code.
This is a link
and my code in which i just include aspose
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Aspose;
using Aspose.Pdf;
using Aspose.Pdf.Devices;
using Aspose.Pdf.DOM;
using Aspose.Pdf.Generator;
using Aspose.Pdf.InteractiveFeatures;
using Aspose.Pdf.Structure;
using Aspose.Pdf.Text;
namespace Imageget
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}
And The class which is suggested in the link is PdfExtractor i am also sharing its code below so one can not waste his time to go to link.
PdfExtractor objExtractor = new PdfExtractor();
//bind input pdf file
objExtractor.BindPdf("input.pdf");
//extract image with specific mode
objExtractor.ExtractImage(ExtractImageMode.Default);
//check if images extracted and save them one by one
while (objExtractor.HasNextImage()) {
objExtractor.GetNextImage(DateTime.Now.Ticks.ToString() + ".jpg");
}
A first sight at google told me that you might need to add namespace:
Aspose.Pdf.Facades
Check out here and see the tree at the left.
and don;t forget to look at my comment at the top, it always help to find the namespace of class if i am unable to find it.
hope it helps!

Missing Using directive for hierarchical_grouping in MSDN crystal reports tutorial

I was working through the MSDN tutorial for Crystal Reports, and I get to the Binding the Embedded Report to the CrystalReportViewer Control step:
When I try the build, it tells me that I am missing my using declaration for Hierarchical_Grouping class. This brings up two questions for me...
What is the namespace for this class definition?
Is there an easy way of determining the namespace of a given class?
In another answer I saw the 'ALT, SHIFT, F10' and the 'CTRL, [period]' suggestions for intellisense, but they don't work in my Visual Studio.
I'm sure I have done something ridiculously stupid....sorry in advance....
Here's the code for the form:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
namespace CrystalTest3
{
public partial class Form1 : Form
{
private Hierarchical_Grouping hierarchicalGroupingReport;
public Form1()
{
InitializeComponent();
}
private void ConfigureCrystalReports()
{
hierarchicalGroupingReport = new Hierarchical_Grouping();
crystalReportViewer.ReportSource = hierarchicalGroupingReport;
}
private void Form1_Load(object sender, EventArgs e)
{
ConfigureCrystalReports();
}
}
}
I am assuming that you are referring to this tutorial.
The Hierarchical_Grouping seems to refer to the report file - which will contain the class named Hierarchical_Grouping. Have you added the report to your project?
The report should be somewhere in these Sample Reports Directories.

C# DirectX input problem

So i have simple application, just a few lines:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.DirectX.DirectInput;
namespace asdasd
{
public partial class Form1 : Form
{
public Device joystick;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
foreach (
DeviceInstance di in
Manager.GetDevices(
DeviceClass.GameControl,
EnumDevicesFlags.AttachedOnly))
{
joystick = new Device(di.InstanceGuid);
break;
}
if (joystick == null)
{
throw new Exception("No joystick found.");
}
}
}
}
and i try to get the active joystick on my computer, but i get error:
i have the assembly Microsoft.DirectX.DirectInput and i have directX SDK 2010 installed.
Can someone tell me where is the problem?
Try adding this to the config file:
http://devonenote.com/2010/08/mixed-mode-assembly-error-after-upgrading-to-dotnet-4-0/
(if configuration already exists, just merge these in)
And, maybe it's not the right place, but just take a look at XNA... Things are usually much easier with that.
I couldn't paste the XML directly here, it doesn't show up.
The DirectX assemblies are built against .NET v1.1 Microsoft stopped actively developing them before .NET v2.0 was released.
They cannot be used in projects targeting other than .NET v1.1. XNA is the "blessed" path forward for managed access to Direct X features. I don't know all if it's features, but SlimDX appears to give a more Direct X feeling API for C# than XNA, though I have not used it, I've heard a lot about it.
You might find better responses for chosing an upgrade path over at gamedev.stackexchange.com though.

Categories