Crystal reports not working after creating project setup - crystal-reports

I have created some Crystal Reports for my Windows Project. They function fine when I run them on Visual Studio. (I am using VS 2010). But they wont work after I created the setup project and install the software on the Client PC. I get the following errors:
http://tistus.srilanka-erickson.com/errors.html
Following displayed is the button click event code that I have used to Load the crystal Report: First try clause has been used to register custom inputs to the Report, meanwhile the second try clause has been used to manually create the database connection to the report. third try clause has been used just to load the report.
private void buttonGenerateSecExportRpt_Click(object sender, EventArgs e)
{
CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
if (comboBoxSecPlateType.Text != "" && comboBoxSecExPlateBrand.Text != "")
{
try
{
dtFrom.Format = DateTimePickerFormat.Custom;
string periodfrom = dtFrom.Value.ToString("yyyy/MM/dd");
dtTo.Format = DateTimePickerFormat.Custom;
string periodto = dtTo.Value.ToString("yyyy/MM/dd");
//cryRpt.VerifyDatabase();
string fullPath = "..\\..\\SecondaryPlateExportReport.rpt";
cryRpt.Load(fullPath);
cryRpt.SetParameterValue("dateFromChecked", dtFrom.Checked);
cryRpt.SetParameterValue("dateToChecked", dtTo.Checked);
cryRpt.SetParameterValue("dtPeriodFrom", periodfrom);
cryRpt.SetParameterValue("dtPeriodTo", periodto);
cryRpt.SetParameterValue("PlateType", comboBoxSecPlateType.Text.Trim());
cryRpt.SetParameterValue("PlateBrand", comboBoxSecExPlateBrand.Text.Trim());
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
DbConnectionInfo.SetConnectionString(ConfigurationManager.ConnectionStrings["con"].ToString());
TableLogOnInfo logOnInfo;
ConnectionInfo connectionInfo;
foreach (Table table in cryRpt.Database.Tables)
{
logOnInfo = table.LogOnInfo;
connectionInfo = logOnInfo.ConnectionInfo;
// Set the Connection parameters.
connectionInfo.DatabaseName = DbConnectionInfo.InitialCatalog;
connectionInfo.ServerName = DbConnectionInfo.ServerName;
if (!DbConnectionInfo.UseIntegratedSecurity)
{
connectionInfo.Password = DbConnectionInfo.Password;
connectionInfo.UserID = DbConnectionInfo.UserName;
}
else
{
connectionInfo.IntegratedSecurity = true;
}
table.ApplyLogOnInfo(logOnInfo);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
crystalReportViewerSecEx.ReportSource = cryRpt;
crystalReportViewerSecEx.Refresh();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Please select both Plate Type and the Brand to Generate the Report!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
I want to make the crystal reports work after deploying the software on the client PCs. Any suggestions would be greatly appreciated!

crystalReport.Load(#"C:\WINDOWS\Temp\samridhi.rpt");
when u creating setup put ur crystal report path like this
and
go to "C:\WINDOWS\Temp"
and copy ur rpt and .cs file go to "C:\WINDOWS\Temp" by mycomputer not by run prompt
for not setup just to check crystal report path in project application here is
the path is
crystalReport.Load(System.Windows.Forms.Application.StartupPath + "\\samridhi.rpt");

Shehan,
It is best not to use hard-codeed paths in any .NET project. It is best if you use the Server.MapPath variable and build your string dynamically.
As an example add the using System.IO to your project. You can then use the Path.Combine method to build your string.
string mappath = HttpContext.Current.Server.MapPath("~/");
Path.Combine(mappath, "Report Folder Path", "FileName.rpt");
You can even place "Report Folder Path" into static string so that it can be called multiple times without fear of change.

Related

How to save/share a file in Net. Maui without savefiledialog?

My MauiBlazorApp can create a .pdf file. In what ways can I make this file accessible for the users of windows/android/IOS. A SaveFile Dialog is not yet implemented in Maui. With this path
string SaveToPath = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory, "hello.pdf");
I can save it on a windows machine and open it (tested).
The path (FileSystem.Current.AppDataDirectory) on a local android device (phone connected to windows maschine via usb) is something like this:
/data/user/0/com.companyname.appname/files/hello.pdf
But later I can't find this folder on my phone. I find this:
/data/com.companyname.appname/cache/ empty folders all the way
Why can't I save a file in .../downloads
How do you import/export data from 'device to device' in Maui? Files seems to be not the way. Email with attechments? Is that possible/better?
You can check the Maui File picker, It provides the method you can pick the file from the device.
public async Task<FileResult> PickAndShow(PickOptions options)
{
try
{
var result = await FilePicker.Default.PickAsync(options);
if (result != null)
{
if (result.FileName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) ||
result.FileName.EndsWith("png", StringComparison.OrdinalIgnoreCase))
{
using var stream = await result.OpenReadAsync();
var image = ImageSource.FromStream(() => stream);
}
}
return result;
}
catch (Exception ex)
{
// The user canceled or something went wrong
}
return null;
}
In addition, you can refer to Folder Picker .NET MAUI. This is more detailed.

SSIS - Redirecting Email to Folder

I am generating emails from an SSIS package using a Script task. During testing, I do not want to really send the email, but drop the message into a folder. In an application, I would use the specifiedPickupDirectory option in the web.config, but SSIS packages do not have a web.config.
Is there a way to send the email to a folder?
Thanks
If you script task is using C# then the following should work. It's similar to how you would change the Web.config to use specifiedPickupDirectory
SmtpClient client = new SmtpClient("my_smtp_host");
client.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
client.PickupDirectoryLocation = #"C:\save_email_directory";
client.Send(message);
You may also need to add Network credentials, see link for example
If you use Exchange mail and this library: http://independentsoft.de/ you can create a message and move it into a specific folder.
I do not own this software, but I'm a satisfied user.
Just start here: http://independentsoft.de/exchangewebservices/tutorial/createmessage.html with this example code:
using System;
using System.Net;
using Independentsoft.Exchange;
namespace Sample
{
class Program
{
static void Main(string[] args)
{
NetworkCredential credential = new NetworkCredential("username", "password");
Service service = new Service("https://myserver/ews/Exchange.asmx", credential);
try
{
Message message = new Message();
message.Subject = "Test";
message.Body = new Body("Body text");
message.ToRecipients.Add(new Mailbox("John#mydomain.com"));
message.CcRecipients.Add(new Mailbox("Mark#mydomain.com"));
ItemId itemId = service.CreateItem(message);
}
catch (ServiceRequestException ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.WriteLine("Error: " + ex.XmlMessage);
Console.Read();
}
catch (WebException ex)
{
Console.WriteLine("Error: " + ex.Message);
Console.Read();
}
}
}
}

Netbeans plugin (read code)

I make a basic plugin on netbeans 8.0.2 and I'm a little confused because I want to read the code in some way to provide errors or other notifications to the user you are writing code but not how.
This should print out all the text in all the open windows.
TopComponent tcArray[] = WindowManager.getDefault().findMode("editor").getTopComponents();
for (TopComponent tc : tcArray) {
System.out.println("tc = " + tc);
Collection<? extends FileObject> fileobjs = tc.getLookup().lookupAll(FileObject.class);
for (FileObject fo : fileobjs) {
try {
String text = fo.asText();
System.out.println("text = " + text);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
}
In order to use it you need the following modules added as dependencies.
File System API
Lookup API
Utilities API
Window System API

How to debug a server-side (.rdl) report that does not work in my application?

I have a SQL Server Report Server (SSRS) that hosts a bunch of reports. When I click on the provided URL, I can navigate to the report, drilling down the path, and I can successfully run the report by passing it the required parameters. The Stored Procedures used by the report are hosted in a database that uses Windows Authentication.
However, when I try to call the same report from my application, I cannot see anything.
Here is the code I use. Upon clicking on a button, I execute this code:
var reportViewer = new ReportViewer();
// Set Processing Mode
reportViewer.ProcessingMode = ProcessingMode.Remote;
// Set report server and report path
reportViewer.ServerReport.ReportServerUrl = new Uri("http://MySsrsServer/reportserver");
reportViewer.ServerReport.ReportPath = "/Reports/MyReport";
// set the credentials
reportViewer.ServerReport.ReportServerCredentials.ImpersonationUser = WindowsIdentity.GetCurrent();
// create report parameters and set them in the report
var param1 = new ReportParameter("First_Param", "Some string");
var param2 = new ReportParameter("Second_Param", "Some other string");
reportViewer.ServerReport.SetParameters(new ReportParameter[] { param1, param2 });
using (var reportForm = new ReportForm(reportViewer))
{
reportForm.ShowDialog();
}
The ReportForm is just a regular Form that has a member of type ReportViewer. In the class constructor I assign the member:
public ReportForm(ReportViewer reportViewer)
{
InitializeComponent();
try
{
this.reportViewer = reportViewer;
reportViewer.SetDisplayMode(DisplayMode.PrintLayout);
reportViewer.Dock = DockStyle.Fill;
reportViewer.ZoomMode = ZoomMode.Percent;
reportViewer.ZoomPercent = 100;
reportViewer.RefreshReport();
}
catch (Exception exception)
{
MessageBox.Show(exception.Message);
}
}
As I said, I can see the report being correctly executed from Server, but not from my application. The content of the ReportForm is empty, but I do not get any exceptions being thrown.
Any idea what is it I am doing wrong?
TIA,
E
Turns out that constructing the ReportViewer object outside the form where the report is to be displayed and then passing it inside the constructor of the form in order to assign it to the inner ReportViewer object is not a good idea. I don't know what's happening behind the scene, perhaps some bindings between the ReportViewr instance and the GUI control that is to show the report are broken.

How to checkout a file using sharpsvn

I tried to checkout a file using sharpsvn from remote repository,but i found sharpsvn can not to checkout single file only checkout folder,please help me to know how to checkout a file?Thx.
My code
SvnUpdateResult result;
SvnCheckOutArgs checkoutArgs = new SvnCheckOutArgs();
string target = txtRepository.Text.Trim();
SvnUriTarget url = new SvnUriTarget(target);
string fileName = url.FileName;
string path = folder + "\\" + fileName;
using (SvnClient client = new SvnClient())
{
try
{
client.CheckOut(url,txtLocalFilePath.Text.Trim(),out result);//.Update(path,updateArgs,out result);
if (result != null)
{
WriteCheckOutTime(txtRepository.Text.Trim(), result.Revision);
MessageBox.Show("Check out success!", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
}
catch (SvnException svnException)
{
MessageBox.Show(svnException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
catch (UriFormatException uriException)
{
MessageBox.Show(uriException.Message + "Check out error!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
The smallest element you can check out with Subversion is a directory. It is not possible to check out a single file.
You can check out a directory, but leave it empty, via the Sparse Directories feature. Then update only the file you're interested in. But you must start with a directory.
FYI if you want to checkout empty use following syntax
//first define args
SvnCheckOutArgs args = new SvnCheckOutArgs();
// then for checkout only forlder empty
args.Depth = SvnDepth.Empty;
//checkout folder
client.CheckOut(url,txtLocalFilePath.Text.Trim(),args,out result)