public bool SendReportsViaEmail() { List <ReportSubscription> subscriptions = new List <ReportSubscription>(); using (IDataReader dr = new ReportsDAO().GetSubscriptions()) { //napchac do subscriptions while (dr.Read()) { ReportSubscription s = new ReportSubscription(); s.ReportName = dr["ReportName"].ToString(); s.ReportTitle = "Raport z systemu eSoda"; s.Format = dr["Format"].ToString(); s.Filename = "Raport"; s.EmailAddress = dr["emailAddress"].ToString(); XElement p = XElement.Parse(dr["xmlParams"].ToString()); s.ParamOUID = p.Descendants("ouID").First().Value; s.ParamYear = p.Descendants("year").FirstOrDefault() != null?p.Descendants("year").FirstOrDefault().Value : null; s.ParamJRWA = p.Descendants("jrwa").FirstOrDefault() != null?p.Descendants("jrwa").FirstOrDefault().Value : null; s.ParamDaysFrom = p.Descendants("daysFrom").FirstOrDefault() != null?p.Descendants("daysFrom").FirstOrDefault().Value : null; s.ParamDaysTo = p.Descendants("daysTo").FirstOrDefault() != null?p.Descendants("daysTo").FirstOrDefault().Value : null; if (s.ParamJRWA == "") { s.ParamJRWA = null; } if (s.ParamDaysFrom == "") { s.ParamDaysFrom = null; } if (s.ParamDaysTo == "") { s.ParamDaysTo = null; } subscriptions.Add(s); } } foreach (ReportSubscription subsc in subscriptions) { SendReport(subsc); } return(true); }