How to choose the company database name of QuickBooks - silverlight-4.0

I am creating silverlight application and integration Quickbooks data using QBFC.
I am browsing company database name from silverlgiht application which is opened in Quickbooks. When i do that i am getting error like File in use.
How can I get file name from browse button which is opened in Quick-books.
I have followed below code to start the quick-book secession.
sessionManager.OpenConnection( "", "Account sample" );
sessionManager.BeginSession( Filename, ENOpenMode.omDontCare );

The BeginSession call should be replaced with the file name that the user selected with your open file dialog. I would also suggest using OpenConnection2 if you're using the newest SDK. Here's a sample, though I've not really used Silverlight:
OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "QuickBooks Files (*.qbw)|*.qbw";
if(dlg.ShowDialog() == true)
{
sessionManager.OpenConnection2("","Account sample", ENConnectionType.ctLocalQBD);
sessionManager.BeginSession(dlg.File.FileName, ENOpenMode.omDontCare);
}

Related

Dialog to pick a file name like in the "Save As" dialog in Photoshop script

Is there an API to show a dialog that allows the user to browse/create folders and either pick an already existing file or enter the name for a new one in order to save some metadata.
Something like the "Save As" dialog in Photoshop but without actually saving anything, but just retrieve the path and filename entered by the user.
Not sure about a specific API, but is this the sort of thing you're looking for?
var inFolder = Folder.selectDialog("Please select folder to process");
if (inFolder != null)
{
var fileList = inFolder.getFiles(/\.(png)$/i);
}
or
var filterFiles = 'CSV:*.csv'; // I am windows
theFile = File.openDialog ("Choose the CSV file to load from" , filterFiles);
Whereas you can reference theFile or fileList to get the file or path you're after.

Can't use a title's Class to automate Windows file upload using AutoIt

I am trying to use AutoIt for Windows file upload. I am clicking a browse button which will open file upload popup. I want AutoIt to type the location of the file and click open.
I need to use FF, Chrome, and IE for testing. I am able to get this to work if I use the Title, but the problem is that each browser has a different title. I would like to use class, as it is #32700 for all browsers. I've tried using class instead of the title, but its not working.
When I use title, everything works fine. Below is an example for Firefox. In this script, the file name is entered and open is clicked.
ControlFocus("File Upload","","Edit1")
ControlSetText("File Upload", "", "Edit1", "SomeFile.txt")
ControlClick("File Upload", "","Button1");
When I try to use class, text is not being entered and the open button is not getting clicked. There are no errors in the AutoIt script editor, so I'm not sure why this isn't working.
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");
I've also tried to add all three browser titles to 1 AutoIt script. The below script is working for Firefox and IE, but doesn't do anything in Chrome.
Local $OrgFile = "SomeFile.csv"
Local $ControlIDText = "Edit1"
Local $ControlIDButton = "Button1"
Local $Title_FF = "File Upload"
Local $Title_Chrome = "Open"
Local $Title_IE = "Choose File to Upload"
;Firefox Import
ControlFocus($Title_FF,"",$ControlIDText)
ControlSetText($Title_FF, "", $ControlIDText, $OrgFile)
ControlClick($Title_FF, "",$ControlIDButton);
;Chrome Import
ControlFocus($Title_Chrome,"",$ControlIDText)
ControlSetText($Title_Chrome, "", $ControlIDText, $OrgFile)
ControlClick($Title_Chrome, "",$ControlIDButton);
;IE Import
ControlFocus($Title_IE,"",$ControlIDText)
ControlSetText($Title_IE, "", $ControlIDText, $OrgFile)
ControlClick($Title_IE, "",$ControlIDButton);
You need to set WinTitleMatchMode option to 4 if you want to use advanced title matching (eg. CLASS).
#RequireAdmin ;Will give your script a permission elevation (sometimes its needed)
Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("WinSearchChildren", 1) ;0=no, 1=search children also
ControlFocus("[CLASS:#32770]","","Edit1")
ControlSetText("[CLASS:#32770]", "", "Edit1", "SomeFile.txt")
ControlClick("[CLASS:#32770]", "","Button1");

Create PDF file with images in WinRT

How I can create PDF files from a list of image in WinRT. I found something similar for windows phone 8 here("Converting list of images to pdf in windows phone 8") But I am looking for a solution for windows 8. If anyone of having knowledge about this please share your thoughts with me.
Try http://jspdf.com/
This should work on WinJS, but I haven't tested it. In a XAML app you can try to host a web browser control with a jsPDF-enabled page.
ComponentOne has now released the same PDF library that they had in Windows Phone for Windows Runtime. Tho it's not open source, of course.
Amyuni PDF Creator for WinRT (a commercial library) could be used for this task. You can create a new PDF file by creating a new instance of the class AmyuniPDFCreator.IacDocument, then add new pages with the method AddPage, and add pictures to each page by using the method IacPage.CreateObject.
The code in C# for adding a picture to a page will look like this:
public IacDocument CreatePDFFromImage()
{
IacDocument pdfDoc = new IacDocument();
// Set the license key
pdfDoc.SetLicenseKey("Amyuni Tech.", "07EFCD0...C4FB9CFD");
IacPage targetPage = pdfDoc.GetPage(1); // A new document will always be created with an empty page
// Adding a picture to the current page
using (Stream imgStrm = await Windows.ApplicationModel.Package.Current.InstalledLocation.OpenStreamForReadAsync("pdfcreatorwinrt.png"))
{
IacObject oPic = page.CreateObject(IacObjectType.acObjectTypePicture, "MyPngPicture");
BinaryReader binReader = new BinaryReader(imgStrm);
byte[] imgData = binReader.ReadBytes((int)imgStrm.Length);
// The "ImageFileData" attribute has not been added yet to the online documentation
oPic.AttributeByName("ImageFileData").Value = imgData;
oPic.Coordinates = new Rect(100, 2000, 1200, 2000);
}
return pdfDoc;
}
Disclaimer: I currently work as a developer of the library
For an "open source" alternative it might be better for you to rely on a web service that creates the PDF file using one of the many open source libraries available.
I think this may help you if you want to convert an image (.jpg) file to a PDF file.
Its working in my lab.
string source = "image.jpg";
string destinaton = "image.pdf";
PdfDocument doc = new PdfDocument();
doc.Pages.Add(new PdfPage());
XGraphics xgr = XGraphics.FromPdfPage(doc.Pages[0]);
XImage img = XImage.FromFile(source);
xgr.DrawImage(img, 0, 0);
doc.Save(destinaton);
doc.Close();
Thanks.

Load local HTML into WebView

Can I load a local HTML file (with images and ...) into a WebView?
Just setting the Source parameter does not do the trick.
You can load it from a file as long as the file is part of the app package, e.g.:
WebView2.Source = new Uri("ms-appx-web:///assets/text.html");
From WebView.Navigate
WebView can load content from the application’s package using
ms-appx-web://, from the network using http/https, or from a string
using NavigateToString. It cannot load content from the application’s
data storage. To access the intranet, the corresponding capability
must be turned on in the application manifest.
For a 'random' file, I suppose you could prompt user via file picker to select the file then read it into a string and use NavigateToString, but the user experience there may be a bit odd depending on what you're trying to accomplish.
I was working at this problem for a long time and I found a way to do that:
At first you should save it in InstalledLocation folder. If you haven't option to create a new .html file you can just use file.CopyAsync(htmlFolder, fname + ".html");
Look into my example:
StorageFolder htmlFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.CreateFolderAsync(#"HtmlFiles", CreationCollisionOption.GenerateUniqueName);
IStorageFile file = await htmlFolder .CreateFileAsync(fname + ".html", CreationCollisionOption.GenerateUniqueName);
and than you can easily open your .html file:
var fop = new FileOpenPicker();
fop.FileTypeFilter.Add(".html");
var file = await fop.PickSingleFileAsync();
if (file != null)
{
string myPath = file.Path.Substring(file.Path.IndexOf("HtmlFiles"));
myWebview.Navigate(new Uri("ms-appx-web:///" + myPath));
}
Remember just only from InstalledLocation you can open it with ms-appx-web:///

Associated icons blank in OpenFileDialog

I'm deploying an application built with VS 2010 Express edition via ClickOnce.
I have associated some file extensions using the options provided in the Publish section of the project's properties.
When I install the application, the associated file extension icons appear normally in Explorer but, when the user tries to open a file in my application, the associated icons appear blank.
The relative code section is the following:
Dim dialog As New OpenFileDialog
With dialog
.AddExtension = True
.CheckFileExists = True
.CheckPathExists = True
.DefaultExt = "pss"
.FileName = String.Empty
.Filter = "Data files|*.pss|All files (*.*)|*.*"
.FilterIndex = 0
.InitialDirectory = MySettings.SavePath
.Multiselect = False
.ValidateNames = True
If .ShowDialog(Me) = Windows.Forms.DialogResult.OK Then
OpenFile(.FileName)
End If
End With
I was always under the impression that OpenFileDialog is a wrapper for Explorer, but for some reason the icons don't appear correct.
Does anyone have any idea how to correct the problem?
Edit: The behaviour is only relevant to Windows 7. Windows XP behaves normally.
I believe you need to set the default view to thumbnail, so that the graphics appear for the pss files. You can check this by manually changing the view to thumbnail while running your application.
If changing the view to thumbnail shows the graphics then check the link below to achieve this:
http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/571b39c2-0edf-4159-ac8d-1c059f69a978
I forgot to change the included associated icons to:
Build action: Content
Copy to Output Directory: Always
I found this thanks to the manual updates, during which I was getting the error message "Object Reference not set to an instance of an object" during the updateCompleted event.