/// <summary> /// 创建一个新的统计账户 /// </summary> /// <returns></returns> public StatisticsAccount CreatNewAccount() { ISiteSettingsManager siteSettingsManager = DIContainer.Resolve <ISiteSettingsManager>(); SiteSettings siteSettings = siteSettingsManager.Get(); string key = EncryptionUtility.MD5(siteSettings.MainSiteRootUrl + "A4ba4oqS").ToLower(); string creatLink = string.Format("http://wss.cnzz.com/user/companion/spacebuilder.php?domain={0}&key={1}", siteSettings.MainSiteRootUrl, key); string webMatter = HttpCollects.GetHTMLContent(creatLink, Encoding.GetEncoding("gb2312"), null); string errorMessage = null; switch (webMatter.Trim()) { case "": errorMessage = "远程站点没有响应"; break; case "-1": errorMessage = "key输入有误"; break; case "-2": errorMessage = "该域名长度有误(1~64)"; break; case "-3": errorMessage = "域名输入有误(比如输入汉字)"; break; case "-4": errorMessage = "域名插入数据库有误"; break; case "-5": errorMessage = "同一个IP用户调用页面超过阀值,阀值暂定为10"; break; } if (!string.IsNullOrEmpty(errorMessage)) { throw new Exception("创建统计帐号出错,错误信息:" + errorMessage); } string siteIdStr = webMatter.Substring(0, webMatter.IndexOf('@')); string passwordStr = webMatter.Substring(webMatter.IndexOf('@') + 1); long siteId = 0; long password = 0; StatisticsAccount account = new StatisticsAccount(); if (long.TryParse(siteIdStr, out siteId) && long.TryParse(passwordStr, out password)) { account.Password = password.ToString(); account.UserName = siteId.ToString(); return(account); } return(null); }
public void ParseHtml(string url, ref ShareThread shareThread) { string htmlContent = HttpCollects.GetHTMLContent(url); if (string.IsNullOrEmpty(htmlContent)) { return; } shareThread = new ShareThread(url, GetPlayerUrlString(url), MediaType.Video, HttpCollects.GetTitle(htmlContent, true), HttpCollects.GetDescription(htmlContent, true), GetThumbnailUrlString(htmlContent, true), DateTime.Now); }
public void ParseHtml(string url, ref ShareThread shareThread) { string ThumbnailUrlString = string.Empty; string htmlContent = HttpCollects.GetHTMLContent(url); if (string.IsNullOrEmpty(htmlContent)) { return; } string PlayerUrl = GetPlayerUrlString(url, htmlContent, out ThumbnailUrlString);//换取url里的参数来设置播放器地址并且从页面里获取播放器地址的参数Sid和缩略图 //新实例 shareThread = new ShareThread(url, PlayerUrl, MediaType.Video, HttpCollects.GetTitle(htmlContent, true), HttpCollects.GetDescription(htmlContent, true), ThumbnailUrlString, DateTime.Now); return; }
/// <summary> /// 生成MailMessage /// </summary> /// <param name="templateName">邮件模板名称</param> /// <param name="model">解析模板使用的数据</param> /// <param name="from">发件人</param> /// <param name="to">收件人</param> /// <param name="cc">抄送地址</param> /// <param name="bcc">密送地址</param> /// <exception cref="CommonExceptionDescriptor">发件人不能为null</exception> /// <exception cref="CommonExceptionDescriptor">编译邮件模板标题时报错</exception> /// <exception cref="CommonExceptionDescriptor">编译邮件模板内容时报错</exception> /// <exception cref="CommonExceptionDescriptor">邮件模板中Body、BodyUrl必须填一个</exception> /// <returns>返回生成的MailMessage</returns> public MailMessage Resolve(string templateName, dynamic model, IEnumerable <string> to, string from = null, IEnumerable <string> cc = null, IEnumerable <string> bcc = null) { if (to == null) { return(null); } if (model == null) { model = new ExpandoObject(); } IEmailSettingsManager emailSettingsManager = DIContainer.Resolve <IEmailSettingsManager>(); EmailSettings settings = emailSettingsManager.Get(); //if (settings.SmtpSettings.ForceSmtpUserAsFromAddress) // from = settings.SmtpSettings.UserEmailAddress; EmailTemplate emailTemplate = GetEmailTemplate(templateName); if (string.IsNullOrEmpty(from)) { if (string.Equals(emailTemplate.From, "NoReplyAddress", StringComparison.CurrentCultureIgnoreCase)) { from = settings.NoReplyAddress; } else if (string.Equals(emailTemplate.From, "AdminAddress", StringComparison.CurrentCultureIgnoreCase)) { from = settings.AdminEmailAddress; } else { throw new ExceptionFacade(new CommonExceptionDescriptor("发件人不能为null")); } } MailMessage email = new MailMessage(); email.IsBodyHtml = true; try { //todo all by bianchx:为了保证发送出去的邮件发送人名称显示都是相同的,所以需要保证Model中的SiteName都是有效的 email.From = new MailAddress(from, model.SiteName); } catch { } foreach (var toAddress in to) { try { email.To.Add(toAddress); } catch { } } if (cc != null) { foreach (var ccAddress in cc) { try { email.CC.Add(ccAddress); } catch { } } } if (bcc != null) { foreach (var bccAddress in bcc) { try { email.Bcc.Add(bccAddress); } catch { } } } //使用RazorEngine解析 EmailTemplate.Subject try { email.Subject = Razor.Parse(emailTemplate.Subject, model, emailTemplate.TemplateName); } catch (Exception e) { throw new ExceptionFacade(new CommonExceptionDescriptor("编译邮件模板标题时报错"), e); } email.Priority = emailTemplate.Priority; if (!string.IsNullOrEmpty(emailTemplate.Body)) { try { email.Body = Razor.Parse(emailTemplate.Body, model, emailTemplate.Body); } catch (Exception e) { throw new ExceptionFacade("编译邮件模板内容时报错", e); } } else if (!string.IsNullOrEmpty(emailTemplate.BodyUrl)) { email.Body = HttpCollects.GetHTMLContent(emailTemplate.BodyUrl); } else { throw new ExceptionFacade("邮件模板中Body、BodyUrl必须填一个"); } return(email); }