private static string GenerateReport(Subscription sub, bool isFirst, ref string cookie) { string url = string.Empty; if (isFirst) { string errMsg = string.Empty; string ticket = GetTableauTicket(AppConfig.TableauServerTrusted, sub.DomainUserName, ref errMsg); if (ticket != "-1") { url = WebHelper.BuildUrl(true, ticket, sub); } else { LogHelper.Write(string.Format("{0} doesn't have access to Tableau Server", sub.DomainUserName)); return string.Empty; } } else { url = WebHelper.BuildUrl(false, null, sub); } string fileName = PathHelper.ReportFilePath(sub); DownloadFile(url, fileName, isFirst, ref cookie); return fileName; }
private static void SendEmail(Subscription sub, string fileName) { try { string reportName = StringHelper.GetReportName(sub.ReportPath); string email = StringHelper.GetEmailByDomainUserName(sub.DomainUserName); string subject = string.Format("Tableau report {0} was executed at {1}", reportName, StringHelper.GetDateString()); EmailHelper.SendMail(email, subject, WebHelper.BuildReportUrl(sub), fileName); } catch (Exception ex) { LogHelper.Write(ex.ToString()); } }
private List<Subscription> ParseSubscription(SqlDataReader sqlDataReader) { List<Subscription> subList = new List<Subscription>(); int iSubscription_id = sqlDataReader.GetOrdinal("Subscription_id"); int iDomainUserName = sqlDataReader.GetOrdinal("DomainUserName"); int iReportPath = sqlDataReader.GetOrdinal("ReportPath"); int iReportArgs = sqlDataReader.GetOrdinal("ReportArgs"); while (sqlDataReader.Read()) { Subscription sub = new Subscription() { Subscription_id = int.Parse(sqlDataReader[iSubscription_id].ToString()), DomainUserName = sqlDataReader[iDomainUserName].ToString(), ReportPath = sqlDataReader[iReportPath].ToString(), ReportArgs = sqlDataReader[iReportArgs].ToString() }; subList.Add(sub); } sqlDataReader.Close(); return subList; }