I am using the ComponentOne Winforms suite, specifically the FlexReport control, to generate output which will be sent directly to one of several printers. This isn't, I believe, an issue with the ComponentOne suite as I was having similar issues with Crystal.
The end result will run as a VB .Net windows service, but I am having real problems getting it to work. The current code is as follows:
Dim factory As New DatabaseProviderFactory()
Dim sysDb As SqlDatabase
Dim dsOrderList As New DataSet
Dim dsOrderDetail As New DataSet
Dim frPicklist55 As New C1.Win.FlexReport.C1FlexReport
Dim p1 As C1.Win.FlexReport.ReportParameter
Dim options As C1PrintOptions = New C1PrintOptions()
options.PrinterSettings = New PrinterSettings()
options.PageSettings = New System.Drawing.Printing.PageSettings()
'options.PrinterSettings.PrinterName = "\\printsvr\printername"
'options.PrinterSettings.PrinterName = "\\\\printsvr\\printername"
options.PrinterSettings.PrinterName = "Printer1"
sysDb = factory.Create("sys")
dsOrderList = sysDb.ExecuteDataSet("sp_apispool_getorders")
For Each r In dsOrderList.Tables(0).Rows
dsOrderDetail = sysDb.ExecuteDataSet("sp_apispool_getorder", r("order_no"))
frPicklist55.Load("D:\API Spooling Docs\Rpt55Picklist.flxr", "Picklist")
frPicklist55.Parameters("OrderNo").Value = r("order_no")
frPicklist55.Render()
frPicklist55.Print(options)
Next
Specifically, the issues are:
If I use a shared printer ('\printsvr\printername' or '\\printsvr\printername'), I get an exception about the printer settings not being valid.
If I use the local printer ('Printer1'), I get an exception -'Operation is not supported'
This should be really simple, but I suspect I am missing something fundamental. No matter what I do I get an exception at the point I call the Print function.
Any ideas?
Related
I made a function which should execute a custom ArcGIS model.
I use VB 2010 with ArcGIS 10.2. The button which should execute this function is placed on a dockable window.
Dim model As Geoprocessor = New Geoprocessor()
model.AddToolbox("D:\Chris\Van Hall Larenstein\Ruimtelijke Informatie Technologie\RPS\RPS.tbx")
Dim parameters As ESRI.ArcGIS.esriSystem.IVariantArray = New ESRI.ArcGIS.esriSystem.VarArrayClass()
model.Execute("RPS_TEST", parameters, Nothing)
There are no errors reported in VB 2010, but it doesn't work in ArcGIS. What am I doing wrong?
EDIT:
Dim pToolHelper As IGPToolCommandHelper2 = New GPToolCommandHelper
'Set the tool you want to invoke.
Dim toolboxPath = "C:\Program Files\ArcGIS\Desktop10.2\ArcToolbox\Toolboxes\Analysis Tools.tbx"
pToolHelper.SetToolByName(toolboxPath, "Buffer")
'Create the messages object to pass to the InvokeModal method.
Dim msgs As IGPMessages
msgs = New GPMessages
'Invoke the tool.
pToolHelper.InvokeModal(0, Nothing, True, msgs)
My.ArcMap.Application.CurrentTool = Nothing
Chris Driessen
If you want user define parameters than this is not the way to do it.
Your code immediately executes the model (without the parameters).
See this link on how to open geoprocessing tool dialog.
I'm trying to learn my way around VS 2013 using VB.net and its Report Viewer. I want to know how to pass a string to a parameter basically. And hopefully move on to other methods/procedures. Anyway I have a problem with this particular code block:
With Me.ReportViewer1.LocalReport
.ReportPath = "C:\Users\Kim\Documents\Visual Studio 2013\Projects\Tests\Tests\Report1.rdlc"
.DisplayName = "Test Report"
.DataSources.Clear()
End With
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.Normal)
Dim rpT As New ReportParameter("rpTitle", "Huehuehue")
Dim rpD As New ReportParameter("rpDate", "This day")
Dim HeaderParams As ReportParameter() = {rpT, rpD}
For Each param As ReportParameter In HeaderParams
ReportViewer1.LocalReport.SetParameters(param)
Next
If I comment out Dim rpD As New ReportParameter("rpDate", "This day") and change this line Dim HeaderParams As ReportParameter() = {rpT}, the rpT part will show correctly on the report form. The result is relatively the same if I exclude rpT instead. If I use both I get a Some parameters or credentials have not been specified on my report. I've been hovering around Google for sometime now but nobody else seems to have this kind of problem.
Solved it. Apparently you had to declare it as New ReportParameter() in the SetParameters. I don't know how to use an array there. But then again I'd still need to list all the parameters, so that'd be redundant. If anybody can improve this that would be great.
ReportViewer1.LocalReport.SetParameters(New ReportParameter() {rpT, rpD})
This is how I send parameter values:
1) create a generic list of type ReportParameter
2) add your new parameters to the list with a parameter name and value and visibility
3) set the parameters for the LocalReport
Dim paramList As New Generic.List(Of ReportParameter)
paramList.Add(New ReportParameter("ReportTitle", stgReportTitle, True))
paramList.Add(New ReportParameter("ReportFooter", stgReportFooter, True))
Me.vwrReport.LocalReport.SetParameters(paramList)
Always works!
I have created a report that is based on a business object - this works great. I am now trying to add a button that renders the report directly to PDF (in a winforms application).
I know what I need to do - in code I am creating a ReportViewer, setting the DataSource, specifying the report (it's an embedded resource), then rendering the report into a byte array before using System.IO.File.WriteAllBytes to flush the byte array to disk. One thing I'm hung up on though, is how do I specify the instance of the object properly? I keep getting the "An error has occurred during the report processing" error. In IntelliTrace I can see that an exception is thrown "A data source instance has not been supplied for the data source 'IssRep'" (IssRep is the dataset name in the report. Here is the code:
Dim warning As Warning() = Nothing
Dim streamids As String() = Nothing
Dim mimetype As String = Nothing
Dim encoding As String = Nothing
Dim extension As String = Nothing
Dim viewer As New ReportViewer
Dim bs As New BindingSource
bs.DataSource = issuedet
Dim rds As New ReportDataSource
rds.Value = bs
viewer.LocalReport.DataSources.Add(rds)
viewer.ProcessingMode = ProcessingMode.Local
viewer.LocalReport.ReportEmbeddedResource = "FRSFE.SR.rdlc"
Dim pdfbytes As Byte()
Try
pdfbytes = viewer.LocalReport.Render("PDF", Nothing, mimetype, encoding, extension, streamids, warning)
File.WriteAllBytes("C:\Shared\FRS\SR.PDF", pdfbytes)
Catch ex As Exception
MsgBox(ex.Message)
End Try
I'm pretty sure whatever I'm stuck on is pretty simple as I'm very rusty on .NET but I just can't figure it out!
Try setting rds.Name = "IssRep" before adding it to viewer.LocalReport.DataSources.
Im writing a silverlight application in vb.net and need to send an email via lotus notes. I wish to do this by opening the lotus notes client app, open a new email window and substitute all the necessary details (to, subject etc.) in the new email window. I am using the below code but it only OPENS the lotus notes application on the machine, it does not do anything past this. Its seems that everything after the initial CreateObject call is simply ignored, although it doesnt throw any errors. I have attempt to reference interops.domino.dll but being silverlight project visual studio states the dll is not compiled for the silverlight runtime. Any assistance with this would be greatly appreciated.
Dim outlook = AutomationFactory.CreateObject("Notes.NotesSession")
Dim notesdb = outlook.GetDatabase("", "")
notesdb.OpenMail()
Dim doc = notesdb.CreateDocument()
Dim msg = "Hey whats up"
doc.ReplaceItemValue("SendTo", "person#temp.com")
doc.ReplaceItemValue("Subject", "Hello")
Dim rtitem = doc.CreateRichTextItem("Body")
rtitem.AppendText(msg)
All you do in the moment is to create a new document in the backend and fill it with values.
It is like creating a word document without opening it...
You need some more code to actually SHOW the document you created.
In addition you need to assign a Form, otherwise Notes will not know, how to display this document:
Dim session = AutomationFactory.CreateObject("Notes.NotesSession")
Dim notesdb = outlook.GetDatabase("", "")
Dim ws = AutomationFactory.CreateObject("Notes.NotesUIWorkspace")
notesdb.OpenMail()
Dim doc = notesdb.CreateDocument()
Dim msg = "Hey whats up"
doc.ReplaceItemValue("Form", "Memo")
doc.ReplaceItemValue("SendTo", "person#temp.com")
doc.ReplaceItemValue("Subject", "Hello")
Dim rtitem = doc.CreateRichTextItem("Body")
rtitem.AppendText(msg)
ws.EditDocument( True, doc )
As I do not use silverlight I unfortunately could not test the code, but It should point into the right direction.
You can not do UI manipulations via COM in Notes, as the UI-Classes (NotesUIDocument, NotesUIWorkspace, ...) are not supported via COM.
You can only use the backend-classes likes NotesDocument, ...
This still leaves you a lot of possibilites, as you can eiter use NotesRichTextItem or MIMEEntity classes to compose e-mails.
Its 5th Question and apart of one I didn't get response from the experts....
Hope this time I will get the helping hand.
I want to do mailmerge in openoffice using Vb.net and I am totally new with openoffice.
I searched on net for some help to understand how to use openoffice with vb.net but all I get is half info.....So can you please help me and give me code for mailmerge in vb.net for openoffice.
Well i have list of workers in DB and there is this facility that if they want to mail to all or some of the workers then they can do it.I have completed this task using Microsoft Office now as a Add in we are providing the facility to perform the same task using Open Office.
What they have to do is just select the List of workers and click on a button and it will automate the mailmerge using the field of those workers data from DB. The Code of mine is as shown below
Public Sub OpenOfficeMail(ByVal StrFilter As String)
Dim oSM ''Root object for accessing OpenOffice from VB
Dim oDesk, oDoc As Object ''First objects from the API
Dim arg(-1) ''Ignore it for the moment !
''Instanciate OOo : this line is mandatory with VB for OOo API
oSM = CreateObject("com.sun.star.ServiceManager")
''Create the first and most important service
oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
''Create a new doc
oDoc = oDesk.loadComponentFromURL("private:factory/swriter", "_blank", 0, arg)
''Close the doc
oDoc.Close(True)
oDoc = Nothing
''Open an existing doc (pay attention to the syntax for first argument)
oDoc = oDesk.loadComponentFromURL("file:///C:\Users\Savan\Documents\1.odt", "_blank", 0, arg)
Dim t_OOo As Type
t_OOo = Type.GetTypeFromProgID("com.sun.star.ServiceManager")
Dim objServiceManager As New Object
objServiceManager = System.Activator.CreateInstance(t_OOo)
Dim oMailMerge As New Object
oMailMerge = t_OOo.InvokeMember("createInstance", Reflection.BindingFlags.InvokeMethod, Nothing, _
objServiceManager, New [Object]() {"com.sun.star.text.MailMerge"}) 'com.sun.star.text.MailMerge"})
oMailMerge.DocumentURL = "file:///C:\Users\Savan\Documents\1.odt"
oMailMerge.DataSourceName = CreateSource(StrFilter)''Function that will return the datasource name which will be a text file's path
oMailMerge.CommandType = 0
oMailMerge.Command = "file:///C:\Mail.txt"
oMailMerge.OutputType = 2
oMailMerge.execute(New [Object]() {})**---->I am getting Error here**
End Sub