Has anyone connected BizTalk with QuickBooks? - biztalk

We use QuickBooks for financial management, and feed it from a variety of sources. I now need to hook it up to BizTalk, and I'd hate to reinvent the wheel. I've done searches, and as far as I can tell there's no QuickBooks adapter for BizTalk. Does anyone know of anything that'll do the job, preferably something that doesn't suck?
Doesn't the QB SDK require that Quickbooks be running on the client machine? Is there any way around it?

Quickbooks talks .NET quite easily. You'll need the QuickBooks SDK 7.0 and a copy of Visual Studio.NET, but after that it's very easy to do anything with Quickbooks.
Imports QBFC7Lib
Sub AttachToDB()
If isAttachedtoQB Then Exit Sub
Lasterror = "Unknown QuickBooks Error"
Try
QbSession = New QBSessionManager
QbSession.OpenConnection("", "Your Company Name")
QbSession.BeginSession("", ENOpenMode.omDontCare)
MsgReq = QbSession.CreateMsgSetRequest("UK", 6, 0)
MsgReq.Attributes.OnError = ENRqOnError.roeStop
Lasterror = ""
isAttachedtoQB = True
Catch e As Exception
If Not QbSession Is Nothing Then
QbSession.CloseConnection()
QbSession = Nothing
End If
isAttachedtoQB = False
Lasterror = "QuickBooks Connection Error. - " + e.Message + "."
End Try
End Sub
See http://developer.intuit.com/ for more information.

If you do build the integration code using .NET, you may want to consider leveraging the WCF Line-of-Business SDK:
http://www.microsoft.com/biztalk/technologies/wcflobadaptersdk.mspx
It's not a BizTalk-only technology, despite its categorization. The SDK is designed to make it easier to create a WCF channel to a LOB application, which can be consumed from almost any other platform.

Unfortunately it does. It also asks you to authorise any application you've built. (at least once.)
I don't know any way around it.

The QB SDK does not require that QuickBooks be running on the client machine. It does require that QuickBooks is installed on the client machine. You can access QuickBooks company files even if QuickBooks is not running though.
Have a look through the SDK docs. Additionally, when QuickBooks first prompts you to authorize the application, you need to make sure to tell it to allow access to the company file, even when QuickBooks isn't open/the company file isn't open.

Related

Send email with Outlook 2016 from ASP.NET

I need to send emails but preview them first before sending. I am using Visual Studio 2019 and my Outlook version is 2016 32-bit on a Windows 10 development machine.
I get an error
FileNotFoundException: Could not load file or assembly 'office, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. The system cannot find the file specified.
Yet I installed the COM libraries via browse to C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Tools.Excel.v9.0\15.0.0.0
I use Outlook version 16 and from what I can tell there is no version 16 of the COM library.
Is there another way to get this working?
private void SendEmail()
{
try
{
Outlook.MailItem mailItem = (Outlook.MailItem)this.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Subject = "This is the subject";
mailItem.To = "someone#example.com";
mailItem.Body = "This is the message.";
mailItem.Importance = Outlook.OlImportance.olImportanceLow;
mailItem.Display(false);
}
catch (Exception eX)
{
throw new Exception("cDocument: Error occurred trying to create an Outlook e-mail"
+ Environment.NewLine + eX.Message);
}
}
This is the VB code I used to run Outlook on local machine.
Public Sub SendEmail(ByVal sTo As String, ByVal sSubject As String, ByVal sBody As String)
Try
If Not Process.GetProcessesByName("OUTLOOK").Any() Then
System.Diagnostics.Process.Start("Outlook.exe")
End If
'Dim oApp As Outlook._Application
'oApp = New Outlook.Application()
Dim oApp As Object
' Create a new MailItem.
'Dim oMsg As Outlook._MailItem
Dim oMsg As Object
Const olMailItem As Long = 0 'à commenter si marche pas
oApp = CreateObject("Outlook.Application") 'à commenter si marche pas
'oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
oMsg = oApp.CreateItem(olMailItem)
oMsg.Subject = sSubject
oMsg.Body = sBody
' TODO: Replace with a valid e-mail address.
oMsg.To = sTo
' Send
oMsg.Send()
' Clean up
oMsg = Nothing
oApp = Nothing
Catch ex As Exception
Debug.Print(ex.ToString)
End Try
End Sub
Is this really asp.net and a web based application???? You do realize the VAST difference between windows desktop software and web based, right? You can't use or display or show ANYTHING from a desktop program in a client side web browser. I have to assume you taking about desktop ONLY software here, and not web based? I mean, even if you could use Outlook in code, it would run on the web server, and the user would not see outlook running on that one web server computer box, would they?
And you certainly can't use and launch Outlook on the end user's client side machine. I mean, it would be really cool then if you come to my web site to view a cat picture, and I can now use YOUR copy of outlook, or Excel. Hey, why not launch your banking application and steal all that information? Or search your local hard drive for a Excel sheet called passwords? If you think about this, if that was possible, then ZERO people would EVER risk using the internet, right?
so, you have ZERO ability to use or mess with MY computer. You can't even search or look for a file on MY computer. It is my computer, and if just going to some web site could let you mess IN ANY WAY with my computer would be the worlds largest security hole.
You can certainly put up a nice big text box, even a send to box as a web form or web page. But sending that email will be based on YOUR own email settings and account that you setup on the web site. I mean, you think that YOUR web site is going to use MY email system and email password and information? Really? So I can now use YOUR software on YOUR computer from my web site? You really have to stop and think about what you asking? As noted, if you think about this, then you will well realize that this type of approach to web software is not possible, but it should ALSO be VERY obvious that such operations with web software could not be possible, since if it was, then no one would ever risk or even consider using the internet to do anything.
Even when you use a up-load file control, you can NEVER EVER even set the file to be picked for up-load - only the end user can do that. Your server side software cannot touch, see, know ANYTHING about the client side computer. Besides, that client computer might be a iPad, a smartphone, or your Apple Mac computer anyway - you have no idea, can't have any idea, and it can't matter.
so, client side software and files are 100% hands off. The end user has a browser sitting on their desktop. You can ONLY send it some HTML for that browser to then display.
And trying to use server side software? Well, if you did manage to do that, then on the server you would see outlook pop up on the computer. But the end user? They would not see anything - since you not able to see and use software.
It would be cool when you go to buy something on amazon, that you web browser lets YOU mess around with software on THEIR web server??
All you can do with a web system is create a web page and pass it down to the end user, and their browser will THEN render and display the markup. What you run on that web server (which is just a computer) is up to you, but you ONLY have the ability to pump out some HTML down to the users browser - nothing more, nothing less. Any windows program launched on the web server would only be seen if you were sitting at the console on and at the web server.
so, what would I do for a template? I would toss up a text box, or web form, and SAVE some template say to a database.
And if you REALLY smart you adopt ckedit, or a screen that allows you to enter markup. So, now you can drop in any graphics or fonts or whatever.
Say like this:
So, what I do with above is "save" my email templates into a database. I then have a simple routine that search/replace the fields like [Email] with the data from the database. So fonts, graphics etc? I can just edit and build and cut + paste in graphics.
But, I certainly can't really use outlook for this purpose. And the "sending" email address will have to be one for the web site - it can't be any old sending email.

SignalR not working correctly after deployment on windows server 2012

I am facing issues in live environment. When ever a ever a page is loaded signal r connection is created but connectionids of other connects are not available for the new connectionids and also for old connectionId this newly created connection is not available. To make it better understand see the code below
My method in chathub.vb which is called from server side
Public Sub getGonnected()
Clients.Client(Context.ConnectionId).hello("Connection is connected CONNECTIONID = " + Context.ConnectionId)
Dim heartBeat = GlobalHost.DependencyResolver.Resolve(Of ITransportHeartbeat)()
Dim connectionAlive = heartBeat.GetConnections().Where(Function(c) c.ConnectionId <> Context.ConnectionId).ToList()
Clients.Client(Context.ConnectionId).hello("Other Connections Available ..............................................................")
For Each item In connectionAlive
Clients.Client(Context.ConnectionId).hello(".................................................................. " + item.ConnectionId)
Next
Clients.Client(Context.ConnectionId).hello("End of other connections available ........................................................")
Clients.All.hello("Total Number of users available ..................................................................")
Clients.All.hello("........................................................................... " + connectionAlive.Count().ToString())
Clients.All.hello("End total Number of users available ...............................................................")
End Sub
And in my clients side
chat.client.hello = function(ping)
{
console.log(ping);
}
$.connection.hub.start().done(function () {
});
setInterval(function () {
chat.server.getGonnected().done(function (result) {
console.log('connectionRequestsent')
});
}, 5000);
Also in my web.config I have added following settings
target framework 4.5
As per above example code above
I am not able to see a new connection in the borwsers console when some new user registers will signalr. And also that new user is unable to see the ConnectionId's of already present users in signalr in the browser console.
This thing is only happening on server. An help would be much appretiated. I have already enabled websockets and my websockets handshake is successfull. Moreover the spefic conntectionId is able to send and recieve messages to and from server. But not with other connectionId as the are not availble.
In simple words some times
Dim connectionAlive = heartBeat.GetConnections().Where(Function(c)
c.ConnectionId <> Context.ConnectionId).ToList()
Length is 0 where as there are already other connections in the app. Which I am not sure why is happening.
Any help or guidance will be much appreciated.
SignalR version is 2.1.0
Regards
Abdul
I don't think this has anything to do with WIndows Server 2012. You will have to implement this yourself in either a dictionary, database or something else suitable to your situation.
Using the OnConnect event, you can broadcast to every currently connected client an update that someone has joined or with the OnDisconnect that someone has left as well. If you want it to be a list of currently connected users you would query your dictionary/database/else... and broadcast.
SignalR Documentation has some examples.
Download working signalr project at https://github.com/aspnet/SignalR-samples from the developer
After downloading select any of the examples in the directory which you will run through your visual studio.
I select ChatSample run and follow the on-screen instruction
After that go through the documentation to read through each files how it works at
https://learn.microsoft.com/en-us/aspnet/core/signalr/
Please install the latest version of .Net Framework, in my case this solve the problem, I installed 4.8 and all broadcast messages were sent.

COM Exception for client-side object called by Classic ASP page

I have tricky problem, which I'm struggling quite a bit with.
The current solution, consists of a Classic ASP site hosted on some Win2K3 server, that calls some Client-side DLL's on XP machines coded in VB6.
These client-side DLL's then again can call some other COM objects, in this particular case it calls IBM Louts Notes (Lotus Domino Objects 1.2).
Now for different reasons these DLL's has to be converted to .NET (still x86), at this stage, this is the only change to be done. This works quite well except for one piece of code which throws an error.
COMException when calling the Lotus Notes COM object
ASP script calling the DLL
Set objLotus = CreateObject("OpenLotusNotes_FU_v2.clsMain")
sRet = objLotus.OpenLotus_mail()
Client-side DLL
Dim session As NotesSession = New NotesSession() 'works well
Dim objNotesWrkSp As Object
objNotesWrkSp = Activator.CreateInstance(Type.GetTypeFromProgID("Notes.NotesUIWorkspace")) 'crashes
Exception
Retrieving the COM class factory for component with CLSID {29131502-2EED-1069-BF5D-
00DD011186B7} failed due to the following error: 80080005
Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
When I try to run this code in console application on the same computer, it works. So it has to be some permissions(?), I have tried changing basically everything I can think of.
Any help would be much appreciated!
Updated 01.09.2014
What I see is when I trigger the code from ASP, is that it creates a new process of Notes everytime, but only in the background, no UI what so ever. When I trigger the code from a console application, I get the Notes UI, which asks me for password, if I don't already have notes running.
I believe that I'm getting the Exception because it eventually times out.
Have a read of this article , your dealing with an Out Of Process COM component which may not initialize properly for some reason.
Another possibility is that the COM threading model is not supported in a free threaded component which .NET is by default compiled with. You can compile you DLL with a STA attribute, but as far am I'm aware that only effects console applications. You might find some additional information in this article from MS, if you have not already read it of course. Hope something there helps you solve your problem.
Consult with your admins first, but for this scenario you can set no password for the ID the Lotus Notes uses.
I did resolve this, so if anyone else would run in to this…
First of all configure the “Notes Link” Component Service to run as a “The interactive user” and that the process owner has permissions in "Launch and Activation Permissions" and "Access permissions".
Then this should be possible
Dim objNotesWrkSp As Object
Dim objWorkspace As Type = Type.GetTypeFromProgID("Notes.NotesUIWorkspace")
objNotesWrkSp = Activator.CreateInstance(objWorkspace)
As it turned out in this particular case I could only get it to work with late-binding, when I tried to this it just opened a conhost.exe process and then never responed:
Dim session as New NotesSession
session.Initialize()
Among other similar issues... So then I only used late-binding for all communication with Notes.
Dim mailServerPath, mailFile As String
objWorkspace.InvokeMember("OpenDatabase", Reflection.BindingFlags.InvokeMethod, Nothing, objNotesWrkSp, New Object() {mailServerPath, mailFile})
And so on...

Programming a Web Portal for Microsoft Dynamics CRM

I'm working on a web portal for customers that will connect to Microsoft Dynamics. I don't want to make Dynamics CRM directly a internet facing deployment (IFD), so I'd like to use a separate database that the web interface interacts with and then use web services to move the data between the web portal database and Dynamics CRM.
I'm just looking for thoughts on whether this is the best way to proceed and whether there are any good code examples, etc. that I can look at for implementing this?
I saw Microsoft has a Customer Portal but it looks like it requires (at a cursory glance) an IFD deployment - which I don't want.
First, after creating your ASP.NET project (WebForms or MVC 3), add the following references:
Microsoft.crm.sdk.proxy.
Microsoft.xrm.sdk.
System.Runtime. Serialization.
System.ServiceModel.
In your code-behind Create a class then add the following code:
private IOrganizationService GetCrmService(string userName, string password, string domain, Uri serviceUri)
{
OrganizationServiceProxy _serviceProxy;
ClientCredentials credentials = new ClientCredentials();
credentials.Windows.ClientCredential = new System.Net.NetworkCredential(userName, password, domain);
//credentials.UserName.UserName = userName; // uncomment in case you want to impersonate
//credentials.UserName.Password = password;
ClientCredentials deviceCredentials = new ClientCredentials();
using (_serviceProxy = new OrganizationServiceProxy(serviceUri,
null,
credentials,
deviceCredentials))
{
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
return (IOrganizationService)_serviceProxy;
}
}
If you want to retrieve multiple records:
string fetch = #"My Fetch goes here";
EntityCollection records = getCrmService().RetrieveMultiple(new FetchExpression(fetch));
I highly recommend to download the SDK or check this
You'll find many samples and walkthroughs which will help you to build good portals.
I think it's a good strategy because:
It allows you to asynchronously put the data entered on the website into the CRM. This decoupling ensures neither the CRM nor the Website will become eachother's bottleneck.
Only the intermediate service layer is internet facing, so you'll be in control over what CRM information would be disclosed/open for alteration if this service layer is compromised.
The architecture you're after is reminiscent of the way the CRM Asynchronous Service works (asynchronous plugins and workflows work this way).:
A job is put in a queue (table) in the CRM DB.
A scheduled service awakes every x seconds and fetches the latest y records from the queue table.
The service performs each job and writes the result (success, error message log) back to the queue table's records.
So the thing that is probably hardest is writing a good scheduled service that never throws an exception (but always digests it) and properly logs the results back to the DB.
To learn more about the Dynamics CRM's "Asynchronous Service Architecture", refer to the following: http://msdn.microsoft.com/en-us/library/gg334554.aspx
It looks like a good approach.
It will improve the performance of both the portal and CRM.
The data shown on portal is NEARLY realtime. i.e it is NOT realtime.
Throughout the development, you better keep checking that there is not TOO MUCH async processing to keep the CRM server busy all time.
I don't think, that the accelerators/portals REQUIRE CRM to be an IFD instance, I guess only the portal part needs to be Internate facing (of course to make it usable for the purpose!)
Anwar is right, SDK is a good lauchpad for such research.
Customer Portal Does not require IFD deployment. And if you do not like the Customer Portal you can always use SDK Extension for Portal development (microsoft.xrm.client.dll & microsoft.xrm.portal.dll and portalbase solution) which are all included in SDK.
There is a great resource regarding how to build portal by using SDK Portal Extenstion.
Dynamics CRM 2011 Portal Development

asp.net run program with Administrator account

I need to run one console application from ASP.NET application using Administrator account and with Desktop interaction enabled. I have tried code below, console app runs ok but within NETWORK SERVICE account. Any ideas how to run console under Administrator account?
string enginePath = Server.MapPath(#"~/engine/MyConsole.exe");
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(enginePath, "");
System.Diagnostics.Process p = System.Diagnostics.Process.Start(info);
p.WaitForExit();
Regards,
Tomas
you could use impersonation, there is an example here
personally i dont like impersonation in asp.net, you need to deal with passwords either not being changed or changing them in code. Is there no way to run what you want as the asp.net user?
edit:
You could acyually impersonate the network service by using "NETWORK SERVICE" as the user name, that would at least allieviate the password issues a little,
Another user already suggested impersonation. If that's good enough, there you go. Like he said, though, there are some maintenance headaches to deal with and some security implications.
Some options that I've used in the past which may or may not be applicable in your situation are:
If the task is on a predictable schedule, just add it to the Scheduled Tasks in Windows, set the appropriate worker account (Administrator, or whatever), and let 'er go. I believe there are also ways to programmatically trigger a scheduled task, but I've never had to do that. A Google search should get you going.
Implement the console app logic as a service running under the appropriate account. Then have the service listen for a "trigger" from your web app--a file drop or something simpler.
Either way the idea is to avoid storing any credientials in your ASP page, and to not have to grant that process rights it doesn't need.
You can use a manifest file and built it into your console application that will instruct it to always run under an admin account. See this example.
If this doesn't work for you then you could try passing in Admin account credentials in the ProcessStartInfo property e.g.
string enginePath = Server.MapPath(#"~/engine/MyConsole.exe");
System.Diagnostics.ProcessStartInfo info = new System.Diagnostics.ProcessStartInfo(enginePath, "");
info.UserName = "Administrator";
info.Password = "Password";
System.Diagnostics.Process p = System.Diagnostics.Process.Start(info); p.WaitForExit();

Resources