private void BindReport(string p, int p_2) { SSRSReport report = new SSRSReport(); SqlParameter[] sqlParams = new SqlParameter[] { new SqlParameter("@Add_Source_Id", 25), new SqlParameter("@Add_Source_Type", "Employee") }; string ReportDataSource = "DataSet1"; bool bind = report.CreateReport(Connectionstring, "Get_Address_sp", sqlParams, ref ReportViewer1, ReportDataSource); if (bind) { ReportViewer1.Visible = true; } }
public JsonResult _ExportTicketToPDF(string id) { try { Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("ScaleID", id); SSRSReport ssrsHelper = new SSRSReport("QScale.rdl", parameter); string attachment = ssrsHelper.ExportReportToPDF(); string appPath = ConfigurationHelper.GetsmARTQBIntegrationBatchFilePath(); string batchFilePath = Path.Combine(appPath, "PrintTicekt.bat"); string filename = Path.Combine(ConfigurationHelper.GetsmARTPrintFilePath(), id + ".pdf"); //PDF.PrintPDFs(filename); return(Json(new { Path = batchFilePath }, JsonRequestBehavior.AllowGet)); } catch (Exception) { var data = new { Sucess = false }; return(Json(data, JsonRequestBehavior.AllowGet)); } }
public ActionResult SendEmail(string id) { try { if (string.IsNullOrEmpty(id)) { throw new Exception("Email send failed due to scale ID not found."); } ScaleLibrary scaleLib = new ScaleLibrary(ConfigurationHelper.GetsmARTDBContextConnectionString()); Scale scale = scaleLib.GetByID(id, new string[] { "Party_ID" }); if (scale == null || scale.Party_ID == null || scale.Ticket_Type != "Receiving Ticket" || scale.Ticket_Status != "Close") { throw new Exception("Email send failed."); } IEnumerable <Contact> contacts = Helpers.ContactHelper.GetEmailContactsByPartyId(scale.Party_ID.ID); if (contacts.Count() <= 0) { throw new Exception("There is no email contact exists."); } NotificationDefinition notDef = new NotificationDefinition(); notDef.ToRecipients = new System.Net.Mail.MailAddressCollection(); foreach (var item in contacts) { notDef.ToRecipients.Add(new System.Net.Mail.MailAddress(item.Email, item.ListText)); } EmployeeHelper employeeHelper = new EmployeeHelper(); Employee employee = employeeHelper.GetEmployeeByUsername(System.Web.HttpContext.Current.User.Identity.Name); if (employee == null || string.IsNullOrEmpty(employee.Email) || string.IsNullOrEmpty(employee.Email_Password)) { throw new Exception("Sender email and password is required."); } string xslPath = Path.Combine(ConfigurationHelper.GetsmARTXslPath(), "ScaleEmailBody.xslt"); string smtpAddress = ConfigurationHelper.GetsmARTSMTPServer(); Dictionary <string, object> parameter = new Dictionary <string, object>(); parameter.Add("ScaleID", id); SSRSReport ssrsHelper = new SSRSReport("ScaleReceiveTicket.rdl", parameter); string attachment = ssrsHelper.ExportReportToPDF(); if (string.IsNullOrEmpty(attachment)) { throw new Exception("There is no attachment found."); } notDef.Attachments = new List <System.Net.Mail.Attachment>(); notDef.Attachments.Add(new System.Net.Mail.Attachment(attachment)); notDef.DeliveryType = EnumNotificationDeliveryType.Email; notDef.FormatType = EnumFormatType.HTML; notDef.Sender = new System.Net.Mail.MailAddress(employee.Email, employee.Emp_Name); notDef.SMTPServer = smtpAddress; notDef.SMTPServerCredentialID = employee.Email; notDef.SMTPServerCredentialPwd = employee.Email_Password; notDef.Subject = "Ticket#" + id.ToString(); NotificationHelper.StartNotificationWF(id, scale.Party_Name, PartyHelper.GetOrganizationName(), employee.Emp_Name, notDef, xslPath, NotificationWFCompleted); //return Display(command, container); if (_sendMail == true) { return(Json(new { Sucess = "Email send sucessfully." }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { Sucess = "Email send failed." }, JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { return(Json(new { Sucess = ex.Message }, JsonRequestBehavior.AllowGet)); } }