public string GetSendeBanner() { var banners = new List <string>(); banners.Add("<img src=\"uploads/events/here_could.png\" />"); for (var i = 0; i < 14; i++) { var d_ts = GetMonday().AddDays(i).Subtract(new DateTime(1970, 1, 1)).TotalSeconds; var dbEntry = db.SQLQuery <T>(string.Format("SELECT banner FROM sendeplan WHERE spident='{0}' AND timestamp >= '{1}'", spident, d_ts)); if (dbEntry.Count == 0) { continue; } for (var ib = ulong.MinValue; ib < (ulong)dbEntry.Count; ib++) { var _ib = (T)Convert.ChangeType(ib, typeof(T)); if (!string.IsNullOrEmpty(dbEntry[_ib]["banner"])) { if (fs.Exists(Filesystem.Combine("uploads/events/", dbEntry[_ib]["banner"]))) { banners.Add(string.Format("<img src=\"uploads/events/{0}\" />", dbEntry[_ib]["banner"])); } } } } return(banners.Count != 0 ? banners[new Random().Next(0, banners.Count)] : string.Empty); }
/// <summary> /// Read a Template from the backend server or from a local file. /// </summary> /// <param name="fs">the Filesystem instance.</param> /// <param name="name">The Name of the Template</param> /// <param name="cookies">Cookies which needs to be passed to the Backend.</param> /// <returns>The parsed Template with Content.</returns> public static string ReadTemplate(Guid userid, string name, HttpListenerContext context, string extradata, Dictionary <string, string> parameters) { if (name.Contains("~")) { name = name.Replace("##UID##", userid.ToString()); var parts = name.Split('~'); var provider = parts[0]; var id = parts[1]; // In Version 3 des Dispatcher kann das Template auch Optionen beinhalten xD if (parts[0].Contains("(") && parts[0].Contains(")")) { provider = parts[0].Substring(0, parts[0].IndexOf("(")); var options = ExtractString(parts[0], "(", ")").Split(';'); foreach (var item in options) { var option = item.Split(':'); if (option[0] == "Load") { if (!parameters.ContainsKey("Request-Type")) { parameters.Add("Request-Type", option[1]); } } if (option[0] == "Target") { if (!parameters.ContainsKey("Target")) { parameters.Add("Target", option[1]); } else { parameters["Target"] = option[1]; } } } } var response = MakeBackendRequest(userid, provider, id, extradata, context, parameters); return(response); } else { using (var _fs = new Filesystem(Filesystem.Combine(Environment.CurrentDirectory, "http_root"))) { var tpl_path = string.Format("templates/{0}.tpl", name.Replace("-", "_")); if (!_fs.Exists(tpl_path)) { return(string.Format("<p class=\"exclaim\">Template \"{0}\" not found!</p>", name)); } var output = _fs.Read(tpl_path).Result; return(Encoding.UTF8.GetString(output, 0, output.Length)); } } }