I would like to ask if anyone knows the thing that i want to do:
I have a report in microsoft report server that's waiting for a parameter (person_id) to make the fulfill.
I need to send an email with the report of each person_id. I need to run a function that runs my report called per_permissions.rdl download it and attached the file to send it by email. Example in vb.net code
strSql = "SELECT per_id,per_email FROM person"
dt_person = getDataTable(strSql)
For each dr_person As DataRow in dt_persona.Rows
attached_file = mysticFunction(dr_person("per_id"))
...
Next
Public Shared Sub DownloadFile(ByVal _URL As String, ByVal _SaveAs As String)
Try
Dim _WebClient As New System.Net.WebClient()
_WebClient.DownloadFile(_URL, _SaveAs)
Catch _Exception As Exception
Console.WriteLine("Exception caught in process: {0}", _Exception.ToString())
End Try
End Sub
Yes, it is fairly simple. Using the ReportExecutionService.Render method you can render the report however you want. We've used this to run reports and attach them to emails automatically.
The MSDN site has some code to get you started.
To add a reference to the report execution web service, right-click References, select Add Service Reference... and add a reference to the web service that will look something like:
http://MyReportServer/ReportServer/ReportExecution2005.asmx
You will also need the report service web service, which is:
http://MyReportServer/ReportServer/ReportService2005.asmx
Related
I searched many times in this topic but with no luck, I have an application on WPF that use Click Once to published and there fore I can't use Admin Privilege, and I need to implement some actions in the installation Process like restart SQL server for example and for that I need Admin Privilege and since i start publishing using click once I had to remove Admin Privilege now, i tried restart my application to force Admin rights using the following code but didn't work
Public Function IsRunAsAdmin() As Boolean
Try
Dim id As WindowsIdentity = WindowsIdentity.GetCurrent()
Dim principal As WindowsPrincipal = New WindowsPrincipal(id)
Return principal.IsInRole(WindowsBuiltInRole.Administrator)
Catch __unusedException1__ As Exception
Return False
End Try
End Function
Public Sub AdminRelauncher()
If Not IsRunAsAdmin() Then
Dim proc As ProcessStartInfo = New ProcessStartInfo()
Dim procExecuting As New Process
proc.UseShellExecute = True
proc.WorkingDirectory = Environment.CurrentDirectory
proc.FileName = Assembly.GetEntryAssembly().CodeBase
proc.Verb = "runas"
Try
procExecuting = Process.Start(proc)
Application.ExitThread()
Application.Exit()
Catch ex As Exception
Console.WriteLine("This program must be run as an administrator! " & vbLf & vbLf & ex.ToString())
End Try
End If
End Sub
I still get the Error "Can not open MSSQL$****** on computer" after i searched of course i found the cause is admin rights needed.
So now i'm working on Code Signing Certificates as some one advise me that this will work for me.
but i'm an individual and my application price is not high enough to buy a paid certificate so i was wondering if i can make a self Code Signing Certificate and use it with click once.
Thank you.
I finally manged to figure out the problem my self, it was the admin rights.
The problem was that the code simply need like 2-3 mile seconds to execute so when i tracked the code i found that my code manged to stop the service indeed but wasn't able to start it again as it didn't take the time for the service to fully stop.
The solution was simple as it just needed couple of seconds to after it execute the code to stop the service.
So simply need to add a code in between.
First
Imports System.Threading
Then use the code as following
Dim service As ServiceController = New ServiceController("SQL Server (SQLEXPRESS)")
service.Stop()
Thread.Sleep(10000)
service.Start()
You see the code where Thread.sleep is make the application wait 10 seconds before it complete to execute the code.
This time is depends on the machine it self, 2-3 sec was enough but some other machine needed more time so to be in the safe side just add more seconds as I did.
Thank you, and "Stay Safe".
I have built an application that obtains details from a web service and displays them in a GUI for the agent to see.
I've had instances of problems occuring, sometimes an exception due to a change in how the data is received due to the provider and unfortunately no user lets me know this occurs, they just click through and pay no attention to the error.
I've built a custom form to capture the error and then email it to me with some details like username etc. etc.
I would ideally LIKE to capture the screen of the application as well, much like an ALT+PRINTSCRN so I can see what the application looks like at the time of error as well.
How possible is this?
Assuming WinForm, I've done this before:
Public Sub SaveAsImage(frm As Form)
'Dim fileName As String = "sth.png"
'define fileName
Dim format As ImageFormat = ImageFormat.Png
Dim image = New Bitmap(frm.Width, frm.Height)
Using g As Graphics = Graphics.FromImage(image)
g.CopyFromScreen(frm.Location, New Point(0, 0), frm.Size)
End Using
image.Save(fileName, format)
End Sub
When being called, it will capture the current screen in the area defined by frm and save to a file.
I am new to a Notes environment, so I've spent a lot of time reading here and other forums in an attempt to learn how to VBA an email via Lotus/IBM Notes.
There seems to be 2 main approaches; I am using the NotesUI method, since one of the requirements for the email is to embed an image of a portion of the Excel worksheet, as well as attaching the file itself.
At this stage, I have functioning code which achieves this (more often than not!) from the email address of the person who runs the macro. I can claim no credit for this - it has been borrowed with gratitude from the web.
However, the team has a shared email account, from which I wish to send the email.
I have seen some discussion of Principal and being able to specify a FromName, but I've so far been unable to achieve this last part.
The code I am using to successfully send an email with an attachment and an image of a section of my worksheet is below - and tips on how to modify the existing code to send from another email address would be most welcomed!
Sub SendEmbedMail(mailTo As String, stSubject As String, _
copyData As Range, Optional msgBeforeEmbed As String, _
Optional msgAfterEmbed As String, Optional attachFile As Workbook)
Dim Notes As Object, db As Object, WorkSpace As Object
Dim UIdoc As Object, UserName As String, MailDbName As String
Dim AttachMe As Object, EmbedObj As Object
'Create & Open New Document
Set WorkSpace = CreateObject("Notes.NotesUIWorkspace")
Call WorkSpace.COMPOSEDOCUMENT(, , "Memo")
Set UIdoc = WorkSpace.CURRENTDOCUMENT
Call UIdoc.inserttext(mailTo)
Call UIdoc.gotofield("Body")
Call UIdoc.inserttext(msgBeforeEmbed)
copyData.CopyPicture
Call UIdoc.Paste
Call UIdoc.inserttext(msgAfterEmbed)
Call UIdoc.gotofield("Subject")
Call UIdoc.inserttext(stSubject)
If Not attachFile Is Nothing Then
Set AttachMe = UIdoc.Document.CreateRichTextItem("Attachment")
Set EmbedObj = AttachMe.EmbedObject(1454, vbNullString, _
attachFile.FullName, "Attachment")
End If
Call UIdoc.Send(0, mailTo)
End Sub
Writing the document directly to the server's mail.box file is often used as a solution for this. See the first answer to this question, and look at the code of the OpenNTF Team Mailbox project for more details. Doing this generally won't completely remove the sender's info from the message, though. (It may vary depending on the Notes and Domino versions, but Notes has never been fully cooperative with spoofing attempts done this way.)
If you want to completely hide the identity of the sender, the approach that works best is to use an agent running on the server to send the message - or in your case, to re-send it. The agent can be signed by a generic Notes id instead of the developer's or the server's id, so by the time the actual send to the actual recipient occurs, the end-user isn't part of the process. In your case, you could accomplish that by creating a mail-in database and changing your VBA code from Call UIdoc.inserttext(mailTo) to Call UIdoc.inserttext("My mail-in database name goes here") but you'll also have to put your mailTo value somewhere, otherwise the agent won't know where to re-send it. You can do that by adding a line of code like this:
Call UIdoc.Document.ReplaceItemValue("actualRecipient",mailTo)
Your agent can be set up to run after new mail arrives in the mail-in database, and it can then clean up the message by removing the From and ReplyTo and INETFrom (if they exist - see here) items, and setting the SendTo and Principal and INETFrom fields. Omitting the basic framework code for the agent (some examples here) and assuming that doc is the variable that contains the NotesDocument that you are re-sending, the actual working part of the agent could be similar to this:
doc.RemoveItem("From")
doc.RemoveItem("InetFROM")
doc.RemoveItem("ReplyTo")
if doc.hasItem("actualRecipient") then
doc.ReplaceItemValue("SendTo",doc.actualRecipient(0))
doc.RemoveItem("actualRecipient")
else
' here you'll want to do something sensible if a message arrives in the mail-in
' database but it doesn't have an actualRecipient; i.e., it wasn't sent by your
' VBA code!
End if
Call doc.ReplaceItemValue("Principal","support#company.com#Your Notes Domain Goes Here <support#company.com>")
Call doc.ReplaceItemValue("INETFrom", "support#company.com")
Call doc.Send()
You could also do this using back-end classes (not UI). I wrote a class to help with creating emails, it includes changing the from-address to anything you like:
http://blog.texasswede.com/lotusscript-mail-notification-class/
You just have to add a method to insert a picture in the text, you can use the approach described by Thomas Hampel at http://blog.tomcat2000.com/blog/tomcat2000.nsf/dx/notesapi-import-pictures-into-richtext-fields-using-backend-classes.htm.
I am using visual studio 2010 to develop my desktop application and ms access database. I have already designed reports in access database and they are working perfectly. Now my concern is that is it possible to use these access reports in my Vb.Net application?
I need this because it would be much easier to distribute the software instead of using crystal report where I will need to install a run time machine for crystal reports.
It's possible to do but it's a horrible implementation. You basically have to launch Access, open the database file in Access, then navigate down and launch the report. There is no way to just "view" the report inside your app. It will only show inside Access.
I think your best option is to use ReportViewer control if you don't want to use Crystal Reports.
I found this: https://support.microsoft.com/kb/317113?wa=wsignin1.0
To preview or to print an Access report, you call the OpenReport method of the DoCmd object. When you call OpenReport, one of the arguments that you pass determines whether the report is previewed on the screen, or whether it is sent to the printer:
' Preview a report named Sales:
oAccess.DoCmd.OpenReport(ReportName:="Sales", View:=Access.AcView.acViewPreview)
' Print a report named Sales:
oAccess.DoCmd.OpenReport(ReportName:="Sales", View:=Access.AcView.acViewNormal)
But I haven't been able to find much info/help regarding OpenReport method or DoCmd object.
I am not a proffesional developer, but after long research it's worked for my project.
I would like to open directly from MS Access, my existing reports and then to open these from not default installation folder path (different for each one pc). The third requirement was to open more than one report (Not all together).
Design:
Form8.vb [Design]
vb.Net Code:
Imports System.ComponentModel
Imports Microsoft.Office.Interop.Access
Public Class Form8
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oAccess As New Microsoft.Office.Interop.Access.Application()
Dim CurDir As String = System.AppDomain.CurrentDomain.BaseDirectory
Dim FPath As String = CurDir & "\YourDatabase.accdb"
oAccess.Visible = True
oAccess.OpenCurrentDatabase(FPath)
If ComboBox1.Text = "Your text" Then
oAccess.DoCmd.OpenReport(ReportName:="Your Report Name", View:=AcView.acViewPreview)
ElseIf ComboBox1.Text = "Your text2" Then
oAccess.DoCmd.OpenReport(ReportName:="Your Report Name", View:=AcView.acViewPreview)
ElseIf ComboBox1.Text = "Your text3" Then
oAccess.DoCmd.OpenReport(ReportName:="Your Report Name", View:=AcView.acViewPreview)
End If
End Sub
End Class
Replace YourDatabase with YourDatabaseName, Replace Your text,Your text1,Your text2,Your text3 with YourText, Replace Your Report Name with the Name of your report Name, As needed.
Finally, in order for this solution to work, you need:
1) Your (Conn.open) connection to look like this:
Dim dbsource As String = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = |DataDirectory|\Your DB.accdb"
2) In Solution Explorer, Your database to include in your project or to your setup project, to be installed with your project. like this:
Solution Explorer [image]
SetUp Project link
3) At server explorer, Data Connection the (Sourse) Database file name, must be with the full path name e.g like this:
C:\Users\User\Desktop\YourDatabase.accdb, and the connection String at the Properties like this:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source = "C:\Users\User\Desktop\YourDatabase.accdb".
I hope this helps!!!
The following code:
Preview a report named Sales:
oAccess.DoCmd.OpenReport(ReportName:="Sales", View:=Access.AcView.acViewPreview)
Print a report named Sales:
oAccess.DoCmd.OpenReport(ReportName:="Sales", View:=Access.AcView.acViewNormal)
But I haven't been able to find much info/help regarding OpenReport method or DoCmd object.
This will only work if you are using VB.Net to automate the Access application. This will open the Access application and allow you to view or print the reports just as if you were running Access directly. However, you need to have the Access application (not just the .mdb or .accdb file) on the computer that is running the VB.Net application.
I have not found any way to utilize the Access reports without having Access on the computers running the VB.Net application. I'm looking into using Crystal Reports for the application I'm working on now.
I have an SSIS package that detects test domains from a data set being passed through the pipeline. I use a Scripting Component to send an e-mail notification listing the domains that have been marked as test domains. When I first posted the package with the notification, it sent a separate e-mail for each domain, after receiving to many e-mails, I changed the script to send a single e-mail with a list of the test domains. However each time I publish this update, it continues to send a single notification for each test domain.
Things I have looked into:
The content of the first e-mail and the second e-mail are different. So I did a "Find in Files" search in Notepad++ to see if I could find where the original e-mail content might be stored. There were no results found containing the original content.
I have disable the step which sends the notifications and published the package. This results in no notification e-mails being sent. However when I re-enable the step and publish, the original notifications sending a single e-mail for each test domains starts again.
I have tried dropping the SQL job that executes this package and recreating it but still the original notifications come through.
So with no trace of the original content even found on the production server, I do not know where this is coming from. I don't see anything about where the content could be cached, but even if it was being cached, then when I disabled the notification step, it would have still sent the notifications.
I am worried that if this can't be fixed, then does this mean there are other packages that are not being fully updated?
Any ideas or help would be greatly appreciated.
This is pretty much how the Scripting Component is setup...
Public Class ScriptMain
Inherits UserComponent
Private strDomains As String = String.Empty
Public Overrides Sub PreExecute()
MyBase.PreExecute()
End Sub
Public Overrides Sub PostExecute()
If strDomains.Length > 0 Then
Dim myHtmlMessage As MailMessage
Dim mySmtpClient As SmtpClient
Dim strMessageBody As New StringBuilder
strMessageBody.AppendLine("The listed domains have blah blah blah...")
strMessageBody.Append(strDomains)
strMessageBody.AppendLine(String.Empty)
strMessageBody.AppendLine("Love and Kisses,")
strMessageBody.AppendLine("Your Loving ETL Package")
strMessageBody.AppendLine(Variables.PackageName)
myHtmlMessage = New MailMessage("ETLNotices#company.com", "me#company.com", "Possible Test Domains", strMessageBody.ToString)
mySmtpClient = New SmtpClient("smtp.company.com")
mySmtpClient.Credentials = CredentialCache.DefaultNetworkCredentials
mySmtpClient.Send(myHtmlMessage)
End If
MyBase.PostExecute()
End Sub
Public Overrides Sub Input0_ProcessInputRow(ByVal Row As Input0Buffer)
Dim str As New StringBuilder
str.AppendLine(strDomains)
str.AppendFormat("{0}", Row.DomainName)
strDomains = str.ToString
End Sub
End Class
Chris,
I have some questions:
I guess you are using looping mechanism in your script task to iterate through all the domains ; find test ones among them; append them to a string and at the end send out an email. Is this correct?
Are you sending the mail in the script or created a separate Send Mail task?
Is the body of the your mail coming from some variable from config file?