public IHttpActionResult CadastrarEmpresa([FromBody] dynamic jsonPostData) { try { Empresa empresa = JsonConvert.DeserializeObject <Empresa>(jsonPostData.empresa.ToString()) as Empresa; if (empresa.Id == 0) { var host = HttpContext.Current.Request.UrlReferrer.AbsoluteUri; string link = host + "#/admEmpresas/" + empresa.Cnpj; var lstParametros = new List <KeyValuePair <string, string> >(); lstParametros.Add(new KeyValuePair <string, string>("@cnpj", empresa.Cnpj)); lstParametros.Add(new KeyValuePair <string, string>("@nome", empresa.Nome)); lstParametros.Add(new KeyValuePair <string, string>("@razaoSocial", empresa.RazaoSocial)); lstParametros.Add(new KeyValuePair <string, string>("@link", link)); EmailApp.RegistrarSenha(empresa.Email, lstParametros); empresa.Perfil = PerfilEnum.Administrador; empresa.Senha = null; } _uow.BeginTransaction(); _empresaRep.SaveOrUpdate(empresa); _uow.Execute(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public void DownLoadEmailFiles(string keyvalue, string type) { var data = new EmailApp().Email_Path(keyvalue); string filename = ""; string filepath = ""; if (type == ".zip") { //文件名 filename = Server.UrlDecode(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/") + 1)); //路径 filepath = Server.MapPath(data.PF_Src); } else { filename = Server.UrlDecode(type); filepath = Server.MapPath(data.PF_Src.Replace(data.PF_Src.Substring(data.PF_Src.LastIndexOf("/")), "") + "/" + filename); } filepath = filepath.Replace("\\Email\\DownLoadEmailFiles", ""); // return File(new System.IO.FileStream(filepath, System.IO.FileMode.Open), "application/octet-stream", filename); if (FileDownHelper.FileExists(filepath)) { FileDownHelper.DownLoadold(filepath, filename); } }
public ActionResult Email_Deatil(string id) { var emailApp = new EmailApp(); if (!string.IsNullOrWhiteSpace(id)) { var entity = emailApp.Email_Detail(id); var email_path = emailApp.Email_Path(id); var accountinfo = emailApp.AccountInfo(entity.PF_Out_UserID); var data = new { // email_key = id, Title = entity.PF_Title, Msg = entity.PF_MSG, Time = entity.PF_CreateTime, Send = accountinfo == null ? null:accountinfo.PF_UName, Path_Zip = email_path == null ? null: email_path.PF_Src, //下载全部 zip地址 Path_Png = email_path == null ? null : email_path.PF_FileName, //文件路径 可能多个 Doc_Count = email_path == null ? null : email_path.PF_FileName.Split(',').Count().ToString() //文件数量 }; return(Content(data.ToJson())); } else { return(Content(null)); } }
public void TrimStringHelper1Arg() { var template = HandlebarsDotNet.Handlebars.Compile("{{substring $Level}}"); var data = Some.LogEvent(); var result = EmailApp.FormatTemplate(template, data, Some.Host()); Assert.Equal("Fatal", result); }
public void IfEqHelperDetectsInequality() { var template = HandlebarsDotNet.Handlebars.Compile("{{#if_eq $Level \"Warning\"}}True{{/if_eq}}"); var data = Some.LogEvent(); var result = EmailApp.FormatTemplate(template, data, Some.Host()); Assert.Equal("", result); }
public void BuiltInPropertiesAreRenderedInTemplates() { var template = HandlebarsDotNet.Handlebars.Compile("{{$Level}}"); var data = Some.LogEvent(); var result = EmailApp.FormatTemplate(template, data, Some.Host()); Assert.Equal(data.Data.Level.ToString(), result); }
public void PayloadPropertiesAreRenderedInTemplates() { var template = HandlebarsDotNet.Handlebars.Compile("See {{What}}"); var data = Some.LogEvent(new Dictionary <string, object> { { "What", 10 } }); var result = EmailApp.FormatTemplate(template, data, Some.Host()); Assert.Equal("See 10", result); }
public ActionResult EmailBoxList(int page, int index) { var count = new EmailApp().GetEmailCount(-1); //返回当前第几页 var data = new { _index_count = count / page + count % page, //总条数/页规格 = 总页数 _index = index, //当前页数 email = new EmailApp().GetEmailList(page, index), }; return(Content(data.ToJson())); }
public ActionResult GetSendUser(string id) { if (!string.IsNullOrWhiteSpace(id)) { var email = new EmailApp().Email_Detail(id); var user = new EmailApp().AccountInfo(email.PF_Out_UserID).PF_UName; return(Content(user)); } else { return(null); } }
public ActionResult MarkedRead(string keys) { var i = new EmailApp().MarkedRead(keys); if (i > 0) { return(Content(new AjaxResult { state = ResultType.success.ToString(), message = "变更成功" }.ToJson())); } else { return(Content(new AjaxResult { state = ResultType.error.ToString(), message = "变更失败" }.ToJson())); } }
public void NoPropertiesAreRequiredOnASourceEvent() { var template = HandlebarsDotNet.Handlebars.Compile("No properties"); var id = Some.EventId(); var timestamp = Some.UtcTimestamp(); var data = new Event <LogEventData>(id, Some.EventType(), timestamp, new LogEventData { Exception = null, Id = id, Level = LogEventLevel.Fatal, LocalTimestamp = new DateTimeOffset(timestamp), MessageTemplate = "Some text", RenderedMessage = "Some text", Properties = null }); var result = EmailApp.FormatTemplate(template, data, Some.Host()); Assert.Equal("No properties", result); }
public void ToAddressesAreTemplated() { var mail = new CollectingMailGateway(); var reactor = new EmailApp(mail) { From = "*****@*****.**", To = "{{Name}}@example.com", Host = "example.com" }; reactor.Attach(new TestAppHost()); var data = Some.LogEvent(new Dictionary <string, object> { { "Name", "test" } }); reactor.On(data); var sent = mail.Sent.Single(); Assert.Equal("*****@*****.**", sent.Message.To.ToString()); }