public static UnitOfWork GetUnitOfWork(Map map) { var cached = map["cached"] as UnitOfWork; if (cached != null) { Logger.InfoFormat("Trova in cache la UnitOfWork id {0}", cached.Uid); return cached; } var def = _mapPlugins.GetMap(map.GetString("type")); if (def == null) { Logger.WarnFormat("Tipo unit sconosciuto {0}", map.GetString("type")); return null; } cached = (UnitOfWork)(Activator.CreateInstance(def["type"] as Type) as UnitOfWork).Copy(map); map["cached"] = cached; Logger.InfoFormat("Mette in cache la UnitOfWork id {0} tipo {1}", cached.Uid, map.GetString("type")); return cached; }
private void SendMail(Map dati, Map config) { if (dati.GetString("smtpServer") == string.Empty) return; // tratto da http://blogs.ugidotnet.org/PietroLibroBlog/archive/2008/08/06/93635.aspx var message = new MailMessage(); message.From = new MailAddress(dati.GetString("mittente")); message.To.Add(dati.GetString("destinatari")); message.Subject = dati.GetString("oggetto"); message.IsBodyHtml = true; message.Body = dati.GetString("testo"); var smtpClient = new SmtpClient(config.GetString("smtpServer"), config.GetInt("smtpPort", 25)); if (config.ContainsKey("smtpUser")) { smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(config.GetString("smtpUser"), config.GetString("smtpPassword")); } smtpClient.Send(message); }
public static string EvalExpression(string expression, Map vars) { int pos1, pos2; for (pos1 = expression.IndexOf('@'); pos1 != -1; pos1 = expression.IndexOf('@', pos1)) { for (pos2 = pos1 + 1; pos2 < expression.Length; pos2++) if (!IsIdentifier(expression[pos2])) break; string var = expression.Substring(pos1, pos2 - pos1); expression = expression.Replace(var, vars.GetString(var.Substring(1))); } return expression; }