/// <summary> /// 绑定数据到实体 /// </summary> /// <param name="_id"></param> public void BindData2Entity(string _id, JumboTCMS.Entity.Normal_Class _class) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.SqlCmd = "SELECT * FROM [jcms_normal_class] WHERE [Id]=" + _id; DataTable dt = _doh.GetDataTable(); if (dt.Rows.Count > 0) { _class.Id = dt.Rows[0]["Id"].ToString(); _class.ChannelId = Validator.StrToInt(dt.Rows[0]["ChannelId"].ToString(), 0); _class.ParentId = Validator.StrToInt(dt.Rows[0]["ParentId"].ToString(), 0); _class.Title = dt.Rows[0]["Title"].ToString(); _class.Info = dt.Rows[0]["Info"].ToString(); _class.Img = dt.Rows[0]["Img"].ToString(); _class.FilePath = dt.Rows[0]["FilePath"].ToString(); _class.Code = dt.Rows[0]["Code"].ToString(); _class.IsPost = Validator.StrToInt(dt.Rows[0]["IsPost"].ToString(), 0) == 1; _class.IsTop = Validator.StrToInt(dt.Rows[0]["IsTop"].ToString(), 0) == 1; _class.TopicNum = Validator.StrToInt(dt.Rows[0]["TopicNum"].ToString(), 0); _class.TemplateId = Str2Str(dt.Rows[0]["TemplateId"].ToString()); _class.ContentTemp = Str2Str(dt.Rows[0]["ContentTemp"].ToString()); _class.PageSize = Validator.StrToInt(dt.Rows[0]["PageSize"].ToString(), 0); _class.IsOut = Validator.StrToInt(dt.Rows[0]["IsOut"].ToString(), 0) == 1; _class.FirstPage = dt.Rows[0]["FirstPage"].ToString(); _class.ReadGroup = Validator.StrToInt(dt.Rows[0]["ReadGroup"].ToString(), 0); } } }
public void ExecuteTags(ref string PageStr, JumboTCMS.Entity.Normal_Channel _Channel) { PageStr = PageStr.Replace("{$ChannelId}", _Channel.Id.ToString()); PageStr = PageStr.Replace("{$ChannelName}", _Channel.Title); PageStr = PageStr.Replace("{$ChannelInfo}", _Channel.Info); PageStr = PageStr.Replace("{$ChannelType}", _Channel.Type); PageStr = PageStr.Replace("{$ChannelDir}", _Channel.Dir); PageStr = PageStr.Replace("{$ChannelItemName}", _Channel.ItemName); PageStr = PageStr.Replace("{$ChannelItemUnit}", _Channel.ItemUnit); PageStr = PageStr.Replace("{$ChannelLink}", Go2Channel(site.IsHtml, _Channel.Id.ToString(), false)); }
/// <summary> /// 新增购物车商品信息 /// </summary> /// <param name="_cart"></param> /// <returns></returns> public int NewGoods(JumboTCMS.Entity.Normal_UserCart _cart) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.AddFieldItem("UserId", _cart.UserId); _doh.AddFieldItem("ProductId", _cart.ProductId); _doh.AddFieldItem("ProductLink", _cart.ProductLink); _doh.AddFieldItem("BuyCount", _cart.BuyCount); _doh.AddFieldItem("State", 0); _doh.AddFieldItem("CartTime", DateTime.Now.ToString()); int _newid = _doh.Insert("jcms_normal_user_cart"); return _newid; } }
/// <summary> /// 新增购物信息 /// </summary> /// <param name="_goods"></param> /// <returns></returns> public int NewGoods(JumboTCMS.Entity.Normal_UserGoods _goods) { using (DbOperHandler _doh = new Common().Doh()) { _doh.Reset(); _doh.AddFieldItem("UserId", _goods.UserId); _doh.AddFieldItem("OrderNum", _goods.OrderNum); _doh.AddFieldItem("ProductId", _goods.ProductId); _doh.AddFieldItem("ProductName", _goods.ProductName); _doh.AddFieldItem("ProductImg", _goods.ProductImg); _doh.AddFieldItem("ProductLink", _goods.ProductLink); _doh.AddFieldItem("UnitPrice", _goods.UnitPrice); _doh.AddFieldItem("BuyCount", _goods.BuyCount); _doh.AddFieldItem("TotalPrice", _goods.TotalPrice); _doh.AddFieldItem("State", 0); _doh.AddFieldItem("GoodsTime", DateTime.Now.ToString()); int _newid = _doh.Insert("jcms_normal_user_goods"); return _newid; } }
/// <summary> /// 生成内容页 /// </summary> /// <param name="_contentID">内容ID</param> /// <param name="_currentPage">指定的页码,-1表示所有</param> protected void CreateContentFile(JumboTCMS.Entity.Normal_Channel _channel, string _contentID, int _currentPage) { JumboTCMS.DAL.ModuleCommand.CreateContent(_channel.Type, _channel.Id, _contentID, _currentPage); }
/// <summary> /// 生成栏目文件 /// </summary> /// <param name="_classId"></param> /// <param name="CreateParent"></param> protected void CreateClassFile(JumboTCMS.Entity.Normal_Channel _channel, string _classId, bool CreateParent) { JumboTCMS.DAL.TemplateEngineDAL teDAL = new JumboTCMS.DAL.TemplateEngineDAL(_channel.Id); int pageCount = new JumboTCMS.DAL.Normal_ClassDAL().GetContetPageCount(_channel.Id, _classId, true); int maxPage = JumboTCMS.Utils.Int.Min(site.CreatePages, pageCount); string PageStr = string.Empty; for (int i = 1; i < (maxPage + 1); i++) { PageStr = teDAL.GetSiteClassPage(_classId, i); JumboTCMS.Utils.DirFile.SaveFile(PageStr, Go2Class(i, true, _channel.Id, _classId, true)); } doh.Reset(); doh.SqlCmd = "SELECT Id, ParentId FROM [jcms_normal_class] WHERE [IsOut]=0 AND [ChannelId]=" + _channel.Id + " AND [Id]=" + _classId; DataTable dtClass = doh.GetDataTable(); if (dtClass.Rows.Count > 0 && dtClass.Rows[0]["ParentId"].ToString() != "0" && CreateParent == true) { CreateClassFile(_channel, dtClass.Rows[0]["ParentId"].ToString(), true); } dtClass.Clear(); dtClass.Dispose(); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="MailTo">接收人用户名,单封邮件</param> /// <param name="MailSubject">邮件主题</param> /// <param name="MailBody">邮件内容</param> /// <param name="IsHtml">邮件正文是否为HTML格式</param> /// <param name="_MailServer"></param> /// <returns></returns> public static bool SendOK(string MailTo, string MailSubject, string MailBody, bool IsHtml, JumboTCMS.Entity.MailServer _MailServer) { if (_MailServer == null) return false; if (_MailServer.FromAddresss.Count == 0) return false; bool _SendOK = false; for (int i = 0; i < _MailServer.FromAddresss.Count; i++) { JumboTCMS.Utils.Mail.MailMessage message = new JumboTCMS.Utils.Mail.MailMessage(); message.MaxRecipientNum = 80;//最大收件人 message.From = System.Configuration.ConfigurationManager.AppSettings["JumboTCMS:WebmasterEmail"]; message.FromName = _MailServer.FromNames[i].ToString(); string[] _mail = MailTo.Split(','); for (int j = 0; j < _mail.Length; j++) { message.AddRecipients(_mail[j]); } message.Subject = MailSubject; if (IsHtml) message.BodyFormat = JumboTCMS.Utils.Mail.MailFormat.HTML; else message.BodyFormat = JumboTCMS.Utils.Mail.MailFormat.Text; message.Priority = JumboTCMS.Utils.Mail.MailPriority.Normal; message.Body = MailBody; JumboTCMS.Utils.Mail.SmtpClient smtp = new JumboTCMS.Utils.Mail.SmtpClient(_MailServer.SmtpHosts[i].ToString(), Convert.ToInt16(_MailServer.SmtpPorts[i].ToString())); if (smtp.Send(message, _MailServer.FromAddresss[i].ToString(), _MailServer.FromPwds[i].ToString())) { string strXmlFile = HttpContext.Current.Server.MapPath("~/_data/config/jcms(emailserver).config"); JumboTCMS.DBUtility.XmlControl XmlTool = new JumboTCMS.DBUtility.XmlControl(strXmlFile); XmlTool.Update("Mails/Mail[FromAddress=\"" + _MailServer.FromAddresss[i].ToString() + "\"]/Used", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); XmlTool.Save(); XmlTool.Dispose(); _SendOK = true; SaveSucLog(MailTo, _MailServer.FromAddresss[i].ToString(), _MailServer.FromNames[i].ToString(), _MailServer.SmtpHosts[i].ToString()); break;//跳出循环 } else { SaveErrLog(MailTo, _MailServer.FromAddresss[i].ToString(), _MailServer.FromNames[i].ToString(), _MailServer.SmtpHosts[i].ToString(), smtp.ErrMsg + "\r\n当前共有:" + _MailServer.FromAddresss.Count + "个发件人在队列中."); continue; } //try //{ // System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(); // message.From = new System.Net.Mail.MailAddress(_MailServer.FromAddresss[i].ToString(), _MailServer.FromNames[i].ToString(), Encoding.GetEncoding("gb2312")); // string[] _mail = MailTo.Split(','); // for (int j = 0; j < _mail.Length; j++) // { // message.To.Add(_mail[j]); // } // message.Subject = MailSubject; // message.Body = MailBody; // message.IsBodyHtml = IsHtml; // message.Priority = System.Net.Mail.MailPriority.Normal; // message.BodyEncoding = Encoding.GetEncoding("gb2312"); // System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(_MailServer.SmtpHosts[i].ToString()); // smtp.Credentials = new System.Net.NetworkCredential(_MailServer.FromAddresss[i].ToString(), _MailServer.FromPwds[i].ToString()); // smtp.Send(message); // string strXmlFile = HttpContext.Current.Server.MapPath("~/_data/config/jcms(emailserver).config"); // JumboTCMS.DBUtility.XmlControl XmlTool = new JumboTCMS.DBUtility.XmlControl(strXmlFile); // XmlTool.Update("Mails/Mail[FromAddress=\"" + _MailServer.FromAddresss[i].ToString() + "\"]/Used", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); // XmlTool.Save(); // XmlTool.Dispose(); // _SendOK = true; // break;//跳出循环 //} //catch (Exception) //{ } } return _SendOK; }